summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2WorldPlugin.cpp
blob: fc55a9cd12b466de7d1e011060c5251d4417d99c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#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) {
}