diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-14 00:50:34 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-14 00:50:34 +0100 |
commit | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch) | |
tree | eaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/T2PoolDef.cpp | |
download | t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip |
initial commit
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2PoolDef.cpp | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/src/T2DLL/T2PoolDef.cpp b/src/T2DLL/T2PoolDef.cpp new file mode 100644 index 0000000..8dba974 --- /dev/null +++ b/src/T2DLL/T2PoolDef.cpp @@ -0,0 +1,152 @@ +#include "CResFile.h" +#include "T2PoolDef.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 <= 8); + + 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() { + // TODO T2WorldPlugin + return 0; +} + +DemandInfo *T2PoolDef::GetDemandInfo(unsigned int index) const { + DemandInfo *info = NULL; + if (index < mNumOfDemand) + info = &mDemand[index]; + return info; +} + +int T2PoolDef::GetGradeDefResID(unsigned int index) const { + int resID = 0; + int index0 = index - 1; + if (index0 < 5) + resID = mGradeDefResID[index0]; + return resID; +} |