2019-05-15 14:52:37 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "patcher.h"
|
2019-07-06 10:27:21 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "Lights.h"
|
2019-05-15 14:52:37 +00:00
|
|
|
#include "Pools.h"
|
2019-06-12 18:07:37 +00:00
|
|
|
#include "Radar.h"
|
|
|
|
#include "Object.h"
|
|
|
|
|
|
|
|
WRAPPER void CObject::ObjectDamage(float amount) { EAXJMP(0x4BB240); }
|
2019-07-08 19:37:47 +00:00
|
|
|
WRAPPER void CObject::DeleteAllTempObjectInArea(CVector, float) { EAXJMP(0x4BBED0); }
|
2019-06-12 18:07:37 +00:00
|
|
|
|
|
|
|
int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2;
|
2019-05-15 14:52:37 +00:00
|
|
|
|
|
|
|
void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); }
|
|
|
|
void CObject::operator delete(void *p, size_t sz) { CPools::GetObjectPool()->Delete((CObject*)p); }
|
|
|
|
|
2019-06-12 18:07:37 +00:00
|
|
|
CObject::CObject(void)
|
|
|
|
{
|
|
|
|
m_type = ENTITY_TYPE_OBJECT;
|
|
|
|
m_fUprootLimit = 0.0f;
|
|
|
|
m_nCollisionDamageEffect = 0;
|
2019-06-19 16:35:51 +00:00
|
|
|
m_nSpecialCollisionResponseCases = COLLRESPONSE_NONE;
|
|
|
|
m_bCameraToAvoidThisObject = false;
|
2019-06-12 18:07:37 +00:00
|
|
|
ObjectCreatedBy = 0;
|
|
|
|
m_nEndOfLifeTime = 0;
|
|
|
|
// m_nRefModelIndex = -1; // duplicate
|
|
|
|
// bUseVehicleColours = false; // duplicate
|
|
|
|
m_colour2 = 0;
|
|
|
|
m_colour1 = m_colour2;
|
|
|
|
field_172 = 0;
|
2019-06-30 19:06:55 +00:00
|
|
|
bIsPickup = false;
|
2019-06-12 18:07:37 +00:00
|
|
|
m_obj_flag2 = false;
|
|
|
|
m_obj_flag4 = false;
|
|
|
|
m_obj_flag8 = false;
|
|
|
|
m_obj_flag10 = false;
|
|
|
|
bHasBeenDamaged = false;
|
|
|
|
m_nRefModelIndex = -1;
|
|
|
|
bUseVehicleColours = false;
|
|
|
|
m_pCurSurface = nil;
|
|
|
|
m_pCollidingEntity = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
CObject::~CObject(void)
|
|
|
|
{
|
|
|
|
CRadar::ClearBlipForEntity(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(this));
|
|
|
|
|
|
|
|
if(m_nRefModelIndex != -1)
|
|
|
|
CModelInfo::GetModelInfo(m_nRefModelIndex)->RemoveRef();
|
|
|
|
|
|
|
|
if(ObjectCreatedBy == TEMP_OBJECT && nNoTempObjects != 0)
|
|
|
|
nNoTempObjects--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CObject::Render(void)
|
|
|
|
{
|
|
|
|
if(m_flagD80)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(m_nRefModelIndex != -1 && ObjectCreatedBy == TEMP_OBJECT && bUseVehicleColours){
|
|
|
|
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nRefModelIndex);
|
|
|
|
assert(mi->m_type == MITYPE_VEHICLE);
|
|
|
|
mi->SetVehicleColour(m_colour1, m_colour2);
|
|
|
|
}
|
|
|
|
|
|
|
|
CEntity::Render();
|
|
|
|
}
|
|
|
|
|
2019-07-06 10:27:21 +00:00
|
|
|
bool
|
|
|
|
CObject::SetupLighting(void)
|
|
|
|
{
|
|
|
|
DeActivateDirectional();
|
|
|
|
SetAmbientColours();
|
|
|
|
|
|
|
|
if(bRenderScorched){
|
|
|
|
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CObject::RemoveLighting(bool reset)
|
|
|
|
{
|
|
|
|
if(reset)
|
|
|
|
WorldReplaceScorchedLightsWithNormal(Scene.world);
|
|
|
|
}
|
|
|
|
|
2019-07-08 19:37:47 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
CObject::RefModelInfo(int32 modelId)
|
|
|
|
{
|
|
|
|
m_nRefModelIndex = modelId;
|
|
|
|
CModelInfo::GetModelInfo(modelId)->AddRef();
|
|
|
|
}
|
2019-06-24 22:42:23 +00:00
|
|
|
|
2019-07-08 06:46:42 +00:00
|
|
|
class CObject_ : public CObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void dtor(void) { this->CObject::~CObject(); }
|
|
|
|
void Render_(void) { CObject::Render(); }
|
|
|
|
};
|
|
|
|
|
2019-06-12 18:07:37 +00:00
|
|
|
STARTPATCHES
|
2019-07-08 06:46:42 +00:00
|
|
|
InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP);
|
|
|
|
InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP);
|
2019-06-12 18:07:37 +00:00
|
|
|
ENDPATCHES
|