#include "StdAfx.h" #include "T2DLL/CFilePluginList.h" #include "T2DLL/CObjectQueue.h" #include "T2DLL/CPluginInfoArray.h" #include "T2DLL/CPluginInfo.h" #include "DbgIPS.h" #include "DbgPeopleView.h" #include "DbgStepRun.h" #include "T2DLL/GlobalFunc.h" #include "T2.h" #include "T2DLL/T2AdvertisePlugin.h" #include "T2DLL/T2Archive.h" #include "T2DLL/T2ArrowWnd.h" #include "T2DLL/T2BitImage.h" #include "T2CtrlPalette.h" #include "T2DLL/T2DateTime.h" #include "T2DLL/T2Dialog.h" #include "T2DLL/T2DlgItemAnimation.h" #include "T2DLL/T2DlgItemProgress.h" #include "T2DLL/T2DlgItemText.h" #include "T2DLL/T2DLL.h" #include "T2DLL/T2FInfoAreaIterator.h" #include "T2DLL/T2FInfoPtIterator.h" #include "T2DLL/T2FloorInfo.h" #include "T2DLL/T2HallEventPlugin.h" #include "T2MainWindow.h" #include "T2DLL/T2Mover.h" #include "T2DLL/T2MoverArray.h" #include "T2DLL/T2MoverArrayList.h" #include "T2DLL/T2MoverDef.h" #include "T2DLL/T2MoverPlugin.h" #include "T2DLL/T2MoviePlugin.h" #include "T2DLL/T2MoviePluginList.h" #include "T2MsgWindow.h" #include "T2MWControl.h" #include "T2DLL/T2Name.h" #include "T2DLL/T2NameList.h" #include "T2OpenSelectDlg.h" #include "T2DLL/T2OptionPluginList.h" #include "T2DLL/T2OuterObjDef.h" #include "T2DLL/T2OuterObjList.h" #include "T2DLL/T2OuterObjPlugin.h" #include "T2DLL/T2OutObj.h" #include "T2DLL/T2OutObjArray.h" #include "T2DLL/T2OutObjArrayList.h" #include "T2DLL/T2PaletteAnime.h" #include "T2DLL/T2People.h" #include "T2DLL/T2PeopleArray.h" #include "T2DLL/T2PeopleArrayList.h" #include "T2DLL/T2PeopleDef.h" #include "T2DLL/T2PeopleLoader.h" #include "T2DLL/T2PluginInfoTable.h" #include "T2DLL/T2PluginLoader.h" #include "T2DLL/T2PluginSpecifier.h" #include "T2DLL/T2Pool.h" #include "T2PoolView.h" #include "T2DLL/T2RegistedTenantDB.h" #include "T2DLL/T2Request.h" #include "T2DLL/T2RequestArrayList.h" #include "T2DLL/T2RouteNavigator.h" #include "T2DLL/T2SearchDialog.h" #include "T2DLL/T2SettingDialog.h" #include "T2DLL/T2Settlement.h" #include "T2DLL/T2SilhouetteDef.h" #include "T2DLL/T2SoundPlayer.h" #include "T2DLL/T2StewardDialog.h" #include "T2SysInfoDlg.h" #include "T2DLL/T2TemplatePluginDB.h" #include "T2DLL/T2TemplatePluginList.h" #include "T2DLL/T2Tenant.h" #include "T2DLL/T2TenantArray.h" #include "T2DLL/T2TenantArrayList.h" #include "T2DLL/T2TenantDef.h" #include "T2DLL/T2TenantPlugin.h" #include "T2DLL/T2ToolWindow.h" #include "T2TowerDoc.h" #include "T2DLL/T2TowerEvent.h" #include "T2TowerMainView.h" #include "T2DLL/T2TowerMessage.h" #include "T2DLL/T2TrafficInfo.h" #include "T2DLL/T2TreasureDialog.h" #include "T2DLL/T2UnitInfo.h" #include "T2DLL/T2WorldDef.h" #include "T2DLL/T2WorldPlugin.h" #include "T2WorldSelectDlg.h" #include "T2DLL/UT2BkgndInfo.h" #include "T2DLL/UT2Coordinate.h" #include "T2DLL/UT2Utils.h" #include "resource.h" IMPLEMENT_DYNCREATE(T2TowerDoc, CDocument) BEGIN_MESSAGE_MAP(T2TowerDoc, CDocument) //{{AFX_MSG_MAP(T2TowerDoc) ON_COMMAND(ID_SYSTEM_INFO, OnSystemInformation) ON_UPDATE_COMMAND_UI(ID_DBG_STEP_RUN, OnUpdateDebugStepRun) ON_COMMAND(ID_DBG_STEP_RUN, OnDebugStepRun) ON_UPDATE_COMMAND_UI(ID_DBG_IDLE_SPEED_MEASURING, OnUpdateDebugIdleSpeedMeasuring) ON_COMMAND(ID_DBG_IDLE_SPEED_MEASURING, OnDebugIdleSpeedMeasuring) ON_UPDATE_COMMAND_UI(ID_DBG_ALL_LOAD_MEASURING, OnUpdateDebugAllLoadMeasuring) ON_COMMAND(ID_DBG_ALL_LOAD_MEASURING, OnDebugAllLoadMeasuring) ON_UPDATE_COMMAND_UI(ID_DBG_POOL, OnUpdateDebugPool) ON_COMMAND(ID_DBG_POOL, OnDebugPool) ON_UPDATE_COMMAND_UI(ID_DBG_DISPLAY_IPS, OnUpdateDebugDisplayIPS) ON_COMMAND(ID_DBG_DISPLAY_IPS, OnDebugDisplayIPS) ON_UPDATE_COMMAND_UI(ID_DBG_PEOPLE, OnUpdateDebugPeople) ON_COMMAND(ID_DBG_PEOPLE, OnDebugPeople) ON_COMMAND(ID_DBG_GRADE_UP, OnDebugGradeUp) ON_COMMAND(ID_DBG_GRADE_DOWN, OnDebugGradeDown) ON_COMMAND(ID_PAUSE, OnPause) ON_UPDATE_COMMAND_UI(ID_PAUSE, OnUpdatePause) ON_COMMAND(ID_SETTING, OnSetting) ON_UPDATE_COMMAND_UI(ID_SETTING, OnUpdateSetting) ON_COMMAND(ID_HIDE_ELEVATOR_ROOM, OnHideElevatorRoom) ON_UPDATE_COMMAND_UI(ID_HIDE_ELEVATOR_ROOM, OnUpdateHideElevatorRoom) ON_COMMAND(ID_FAVORITE, OnFavorite) ON_UPDATE_COMMAND_UI(ID_FAVORITE, OnUpdateFavorite) ON_COMMAND(ID_HIDE_CONTROL_WINDOW, OnHideControlWindow) ON_UPDATE_COMMAND_UI(ID_HIDE_CONTROL_WINDOW, OnUpdateHideControlWindow) ON_COMMAND(ID_HIDE_MESSAGE_WINDOW, OnHideMessageWindow) ON_UPDATE_COMMAND_UI(ID_HIDE_MESSAGE_WINDOW, OnUpdateHideMessageWindow) ON_COMMAND(ID_HIDE_TOOL_WINDOW, OnHideToolWindow) ON_UPDATE_COMMAND_UI(ID_HIDE_TOOL_WINDOW, OnUpdateHideToolWindow) //}}AFX_MSG_MAP END_MESSAGE_MAP() T2TowerDoc::T2TowerDoc() { g_TowerDoc = this; gT2App->_E4 = 1; m228 = 1; _22C = false; mNewDocFlag = true; m208 = 0; mTowerMainView = NULL; mDestroyCallbackData = NULL; mDestroyCallback = NULL; mWorldPluginID = 0; mToolPaletteID = 1000; mWorldDef = NULL; mIsStuffLoadedFlag = false; _B0 = true; mLastRequestedCursor = 256; mCurrentCursorIndex = -1; _1F8 = 0; mFundsOnClick = 0; mT2PluginLoader = T2_APP->mPluginLoader; T2_APP->mDocument = this; m20C = 0; HDC hdc = GetDC(NULL); if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) mIsPaletteMode = true; else mIsPaletteMode = false; ReleaseDC(NULL, hdc); mTowerMessage = NULL; } /*virtual*/ T2TowerDoc::~T2TowerDoc() { gT2App->_E4 = 0; if (mDestroyCallbackData && mDestroyCallback) { mDestroyCallback(mDestroyCallbackData); mDestroyCallbackData = NULL; } towerDoc_vfD4(false); } /*virtual*/ void T2TowerDoc::towerDoc_vfC8() { mSoundPlayer = NULL; mNameDB = NULL; mWorldPluginSpecifier = mT2PluginLoader->FindPlugin(mWorldPluginID, 'WdPl'); if (!mWorldPluginSpecifier) { if (m228) { T2OpenSelectDlg *dlg = new T2OpenSelectDlg(this); dlg->ShowOpenSelectDialog(); } else { LoadsWorldPlugin(); } } else { towerDoc_vfCC(mWorldPluginSpecifier, true); } } /*virtual*/ void T2TowerDoc::towerDoc_vfCC(T2PluginSpecifier *inWorldPluginSpec, BOOL inIsExistingFile) { T2MainWindow *theMainWindow = T2_MAIN_WINDOW; if (theMainWindow) theMainWindow->EnableWindow(); if (!mWorldPluginSpecifier) { mWorldPluginSpecifier = inWorldPluginSpec; mWorldPluginID = mWorldPluginSpecifier->mID; } #line 187 _ASSERT(mWorldPluginSpecifier != NULL); mWorldPlugin = (T2WorldPlugin *) T2PluginLoader::LoadPlugin(mWorldPluginSpecifier); mWorldDef = mWorldPlugin->LoadT2WorldDef(); mToolPaletteSpecifier = mT2PluginLoader->FindPlugin(mToolPaletteID, 'TOPL'); #line 192 _ASSERT(mToolPaletteSpecifier != NULL); T2_APP->mToolWindow = NULL; m218 = 0; m21C = 0; mGameLevel = mWorldDef->m70; _1F4 = 1; m9C = 0; mA0 = 0; mZoomLevel = 0; mDrawSpeed = 25; _94 = 0; mViewMode = kInView; mPause = false; m204 = 0; mNow = new T2DateTime(1, mWorldDef->m74, 7, 0, 0); mFloorDef = NULL; mDragMask = NULL; mDebugStepRunEnabled = false; mDisplayIPS = false; m1C4 = NULL; mPeopleArrayList = NULL; mTrafficInfo = NULL; mSearchRangeFrom = NULL; m1F0 = 0; mElevTransparent = false; mWalkRate = 1; _224 = 0; mObjectQueue = new CObjectQueue; mCraneCount = 0; mCranePosArray = NULL; mBC = 0; mC0 = 0; mRegistedTenantDB = new T2RegistedTenantDB; m1A0 = NULL; _1A4 = NULL; _1A8 = 0; _1AC = 0; mFloorInfo = new T2FloorInfo(mWorldDef); mWorldDef->InitializeFloorInfo(mFloorInfo); m1CC = 0; mRouteNavigator = new T2RouteNavigator(mFloorInfo); mPaletteUpdated = false; mIsDustOn = mWorldDef->IsDustOn(mGameLevel); mToiletDenomi = mWorldDef->GetToiletDenomi(mGameLevel); mColdDenomi = mWorldDef->GetColdDenomi(mGameLevel, mNow->GetMonth()); mPaletteAnime = new T2PaletteAnime(mWorldDef, mNow); mTenantPlugins = new CFilePluginList('TnPl'); mMoverPlugins = new CFilePluginList('MvPl'); mOuterObjPlugins = new CFilePluginList('OoPl'); mMoviePluginList = new T2MoviePluginList; mHallEventPlugins = new CFilePluginList('HePl'); mAdvertisePlugins = new CFilePluginList('AdPl'); mTenantTemplates = new T2TemplatePluginList('TnDf'); mMoverTemplates = new T2TemplatePluginList('MvDf'); mOuterObjTemplates = new T2TemplatePluginList('OODf'); if (mWorldDef->IsUseMatterObject()) mMatterTemplates = new T2TemplatePluginList('MtDf'); else mMatterTemplates = NULL; mPeopleTemplates = new T2TemplatePluginList('PPDf'); mSilhouetteTemplates = new T2TemplatePluginList('SlDf'); mTemplatePluginDB = new T2TemplatePluginDB; mTemplatePluginDB->Add(mTenantTemplates); mTemplatePluginDB->Add(mMoverTemplates); mTemplatePluginDB->Add(mOuterObjTemplates); if (mWorldDef->IsUseMatterObject()) mTemplatePluginDB->Add(mMatterTemplates); mTemplatePluginDB->Add(mPeopleTemplates); mTemplatePluginDB->Add(mSilhouetteTemplates); mOuterObjList = new T2OuterObjList; mPeopleArrayList = new T2PeopleArrayList; mPeopleArrayList->SetWalkPeople(mWalkRate); mOptionPluginList = new T2OptionPluginList; mNameDB = new T2NameList; T2PeopleLoader::Load(mWorldPluginSpecifier, mTemplatePluginDB); towerDoc_vfD0(); LoadOptionPlugins(); if (!inIsExistingFile) SelectPlugins(false); CreatePool(); RECT theBkgndRect; SetRect(&theBkgndRect, 0, 0, mWorldDef->GetWidth(), mWorldDef->GetHeight()); mBkgndInfo = UT2BkgndInfo::SetupBkgndInfo(theBkgndRect, mWorldDef->mGroundLine); mWorldDef->InitializeBkgndInfo(mBkgndInfo); InitSound(T2_APP->mMainWindow->mSoundPlayer); mWorldDef->InitializeDocument(this); mWorldDef->InitTowerEvent(this); RECT theFloorArea; mFloorInfo->GetFloorArea(theFloorArea); mTrafficInfo = new T2TrafficInfo(theFloorArea, 100, 500, 1000, 4); mSettlement = new T2Settlement(this, mWorldDef->GetInitialFunds()); T2_APP->mMainWindow->Setup(); T2ToolWindow *theToolPalette = T2_APP->mMainWindow->mToolWindow; theToolPalette->SetDocument(this); T2MsgWindow *messageWindow = T2_APP->mMainWindow->mMsgWindow; messageWindow->SetDocument(this); T2CtrlPalette *controlPalette = T2_APP->mMainWindow->mCtrlPalette; controlPalette->SetDocument(this); controlPalette->vf100(mViewMode); T2_APP->mMainWindow->InvalidateRect(NULL); mIsStuffLoadedFlag = true; m228 = 0; CRect mainWindowArea; T2_APP->mMainWindow->GetWindowRect(mainWindowArea); T2_APP->mMainWindow->x414445(); m188 = mTowerMainView->mScrollOffset; if (!mTowerMessage) mTowerMessage = new T2TowerMessage(AfxGetInstanceHandle(), this); SetupGradeAnimation(); } void T2TowerDoc::xUnkNameSelectWorld(T2PluginSpecifier *inWorldPluginSpec) { towerDoc_vfCC(inWorldPluginSpec, false); x41CFEB(); } void T2TowerDoc::x41CFEB() { mPaletteAnime->MinuteChanged(mNow); mPaletteAnime->ChangeSE(); mPaletteAnime->DoAnimatePalette(); _22C = true; UpdateAllViews(NULL); T2MainWindow *theMainWindow = T2_MAIN_WINDOW; if (theMainWindow) theMainWindow->InvalidateRect(NULL); } /*virtual*/ void T2TowerDoc::towerDoc_vfD0() { T2ToolWindow *toolWindow = T2_APP->mToolWindow; toolWindow = (T2ToolWindow *) T2PluginLoader::LoadPlugin(mToolPaletteSpecifier); T2_APP->mToolWindow = toolWindow; toolWindow->mModule = mToolPaletteSpecifier->mInstance; toolWindow->SetDocument(this); toolWindow->AddIcon( "ToolDestruct", 3, // 撤去ツール // テナント、移動設備、看板を撤去します。 "\x93\x50\x8B\x8E\x83\x63\x81\x5B\x83\x8B\n\x83\x65\x83\x69\x83\x93\x83\x67\x81\x41\x88\xDA\x93\xAE\x90\xDD\x94\xF5\x81\x41\x8A\xC5\x94\xC2\x82\xF0\x93\x50\x8B\x8E\x82\xB5\x82\xDC\x82\xB7\x81\x42", this); toolWindow->AddIcon( "ToolFinger", 1, // エレベータ伸縮ツール // エレベータの機械室をドラッグして伸縮します。 "\x83\x47\x83\x8C\x83\x78\x81\x5B\x83\x5E\x90\x4C\x8F\x6B\x83\x63\x81\x5B\x83\x8B\n\x83\x47\x83\x8C\x83\x78\x81\x5B\x83\x5E\x82\xCC\x8B\x40\x8A\x42\x8E\xBA\x82\xF0\x83\x68\x83\x89\x83\x62\x83\x4F\x82\xB5\x82\xC4\x90\x4C\x8F\x6B\x82\xB5\x82\xDC\x82\xB7\x81\x42", this); toolWindow->AddIcon( "ToolInfo", 3, // 情報ツール // テナント、移動設備、人をクリックすると情報ウィンドウが表示されます。 "\x8F\xEE\x95\xF1\x83\x63\x81\x5B\x83\x8B\n\x83\x65\x83\x69\x83\x93\x83\x67\x81\x41\x88\xDA\x93\xAE\x90\xDD\x94\xF5\x81\x41\x90\x6C\x82\xF0\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xB7\x82\xE9\x82\xC6\x8F\xEE\x95\xF1\x83\x45\x83\x42\x83\x93\x83\x68\x83\x45\x82\xAA\x95\x5C\x8E\xA6\x82\xB3\x82\xEA\x82\xDC\x82\xB7\x81\x42", this); toolWindow->AddIcon( "ToolZoom", 3, // ズームツール // ゲーム画面を拡大縮小します。 // 左クリックで拡大、右クリックで縮小します。 "\x83\x59\x81\x5B\x83\x80\x83\x63\x81\x5B\x83\x8B\n\x83\x51\x81\x5B\x83\x80\x89\xE6\x96\xCA\x82\xF0\x8A\x67\x91\xE5\x8F\x6B\x8F\xAC\x82\xB5\x82\xDC\x82\xB7\x81\x42\n\x8D\xB6\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xC5\x8A\x67\x91\xE5\x81\x41\x89\x45\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xC5\x8F\x6B\x8F\xAC\x82\xB5\x82\xDC\x82\xB7\x81\x42", this); toolWindow->AddIcon( "ToolHand", 3, // スクロールツール // 画面を自由にスクロールできます。 "\x83\x58\x83\x4E\x83\x8D\x81\x5B\x83\x8B\x83\x63\x81\x5B\x83\x8B\n\x89\xE6\x96\xCA\x82\xF0\x8E\xA9\x97\x52\x82\xC9\x83\x58\x83\x4E\x83\x8D\x81\x5B\x83\x8B\x82\xC5\x82\xAB\x82\xDC\x82\xB7\x81\x42", this); toolWindow->AddIcon( "ToolMic", 1, // インタビューツール // 歩いている人の意見を聞くことができます。 "\x83\x43\x83\x93\x83\x5E\x83\x72\x83\x85\x81\x5B\x83\x63\x81\x5B\x83\x8B\n\x95\xE0\x82\xA2\x82\xC4\x82\xA2\x82\xE9\x90\x6C\x82\xCC\x88\xD3\x8C\xA9\x82\xF0\x95\xB7\x82\xAD\x82\xB1\x82\xC6\x82\xAA\x82\xC5\x82\xAB\x82\xDC\x82\xB7\x81\x42", this); toolWindow->AddIcon( "ToolRoot", 1, // 集客範囲表示ツール // クリックしたテナントが人を呼べる範囲を表示します。 "\x8F\x57\x8B\x71\x94\xCD\x88\xCD\x95\x5C\x8E\xA6\x83\x63\x81\x5B\x83\x8B\n\x83\x4E\x83\x8A\x83\x62\x83\x4E\x82\xB5\x82\xBD\x83\x65\x83\x69\x83\x93\x83\x67\x82\xAA\x90\x6C\x82\xF0\x8C\xC4\x82\xD7\x82\xE9\x94\xCD\x88\xCD\x82\xF0\x95\x5C\x8E\xA6\x82\xB5\x82\xDC\x82\xB7\x81\x42", this); } void T2TowerDoc::LoadOptionPlugins() { T2PluginSpecifier *specifier; POSITION pos; mT2PluginLoader->SetTypeFilter(pos, 'OPPL'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if (specifier->mAttrib == 0 || specifier->mAttrib == mWorldPluginSpecifier->mID) { T2OptionPlugin *plugin = (T2OptionPlugin *) T2PluginLoader::LoadPlugin(specifier); mOptionPluginList->Add(plugin); } } mOptionPluginList->DispatchEvent(kInitOptionEvent, this, NULL); } /*virtual*/ void T2TowerDoc::towerDoc_vfD4(BOOL inResetMainWindow) { _22C = false; if (mIsStuffLoadedFlag) { mIsStuffLoadedFlag = false; mOptionPluginList->DispatchEvent(kDestroyOptionEvent, this, NULL); if (inResetMainWindow) { T2_MAIN_WINDOW->Teardown(); mSoundPlayer->DeleteSoundAll(); } mWorldDef->ClearCranePos(this); delete mPool; T2PeopleLoader::Unload(mTemplatePluginDB); delete mTenantPlugins; delete mMoverPlugins; delete mOuterObjPlugins; delete mMoviePluginList; delete mHallEventPlugins; delete mAdvertisePlugins; delete mTenantTemplates; delete mMoverTemplates; delete mOuterObjTemplates; if (mMatterTemplates) delete mMatterTemplates; delete mPeopleTemplates; delete mSilhouetteTemplates; delete mTemplatePluginDB; delete mObjectQueue; delete mOuterObjList; delete mNameDB; delete mTrafficInfo; delete mSettlement; delete mOptionPluginList; UT2BkgndInfo::DisposeBkgndInfo(mBkgndInfo); delete mRouteNavigator; delete mFloorInfo; T2PluginSpecifier *specifier; POSITION pos; mT2PluginLoader->SetTypeFilter(pos, 0); while ((specifier = mT2PluginLoader->GetNext(pos))) { if (specifier->mIsLoaded) T2PluginLoader::UnloadPlugin(specifier); } delete mRegistedTenantDB; delete mNow; mSprite.AllClear(); if (mPeopleArrayList) delete mPeopleArrayList; mWorldDef = NULL; UpdateAllViews(NULL); if (inResetMainWindow) T2_APP->mMainWindow->InvalidateRect(NULL); } } /*virtual*/ BOOL T2TowerDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return false; towerDoc_vfD4(true); mWorldPluginID = 0; mNewDocFlag = true; towerDoc_vfC8(); return true; } /*virtual*/ BOOL T2TowerDoc::OnOpenDocument(LPCTSTR lpszPathName) { mErrorFlag = false; if (!towerDoc_vf2BC(lpszPathName)) { MessageBox(NULL, "File load error", "ERROR", MB_OK); mErrorFlag = true; return false; } return true; } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf2BC(const char *inPath) { BOOL loaded = true; int viewMode = kInView; mNewDocFlag = false; T2Archive stream; if (stream.OpenAsReadMode(inPath)) { DWORD magic; stream >> magic; if (magic == 'T200') { stream.BeginCompressedStream(); BOOL foundWorldPlugin = true; stream >> mWorldPluginID; if (!mT2PluginLoader->FindPlugin(mWorldPluginID, 'WdPl')) foundWorldPlugin = false; if (foundWorldPlugin) { towerDoc_vfD4(true); mTowerMainView->tmv_vf110(); towerDoc_vfC8(); _22C = false; try { #pragma var_order(i, installedPlugins, mustCheckError, uc, queueVar, checkError, pluginInfoArray, s, theFloorArea, pluginInfo, us, scrollX, desktopRect, numPlugins, ctrlPalette, scrollY, pluginIterator, desktopWindow, pt2, anotherRect, pt1, missingPlugins) int i; short s; unsigned short us; unsigned char uc; stream >> s; mGameLevel = s; stream >> s; m9C = s; stream >> mA0; stream >> s; mZoomLevel = s; stream >> uc; if (uc) mPause = true; else mPause = false; stream >> s; // drawSpeed on Mac stream >> s; // field 0x8C on Mac stream >> s; viewMode = s; stream >> uc; // field 0x92 on Mac stream >> uc; // field 0x93 on Mac stream >> uc; // soundplayer pausedFlag on Mac // soundplayer priority on flags on Mac for (i = 0; i < 7; i++) stream >> uc; delete mNow; mNow = new T2DateTime(stream); SelectPlugins(false); int numPlugins; stream >> numPlugins; CPluginInfoArray *pluginInfoArray = new CPluginInfoArray(false); CPluginInfo *pluginInfo; for (i = 0; i < numPlugins; i++) { pluginInfo = CPluginInfo::ReadPluginInfo(stream); pluginInfoArray->Add(&pluginInfo); } BOOL mustCheckError = false; BOOL checkError = false; LArray *missingPlugins = new CPluginInfoArray(true); CPluginInfoArray *installedPlugins = MakePluginInfoArray(); LArrayIterator pluginIterator(*pluginInfoArray); while (pluginIterator.Next(&pluginInfo)) { DWORD id = pluginInfo->GetID(); BOOL found = false; LArrayIterator iteratorCheck(*installedPlugins); CPluginInfo *thePluginCheck; while (iteratorCheck.Next(&thePluginCheck)) { if (id == thePluginCheck->GetID()) { found = true; break; } } if (!found) missingPlugins->Add(&pluginInfo); } if (missingPlugins->GetCount() > 0) { TRACE("\r\nPlugin Check Error !\r\n"); checkError = true; CPluginInfo *errorPlugin; LArrayIterator iterator(*missingPlugins); while (iterator.Next(&errorPlugin)) { if (errorPlugin->mMustItem) { mustCheckError = true; break; } } if (mustCheckError) { TRACE("\r\nPlugin Must Check Error !\r\n"); T2Dialog dialog; CRect rect; AfxGetMainWnd()->GetWindowRect(rect); T2DLGTEMPLATE theTmpl; theTmpl.pt = rect.CenterPoint(); theTmpl.moduleHandle = AfxGetApp()->m_hInstance; theTmpl.resID = 1110; dialog.Realize(this, &theTmpl, this, NULL, NULL, true, NULL, 0, true); T2PluginInfoTable *pluginInfoTable = (T2PluginInfoTable *) dialog.GetDlgItem(102); if (pluginInfoTable) { CPluginInfo *errorPlugin; LArrayIterator iterator(*missingPlugins); while (iterator.Next(&errorPlugin)) { if (errorPlugin->mMustItem) pluginInfoTable->Add(errorPlugin); } } int code = dialog.DoModal(); throw -10000; } } if (checkError) { T2Dialog dialog; CRect rect; AfxGetMainWnd()->GetWindowRect(rect); T2DLGTEMPLATE theTmpl; theTmpl.pt = rect.CenterPoint(); theTmpl.moduleHandle = AfxGetApp()->m_hInstance; theTmpl.resID = 1111; dialog.Realize(this, &theTmpl, this, NULL, NULL, true, NULL, 0, true); T2PluginInfoTable *pluginInfoTable = (T2PluginInfoTable *) dialog.GetDlgItem(102); if (pluginInfoTable) { CPluginInfo *errorPlugin; LArrayIterator iterator(*missingPlugins); while (iterator.Next(&errorPlugin)) pluginInfoTable->Add(errorPlugin); } int code = dialog.DoModal(); if (code == IDOK) throw -10000; } delete missingPlugins; delete installedPlugins; delete pluginInfoArray; mPeopleArrayList->Read(stream, this); mFloorInfo->Read(stream, this); short queueVar; stream >> queueVar; if (queueVar > 0) { unsigned int queueLen; stream >> queueLen; for (unsigned int index = 0; index < queueLen; index++) { stream >> s; T2Tenant *theTenant = mFloorInfo->GetTenant(s); if (theTenant) mObjectQueue->AddItem(theTenant); } } stream >> uc; mElevTransparent = (uc != 0); stream >> s; mWalkRate = s; LoadPool(stream); delete mRouteNavigator; mRouteNavigator = new T2RouteNavigator(mFloorInfo); RECT theFloorArea; mFloorInfo->GetFloorArea(theFloorArea); mTrafficInfo = new T2TrafficInfo(theFloorArea, 100, 500, 1000, 4); mTrafficInfo->Read(stream); mSettlement = new T2Settlement(this, stream); mMoviePluginList->Read(stream); mWorldDef->ReadTowerEvent(stream); CRect desktopRect; CWnd *desktopWindow = CWnd::GetDesktopWindow(); if (desktopWindow) desktopWindow->GetWindowRect(&desktopRect); CRect anotherRect; CPoint pt1, pt2; stream.ReadSRect(anotherRect); pt1 = anotherRect.TopLeft(); pt2 = anotherRect.BottomRight(); if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) AfxGetMainWnd()->MoveWindow(&anotherRect); int scrollX, scrollY; stream >> scrollY; m188.y = scrollY; stream >> scrollX; m188.x = scrollX; // tool window bounds stream.ReadSRect(anotherRect); anotherRect.right = anotherRect.left + 92; anotherRect.bottom = anotherRect.top + 359; pt1 = anotherRect.TopLeft(); pt2 = anotherRect.BottomRight(); if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) T2_APP->mToolWindow->MoveWindow(&anotherRect); // message window bounds stream.ReadSRect(anotherRect); anotherRect.right = anotherRect.left + 523; anotherRect.bottom = anotherRect.top + 70; pt1 = anotherRect.TopLeft(); pt2 = anotherRect.BottomRight(); if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) T2_MAIN_WINDOW->mMsgWindow->MoveWindow(&anotherRect); // control window bounds stream.ReadSRect(anotherRect); anotherRect.right = anotherRect.left + 133; anotherRect.bottom = anotherRect.top + 76; T2CtrlPalette *ctrlPalette = T2_APP->mMainWindow->mCtrlPalette; pt1 = anotherRect.TopLeft(); pt2 = anotherRect.BottomRight(); if (desktopRect.PtInRect(pt1) && desktopRect.PtInRect(pt2)) ctrlPalette->MoveWindow(&anotherRect); SetViewMode(mViewMode); // calendar window bounds - Mac only stream.ReadSRect(anotherRect); // sub-window visibility flags - Mac only stream >> uc; stream >> uc; stream >> uc; stream >> uc; stream >> us; mSearchRangeFrom = (us == 0) ? NULL : mFloorInfo->GetTenant(us); mNameDB->Read(stream); mWorldDef->ReadStatisticsProc(this, stream); } catch (int err) { loaded = false; } } else { loaded = false; } stream.EndCompressedStream(); } else { loaded = false; } stream.Close(); } else { loaded = false; } if (loaded) { #pragma var_order(theTenantArrayList, theMoverDef, theOutObjArrayList, theMover, theOutObjArray, theIterator, theMoverArray, theTenantArray, theMoverArrayList, theTenant, theOutObj, theTenantDef) SelectPlugins(false); T2TenantArrayList *theTenantArrayList = mFloorInfo->GetTenantArrayList(); LArrayIterator *theIterator = new LArrayIterator(*theTenantArrayList); T2TenantArray *theTenantArray; T2Tenant *theTenant; T2TenantDef *theTenantDef; while (theIterator->Next(&theTenantArray)) { for (int index = 0; index < T2TenantArray::kGroupSize; index++) { theTenant = &theTenantArray->mTenants[index]; if (theTenant->IsUsed()) { LArrayIterator templateIterator(*mTenantTemplates); while (templateIterator.Next(&theTenantDef)) { if (theTenantDef->GetEquipType() == theTenant->GetEquipType()) { theTenant->SetToolDef(theTenantDef); break; } } if (!theTenant->GetToolDef()) { CRect tmp; theTenant->Destruct(this, tmp); } } } } delete theIterator; T2MoverArrayList *theMoverArrayList = mFloorInfo->GetMoverArrayList(); theIterator = new LArrayIterator(*theMoverArrayList); T2MoverArray *theMoverArray; T2Mover *theMover; T2MoverDef *theMoverDef; while (theIterator->Next(&theMoverArray)) { for (int index = 0; index < T2MoverArray::kGroupSize; index++) { theMover = &theMoverArray->mMover[index]; if (theMover->IsUsed()) { LArrayIterator templateIterator(*mMoverTemplates); while (templateIterator.Next(&theMoverDef)) { if (theMoverDef->GetEquipType() == theMover->GetEquipType()) { theMover->SetToolDef(theMoverDef); break; } } if (!theMover->GetToolDef()) { CRect tmp; theMover->Destruct(this, tmp); } } } } delete theIterator; T2OutObjArrayList *theOutObjArrayList = mFloorInfo->GetOutObjArrayList(); theIterator = new LArrayIterator(*theOutObjArrayList); T2OutObjArray *theOutObjArray; T2OutObj *theOutObj; while (theIterator->Next(&theOutObjArray)) { for (int index = 0; index < T2OutObjArray::kGroupSize; index++) { theOutObj = &theOutObjArray->mOutObj[index]; if (theOutObj->IsUsed()) { mOuterObjList->Add(&theOutObj); theOutObj->_3C = theOutObj->mOutObjArea; } } } delete theIterator; } BOOL pausedFlag = false; if (mPause) pausedFlag = true; x429A9A(pausedFlag); x429B01(pausedFlag); SetViewMode(viewMode); mWorldDef->DayChanged(this); if (loaded) x41CFEB(); return loaded; } /*virtual*/ BOOL T2TowerDoc::OnSaveDocument(LPCTSTR lpszPathName) { if (!towerDoc_vf2C0(lpszPathName)) MessageBox(NULL, "File save error", "ERROR", MB_OK); return true; } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf2C0(const char *inPath) { #pragma var_order(thePluginInfoArray, uc, stream, queueVar, s, magic, thePluginInfo, us, pluginIterator, i, scrollPos, windowPlacement, dummyRect) T2Archive stream; if (!stream.OpenAsWriteMode(inPath)) return false; short s; unsigned char uc; unsigned short us; DWORD magic = 'T200'; stream << magic; stream.BeginCompressedStream(); stream << mWorldPluginSpecifier->mID; s = mGameLevel; stream << s; s = m9C; stream << s; stream << mA0; s = mZoomLevel; stream << s; uc = 0; s = 0; stream << uc; stream << s; stream << s; s = mViewMode; stream << s; stream << uc; stream << uc; stream << uc; for (int i = 0; i < 7; i++) stream << uc; mNow->Write(stream); CPluginInfoArray *thePluginInfoArray = MakePluginInfoArray(); stream << thePluginInfoArray->GetCount(); LArrayIterator pluginIterator(*thePluginInfoArray); CPluginInfo *thePluginInfo; while (pluginIterator.Next(&thePluginInfo)) thePluginInfo->Write(stream); mPeopleArrayList->Write(stream); mFloorInfo->Write(stream); short queueVar = 0; if (mObjectQueue) { queueVar = 1; stream << queueVar; stream << mObjectQueue->GetItemCount(); POSITION pos = mObjectQueue->GetHeadPosition(); while (pos) { POSITION prevPos = pos; T2Tenant *theTenant = (T2Tenant *) mObjectQueue->GetNext(pos); s = theTenant->GetEquipID(); stream << s; } } else { stream << queueVar; } uc = mElevTransparent != 0; stream << uc; stream << (short) mWalkRate; mPool->Write(stream); mTrafficInfo->Write(stream); mSettlement->Write(stream); mMoviePluginList->Write(stream); mWorldDef->WriteTowerEvent(stream); WINDOWPLACEMENT windowPlacement; AfxGetMainWnd()->GetWindowPlacement(&windowPlacement); stream.WriteSRect(windowPlacement.rcNormalPosition); POINT scrollPos = mTowerMainView->mScrollOffset; stream << (int) scrollPos.y; stream << (int) scrollPos.x; T2_APP->mToolWindow->GetWindowPlacement(&windowPlacement); windowPlacement.rcNormalPosition.right = windowPlacement.rcNormalPosition.left + 88; windowPlacement.rcNormalPosition.bottom = windowPlacement.rcNormalPosition.top + 353; stream.WriteSRect(windowPlacement.rcNormalPosition); T2_MAIN_WINDOW->mMsgWindow->GetWindowPlacement(&windowPlacement); windowPlacement.rcNormalPosition.right = windowPlacement.rcNormalPosition.left + 513; windowPlacement.rcNormalPosition.bottom = windowPlacement.rcNormalPosition.top + 45; stream.WriteSRect(windowPlacement.rcNormalPosition); T2_APP->mMainWindow->mCtrlPalette->GetWindowPlacement(&windowPlacement); windowPlacement.rcNormalPosition.right = windowPlacement.rcNormalPosition.left + 150; windowPlacement.rcNormalPosition.bottom = windowPlacement.rcNormalPosition.top + 58; stream.WriteSRect(windowPlacement.rcNormalPosition); RECT dummyRect; dummyRect.left = 0; dummyRect.top = 0; dummyRect.right = 0; dummyRect.bottom = 0; stream.WriteSRect(dummyRect); uc = 1; stream << uc; stream << uc; stream << uc; stream << uc; us = (mSearchRangeFrom == NULL) ? 0 : mSearchRangeFrom->GetEquipID(); stream << us; mNameDB->Write(stream); mWorldDef->WriteStatisticsProc(this, stream); stream.EndCompressedStream(); stream.Close(); return true; } void T2TowerDoc::OnSystemInformation() { T2SysInfoDlg dlg(NULL); dlg.SetDocument(this); dlg.DoModal(); } /*virtual*/ int T2TowerDoc::GetZoomLevel() const { return mZoomLevel; } /*virtual*/ void T2TowerDoc::DrawBkgnd(const RECT &inRect) { RECT bkgndRect, updateRect; bkgndRect.left = 0; bkgndRect.top = 0; bkgndRect.right = mBkgndInfo->hRange; bkgndRect.bottom = mBkgndInfo->vRange; IntersectRect(&updateRect, &inRect, &bkgndRect); if (updateRect.left < 0 || updateRect.right > mBkgndInfo->hRange || updateRect.top < 0 || updateRect.bottom > mBkgndInfo->vRange) { OutputDebugString("Backgound update rect is invalid!!\n"); return; } if (!IsRectEmpty(&inRect)) mWorldDef->DrawBkgnd(inRect, this); } /*virtual*/ void T2TowerDoc::towerDoc_vfF0(const RECT &inRect1, const RECT &inRect2) { RECT rect; UnionRect(&rect, &inRect1, &inRect2); towerDoc_vfD8(inRect1, inRect2); } /*virtual*/ void T2TowerDoc::DrawBuilding(const RECT &inRect1, const RECT &inRect2) { RECT rect; UnionRect(&rect, &inRect1, &inRect2); if (mViewMode == kOutView) DrawOutView(rect, inRect2); else DrawInView(rect, inRect2); mWorldDef->DrawCrane(this, rect); } /*virtual*/ void T2TowerDoc::DrawInView(const RECT &inRect1, const RECT &inRect2) { DrawRequestAll(inRect1); mPeopleArrayList->DrawSearchedPerson(this); DrawMoverAll(inRect1); } /*virtual*/ void T2TowerDoc::DrawOutView(const RECT &inRect1, const RECT &inRect2) { DrawTenantOutViewAll(inRect1); } /*virtual*/ void T2TowerDoc::towerDoc_vfD8(const RECT &inRect1, const RECT &inRect2) { if (!IsRectEmpty(&inRect2)) { RECT rect; UnionRect(&rect, &inRect1, &inRect2); towerDoc_vfFC(rect); } else { towerDoc_vfF8(inRect1); } } /*virtual*/ void T2TowerDoc::towerDoc_vfFC(const RECT &inRect) { RECT drawRect = inRect; if (mViewMode == kOutView) { drawRect.bottom = mFloorInfo->GetGroundLine(); InsetRect(&drawRect, -mFloorInfo->GetEntranceWidth(), 0); } int topFloorLine = mWorldDef->mTopFloorLine; T2FInfoAreaIterator iterator(*mFloorInfo, drawRect); T2Tenant *theTenant; while (iterator.NextTenant(theTenant)) { if (theTenant) { RECT rect; theTenant->GetEquipArea(rect); ROOFANDFLOOR roofAndFloor; if (((T2TenantDef *) theTenant->GetToolDef())->mDrawRoof) { if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) roofAndFloor = RoofAndFloor_Both; else roofAndFloor = RoofAndFloor_Roof; } else { if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) roofAndFloor = RoofAndFloor_Floor; else roofAndFloor = RoofAndFloor_None; } T2Tenant *theFloor = NULL; if (theTenant->IsFloor()) { if (theTenant->IsBuildFinish()) { iterator.GetTenantRect(rect); if (mViewMode != kOutView) mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); theTenant->Draw(this, rect); } else { mWorldDef->DrawBuild(theTenant, this); } theFloor = theTenant; } else { if (theTenant->IsBuildFinish()) { if (mViewMode != kOutView) mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); theTenant->Draw(this, rect); } else { mWorldDef->DrawBuild(theTenant, this); } theFloor = mFloorInfo->GetTenant(theTenant->GetFloorID(-1)); } theTenant->ClearDrawMode(); } } } /*virtual*/ void T2TowerDoc::towerDoc_vfF8(const RECT &inRect) { RECT drawRect = inRect; if (mViewMode == kOutView) { drawRect.bottom = mFloorInfo->GetGroundLine(); InsetRect(&drawRect, -mFloorInfo->GetEntranceWidth(), 0); } int topFloorLine = mWorldDef->mTopFloorLine; T2FInfoAreaIterator iterator(*mFloorInfo, drawRect); T2Tenant *theTenant; unsigned int floorID = 0; while (iterator.NextTenant(theTenant)) { if (theTenant) { RECT rect; ROOFANDFLOOR roofAndFloor; if (((T2TenantDef *) theTenant->GetToolDef())->mDrawRoof) { if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) roofAndFloor = RoofAndFloor_Both; else roofAndFloor = RoofAndFloor_Roof; } else { if (((T2TenantDef *) theTenant->GetToolDef())->mDrawFloor) roofAndFloor = RoofAndFloor_Floor; else roofAndFloor = RoofAndFloor_None; } if (theTenant->IsNeedDraw()) { if (theTenant->IsBuildFinish()) { theTenant->GetEquipArea(rect); if (theTenant->IsFloor()) iterator.GetTenantRect(rect); if (mViewMode != kOutView) mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); theTenant->Draw(this, rect); } else { mWorldDef->DrawBuild(theTenant, this); } theTenant->ClearDrawMode(); } else if (theTenant->IsFloor() && theTenant->GetEquipID() == floorID) { theTenant->GetEquipArea(rect); iterator.GetTenantRect(rect); if (mViewMode != kOutView) mWorldDef->DrawRoofAndFloor(rect, this, roofAndFloor); theTenant->Draw(this, rect); theTenant->ClearDrawMode(); } } } } /*virtual*/ void T2TowerDoc::towerDoc_vf100(const RECT &inRect) { mWorldDef->DrawOptionObj(this, inRect); } /*virtual*/ void T2TowerDoc::DrawRequestAll(const RECT &inRect) { T2FInfoAreaIterator iterator(*mFloorInfo, inRect); T2Request *theReq; while (iterator.NextRequest(theReq)) { RECT rect, requestArea; theReq->CalcArea(requestArea); if (IntersectRect(&rect, &requestArea, &inRect)) theReq->Draw(this, rect); } } /*virtual*/ void T2TowerDoc::DrawMoverAll(const RECT &inRect) { T2MoverArrayList *theMoverArrayList = mFloorInfo->GetMoverArrayList(); if (theMoverArrayList) theMoverArrayList->DrawMoverAll(this, inRect); } /*virtual*/ void T2TowerDoc::DrawTenantOutViewAll(const RECT &inRect) { RECT rect; LArrayIterator iterator(*mOuterObjList); T2OutObj *theOutObj; while (iterator.Next(&theOutObj)) { if (IntersectRect(&rect, &inRect, &theOutObj->_3C)) { CRect rectCopy = inRect; theOutObj->Draw(this, rectCopy); } } } /*virtual*/ int T2TowerDoc::HitTest(POINT inPt, HitTestResult &outObj, BOOL inSkipPeople, BOOL inSkipOuterObj) { int theHitType = kHitNull; outObj.obj = NULL; T2BitImage *theImage = mTowerMainView->mImage; theImage->SetOrigin(mTowerMainView->mScrollOffset.x, mTowerMainView->mScrollOffset.y); theImage->SetClipRect(NULL); theImage->Clear(254); POINT pt = inPt; UT2Coordinate::QDToUnit(pt, mZoomLevel); theHitType = HitTestLayer(theImage, inPt, outObj, T2Sprite::ELayer_2); if (theHitType == kHitNull && !inSkipOuterObj) { LArrayIterator iterator(*mOuterObjList); T2OutObj *theOuterObj; while (theHitType == kHitNull && iterator.Next(&theOuterObj)) { theOuterObj->DrawHitMask(this); if (theImage->GetPixel(inPt) != 254) { theHitType = kHitOutObj; outObj.obj = theOuterObj; } } } if (theHitType == kHitNull) { LArrayIterator arrayListIter(*mFloorInfo->GetMoverArrayList()); T2MoverArray *theMoverArray; while (theHitType == kHitNull && arrayListIter.Next(&theMoverArray)) { for (int i = 0; theHitType == kHitNull && i < T2MoverArray::kGroupSize; i++) { T2Mover *theMover = &theMoverArray->mMover[i]; if (theMover->IsUsed()) { theMover->DrawHitMask(this); if (theImage->GetPixel(inPt) != 254) { theHitType = kHitMover; outObj.obj = theMover; } } } } } if (theHitType == kHitNull && !inSkipPeople) { RECT visibleRect; mTowerMainView->GetVisibleUnitRect(visibleRect); T2FInfoAreaIterator iterator(*mFloorInfo, visibleRect); T2Request *theRequest; while (theHitType == kHitNull && iterator.NextRequest(theRequest)) { theRequest->DrawHitMask(this); if (theImage->GetPixel(inPt) != 254) { T2People *thePeople = theRequest->FindPeople(pt.x); #line 1414 _ASSERT(thePeople != NULL); theHitType = kHitPeople; outObj.obj = thePeople; } } } if (theHitType == kHitNull && !inSkipPeople) { LArrayIterator arrayListIter(*mPeopleArrayList); T2PeopleArray *thePeopleArray; while (theHitType == kHitNull && arrayListIter.Next(&thePeopleArray)) { for (int i = 0; theHitType == kHitNull && i < T2PeopleArray::kGroupSize; i++) { T2People *thePeople = &thePeopleArray->mPeople[i]; if (thePeople->IsUsed() && thePeople->IsWalk()) { thePeople->DrawHitMask(this); if (theImage->GetPixel(inPt) != 254) { theHitType = kHitPeople; outObj.obj = thePeople; } } } } } if (theHitType == kHitNull) { RECT visibleRect; mTowerMainView->GetVisibleUnitRect(visibleRect); T2FInfoAreaIterator iterator(*mFloorInfo, visibleRect); T2Tenant *theTenant; while (theHitType == kHitNull && iterator.NextTenant(theTenant)) { if (theTenant && !theTenant->IsFloor()) { theTenant->DrawHitMask(this); if (theImage->GetPixel(inPt) != 254) { theHitType = kHitTenant; if (theTenant->GetStatus() >= kTenantStatus10) outObj.obj = theTenant; } } } } if (theHitType == kHitNull) { RECT visibleRect; mTowerMainView->GetVisibleUnitRect(visibleRect); T2FInfoAreaIterator iterator(*mFloorInfo, visibleRect); T2Tenant *theTenant; while (theHitType == kHitNull && iterator.NextTenant(theTenant)) { if (theTenant && theTenant->IsFloor()) { theTenant->DrawHitMask(this); if (theImage->GetPixel(inPt) != 254) { theHitType = kHitTenant; outObj.obj = theTenant; } } } } if (theHitType == kHitNull) theHitType = HitTestLayer(theImage, inPt, outObj, T2Sprite::ELayer_1); if (theHitType == kHitNull) { CRect bkgndRect; mTowerMainView->GetClientRect(bkgndRect); bkgndRect.OffsetRect(mTowerMainView->mScrollOffset); UT2Coordinate::QDToBkgnd(bkgndRect, mZoomLevel); bkgndRect.right += 1; bkgndRect.bottom += 1; for (int y = bkgndRect.top; theHitType == kHitNull && y < bkgndRect.bottom; y++) { for (int x = bkgndRect.left; theHitType == kHitNull && x < bkgndRect.right; x++) { unsigned int bkgndInfo = UT2BkgndInfo::GetBkgndInfo(mBkgndInfo, y, x); RECT bkgndInfoRect; SetRect(&bkgndInfoRect, x, y, x + 1, y + 1); mWorldDef->DrawBkgnd(bkgndInfo, bkgndInfoRect, this); if (theImage->GetPixel(inPt) != 254) { theHitType = kHitBkgndInfo; outObj.bkgndInfo = bkgndInfo; } } } } if (theHitType == kHitNull) theHitType = HitTestLayer(theImage, inPt, outObj, T2Sprite::ELayer_0); theImage->SetOrigin(0, 0); mTowerMainView->Invalidate(true); mTowerMainView->tmv_vf11C(); return theHitType; } int T2TowerDoc::HitTestLayer(T2BitImage *inImage, POINT inPt, HitTestResult &outObj, int inLayer) { POSITION pos = mSprite.GetHeadPosition(); while (pos) { T2SpriteObj *obj = mSprite.GetNext(pos); if (obj->mLayer == inLayer) { mSprite.DrawSprite(inImage, obj, mZoomLevel); if (inImage->GetPixel(inPt) != 254) { outObj.spriteObj = obj; return kHitSpriteObj; } } } return kHitNull; } /*virtual*/ T2BitImage *T2TowerDoc::GetImage() const { return mTowerMainView->mImage; } /*virtual*/ T2TowerMainView *T2TowerDoc::GetMainView() const { return mTowerMainView; } /*virtual*/ T2DateTime *T2TowerDoc::GetNow() const { return mNow; } /*virtual*/ T2RouteNavigator *T2TowerDoc::GetRouteNavi() const { return mRouteNavigator; } /*virtual*/ T2TemplatePluginList *T2TowerDoc::GetSilhouetteTemplates() { return mSilhouetteTemplates; } static int cursors[16] = { IDC_DESTRUCT_B, IDC_DESTRUCT, IDC_FINGER, IDC_FINGER_B, IDC_INFO_B, IDC_INFO, IDC_ZOOM, IDC_ZOOM, IDC_HAND, IDC_HAND_B, IDC_MIC, IDC_MIC, IDC_SEARCH_RANGE, IDC_SEARCH_RANGE, IDC_T2_NO, IDC_T2_NO }; /*virtual*/ void T2TowerDoc::SetCursorType(int inCursor, BOOL inIsPressed) { HCURSOR theCursorH = NULL; CT2App *theApp = T2_APP; UINT id; if (inCursor == kCursorNoChange) inCursor = mLastRequestedCursor; else mLastRequestedCursor = inCursor; if (inCursor < kCursorDefault) { inCursor *= 2; if (inIsPressed) inCursor++; id = cursors[inCursor]; theCursorH = theApp->LoadCursor(id); } else if (inCursor == kCursorDefault) { theCursorH = theApp->LoadStandardCursor(IDC_ARROW); } if (mCurrentCursorIndex != inCursor) { mCurrentCursorIndex = inCursor; if (inCursor == kCursorDefault) { theCursorH = theApp->LoadStandardCursor(IDC_ARROW); } else { id = cursors[inCursor]; theCursorH = theApp->LoadCursor(id); } if (theCursorH) { SetClassLong(mTowerMainView->m_hWnd, GCL_HCURSOR, (LONG) theCursorH); SetCursor(theCursorH); } } } /*virtual*/ void T2TowerDoc::Serialize(CArchive &ar) { if (ar.IsStoring()) { } else { } } /*virtual*/ void T2TowerDoc::InitSound(T2SoundPlayer *inSoundPlayer) { mSoundPlayer = inSoundPlayer; Sounds = mSoundPlayer; LoadSoundForPlugin(mWorldDef); T2TemplatePlugin *thePlugin; LArrayIterator *theIterator; theIterator = new LArrayIterator(*mTenantTemplates); while (theIterator->Next(&thePlugin)) LoadSoundForPlugin(thePlugin); delete theIterator; theIterator = new LArrayIterator(*mMoverTemplates); while (theIterator->Next(&thePlugin)) LoadSoundForPlugin(thePlugin); delete theIterator; } void T2TowerDoc::LoadSoundForPlugin(T2TemplatePlugin *inPlugin) { if (mSoundPlayer) inPlugin->LoadSound(this); } /*virtual*/ void T2TowerDoc::CreatePool() { if (mWorldDef) { T2PoolDef *thePoolDef = mWorldDef->mPoolDef; if (thePoolDef) { T2TemplatePluginList *theList = mTemplatePluginDB->GetTemplatePluginList('PPDf'); unsigned int theHour = mNow->Get24Hour(); mPool = new T2Pool( thePoolDef, mWorldDef->GetSeasonParamDef(), theList, mPeopleArrayList, mGameLevel, mNow->GetMonth(), mNow->Get24Hour(), mWorldDef); } } } /*virtual*/ void T2TowerDoc::LoadPool(T2Archive &inArchive) { if (mWorldDef) { T2PoolDef *thePoolDef = mWorldDef->mPoolDef; if (thePoolDef) { T2TemplatePluginList *theList = mTemplatePluginDB->GetTemplatePluginList('PPDf'); unsigned int theHour = mNow->Get24Hour(); mPool = new T2Pool( inArchive, thePoolDef, mWorldDef->GetSeasonParamDef(), theList, mPeopleArrayList, mWorldDef); } } } /*virtual*/ void T2TowerDoc::SetViewMode(int inViewMode) { if (mViewMode != inViewMode) { if (mWorldDef) mWorldDef->ViewModeChanged(this, (VIEWMODE) inViewMode); T2MainWindow *theMainWindow = T2_MAIN_WINDOW; if (theMainWindow) { T2CtrlPalette *theCtrlPalette = theMainWindow->mCtrlPalette; if (theCtrlPalette) theCtrlPalette->vf100(inViewMode); } GetWorldDef()->GetTowerEvent()->ViewModeChanged(this, (VIEWMODE) inViewMode); mViewMode = inViewMode; mSearchRangeFrom = NULL; T2ToolWindow *theToolWindow = T2_APP->mToolWindow; unsigned short theIconSet; if (mViewMode == kOutView) theIconSet = 2; else theIconSet = 1; theToolWindow->EnableIcon(theIconSet); mTowerMainView->Invalidate(false); mTowerMainView->tmv_vf120(); } } /*virtual*/ void T2TowerDoc::SelectPlugins(BOOL inIsGradeUp) { #pragma var_order(rect, pos2, pos3, theItemNameText, tmpl, thePluginTypeText, specifier, theToolWindow, numPlugins, str, pos1, theProgress, pos, theDialog) mOptionPluginList->DispatchEvent(kSelectPluginsOptionEvent, this, NULL); T2ToolWindow *theToolWindow = T2_APP->mToolWindow; towerDoc_vf290(true); POSITION pos; T2PluginSpecifier *specifier; int numPlugins = 0; mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mTenantPlugins->GetItem(specifier->mID) && (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mMoverPlugins->GetItem(specifier->mID) && (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mOuterObjPlugins->GetItem(specifier->mID) && (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'MoPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mMoviePluginList->GetItem(specifier->mID) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'HePl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mHallEventPlugins->GetItem(specifier->mID) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'AdPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mAdvertisePlugins->GetItem(specifier->mID) ) numPlugins++; } CRect rect; AfxGetMainWnd()->GetWindowRect(rect); T2DLGTEMPLATE tmpl; tmpl.pt = rect.CenterPoint(); tmpl.moduleHandle = GetWorldModuleHandle(); if (!inIsGradeUp) tmpl.resID = 9100; else tmpl.resID = 9101; T2Dialog *theDialog = new T2Dialog; theDialog->mDeleteOnClose = true; theDialog->Realize(this, &tmpl, this, NULL, NULL, true, NULL, 0, true); T2_APP->app_vfB4(); if (inIsGradeUp) { T2DlgItemAnimation *theGradeUpAnimation = (T2DlgItemAnimation *) theDialog->GetDlgItem(104); mWorldDef->SetupGradeUpAnimation(theGradeUpAnimation, mGameLevel); CString message; mWorldDef->GetGradeUpMessage(mGameLevel, message); ((T2DlgItem *) theDialog->GetDlgItem(105))->SetDescriptor(message); mSoundPlayer->Play("GradeUp", SoundMask_10, SoundFlags_10, NULL, PlayMode_2, 100); DWORD v = timeGetTime(); while ((timeGetTime() - v) < 3000) T2_APP->app_vfB4(); } CString str; T2DlgItemText *theItemNameText = (T2DlgItemText *) theDialog->GetDlgItem(101); T2DlgItemText *thePluginTypeText = (T2DlgItemText *) theDialog->GetDlgItem(102); T2DlgItemProgress *theProgress = (T2DlgItemProgress *) theDialog->GetDlgItem(103); theProgress->SetRange(0, numPlugins); theProgress->SetPos(0); theProgress->SetStep(1); // "テナント" thePluginTypeText->SetDescriptor("\x83\x65\x83\x69\x83\x93\x83\x67"); T2_APP->app_vfB4(); mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mTenantPlugins->GetItem(specifier->mID) && (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) ) { theItemNameText->SetDescriptor(specifier->mPluginName); theProgress->StepIt(); T2_APP->app_vfB4(); T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mT2PluginLoader->LoadPlugin(specifier); mTenantPlugins->Add(theTenantPlugin); theTenantPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); mTenantTemplates->Regist(def); if (def->IsFloor()) mFloorDef = def; if (!def->RequierToolIcon(theToolWindow)) theToolWindow->AddIcon(def->mStr48, NULL, 0, kToolOption1, def, 0, 1, this); theToolWindow->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); LoadSoundForPlugin(def); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } #line 1996 _ASSERT(mFloorDef != NULL); // "移動設備" thePluginTypeText->SetDescriptor("\x88\xDA\x93\xAE\x90\xDD\x94\xF5"); T2_APP->app_vfB4(); mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mMoverPlugins->GetItem(specifier->mID) && (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) ) { theItemNameText->SetDescriptor(specifier->mPluginName); theProgress->StepIt(); T2_APP->app_vfB4(); T2MoverPlugin *theMoverPlugin = (T2MoverPlugin *) mT2PluginLoader->LoadPlugin(specifier); mMoverPlugins->Add(theMoverPlugin); theMoverPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); T2MoverDef *def = (T2MoverDef *) theMoverPlugin->GetTemplatePlugin(); mMoverTemplates->Regist(def); if (!def->RequierToolIcon(theToolWindow)) theToolWindow->AddIcon(def->mStr48, NULL, 0, kToolOption2, def, 0, 1, this); theToolWindow->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); LoadSoundForPlugin(def); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } // "外観" thePluginTypeText->SetDescriptor("\x8A\x4F\x8A\xCF"); T2_APP->app_vfB4(); mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mOuterObjPlugins->GetItem(specifier->mID) && (!specifier->mSecretItem || (specifier->mSecretItem & (m9C != 0))) ) { theItemNameText->SetDescriptor(specifier->mPluginName); theProgress->StepIt(); T2_APP->app_vfB4(); T2OuterObjPlugin *theOuterObjPlugin = (T2OuterObjPlugin *) mT2PluginLoader->LoadPlugin(specifier); mOuterObjPlugins->Add(theOuterObjPlugin); theOuterObjPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); T2OuterObjDef *def = (T2OuterObjDef *) theOuterObjPlugin->GetTemplatePlugin(); mOuterObjTemplates->Regist(def); if (!def->RequierToolIcon(theToolWindow)) theToolWindow->AddIcon(def->mStr48, NULL, 0, kToolOption3, def, 0, 2, this); theToolWindow->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 2, this); LoadSoundForPlugin(def); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } // "ムービー" thePluginTypeText->SetDescriptor("\x83\x80\x81\x5B\x83\x72\x81\x5B"); T2_APP->app_vfB4(); mT2PluginLoader->SetTypeFilter(pos, 'MoPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mMoviePluginList->GetItem(specifier->mID) ) { theItemNameText->SetDescriptor(specifier->mPluginName); theProgress->StepIt(); T2_APP->app_vfB4(); T2MoviePlugin *theMoviePlugin = new T2MoviePlugin('MoPl', *specifier); theMoviePlugin->LoadSelf(); mMoviePluginList->Add(theMoviePlugin); theMoviePlugin->UnfoldPluginSelf(); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } // "イベント" thePluginTypeText->SetDescriptor("\x83\x43\x83\x78\x83\x93\x83\x67"); T2_APP->app_vfB4(); mT2PluginLoader->SetTypeFilter(pos, 'HePl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mHallEventPlugins->GetItem(specifier->mID) ) { theItemNameText->SetDescriptor(specifier->mPluginName); theProgress->StepIt(); T2_APP->app_vfB4(); T2HallEventPlugin *theHallEventPlugin = new T2HallEventPlugin('HePl', *specifier); theHallEventPlugin->LoadSelf(); mHallEventPlugins->Add(theHallEventPlugin); theHallEventPlugin->UnfoldPluginSelf(); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } // "広告" thePluginTypeText->SetDescriptor("\x8D\x4C\x8D\x90"); T2_APP->app_vfB4(); mT2PluginLoader->SetTypeFilter(pos, 'AdPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mAdvertisePlugins->GetItem(specifier->mID) ) { theItemNameText->SetDescriptor(specifier->mPluginName); theProgress->StepIt(); T2_APP->app_vfB4(); T2AdvertisePlugin *theAdvertisePlugin = new T2AdvertisePlugin('AdPl', *specifier); theAdvertisePlugin->LoadSelf(); mAdvertisePlugins->Add(theAdvertisePlugin); theAdvertisePlugin->UnfoldPluginSelf(); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } if (!inIsGradeUp) { int id; if (mViewMode == kOutView) { id = theToolWindow->GetID("ToolInfo", 0); } else { // "フロア" id = theToolWindow->GetID("\x83\x74\x83\x8D\x83\x41", 1); } theToolWindow->SetSel(id); } POSITION pos1 = mTenantPlugins->GetHeadPosition(); while (pos1) { T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mTenantPlugins->GetNext(pos1); T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); if (def) { DWORD subPluginType = def->GetSubPluginType(); if (subPluginType == 'MoPl') { POSITION pluginPos = mMoviePluginList->GetHeadPosition(); while (pluginPos) { CResourcePlugin *thePlugin = (CResourcePlugin *) mMoviePluginList->GetNext(pluginPos); if (thePlugin->GetType() == subPluginType) def->Add(thePlugin); } } } } POSITION pos2 = mTenantPlugins->GetHeadPosition(); while (pos2) { T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mTenantPlugins->GetNext(pos2); T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); if (def) { DWORD subPluginType = def->GetSubPluginType(); if (subPluginType == 'HePl') { POSITION pluginPos = mHallEventPlugins->GetHeadPosition(); while (pluginPos) { CResourcePlugin *thePlugin = (CResourcePlugin *) mHallEventPlugins->GetNext(pluginPos); if (thePlugin->GetType() == subPluginType) def->Add(thePlugin); } } } } POSITION pos3 = mOuterObjPlugins->GetHeadPosition(); while (pos3) { T2OuterObjPlugin *theOuterObjPlugin = (T2OuterObjPlugin *) mOuterObjPlugins->GetNext(pos3); T2OuterObjDef *theOuterObjDef = (T2OuterObjDef *) theOuterObjPlugin->GetTemplatePlugin(); if (theOuterObjDef) { DWORD subPluginType = theOuterObjDef->GetSubPluginType(); if (subPluginType != 0) { POSITION pluginPos = mAdvertisePlugins->GetHeadPosition(); while (pluginPos) { T2AdvertisePlugin *thePlugin = (T2AdvertisePlugin *) mAdvertisePlugins->GetNext(pluginPos); if (thePlugin->GetSubType() == subPluginType) theOuterObjDef->Add(thePlugin); } } } } _1F4 = 0; theDialog->DestroyWindow(); SetupGradeAnimation(); towerDoc_vf294(); } /*virtual*/ void T2TowerDoc::towerDoc_vfC0(int) { #pragma var_order(var8, varC, counter, var14, oldLevel) if (!mWorldPluginID || !mTowerMainView) return; DWORD varC = timeGetTime(); if (m218 == 0) m218 = varC; if (varC > m218) m21C += varC - m218; if (m21C > 1000) m21C = 1000; int counter = 0; DWORD var14 = timeGetTime(); while (m21C > mDrawSpeed) { if ((counter++ % 2) == 0) { MSG msg; if (PeekMessage(&msg, NULL, 0, 0, 0)) { if (msg.message == WM_QUIT) return; if (msg.message != WM_PAINT) { m21C = 0; break; } } } if ((timeGetTime() - var14) > 1000) { m21C = 0; break; } mTowerMessage->SpendTime2(); if (!mPause) towerDoc_vfC4(); if (m21C >= mDrawSpeed) m21C -= mDrawSpeed; if (m208) break; } DWORD var8 = GetTickCount(); if ((var8 - mC0) > 20) { mBC = (mBC >= 7) ? 0 : (mBC + 1); mC0 = var8; } if (!gT2App->_E4) return; mTowerMainView->tmv_vf120(); m218 = varC; int oldLevel = mGameLevel; if (oldLevel != CheckGameLevel()) { mBC = 0; mC0 = GetTickCount(); SelectPlugins(true); mPool->GameLevelChanged(mGameLevel); mIsDustOn = mWorldDef->IsDustOn(mGameLevel); mToiletDenomi = mWorldDef->GetToiletDenomi(mGameLevel); mColdDenomi = mWorldDef->GetColdDenomi(mGameLevel, mNow->GetMonth()); } } /*virtual*/ void T2TowerDoc::towerDoc_vfC4() { if (m20C) { m210++; if ((time(NULL) - m20C) >= 5) { m20C = 0; CString str; str.Format("%.2f Idles/sec.", m210 / 5.0f); MessageBox(NULL, str, "RESULT", MB_OK); } if (m214) mTowerMainView->Invalidate(false); } DispatchOptionEvent(kIdleOptionEvent, NULL); unsigned int theOldDay = mNow->GetDay(); unsigned int theOldHour = mNow->GetHour(); if (mNow->IsIncDateTime()) { InvalClock(); if (mNow->GetHour() != theOldHour) { mPool->IncHour(mNow); mTrafficInfo->HourChanged(this); unsigned int theNewDay = mNow->GetDay(); if (theNewDay != theOldDay) { InvalCalender(); mWorldDef->DayChanged(this); mColdDenomi = mWorldDef->GetColdDenomi(mGameLevel, mNow->GetMonth()); if (theNewDay == 1) { mSettlement->Update(); mFloorInfo->CalcMentenanceCost(this); } } } if (mPool->IsChangePopulation()) InvalPopulation(); if ((mNow->GetMinutes() == 0) && (mNow->GetHour() % 3) == 0) { } mPaletteAnime->MinuteChanged(mNow); } // this might be a bool int idleResult = mWorldDef->IdleProc(this); if (m1CC) { m1CC++; if (m1CC == 256) m1CC = 0; } mPeopleArrayList->DispatchIdle(this); static DWORD var4479B0; DWORD ticks = GetTickCount(); if (ticks < var4479B0 || ticks >= (var4479B0 + 100)) { var4479B0 = ticks; CycleOutlinePalette(); } mFloorInfo->GetRequestArrayList()->DispatchIdle(this); mFloorInfo->GetMoverArrayList()->DispatchIdle(this); if (idleResult == 0) { mFloorInfo->GetTenantArrayList()->DispatchIdle(this); mFloorInfo->GetOutObjArrayList()->DispatchIdle(this); m204++; if (m204 >= 40) { m204 = 0; if (mOuterObjTemplates) mOuterObjTemplates->DispatchIdle(this); if (mMoverTemplates) mMoverTemplates->DispatchIdle(this); if (mTenantTemplates) mTenantTemplates->DispatchIdle(this); } CheckBuildQueue(); } if (mPaletteAnime->IsSETime()) mPaletteAnime->ChangeSE(); mPaletteAnime->DoAnimatePalette(); mTowerMessage->SpendTime(); static DWORD var4479B4 = 0; static DWORD var4479B8 = 0; var4479B4++; if (var4479B8 == 0) var4479B8 = GetTickCount(); DWORD endTicks = GetTickCount(); if ((endTicks - var4479B8) >= 550) { if (mDisplayIPS) { char buf[12]; sprintf(buf, "%.2f", (var4479B4 * 1000.0f) / (endTicks - var4479B8)); T2_MAIN_WINDOW->mDbgIPS->GetDlgItem(1019)->SetWindowText(buf); } var4479B4 = 0; var4479B8 = endTicks; } SetModifiedFlag(); } /*virtual*/ void T2TowerDoc::DoDestruct(const CPoint &inPt) { #pragma var_order(ptC, result, theHit, var18, pt20, var24) POINT pt20 = inPt; POINT ptC = inPt; UT2Coordinate::QDToUnit(pt20, mZoomLevel); T2DrawableObject *var18 = NULL; BOOL var24 = false; HitTestResult result; int theHit = HitTest(inPt, result, true, mViewMode != kOutView); if (!result.obj) return; if (mViewMode == kOutView) { if (theHit == kHitOutObj) { var24 = DestructOutObj(inPt, pt20, (T2OutObj *) result.obj); if (var24) var18 = result.obj; } } else { if (theHit == kHitMover) { var24 = DestructMover(inPt, pt20, (T2Mover *) result.obj); if (var24) var18 = result.obj; } if (theHit == kHitTenant) { var24 = DestructTenant(inPt, pt20, (T2Tenant *) result.obj, false); if (var24) var18 = result.obj; } } if (var24 && mWorldDef && var18) { if (theHit == kHitOutObj) mWorldDef->SetLatestBuild(((T2OutObj *) var18)->GetToolDef(), false); else mWorldDef->SetLatestBuild((T2Equip *) var18, false); } } /*virtual*/ BOOL T2TowerDoc::DestructTenant(POINT inPt1, POINT inPt2, T2Tenant *inTenant, BOOL inSkipSounds) { if (inTenant->IsFloor() && !OutsideAreaCheck(inTenant, true)) return false; if (!inTenant->IsBuildFinish()) { // EN: Can not remove the item under construction until it is completed. GetTowerMessage()->BuildErr(52, NULL); if (!inSkipSounds) mSoundPlayer->Play("No", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); return false; } T2Name *theName = mNameDB->Search(inTenant); RECT destructRect = {0, 0, 0, 0}; PROCCODE result = inTenant->DoDestruct(this, inPt1, destructRect); if (result == ProcCode_1 && theName) { mNameDB->RemoveName(theName); delete theName; } if (!IsRectEmpty(&destructRect)) { CalcCraneUpdateRect(destructRect); mTowerMainView->InvalUnitRect(destructRect, true); } if (!inSkipSounds) { if (result == ProcCode_1) mSoundPlayer->Play("Destroy", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); else mSoundPlayer->Play("No", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); } return true; } BOOL T2TowerDoc::OutsideAreaCheck(T2Tenant *inTenant, BOOL inShowError) { RECT rect; inTenant->GetEquipArea(rect); for (int v = rect.top; v < rect.bottom; v++) { for (int h = rect.left; h < rect.right; h++) { if (mFloorInfo->GetOutObjID(v, h) != 0) { if (inShowError) { // EN: Can not remove this floor because an outside item is placed. GetTowerMessage()->BuildErr(69 /*nice*/, NULL); } return false; } } } return true; } void T2TowerDoc::CalcCraneUpdateRect(RECT &ioRect) { RECT rect; RECT craneArea; int i; rect.top = rect.left = 0; rect.right = mWorldDef->m190.x; rect.bottom = mWorldDef->m190.y; for (i = 0; i < mCraneCount; i++) { craneArea = rect; OffsetRect(&craneArea, mCranePosArray[i].x, mCranePosArray[i].y); UnionRect(&ioRect, &craneArea, &ioRect); } mWorldDef->CalcCranePos(this); for (i = 0; i < mCraneCount; i++) { craneArea = rect; OffsetRect(&craneArea, mCranePosArray[i].x, mCranePosArray[i].y); UnionRect(&ioRect, &craneArea, &ioRect); } } /*virtual*/ BOOL T2TowerDoc::DestructMover(POINT inPt1, POINT inPt2, T2Mover *inMover) { RECT destructRect = {0, 0, 0, 0}; if (inMover->DoDestruct(this, inPt1, destructRect) == ProcCode_1) { mSoundPlayer->Play("Destroy", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); mTowerMainView->InvalUnitRect(destructRect, true); return true; } return true; } /*virtual*/ BOOL T2TowerDoc::DestructOutObj(POINT inPt1, POINT inPt2, T2OutObj *inOutObj) { CRect rect; if (inOutObj->DoDestruct(this, 0, inPt1, inPt2, rect) == ProcCode_1) { mOuterObjList->RemoveItemsAt(1, mOuterObjList->FetchIndexOf(&inOutObj)); mSoundPlayer->Play("Destroy", SoundMask_20, SoundFlags_20, &inPt2, PlayMode_2, 100); mTowerMainView->InvalUnitRect(rect, true); CalcCraneUpdateRect(rect); mTowerMainView->InvalUnitRect(rect, true); return true; } return false; } /*virtual*/ BOOL T2TowerDoc::DoClickByTenantTool(CRect inRect, T2TenantDef *inDef, unsigned int inValiation) { #pragma var_order(rect, clickResult, result) if (!inDef) return false; _200 = 0; RECT rect = inRect; mFundsOnClick = GetCurrentFunds(); _1A4 = NULL; int clickResult = 0; clickResult = inDef->ClickProc(this, &rect, inValiation); _1BC = inRect.TopLeft(); m1A0 = inDef; mValiation = inValiation; CalcDragMask(inRect); BOOL result = towerDoc_vf248(rect); mTowerMainView->tmv_vf120(); if (!clickResult) { free(mDragMask); mDragMask = NULL; } return result; } /*virtual*/ void T2TowerDoc::DoDragByTenantTool(CRect inRect) { #pragma var_order(buildArea, pt) // TODO: name me CPoint pt = inRect.TopLeft(); RECT buildArea; mWorldDef->GetBuildArea(buildArea); pt.x = min(pt.x, buildArea.right); pt.x = max(pt.x, buildArea.left); pt.y = min(pt.y, buildArea.bottom); pt.y = max(pt.y, buildArea.top); if (mDragMask) { #pragma var_order(rect, pt2) CRect rect; POINT pt2; pt2.y = _1BC.y; if (_1BC.x <= pt.x) { for (pt2.x = _1BC.x; pt2.x <= pt.x; pt2.x += inRect.Width()) { if (mDragMask[pt2.x].x0 == kDm1) break; rect.top = pt2.y; rect.left = pt2.x; rect.bottom = pt2.y + inRect.Height(); rect.right = pt2.x + inRect.Width(); towerDoc_vf248(rect); } } else { for (pt2.x = _1BC.x; pt2.x >= pt.x; pt2.x -= inRect.Width()) { if (mDragMask[pt2.x].x0 == kDm1) break; rect.top = pt2.y; rect.left = pt2.x; rect.bottom = pt2.y + inRect.Height(); rect.right = pt2.x + inRect.Width(); towerDoc_vf248(rect); } } mTowerMainView->tmv_vf120(); } } /*virtual*/ void T2TowerDoc::DoReleaseByTenantTool(CRect inRect) { CPoint centerPt = inRect.CenterPoint(); if (_200 > 0) { if (m1A0 && !m1A0->IsFloor()) mSoundPlayer->Play("Build2", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); else if (m1A0 && m1A0->IsFloor()) mSoundPlayer->Play("Build", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); RECT craneUpdateRect = {0, 0, 0, 0}; CalcCraneUpdateRect(craneUpdateRect); mTowerMainView->InvalUnitRect(craneUpdateRect, true); } int moneySpent = mFundsOnClick - GetCurrentFunds(); if (inRect.top >= mWorldDef->mGroundLine && !m1A0->IsFloor() && moneySpent >= 65) { T2TreasureStatus status; if (mWorldDef->CheckTreasure(this, &status)) { T2TreasureDialog::ShowTreasureDialog(this, &status); int winnings = status._0; DoPay(-winnings, kFundGroup4); } } if (mDragMask) { free(mDragMask); mDragMask = NULL; } } /*virtual*/ void T2TowerDoc::CalcDragMask(CRect inRect) { RECT buildArea; mWorldDef->GetBuildArea(buildArea); int width = mWorldDef->GetWidth(); mDragMask = (DragMask *) malloc(width * sizeof(DragMask)); int i; for (i = 0; i < width; i++) { mDragMask[i].x0 = kDm1; mDragMask[i].x4 = 0; SetRectEmpty(&mDragMask[i].rect); } int funds = GetCurrentFunds(); CalcDragMaskPoint(inRect, funds, mDragMask, 0, false); if (mDragMask[inRect.left].x0 == kDm0) { CRect rect = inRect; for (i = inRect.left + inRect.Width(); i < width; i += inRect.Width()) { rect.left = i; rect.right = i + inRect.Width(); if (CalcDragMaskPoint(rect, funds, mDragMask, 2, false) != kDm0) break; } funds = mDragMask[inRect.left].x4; for (i = inRect.left - m1A0->mWidth; i >= 0; i -= inRect.Width()) { rect.left = i; rect.right = i + inRect.Width(); if (CalcDragMaskPoint(rect, funds, mDragMask, 1, false) != kDm0) break; } } } /*virtual*/ int T2TowerDoc::CalcDragMaskPoint(CRect &ioRect, int &ioFunds, DragMask *inArray, int inMode, BOOL inShowError) { int h = ioRect.left; if (ioFunds < 0) return true; if (inArray && inArray[h].x0 == kDm2) return true; RECT area = ioRect; unsigned int valiation; if (!m1A0->IsFloor()) { if (area.bottom == mWorldDef->mGroundLine) valiation = 1; else valiation = 0; } else { valiation = mValiation; } int cost = 0; BOOL success = CheckTenantArea(area, m1A0, inShowError, false); if (success && success) { RECT rect2 = area; BOOL isSkyBridge = false; CProgramPlugin *thePlugin = m1A0->GetPlugin(); isSkyBridge = (thePlugin && thePlugin->GetID() == 'SKYB'); if (!isSkyBridge) { success = mFloorDef->AreaCheck( this, rect2, valiation | (!m1A0->IsFloor() ? kAreaCheckFlag10000 : 0) | ((inMode == 1) ? kAreaCheckFlag1000 : 0) | ((inMode == 2) ? kAreaCheckFlag100 : 0), inShowError ) == AreaCheckCode_1; } if (success) cost += mFloorDef->CalcPayment(this, rect2, valiation); if (success && !m1A0->IsFloor()) { success = (m1A0->AreaCheck(this, area, mValiation, inShowError) == AreaCheckCode_1); cost += m1A0->CalcPayment(this, area, mValiation); } if (success) { if (ioFunds >= cost) { ioFunds -= cost; ioRect = area; if (inArray) { for (int i = area.left; i < area.right; i++) { if (inArray[i].x0 != kDm0) inArray[i].x0 = kDm2; } inArray[h].x0 = kDm0; inArray[h].x4 = ioFunds; inArray[h].rect = area; } } else { success = false; if (inShowError) { // EN: Shortage of construction money. GetTowerMessage()->BuildErr(10, NULL); } } } } if (inArray) return inArray[h].x0; return success ? kDm0 : kDm1; } /*virtual*/ BOOL T2TowerDoc::CheckTenantArea(const RECT &inRect, T2TenantDef *inTenantDef, BOOL inShowErr, BOOL inUnkFlag) { RECT buildArea; mWorldDef->GetBuildArea(buildArea); if (inRect.top < buildArea.top || inRect.bottom > buildArea.bottom || inRect.left < buildArea.left || inRect.right > buildArea.right) { if (inShowErr) { // EN: Can not place items here. GetTowerMessage()->BuildErr(8, NULL); } return false; } if (!mFloorInfo->IsAreaBuildable(inRect)) { if (inShowErr) { // EN: Can not place items here. GetTowerMessage()->BuildErr(8, NULL); } return false; } if (!inUnkFlag) { if (!m1A0->IsFloor()) { if (m1A0->IsSetAttribute(kTenantAttrOnlyGroundFloor)) { if (inRect.bottom != mWorldDef->mGroundLine) { if (inShowErr) { // EN: This item can only be placed on the lobby floor. GetTowerMessage()->BuildErr(23, NULL); } return false; } } else { if (mWorldDef->mGroundLine > inRect.top && inRect.bottom > (mWorldDef->mGroundLine - mWorldDef->GetLobbyHeight())) { if (inShowErr) { // EN: Can not place this item on the lobby floor. GetTowerMessage()->BuildErr(24, NULL); } return false; } } if (m1A0->IsSetAttribute(kTenantAttrOnlyAboveGround)) { if (inRect.bottom > mWorldDef->mGroundLine) { if (inShowErr) { // EN: Can not place this item underground. GetTowerMessage()->BuildErr(6, NULL); } return false; } } if (m1A0->IsSetAttribute(kTenantAttrOnlyUnderground)) { if (inRect.top < mWorldDef->mGroundLine) { if (inShowErr) { // EN: Can not place this item above ground. GetTowerMessage()->BuildErr(7, NULL); } return false; } } } BOOL isBuildingFloor = m1A0->IsFloor(); POSITION pos = mObjectQueue->GetHeadPosition(); while (pos) { RECT tmp; T2Equip *equip = (T2Equip *) mObjectQueue->GetNext(pos); if (IntersectRect(&tmp, &inRect, &equip->mArea)) { if (inShowErr) { // EN: Can not place items where something else already exists. GetTowerMessage()->BuildErr(9, NULL); } return false; } } for (int v = inRect.top; v < inRect.bottom; v++) { for (int h = inRect.left; h < inRect.right; h++) { T2Tenant *theTenant = mFloorInfo->GetTenant(v, h); if (theTenant && (isBuildingFloor || !theTenant->IsFloor())) { if (inShowErr) { // EN: Can not place items where something else already exists. GetTowerMessage()->BuildErr(9, NULL); } return false; } } } } return true; } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf248(CRect inRect) { BOOL result = true; int cost2 = 0; int beginH = inRect.left; CPoint centerPt = inRect.CenterPoint(); if (mDragMask[beginH].x0 == kDm3) result = false; if (result && m1A0->GetMaxBuildCount() != 0) { if (m1A0->GetCurBuildCount() >= m1A0->GetMaxBuildCount()) { if (_B0) { // EN: Can not make additional placement of this item. GetTowerMessage()->BuildErr(11, NULL); } result = false; } } if (result) { int funds = GetCurrentFunds(); CalcDragMaskPoint(inRect, funds, NULL, 0, _B0); if (mDragMask[beginH].x0 != kDm0) result = false; } CRect rect = inRect; if (result) { if (!CheckTenantArea(rect, m1A0, false, false)) result = false; } if (result) { int cost = 0; int h, v; if (!m1A0->IsFloor()) { for (v = rect.top; v < rect.bottom; v++) { BOOL isLobby; if (rect.bottom == mWorldDef->mGroundLine) isLobby = true; else isLobby = false; for (h = rect.left; h < rect.right; h++) { if (!mFloorInfo->GetTenant(v, h)) { RECT newTenantRect; newTenantRect.top = v; newTenantRect.left = h; newTenantRect.bottom = v + 1; for (; h < rect.right; h++) { if (mFloorInfo->GetTenant(v, h)) break; } newTenantRect.right = h; mFloorDef->AreaCheck(this, newTenantRect, 3, false); cost += mFloorDef->CalcPayment(this, newTenantRect, 0); h = newTenantRect.right; T2Tenant *theTenant = AssignNewTenant(mFloorDef, newTenantRect, (isLobby == 1)); theTenant->StartBuild(); mFloorInfo->FillTenantID(theTenant->mArea, theTenant->mEquipID); theTenant->GetEquipDef()->BuildFinish(this, theTenant); mTowerMainView->InvalUnitRect(newTenantRect, true); mTowerMainView->tmv_vf120(); } } } } if (_1A4 && !_1A4->IsFloor()) _1A4 = NULL; if (!_1A4) { _1A4 = AssignNewTenant(m1A0, rect, mValiation); TenantAdded(_1A4); cost += m1A0->CalcPayment(this, rect, mValiation); } BOOL isFloor = false; if (!_1A4->IsFloor()) { mSoundPlayer->Play("Build1", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); mObjectQueue->AddItem(_1A4); CheckBuildQueue(); } else { mSoundPlayer->Play("BuildFloor", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_0, 100); RECT origArea = _1A4->mArea; if (rect.left < _1A4->mArea.left) _1A4->mArea.left = rect.left; if (_1A4->mArea.right < rect.right) _1A4->mArea.right = rect.right; mFloorDef->AreaCheck(this, _1A4->mArea, mValiation, false); if (!EqualRect(&origArea, &_1A4->mArea) || EqualRect(&rect, &_1A4->mArea)) { if (!EqualRect(&origArea, &_1A4->mArea)) cost += mFloorDef->CalcPayment(this, _1A4->mArea, mValiation); mFloorDef->OptionProc(this, _1A4, NULL); mFloorInfo->FillTenantID(_1A4->mArea, _1A4->mEquipID); _1A4->StartBuild(); _1A4->GetEquipDef()->BuildFinish(this, _1A4); isFloor = true; } } if (isFloor) mTowerMainView->InvalUnitRect(_1A4->mArea, true); DoPay(cost, kFundGroup1); DoPay(-cost2, kFundGroup4); mWorldDef->SetLatestBuild(_1A4, true); for (h = inRect.left; h < inRect.right; h++) mDragMask[h].x0 = kDm3; InvalFunds(); _200++; } else { if (_200 == 0) { CPoint pt = inRect.CenterPoint(); mSoundPlayer->Play("No", SoundMask_20, SoundFlags_20, &pt, PlayMode_2, 100); _200--; } } return result; } /*virtual*/ T2Tenant *T2TowerDoc::AssignNewTenant(T2TenantDef *inTenantDef, RECT &inRect, unsigned int inValiation) { T2Tenant *theTenant = mFloorInfo->FindUnusedTenant(); theTenant->InitTenant(inTenantDef, inRect, inValiation); return theTenant; } /*virtual*/ void T2TowerDoc::CheckBuildQueue() { POSITION position = mObjectQueue->GetHeadPosition(); while (position) { POSITION oldPosition = position; T2Tenant *tenant = (T2Tenant *) mObjectQueue->GetNext(position); BOOL isWait = false; for (int v = tenant->mArea.top; v < tenant->mArea.bottom; v++) { for (int h = tenant->mArea.left; h < tenant->mArea.right; h++) { T2Tenant *otherTenant = mFloorInfo->GetTenant(v, h); if (otherTenant && otherTenant->IsFloor()) { if (!otherTenant->IsBuildFinish()) { isWait = true; break; } h = otherTenant->mArea.right - 1; } } } if (!isWait) { T2Tenant *theFloor = mFloorInfo->GetTenant(tenant->mArea.top, tenant->mArea.left); tenant->SetFloorID(mFloorInfo); mFloorInfo->FillTenantID(tenant->mArea, tenant->mEquipID); tenant->StartBuild(); RECT updateRect = tenant->mArea; if (tenant->mArea.right < theFloor->mArea.right) { updateRect.right = theFloor->mArea.right; theFloor->SetDrawMode(DrawMode3); } mTowerMainView->InvalUnitRect(updateRect, true); mObjectQueue->RemoveItem(oldPosition); position = mObjectQueue->GetHeadPosition(); } } } /*virtual*/ BOOL T2TowerDoc::DoClickByMoverTool(CRect inRect, T2MoverDef *inDef, unsigned int inValiation, BOOL inIsFromMouseMove) { if (!inDef) return false; int cost = 0; RECT moverRect = inRect; #line 3246 _ASSERT(!inDef->ClickProc(this, &moverRect, inValiation)); if (!mFloorInfo->IsAreaBuildable(moverRect)) return false; AREACHECKCODE theAreaCheck = inDef->AreaCheck(this, moverRect, 0, !inIsFromMouseMove); if (theAreaCheck == AreaCheckCode_0) return false; if (theAreaCheck == AreaCheckCode_0) return false; if (theAreaCheck == AreaCheckCode_1) { moverRect.top -= inDef->mAddSize.top; moverRect.left -= inDef->mAddSize.left; moverRect.bottom -= inDef->mAddSize.bottom; moverRect.right -= inDef->mAddSize.right; } CRect requiredSpace = moverRect; requiredSpace.left -= T2MoverDef::GetRequiredRequestSpace(); requiredSpace.right += T2MoverDef::GetRequiredRequestSpace(); CRect checkSpace, buildArea; mFloorInfo->GetBuildArea(buildArea); checkSpace.IntersectRect(buildArea, requiredSpace); if (checkSpace != requiredSpace || !mFloorInfo->IsAllTenant(requiredSpace)) { if (!inIsFromMouseMove) { if (inDef->IsStair()) { // EN: can not be placed there. GetTowerMessage()->BuildErr(41, inDef); } else { // EN: Can not place elevator system there. GetTowerMessage()->BuildErr(42, NULL); } } return false; } T2FInfoAreaIterator iter(*mFloorInfo, requiredSpace); T2UnitInfo *theUnitInfo; while (iter.Next(theUnitInfo)) { unsigned int theTenantID = theUnitInfo->GetTenantID(); if (theTenantID != 0) { T2Tenant *theTenant = mFloorInfo->GetTenant(theTenantID); if (theTenant && theTenant->IsSetAttribute(kTenantAttr40000)) { if (!inIsFromMouseMove) { // EN: Can not place a transit system on the Sky Bridge. GetTowerMessage()->BuildErr(72, NULL); } return false; } } } if (!mFloorInfo->IsEnoughSideSpace(inRect)) { if (!inIsFromMouseMove) { if (inDef->IsStair()) { // EN: requires space on both sides. GetTowerMessage()->BuildErr(32, inDef); } else { // EN: The elevator item requires space on both sides. GetTowerMessage()->BuildErr(33, NULL); } } return false; } BOOL finish = true; if (theAreaCheck == AreaCheckCode_1) { cost = inDef->CalcPayment(this, moverRect, 0); if (cost > GetCurrentFunds()) { if (!inIsFromMouseMove) { // EN: Shortage of construction money. GetTowerMessage()->BuildErr(10, NULL); } return false; } if (!inIsFromMouseMove) { mFloorInfo->FinishBuildFloor(this, requiredSpace); finish = towerDoc_vf258(moverRect, inDef); } } else if (theAreaCheck == AreaCheckCode_2) { cost = inDef->m194; if (cost == 0) cost = inDef->CalcPayment(this, moverRect, 0); if (cost > GetCurrentFunds()) { if (!inIsFromMouseMove) { // EN: Shortage of construction money. GetTowerMessage()->BuildErr(10, NULL); } return false; } if (!inIsFromMouseMove) { mFloorInfo->FinishBuildFloor(this, requiredSpace); finish = towerDoc_vf25C(moverRect, inDef); } } if (!inIsFromMouseMove && finish) { DoPay(cost, kFundGroup1); mWorldDef->SetLatestBuild(inDef, true); } return true; } /*virtual*/ void T2TowerDoc::DoDragByMoverTool(CRect inRect) { // empty } /*virtual*/ void T2TowerDoc::DoReleaseByMoverTool(CRect inRect) { // empty } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf258(const RECT &inRect, T2MoverDef *inMoverDef) { if (!inMoverDef) return false; CRect cRect = inRect; CPoint centerPt = cRect.CenterPoint(); RECT moverArea = inRect; BOOL didBuildMover = false; PROCCODE result = inMoverDef->DoBuildProc(this, moverArea, 0); if (result == ProcCode_1) { mSoundPlayer->Play("Build", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); didBuildMover = true; } if (result == ProcCode_0) { T2Mover *theMover = mFloorInfo->FindUnusedMover(); theMover->InitMover(inMoverDef, moverArea, 0); mFloorInfo->FillMoverID(theMover->mArea, theMover->mEquipID); theMover->GetEquipDef()->BuildFinish(this, theMover); moverArea = theMover->mArea; } mTowerMainView->InvalUnitRect(moverArea); mTowerMainView->tmv_vf120(); return didBuildMover; } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf25C(const RECT &inRect, T2MoverDef *inMoverDef) { if (!inMoverDef) return false; CRect buildRect = inRect; CPoint centerPt = buildRect.CenterPoint(); RECT moverArea = inRect; T2FInfoAreaIterator iter(*mFloorInfo, inRect); T2UnitInfo *unitInfo; T2Mover *theMover; while (iter.Next(unitInfo)) { unsigned int theMoverID = unitInfo->GetMoverID(); if (theMoverID != 0) { theMover = mFloorInfo->GetMover(theMoverID); if (theMover->GetEquipType() == inMoverDef->GetEquipType()) break; } } if (inMoverDef->AddModuleProc(this, theMover, &moverArea) == ProcCode_1) { mSoundPlayer->Play("Build1", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); return true; } return false; } /*virtual*/ BOOL T2TowerDoc::DoClickByFingerTool(CPoint inPt) { CPoint pt = inPt; UT2Coordinate::QDToUnit(pt, mZoomLevel); T2Mover *theMover = mFloorInfo->GetMover(pt.y, pt.x); m1C4 = theMover; if (theMover) { if (theMover->GetPartFromPoint(this, inPt, NULL)) return theMover->GetEquipDef()->FingerToolProc(this, theMover, inPt, MouseEvent_0); } T2Tenant *theTenant = mFloorInfo->GetTenant(pt.y, pt.x); m1C4 = theTenant; if (theTenant) { if (theTenant->GetPartFromPoint(this, inPt, NULL)) return theTenant->GetEquipDef()->FingerToolProc(this, theTenant, inPt, MouseEvent_0); } return false; } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf23C(CPoint inPt) { CPoint pt = inPt; UT2Coordinate::QDToUnit(pt, mZoomLevel); if (pt.x < 0) return false; if (pt.x >= mFloorInfo->GetHRange()) return false; if (pt.y < 0) return false; if (pt.y >= mFloorInfo->GetVRange()) return false; T2Mover *theMover = mFloorInfo->GetMover(pt.y, pt.x); if (theMover) { T2MoverDef *theMoverDef = (T2MoverDef *) theMover->GetEquipDef(); if (theMoverDef) { PARTCODE part = theMoverDef->GetPartFromPoint(this, theMover, inPt, NULL); if (part == PartCode_1 || part == PartCode_3) return true; } } return false; } /*virtual*/ void T2TowerDoc::DoDragByFingerTool(CPoint inPt) { m1C4->GetEquipDef()->FingerToolProc(this, m1C4, inPt, MouseEvent_1); } /*virtual*/ void T2TowerDoc::DoReleaseByFingerTool(CPoint inPt) { m1C4->GetEquipDef()->FingerToolProc(this, m1C4, inPt, MouseEvent_2); m1C4 = NULL; } /*virtual*/ void T2TowerDoc::DoClickByOutObjTool(CRect inRect, T2OuterObjDef *inDef, unsigned int inValiation) { towerDoc_vf260(inRect, inDef); } /*virtual*/ void T2TowerDoc::DoDragByOutObjTool(CRect inRect) { // empty } /*virtual*/ void T2TowerDoc::DoReleaseByOutObjTool(CRect inRect) { // empty } /*virtual*/ void T2TowerDoc::DoGetInfo(CPoint inPt) { HitTestResult result; int theHit = HitTest(inPt, result, false, mViewMode != kOutView); if (!result.obj) return; if (theHit != kHitBkgndInfo && theHit != kHitSpriteObj) { if (mViewMode != kOutView || (mViewMode == kOutView && theHit == kHitOutObj)) { if (theHit == kHitMover) ((T2Mover *) result.obj)->ShowInfoDialog(this, inPt); else ((T2Equip *) result.obj)->ShowInfoDialog(this); } } } /*virtual*/ void T2TowerDoc::towerDoc_vf228(CPoint inPt) { // empty } /*virtual*/ void T2TowerDoc::DoInterview(CPoint inPt) { CPoint pt = inPt; UT2Coordinate::QDToUnit(pt, mZoomLevel); T2People *thePeople = mFloorInfo->FindPeople(pt.y, pt.x); if (thePeople) thePeople->Interview(this); } /*virtual*/ void T2TowerDoc::DoSearchRangeTool(CPoint inPt) { CPoint pt = inPt; UT2Coordinate::QDToUnit(pt, mZoomLevel); T2Tenant *theClickTenant = mFloorInfo->GetTenant(pt.y, pt.x); if (theClickTenant && !theClickTenant->IsFloor()) SetSearchRangeFrom(theClickTenant); } /*virtual*/ void T2TowerDoc::towerDoc_vf260(const RECT &inRect, T2OuterObjDef *inOuterObjDef) { CRect rect = inRect; CPoint centerPt = rect.CenterPoint(); if (inOuterObjDef->AreaCheck(this, rect, 0, true) == AreaCheckCode_1) { mSoundPlayer->Play("Build", SoundMask_20, SoundFlags_20, ¢erPt, PlayMode_2, 100); T2OutObj *theOutObj = mFloorInfo->FindUnusedOutObj(); inOuterObjDef->InitObject(theOutObj); theOutObj->_3C = rect; mOuterObjList->Add(&theOutObj); mFloorInfo->FillOutObjID(rect, theOutObj->mID); mTowerMainView->InvalUnitRect(rect, true); mWorldDef->SetLatestBuild(inOuterObjDef, true); DoPay(inOuterObjDef->mPrice[0], kFundGroup1); theOutObj->InitOutObj(inOuterObjDef, rect, mValiation); } } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf288(RECT &ioRect, int &ioCost) { int cost = ioCost, x, y; RECT rect; RECT origRect = ioRect; for (y = ioRect.top; y < ioRect.bottom; y++) { for (x = ioRect.left; x < ioRect.right; x++) { if (mFloorInfo->GetTenant(y, x) == 0) { rect.top = y; rect.bottom = y + 1; rect.left = x; for (; x < ioRect.right; x++) { if (mFloorInfo->GetTenant(y, x)) break; } rect.right = x; if (!CheckTenantArea(rect, mFloorDef, false, true)) return false; if (!mWorldDef->TenantAreaCheck(this, rect, false)) return false; if (mFloorDef->AreaCheck(this, rect, 0, false) != AreaCheckCode_1) return false; cost += mFloorDef->CalcPayment(this, rect, 0); if (cost > GetCurrentFunds()) return false; UnionRect(&ioRect, &ioRect, &rect); } } } ioCost = cost; return true; } /*virtual*/ void T2TowerDoc::FillFloor(const RECT &inRect) { RECT rect; int x, y; for (y = inRect.top; y < inRect.bottom; y++) { for (x = inRect.left; x < inRect.right; x++) { if (mFloorInfo->GetTenantID(y, x) == 0) { rect.top = y; rect.bottom = y + 1; rect.left = x; for (; x < inRect.right; x++) { if (mFloorInfo->GetTenant(y, x)) break; } rect.right = x; T2Tenant *theTenant = AssignNewTenant(mFloorDef, rect, 0); theTenant->SetStatus(kTenantStatus1); mFloorInfo->FillTenantID(theTenant->mArea, theTenant->mEquipID); theTenant->GetEquipDef()->BuildFinish(this, theTenant); theTenant->Idle(this); CalcCraneUpdateRect(rect); mTowerMainView->InvalUnitRect(rect, true); } } } mFloorInfo->FinishBuildFloor(this, inRect); } /*virtual*/ void T2TowerDoc::towerDoc_vf298() { if (!m1CC) m1CC = 1; } /*virtual*/ void T2TowerDoc::BreakoutEmergency() { mFloorInfo->GetTenantArrayList()->BreakoutEmergency(this); mFloorInfo->GetRequestArrayList()->BreakoutEmergency(this); mPeopleArrayList->BreakoutEmergency(this); } void T2TowerDoc::OnUpdateDebugStepRun(CCmdUI *pCmdUI) { pCmdUI->SetCheck(mDebugStepRunEnabled != FALSE); } void T2TowerDoc::OnDebugStepRun() { mDebugStepRunEnabled = !mDebugStepRunEnabled; T2_APP->app_vfA4(!mDebugStepRunEnabled); T2_MAIN_WINDOW->mDbgStepRun->ShowWindow(mDebugStepRunEnabled ? SW_SHOW : SW_HIDE); } void T2TowerDoc::InvalClock() { T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; msgWindow->GetDlgItem(1000)->InvalidateRect(NULL); } void T2TowerDoc::InvalCalender() { T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; msgWindow->GetDlgItem(1001)->InvalidateRect(NULL); } void T2TowerDoc::InvalFunds() { T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; msgWindow->GetDlgItem(1002)->InvalidateRect(NULL); } void T2TowerDoc::InvalPopulation() { T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; msgWindow->GetDlgItem(1003)->InvalidateRect(NULL); } void T2TowerDoc::SetupGradeAnimation() { T2MsgWindow *msgWindow = T2_MAIN_WINDOW->mMsgWindow; if (msgWindow) { T2DlgItemAnimation *theAnimation = (T2DlgItemAnimation *) msgWindow->GetDlgItem(1005); theAnimation->SetAnimation(mWorldDef->mModuleHandle, mWorldDef->m148[mGameLevel - 1], 0); theAnimation->SetAnimationParam(100, 0); } } void T2TowerDoc::x42670C() { // empty } void T2TowerDoc::x426717() { // empty } void T2TowerDoc::CycleOutlinePalette() { static int sMode = 0; static int sCounter = 0; PALETTEENTRY colors[2]; if (sMode == 0) { colors[0].peRed = 1; colors[0].peGreen = 1; colors[0].peBlue = 1; colors[0].peFlags = PC_RESERVED; colors[1].peRed = 255; colors[1].peGreen = 255; colors[1].peBlue = 255; colors[1].peFlags = PC_RESERVED; sCounter++; if (sCounter == 2) sCounter = 0; } else if (sMode == 1) { int i = ((sCounter + 1) * 254) / 3; colors[0].peRed = i + 1; colors[0].peGreen = i + 1; colors[0].peBlue = i + 1; colors[0].peFlags = PC_RESERVED; colors[1].peRed = 255 - i; colors[1].peGreen = 255 - i; colors[1].peBlue = 255 - i; colors[1].peFlags = PC_RESERVED; sCounter++; if (sCounter == 2) sCounter = 0; } else if (sMode == 2) { colors[0].peRed = 255; colors[0].peGreen = 255; colors[0].peBlue = 255; colors[0].peFlags = PC_RESERVED; colors[1].peRed = 1; colors[1].peGreen = 1; colors[1].peBlue = 1; colors[1].peFlags = PC_RESERVED; sCounter++; if (sCounter == 2) sCounter = 0; } else if (sMode == 3) { int i = ((sCounter + 1) * 254) / 3; colors[0].peRed = 255 - i; colors[0].peGreen = 255 - i; colors[0].peBlue = 255 - i; colors[0].peFlags = PC_RESERVED; colors[1].peRed = i + 1; colors[1].peGreen = i + 1; colors[1].peBlue = i + 1; colors[1].peFlags = PC_RESERVED; sCounter++; if (sCounter == 2) sCounter = 0; } if (sCounter == 0) { sMode++; if (sMode == 4) sMode = 0; } UpdatePalette(253, 2, colors); } /*virtual*/ void T2TowerDoc::UpdatePalette(int startIndex, int count, PALETTEENTRY *entries) { if (mIsPaletteMode) { mWorldDef->GetPalette()->AnimatePalette(startIndex, count, entries); } else { mWorldDef->GetPalette()->SetPaletteEntries(startIndex, count, entries); mPaletteUpdated = true; } } /*virtual*/ void T2TowerDoc::DoPayTool(int inCost, short inFundGroup, T2ToolDef *inToolDef) { if (inCost == 0) return; mSettlement->DoPayTool(inCost, inFundGroup, inToolDef); InvalFunds(); } /*virtual*/ void T2TowerDoc::DoPayTool(int inCost, short inFundGroup, T2ToolDef *inToolDef, const char *inMessage, int inLimitLength, int inLimitType) { if (inCost == 0) return; mSettlement->DoPayTool(inCost, inFundGroup, inToolDef); mSettlement->EmitPayToolMessage(this, inToolDef, inMessage, inLimitLength, inLimitType); InvalFunds(); } /*virtual*/ void T2TowerDoc::DoPay(int inCost, short inFundGroup) { if (inCost == 0) return; mSettlement->DoPay(inCost, inFundGroup); InvalFunds(); } /*virtual*/ void T2TowerDoc::CallbackZoomIn(POINT inPt) { mTowerMainView->DoZoomIn(inPt); x42670C(); } /*virtual*/ void T2TowerDoc::CallbackZoomOut() { mTowerMainView->DoZoomOut(); x42670C(); } /*virtual*/ void T2TowerDoc::CallbackInView() { SetViewMode(kInView); mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::CallbackOutView() { SetViewMode(kOutView); mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::CallbackPriceView() { SetViewMode(kPriceView); mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::CallbackMaintView() { SetViewMode(kMaintView); mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::CallbackTransView() { SetViewMode(kTransView); mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::CallbackEvalView() { SetViewMode(kEvalView); mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::CallbackPause(BOOL inPause) { towerDoc_vf290(inPause); x429B01(inPause); } /*virtual*/ void T2TowerDoc::CallbackCalendar() { } /*virtual*/ void T2TowerDoc::CallbackFunds() { } /*virtual*/ void T2TowerDoc::CallbackPopulation() { } void T2TowerDoc::OnUpdateDebugIdleSpeedMeasuring(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnDebugIdleSpeedMeasuring() { m20C = time(NULL); time_t t; retry: t = time(NULL); if (t == m20C) goto retry; m20C = t; m210 = 0; m214 = 0; } void T2TowerDoc::OnUpdateDebugAllLoadMeasuring(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnDebugAllLoadMeasuring() { m20C = time(NULL); time_t t; retry: t = time(NULL); if (t == m20C) goto retry; m20C = t; m210 = 0; m214 = 1; } /*virtual*/ void T2TowerDoc::towerDoc_vf290(BOOL inPause) { if (inPause) { mPause++; } else if (mPause > 0) { mPause--; } else { #line 4043 _ASSERT(!1); } TRACE("\x81\x9FPAUSE COUNTER = %d\n", mPause); } void T2TowerDoc::OnUpdateDebugPool(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnDebugPool() { CString wndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); RECT theRect; SetRect(&theRect, 300, 80, 500, 400); T2PoolView *thePoolView = new T2PoolView; thePoolView->Create(wndClass, "Pool", WS_THICKFRAME | WS_POPUPWINDOW | WS_VSCROLL | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE, theRect, AfxGetMainWnd(), NULL, WS_EX_TOOLWINDOW); thePoolView->SetPool(mPool); } void T2TowerDoc::OnUpdateDebugDisplayIPS(CCmdUI *pCmdUI) { pCmdUI->Enable(); pCmdUI->SetCheck(mDisplayIPS); } void T2TowerDoc::OnDebugDisplayIPS() { mDisplayIPS = !mDisplayIPS; T2_MAIN_WINDOW->mDbgIPS->ShowWindow(mDisplayIPS ? SW_SHOW : SW_HIDE); } /*virtual*/ void T2TowerDoc::LoadsWorldPlugin() { mWorldPluginSpecifier = mT2PluginLoader->FindPlugin(mWorldPluginID, 'WdPl'); if (!mWorldPluginSpecifier) { T2WorldSelectDlg *dlg = new T2WorldSelectDlg; dlg->ShowWorldSelectDlg(this, mT2PluginLoader, false); } else { towerDoc_vfCC(mWorldPluginSpecifier, false); } } void T2TowerDoc::OnDebugPeople() { CString wndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH)); RECT theRect; SetRect(&theRect, 200, 80, 600, 400); DbgPeopleView *thePeopleView = new DbgPeopleView; thePeopleView->SetPeople(mPeopleArrayList); thePeopleView->Create(wndClass, "People link", WS_THICKFRAME | WS_POPUPWINDOW | WS_VSCROLL | WS_CAPTION | WS_CLIPCHILDREN | WS_VISIBLE, theRect, AfxGetMainWnd(), NULL, WS_EX_TOOLWINDOW); } void T2TowerDoc::OnUpdateDebugPeople(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::UpdateAllTenant() { CRect rect; mTowerMainView->GetVisibleUnitRect(rect); mFloorInfo->SetTenantDrawModeByRect(rect, DrawMode3); mTowerMainView->Invalidate(false); mTowerMainView->tmv_vf120(); } /*virtual*/ BOOL T2TowerDoc::IsRectInView(const RECT &inRect) { CRect theRect, viewRect, intersect; theRect = inRect; UT2Coordinate::UnitToQD(theRect, mZoomLevel); mTowerMainView->GetClientRect(viewRect); viewRect.OffsetRect(mTowerMainView->mScrollOffset); return intersect.IntersectRect(theRect, viewRect); } /*virtual*/ void T2TowerDoc::SetWalkRate(int inWalkRate) { mWalkRate = inWalkRate; mPeopleArrayList->SetWalkPeople(mWalkRate); UpdateAllTenant(); } /*virtual*/ void T2TowerDoc::AddFavoritePeople(T2People *inPeople) { if (inPeople) { #line 4141 _ASSERT(!inPeople->IsFavorite()); CString roomName, peopleDefaultName, name; unsigned int theTenantID = (inPeople->GetWorkTenant() > 1) ? inPeople->GetWorkTenant() : (inPeople->GetHomeTenant() > 1) ? inPeople->GetHomeTenant() : 1; T2Tenant *theTenant = GetFloorInfo()->GetTenantArrayList()->GetTenantByID(theTenantID); if (theTenant) { int roomNumber = theTenant->GetRoomNumber(GetFloorInfo()); UT2Utils::GetRoomNumberString(roomNumber, roomName); roomName += "\x8D\x86\x8E\xBA"; } else { roomName = "\x83\x65\x83\x69\x83\x93\x83\x67\x82\xC8\x82\xB5"; } T2Name *theName = mNameDB->Search(inPeople); if (theName) { unsigned int id; theName->GetName(peopleDefaultName, id); } else { #line 4165 _ASSERT(inPeople->GetMatterDef() != NULL); _ASSERT(((T2PeopleDef *) inPeople->GetMatterDef())->GetSilhouetteDef() != NULL); ((T2PeopleDef *) inPeople->GetMatterDef())->GetSilhouetteDef()->GetName(peopleDefaultName); } name = roomName + "\x81\x40" + peopleDefaultName; int index = 2; while (mNameDB->Search(name) || mNameDB->Search(name, true)) { CString indexStr; indexStr.Format("%d", index++); name = roomName + "\x81\x40" + peopleDefaultName + " " + indexStr; } T2Name *newName = new T2Name(name, inPeople, true); mNameDB->Add(newName); inPeople->SetFavorite(true); _1E4 = true; } } /*virtual*/ void T2TowerDoc::AddFavoriteTenant(T2Tenant *inTenant) { if (inTenant) { #line 4192 _ASSERT(!inTenant->IsFavorite()); CString roomName, tenantDefaultName, name; int RoomNum = inTenant->GetRoomNumber(GetFloorInfo()); UT2Utils::GetRoomNumberString(RoomNum, roomName); roomName += "\x8D\x86\x8E\xBA"; T2Name *theName = mNameDB->Search(inTenant); if (theName) { unsigned int id; theName->GetName(tenantDefaultName, id); } else { inTenant->GetTypicalName(tenantDefaultName); } name = roomName + "\x81\x40" + tenantDefaultName; int index = 2; while (mNameDB->Search(name) || mNameDB->Search(name, true)) { CString indexStr; indexStr.Format("%d", index++); name = roomName + "\x81\x40" + tenantDefaultName + " " + indexStr; } T2Name *newName = new T2Name(name, inTenant, true); mNameDB->Add(newName); inTenant->SetFavorite(true); _1E4 = true; } } /*virtual*/ void T2TowerDoc::RemoveFavoritePeople(const char *inName, BOOL inFlag) { T2Name *theName = mNameDB->Search(inName, true); if (theName) { mNameDB->RemoveName(theName); T2People *thePeople = mPeopleArrayList->FindPeople(theName->GetID()); thePeople->SetFavorite(false); if (inFlag) return; _1E4 = true; } } /*virtual*/ void T2TowerDoc::RemoveFavoriteTenant(const char *inName, BOOL inFlag) { T2Name *theName = mNameDB->Search(inName, true); if (theName) { mNameDB->RemoveName(theName); T2Tenant *theTenant = mFloorInfo->GetTenantArrayList()->GetTenantByID(theName->GetID()); theTenant->SetFavorite(false); if (inFlag) return; _1E4 = true; } } /*virtual*/ void T2TowerDoc::RemoveFavoritePeople(T2People *inPeople, BOOL inFlag) { T2Name *theName = mNameDB->Search(inPeople, true); if (theName) { mNameDB->RemoveName(theName); T2People *thePeople = mPeopleArrayList->FindPeople(theName->GetID()); thePeople->SetFavorite(false); if (inFlag) return; _1E4 = true; } } /*virtual*/ void T2TowerDoc::RemoveFavoriteTenant(T2Tenant *inTenant, BOOL inFlag) { T2Name *theName = mNameDB->Search(inTenant, true); if (theName) { mNameDB->RemoveName(theName); T2Tenant *theTenant = mFloorInfo->GetTenantArrayList()->GetTenantByID(theName->GetID()); theTenant->SetFavorite(false); if (inFlag) return; _1E4 = true; } } /*virtual*/ void T2TowerDoc::towerDoc_vf1D4() { // empty } /*virtual*/ void T2TowerDoc::towerDoc_vf1D8() { // empty } /*virtual*/ BOOL T2TowerDoc::IsToiletFlagOn() const { BOOL isFlagOn = false; if (mToiletDenomi > 0) isFlagOn = (UT2Utils::Randomize(mToiletDenomi) == 0); return isFlagOn; } int T2TowerDoc::CheckGameLevel() { if (m1F0 == 0 && mWorldDef) m1F0 = mWorldDef->CheckGameLevelProc(this); if (m1F0 == 10005) mGameLevel++; else if (m1F0 == 10006) mGameLevel--; m1F0 = 0; return mGameLevel; } void T2TowerDoc::OnDebugGradeUp() { m1F0 = 10005; } void T2TowerDoc::OnDebugGradeDown() { m1F0 = 10006; } /*virtual*/ void T2TowerDoc::TenantAdded(T2Tenant *inTenant) { mRegistedTenantDB->AddItem(inTenant); } /*virtual*/ void T2TowerDoc::TenantRemoved(T2Tenant *inTenant) { mRegistedTenantDB->RemoveItem(inTenant); mFloorInfo->GetTenantArrayList()->TenantRemoved(inTenant->GetEquipID()); mPeopleArrayList->TenantRemoved(inTenant->GetEquipID()); } CPluginInfoArray *T2TowerDoc::MakePluginInfoArray() { CPluginInfoArray *theArray = new CPluginInfoArray; #line 4366 _ASSERT(theArray != NULL); CPluginInfo *worldPluginInfo = mWorldPlugin->GetPluginInfo(); theArray->Add(&worldPluginInfo); _MakePluginInfoArray(theArray, mTenantPlugins); _MakePluginInfoArray(theArray, mMoverPlugins); _MakePluginInfoArray(theArray, mOuterObjPlugins); _MakePluginInfoArray(theArray, mMoviePluginList); _MakePluginInfoArray(theArray, mHallEventPlugins); return theArray; } void T2TowerDoc::_MakePluginInfoArray(CPluginInfoArray *inResultArray, CFilePluginList *inPluginArray) { POSITION position = inPluginArray->GetHeadPosition(); while (position) { CFilePlugin *plugin = inPluginArray->GetNext(position); if (plugin->GetGameLevel() <= mGameLevel) { CPluginInfo *info = plugin->GetPluginInfo(); inResultArray->Add(&info); } } } /*virtual*/ void T2TowerDoc::towerDoc_vf184(int inFlags) { #pragma var_order(var14, var18, theToolWindow, specifier, theToolWindow2, numPlugins, str, pos) if (!(inFlags & _98)) return; T2ToolWindow *theToolWindow = T2_APP->mToolWindow; T2ToolWindow *theToolWindow2 = T2_APP->mToolWindow; int var14 = 0; T2TemplatePluginList *var18 = NULL; int numPlugins = 0; CString str; POSITION pos; T2PluginSpecifier *specifier; mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); var18 = mTenantTemplates; while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && (specifier->mSecretItem & inFlags) && !mTenantPlugins->GetItem(specifier->mID) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'TnPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && (specifier->mSecretItem & inFlags) && !mTenantPlugins->GetItem(specifier->mID) ) { T2TenantPlugin *theTenantPlugin = (T2TenantPlugin *) mT2PluginLoader->LoadPlugin(specifier); mTenantPlugins->Add(theTenantPlugin); theTenantPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); T2TenantDef *def = (T2TenantDef *) theTenantPlugin->GetTemplatePlugin(); theTenantPlugin->GetName(str); mTenantTemplates->Regist(def); if (def->IsFloor()) mFloorDef = def; if (!def->RequierToolIcon(theToolWindow2)) theToolWindow2->AddIcon(def->mStr48, NULL, 0, kToolOption1, def, 0, 1, this); theToolWindow2->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); LoadSoundForPlugin(def); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mMoverPlugins->GetItem(specifier->mID) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'MvPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mMoverPlugins->GetItem(specifier->mID) ) { T2MoverPlugin *theMoverPlugin = (T2MoverPlugin *) mT2PluginLoader->LoadPlugin(specifier); mMoverPlugins->Add(theMoverPlugin); theMoverPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); T2MoverDef *def = (T2MoverDef *) theMoverPlugin->GetTemplatePlugin(); theMoverPlugin->GetName(str); mMoverTemplates->Regist(def); if (!def->RequierToolIcon(theToolWindow2)) theToolWindow2->AddIcon(def->mStr48, NULL, 0, kToolOption2, def, 0, 1, this); theToolWindow2->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 1, this); LoadSoundForPlugin(def); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mOuterObjPlugins->GetItem(specifier->mID) ) numPlugins++; } mT2PluginLoader->SetTypeFilter(pos, 'OoPl'); while ((specifier = mT2PluginLoader->GetNext(pos))) { if ( (mWorldPlugin->GetAttrib() & specifier->mAttrib) && (specifier->mGameLevel <= mGameLevel) && !mOuterObjPlugins->GetItem(specifier->mID) ) { T2OuterObjPlugin *theOuterObjPlugin = (T2OuterObjPlugin *) mT2PluginLoader->LoadPlugin(specifier); mOuterObjPlugins->Add(theOuterObjPlugin); theOuterObjPlugin->LoadAllTemplatePlugin(mWorldDef, mTemplatePluginDB); T2OuterObjDef *def = (T2OuterObjDef *) theOuterObjPlugin->GetTemplatePlugin(); theOuterObjPlugin->GetName(str); mOuterObjTemplates->Regist(def); if (!def->RequierToolIcon(theToolWindow2)) theToolWindow2->AddIcon(def->mStr48, NULL, 0, kToolOption3, def, 0, 2, this); theToolWindow2->AddIcon("Category", NULL, def->mCategoryNo, kToolOption4, def, 0, 2, this); LoadSoundForPlugin(def); T2PeopleLoader::Load(specifier, mTemplatePluginDB); } } m9C |= inFlags; } /*virtual*/ BOOL T2TowerDoc::SetElevTransparent(BOOL inTransparent) { BOOL oldValue = mElevTransparent; mElevTransparent = inTransparent; mTowerMainView->Invalidate(false); mTowerMainView->tmv_vf120(); return oldValue; } /*virtual*/ BOOL T2TowerDoc::towerDoc_vf2B0(BOOL inValue) { BOOL oldValue = _1FC; if (inValue != _1FC) _1FC = inValue; return oldValue; } /*virtual*/ void T2TowerDoc::FinalEventOccur() { if (mGameLevel == mWorldDef->mNumOfGradeDef) mA0 |= mWorldDef->mGradeDef[mGameLevel - 1].m0; } /*virtual*/ void T2TowerDoc::SetSearchRangeFrom(T2Tenant *inTenant) { mViewMode = ViewMode_6; mSearchRangeFrom = inTenant; mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf100(kInView); T2_APP->mMainWindow->mCtrlPalette->vf104(kInView); } /*virtual*/ void T2TowerDoc::towerDoc_vf194() { mViewMode = kInView; mSearchRangeFrom = NULL; mTowerMainView->Invalidate(true); T2_APP->mMainWindow->mCtrlPalette->vf100(mViewMode); T2_APP->mMainWindow->mCtrlPalette->vf104(mViewMode); } /*virtual*/ void T2TowerDoc::DoRenumberTenant() { CRect rect; mFloorInfo->GetBuildArea(rect); for (int v = rect.top; v < rect.bottom; v++) { CPoint rightPt; rightPt.x = rect.right - 1; rightPt.y = v; T2FInfoPtIterator iterator(*mFloorInfo, rightPt); int number = 0; T2Tenant *tenant = NULL; while (iterator.LeftTenant(tenant)) { if (tenant->IsFloor()) continue; number++; tenant->SetTenantNumber(number); } mFloorInfo->SetTenantNumber(v, number); } towerDoc_vf280(); } /*virtual*/ int T2TowerDoc::GetNextTenantNumber(int inV) { return mFloorInfo->GetNextTenantNumber(inV); } /*virtual*/ void T2TowerDoc::towerDoc_vf280() { // empty } /*virtual*/ void T2TowerDoc::towerDoc_vf1A0(BOOL inPause) { if (inPause) { _1F8++; if (_1F8 != 1) return; } else if (_1F8 != 0) { _1F8--; if (_1F8 != 0) return; } else { return; } T2ToolWindow *theToolWindow = T2_APP->mToolWindow; unsigned int isEnabled; if (inPause) { theToolWindow->EnableIcon(false); isEnabled = MF_BYPOSITION | MF_GRAYED; } else { theToolWindow->EnableIcon(true); isEnabled = MF_BYPOSITION; } T2MainWindow *theMain = T2_MAIN_WINDOW; CMenu *theMenu = theMain->GetMenu(); unsigned int numItems = theMenu->GetMenuItemCount(); for (unsigned int i = 0; i < numItems; i++) theMenu->EnableMenuItem(i, isEnabled); theMain->DrawMenuBar(); } /*virtual*/ void T2TowerDoc::towerDoc_vf198(unsigned short inWindowType) { T2MainWindow *theMain = T2_MAIN_WINDOW; CMenu *theMainMenu = theMain->GetMenu(); if (!theMainMenu) return; CString label; CWnd *theWnd; unsigned int id; switch (inWindowType) { case kControlWindow: id = 0x801F; theWnd = T2_APP->mMainWindow->mCtrlPalette; // "コントロールパレット" label = "\x83\x52\x83\x93\x83\x67\x83\x8D\x81\x5B\x83\x8B\x83\x70\x83\x8C\x83\x62\x83\x67"; break; case kMessageWindow: id = 0x8020; theWnd = T2_APP->mMainWindow->mMsgWindow; // "情報バー" label = "\x8F\xEE\x95\xF1\x83\x6F\x81\x5B"; break; case kToolWindow: id = 0x8021; theWnd = T2_APP->mMainWindow->mToolWindow; // "ツールパレット" label = "\x83\x63\x81\x5B\x83\x8B\x83\x70\x83\x8C\x83\x62\x83\x67"; break; } if (theMainMenu->GetMenuState(id, 0) & MFS_CHECKED) { // "を表示" label += "\x82\xF0\x95\x5C\x8E\xA6"; theMainMenu->ModifyMenu(id, 0, id, label); theMainMenu->CheckMenuItem(id, MFS_UNCHECKED); theWnd->ShowWindow(SW_HIDE); } else { // "を隠す" label += "\x82\xF0\x89\x42\x82\xB7"; theMainMenu->ModifyMenu(id, 0, id, label); theMainMenu->CheckMenuItem(id, MFS_CHECKED); theWnd->ShowWindow(SW_SHOW); } } void T2TowerDoc::OnPause() { T2CtrlPalette *ctrlPalette = T2_APP->mMainWindow->mCtrlPalette; if (!ctrlPalette) return; T2MWControl *pauseCtrl = ctrlPalette->mPauseControl; if (!pauseCtrl) return; BOOL isPaused = false; if (pauseCtrl->GetData() == 0) isPaused = true; towerDoc_vf290(isPaused); x429A9A(isPaused); x429B01(isPaused); } void T2TowerDoc::OnUpdatePause(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnSetting() { T2SettingDialog *theDialog = new T2SettingDialog(this); short dialogResult = theDialog->DoModal(); } void T2TowerDoc::OnUpdateSetting(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnHideElevatorRoom() { T2MainWindow *theMain = T2_MAIN_WINDOW; CMenu *theMainMenu = theMain->GetMenu(); // "エレベータ機械室" CString label = "\x83\x47\x83\x8C\x83\x78\x81\x5B\x83\x5E\x8B\x40\x8A\x42\x8E\xBA"; if (mElevTransparent) { // "非表示" label += "\x94\xF1\x95\x5C\x8E\xA6"; mElevTransparent = false; } else { // "表示" label += "\x95\x5C\x8E\xA6"; mElevTransparent = true; } theMainMenu->ModifyMenu(0x801B, 0, 0x801B, label); mTowerMainView->Invalidate(true); mTowerMainView->tmv_vf120(); } void T2TowerDoc::OnUpdateHideElevatorRoom(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnFavorite() { T2SearchDialog *theDialog = new T2SearchDialog(this); short dialogResult = theDialog->DoModal(); } void T2TowerDoc::OnUpdateFavorite(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnHideControlWindow() { towerDoc_vf198(kControlWindow); } void T2TowerDoc::OnUpdateHideControlWindow(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnHideMessageWindow() { towerDoc_vf198(kMessageWindow); } void T2TowerDoc::OnUpdateHideMessageWindow(CCmdUI *pCmdUI) { pCmdUI->Enable(); } void T2TowerDoc::OnHideToolWindow() { towerDoc_vf198(kToolWindow); } void T2TowerDoc::OnUpdateHideToolWindow(CCmdUI *pCmdUI) { pCmdUI->Enable(); } /*virtual*/ T2ToolWindow *T2TowerDoc::towerDoc_vf2A0() { if (gT2App->mMainWindow && gT2App->mMainWindow->mToolWindow) return gT2App->mMainWindow->mToolWindow; return NULL; } /*virtual*/ void T2TowerDoc::toolCallback_vf00(T2ToolWindow *inToolWindow, T2ToolIconItem *inItem) { if (inItem->mName == "ToolRoot") { if (inItem->m24) towerDoc_vf194(); } else if (mSearchRangeFrom) { towerDoc_vf194(); } } /*virtual*/ void T2TowerDoc::DoFind(T2Name *inName) { if (!inName) return; RECT rect; BOOL found = false; switch (inName->GetType()) { case kTenantNameType: { T2Tenant *theTenant = mFloorInfo->GetTenant(inName->GetID()); if (theTenant) { theTenant->GetEquipArea(rect); #line 5031 _ASSERT(GetMainView() != NULL); GetMainView()->CenterOnRect(&rect); found = true; } break; } case kMoverNameType: { T2Mover *theMover = mFloorInfo->GetMover(inName->GetID()); if (theMover) { theMover->GetEquipArea(rect); #line 5043 _ASSERT(GetMainView() != NULL); GetMainView()->CenterOnRect(&rect); found = true; } break; } case kPeopleNameType: { #line 5068 _ASSERT(mPeopleArrayList != NULL); T2People *thePeople = mPeopleArrayList->FindPeople(inName->GetID()); if (thePeople) found = x4295F1(thePeople, rect); break; } } if (found) { CPoint leftPt(rect.left, rect.top); UT2Coordinate::UnitToQD(leftPt, GetZoomLevel()); CPoint rightPt(rect.right, rect.top); UT2Coordinate::UnitToQD(rightPt, GetZoomLevel()); leftPt.x += (rightPt.x - leftPt.x) / 2; T2TowerMainView *theMainView = GetMainView(); leftPt -= theMainView->mScrollOffset; T2ArrowWnd *arrow = new T2ArrowWnd; arrow->Show(leftPt.x, leftPt.y, this); } } BOOL T2TowerDoc::x4295F1(T2People *inPeople, RECT &outRect) { BOOL isFound = false; BOOL isFail = false; CString text; switch (inPeople->GetStatus()) { case kStatus1: { T2Name *theName = mNameDB->Search(inPeople); if (theName) { unsigned int id; theName->GetName(text, id); } else { inPeople->GetName(text); } // "は今、ビル内にいません。" // is not in the building now. text += "\x82\xCD\x8D\xA1\x81\x41\x83\x72\x83\x8B\x93\xE0\x82\xC9\x82\xA2\x82\xDC\x82\xB9\x82\xF1\x81\x42"; isFail = true; break; } case kStatus11: { T2Tenant *theTenant = GetFloorInfo()->GetTenant(inPeople->GetCurTenantID()); if (theTenant) { theTenant->GetEquipArea(outRect); #line 5117 _ASSERT(GetMainView() != NULL); GetMainView()->CenterOnRect(&outRect); isFound = true; } break; } case kStatus8: { T2Mover *theMover = GetFloorInfo()->GetMover(inPeople->GetCurrEquipID()); if (theMover) { T2MoverModule *theModule = theMover->FindPeople(inPeople); if (theModule) { int moduleID; if (theMover->CalcModuleRect(theModule, outRect, moduleID)) { #line 5132 _ASSERT(GetMainView() != NULL); GetMainView()->CenterOnRect(&outRect); isFound = true; } else { T2Name *theName = mNameDB->Search(inPeople); if (theName) { unsigned int id; theName->GetName(text, id); } else { inPeople->GetName(text); } // "は今、移動設備内にいます。" // is now in the mobile facility. text += "\x82\xCD\x8D\xA1\x81\x41\x88\xDA\x93\xAE\x90\xDD\x94\xF5\x93\xE0\x82\xC9\x82\xA2\x82\xDC\x82\xB7\x81\x42"; isFail = true; } } } break; } case kStatus6: case kStatus7: case kStatus9: UT2Coordinate::MakeRect( outRect, inPeople->GetCurPosition(), inPeople->IsFatSilhouette() ? 2 : 1, 1); #line 5160 _ASSERT(GetMainView() != NULL); GetMainView()->CenterOnRect(&outRect); isFound = true; break; default: { int theFloor = GetFloorInfo()->UnitToFloor(inPeople->GetCurPosition().y); T2Tenant *theTenant = GetFloorInfo()->GetTenant(inPeople->GetCurTenantID()); CString numStr; T2Name *theName = mNameDB->Search(inPeople); if (theName) { unsigned int id; theName->GetName(text, id); } else { inPeople->GetName(text); } // "は今、" - is now text += "\x82\xCD\x8D\xA1\x81\x41"; UT2Utils::GetRoomNumberString(theFloor, numStr); text += numStr; // "階フロアを移動中です" - moving between floors text += "\x8A\x4B\x83\x74\x83\x8D\x83\x41\x82\xF0\x88\xDA\x93\xAE\x92\x86\x82\xC5\x82\xB7"; isFail = true; } } if (isFail) { T2WorldDef *theWorldDef = GetWorldDef(); T2StewardDialog *theStewardDialog = new T2StewardDialog(this, theWorldDef->mModuleHandle, text, 0); } return isFound; } void T2TowerDoc::x429A9A(BOOL inPause) { T2CtrlPalette *theCtrlPalette = T2_APP->mMainWindow->mCtrlPalette; if (!theCtrlPalette) return; T2MWControl *thePauseButton = theCtrlPalette->mPauseControl; if (!thePauseButton) return; if (inPause) thePauseButton->SetData(100); else thePauseButton->SetData(0); } void T2TowerDoc::x429B01(BOOL inPause) { T2MainWindow *theMainWindow = T2_MAIN_WINDOW; if (!theMainWindow) return; CMenu *theMainMenu = theMainWindow->GetMenu(); if (!theMainMenu) return; if (inPause) { // "再生" - play theMainMenu->ModifyMenu(0x8019, 0, 0x8019, "\x8D\xC4\x90\xB6"); } else { // "一時停止" - pause theMainMenu->ModifyMenu(0x8019, 0, 0x8019, "\x88\xEA\x8E\x9E\x92\xE2\x8E\x7E"); } } /*virtual*/ void T2TowerDoc::SetInfoBarText(const char *inText) { T2MainWindow *theMainWindow = T2_MAIN_WINDOW; if (theMainWindow) { T2MsgWindow *theMsgWindow = theMainWindow->mMsgWindow; if (theMsgWindow) { theMsgWindow->GetDlgItem(1004)->SetWindowText(inText); theMsgWindow->GetDlgItem(1004)->InvalidateRect(NULL); } } } /*virtual*/ BOOL T2TowerDoc::IsColdFlagOn() const { BOOL isFlagOn = false; if (mColdDenomi > 0) isFlagOn = (UT2Utils::Randomize(mColdDenomi) == 0); return isFlagOn; }