summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2Mover.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2Mover.cpp')
-rw-r--r--src/T2DLL/T2Mover.cpp174
1 files changed, 89 insertions, 85 deletions
diff --git a/src/T2DLL/T2Mover.cpp b/src/T2DLL/T2Mover.cpp
index f62f502..65120c1 100644
--- a/src/T2DLL/T2Mover.cpp
+++ b/src/T2DLL/T2Mover.cpp
@@ -300,9 +300,9 @@ void T2Mover::RemoveUnstoppable(T2TowerDoc* towerDoc) {
T2MoverDef *theMoverDef = (T2MoverDef *) GetEquipDef();
BOOL changed = false;
- for (int i = 0; i < mLength; i++) {
- if (IsStopPosition(i) && !theMoverDef->IsaKindOfStopProc(towerDoc, this, i, 0)) {
- RemoveStopBoth(towerDoc, i);
+ for (int p = 0; p < mLength; p++) {
+ if (IsStopPosition(p) && !theMoverDef->IsaKindOfStopProc(towerDoc, this, p, 0)) {
+ RemoveStopBoth(towerDoc, p);
changed = true;
}
}
@@ -321,21 +321,23 @@ void T2Mover::AddCrossEquipID(T2FloorInfo* floorInfo, int position) {
}
void T2Mover::AddCEFloorID(T2FloorInfo* floorInfo, int position) {
- POINT stopPt = PositionToStopPt(position, ERequestUpDown_0);
- unsigned int floorID = floorInfo->GetFloorID(stopPt.y, stopPt.x);
+ POINT thePt = PositionToStopPt(position, ERequestUpDown_0);
+ unsigned int theOldFloorID;
+ unsigned int theFloorID = floorInfo->GetFloorID(thePt.y, thePt.x);
- if (floorID != 0) {
+ if (theFloorID != 0) {
int i;
for (i = position - 1; i >= 0; i--) {
if (IsStopPosition(i))
break;
}
- unsigned int idA = 0;
+ // BUG? The result of this GetFloorID call is assigned to theOldFloorID in the Mac version
+ theOldFloorID = 0;
if (i >= 0)
- floorInfo->GetFloorID(stopPt.y, stopPt.x - (position - i));
+ floorInfo->GetFloorID(thePt.y, thePt.x - (position - i));
- InsertCEID(idA, floorID);
+ InsertCEID(theOldFloorID, theFloorID);
}
}
@@ -349,10 +351,10 @@ POINT T2Mover::PositionToStopPt(int position, ERequestUpDown upDown) {
result.x = 0;
result.y = 0;
- T2MoverDef *theMoverDef = (T2MoverDef *) GetEquipDef();
- if (theMoverDef) {
+ T2MoverDef *moverDef = (T2MoverDef *) GetEquipDef();
+ if (moverDef) {
RECT addSize;
- theMoverDef->GetAddSize(addSize);
+ moverDef->GetAddSize(addSize);
result.y = mArea.bottom - 1 - addSize.bottom - position;
if (upDown == ERequestUpDown_0)
@@ -378,10 +380,10 @@ int T2Mover::UnitToPosition(int unit) const {
int T2Mover::PositionToUnit(int position) const {
int result = mArea.bottom - 1 - position;
- T2MoverDef *theMoverDef = (T2MoverDef *) GetEquipDef();
- if (theMoverDef) {
+ T2MoverDef *theDef = (T2MoverDef *) GetEquipDef();
+ if (theDef) {
RECT addSize;
- theMoverDef->GetAddSize(addSize);
+ theDef->GetAddSize(addSize);
result -= addSize.bottom;
}
@@ -443,16 +445,16 @@ int T2Mover::GetModuleCount() const {
}
BOOL T2Mover::FindStairModule(T2TowerDoc* towerDoc, POINT pt, T2MoverModule*& module1, T2MoverModule*& module2) {
- int var;
- PARTCODE partCode = GetPartFromPoint(towerDoc, pt, &var);
- BOOL result = (partCode == PartCode_2 && var >= 0);
+ int index;
+ PARTCODE thePartCode = GetPartFromPoint(towerDoc, pt, &index);
+ BOOL found = (thePartCode == PartCode_2 && index >= 0);
- if (result) {
- if (!mModuleList->FetchItemAt(var, &module1) || !mModuleList->FetchItemAt(var + 1, &module2))
- result = false;
+ if (found) {
+ if (!mModuleList->FetchItemAt(index, &module1) || !mModuleList->FetchItemAt(index + 1, &module2))
+ found = false;
}
- return result;
+ return found;
}
int T2Mover::CalcModuleRect(const T2MoverModule* module, RECT& rect, int& unk) const {
@@ -460,21 +462,21 @@ int T2Mover::CalcModuleRect(const T2MoverModule* module, RECT& rect, int& unk) c
}
T2MoverModule* T2Mover::FindPeople(const T2People* inPeople) const {
- T2MoverModule *result = NULL;
- T2MoverModuleList *theList = GetModuleList();
+ T2MoverModule *theMoverModule = NULL;
+ T2MoverModuleList *theModuleList = GetModuleList();
- if (theList) {
- LArrayIterator moduleIterator(*theList);
+ if (theModuleList) {
+ LArrayIterator moduleIterator(*theModuleList);
T2MoverModule *moverModule;
- while (!result && moduleIterator.Next(&moverModule)) {
+ while (!theMoverModule && moduleIterator.Next(&moverModule)) {
if (moverModule->IsUsed() && moverModule->mLink1) {
- T2PeopleLinkIterator peopleIterator((T2People *) moverModule->mLink1);
- T2People *people;
+ T2PeopleLinkIterator peopleLinkIterator((T2People *) moverModule->mLink1);
+ T2People *thePeople;
- while (peopleIterator.Next(&people)) {
- if (people == inPeople) {
- result = moverModule;
+ while (peopleLinkIterator.Next(&thePeople)) {
+ if (thePeople == inPeople) {
+ theMoverModule = moverModule;
break;
}
}
@@ -482,7 +484,7 @@ T2MoverModule* T2Mover::FindPeople(const T2People* inPeople) const {
}
}
- return result;
+ return theMoverModule;
}
void T2Mover::CalcMachineArea(EEquipPos pos, RECT& rect) const {
@@ -540,51 +542,51 @@ int T2Mover::CalcScore(int multiplier) const {
return result;
}
-int T2Mover::ExpandArea(T2TowerDoc* towerDoc, EEquipPos pos, int count) {
+int T2Mover::ExpandArea(T2TowerDoc* inDoc, EEquipPos inEquipPos, int inCount) {
int result = 0;
- T2FloorInfo *theFloorInfo = towerDoc->towerDoc_vf12C();
+ T2FloorInfo *theFloorInfo = inDoc->towerDoc_vf12C();
- RECT area = mArea;
+ RECT theMoverArea = mArea;
- RECT addSize;
- ((T2MoverDef *) mToolDef)->GetAddSize(addSize);
+ RECT theAddSize;
+ ((T2MoverDef *) mToolDef)->GetAddSize(theAddSize);
- switch (pos) {
+ switch (inEquipPos) {
case EEquipPos_2:
- if (count < 0) {
- for (int i = 0; i < -count; i++) {
- int position = mLength - 1 - i;
- if (IsStopPosition(position)) {
- RemoveStopBoth(towerDoc, position);
+ if (inCount < 0) {
+ for (int i = 0; i < -inCount; i++) {
+ int pos = mLength - 1 - i;
+ if (IsStopPosition(pos)) {
+ RemoveStopBoth(inDoc, pos);
result = 2;
}
}
}
- mArea.top -= count;
- mLength += count;
- mReqIDArray->Expand(ReqIDArrayPos_1, count);
- ((T2ElvModuleList *) mModuleList)->MoverExpanded(this, EEquipPos_2, count);
+ mArea.top -= inCount;
+ mLength += inCount;
+ mReqIDArray->Expand(ReqIDArrayPos_1, inCount);
+ ((T2ElvModuleList *) mModuleList)->MoverExpanded(this, EEquipPos_2, inCount);
- if (count > 0) {
- area.bottom = area.top;
- area.top -= count;
- theFloorInfo->MoverAreaAdded(area, mEquipID);
- area.bottom += -addSize.top;
+ if (inCount > 0) {
+ theMoverArea.bottom = theMoverArea.top;
+ theMoverArea.top -= inCount;
+ theFloorInfo->MoverAreaAdded(theMoverArea, mEquipID);
+ theMoverArea.bottom += -theAddSize.top;
} else {
- area.bottom = area.top - count;
- theFloorInfo->MoverAreaRemoved(area);
- area.bottom += -addSize.top + 1;
+ theMoverArea.bottom = theMoverArea.top - inCount;
+ theFloorInfo->MoverAreaRemoved(theMoverArea);
+ theMoverArea.bottom += -theAddSize.top + 1;
}
- if (count > 0) {
- RemoveUnstoppable(towerDoc);
+ if (inCount > 0) {
+ RemoveUnstoppable(inDoc);
T2MoverDef *theMoverDef = (T2MoverDef *) GetEquipDef();
- for (int i = 0; i < count; i++) {
- int position = mLength - 1 - i;
+ for (int i = 0; i < inCount; i++) {
+ int pos = mLength - 1 - i;
if (theMoverDef->GetMaxStop() == 0 || GetNumStop() < theMoverDef->GetMaxStop()) {
- if (theMoverDef->IsaKindOfStopProc(towerDoc, this, position, 1) && !IsStopPosition(position)) {
- AddStopBoth(towerDoc, position);
+ if (theMoverDef->IsaKindOfStopProc(inDoc, this, pos, 1) && !IsStopPosition(pos)) {
+ AddStopBoth(inDoc, pos);
result = 1;
}
}
@@ -594,38 +596,38 @@ int T2Mover::ExpandArea(T2TowerDoc* towerDoc, EEquipPos pos, int count) {
break;
case EEquipPos_3:
- if (count < 0) {
- for (int position = 0; position < -count; position++) {
- if (IsStopPosition(position)) {
- RemoveStopBoth(towerDoc, position);
+ if (inCount < 0) {
+ for (int pos = 0; pos < -inCount; pos++) {
+ if (IsStopPosition(pos)) {
+ RemoveStopBoth(inDoc, pos);
result = 2;
}
}
}
- mArea.bottom += count;
- mLength += count;
- mReqIDArray->Expand(ReqIDArrayPos_0, count);
- ((T2ElvModuleList *) mModuleList)->MoverExpanded(this, EEquipPos_3, count);
+ mArea.bottom += inCount;
+ mLength += inCount;
+ mReqIDArray->Expand(ReqIDArrayPos_0, inCount);
+ ((T2ElvModuleList *) mModuleList)->MoverExpanded(this, EEquipPos_3, inCount);
- if (count > 0) {
- area.top = area.bottom;
- area.bottom += count;
- theFloorInfo->MoverAreaAdded(area, mEquipID);
- area.top -= addSize.bottom;
+ if (inCount > 0) {
+ theMoverArea.top = theMoverArea.bottom;
+ theMoverArea.bottom += inCount;
+ theFloorInfo->MoverAreaAdded(theMoverArea, mEquipID);
+ theMoverArea.top -= theAddSize.bottom;
} else {
- area.top = area.bottom + count;
- theFloorInfo->MoverAreaRemoved(area);
- area.top -= addSize.bottom + 1;
+ theMoverArea.top = theMoverArea.bottom + inCount;
+ theFloorInfo->MoverAreaRemoved(theMoverArea);
+ theMoverArea.top -= theAddSize.bottom + 1;
}
- if (count > 0) {
- RemoveUnstoppable(towerDoc);
+ if (inCount > 0) {
+ RemoveUnstoppable(inDoc);
T2MoverDef *theMoverDef = (T2MoverDef *) GetEquipDef();
- for (int position = 0; position < count; position++) {
+ for (int pos = 0; pos < inCount; pos++) {
if (theMoverDef->GetMaxStop() == 0 || GetNumStop() < theMoverDef->GetMaxStop()) {
- if (theMoverDef->IsaKindOfStopProc(towerDoc, this, position, 1) && !IsStopPosition(position)) {
- AddStopBoth(towerDoc, position);
+ if (theMoverDef->IsaKindOfStopProc(inDoc, this, pos, 1) && !IsStopPosition(pos)) {
+ AddStopBoth(inDoc, pos);
result = 1;
}
}
@@ -635,8 +637,8 @@ int T2Mover::ExpandArea(T2TowerDoc* towerDoc, EEquipPos pos, int count) {
break;
}
- if (count != 0)
- towerDoc->GetTowerMainView()->tmv_vf128(area, true);
+ if (inCount != 0)
+ inDoc->GetTowerMainView()->tmv_vf128(theMoverArea, true);
return result;
}
@@ -708,6 +710,7 @@ void T2Mover::HideShaft() {
mCapacity = GetEquipDef()->GetCapacity();
}
+#pragma var_order(uc, s)
unsigned char uc;
short s;
@@ -733,6 +736,7 @@ void T2Mover::HideShaft() {
if (GetEquipDef()) {
GetEquipDef()->LoadExtraData(archive, towerDoc, this);
} else {
+#pragma var_order(i, count)
int count;
archive >> count;