diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2UnitInfo.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2UnitInfo.cpp | 70 |
1 files changed, 62 insertions, 8 deletions
diff --git a/src/T2DLL/T2UnitInfo.cpp b/src/T2DLL/T2UnitInfo.cpp index 15660b5..4b137e8 100644 --- a/src/T2DLL/T2UnitInfo.cpp +++ b/src/T2DLL/T2UnitInfo.cpp @@ -1,40 +1,94 @@ +#include "CResFile.h" +#include "T2Archive.h" #include "T2UnitInfo.h" T2UnitInfo::T2UnitInfo() { + mVarA = 0; + mVarB = 0; } T2UnitInfo::~T2UnitInfo() { } -int T2UnitInfo::IsBuildable() { +BOOL T2UnitInfo::IsBuildable() { + return ((mVarA & 0x8000) == 0); } -int T2UnitInfo::IsMoverID(unsigned int) { +BOOL T2UnitInfo::IsMoverID(unsigned int id) { + return (id > 0) && (id < 1000); } -int T2UnitInfo::IsRequestID(unsigned int) { +BOOL T2UnitInfo::IsRequestID(unsigned int id) { + return (id >= 1000); } unsigned int T2UnitInfo::GetTenantID() { + unsigned int tenantID = 0; + + if (mVarB) + tenantID = mVarB & 0x7FFF; + + return tenantID; } unsigned int T2UnitInfo::GetMoverID() { + unsigned int moverID = 0; + + if (mVarA) { + moverID = mVarA & 0x7FFF; + if (!IsMoverID(moverID)) + moverID = 0; + } + + return moverID; } unsigned int T2UnitInfo::GetRequestID() { + unsigned int requestID = 0; + + if (mVarA) { + requestID = mVarA & 0x7FFF; + if (!IsRequestID(requestID)) + requestID = 0; + } + + return requestID; } -void T2UnitInfo::FillTenantID(unsigned int) { +void T2UnitInfo::FillTenantID(unsigned int tenantID) { + mVarB &= 0x8000; + mVarB += tenantID; } -void T2UnitInfo::FillMoverID(unsigned int) { +void T2UnitInfo::FillMoverID(unsigned int moverID) { + mVarA &= 0x8000; + mVarA += moverID; } -void T2UnitInfo::InitMask(CResFile&) { +void T2UnitInfo::InitMask(CResFile& resFile) { + int v; + + resFile >> v; + if (v != 0) + mVarA |= 0x8000; + else + mVarA &= ~0x8000; } -void T2UnitInfo::Read(T2Archive&, T2TowerDoc*) { +void T2UnitInfo::Read(T2Archive& archive, T2TowerDoc*) { + unsigned short v; + + archive >> v; + mVarA = v; + archive >> v; + mVarB = v; } -void T2UnitInfo::Write(T2Archive&) { +void T2UnitInfo::Write(T2Archive& archive) { + unsigned short v; + + v = mVarA; + archive << v; + v = mVarB; + archive << v; } |