summaryrefslogblamecommitdiffstats
path: root/src/entities/Building.cpp
blob: 7813c87f3dc270a77928f865248a42c5d9bce81a (plain) (tree)
1
2
3
4
5
6
7
8
                   
                    
                     
                      



                                                                                                         











                                                                        
                                                                              

 

              






                                                                  
            

                                                            

                                                                          
#include "common.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, STREAMFLAGS_DONT_REMOVE);
}

#include <new>

class CBuilding_ : public CBuilding
{
public:
	CBuilding *ctor(void) { return ::new (this) CBuilding(); }
	void dtor(void) { CBuilding::~CBuilding(); }
};

STARTPATCHES
	InjectHook(0x4057D0, &CBuilding_::ctor, PATCH_JUMP);
	InjectHook(0x405800, &CBuilding_::dtor, PATCH_JUMP);
	InjectHook(0x405850, &CBuilding::ReplaceWithNewModel, PATCH_JUMP);
ENDPATCHES