#include "StdAfx.h" #include "CResFile.h" #include "T2Archive.h" #include "T2UnitInfo.h" T2UnitInfo::T2UnitInfo() { mVarA = 0; mVarB = 0; } T2UnitInfo::~T2UnitInfo() { } BOOL T2UnitInfo::IsBuildable() { return ((mVarA & 0x8000) == 0); } BOOL T2UnitInfo::IsMoverID(unsigned int id) { return (id > 0) && (id < 1000); } 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 tenantID) { mVarB &= 0x8000; mVarB += tenantID; } void T2UnitInfo::FillMoverID(unsigned int moverID) { mVarA &= 0x8000; mVarA += moverID; } void T2UnitInfo::InitMask(CResFile& resFile) { int v; resFile >> v; if (v != 0) mVarA |= 0x8000; else mVarA &= ~0x8000; } void T2UnitInfo::Read(T2Archive& archive, T2TowerDoc*) { unsigned short v; archive >> v; mVarA = v; archive >> v; mVarB = v; } void T2UnitInfo::Write(T2Archive& archive) { unsigned short v; v = mVarA; archive << v; v = mVarB; archive << v; }