#include "CResFile.h" #include "T2FloorInfo.h" #include "T2Pool.h" #include "T2TowerDoc.h" #include "T2WorldDef.h" #include "T2WorldPlugin.h" #include "T2XEvent.h" #include "UT2BkgndInfo.h" T2WorldPlugin::T2WorldPlugin(DWORD inType, T2PluginSpecifier& inSpecifier) : CProgramPlugin(inType, inSpecifier) { mNumOfClockStyle = 1; m70 = 0; } /*virtual*/ T2WorldPlugin::~T2WorldPlugin() { } typedef T2WorldDef *(MSVC_STDCALL* ConstructTemplatePluginType) (T2PluginSpecifier *, CResFile *, T2WorldPlugin *); /*virtual*/ BOOL T2WorldPlugin::LoadAllTemplatePlugin(T2WorldDef* inWorldDef, T2TemplatePluginDB* inDB) { return true; } /*virtual*/ T2WorldDef* T2WorldPlugin::LoadT2WorldDef() { ConstructTemplatePluginType theFunc = (ConstructTemplatePluginType) GetProcAddress((HMODULE) mModuleHandle, "ConstructTemplatePlugin"); #line 29 _ASSERT(theFunc); CResFile resFile; resFile.OpenResource(mModuleHandle, 1, "WorldDef"); T2WorldDef *worldDef = theFunc(&mSpecifier, &resFile, this); mTemplatePlugin = worldDef; return worldDef; } /*virtual*/ void T2WorldPlugin::InitFloorInfoProc(T2WorldDef* inWorldDef, T2FloorInfo& inFloorInfo) { CResFile resFile; if (resFile.OpenResource(mModuleHandle, 1, 'FInf')) inFloorInfo.InitMask(resFile); } /*virtual*/ void T2WorldPlugin::InitBkgndInfoProc(T2WorldDef* inWorldDef, BkgndInfo* inBkgndInfoPtr) { int vRange, hRange; unsigned int data; CResFile resFile; resFile.OpenResource(mModuleHandle, 1, 'BInf'); resFile >> vRange; resFile >> hRange; #line 53 _ASSERT((inBkgndInfoPtr->vRange == vRange) && (inBkgndInfoPtr->hRange == hRange)); int notUsed; resFile >> notUsed; for (int h = 0; h < hRange; h++) { for (int v = 0; v < vRange; v++) { unsigned int *array = inBkgndInfoPtr->arrays[v]; resFile >> data; array[h] = data; } } } /*virtual*/ void T2WorldPlugin::InitializeDocumentProc(T2TowerDoc* inDoc) { } /*virtual*/ BOOL T2WorldPlugin::IsHoliday(T2DateTime* inDateTime) const { return ((T2WorldDef *) mTemplatePlugin)->IsHoliday(inDateTime); } /*virtual*/ BOOL T2WorldPlugin::IsRainyDay(T2DateTime* inDateTime) { return ((T2WorldDef *) mTemplatePlugin)->IsRainyDay(inDateTime); } void T2WorldPlugin::_DrawClock(CWnd*, unsigned int) { } void T2WorldPlugin::_DrawCalendar(CWnd*, unsigned int) { } void T2WorldPlugin::_DrawFunds(CWnd*, int) { } /*virtual*/ int T2WorldPlugin::CheckGameLevel(T2WorldDef* inWorldDef, T2TowerDoc* inDoc) { int result = 0; if (inDoc->mGameLevel <= inWorldDef->mNumOfGradeDef) { T2Pool *thePool = inDoc->GetPool(); if (thePool) { GradeDef gradeDef = inWorldDef->mGradeDef[inDoc->mGameLevel - 1]; int population = thePool->GetPopulation(); if ((inDoc->mA0 & gradeDef.m0) == gradeDef.m0 && population >= gradeDef.m4) result = 10005; } } return result; } /*virtual*/ int T2WorldPlugin::XEventIsBeginTime(T2XEvent* inXEvent, T2TowerDoc* inDoc, unsigned int inTime) { return inXEvent->IsBeginTime(inDoc, inTime); } /*virtual*/ int T2WorldPlugin::XEventIsBeginDay(T2XEvent* inXEvent, T2TowerDoc* inDoc, int inDay) { return inXEvent->IsBeginDay(inDoc, inDay); } /*virtual*/ void T2WorldPlugin::XEventWrite(T2XEvent* inXEvent, T2Archive& inArchive) { } /*virtual*/ void T2WorldPlugin::XEventRead(T2XEvent* inXEvent, T2Archive& inArchive) { }