diff options
Diffstat (limited to 'src/T2DLL/T2WorldPlugin.cpp')
-rw-r--r-- | src/T2DLL/T2WorldPlugin.cpp | 90 |
1 files changed, 78 insertions, 12 deletions
diff --git a/src/T2DLL/T2WorldPlugin.cpp b/src/T2DLL/T2WorldPlugin.cpp index d57e40c..afa7d1c 100644 --- a/src/T2DLL/T2WorldPlugin.cpp +++ b/src/T2DLL/T2WorldPlugin.cpp @@ -1,30 +1,80 @@ +#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(unsigned long, T2PluginSpecifier&) { +T2WorldPlugin::T2WorldPlugin(DWORD inType, T2PluginSpecifier& inSpecifier) + : CProgramPlugin(inType, inSpecifier) +{ + mNumOfClockStyle = 1; + m70 = 0; } /*virtual*/ T2WorldPlugin::~T2WorldPlugin() { } -/*virtual*/ int T2WorldPlugin::LoadAllTemplatePlugin(T2WorldDef*, T2TemplatePluginDB*) { +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*, T2FloorInfo&) { +/*virtual*/ void T2WorldPlugin::InitFloorInfoProc(T2WorldDef* inWorldDef, T2FloorInfo& inFloorInfo) { + CResFile resFile; + if (resFile.OpenResource(mModuleHandle, 1, 'FInf')) + inFloorInfo.InitMask(resFile); } -/*virtual*/ void T2WorldPlugin::InitBkgndInfoProc(T2WorldDef*, BkgndInfo*) { +/*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*) { +/*virtual*/ void T2WorldPlugin::InitializeDocumentProc(T2TowerDoc* inDoc) { } -/*virtual*/ int T2WorldPlugin::IsHoliday(T2DateTime*) const { +/*virtual*/ BOOL T2WorldPlugin::IsHoliday(T2DateTime* inDateTime) const { + return ((T2WorldDef *) mTemplatePlugin)->IsHoliday(inDateTime); } -/*virtual*/ int T2WorldPlugin::IsRainyDay(T2DateTime*) { +/*virtual*/ BOOL T2WorldPlugin::IsRainyDay(T2DateTime* inDateTime) { + return ((T2WorldDef *) mTemplatePlugin)->IsRainyDay(inDateTime); } void T2WorldPlugin::_DrawClock(CWnd*, unsigned int) { @@ -36,17 +86,33 @@ void T2WorldPlugin::_DrawCalendar(CWnd*, unsigned int) { void T2WorldPlugin::_DrawFunds(CWnd*, int) { } -/*virtual*/ int T2WorldPlugin::CheckGameLevel(T2WorldDef*, T2TowerDoc*) { +/*virtual*/ int T2WorldPlugin::CheckGameLevel(T2WorldDef* inWorldDef, T2TowerDoc* inDoc) { + int result = 0; + + if (inDoc->mGameLevel <= inWorldDef->mNumOfGradeDef) { + T2Pool *thePool = inDoc->towerDoc_vf130(); + 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*, T2TowerDoc*, unsigned int) { +/*virtual*/ int T2WorldPlugin::XEventIsBeginTime(T2XEvent* inXEvent, T2TowerDoc* inDoc, unsigned int inTime) { + return inXEvent->IsBeginTime(inDoc, inTime); } -/*virtual*/ int T2WorldPlugin::XEventIsBeginDay(T2XEvent*, T2TowerDoc*, int) { +/*virtual*/ int T2WorldPlugin::XEventIsBeginDay(T2XEvent* inXEvent, T2TowerDoc* inDoc, int inDay) { + return inXEvent->IsBeginDay(inDoc, inDay); } -/*virtual*/ void T2WorldPlugin::XEventWrite(T2XEvent*, T2Archive&) { +/*virtual*/ void T2WorldPlugin::XEventWrite(T2XEvent* inXEvent, T2Archive& inArchive) { } -/*virtual*/ void T2WorldPlugin::XEventRead(T2XEvent*, T2Archive&) { +/*virtual*/ void T2WorldPlugin::XEventRead(T2XEvent* inXEvent, T2Archive& inArchive) { } |