#include "StdAfx.h" #include "FloorDef.h" #include "../../../T2DLL/T2BitImage.h" #include "../../../T2DLL/T2CrossEquipArray.h" #include "../../../T2DLL/T2FInfoAreaIterator.h" #include "../../../T2DLL/T2FInfoPtIterator.h" #include "../../../T2DLL/T2FloorInfo.h" #include "../../../T2DLL/T2ImageObj.h" #include "../../../T2DLL/T2Mover.h" #include "../../../T2DLL/T2PaletteAnime.h" #include "../../../T2DLL/T2People.h" #include "../../../T2DLL/T2Request.h" #include "../../../T2DLL/T2RouteNavigator.h" #include "../../../T2DLL/T2Tenant.h" #include "../../../T2DLL/T2ToolWindow.h" #include "../../../T2DLL/T2TowerMessage.h" #include "../../../T2DLL/T2WorldDef.h" #include "../../../T2DLL/UT2Coordinate.h" #include "../../../T2TowerDoc.h" #include "../../../T2TowerMainView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif static BOOL DoMerges(T2Tenant *&ioFloor, T2TowerDoc *inDoc); static void MergeFloor(T2Tenant *inFloorA, T2Tenant *inFloorB, T2TowerDoc *inDoc); static void ReplaceMoverIDForFloors(const RECT &inRect, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo); static void ReplaceFloorIDForMovers(T2CrossEquipArray *inMoverIDArray, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo); /*virtual*/ unsigned int FloorDef::IdleProc(T2HaveOutViewObject *inObject, T2TowerDoc *inDoc) { unsigned int result = 0; T2Tenant *floor = (T2Tenant *) inObject; int status = floor->GetStatus(); if (status == kTenantStatus1) { T2Tenant *floorMerge = floor; CRect area; floorMerge->GetEquipArea(area); if (DoMerges(floorMerge, inDoc)) { inDoc->GetMainView()->InvalUnitRect(area); } else { floor->SetStatus(kTenantStatus10); result = 2; inDoc->GetRouteNavi()->FloorAdded(floorMerge, false); } BuildFinish(inDoc, floor); } return result; } FloorDef::FloorDef(DWORD inType, T2PluginSpecifier &inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin) : T2TenantDef(inType, inSpecifier, inResFile, inWorldDef, inPlugin) { } /*virtual*/ FloorDef::~FloorDef() { } /*virtual*/ T2InfoDialog *FloorDef::ShowInfoDialog(T2TowerDoc *doc, T2Equip *equip) { return NULL; } /*virtual*/ void FloorDef::DrawProc(T2HaveOutViewObject *inObject, const RECT &inRect, T2TowerDoc *inDoc) const { #pragma var_order(var14, width, var1C, var20, theTenant, theFloor, isExcludeRoofAndFloor, var30, floorArea, var44, var48, var4C, rect5, pattern, visibleRFloor, rect6, height, var88, id, var90, fInfoAreaIter) T2Tenant *theFloor = (T2Tenant *) inObject; CRect visibleFloor = inRect; visibleFloor = theFloor->mArea; T2FInfoAreaIterator fInfoAreaIter(*inDoc->GetFloorInfo(), theFloor->mArea); T2Tenant *theTenant; while (fInfoAreaIter.NextTenant(theTenant)) { if (theTenant->GetEquipID() == theFloor->GetEquipID()) { RECT rect2 = theFloor->mArea; fInfoAreaIter.GetTenantRect(rect2); RECT rect3; if (IntersectRect(&rect3, &rect2, &inRect)) { visibleFloor = rect2; break; } } } int height = theFloor->mArea.bottom - theFloor->mArea.top; int width = visibleFloor.left - theFloor->mArea.left; CRect floorArea = theFloor->mArea; int id; int pattern; BOOL isExcludeRoofAndFloor; if (inDoc->mViewMode != kOutView) { id = 100; if (theFloor->mValiation == 0) pattern = 100; else pattern = height * 100 + 1000; isExcludeRoofAndFloor = false; } else { id = 101; pattern = (inDoc->GetWorldDef()->GetOutViewKind() + 1) * 10000 + theFloor->mValiation * 1000 + height * 100; if (theFloor->IsFire()) pattern += 2; else if (inDoc->GetPaletteAnime()->IsSnow()) pattern += 1; isExcludeRoofAndFloor = true; } CRect rect5, rect6; int var14; int var44; T2BitImage *var48; if (inDoc->mViewMode != kOutView) { var44 = mImageObj->FindObject(id, pattern); var48 = mImageObj->GetObjectImage(var44, rect5); var14 = rect5.Width() / 8; } else { var14 = 0; } int var4C = mImageObj->FindObject(id, pattern + 100000); T2BitImage *var30 = mImageObj->GetObjectImage(var4C, rect6); int var88 = rect6.Width() / 8; int var90; if (inDoc->mViewMode != kOutView) { var90 = var14 + ((floorArea.left + var14 - 7) % 8) - 7; var90 = min(var90, visibleFloor.right - floorArea.left); } else { var90 = 0; } int var20 = visibleFloor.right - floorArea.left - var90; int var1C = floorArea.left + var90; if (var90 > width) { CRect src = rect5; src.right = src.left + var90 * 8; src.left += width * 8; CRect dst = visibleFloor; dst.right = min(dst.left + var90 - width, visibleFloor.right); visibleFloor.left = dst.right; UT2Coordinate::UnitToQD(dst, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); var48->CopyImage(*inDoc->GetImage(), src, dst); width = 0; } if (var20 > 0) { if (width > 0) width -= var90; width += var1C % var88; width %= var88; CRect dstUnitRect, srcRect, dstRect; if ((width + visibleFloor.Width()) <= var88) { dstUnitRect = visibleFloor; srcRect = rect6; srcRect.left += width * 8; srcRect.right = srcRect.left + visibleFloor.Width() * 8; UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); } else { if (width > 0) { dstUnitRect = visibleFloor; dstUnitRect.right = dstUnitRect.left + (var88 - width); srcRect = rect6; srcRect.left += width * 8; UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); visibleFloor.left = dstUnitRect.right; } while ((visibleFloor.left + var88) <= visibleFloor.right) { dstUnitRect = visibleFloor; dstUnitRect.right = dstUnitRect.left + var88; srcRect = rect6; UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); visibleFloor.left = dstUnitRect.right; } if (visibleFloor.left < visibleFloor.right) { dstUnitRect = visibleFloor; srcRect = rect6; srcRect.right = srcRect.left + dstUnitRect.Width() * 8; UT2Coordinate::UnitToQD(dstUnitRect, dstRect, inDoc->GetZoomLevel(), isExcludeRoofAndFloor); var30->CopyImage(*inDoc->GetImage(), srcRect, dstRect); visibleFloor.left = dstUnitRect.right; } } } } /*virtual*/ AREACHECKCODE FloorDef::AreaCheck(T2TowerDoc *inDoc, RECT &ioRect, unsigned int inInfo, BOOL inShowError) { AREACHECKCODE result = AreaCheckCode_1; if (!(inInfo & kAreaCheckFlag10000)) { if (GetCategory() != 100 && ioRect.top < inDoc->mWorldDef->mTopFloorLine) { if (inShowError) { // EN: Only Final item can be placed on the top floor of building. inDoc->GetTowerMessage()->BuildErr(68, NULL); } result = AreaCheckCode_0; } if (result == AreaCheckCode_1 && ioRect.bottom > inDoc->mWorldDef->mBottomFloorLine) { if (inShowError) { // EN: Can not place items beyond the edges of the floor below. inDoc->GetTowerMessage()->BuildErr(2, NULL); } return AreaCheckCode_0; } } if (result == AreaCheckCode_1) { inInfo &= 0xFF; if (ioRect.bottom == inDoc->GetWorldDef()->mGroundLine) { if (inInfo == 0) { if (inShowError) { // EN: Only the lobby item can be placed on the first floor. inDoc->GetTowerMessage()->BuildErr(15, NULL); } return AreaCheckCode_0; } } else { if (inInfo == 1) { if (inShowError) { // EN: The lobby item can be only placed on the first floor. inDoc->GetTowerMessage()->BuildErr(16, NULL); } return AreaCheckCode_0; } } if (inInfo != 3) { #line 289 _ASSERT(inDoc != NULL && inDoc->GetWorldDef() != NULL); if (ioRect.bottom < inDoc->GetWorldDef()->mTopFloorLine) { if (inShowError) { // EN: Can not place items here. inDoc->GetTowerMessage()->BuildErr(8, NULL); } return AreaCheckCode_0; } } if (inInfo == 0) { T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); if (ioRect.bottom <= theFloorInfo->GetGroundLine()) { for (int h = ioRect.left; h < ioRect.right; h++) { unsigned int theTenantID = theFloorInfo->GetTenantID(ioRect.bottom, h); if (theTenantID == 0) { if (inShowError) { RECT area; theFloorInfo->GetFloorArea(area); area.top = ioRect.bottom; area.bottom = ioRect.bottom + 1; T2FInfoAreaIterator iterator(*theFloorInfo, area); T2Tenant *theTenant; if (iterator.NextTenant(theTenant)) { // EN: Can not place items beyond the edges of the floor below. inDoc->GetTowerMessage()->BuildErr(2, NULL); } else { // EN: There is no floor below. inDoc->GetTowerMessage()->BuildErr(4, NULL); } } return AreaCheckCode_0; } else { T2Tenant *theTenant = theFloorInfo->GetTenant(theTenantID); if (theTenant && T2EquipDef::IsSetAttribute(kTenantAttr40000)) { if (inShowError) { // EN: Can not place this item above the sky bridge. inDoc->GetTowerMessage()->BuildErr(13, NULL); } return AreaCheckCode_0; } } } } else { BOOL flag = false; if (inDoc->GetWorldDef()->m17C == 1 || inDoc->GetWorldDef()->m17C == 2) { for (int v = ioRect.top; v < ioRect.bottom; v++) { if (theFloorInfo->GetTenantID(v, ioRect.left - 1) || theFloorInfo->GetTenantID(v, ioRect.right)) { flag = true; break; } } if (!flag) { for (int h = ioRect.left; h < ioRect.right; h++) { if (theFloorInfo->GetTenantID(ioRect.top - 1, h)) { flag = true; break; } } } } else { flag = true; for (int h = ioRect.left; h < ioRect.right; h++) { if (!theFloorInfo->GetTenantID(ioRect.top - 1, h)) { flag = false; break; } } } if (!flag) { if (inShowError) { // EN: Can not place items beyond the edges of the floor above. inDoc->GetTowerMessage()->BuildErr(3, NULL); } return AreaCheckCode_0; } } } RECT area; inDoc->GetFloorInfo()->GetFloorArea(area); int minimumX = (inInfo != 1) ? (ioRect.left - 9) : area.left; minimumX = max(minimumX, area.left); int maximumX = (inInfo != 1) ? (ioRect.right + 8) : (area.right - 1); maximumX = min(maximumX, area.right - 1); int y = ioRect.bottom - 1; int x; for (x = ioRect.left - 1; x >= minimumX; x--) { if (inDoc->GetFloorInfo()->GetTenant(y, x)) break; } if (x >= minimumX) ioRect.left = x + 1; for (x = ioRect.right; x <= maximumX; x++) { if (inDoc->GetFloorInfo()->GetTenant(y, x)) break; } if (x <= maximumX) ioRect.right = x; result = AreaCheckCode_1; } return result; } /*virtual*/ int FloorDef::RequierToolIcon(T2ToolWindow *window) { window->AddIcon(mStr48, 0, 1, kToolOption1, NULL, 0, 1, NULL); return 0; } /*virtual*/ CURSORTYPE FloorDef::QueryCursor(T2TowerDoc *inDoc, POINT inPt, CString &outSpriteName, RECT &outRect, POINT &outPt, int inZoomLevel, unsigned int inValiation, int i) { int height; if (inValiation == 0) { outSpriteName = "Csr"; height = mHeight; } else { char buf[20]; height = inDoc->GetWorldDef()->GetLobbyHeight(); wsprintfA(buf, "LCsr%d%d", 1, height); outSpriteName = buf; } inPt.x -= ((UT2Coordinate::UnitHSize(inZoomLevel) * mWidth) / 2) - (UT2Coordinate::UnitHSize(inZoomLevel) / 2); inPt.y -= ((UT2Coordinate::UnitVSize(inZoomLevel) * height) / 2) - (UT2Coordinate::UnitVSize(inZoomLevel) / 2); UT2Coordinate::QDToUnit(inPt, inZoomLevel); SetRect(&outRect, inPt.x, inPt.y, inPt.x + mWidth, inPt.y + height); outPt.x = outRect.left; outPt.y = outRect.top; UT2Coordinate::UnitToQD(outRect, inZoomLevel); return CursorType_0; } static BOOL DoMerges(T2Tenant *&ioFloor, T2TowerDoc *inDoc) { #pragma var_order(leftFloor, rightFloor, flag10, floorInfo, area, pt, result) BOOL result = false; BOOL flag10 = (ioFloor->GetEquipID() == 1000); T2FloorInfo *floorInfo = inDoc->mFloorInfo; RECT area; ioFloor->GetEquipArea(area); POINT pt; pt.y = area.top; pt.x = area.left - 1; T2Tenant *leftFloor = floorInfo->GetFloor(pt.y, pt.x); if (leftFloor && leftFloor->IsBuildFinish()) { if (!flag10) { MergeFloor(ioFloor, leftFloor, inDoc); ioFloor = leftFloor; } else { ioFloor->SetStatus(kTenantStatus10); inDoc->GetRouteNavi()->FloorAdded(ioFloor, false); MergeFloor(leftFloor, ioFloor, inDoc); } result = true; } pt.x = area.right; T2Tenant *rightFloor = floorInfo->GetFloor(pt.y, pt.x); if (rightFloor && rightFloor->IsBuildFinish()) { if (!result) { if (!flag10) { MergeFloor(ioFloor, rightFloor, inDoc); ioFloor = rightFloor; } else { ioFloor->SetStatus(kTenantStatus10); inDoc->GetRouteNavi()->FloorAdded(ioFloor, false); MergeFloor(rightFloor, ioFloor, inDoc); } } else { if (ioFloor->IsMoverAvailable() || flag10) { MergeFloor(rightFloor, ioFloor, inDoc); } else { MergeFloor(ioFloor, rightFloor, inDoc); } } result = true; } return result; } static void MergeFloor(T2Tenant *inFloorA, T2Tenant *inFloorB, T2TowerDoc *inDoc) { #pragma var_order(floorIDA, flagC, ceArrayB, floorInfo, ceArrayA, pt, areaA, isFloorB, areaB, isFinishA, floorIDB, isFloorA) T2FloorInfo *floorInfo = inDoc->mFloorInfo; #line 481 _ASSERT(floorInfo != NULL); BOOL isFloorA = inFloorA->IsFloor(); if (!isFloorA) { unsigned int floorID = inFloorA->GetFloorID(-1); if (floorID != 0) inFloorA = floorInfo->GetTenant(floorID); } BOOL isFloorB = inFloorB->IsFloor(); if (!isFloorB) { unsigned int floorID = inFloorB->GetFloorID(-1); if (floorID != 0) inFloorB = floorInfo->GetTenant(floorID); } BOOL isFinishA = inFloorA->IsBuildFinish(); BOOL flagC = isFinishA && inFloorA->IsMoverAvailable(); RECT areaA, areaB; inFloorA->GetEquipArea(areaA); inFloorB->GetEquipArea(areaB); unsigned int floorIDA = inFloorA->GetEquipID(); unsigned int floorIDB = inFloorB->GetEquipID(); T2CrossEquipArray *ceArrayA = inFloorA->GetCEArray(); T2CrossEquipArray *ceArrayB = inFloorB->GetCEArray(); ReplaceMoverIDForFloors(areaA, floorIDA, floorIDB, floorInfo); ReplaceFloorIDForMovers(ceArrayA, floorIDA, floorIDB, floorInfo); inFloorB->UnionFloorPeople(inFloorA); POINT pt; pt.x = (areaA.left < areaB.left) ? (areaB.left - 1) : (areaA.left - 1); pt.y = areaA.bottom - 1; ceArrayB->Union(ceArrayA); floorInfo->ReplaceFloorID(areaA, floorIDA, floorIDB); UnionRect(&areaB, &areaB, &areaA); inFloorB->SetEquipArea(areaB); if (isFinishA) inDoc->GetRouteNavi()->FloorRemoved(inFloorA, flagC); inFloorA->SetUsed(false); floorInfo->UpdeteRequestByUnionFloor(inFloorB, pt); } static void ReplaceMoverIDForFloors(const RECT &inRect, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo) { T2FInfoAreaIterator iterator(*inFloorInfo, inRect); T2Tenant *theTenant; while (iterator.NextTenant(theTenant)) { if (theTenant && !theTenant->IsFloor()) { T2CrossEquipArray *theFloorCEArray = theTenant->GetCEArray(); if (theFloorCEArray) theFloorCEArray->ReplaceID(inOldID, inNewID); } } } static void ReplaceFloorIDForMovers(T2CrossEquipArray *inMoverIDArray, unsigned int inOldID, unsigned int inNewID, T2FloorInfo *inFloorInfo) { LArrayIterator iterator(*inMoverIDArray); unsigned int theMoverID; while (iterator.Next(&theMoverID)) { T2Mover *theMover = inFloorInfo->GetMover(theMoverID); if (theMover) { T2CrossEquipArray *theMoverCEArray = theMover->GetCEArray(); if (theMoverCEArray) theMoverCEArray->ReplaceID(inOldID, inNewID); } } } /*virtual*/ void FloorDef::BuildFinish(T2TowerDoc *inDoc, T2Equip *inEquip) { T2EquipDef::BuildFinish(inDoc, inEquip); CRect floorArea; inEquip->GetEquipArea(floorArea); CRect aboveArea(floorArea.left, floorArea.top - 1, floorArea.right, floorArea.top); T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), aboveArea); T2Tenant *theTenant = NULL; while (iter.NextTenant(theTenant)) { if (theTenant->IsSetAttribute(kTenantAttr40000)) { theTenant->GetEquipDef()->OptionProc(inDoc, theTenant, NULL); break; } } } static PROCCODE x154C0(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect); /*virtual*/ PROCCODE FloorDef::DoDestructProc(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect) { T2Tenant *theFloor = (T2Tenant *) inObject; POINT unitPt = inPt; UT2Coordinate::QDToUnit(unitPt, inDoc->GetZoomLevel()); if (unitPt.y < (inDoc->GetFloorInfo()->GetGroundLine() - 1)) { if (!inDoc->GetFloorInfo()->GetTenant(unitPt.y + 1, unitPt.x)) return x154C0(inDoc, theFloor, unitPt, outRect); } PROCCODE result = ProcCode_1; int buildErr = 0; CRect equipArea; theFloor->GetEquipArea(equipArea); // bug??? if (!theFloor->GetCEArray() && theFloor->GetCEArray()->GetCount()) { result = ProcCode_2; // EN: This floor can not be removed because transit systems are connected. buildErr = 22; } if (result == ProcCode_1) { T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), equipArea); T2Mover *theMover; while (result == ProcCode_1 && iter.NextMover(theMover)) { CRect moverArea, intersect; theMover->CalcBodyArea(moverArea); if (intersect.IntersectRect(equipArea, moverArea)) { result = ProcCode_2; // EN: This floor can not be removed because transit systems are connected. buildErr = 22; } } } if (theFloor->GetFirstPeople()) { result = ProcCode_2; // EN: Can not remove the floor because there are people here. buildErr = 73; } if (result == ProcCode_1) { T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), equipArea); T2Tenant *tenant; while (iter.NextTenant(tenant) && tenant) { if (!tenant->IsFloor()) { result = ProcCode_2; // EN: This floor can not be removed because there is already a tenant on it. buildErr = 21; break; } } } if (result == ProcCode_1) { BOOL isAbove = equipArea.bottom <= inDoc->GetFloorInfo()->GetGroundLine(); if (isAbove) { CRect aboveArea(equipArea.left, equipArea.top - 1, equipArea.right, equipArea.top); T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), aboveArea); T2Tenant *tenant = NULL; if (iter.NextTenant(tenant) && tenant) { result = ProcCode_2; // EN: Floor can only be removed if it is the top floor of the building. buildErr = 19; } } BOOL isBelow = equipArea.bottom >= inDoc->GetFloorInfo()->GetGroundLine(); if (isBelow) { CRect undergroundArea(equipArea.left, equipArea.bottom, equipArea.right, equipArea.bottom + 1); T2FInfoAreaIterator iter(*inDoc->GetFloorInfo(), undergroundArea); T2Tenant *tenant = NULL; if (iter.NextTenant(tenant) && tenant) { result = ProcCode_2; // EN: Floor can only be removed if it is the lowest floor of the building. buildErr = 20; } } } if (buildErr != 0) inDoc->GetTowerMessage()->BuildErr(buildErr, NULL); if (result == ProcCode_1) result = ProcCode_0; return result; } static PROCCODE x154C0(T2TowerDoc *inDoc, T2HaveOutViewObject *inObject, POINT inPt, RECT &outRect) { #pragma var_order(crossEquipArrayIterator, lastID, theFloor, result, theMoverID, theIterR, theFloorID, theUpRequest, theFloorInfo, tenant, requestIterator, removedArea, iterator3, rightTenant, ceIterator, theFloorDef, rightArea, leftArea, leftTenant, floorArea, theRequest, theIterL, pt, theRightFloor, theRightFloorID, theCEArray, theDnRequest) PROCCODE result = ProcCode_1; T2FloorInfo *theFloorInfo = inDoc->GetFloorInfo(); T2Tenant *theFloor = (T2Tenant *) inObject; FloorDef *theFloorDef = (FloorDef *) theFloor->GetEquipDef(); unsigned int theFloorID = theFloor->GetEquipID(); CRect floorArea; theFloor->GetEquipArea(floorArea); outRect = floorArea; CRect removedArea(0, 0, 0, 0); POINT pt; pt.x = inPt.x; pt.y = inPt.y + 1; T2FInfoPtIterator theIterL(*theFloorInfo, inPt); T2FInfoPtIterator theIterR(*theFloorInfo, pt); T2Tenant *leftTenant = NULL; T2Tenant *rightTenant = NULL; if (theIterL.LeftTenant(leftTenant) && theIterR.RightTenant(rightTenant)) { CRect theLeftArea, theRightArea; leftTenant->GetEquipArea(theLeftArea); rightTenant->GetEquipArea(theRightArea); removedArea = CRect(theLeftArea.left, floorArea.top, theRightArea.right, floorArea.bottom); } T2CrossEquipArray *theCEArray = theFloor->GetCEArray(); LArrayIterator ceIterator(*theCEArray); unsigned int theMoverID; while (ceIterator.Next(&theMoverID)) { T2Mover *mover = theFloorInfo->GetMover(theMoverID); if (mover) { CRect moverArea, intersect; mover->GetEquipArea(moverArea); #line 634 _ASSERT(!intersect.IntersectRect(&removedArea, &moverArea)); } } T2Request *theDnRequest = NULL; T2Request *theUpRequest = NULL; T2Request *theRequest; T2FInfoAreaIterator requestIterator(*theFloorInfo, removedArea); while (requestIterator.NextRequest(theRequest)) { POINT head = theRequest->GetHeadPosition(); #line 646 _ASSERT(!removedArea.PtInRect(head)); CRect requestArea; theRequest->CalcArea(requestArea); if (theRequest->GetUpDown() == ERequestUpDown_1) theDnRequest = theRequest; else theUpRequest = theRequest; theFloorInfo->RemoveRequestID(theRequest->GetUpDown(), requestArea); } CRect leftArea(floorArea.left, floorArea.top, removedArea.left, floorArea.bottom); CRect rightArea(removedArea.right, floorArea.top, floorArea.right, floorArea.bottom); #line 659 _ASSERT(!leftArea.IsRectEmpty() && !rightArea.IsRectEmpty()); T2Tenant *theRightFloor = theFloorInfo->FindUnusedTenant(); #line 663 _ASSERT(theRightFloor != NULL); theRightFloor->InitTenant(theFloorDef, rightArea, theFloor->GetValiation()); theRightFloor->SetStatus(kTenantStatus10); unsigned int theRightFloorID = theRightFloor->GetEquipID(); theFloor->SetEquipArea(leftArea); unsigned int lastID = 0; LArrayIterator crossEquipArrayIterator(*theCEArray); while (crossEquipArrayIterator.Next(&theMoverID)) { T2Mover *mover = theFloorInfo->GetMover(theMoverID); if (mover) { CRect moverArea, intersect; mover->GetEquipArea(moverArea); if (intersect.IntersectRect(rightArea, moverArea)) { T2CrossEquipArray *moverCEArray = mover->GetCEArray(); if (moverCEArray) { moverCEArray->ReplaceID(theFloorID, theRightFloorID); theFloor->RemoveCEID(theMoverID); theRightFloor->InsertCEID(lastID, theMoverID); lastID = theMoverID; } } } } T2FInfoAreaIterator iterator3(*theFloorInfo, rightArea); T2Tenant *tenant; while (iterator3.NextTenant(tenant)) { if (!tenant->IsFloor()) { T2CrossEquipArray *tenantCEArray = tenant->GetCEArray(); if (tenantCEArray) tenantCEArray->ReplaceID(theFloorID, theRightFloorID); } } if (theFloor->IsTherePeople()) { int centerH = (removedArea.left + removedArea.right) / 2; T2People *thePeople = theFloor->mFirstPeople; T2People *theNextPeople = NULL; for (; thePeople; thePeople = theNextPeople) { theNextPeople = (T2People *) thePeople->mNext; POINT curPt = thePeople->GetCurPosition(); if (curPt.x < centerH) { if (curPt.x > (leftArea.right - 2)) thePeople->MoveHTo(leftArea.right - 2); } else { theFloor->Leave(thePeople); theRightFloor->Enter(thePeople); } thePeople->SetStatus(kStatus2); } } theFloorInfo->FillTenantID(removedArea, 0); theFloorInfo->ReplaceFloorID(rightArea, theFloorID, theRightFloorID); if (theDnRequest) theDnRequest->SetDrawWidth(theFloorInfo->FillRequestID(theDnRequest->GetHeadPosition(), ERequestUpDown_1, theDnRequest->GetRequestID())); if (theUpRequest) theUpRequest->SetDrawWidth(theFloorInfo->FillRequestID(theUpRequest->GetHeadPosition(), ERequestUpDown_0, theUpRequest->GetRequestID())); inDoc->GetRouteNavi()->FloorAdded(theRightFloor, true); return ProcCode_2; } /*virtual*/ PROCCODE FloorDef::DrawHitMask(T2TowerDoc *doc, T2HaveOutViewObject *object) { RECT rect; ((T2Tenant *) object)->GetEquipArea(rect); UT2Coordinate::UnitToQD(rect, doc->GetZoomLevel()); doc->GetImage()->FillRect(rect, 1); return ProcCode_1; }