summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
authorFire_Head <Fire-Head@users.noreply.github.com>2019-06-13 02:47:13 +0200
committerGitHub <noreply@github.com>2019-06-13 02:47:13 +0200
commit9689def6a59bd8a1d05860c7d23f1837cf3b4a80 (patch)
treecbd5cdfcb16bb993ca4b75552a48eab641541b77 /src/entities
parentUpdate Replay.h (diff)
parentsilly mistake (diff)
downloadre3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.tar
re3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.tar.gz
re3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.tar.bz2
re3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.tar.lz
re3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.tar.xz
re3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.tar.zst
re3-9689def6a59bd8a1d05860c7d23f1837cf3b4a80.zip
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/CutsceneHead.cpp115
-rw-r--r--src/entities/CutsceneHead.h14
-rw-r--r--src/entities/CutsceneObject.cpp96
-rw-r--r--src/entities/CutsceneObject.h16
-rw-r--r--src/entities/Entity.h2
-rw-r--r--src/entities/Object.cpp63
-rw-r--r--src/entities/Object.h13
-rw-r--r--src/entities/Physical.cpp54
-rw-r--r--src/entities/Physical.h2
9 files changed, 371 insertions, 4 deletions
diff --git a/src/entities/CutsceneHead.cpp b/src/entities/CutsceneHead.cpp
index 6a8874f5..766befb0 100644
--- a/src/entities/CutsceneHead.cpp
+++ b/src/entities/CutsceneHead.cpp
@@ -1,2 +1,117 @@
#include "common.h"
+#include <rpskin.h>
+#include "patcher.h"
+#include "RwHelper.h"
+#include "RpAnimBlend.h"
+#include "AnimBlendClumpData.h"
+#include "Directory.h"
+#include "CutsceneMgr.h"
+#include "Streaming.h"
#include "CutsceneHead.h"
+
+
+CCutsceneHead::CCutsceneHead(CObject *obj)
+{
+ RpAtomic *atm;
+
+ assert(RwObjectGetType(obj->m_rwObject) == rpCLUMP);
+ m_pHeadNode = RpAnimBlendClumpFindFrame((RpClump*)obj->m_rwObject, "Shead")->frame;
+ atm = (RpAtomic*)GetFirstObject(m_pHeadNode);
+ if(atm){
+ assert(RwObjectGetType(atm) == rpATOMIC);
+ RpAtomicSetFlags(atm, RpAtomicGetFlags(atm) & ~rpATOMICRENDER);
+ }
+}
+
+void
+CCutsceneHead::CreateRwObject(void)
+{
+ RpAtomic *atm;
+
+ CEntity::CreateRwObject();
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ RpSkinAtomicSetHAnimHierarchy(atm, RpHAnimFrameGetHierarchy(GetFirstChild(RpClumpGetFrame((RpClump*)m_rwObject))));
+}
+
+void
+CCutsceneHead::DeleteRwObject(void)
+{
+ CEntity::DeleteRwObject();
+}
+
+void
+CCutsceneHead::ProcessControl(void)
+{
+ RpAtomic *atm;
+ RpHAnimHierarchy *hier;
+
+ CPhysical::ProcessControl();
+
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+ UpdateRwFrame();
+
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ hier = RpSkinAtomicGetHAnimHierarchy(atm);
+ RpHAnimHierarchyAddAnimTime(hier, CTimer::GetTimeStepNonClipped()/50.0f);
+}
+
+void
+CCutsceneHead::Render(void)
+{
+ RpAtomic *atm;
+
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+ UpdateRwFrame();
+
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ RpHAnimHierarchyUpdateMatrices(RpSkinAtomicGetHAnimHierarchy(atm));
+
+ CObject::Render();
+}
+
+void
+CCutsceneHead::PlayAnimation(const char *animName)
+{
+ RpAtomic *atm;
+ RpHAnimHierarchy *hier;
+ RpHAnimAnimation *anim;
+ uint32 offset, size;
+ RwStream *stream;
+
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ atm = GetFirstAtomic((RpClump*)m_rwObject);
+ hier = RpSkinAtomicGetHAnimHierarchy(atm);
+
+ sprintf(gString, "%s.anm", animName);
+
+ if(CCutsceneMgr::ms_pCutsceneDir->FindItem(gString, offset, size)){
+ stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "ANIM\\CUTS.IMG");
+ assert(stream);
+
+ CStreaming::MakeSpaceFor(size*2048);
+ CStreaming::ImGonnaUseStreamingMemory();
+
+ RwStreamSkip(stream, offset*2048);
+ if(RwStreamFindChunk(stream, rwID_HANIMANIMATION, nil, nil)){
+ anim = RpHAnimAnimationStreamRead(stream);
+ RpHAnimHierarchySetCurrentAnim(hier, anim);
+ }
+
+ CStreaming::IHaveUsedStreamingMemory();
+
+ RwStreamClose(stream, nil);
+ }
+}
+
+STARTPATCHES
+ InjectHook(0x4BA650, &CCutsceneHead::CreateRwObject_, PATCH_JUMP);
+ InjectHook(0x4BA690, &CCutsceneHead::DeleteRwObject_, PATCH_JUMP);
+ InjectHook(0x4BA760, &CCutsceneHead::ProcessControl_, PATCH_JUMP);
+ InjectHook(0x4BA800, &CCutsceneHead::Render_, PATCH_JUMP);
+ InjectHook(0x4BA6A0, &CCutsceneHead::PlayAnimation, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/entities/CutsceneHead.h b/src/entities/CutsceneHead.h
index 5784ffc9..de4f011f 100644
--- a/src/entities/CutsceneHead.h
+++ b/src/entities/CutsceneHead.h
@@ -6,5 +6,19 @@ class CCutsceneHead : public CCutsceneObject
{
public:
RwFrame *m_pHeadNode;
+
+ CCutsceneHead(CObject *obj);
+
+ void CreateRwObject(void);
+ void DeleteRwObject(void);
+ void ProcessControl(void);
+ void Render(void);
+
+ void PlayAnimation(const char *animName);
+
+ void CreateRwObject_(void) { CCutsceneHead::CreateRwObject(); }
+ void DeleteRwObject_(void) { CCutsceneHead::DeleteRwObject(); }
+ void ProcessControl_(void) { CCutsceneHead::ProcessControl(); }
+ void Render_(void) { CCutsceneHead::Render(); }
};
static_assert(sizeof(CCutsceneHead) == 0x19C, "CCutsceneHead: error");
diff --git a/src/entities/CutsceneObject.cpp b/src/entities/CutsceneObject.cpp
index 6aa0f4b3..d00a668b 100644
--- a/src/entities/CutsceneObject.cpp
+++ b/src/entities/CutsceneObject.cpp
@@ -1,2 +1,98 @@
#include "common.h"
+#include "patcher.h"
+#include "lights.h"
+#include "PointLights.h"
+#include "RpAnimBlend.h"
+#include "AnimBlendClumpData.h"
+#include "Renderer.h"
+#include "ModelIndices.h"
+#include "Shadows.h"
+#include "TimeCycle.h"
#include "CutsceneObject.h"
+
+CCutsceneObject::CCutsceneObject(void)
+{
+ m_status = STATUS_SIMPLE;
+ bUsesCollision = false;
+ m_flagC20 = true;
+ ObjectCreatedBy = CUTSCENE_OBJECT;
+ m_fMass = 1.0f;
+ m_fTurnMass = 1.0f;
+}
+
+void
+CCutsceneObject::SetModelIndex(uint32 id)
+{
+ CEntity::SetModelIndex(id);
+ assert(RwObjectGetType(m_rwObject) == rpCLUMP);
+ RpAnimBlendClumpInit((RpClump*)m_rwObject);
+ (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity = &m_vecMoveSpeed;
+ (*RPANIMBLENDCLUMPDATA(m_rwObject))->frames[0].flag |= AnimBlendFrameData::VELOCITY_EXTRACTION_3D;
+}
+
+void
+CCutsceneObject::ProcessControl(void)
+{
+ CPhysical::ProcessControl();
+
+ if(CTimer::GetTimeStep() < 1/100.0f)
+ m_vecMoveSpeed *= 100.0f;
+ else
+ m_vecMoveSpeed *= 1.0f/CTimer::GetTimeStep();
+
+ ApplyMoveSpeed();
+}
+
+void
+CCutsceneObject::PreRender(void)
+{
+ if(IsPedModel(GetModelIndex()))
+ CShadows::StoreShadowForPedObject(this,
+ CTimeCycle::m_fShadowDisplacementX[CTimeCycle::m_CurrentStoredValue],
+ CTimeCycle::m_fShadowDisplacementY[CTimeCycle::m_CurrentStoredValue],
+ CTimeCycle::m_fShadowFrontX[CTimeCycle::m_CurrentStoredValue],
+ CTimeCycle::m_fShadowFrontY[CTimeCycle::m_CurrentStoredValue],
+ CTimeCycle::m_fShadowSideX[CTimeCycle::m_CurrentStoredValue],
+ CTimeCycle::m_fShadowSideY[CTimeCycle::m_CurrentStoredValue]);
+}
+
+void
+CCutsceneObject::Render(void)
+{
+ CObject::Render();
+}
+
+bool
+CCutsceneObject::SetupLighting(void)
+{
+ ActivateDirectional();
+ SetAmbientColoursForPedsCarsAndObjects();
+
+ if(bRenderScorched){
+ WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
+ }else{
+ CVector coors = GetPosition();
+ float lighting = CPointLights::GenerateLightsAffectingObject(&coors);
+ if(!m_flagB20 && lighting != 1.0f){
+ SetAmbientAndDirectionalColours(lighting);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void
+CCutsceneObject::RemoveLighting(bool reset)
+{
+ CRenderer::RemoveVehiclePedLights(this, reset);
+}
+
+STARTPATCHES
+ InjectHook(0x4BA980, &CCutsceneObject::SetModelIndex_, PATCH_JUMP);
+ InjectHook(0x4BA9C0, &CCutsceneObject::ProcessControl_, PATCH_JUMP);
+ InjectHook(0x4BAA40, &CCutsceneObject::PreRender_, PATCH_JUMP);
+ InjectHook(0x4BAAA0, &CCutsceneObject::Render_, PATCH_JUMP);
+ InjectHook(0x4A7E70, &CCutsceneObject::SetupLighting_, PATCH_JUMP);
+ InjectHook(0x4A7F00, &CCutsceneObject::RemoveLighting_, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/entities/CutsceneObject.h b/src/entities/CutsceneObject.h
index c5cbf83f..182d8612 100644
--- a/src/entities/CutsceneObject.h
+++ b/src/entities/CutsceneObject.h
@@ -5,5 +5,21 @@
class CCutsceneObject : public CObject
{
public:
+ CCutsceneObject(void);
+
+ void SetModelIndex(uint32 id);
+ void ProcessControl(void);
+ void PreRender(void);
+ void Render(void);
+ bool SetupLighting(void);
+ void RemoveLighting(bool reset);
+
+
+ void SetModelIndex_(uint32 id) { CCutsceneObject::SetModelIndex(id); }
+ void ProcessControl_(void) { CCutsceneObject::ProcessControl(); }
+ void PreRender_(void) { CCutsceneObject::PreRender(); }
+ void Render_(void) { CCutsceneObject::Render(); }
+ bool SetupLighting_(void) { return CCutsceneObject::SetupLighting(); }
+ void RemoveLighting_(bool reset) { CCutsceneObject::RemoveLighting(reset); }
};
static_assert(sizeof(CCutsceneObject) == 0x198, "CCutsceneObject: error");
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index c4a5c467..73a2c668 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -82,7 +82,7 @@ public:
uint32 m_flagD10 : 1;
uint32 bDrawLast : 1;
uint32 m_flagD40 : 1;
- uint32 m_flagD80 : 1;
+ uint32 m_flagD80 : 1; // CObject visibility?
// flagsE
uint32 bDistanceFade : 1;
diff --git a/src/entities/Object.cpp b/src/entities/Object.cpp
index 8ce1250f..2b068d49 100644
--- a/src/entities/Object.cpp
+++ b/src/entities/Object.cpp
@@ -1,9 +1,68 @@
#include "common.h"
#include "patcher.h"
-#include "Object.h"
#include "Pools.h"
+#include "Radar.h"
+#include "Object.h"
+
+WRAPPER void CObject::ObjectDamage(float amount) { EAXJMP(0x4BB240); }
+
+int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2;
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); }
-WRAPPER void CObject::ObjectDamage(float amount) { EAXJMP(0x4BB240); }
+CObject::CObject(void)
+{
+ m_type = ENTITY_TYPE_OBJECT;
+ m_fUprootLimit = 0.0f;
+ m_nCollisionDamageEffect = 0;
+ m_bSpecialCollisionResponseCases = 0;
+ m_bCameraToAvoidThisObject = 0;
+ ObjectCreatedBy = 0;
+ m_nEndOfLifeTime = 0;
+// m_nRefModelIndex = -1; // duplicate
+// bUseVehicleColours = false; // duplicate
+ m_colour2 = 0;
+ m_colour1 = m_colour2;
+ field_172 = 0;
+ m_obj_flag1 = false;
+ 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();
+}
+
+STARTPATCHES
+ InjectHook(0x4BB1E0, &CObject::Render_, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/entities/Object.h b/src/entities/Object.h
index d71b155e..c9800e20 100644
--- a/src/entities/Object.h
+++ b/src/entities/Object.h
@@ -6,6 +6,7 @@ enum {
GAME_OBJECT = 1,
MISSION_OBJECT = 2,
TEMP_OBJECT = 3,
+ CUTSCENE_OBJECT = 4,
};
class CVehicle;
@@ -22,7 +23,7 @@ public:
int8 m_obj_flag8 : 1;
int8 m_obj_flag10 : 1;
int8 bHasBeenDamaged : 1;
- int8 m_obj_flag40 : 1;
+ int8 bUseVehicleColours : 1;
int8 m_obj_flag80 : 1;
int8 field_172;
int8 field_173;
@@ -43,9 +44,19 @@ public:
CEntity *m_pCollidingEntity;
int8 m_colour1, m_colour2;
+ static int16 &nNoTempObjects;
+
static void *operator new(size_t);
static void operator delete(void*, size_t);
+ CObject(void);
+ ~CObject(void);
+
+ void Render(void);
+
void ObjectDamage(float amount);
+
+
+ void Render_(void) { CObject::Render(); }
};
static_assert(sizeof(CObject) == 0x198, "CObject: error");
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 9cd36070..33e2deff 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -15,6 +15,60 @@
#include "Automobile.h"
#include "Physical.h"
+CPhysical::CPhysical(void)
+{
+ int i;
+
+ fForceMultiplier = 1.0f;
+ m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
+ m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
+ m_vecMoveFriction = CVector(0.0f, 0.0f, 0.0f);
+ m_vecTurnFriction = CVector(0.0f, 0.0f, 0.0f);
+ m_vecMoveSpeedAvg = CVector(0.0f, 0.0f, 0.0f);
+ m_vecTurnSpeedAvg = CVector(0.0f, 0.0f, 0.0f);
+
+ m_movingListNode = nil;
+ m_nStaticFrames = 0;
+
+ m_nCollisionRecords = 0;
+ for(i = 0; i < 6; i++)
+ m_aCollisionRecords[0] = nil;
+
+ field_EF = false;
+
+ m_nDamagePieceType = 0;
+ m_fDamageImpulse = 0.0f;
+ m_pDamageEntity = nil;
+ m_vecDamageNormal = CVector(0.0f, 0.0f, 0.0f);
+
+ bUsesCollision = true;
+ uAudioEntityId = -5;
+ unk1 = 100.0f;
+ m_vecCentreOfMass = CVector(0.0f, 0.0f, 0.0f);
+ field_EC = 0;
+
+ bIsHeavy = false;
+ bAffectedByGravity = true;
+ bInfiniteMass = false;
+ bIsInWater = false;
+ bHitByTrain = false;
+ m_phy_flagA80 = false;
+
+ m_fDistanceTravelled = 0.0f;
+ m_pedTreadable = nil;
+ m_carTreadable = nil;
+
+ m_phy_flagA10 = false;
+ m_phy_flagA20 = false;
+
+ m_nLastCollType = 0;
+}
+
+CPhysical::~CPhysical(void)
+{
+ m_entryInfoList.Flush();
+}
+
void
CPhysical::Add(void)
{
diff --git a/src/entities/Physical.h b/src/entities/Physical.h
index c6944b76..6b5bd1f6 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -62,6 +62,8 @@ public:
uint8 m_nZoneLevel;
uint8 pad[3];
+ CPhysical(void);
+ ~CPhysical(void);
// from CEntity
void Add(void);