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/T2OutObjArray.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2OutObjArray.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/T2DLL/T2OutObjArray.cpp b/src/T2DLL/T2OutObjArray.cpp index ef96821..b38ac82 100644 --- a/src/T2DLL/T2OutObjArray.cpp +++ b/src/T2DLL/T2OutObjArray.cpp @@ -1,22 +1,49 @@ #include "T2OutObjArray.h" -T2OutObjArray::T2OutObjArray(unsigned int) { +T2OutObjArray::T2OutObjArray(unsigned int inStartID) + : T2ObjectArray(inStartID) +{ + for (unsigned int i = 0; i < kGroupSize; i++) + mOutObj[i].mID = mStartID + i; } /*virtual*/ T2OutObjArray::~T2OutObjArray() { } T2OutObj* T2OutObjArray::FindUnusedOutObj() const { + for (int i = 0; i < kGroupSize; i++) { + if (!mOutObj[i].IsUsed()) + return (T2OutObj *) &mOutObj[i]; + } + + return NULL; } -/*virtual*/ void T2OutObjArray::DispatchIdle(T2TowerDoc*, int) { +/*virtual*/ void T2OutObjArray::DispatchIdle(T2TowerDoc* inDoc, int) { + for (int i = 0; i < kGroupSize; i++) { + if (mOutObj[i].IsUsed()) + mOutObj[i].Idle(inDoc); + } } -int T2OutObjArray::CalcMentenanceCost(T2TowerDoc*) const { +int T2OutObjArray::CalcMentenanceCost(T2TowerDoc* inDoc) const { + int cost = 0; + const T2OutObj *theOutObj = &mOutObj[0]; + + for (unsigned int i = 0; i < kGroupSize; i++, theOutObj++) { + if (theOutObj->IsUsed()) + cost += theOutObj->CalcMentenanceCost(inDoc); + } + + return cost; } -void T2OutObjArray::Read(T2Archive&, T2TowerDoc*) { +void T2OutObjArray::Read(T2Archive& inArchive, T2TowerDoc* inDoc) { + for (int i = 0; i < kGroupSize; i++) + mOutObj[i].Load(inArchive, inDoc); } -void T2OutObjArray::Write(T2Archive&) { +void T2OutObjArray::Write(T2Archive& inArchive) { + for (int i = 0; i < kGroupSize; i++) + mOutObj[i].Save(inArchive); } |