summaryrefslogtreecommitdiffstats
path: root/src/entities/Building.cpp
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-05-19 00:49:09 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-05-19 00:49:09 +0200
commit6510b15704998b14b89fa453ba9d142f85c30dd5 (patch)
treee194a3641474f3a0818bb4ff2dd139f2c293e804 /src/entities/Building.cpp
parentfixes for braking and cloud rotation at high fps (diff)
downloadre3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar
re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.gz
re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.bz2
re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.lz
re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.xz
re3-6510b15704998b14b89fa453ba9d142f85c30dd5.tar.zst
re3-6510b15704998b14b89fa453ba9d142f85c30dd5.zip
Diffstat (limited to 'src/entities/Building.cpp')
-rw-r--r--src/entities/Building.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp
index 3c096636..3217e684 100644
--- a/src/entities/Building.cpp
+++ b/src/entities/Building.cpp
@@ -20,3 +20,25 @@ CBuilding::ReplaceWithNewModel(int32 id)
if(m_level == LEVEL_NONE || 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((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(pBuilding);
+#ifdef FIX_BUGS
+ return index >= 0 && index < CPools::GetBuildingPool()->GetSize();
+#else
+ return index >= 0 && index <= CPools::GetBuildingPool()->GetSize();
+#endif
+ }
+}