diff options
Diffstat (limited to '')
-rw-r--r-- | src/entities/Building.cpp | 21 | ||||
-rw-r--r-- | src/entities/Building.h | 3 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp index e8f19b01..ef236e89 100644 --- a/src/entities/Building.cpp +++ b/src/entities/Building.cpp @@ -1,7 +1,26 @@ #include "common.h" -#include "rpworld.h" +#include "patcher.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)->m_refCount == 0) + CStreaming::RemoveModel(m_modelIndex); + m_modelIndex = id; + + if(bIsBIGBuilding) + if(m_level == LEVEL_NONE || m_level == CGame::currLevel) + CStreaming::RequestModel(id, STREAM_DONT_REMOVE); +} + +STARTPATCHES + InjectHook(0x405850, &CBuilding::ReplaceWithNewModel, PATCH_JUMP); +ENDPATCHES diff --git a/src/entities/Building.h b/src/entities/Building.h index 612e0fb3..7b837f46 100644 --- a/src/entities/Building.h +++ b/src/entities/Building.h @@ -5,7 +5,6 @@ class CBuilding : public CEntity { public: - // TODO: ReplaceWithNewModel CBuilding(void) { m_type = ENTITY_TYPE_BUILDING; bUsesCollision = true; @@ -13,6 +12,8 @@ public: static void *operator new(size_t); static void operator delete(void*, size_t); + void ReplaceWithNewModel(int32 id); + virtual bool GetIsATreadable(void) { return false; } }; static_assert(sizeof(CBuilding) == 0x64, "CBuilding: error"); |