diff options
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2ElevatorModule.cpp | 151 |
1 files changed, 75 insertions, 76 deletions
diff --git a/src/T2DLL/T2ElevatorModule.cpp b/src/T2DLL/T2ElevatorModule.cpp index 33fc3af..5fa8438 100644 --- a/src/T2DLL/T2ElevatorModule.cpp +++ b/src/T2DLL/T2ElevatorModule.cpp @@ -136,33 +136,33 @@ BOOL T2ElevatorModule::IsPtInArea(POINT pt, const RECT& area) const { void T2ElevatorModule::Remove(T2TowerDoc* towerDoc, T2Mover* mover) { T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); - T2People *people = NULL; - BOOL flag = true; + T2People *theRemovePeople = NULL; + BOOL isDown = true; T2Request *theRequest; switch (mStatus) { case kElevatorStatus1: - flag = false; + isDown = false; case kElevatorStatus2: - theRequest = mover->GetRequest(theFloorInfo, mPosition, flag); + theRequest = mover->GetRequest(theFloorInfo, mPosition, isDown); #line 183 ASSERT(theRequest != NULL); - people = theRequest->RemoveOffPeople(); + theRemovePeople = theRequest->RemoveOffPeople(); break; case kElevatorStatus3: theRequest = GetAppointRequest(theFloorInfo, mover); #line 189 ASSERT(theRequest != NULL); - people = theRequest->RemoveOnPeople(); + theRemovePeople = theRequest->RemoveOnPeople(); break; } - if (people) { - POINT curPosition = people->GetCurPosition(); - T2Tenant *theFloor = theFloorInfo->GetFloor(curPosition.y, curPosition.x); + if (theRemovePeople) { + POINT curPos = theRemovePeople->GetCurPosition(); + T2Tenant *theFloor = theFloorInfo->GetFloor(curPos.y, curPos.x); #line 199 ASSERT(theFloor != NULL); - theFloor->Enter(people); + theFloor->Enter(theRemovePeople); } T2MoverModule::RemoveContents(towerDoc); @@ -173,52 +173,51 @@ void T2ElevatorModule::RemoveContents(T2TowerDoc* towerDoc, T2Mover* mover, int BOOL flag = false; if (mLink1) { - POINT stopPt = mover->PositionToStopPt(position, ERequestUpDown_0); + POINT theStopPos = mover->PositionToStopPt(position, ERequestUpDown_0); T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C(); #line 221 ASSERT(theFloorInfo != NULL); - T2Tenant *theDstFloor = theFloorInfo->GetFloor(stopPt.y, stopPt.x); + T2Tenant *theDstFloor = theFloorInfo->GetFloor(theStopPos.y, theStopPos.x); #line 224 ASSERT(theDstFloor != NULL); T2PeopleLinkIterator iterator((T2People *) mLink1); - T2People *people = NULL; - T2People *nextPeople = NULL; - iterator.Next(&people); - while (people) { - iterator.Next(&nextPeople); - - POINT destPos = people->GetCurrDestPos(); - if (destPos.y == stopPt.y) { - Leave(people); - theDstFloor->Enter(people); - people->IncEstimate(-100); + T2People *thePeople = NULL; + T2People *theNextPeople = NULL; + iterator.Next(&thePeople); + while (thePeople) { + iterator.Next(&theNextPeople); + + if (thePeople->GetCurrDestPos().y == theStopPos.y) { + Leave(thePeople); + theDstFloor->Enter(thePeople); + thePeople->IncEstimate(-100); flag = true; } - people = nextPeople; - nextPeople = NULL; + thePeople = theNextPeople; + theNextPeople = NULL; } if (flag && IsPatChanged(mover)) { - RECT rect; - CalcUintArea(mover, rect); + RECT theRect; + CalcUintArea(mover, theRect); T2TowerMainView *theView = towerDoc->GetTowerMainView(); #line 251 ASSERT(theView != NULL); - theView->tmv_vf128(rect); + theView->tmv_vf128(theRect); } } } BOOL T2ElevatorModule::HomePosRemoved(T2Mover* mover, int position) { BOOL done = false; - int length = mover->GetLength(); + int theLength = mover->GetLength(); - for (unsigned int i = position + 1; !done && i < length; i++) { + for (unsigned int i = position + 1; !done && i < theLength; i++) { if (mover->IsStopPosition(i)) { mHomePosition = i; done = true; @@ -241,9 +240,9 @@ void T2ElevatorModule::TopTurnPosRemoved(int position) { if (mDirection != kElevatorDirection0 && mTopTurn != mBottomTurn) { BOOL done = false; - for (int i = position; !done && i > mBottomTurn; i--) { - if (IsStopPos(i, ERequestUpDown_0) || IsStopPos(i, ERequestUpDown_1)) { - mTopTurn = i; + for (int p = position; !done && p > mBottomTurn; p--) { + if (IsStopPos(p, ERequestUpDown_0) || IsStopPos(p, ERequestUpDown_1)) { + mTopTurn = p; done = true; } } @@ -258,9 +257,9 @@ void T2ElevatorModule::TopTurnPosRemoved(int position) { void T2ElevatorModule::BottomTurnPosRemoved(int position) { BOOL done = false; - for (int i = position; !done && i < mTopTurn; i++) { - if (IsStopPos(i, ERequestUpDown_0) || IsStopPos(i, ERequestUpDown_1)) { - mBottomTurn = i; + for (int p = position; !done && p < mTopTurn; p++) { + if (IsStopPos(p, ERequestUpDown_0) || IsStopPos(p, ERequestUpDown_1)) { + mBottomTurn = p; done = true; } } @@ -307,8 +306,8 @@ void T2ElevatorModule::MoverExpanded(T2Mover* mover, EEquipPos pos, int count) { mStopInfoArray->Expand(pos, count); int length = mover->GetLength(); - BOOL flag1 = false; - BOOL flag2 = false; + BOOL isResetPosition = false; + BOOL isResetHomePosition = false; switch (pos) { case EEquipPos_2: @@ -316,15 +315,15 @@ void T2ElevatorModule::MoverExpanded(T2Mover* mover, EEquipPos pos, int count) { if (mPosition > (length - 1)) { mOffsetPos = 0; mPosition = length - 1; - flag1 = true; + isResetPosition = true; } else if (mPosition == (length - 1) && mOffsetPos > 0) { mOffsetPos = 0; - flag1 = true; + isResetPosition = true; } if (mHomePosition > (length - 1)) { mHomePosition = length - 1; - flag2 = true; + isResetHomePosition = true; } } break; @@ -340,18 +339,18 @@ void T2ElevatorModule::MoverExpanded(T2Mover* mover, EEquipPos pos, int count) { if (mPosition < 0) { mOffsetPos = 0; mPosition = 0; - flag1 = true; + isResetPosition = true; } if (mHomePosition < 0) { mHomePosition = 0; - flag2 = true; + isResetHomePosition = true; } } break; } - if (flag1) { + if (isResetPosition) { if (mPosition != mNextStop || mNumPeople == 0) { mStatus = kElevatorStatus0; } else { @@ -360,7 +359,7 @@ void T2ElevatorModule::MoverExpanded(T2Mover* mover, EEquipPos pos, int count) { } } - if (flag2) { + if (isResetHomePosition) { mTopTurn = mBottomTurn = mNextStop = mHomePosition; StartToHomePos(); } @@ -434,28 +433,28 @@ void T2ElevatorModule::SetNextStop() { if (mStopInfoArray) { switch (mDirection) { case kElevatorDirection1: { - BOOL done = false; - for (int i = mPosition + 1; i < mTopTurn && !done; i++) { - if (IsStopPos(i, ERequestUpDown_0)) { - mNextStop = i; - done = true; + BOOL isStop = false; + for (int p = mPosition + 1; p < mTopTurn && !isStop; p++) { + if (IsStopPos(p, ERequestUpDown_0)) { + mNextStop = p; + isStop = true; } } - if (!done) + if (!isStop) mNextStop = mTopTurn; break; } case kElevatorDirection2: { - BOOL done = false; - for (int i = mPosition - 1; i > mBottomTurn && !done; i--) { - if (IsStopPos(i, ERequestUpDown_1)) { - mNextStop = i; - done = true; + BOOL isStop = false; + for (int p = mPosition - 1; p > mBottomTurn && !isStop; p--) { + if (IsStopPos(p, ERequestUpDown_1)) { + mNextStop = p; + isStop = true; } } - if (!done) + if (!isStop) mNextStop = mBottomTurn; break; } @@ -468,30 +467,30 @@ void T2ElevatorModule::ChangeTurnPos() { switch (mDirection) { case kElevatorDirection1: if (mBottomTurn == mPosition) { - BOOL done = false; - for (int i = mPosition; i < mNextStop && !done; i++) { - if (IsStopPos(i, ERequestUpDown_0) || IsStopPos(i, ERequestUpDown_1)) { - mBottomTurn = i; - done = true; + BOOL isStop = false; + for (int p = mPosition; p < mNextStop && !isStop; p++) { + if (IsStopPos(p, ERequestUpDown_0) || IsStopPos(p, ERequestUpDown_1)) { + mBottomTurn = p; + isStop = true; } } - if (!done) + if (!isStop) mBottomTurn = mNextStop; } break; case kElevatorDirection2: if (mTopTurn == mPosition) { - BOOL done = false; - for (int i = mPosition; i > mNextStop && !done; i--) { - if (IsStopPos(i, ERequestUpDown_0) || IsStopPos(i, ERequestUpDown_1)) { - mTopTurn = i; - done = true; + BOOL isStop = false; + for (int p = mPosition; p > mNextStop && !isStop; p--) { + if (IsStopPos(p, ERequestUpDown_0) || IsStopPos(p, ERequestUpDown_1)) { + mTopTurn = p; + isStop = true; } } - if (!done) + if (!isStop) mTopTurn = mNextStop; } break; @@ -557,25 +556,25 @@ void T2ElevatorModule::CalcUintArea(const T2Mover* mover, int position, RECT& ou } BOOL T2ElevatorModule::IsPatChanged(T2Mover* mover) { - BOOL changed = false; + BOOL isChanged = false; - T2MoverDef *def = (T2MoverDef *) mover->GetEquipDef(); - if (def) { - int newIndex = def->CalcModulePatIndex(mNumPeople); + T2MoverDef *moverDef = (T2MoverDef *) mover->GetEquipDef(); + if (moverDef) { + int newIndex = moverDef->CalcModulePatIndex(mNumPeople); if (mPatIndex != newIndex) { mPatIndex = newIndex; - changed = true; + isChanged = true; } } - if (changed) { + if (isChanged) { T2MoverModuleMessageData data; data.moverModule = this; data.value = GetPosition(); BroadcastMessage(1001, &data); } - return changed; + return isChanged; } T2People* T2ElevatorModule::LeaveToDstFloor(int y) { |