summaryrefslogtreecommitdiffstats
path: root/src/buildings
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildings')
-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 00bbb21e..8035cf25 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 3586a8dc..2c2dfb1f 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 c3160f47..c3ab755e 100644
--- a/src/buildings/Treadable.h
+++ b/src/buildings/Treadable.h
@@ -8,10 +8,5 @@ public:
static void *operator new(size_t);
static void operator delete(void*, size_t);
- int16 m_nodeIndices[2][12]; // first car, then ped
-
bool GetIsATreadable(void) { return true; }
};
-
-VALIDATE_SIZE(CTreadable, 0x94);
-