summaryrefslogtreecommitdiffstats
path: root/src/buildings
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/buildings/Building.cpp22
-rw-r--r--src/buildings/Building.h3
-rw-r--r--src/buildings/Treadable.h5
3 files changed, 23 insertions, 7 deletions
diff --git a/src/buildings/Building.cpp b/src/buildings/Building.cpp
index e4475ae6..92c787e5 100644
--- a/src/buildings/Building.cpp
+++ b/src/buildings/Building.cpp
@@ -20,3 +20,25 @@ CBuilding::ReplaceWithNewModel(int32 id)
if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel)
CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
}
+
+bool
+IsBuildingPointerValid(CBuilding* pBuilding)
+{
+ if (!pBuilding)
+ return false;
+ if (pBuilding->GetIsATreadable()) {
+ int index = CPools::GetTreadablePool()->GetJustIndex_NoFreeAssert((CTreadable*)pBuilding);
+#ifdef FIX_BUGS
+ return index >= 0 && index < CPools::GetTreadablePool()->GetSize();
+#else
+ return index >= 0 && index <= CPools::GetTreadablePool()->GetSize();
+#endif
+ } else {
+ int index = CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pBuilding);
+#ifdef FIX_BUGS
+ return index >= 0 && index < CPools::GetBuildingPool()->GetSize();
+#else
+ return index >= 0 && index <= CPools::GetBuildingPool()->GetSize();
+#endif
+ }
+}
diff --git a/src/buildings/Building.h b/src/buildings/Building.h
index 94e66c89..f8ddfa46 100644
--- a/src/buildings/Building.h
+++ b/src/buildings/Building.h
@@ -17,5 +17,4 @@ public:
virtual bool GetIsATreadable(void) { return false; }
};
-VALIDATE_SIZE(CBuilding, 0x64);
-
+bool IsBuildingPointerValid(CBuilding*);
diff --git a/src/buildings/Treadable.h b/src/buildings/Treadable.h
index 9e895969..6a183c63 100644
--- a/src/buildings/Treadable.h
+++ b/src/buildings/Treadable.h
@@ -8,10 +8,5 @@ public:
static void *operator new(size_t) throw();
static void operator delete(void*, size_t) throw();
- int16 m_nodeIndices[2][12]; // first car, then ped
-
bool GetIsATreadable(void) { return true; }
};
-
-VALIDATE_SIZE(CTreadable, 0x94);
-