2019-05-15 16:52:37 +02:00
|
|
|
#include "common.h"
|
2019-06-19 23:41:43 +02:00
|
|
|
#include "patcher.h"
|
2019-05-15 16:52:37 +02:00
|
|
|
#include "Building.h"
|
2019-06-19 23:41:43 +02:00
|
|
|
#include "Streaming.h"
|
2019-05-15 16:52:37 +02:00
|
|
|
#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); }
|
2019-06-19 23:41:43 +02:00
|
|
|
|
|
|
|
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)
|
2019-06-20 14:49:16 +02:00
|
|
|
CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
|
2019-06-19 23:41:43 +02:00
|
|
|
}
|
|
|
|
|
2019-07-08 08:46:42 +02:00
|
|
|
class CBuilding_ : public CBuilding
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CBuilding *ctor(void) { return ::new (this) CBuilding(); }
|
|
|
|
void dtor(void) { CBuilding::~CBuilding(); }
|
|
|
|
};
|
|
|
|
|
2019-06-19 23:41:43 +02:00
|
|
|
STARTPATCHES
|
2019-07-08 08:46:42 +02:00
|
|
|
InjectHook(0x4057D0, &CBuilding_::ctor, PATCH_JUMP);
|
|
|
|
InjectHook(0x405800, &CBuilding_::dtor, PATCH_JUMP);
|
2019-06-19 23:41:43 +02:00
|
|
|
InjectHook(0x405850, &CBuilding::ReplaceWithNewModel, PATCH_JUMP);
|
|
|
|
ENDPATCHES
|