diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-07-01 02:43:29 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-07-01 02:43:29 +0100 |
commit | 5c6a48b2ff362a70416a6a00fda7d06e0f276f2d (patch) | |
tree | 62cf542c68d91aa6f7a4e3bfa9eddca4ab352970 /src/T2DLL/T2FInfoAreaIterator.cpp | |
parent | c0c336500955a23e344651e5412c9d9d441ef4ee (diff) | |
download | t2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.tar.gz t2win-5c6a48b2ff362a70416a6a00fda7d06e0f276f2d.zip |
i am in hell
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2FInfoAreaIterator.cpp | 162 |
1 files changed, 10 insertions, 152 deletions
diff --git a/src/T2DLL/T2FInfoAreaIterator.cpp b/src/T2DLL/T2FInfoAreaIterator.cpp index 5d81af0..d95ae82 100644 --- a/src/T2DLL/T2FInfoAreaIterator.cpp +++ b/src/T2DLL/T2FInfoAreaIterator.cpp @@ -103,10 +103,10 @@ BOOL T2FInfoAreaIterator::Next(T2UnitInfo*& outUnitInfo) { } BOOL T2FInfoAreaIterator::NextTenant(T2Tenant*& outTenant) { - BOOL result; + BOOL found; T2UnitInfo *unitInfo; - for (result = Next(unitInfo); result; result = Next(unitInfo)) { + for (found = Next(unitInfo); found; found = Next(unitInfo)) { unsigned int tenantID = unitInfo->GetTenantID(); if (tenantID != mLastIDSeen) { mLastIDSeen = tenantID; @@ -117,7 +117,7 @@ BOOL T2FInfoAreaIterator::NextTenant(T2Tenant*& outTenant) { } } - return result; + return found; } void T2FInfoAreaIterator::GetTenantRect(RECT& outRect) { @@ -127,7 +127,7 @@ void T2FInfoAreaIterator::GetTenantRect(RECT& outRect) { if (IsValidPosition()) { outRect.right++; T2UnitInfo *unitInfo = mCurrUnitInfo + 1; - while (unitInfo->GetTenantID() == mLastIDSeen) { + while (mLastIDSeen == unitInfo->GetTenantID()) { outRect.right++; unitInfo++; } @@ -135,10 +135,10 @@ void T2FInfoAreaIterator::GetTenantRect(RECT& outRect) { } BOOL T2FInfoAreaIterator::NextRequest(T2Request*& outRequest) { - BOOL result; + BOOL found; T2UnitInfo *unitInfo; - for (result = Next(unitInfo); result; result = Next(unitInfo)) { + for (found = Next(unitInfo); found; found = Next(unitInfo)) { unsigned int requestID = unitInfo->GetRequestID(); if (requestID != mLastIDSeen) { mLastIDSeen = requestID; @@ -149,14 +149,14 @@ BOOL T2FInfoAreaIterator::NextRequest(T2Request*& outRequest) { } } - return result; + return found; } BOOL T2FInfoAreaIterator::NextMover(T2Mover*& outMover) { - BOOL result; + BOOL found; T2UnitInfo *unitInfo; - for (result = Next(unitInfo); result; result = Next(unitInfo)) { + for (found = Next(unitInfo); found; found = Next(unitInfo)) { unsigned int moverID = unitInfo->GetMoverID(); if (moverID != mLastIDSeen) { mLastIDSeen = moverID; @@ -167,147 +167,5 @@ BOOL T2FInfoAreaIterator::NextMover(T2Mover*& outMover) { } } - return result; -} - - - -T2FInfoPtIterator::T2FInfoPtIterator(const T2FloorInfo& inFloorInfo, POINT inPt) - : mFloorInfo(inFloorInfo) - , mLeftBound(mFloorInfo.mBuildArea.left) - , mRightBound(mFloorInfo.mBuildArea.right - 1) -{ - if (PtInRect(&mFloorInfo.mBuildArea, inPt)) { - mCurrH = inPt.x; - mCurrUnitInfo = mFloorInfo.GetUnitInfo(inPt.y, mCurrH); - mLastIDSeen = 0; - } else { - mCurrH = -2; - } -} - -/*virtual*/ T2FInfoPtIterator::~T2FInfoPtIterator() { -} - -BOOL T2FInfoPtIterator::CurrentH(int& outH) const { - BOOL result = true; - - if (IsValidPosition()) - outH = mCurrH; - else - result = false; - - return result; -} - -BOOL T2FInfoPtIterator::CalcRightUnitInfo() { - BOOL result = true; - - if (mCurrH != -2) { - if (mCurrH != -1) { - if (mCurrH < mRightBound) { - mCurrH++; - mCurrUnitInfo++; - } else { - mCurrH = -2; - result = false; - } - } else { - mCurrH = mLeftBound; - } - } else { - result = false; - } - - return result; -} - -BOOL T2FInfoPtIterator::CalcLeftUnitInfo() { - BOOL result = true; - - if (mCurrH != -2) { - if (mCurrH != -1) { - if (mCurrH > mLeftBound) { - mCurrH--; - mCurrUnitInfo--; - } else { - result = false; - } - } else { - mCurrH = mRightBound; - } - } else { - result = false; - } - - return result; -} - -BOOL T2FInfoPtIterator::Current(T2UnitInfo*& outUnitInfo) { - BOOL result = true; - - if (IsValidPosition()) - outUnitInfo = mCurrUnitInfo; - else - result = false; - - return result; -} - -BOOL T2FInfoPtIterator::Right(T2UnitInfo*& outUnitInfo) { - BOOL result = true; - - if (CalcRightUnitInfo()) - outUnitInfo = mCurrUnitInfo; - else - result = false; - - return result; -} - -BOOL T2FInfoPtIterator::Left(T2UnitInfo*& outUnitInfo) { - BOOL result = true; - - if (CalcLeftUnitInfo()) - outUnitInfo = mCurrUnitInfo; - else - result = false; - - return result; -} - -BOOL T2FInfoPtIterator::RightTenant(T2Tenant*& outTenant) { - BOOL result; - T2UnitInfo *unitInfo; - - for (result = Right(unitInfo); result; result = Right(unitInfo)) { - unsigned int tenantID = unitInfo->GetTenantID(); - if (tenantID != mLastIDSeen) { - mLastIDSeen = tenantID; - if (tenantID != 0) { - outTenant = mFloorInfo.mTenantArrayList->GetTenantByID(tenantID); - break; - } - } - } - - return result; -} - -BOOL T2FInfoPtIterator::LeftTenant(T2Tenant*& outTenant) { - BOOL result; - T2UnitInfo *unitInfo; - - for (result = Left(unitInfo); result; result = Left(unitInfo)) { - unsigned int tenantID = unitInfo->GetTenantID(); - if (tenantID != mLastIDSeen) { - mLastIDSeen = tenantID; - if (tenantID != 0) { - outTenant = mFloorInfo.mTenantArrayList->GetTenantByID(tenantID); - break; - } - } - } - - return result; + return found; } |