summaryrefslogtreecommitdiffstats
path: root/src/buildings/Building.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-12-20 11:39:44 +0100
committerSergeanur <s.anureev@yandex.ua>2020-12-20 11:40:59 +0100
commitbe92b57b54241de55e233376f481ba848ca8df35 (patch)
tree18111337fba137a947e5c7479021887a0c302fcb /src/buildings/Building.cpp
parentMerge pull request #890 from aap/miami (diff)
downloadre3-be92b57b54241de55e233376f481ba848ca8df35.tar
re3-be92b57b54241de55e233376f481ba848ca8df35.tar.gz
re3-be92b57b54241de55e233376f481ba848ca8df35.tar.bz2
re3-be92b57b54241de55e233376f481ba848ca8df35.tar.lz
re3-be92b57b54241de55e233376f481ba848ca8df35.tar.xz
re3-be92b57b54241de55e233376f481ba848ca8df35.tar.zst
re3-be92b57b54241de55e233376f481ba848ca8df35.zip
Diffstat (limited to 'src/buildings/Building.cpp')
-rw-r--r--src/buildings/Building.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/buildings/Building.cpp b/src/buildings/Building.cpp
new file mode 100644
index 00000000..8035cf25
--- /dev/null
+++ b/src/buildings/Building.cpp
@@ -0,0 +1,44 @@
+#include "common.h"
+
+#include "Building.h"
+#include "Streaming.h"
+#include "Pools.h"
+
+void *CBuilding::operator new(size_t sz) { return CPools::GetBuildingPool()->New(); }
+void CBuilding::operator delete(void *p, size_t sz) { CPools::GetBuildingPool()->Delete((CBuilding*)p); }
+
+void
+CBuilding::ReplaceWithNewModel(int32 id)
+{
+ DeleteRwObject();
+
+ if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0)
+ CStreaming::RemoveModel(m_modelIndex);
+ m_modelIndex = id;
+
+ if(bIsBIGBuilding)
+ 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
+ }
+}