summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PeopleArray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/T2DLL/T2PeopleArray.cpp')
-rw-r--r--src/T2DLL/T2PeopleArray.cpp105
1 files changed, 94 insertions, 11 deletions
diff --git a/src/T2DLL/T2PeopleArray.cpp b/src/T2DLL/T2PeopleArray.cpp
index 53a56e9..91edc64 100644
--- a/src/T2DLL/T2PeopleArray.cpp
+++ b/src/T2DLL/T2PeopleArray.cpp
@@ -1,40 +1,123 @@
#include "T2PeopleArray.h"
+#include "T2TowerDoc.h"
-T2PeopleArray::T2PeopleArray(unsigned int) {
+T2PeopleArray::T2PeopleArray(unsigned int startID)
+ : T2ObjectArray(startID)
+{
+ for (unsigned int i = 0; i < 256; i++)
+ mPeople[i].mMatterID = mStartID + i;
}
-T2People* T2PeopleArray::FindPeople(unsigned int) {
+T2People* T2PeopleArray::FindPeople(unsigned int peopleID) {
+ unsigned int firstID = mPeople[0].GetPeopleID();
+
+ if (firstID > peopleID || (firstID + 256) < peopleID)
+ return NULL;
+
+ for (int i = 0; i < 256; i++) {
+ if (mPeople[i].GetPeopleID() == peopleID)
+ return &mPeople[i];
+ }
+
+ return NULL;
}
-void T2PeopleArray::ResolveLink(T2PeopleArrayList*) {
+void T2PeopleArray::ResolveLink(T2PeopleArrayList* list) {
+ for (int i = 0; i < 256; i++) {
+ if (mPeople[i].IsUsed())
+ mPeople[i].ResolveLink(list);
+ }
}
T2People* T2PeopleArray::FindUnusedPeople() {
+ T2People *result = NULL;
+
+ for (unsigned int i = 0; i < 256; i++) {
+ if (!mPeople[i].IsUsed()) {
+ result = &mPeople[i];
+ break;
+ }
+ }
+
+ return result;
}
-/*virtual*/ void T2PeopleArray::DispatchIdle(T2TowerDoc*, int) {
+/*virtual*/ void T2PeopleArray::DispatchIdle(T2TowerDoc* towerDoc, int startIndex) {
+ int i;
+ T2People *people;
+
+ people = &mPeople[startIndex];
+ for (i = startIndex; i < 256; i += 8) {
+ if (people->mUsed)
+ people->Idle(towerDoc);
+ people += 8;
+ }
+
+ people = mPeople;
+ int walkRate = towerDoc->towerDoc_vf148();
+ for (i = 0; i < 256; i++) {
+ if (people->mUsed) {
+ if ((walkRate > 0 && !(i % walkRate)) || people->IsSetSpecialFlag(kSpecialFlag20))
+ people->IdleSearchedPerson(towerDoc);
+ }
+ people++;
+ }
}
-void T2PeopleArray::DrawSearchedPerson(T2TowerDoc*) {
+void T2PeopleArray::DrawSearchedPerson(T2TowerDoc* towerDoc) {
+ T2People *people = mPeople;
+ for (int i = 0; i < 256; i++) {
+ if (people->mUsed && people->IsWalk())
+ people->DrawSearchedPerson(towerDoc);
+ people++;
+ }
}
-void T2PeopleArray::SetWalkPeople(int) {
+void T2PeopleArray::SetWalkPeople(int v) {
+ for (int i = 0; i < 256; i++)
+ mPeople[i].SetWalk(false);
+
+ if (v != -1) {
+ for (int i = 0; i < 256; i += v)
+ mPeople[i].SetWalk(true);
+ }
}
void T2PeopleArray::DayChanged() {
+ for (int i = 0; i < 256; i++) {
+ if (mPeople[i].IsUsed())
+ mPeople[i].DayChanged();
+ }
}
-void T2PeopleArray::TenantRemoved(unsigned int) {
+void T2PeopleArray::TenantRemoved(unsigned int v) {
+ for (int i = 0; i < 256; i++) {
+ if (mPeople[i].IsUsed())
+ mPeople[i].TenantRemoved(v);
+ }
}
-void T2PeopleArray::AddStress(int) {
+void T2PeopleArray::AddStress(int v) {
+ for (int i = 0; i < 256; i++) {
+ if (mPeople[i].IsUsed())
+ mPeople[i].IncStress(v);
+ }
}
-void T2PeopleArray::BreakoutEmergency(T2TowerDoc*) {
+void T2PeopleArray::BreakoutEmergency(T2TowerDoc* towerDoc) {
+ for (int i = 0; i < 256; i++) {
+ T2People *people = &mPeople[i];
+ if (people->IsUsed())
+ people->BreakoutEmergency(towerDoc);
+ }
}
-void T2PeopleArray::Read(T2Archive&, T2TowerDoc*) {
+void T2PeopleArray::Read(T2Archive& archive, T2TowerDoc* towerDoc) {
+ for (int i = 0; i < 256; i++)
+ mPeople[i].Load(archive, towerDoc);
}
-void T2PeopleArray::Write(T2Archive&) {
+void T2PeopleArray::Write(T2Archive& archive) {
+ for (int i = 0; i < 256; i++)
+ mPeople[i].Save(archive);
}