#include "StdAfx.h" #include "CFilePlugin.h" #include "CFilePluginList.h" #include "CProgramPlugin.h" #include "CResFile.h" #include "GlobalFunc.h" #include "T2Archive.h" #include "T2DateTime.h" #include "T2DLL.h" #include "T2EquipPtrList.h" #include "T2FloorInfo.h" #include "T2Name.h" #include "T2NameList.h" #include "T2People.h" #include "T2PeopleArrayList.h" #include "T2PluginLoader.h" #include "T2PluginSpecifier.h" #include "T2Pool.h" #include "T2RegistedTenantDB.h" #include "T2SoundPlayer.h" #include "T2Tenant.h" #include "../T2TowerDoc.h" #include "T2TowerEvent.h" #include "T2TowerMessage.h" #include "T2WorldDef.h" #include "T2VisitVIP.h" T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, CResFile* inResFile, int inSubID) : T2EventItem(inTowerEvent, inResFile, inSubID) { int cycleDay = mCycleDay; mSilhouetteType = 0; int numVIPs; *inResFile >> numVIPs; T2VisitVIP *theVIP; for (int i = 0; i < numVIPs; i++) { theVIP = (i == 0) ? this : new T2VisitVIP(mTowerEvent, inSubID + i, mLevelBit, mExclusive, mCycleDay, mBeginTime, mEndTime); if (theVIP) theVIP->Init(inResFile); if (theVIP != this) mTowerEvent->AppendStandby(theVIP); } } T2VisitVIP::T2VisitVIP(T2TowerEvent* inTowerEvent, int inSubID, int inLevelBit, BOOL inExclusive, int inCycleDay, int inBeginTime, int inEndTime) : T2EventItem(inTowerEvent, inSubID, inLevelBit, inExclusive, inCycleDay, inBeginTime, inEndTime) { mSilhouetteType = 0; } /*virtual*/ T2VisitVIP::~T2VisitVIP() { } /*virtual*/ BOOL T2VisitVIP::IsBeginDay(int inDay) { if (inDay > mBeginDay) mBeginDay = inDay; return (mBeginDay == inDay); } /*virtual*/ BOOL T2VisitVIP::IsBeginTime(unsigned int inTime) { return (mBeginTime == inTime); } /*virtual*/ BOOL T2VisitVIP::Start(T2TowerDoc* inDoc) { BOOL mysteriousUnusedVar = true; T2WorldDef *theWorldDef = GetWorldDef(); mStatus = kVisitVIPStatus0; mCheckedIn = false; mPeopleID = 0; mTenantID = 0; if (mGrade <= theWorldDef->mNumOfGradeDef && inDoc->GetLevel() == mGrade) { GradeDef *theGrade = &theWorldDef->mGradeDef[mGrade - 1]; if ((theGrade->m0 & mVisitFlag) != 0 && (inDoc->mA0 & mVisitFlag) == 0) { T2Pool *thePool = inDoc->GetPool(); if (thePool && thePool->GetPopulation() > (theGrade->m4 / 2)) { T2Tenant *theTenant = NULL; CFilePlugin *thePlugin = NULL; T2PluginSpecifier *theSpecifier = NULL; if (GetDestinationTennant(mTenantPluginID, theTenant, thePlugin, theSpecifier)) { if (theTenant && thePool) { T2People *theVIP = thePool->BornVIP(mSilhouetteType, -1); if (theVIP) { CString tmp; CString text; theVIP->GetName(text); T2Name *theName = inDoc->mNameDB->Search(theVIP); if (theName) { theName->SetName(text); } else { T2Name *newName = new T2Name(text, theVIP, false); inDoc->mNameDB->Add(newName); } theVIP->mColor = 14; if (theTenant->GetRegistID() == kTenantRegistID1) { theTenant->RegistBelongPeople(theVIP); theVIP->SetDestination(theTenant->GetRelatedTenantID(), mArrivalTime); theTenant->SetStatus(kTenantStatus31); mCheckedIn = true; } else { theVIP->SetDestination(theTenant->mEquipID, mArrivalTime); } // "様より" - From text += "\x97\x6C\x82\xE6\x82\xE8"; RECT rect; theTenant->GetEquipArea(rect); int floorNum = inDoc->GetFloorInfo()->UnitToFloor(rect.top); if (floorNum < 0) { text += 'B'; floorNum = 0 - floorNum; } tmp.Format("%d", floorNum); text += tmp; // "階" - floor text += "\x8A\x4B"; int roomNum = theTenant->GetRoomNumber(inDoc->GetFloorInfo()); if (roomNum < 0) { text += 'B'; roomNum = 0 - roomNum; } tmp.Format("%d", roomNum); text += tmp; // "号室の" - of room number text += "\x8D\x86\x8E\xBA\x82\xCC"; T2EquipDef *theTenantDef = theTenant->GetEquipDef(); if (theTenantDef) theTenantDef->GetName(tmp, 0); text += tmp; // "に、予約がはいりました。\n今日の" - I have a reservation. Today's text += "\x82\xC9\x81\x41\x97\x5C\x96\xF1\x82\xAA\x82\xCD\x82\xA2\x82\xE8\x82\xDC\x82\xB5\x82\xBD\x81\x42\x0A\x8D\xA1\x93\xFA\x82\xCC"; tmp.Format("%d", mArrivalTime / 60); text += tmp; // "時" - Time text += "\x8E\x9E"; int minute = mArrivalTime % 60; if (minute != 0) { // "%d分" - %d minute tmp.Format("%d\x95\xAA", minute); text += tmp; } // "にロビーに到着する予定です。" - will arrive at the lobby on text += "\x82\xC9\x83\x8D\x83\x72\x81\x5B\x82\xC9\x93\x9E\x92\x85\x82\xB7\x82\xE9\x97\x5C\x92\xE8\x82\xC5\x82\xB7\x81\x42"; Sounds->AddSound("VIP:Reserve", SoundPriority_1, 9002, GetWorldModuleHandle()); Sounds->Play("VIP:Reserve", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100); DoDialog(inDoc, 8200, 8200, 1, text); Sounds->Stop("VIP:Reserve"); Sounds->DeleteSound("VIP:Reserve"); mPeopleID = theVIP->GetPeopleID(); mTenantID = theTenant->GetEquipID(); mStatus = kVisitVIPStatus1; } } } else if (thePlugin) { CString tmp; thePlugin->GetName(tmp); CString str; // "VIPを招待するには、" - To invite your VIP, str = "\x56\x49\x50\x82\xF0\x8F\xB5\x91\xD2\x82\xB7\x82\xE9\x82\xC9\x82\xCD\x81\x41"; str += tmp; // "の設置が必要です。" - installation is required. str += "\x82\xCC\x90\xDD\x92\x75\x82\xAA\x95\x4B\x97\x76\x82\xC5\x82\xB7\x81\x42"; inDoc->GetTowerMessage()->InfoBarMessage(str, 900, NULL); } else if (!theSpecifier) { inDoc->mA0 |= mVisitFlag; mStatus = kVisitVIPStatus4; } } } } return (mStatus != kVisitVIPStatus0); } /*virtual*/ int T2VisitVIP::Exec(T2TowerDoc* inDoc) { int result = 0; switch (mStatus) { case kVisitVIPStatus0: case kVisitVIPStatus4: case kVisitVIPStatus5: mStatus = kVisitVIPStatus0; result = 3; } if (DoReception(inDoc)) result = 3; else result = IsExclusive() ? 1 : 0; return result; } void T2VisitVIP::Init(CResFile* inResFile) { *inResFile >> mGrade; *inResFile >> mTenantPluginID; *inResFile >> mArrivalTime; *inResFile >> mArriveAnimResID; *inResFile >> mSatisfiedSoundID; *inResFile >> mDissatisfiedSoundID; int subResID; *inResFile >> subResID; CResFile subResFile; if (subResFile.OpenResource(GetWorldDef()->mModuleHandle, subResID, 'VIPL')) subResFile >> mSilhouetteType; *inResFile >> mSatisfiedText; *inResFile >> mDissatisfiedText; mLevelBit = 1 << (mGrade - 1); mDaysBeforeNextVisit = mCycleDay; mCycleDay = 1; mBeginDay = 0; mPeopleID = 0; mTenantID = 0; mStatus = kVisitVIPStatus0; mCheckedIn = false; mVisitFlag = 1 << ((mGrade - 1) * 4); while (mTowerEvent->_88 & mVisitFlag) mVisitFlag <<= 1; mTowerEvent->_88 |= mVisitFlag; } BOOL T2VisitVIP::DoReception(T2TowerDoc* inDoc) { T2People *thePeople = inDoc->mPeopleArrayList->FindPeople(mPeopleID); if (thePeople) { int theSndID; CString str; T2Name *theName; T2Pool *thePool; switch (thePeople->GetStatus()) { case kStatus2: case kStatus3: case kStatus4: if (mStatus < kVisitVIPStatus2) { Sounds->AddSound("VIP:Arrive", SoundPriority_1, 9001, GetWorldModuleHandle()); Sounds->Play("VIP:Arrive", SoundMask_10, SoundFlags_10 | SoundFlags_10000, NULL, PlayMode_0, 100); thePeople->GetName(str); // "様が今ロビーに到着しました。" - You have just arrived at the lobby. str += "\x97\x6C\x82\xAA\x8D\xA1\x83\x8D\x83\x72\x81\x5B\x82\xC9\x93\x9E\x92\x85\x82\xB5\x82\xDC\x82\xB5\x82\xBD\x81\x42"; DoDialog(inDoc, 8200, mArriveAnimResID, 1, str); Sounds->Stop("VIP:Arrive"); Sounds->DeleteSound("VIP:Arrive"); mStatus = kVisitVIPStatus2; } break; case kStatus1: if (mStatus < kVisitVIPStatus2) break; thePeople->GetName(str); // "様が御帰宅なされました。\nあなたのビルに" - You have gone home. In your building str += "\x97\x6C\x82\xAA\x8C\xE4\x8B\x41\x91\xEE\x82\xC8\x82\xB3\x82\xEA\x82\xDC\x82\xB5\x82\xBD\x81\x42\x0A\x82\xA0\x82\xC8\x82\xBD\x82\xCC\x83\x72\x83\x8B\x82\xC9"; theSndID = 0; if (thePeople->VIPEstimation()) { // "大変満足した様子です。\n\n「" - I am very satisfied. str += "\x91\xE5\x95\xCF\x96\x9E\x91\xAB\x82\xB5\x82\xBD\x97\x6C\x8E\x71\x82\xC5\x82\xB7\x81\x42\x0A\x0A\x81\x75"; str += mSatisfiedText; inDoc->mA0 |= mVisitFlag; mStatus = kVisitVIPStatus4; theSndID = mSatisfiedSoundID; } else { // "不満な様子です。\n\n「" - I'm dissatisfied. str += "\x95\x73\x96\x9E\x82\xC8\x97\x6C\x8E\x71\x82\xC5\x82\xB7\x81\x42\x0A\x0A\x81\x75"; T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(mTenantID); if (theTenant) { CString tmp; RECT rect; theTenant->GetEquipArea(rect); int floorNum = inDoc->GetFloorInfo()->UnitToFloor(rect.top); if (floorNum < 0) { str += 'B'; floorNum = 0 - floorNum; } tmp.Format("%d", floorNum); str += tmp; // "階の - of the floor str += "\x8A\x4B\x82\xCC"; T2EquipDef *theTenantDef = theTenant->GetEquipDef(); if (theTenantDef) theTenantDef->GetToolName(tmp, 0); str += tmp; // "は遠すぎる。\n" - is too far str += "\x82\xCD\x89\x93\x82\xB7\x82\xAC\x82\xE9\x81\x42\x0A"; } str += mDissatisfiedText; mBeginDay += mDaysBeforeNextVisit; mStatus = kVisitVIPStatus6; theSndID = mDissatisfiedSoundID; } DoAlert(inDoc, str, theSndID); theName = inDoc->mNameDB->Search(thePeople); if (theName) { inDoc->mNameDB->RemoveName(theName); delete theName; } thePool = inDoc->GetPool(); thePool->DeadVIP(thePeople); return true; case kStatus11: if (mCheckedIn) { T2DateTime *theNow = inDoc->mNow; if (theNow && theNow->GetRawMinutes() == 600) { T2Tenant *theTenant = inDoc->GetFloorInfo()->GetTenant(mTenantID); if (theTenant && theTenant->IsBelongPeople(thePeople)) { theTenant->SetStatus(kTenantStatus34); mCheckedIn = false; } } } break; } } return false; } BOOL T2VisitVIP::GetDestinationTennant(DWORD inPluginID, T2Tenant*& outTenant, CFilePlugin*& outPlugin, T2PluginSpecifier*& outSpecifier) { BOOL loaded = false; T2TowerDoc *theTowerDoc = GetTowerDoc(); T2PluginLoader *theT2PluginLoader = theTowerDoc->mT2PluginLoader; T2PluginSpecifier *theSpecifier; POSITION pos; theT2PluginLoader->SetTypeFilter(pos, 'TnPl'); while ((theSpecifier = theT2PluginLoader->GetNext(pos))) { if (theSpecifier->mID == inPluginID) { outPlugin = theTowerDoc->mTenantPlugins->GetItem(theSpecifier->mID); outSpecifier = theSpecifier; break; } } if (outPlugin) { T2FloorInfo *theFloorInfo = theTowerDoc->GetFloorInfo(); if (theFloorInfo) { T2Tenant *theTenant = theFloorInfo->GetTenantByPID(inPluginID); if (theTenant) { unsigned int registID = theTenant->GetRegistID(); if (registID == kTenantRegistID1) { theTenant = NULL; T2RegistedTenantDB *theDB = theTowerDoc->GetRegistedTenantDB(); if (theDB) { T2EquipPtrList *theList = theDB->GetList(kTenantRegistID1); if (theList) { LArrayIterator iterator(*theList); T2Tenant *iteratorTenant; while (!theTenant && iterator.Next(&iteratorTenant)) { if (theFloorInfo->GetTenant(iteratorTenant->GetRelatedTenantID())) { CProgramPlugin *plugin = iteratorTenant->GetEquipDef()->GetPlugin(); if (plugin) { if (plugin->GetID() == inPluginID && iteratorTenant->GetStatus() == kTenantStatus30) theTenant = iteratorTenant; } } } } } } outTenant = theTenant; loaded = true; } } } return loaded; } /*virtual*/ void T2VisitVIP::Write(T2Archive& inArchive) { unsigned int len = 14; inArchive << len; inArchive << (short) mStatus; inArchive << mPeopleID; inArchive << (unsigned short) mTenantID; inArchive << mVisitFlag; inArchive << (short) mBeginDay; } /*virtual*/ void T2VisitVIP::Read(T2Archive& inArchive) { unsigned int len; inArchive >> len; short s; unsigned short su; inArchive >> s; mStatus = s; inArchive >> mPeopleID; inArchive >> su; mTenantID = su; inArchive >> mVisitFlag; inArchive >> s; mBeginDay = s; }