buildings directory

# Conflicts:
#	premake5.lua
This commit is contained in:
Sergeanur
2020-12-20 12:39:44 +02:00
parent 6697ab6b63
commit be92b57b54
6 changed files with 2 additions and 0 deletions

View File

@ -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
}
}

20
src/buildings/Building.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include "Entity.h"
class CBuilding : public CEntity
{
public:
CBuilding(void) {
m_type = ENTITY_TYPE_BUILDING;
bUsesCollision = true;
}
static void *operator new(size_t);
static void operator delete(void*, size_t);
void ReplaceWithNewModel(int32 id);
virtual bool GetIsATreadable(void) { return false; }
};
bool IsBuildingPointerValid(CBuilding*);

12
src/buildings/Solid.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "Entity.h"
class CSolid : public CEntity
{
public:
CSolid(void) {
m_type = ENTITY_TYPE_BUILDING;
bUsesCollision = true;
}
};

View File

@ -0,0 +1,8 @@
#include "common.h"
#include "rpworld.h"
#include "Treadable.h"
#include "Pools.h"
void *CTreadable::operator new(size_t sz) { return CPools::GetTreadablePool()->New(); }
void CTreadable::operator delete(void *p, size_t sz) { CPools::GetTreadablePool()->Delete((CTreadable*)p); }

12
src/buildings/Treadable.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "Building.h"
class CTreadable : public CBuilding
{
public:
static void *operator new(size_t);
static void operator delete(void*, size_t);
bool GetIsATreadable(void) { return true; }
};