#include "StdAfx.h" #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; }