summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PoolDef.cpp
blob: 558fdd7a0b493c67b7bedf806b9e614713c1fc30 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "CResFile.h"
#include "T2PeopleType.h"
#include "T2PoolDef.h"
#include "T2WorldPlugin.h"

T2PoolTimeZoneDef::T2PoolTimeZoneDef(CResFile &resFile) {
	Initialize();

	resFile >> mNumOfElems;
	mPeopleElems = new PeopleElem[mNumOfElems];

	unsigned int theSum = 0;

	for (unsigned int i = 0; i < mNumOfElems; i++) {
		resFile >> mPeopleElems[i].mSilhouetteType;
		resFile >> mPeopleElems[i].mEconoType;
		resFile >> mPeopleElems[i].mTransportType;
		resFile >> mPeopleElems[i].mRate;
		mPeopleElems[i].m4 = (mPeopleElems[i].mRate * 20) / 100;
		theSum += mPeopleElems[i].m4;
	}
}

void T2PoolTimeZoneDef::Initialize() {
	mNumOfElems = 0;
	mPeopleElems = NULL;
}

T2PoolTimeZoneDef::~T2PoolTimeZoneDef() {
	delete[] mPeopleElems;
}

PeopleElem *T2PoolTimeZoneDef::GetPeopleElem(unsigned int index) const {
	PeopleElem *elem = NULL;
	if (index < mNumOfElems)
		elem = &mPeopleElems[index];
	return elem;
}



T2PoolDefDemandElem::T2PoolDefDemandElem() {
	mNumOfElems = 0;
	mElems = NULL;
}

void T2PoolDefDemandElem::Initialize(CResFile &resFile) {
	resFile >> mNumOfElems;
	mElems = new TimeZoneInfo[mNumOfElems];

	for (unsigned int i = 0; i < mNumOfElems; i++) {
		resFile >> mElems[i].m0;
		resFile >> mElems[i].m4;
	}
}

T2PoolDefDemandElem::~T2PoolDefDemandElem() {
	delete[] mElems;
}

TimeZoneInfo *T2PoolDefDemandElem::GetTimeZoneInfo(unsigned int index) const {
	TimeZoneInfo *elem = NULL;
	if (index < mNumOfElems)
		elem = &mElems[index];
	return elem;
}



T2PoolGradeDef::T2PoolGradeDef(CResFile &resFile) {
	Initialize();

	resFile >> mNumOfElems;
	mDemandElems = new T2PoolDefDemandElem[mNumOfElems];

	for (unsigned int i = 0; i < mNumOfElems; i++) {
		mDemandElems[i].Initialize(resFile);
	}
}

void T2PoolGradeDef::Initialize() {
	mNumOfElems = 0;
	mDemandElems = NULL;
}

T2PoolGradeDef::~T2PoolGradeDef() {
	delete[] mDemandElems;
}

T2PoolDefDemandElem *T2PoolGradeDef::GetDemandElem(unsigned int index) const {
	T2PoolDefDemandElem *elem = NULL;
	if (index < mNumOfElems)
		elem = &mDemandElems[index];
	return elem;
}



T2PoolDef::T2PoolDef(CResFile &resFile, T2WorldPlugin *worldPlugin) {
	unsigned int i;

	Initialize();

	mWorldPlugin = worldPlugin;

	resFile >> m8;
	for (i = 0; i < 5; i++)
		resFile >> mGradeDefResID[i];

	resFile >> m20;
	resFile >> mNumOfDemand;
#line 129
	_ASSERT(mNumOfDemand <= kMaxDemand);

	mDemand = new DemandInfo[mNumOfDemand];
	for (i = 0; i < mNumOfDemand; i++) {
		resFile >> mDemand[i].a;
		resFile >> mDemand[i].b;
	}
}

void T2PoolDef::Initialize() {
	mWorldPlugin = NULL;
	m20 = 0;
	mNumOfDemand = 0;
	m8 = 0;
	for (unsigned int i = 0; i < 5; i++)
		mGradeDefResID[i] = 0;
	mDemand = NULL;
}

T2PoolDef::~T2PoolDef() {
	delete[] mDemand;
}

HINSTANCE T2PoolDef::GetModuleHandle() {
	return mWorldPlugin->mModuleHandle;
}

DemandInfo *T2PoolDef::GetDemandInfo(unsigned int index) const {
	DemandInfo *info = NULL;
	if (index < mNumOfDemand)
		info = &mDemand[index];
	return info;
}

int T2PoolDef::GetGradeDefResID(unsigned int inIndex) const {
	int theResID = 0;
	unsigned int index = inIndex - 1;
	if (index < 5)
        theResID = mGradeDefResID[index];
	return theResID;
}