re3/src/buildings/Building.cpp

45 lines
1.3 KiB
C++
Raw Normal View History

2019-05-15 14:52:37 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
2019-05-15 14:52:37 +00:00
#include "Building.h"
2019-06-19 21:41:43 +00:00
#include "Streaming.h"
2019-05-15 14:52:37 +00:00
#include "Pools.h"
void *CBuilding::operator new(size_t sz) throw() { return CPools::GetBuildingPool()->New(); }
void CBuilding::operator delete(void *p, size_t sz) throw() { CPools::GetBuildingPool()->Delete((CBuilding*)p); }
2019-06-19 21:41:43 +00:00
void
CBuilding::ReplaceWithNewModel(int32 id)
{
DeleteRwObject();
2020-05-05 12:06:55 +00:00
if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0)
2019-06-19 21:41:43 +00:00
CStreaming::RemoveModel(m_modelIndex);
m_modelIndex = id;
if(bIsBIGBuilding)
2020-07-13 14:43:09 +00:00
if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel)
2019-06-20 12:49:16 +00:00
CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
2019-06-19 21:41:43 +00:00
}
2020-05-18 22:49:09 +00:00
bool
IsBuildingPointerValid(CBuilding* pBuilding)
{
if (!pBuilding)
return false;
if (pBuilding->GetIsATreadable()) {
2020-12-06 18:28:40 +00:00
int index = CPools::GetTreadablePool()->GetJustIndex_NoFreeAssert((CTreadable*)pBuilding);
2020-05-18 22:49:09 +00:00
#ifdef FIX_BUGS
return index >= 0 && index < CPools::GetTreadablePool()->GetSize();
#else
return index >= 0 && index <= CPools::GetTreadablePool()->GetSize();
#endif
} else {
2020-12-06 18:28:40 +00:00
int index = CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pBuilding);
2020-05-18 22:49:09 +00:00
#ifdef FIX_BUGS
return index >= 0 && index < CPools::GetBuildingPool()->GetSize();
#else
return index >= 0 && index <= CPools::GetBuildingPool()->GetSize();
#endif
}
}