#include "CResFile.h" #include "GlobalFunc.h" #include "T2Archive.h" #include "T2FInfoAreaIterator.h" #include "T2FInfoPtIterator.h" #include "T2FloorInfo.h" #include "T2Mover.h" #include "T2MoverArray.h" #include "T2MoverArrayList.h" #include "T2MoverDef.h" #include "T2MoverModule.h" #include "T2MoverModuleList.h" #include "T2OutObjArrayList.h" #include "T2OutsideInfo.h" #include "T2RegistedTenantDB.h" #include "T2Request.h" #include "T2RequestArrayList.h" #include "T2Tenant.h" #include "T2TenantArrayList.h" #include "T2TowerDoc.h" #include "T2TowerMainView.h" #include "T2UnitInfo.h" #include "T2WorldDef.h" T2FloorInfo::T2FloorInfo(const T2WorldDef* inWorldDef) { mVRange = inWorldDef->GetHeight(); mHRange = inWorldDef->GetWidth(); mGroundLine = inWorldDef->mGroundLine; mTopFloorLine = inWorldDef->mTopFloorLine; mBottomFloorLine = inWorldDef->mBottomFloorLine; mEntranceWidth = 7; inWorldDef->GetBuildArea(mBuildArea); mFloorArea = mBuildArea; mFloorArea.top = mTopFloorLine; mFloorArea.bottom = mBottomFloorLine; mUnitInfo = NULL; mTenantArrayList = NULL; mMoverArrayList = NULL; mRequestArrayList = NULL; mOutObjArrayList = NULL; mTenantNumber = NULL; mUnitInfo = new T2UnitInfo[mHRange * mVRange]; mTenantArrayList = new T2TenantArrayList; mMoverArrayList = new T2MoverArrayList; mRequestArrayList = new T2RequestArrayList; mOutObjArrayList = new T2OutObjArrayList; mOutsideInfo = new T2OutsideInfo(*this); mTenantNumber = new unsigned int[mVRange]; memset(mTenantNumber, 0, sizeof(unsigned int) * mVRange); } /*virtual*/ T2FloorInfo::~T2FloorInfo() { if (mUnitInfo) delete[] mUnitInfo; if (mTenantArrayList) delete mTenantArrayList; if (mMoverArrayList) delete mMoverArrayList; if (mRequestArrayList) delete mRequestArrayList; if (mOutObjArrayList) delete mOutObjArrayList; if (mOutsideInfo) delete mOutsideInfo; if (mTenantNumber) delete[] mTenantNumber; } int T2FloorInfo::UnitToFloor(int unit) const { int result; if (unit < mGroundLine) result = mGroundLine - unit; else result = mGroundLine - unit - 1; return result; } void T2FloorInfo::InitMask(CResFile& inResFile) { int vcheck; int hcheck; inResFile >> vcheck; inResFile >> hcheck; #line 211 _ASSERT((vcheck == mVRange) && (hcheck == mHRange)); int someUnkVal; RECT someUnkRect; inResFile >> someUnkVal; inResFile >> someUnkRect; for (int i = 0; i < (mVRange * mHRange); i++) mUnitInfo[i].InitMask(inResFile); } void T2FloorInfo::Read(T2Archive& inArchive, T2TowerDoc* inDoc) { int vcheck; int hcheck; inArchive >> vcheck; inArchive >> hcheck; if (vcheck != mVRange || hcheck != mHRange) return; #line 234 _ASSERT((vcheck == mVRange) && (hcheck == mHRange)); DWORD classID; inArchive >> classID; #line 239 _ASSERT(classID == 'UntI'); for (int i = 0; i < (mHRange * mVRange); i++) mUnitInfo[i].Read(inArchive, inDoc); inArchive >> classID; if (classID == 'TntA') { mTenantArrayList->Read(inArchive, inDoc); T2RegistedTenantDB *theDB = inDoc->towerDoc_vf174(); theDB->Init(mTenantArrayList); mTenantArrayList->RecoverRelatedTenantList(theDB); inArchive >> classID; } if (classID == 'MvrA') { mMoverArrayList->Read(inArchive, inDoc); inArchive >> classID; } if (classID == 'ReqA') { mRequestArrayList->Read(inArchive, inDoc); inArchive >> classID; } if (classID == 'OObA') { mOutObjArrayList->Read(inArchive, inDoc); inArchive >> classID; } if (classID == 'OutI') mOutsideInfo->Read(inArchive); } void T2FloorInfo::Write(T2Archive& inArchive) { inArchive << mVRange; inArchive << mHRange; DWORD classID = 'UntI'; inArchive << classID; for (int i = 0; i < (mHRange * mVRange); i++) mUnitInfo[i].Write(inArchive); classID = 'TntA'; inArchive << classID; mTenantArrayList->Write(inArchive); classID = 'MvrA'; inArchive << classID; mMoverArrayList->Write(inArchive); classID = 'ReqA'; inArchive << classID; mRequestArrayList->Write(inArchive); classID = 'OObA'; inArchive << classID; mOutObjArrayList->Write(inArchive); classID = 'OutI'; inArchive << classID; mOutsideInfo->Write(inArchive); } BOOL T2FloorInfo::IsValidRange(const RECT& inRect) const { BOOL result = true; if (mBuildArea.top > inRect.top || mBuildArea.bottom < inRect.bottom || mBuildArea.left > inRect.left || mBuildArea.right < inRect.right) result = false; return result; } BOOL T2FloorInfo::IsAreaBuildable(const RECT& inRect) { BOOL result = false; if (IsValidRange(inRect)) { result = true; T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *unitInfo; while (iterator.Next(unitInfo) && result == true) { if (!unitInfo->IsBuildable()) result = false; } } return result; } BOOL T2FloorInfo::IsAllTenant(const RECT& inRect) { BOOL result = true; T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *theUnitInfo; while (iterator.Next(theUnitInfo)) { if (theUnitInfo->GetTenantID() < 1000) { result = false; break; } } return result; } BOOL T2FloorInfo::IsThereNoFloorTenant(const RECT& inRect) { BOOL result = false; T2FInfoAreaIterator iterator(*this, inRect); T2Tenant *theTenant; while (iterator.NextTenant(theTenant)) { if (!theTenant->IsFloor()) { result = true; break; } } return result; } BOOL T2FloorInfo::IsThereMover(const RECT& inRect) { BOOL found = false; T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *theUnitInfo; while (iterator.Next(theUnitInfo)) { if (theUnitInfo->GetMoverID()) { found = true; break; } } return found; } BOOL T2FloorInfo::IsThereOtherKindMover(const RECT& inRect, int inType) { BOOL found = false; unsigned int noMoverID = 0; T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *theUnitInfo; while (iterator.Next(theUnitInfo)) { unsigned int moverID = theUnitInfo->GetMoverID(); if (moverID != 0 && moverID != noMoverID) { T2Mover *theMover = GetMover(moverID); if (theMover && theMover->GetEquipType() != inType) { found = true; break; } } } return found; } BOOL T2FloorInfo::IsEnoughSideSpace(const RECT& inRect) { BOOL isEnough = true; RECT rect = inRect; rect.right = rect.left; rect.left -= T2MoverDef::GetRequiredRequestSpace() * 2; isEnough = !IsThereMover(rect); if (isEnough) { rect = inRect; rect.left = rect.right; rect.right += T2MoverDef::GetRequiredRequestSpace() * 2; isEnough = !IsThereMover(rect); } return isEnough; } T2Tenant* T2FloorInfo::GetTenant(unsigned int inTenantID) const { T2Tenant *result = NULL; if (inTenantID >= 1000) result = mTenantArrayList->GetTenantByID(inTenantID); return result; } T2Tenant* T2FloorInfo::GetTenant(int inV, int inH) const { T2Tenant *result = NULL; unsigned int tenantID = GetTenantID(inV, inH); if (tenantID) result = mTenantArrayList->GetTenantByID(tenantID); return result; } T2Tenant* T2FloorInfo::GetPoolTenant() const { return GetTenant(1000); } T2Tenant* T2FloorInfo::GetFloor(int inV, int inH) const { T2Tenant *floor = NULL; T2Tenant *theTenant = GetTenant(inV, inH); if (theTenant) { if (theTenant->IsFloor()) { floor = theTenant; } else { unsigned int floorID = theTenant->GetFloorID(inV); floor = GetTenant(floorID); } } return floor; } T2Mover* T2FloorInfo::GetMover(unsigned int inMoverID) { return mMoverArrayList->GetMoverByID(inMoverID); } T2Mover* T2FloorInfo::GetMover(int inV, int inH) { T2Mover *result = NULL; unsigned int moverID = GetMoverID(inV, inH); if (moverID) result = mMoverArrayList->GetMoverByID(moverID); return result; } T2MoverModule* T2FloorInfo::GetModule(unsigned int inModuleID) const { LArrayIterator arrayIterator(*mMoverArrayList); T2MoverArray *theArray; while (arrayIterator.Next(&theArray)) { for (int i = 0; i < T2MoverArray::kGroupSize; i++) { T2Mover *theMover = theArray->GetIndexMover(i); if (theMover->IsUsed() && theMover->GetModuleList()) { LArrayIterator moduleIterator(*theMover->GetModuleList()); T2MoverModule *theModule; while (moduleIterator.Next(&theModule)) { if (theModule->GetModuleID() == inModuleID) return theModule; } } } } return NULL; } T2Request* T2FloorInfo::GetRequest(unsigned int inRequestID) const { return mRequestArrayList->GetRequestByID(inRequestID); } T2Request* T2FloorInfo::GetRequest(int inV, int inH) const { T2Request *result = NULL; unsigned int requestID = GetRequestID(inV, inH); if (requestID) result = mRequestArrayList->GetRequestByID(requestID); return result; } T2People* T2FloorInfo::FindPeople(int inV, int inH) const { T2People *result = NULL; T2Tenant *theFloor = GetFloor(inV, inH); if (theFloor) { POINT pt; pt.x = inH; pt.y = inV; result = theFloor->FindPeople(pt); } if (!result) { T2Request *theRequest = GetRequest(inV, inH); if (theRequest) result = theRequest->FindPeople(inH); } return result; } T2OutObj* T2FloorInfo::GetOutObj(int inV, int inH) const { return mOutObjArrayList->GetOutObjByID(GetOutObjID(inV, inH)); } T2OutObj* T2FloorInfo::GetIndOutObj(unsigned int inIndex) const { return mOutObjArrayList->GetIndOutObj(inIndex); } T2Tenant* T2FloorInfo::FindUnusedTenant() { return mTenantArrayList->FindUnusedTenant(); } T2Mover* T2FloorInfo::FindUnusedMover() { return mMoverArrayList->FindUnusedMover(); } T2Request* T2FloorInfo::FindUnusedRequest() { return mRequestArrayList->FindUnusedRequest(); } T2OutObj* T2FloorInfo::FindUnusedOutObj() { return mOutObjArrayList->FindUnusedOutObj(); } unsigned int T2FloorInfo::GetTenantID(int inV, int inH) const { unsigned int result = 0; T2UnitInfo *theUnitInfo = GetUnitInfo(inV, inH); if (theUnitInfo) result = theUnitInfo->GetTenantID(); return result; } unsigned int T2FloorInfo::GetFloorID(int inV, int inH) { unsigned int theID = 0; T2Tenant *theTenant = GetTenant(inV, inH); if (theTenant) theID = theTenant->GetFloorID(inV); return theID; } unsigned int T2FloorInfo::GetEntranceFloorID(unsigned int inTenantID) { unsigned int result = 0; if (inTenantID == 1 || inTenantID == 2) { result = 1000; } else { T2Tenant *theTenant = GetTenant(inTenantID); if (theTenant) result = theTenant->GetEntranceFloorID(); } return result; } POINT T2FloorInfo::GetEntrancePt(unsigned int inTenantID) { POINT result; result.x = -1; result.y = -1; if (inTenantID == 1 || inTenantID == 2) { unsigned int id = 1000; T2Tenant *theTenant = GetTenant(id); if (theTenant) { RECT area; theTenant->GetEquipArea(area); result.y = area.bottom - 1; if (inTenantID == 1) result.x = area.left; else result.x = area.right - 2; } } else { T2Tenant *theTenant = GetTenant(inTenantID); if (theTenant) result = theTenant->GetEntrancePt(); } return result; } unsigned int T2FloorInfo::GetMoverID(int inV, int inH) { unsigned int result = 0; T2UnitInfo *theUnitInfo = GetUnitInfo(inV, inH); if (theUnitInfo) result = theUnitInfo->GetMoverID(); return result; } unsigned int T2FloorInfo::GetRequestID(int inV, int inH) const { unsigned int result = 0; T2UnitInfo *theUnitInfo = GetUnitInfo(inV, inH); if (theUnitInfo) result = theUnitInfo->GetRequestID(); return result; } unsigned int T2FloorInfo::GetOutObjID(int inV, int inH) const { unsigned int result = 0; if (mOutsideInfo) result = mOutsideInfo->GetOutObjID(inV, inH); return result; } T2UnitInfo* T2FloorInfo::GetUnitInfo(int inV, int inH) const { T2UnitInfo *result = NULL; #line 829 _ASSERT((inV >= 0) && (inV < mVRange)); _ASSERT((inH >= 0) && (inH < mHRange)); if (inV >= 0 && inV < mVRange && inH >= 0 && inH < mHRange) result = &mUnitInfo[mHRange * inV + inH]; return result; } void T2FloorInfo::FillTenantID(const RECT& inRect, unsigned int inTenantID) { if (IsValidRange(inRect)) { T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *theUnitInfo; while (iterator.Next(theUnitInfo)) theUnitInfo->FillTenantID(inTenantID); } } void T2FloorInfo::ReplaceFloorID(const RECT& inRect, unsigned int inOldID, unsigned int inNewID) { if (IsValidRange(inRect)) { T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *theUnitInfo; while (iterator.Next(theUnitInfo)) { if (theUnitInfo->GetTenantID() == inOldID) theUnitInfo->FillTenantID(inNewID); } } } void T2FloorInfo::FillMoverID(const RECT& inRect, unsigned int inMoverID) { if (IsValidRange(inRect)) { T2FInfoAreaIterator iterator(*this, inRect); T2UnitInfo *theUnitInfo; while (iterator.Next(theUnitInfo)) theUnitInfo->FillMoverID(inMoverID); } } void T2FloorInfo::FillRequestID(const RECT& inRect, unsigned int inRequestID) { FillMoverID(inRect, inRequestID); } int T2FloorInfo::FillRequestID(POINT inPt, ERequestUpDown inUpDown, unsigned int inRequestID) { int theWidth = 0; POINT pt = inPt; if (inUpDown == ERequestUpDown_1) { pt.x += 2; T2Request *theRightReq = GetRequest(pt.y, pt.x); if (theRightReq) { POINT headPtR = theRightReq->GetHeadPosition(); theWidth = ((headPtR.x - inPt.x) / 2) - 2; int theRemain = theWidth + ((headPtR.x - inPt.x) % 2); theRightReq->SetDrawWidth(theRemain); } else { T2Tenant *theFloor = GetFloor(pt.y, pt.x); if (theFloor) { RECT floorArea; theFloor->GetEquipArea(floorArea); theWidth = CalcRequestRightEnd(pt, floorArea.right) - inPt.x - 2; } } } else { pt.x -= 3; T2Request *theLeftReq = GetRequest(pt.y, pt.x); if (theLeftReq) { POINT headPtL = theLeftReq->GetHeadPosition(); int theRemain = ((inPt.x - headPtL.x) / 2) - 2; theLeftReq->SetDrawWidth(theRemain); theWidth = theRemain + ((inPt.x - headPtL.x) % 2); } else { T2Tenant *theFloor = GetFloor(pt.y, pt.x); if (theFloor) { RECT floorArea; theFloor->GetEquipArea(floorArea); theWidth = inPt.x - CalcRequestLeftEnd(pt, floorArea.left) - 2; } } } RECT theFillArea; theFillArea.top = inPt.y; theFillArea.bottom = inPt.y + 1; theFillArea.left = theFillArea.right = inPt.x; if (inUpDown == ERequestUpDown_1) theFillArea.right = inPt.x + theWidth + 2; else theFillArea.left = inPt.x - theWidth - 2; FillRequestID(theFillArea, inRequestID); return theWidth; } void T2FloorInfo::RemoveRequestID(ERequestUpDown inUpDown, const RECT& inRect) { FillRequestID(inRect, 0); if (inUpDown == ERequestUpDown_0) { T2Request *theRequest = GetRequest(inRect.top, inRect.left - 1); if (theRequest) { RECT rect = inRect; rect.right -= 2; theRequest->SetDrawWidth(theRequest->GetDrawWidth() + (rect.right - rect.left)); FillRequestID(rect, theRequest->GetRequestID()); } } else { T2Request *theRequest = GetRequest(inRect.top, inRect.right); if (theRequest) { RECT rect = inRect; rect.left += 2; theRequest->SetDrawWidth(theRequest->GetDrawWidth() + (rect.right - rect.left)); FillRequestID(rect, theRequest->GetRequestID()); } } } void T2FloorInfo::FillOutObjID(const RECT& inRect, unsigned int inOutObjID) { if (IsValidRange(inRect)) mOutsideInfo->FillOutObjID(inRect, inOutObjID); } unsigned int T2FloorInfo::FindTenantID(int inV, int inH, BOOL inRight, int inMaxDistance, unsigned int inExclTenantID) { unsigned int id = 0; POINT ptStart; SetPt(&ptStart, inH, inV); T2FInfoPtIterator iterator(*this, ptStart); int count = 0; T2UnitInfo *theUnitInfo; unsigned int theUnitID; if (!inRight) { while (iterator.Left(theUnitInfo) && count < inMaxDistance) { theUnitID = theUnitInfo->GetTenantID(); if (theUnitID != 0 && theUnitID != inExclTenantID) { id = theUnitID; break; } count++; } } else { while (iterator.Right(theUnitInfo) && count < inMaxDistance) { theUnitID = theUnitInfo->GetTenantID(); if (theUnitID != 0 && theUnitID != inExclTenantID) { id = theUnitID; break; } count++; } } return id; } int T2FloorInfo::CalcRequestRightEnd(POINT inPt, int inMaxH) { int currH = inPt.x + 1; T2FInfoPtIterator iterator(*this, inPt); T2UnitInfo *theInfo; while (iterator.Right(theInfo) && currH < inMaxH) { if (theInfo->GetMoverID() != 0) { currH -= 2; break; } currH++; } return currH; } int T2FloorInfo::CalcRequestLeftEnd(POINT inPt, int inMinH) { int currH = inPt.x; T2FInfoPtIterator iterator(*this, inPt); T2UnitInfo *theInfo; while (iterator.Left(theInfo) && currH > inMinH) { if (theInfo->GetMoverID() != 0) { currH += 2; break; } currH--; } return currH; } int T2FloorInfo::GetLeftMoverID(POINT inPt, int inMinH) const { int moverID = 0; int currH = inPt.x; T2FInfoPtIterator iterator(*this, inPt); T2UnitInfo *theInfo; while (iterator.Left(theInfo) && currH > inMinH && moverID == 0) { moverID = theInfo->GetMoverID(); currH--; } return moverID; } void T2FloorInfo::UpdeteRequestByUnionFloor(T2Tenant* inTenant, POINT inPt) { POINT ptR = inPt; ptR.x++; T2Request *theLeftReq = GetRequest(inPt.y, inPt.x); T2Request *theRightReq = GetRequest(ptR.y, ptR.x); if (theLeftReq) { POINT headPtLeft = theLeftReq->GetHeadPosition(); if (theRightReq) { POINT headPtRight = theRightReq->GetHeadPosition(); int theWidth = ((headPtRight.x - headPtLeft.x) / 2) - 2; theLeftReq->SetDrawWidth(theWidth); theRightReq->SetDrawWidth(theWidth + ((headPtRight.x - headPtLeft.x) % 2)); RECT rightArea; theRightReq->CalcArea(rightArea); FillRequestID(rightArea, theRightReq->GetRequestID()); } else { RECT rightArea; inTenant->GetEquipArea(rightArea); theLeftReq->SetDrawWidth(CalcRequestRightEnd(inPt, rightArea.right) - headPtLeft.x - 2); } RECT leftArea; theLeftReq->CalcArea(leftArea); FillRequestID(leftArea, theLeftReq->GetRequestID()); } else if (theRightReq) { POINT headPtRight = theRightReq->GetHeadPosition(); RECT leftArea; inTenant->GetEquipArea(leftArea); theRightReq->SetDrawWidth(headPtRight.x - CalcRequestLeftEnd(ptR, leftArea.left) - 2); RECT rightArea; theRightReq->CalcArea(rightArea); FillRequestID(rightArea, theRightReq->GetRequestID()); } } void T2FloorInfo::MoverAreaAdded(const RECT& inRect, unsigned int inMoverID) { UpdeteRequestByBuildMover(inRect); FillMoverID(inRect, inMoverID); } void T2FloorInfo::MoverAreaRemoved(const RECT& inRect) { FillMoverID(inRect, 0); UpdeteRequestByRemoveMover(inRect); } void T2FloorInfo::UpdeteRequestByBuildMover(const RECT& inRect) { POINT ptStart; ptStart.x = inRect.left; ptStart.y = inRect.top; for (int v = inRect.top; v < inRect.bottom; v++, ptStart.y++) { T2Request *theRequest = GetRequest(ptStart.y, ptStart.x); if (theRequest) { POINT headPt = theRequest->GetHeadPosition(); int width = theRequest->GetDrawWidth() + 2; RECT area; area.top = v; area.bottom = v + 1; if (theRequest->GetUpDown() == ERequestUpDown_1) { POINT ptEnd = ptStart; area.left = inRect.left - 2; area.right = headPt.x + width; theRequest->SetDrawWidth(area.left - headPt.x - 2); FillRequestID(area, 0); ptEnd.x = area.right; T2Request *theOtherReq = GetRequest(ptEnd.y, ptEnd.x); if (theOtherReq) { POINT headPt2 = theOtherReq->GetHeadPosition(); if (ptEnd.x < (inRect.right + 2)) { area.left = ptEnd.x; area.right = inRect.right + 2; theOtherReq->SetDrawWidth(headPt2.x - area.right - 2); FillRequestID(area, 0); } else if (ptEnd.x > (inRect.right + 2)) { area.left = inRect.right + 2; area.right = ptEnd.x; theOtherReq->SetDrawWidth(headPt2.x - area.left - 2); FillRequestID(area, theOtherReq->GetRequestID()); } } } else { POINT ptEnd = ptStart; area.left = headPt.x - width; area.right = inRect.right + 2; theRequest->SetDrawWidth(headPt.x - area.right - 2); FillRequestID(area, 0); ptEnd.x = area.left - 1; T2Request *theOtherReq = GetRequest(ptEnd.y, ptEnd.x); if (theOtherReq) { POINT headPt2 = theOtherReq->GetHeadPosition(); area.left = ptEnd.x + 1; area.right = inRect.left - 2; theOtherReq->SetDrawWidth(area.right - headPt2.x - 2); FillRequestID(area, theOtherReq->GetRequestID()); } } } } } void T2FloorInfo::UpdeteRequestByRemoveMover(const RECT& inRect) { POINT ptL; POINT ptR; ptR.y = ptL.y = inRect.top; ptL.x = inRect.left - 3; ptR.x = inRect.right + 2; for (; ptL.y < inRect.bottom; ptL.y++, ptR.y++) { T2Request *theLeftReq = GetRequest(ptL.y, ptL.x); T2Request *theRightReq = GetRequest(ptR.y, ptR.x); if (theLeftReq) { POINT headPtLeft = theLeftReq->GetHeadPosition(); if (theRightReq) { POINT headPtRight = theRightReq->GetHeadPosition(); int theWidth = ((headPtRight.x - headPtLeft.x) / 2) - 2; theLeftReq->SetDrawWidth(theWidth); theRightReq->SetDrawWidth(theWidth + ((headPtRight.x - headPtLeft.x) % 2)); RECT rightArea; theRightReq->CalcArea(rightArea); FillRequestID(rightArea, theRightReq->GetRequestID()); } else { T2Tenant *theLeftFloor = GetFloor(ptL.y, ptL.x); if (theLeftFloor) { RECT floorArea; theLeftFloor->GetEquipArea(floorArea); theLeftReq->SetDrawWidth(CalcRequestRightEnd(ptL, floorArea.right) - headPtLeft.x - 2); } } RECT leftArea; theLeftReq->CalcArea(leftArea); FillRequestID(leftArea, theLeftReq->GetRequestID()); } else if (theRightReq) { POINT headPtRight = theRightReq->GetHeadPosition(); T2Tenant *theRightFloor = GetFloor(ptR.y, ptR.x); if (theRightFloor) { RECT floorArea; theRightFloor->GetEquipArea(floorArea); theRightReq->SetDrawWidth(headPtRight.x - CalcRequestLeftEnd(ptR, floorArea.left) - 2); } RECT rightArea; theRightReq->CalcArea(rightArea); FillRequestID(rightArea, theRightReq->GetRequestID()); } } } unsigned int T2FloorInfo::GetNextTenantNumber(int inV) { #line 1364 _ASSERT((inV >= 0) && (inV < mVRange)); unsigned int result = mTenantNumber[inV]; do { result++; if (result >= 1000) result = 1; } while (FindNumberredTenant(inV, result)); mTenantNumber[inV] = result; return result; } void T2FloorInfo::SetTenantNumber(int inV, unsigned int inTenantNumber) { #line 1387 _ASSERT((inV >= 0) && (inV < mVRange)); mTenantNumber[inV] = inTenantNumber; } T2Tenant* T2FloorInfo::FindNumberredTenant(int inV, unsigned int inTenantNumber) { #line 1399 _ASSERT((inV >= 0) && (inV < mVRange)); POINT leftPt; SetPt(&leftPt, mBuildArea.left, inV); T2FInfoPtIterator iterator(*this, leftPt); T2Tenant *theTenant = NULL; while (iterator.RightTenant(theTenant)) { if (theTenant->GetTenantNumber() == inTenantNumber) break; theTenant = NULL; } return theTenant; } void T2FloorInfo::FinishBuildFloor(T2TowerDoc* inDoc, const RECT& inRect) { T2FInfoAreaIterator iterator(*this, inRect); T2Tenant *theTenant; while (iterator.NextTenant(theTenant)) { if (!theTenant->IsBuildFinish()) theTenant->Idle(inDoc); } } void T2FloorInfo::SetTenantDrawModeByRect(const RECT& inRect, int inDrawMode) { RECT theRect = inRect; int actualMode; switch (inDrawMode) { case DrawMode1: { RECT rect2 = inRect; rect2.bottom = rect2.top + 1; T2FInfoAreaIterator iterator(*this, rect2); T2Tenant *theTenant; while (iterator.NextTenant(theTenant)) theTenant->SetDrawMode(inDrawMode); theRect.top++; actualMode = DrawMode2; break; } case DrawMode3: actualMode = DrawMode1; break; case DrawMode2: actualMode = inDrawMode; break; } T2FInfoAreaIterator iterator(*this, theRect); T2Tenant *theTenant; while (iterator.NextTenant(theTenant)) theTenant->SetDrawMode(actualMode); } void T2FloorInfo::UpdateFloorCEArray(const RECT& inRect, unsigned int inOldID, unsigned int inNewID) { POINT pt; pt.x = inRect.left; for (pt.y = inRect.top; pt.y < inRect.bottom; pt.y++) { T2Tenant *theFloor = GetFloor(pt.y, pt.x); if (theFloor) theFloor->ReplaceCEID(inOldID, inNewID); } } int T2FloorInfo::CalcMentenanceCost(T2TowerDoc* inDoc) const { int cost = 0; #line 1502 _ASSERT(mTenantArrayList != NULL); cost += mTenantArrayList->CalcMentenanceCost(inDoc); _ASSERT(mMoverArrayList != NULL); cost += mMoverArrayList->CalcMentenanceCost(inDoc); cost += mOutObjArrayList->CalcMentenanceCost(inDoc); return cost; } T2Tenant* T2FloorInfo::GetTenantByPID(DWORD inPluginID) { T2Tenant *result = NULL; if (mTenantArrayList) result = mTenantArrayList->GetTenantByPID(inPluginID); return result; } BOOL T2FloorInfo::BuildFinishForce(const RECT& inRect) { BOOL finished = false; POINT pt; T2Tenant *theTenant; for (pt.y = inRect.top; pt.y < inRect.bottom; pt.y++) { for (pt.x = inRect.left; pt.x < inRect.right; pt.x++) { theTenant = GetTenant(pt.y, pt.x); if (theTenant && theTenant->GetStatus() < kTenantStatus10) { theTenant->SetStatus(kTenantStatus9); theTenant->Idle(GetCurrentT2TowerDoc()); GetCurrentT2TowerDoc()->mTowerMainView->tmv_vf128(theTenant->mArea); finished = true; } } } return finished; }