diff options
Diffstat (limited to 'src/T2DLL/T2TenantMemberTableDef.cpp')
-rw-r--r-- | src/T2DLL/T2TenantMemberTableDef.cpp | 183 |
1 files changed, 171 insertions, 12 deletions
diff --git a/src/T2DLL/T2TenantMemberTableDef.cpp b/src/T2DLL/T2TenantMemberTableDef.cpp index 37a06a1..780ea02 100644 --- a/src/T2DLL/T2TenantMemberTableDef.cpp +++ b/src/T2DLL/T2TenantMemberTableDef.cpp @@ -1,46 +1,205 @@ +#include "CResFile.h" +#include "T2DateTime.h" +#include "T2DayParamDef.h" +#include "T2PlaceParamDef.h" +#include "T2TenantMemberDef.h" #include "T2TenantMemberTableDef.h" +#include "T2TowerDoc.h" +#include "UT2Utils.h" -T2TenantMemberTableDef::T2TenantMemberTableDef(HINSTANCE, CResFile*, float) { +T2TenantMemberTableDef::T2TenantMemberTableDef(HINSTANCE instance, CResFile* resFile, float f) { + Initialize(); + + *resFile >> mEconoType; + *resFile >> mSpecialFlag; + + int resID; + + *resFile >> resID; + if (resID) + mDayParamDef = MakeDayParamDef(instance, resID); + + try { + *resFile >> resID; + if (resID) + mPlaceParamDef = MakePlaceParamDef(instance, resID); + + *resFile >> mNumOfElem; + if (mNumOfElem > 0) { + mElem = new T2TenantMemberDef[mNumOfElem]; + for (int i = 0; i < mNumOfElem; i++) + mElem[i].Initialize(resFile, f); + } + } catch (CException &exc) { + delete this; + } } -T2TenantMemberTableDef::T2TenantMemberTableDef(const char*, CResFile*, float) { +T2TenantMemberTableDef::T2TenantMemberTableDef(const char* path, CResFile* resFile, float f) { + Initialize(); + + *resFile >> mEconoType; + *resFile >> mSpecialFlag; + + int resID; + + *resFile >> resID; + if (resID) + mDayParamDef = MakeDayParamDef(path, resID); + + try { + *resFile >> resID; + if (resID) + mPlaceParamDef = MakePlaceParamDef(path, resID); + + *resFile >> mNumOfElem; + if (mNumOfElem > 0) { + mElem = new T2TenantMemberDef[mNumOfElem]; + for (int i = 0; i < mNumOfElem; i++) + mElem[i].Initialize(resFile, f); + } + } catch (CException &exc) { + delete this; + } } /*virtual*/ T2TenantMemberTableDef::~T2TenantMemberTableDef() { + if (mDayParamDef) + delete mDayParamDef; + if (mPlaceParamDef) + delete mPlaceParamDef; + delete[] mElem; } void T2TenantMemberTableDef::Initialize() { + mEconoType = 0; + mSpecialFlag = 0; + mDayParamDef = NULL; + mPlaceParamDef = NULL; + mNumOfElem = 0; + mElem = NULL; } int T2TenantMemberTableDef::GetEconoType() const { + int type = mEconoType; + if (mEconoType != -1) + type &= ~0x10; + return type; } -int T2TenantMemberTableDef::IsCheckOnlyFirstEconoType() const { +BOOL T2TenantMemberTableDef::IsCheckOnlyFirstEconoType() const { + BOOL result = false; + if (mEconoType != -1) + result = (mEconoType & 0x10) != 0; + return result; } -T2TenantMemberDef* T2TenantMemberTableDef::GetElem(int) const { +T2TenantMemberDef* T2TenantMemberTableDef::GetElem(int i) const { + T2TenantMemberDef *result = NULL; + if (i >= 0 && i < mNumOfElem) + result = &mElem[i]; + return result; } -int T2TenantMemberTableDef::GetScore(T2PlaceParamDef::EPlace) const { +int T2TenantMemberTableDef::GetScore(T2PlaceParamDef::EPlace place) const { + int result = 0; + if (mPlaceParamDef) { + result = mPlaceParamDef->GetScore(place); + } else if (place == T2PlaceParamDef::Place_0) { + result = 1000; + } + return result; } -int T2TenantMemberTableDef::IsCollectFromFloor() const { +BOOL T2TenantMemberTableDef::IsCollectFromFloor() const { + BOOL result = false; + if (mPlaceParamDef) { + float rate = mPlaceParamDef->GetRate(T2PlaceParamDef::Place_2); + if (UT2Utils::Float2Int(rate) > 0) + result = true; + } + return result; } -int T2TenantMemberTableDef::IsCollectFromPool(T2TowerDoc*) const { +BOOL T2TenantMemberTableDef::IsCollectFromPool(T2TowerDoc* towerDoc) const { + BOOL result = true; + + if (mPlaceParamDef) { + float rate = mPlaceParamDef->GetRate(T2PlaceParamDef::Place_0); + if (UT2Utils::Float2Int(rate) == 0) + result = false; + } + + if (result && mDayParamDef) { + T2DayParamDef::EDay day = T2DayParamDef::Day_0; + T2DayParamDef::EWhether whether = T2DayParamDef::Whether_0; + + T2DateTime *now = towerDoc->towerDoc_vf120(); + if (now->IsHoliday(towerDoc)) + day = T2DayParamDef::Day_1; + + float rate = mDayParamDef->GetRate(day, whether); + if (UT2Utils::Float2Int(rate) == 0) + result = false; + } + + return result; } -int T2TenantMemberTableDef::IsCollectFromTenant() const { +BOOL T2TenantMemberTableDef::IsCollectFromTenant() const { + BOOL result = false; + if (mPlaceParamDef) { + float rate = mPlaceParamDef->GetRate(T2PlaceParamDef::Place_1); + if (UT2Utils::Float2Int(rate) > 0) + result = true; + } + return result; } -T2DayParamDef* T2TenantMemberTableDef::MakeDayParamDef(HINSTANCE, int) { +T2DayParamDef* T2TenantMemberTableDef::MakeDayParamDef(HINSTANCE instance, int resID) { + T2DayParamDef *result = NULL; + + CResFile resFile; + if (resFile.OpenResource(instance, resID, 'DpDf')) { + result = new T2DayParamDef(resFile); + resFile.End(); + } + + return result; } -T2DayParamDef* T2TenantMemberTableDef::MakeDayParamDef(const char*, int) { +T2DayParamDef* T2TenantMemberTableDef::MakeDayParamDef(const char* path, int resID) { + T2DayParamDef *result = NULL; + + CResFile resFile; + if (resFile.OpenResource(path, resID, 'DPDF')) { + result = new T2DayParamDef(resFile); + resFile.End(); + } + + return result; } -T2PlaceParamDef* T2TenantMemberTableDef::MakePlaceParamDef(HINSTANCE, int) { +T2PlaceParamDef* T2TenantMemberTableDef::MakePlaceParamDef(HINSTANCE instance, int resID) { + T2PlaceParamDef *result = NULL; + + CResFile resFile; + if (resFile.OpenResource(instance, resID, 'PlDf')) { + result = new T2PlaceParamDef(resFile); + resFile.End(); + } + + return result; } -T2PlaceParamDef* T2TenantMemberTableDef::MakePlaceParamDef(const char*, int) { +T2PlaceParamDef* T2TenantMemberTableDef::MakePlaceParamDef(const char* path, int resID) { + T2PlaceParamDef *result = NULL; + + CResFile resFile; + if (resFile.OpenResource(path, resID, 'PLDF')) { + result = new T2PlaceParamDef(resFile); + resFile.End(); + } + + return result; } |