summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2MoverModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2MoverModule.cpp')
-rw-r--r--src/T2DLL/T2MoverModule.cpp223
1 files changed, 205 insertions, 18 deletions
diff --git a/src/T2DLL/T2MoverModule.cpp b/src/T2DLL/T2MoverModule.cpp
index 358c1f2..d4a267b 100644
--- a/src/T2DLL/T2MoverModule.cpp
+++ b/src/T2DLL/T2MoverModule.cpp
@@ -1,15 +1,70 @@
+#include "GlobalFunc.h"
+#include "T2Archive.h"
+#include "T2FloorInfo.h"
+#include "T2Mover.h"
#include "T2MoverModule.h"
+#include "T2Name.h"
+#include "T2NameList.h"
+#include "T2People.h"
+#include "T2PeopleArrayList.h"
+#include "T2Tenant.h"
+#include "T2TowerDoc.h"
T2MoverModule::T2MoverModule() {
+ mPosition = 0;
+ mDirection = 0;
+ mWaitCounter = 0;
+ mPatIndex = 0;
+ mNumPeople = 0;
+ _4C = 0;
+ mLink1 = NULL;
+ mLink2 = NULL;
+ mModuleID = 0;
}
/*virtual*/ T2MoverModule::~T2MoverModule() {
}
-/*virtual*/ void T2MoverModule::SetUsed(int) {
+/*virtual*/ void T2MoverModule::SetUsed(BOOL used) {
+ if (!used) {
+ T2TowerDoc *towerDoc = GetCurrentT2TowerDoc();
+#line 35
+ ASSERT(towerDoc);
+
+ T2NameList *nameList = towerDoc->mNameDB;
+#line 38
+ ASSERT(nameList);
+
+ T2Name *name = nameList->Search(this, true);
+ if (name) {
+ nameList->RemoveName(name);
+ delete name;
+ }
+
+ name = nameList->Search(this, false);
+ if (name) {
+ nameList->RemoveName(name);
+ delete name;
+ }
+ }
+
+ T2Object::SetUsed(used);
}
-/*virtual*/ void T2MoverModule::RemoveContents(T2TowerDoc*) {
+/*virtual*/ void T2MoverModule::RemoveContents(T2TowerDoc* towerDoc) {
+ T2FloorInfo *floorInfo = towerDoc->mFloorInfo;
+
+ while (mLink1) {
+ T2People *people = (T2People *) mLink1;
+ Leave(people);
+
+ POINT destPos = people->GetCurrDestPos();
+ T2Tenant *floor = floorInfo->GetFloor(destPos.y, destPos.x);
+ if (floor) {
+ floor->Enter(people);
+ people->IncEstimate(-100);
+ }
+ }
}
/*virtual*/ void T2MoverModule::StopAdded(T2TowerDoc*, T2Mover*, int) {
@@ -18,32 +73,164 @@ T2MoverModule::T2MoverModule() {
/*virtual*/ void T2MoverModule::StopRemoved(T2TowerDoc*, T2Mover*, int) {
}
-/*virtual*/ void T2MoverModule::Enter(T2Mover*, T2People*) {
+/*virtual*/ void T2MoverModule::Enter(T2Mover* mover, T2People* people) {
+ people->mCurrEquipID = mover->GetEquipID();
+
+ RECT area;
+ mover->GetEquipArea(area);
+ people->mCurPosition.x = (area.left + area.right) / 2;
+
+ people->ChangeStatus(kStatus8);
+ Enter(people);
+}
+
+/*virtual*/ BOOL T2MoverModule::Enter(CLink* link) {
+ mNumPeople++;
+
+ if (!mLink1) {
+ mLink1 = link;
+ mLink2 = link;
+ link->SetPrev(NULL);
+ return true;
+ }
+
+ if (mLink2) {
+ mLink2->InsertAt(link);
+ mLink2 = link;
+ return true;
+ }
+
+ return false;
+}
+
+/*virtual*/ BOOL T2MoverModule::Leave(CLink* link) {
+ mNumPeople--;
+
+ if (mLink1) {
+ if (mLink1 == link) {
+ mLink1 = link->GetNext();
+ if (mLink1 == NULL)
+ mLink2 = NULL;
+ else if (mLink1->GetNext() == NULL)
+ mLink2 = mLink1;
+ link->Remove();
+ return true;
+ }
+
+ if (mLink2 != link) {
+ link->Remove();
+ } else if (mLink2 == link) {
+ mLink2 = link->GetPrev();
+ link->Remove();
+ if (mLink2 == NULL)
+ mLink1 = NULL;
+ return true;
+ }
+ }
+
+ return false;
}
-/*virtual*/ int T2MoverModule::Enter(CLink*) {
-}
+/*virtual*/ void T2MoverModule::LoadSelf(T2Archive& archive, T2TowerDoc* towerDoc) {
+ T2Object::LoadSelf(archive, towerDoc);
-/*virtual*/ int T2MoverModule::Leave(CLink*) {
-}
+ if (IsUsed()) {
+ short s;
-/*virtual*/ void T2MoverModule::LoadSelf(T2Archive&, T2TowerDoc*) {
-}
+ archive >> s;
+ mPosition = s;
+ archive >> s;
+ mDirection = s;
+ archive >> s;
+ mWaitCounter = s;
+ archive >> s;
+ mPatIndex = s;
+ archive >> s;
+ mNumPeople = s;
+ archive >> s;
+ _4C = s;
-/*virtual*/ void T2MoverModule::SaveSelf(T2Archive&) {
-}
+ unsigned int peopleID;
-void T2MoverModule::SetDirection(int) {
-}
+ archive >> peopleID;
+ if (peopleID)
+ mLink1 = towerDoc->mPeopleArrayList->FindPeople(peopleID);
+ else
+ mLink1 = NULL;
-void T2MoverModule::AddPosition(int) {
+ archive >> peopleID;
+ if (peopleID)
+ mLink2 = towerDoc->mPeopleArrayList->FindPeople(peopleID);
+ else
+ mLink2 = NULL;
+ }
}
-/*static*/ unsigned int T2MoverModule::GetNewModuleID(T2TowerDoc*) {
-}
+/*virtual*/ void T2MoverModule::SaveSelf(T2Archive& archive) {
+ T2Object::SaveSelf(archive);
+
+ if (IsUsed()) {
+ short s;
+
+ s = mPosition;
+ archive << s;
+ s = mDirection;
+ archive << s;
+ s = mWaitCounter;
+ archive << s;
+ s = mPatIndex;
+ archive << s;
+ s = mNumPeople;
+ archive << s;
+ s = _4C;
+ archive << s;
+
+ unsigned int peopleID;
+
+ if (mLink1)
+ peopleID = ((T2People *) mLink1)->GetPeopleID();
+ else
+ peopleID = 0;
+ archive << peopleID;
+
+ if (mLink2)
+ peopleID = ((T2People *) mLink2)->GetPeopleID();
+ else
+ peopleID = 0;
+ archive << peopleID;
+ }
+}
+
+void T2MoverModule::SetDirection(int direction) {
+ mDirection = direction;
+
+ T2MoverModuleMessageData data;
+ data.moverModule = this;
+ data.value = mPosition;
+ BroadcastMessage(1000, &data);
+}
+
+void T2MoverModule::AddPosition(int value) {
+ int oldPosition = mPosition;
+ mPosition += value;
+
+ T2MoverModuleMessageData data;
+ data.moverModule = this;
+ data.value = oldPosition;
+ BroadcastMessage(1000, &data);
+}
+
+/*static*/ unsigned int T2MoverModule::sModuleID;
+
+/*static*/ unsigned int T2MoverModule::GetNewModuleID(T2TowerDoc* towerDoc) {
+incAgain:
+ sModuleID++;
+ if (towerDoc->towerDoc_vf12C()->GetModule(sModuleID))
+ goto incAgain;
-void T2MoverModule::SetModuleID(T2TowerDoc*) {
+ return sModuleID;
}
-/*static*/ unsigned int T2MoverModule::sModuleID {
+void T2MoverModule::SetModuleID(T2TowerDoc* towerDoc) {
+ mModuleID = GetNewModuleID(towerDoc);
}