summaryrefslogtreecommitdiffstats
path: root/src/objects
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/objects/CutsceneHead.cpp114
-rw-r--r--src/objects/CutsceneHead.h9
-rw-r--r--src/objects/CutsceneObject.cpp89
-rw-r--r--src/objects/CutsceneObject.h16
-rw-r--r--src/objects/DummyObject.cpp18
-rw-r--r--src/objects/Object.cpp50
-rw-r--r--src/objects/Object.h15
-rw-r--r--src/objects/ObjectData.cpp7
-rw-r--r--src/objects/ParticleObject.cpp194
-rw-r--r--src/objects/ParticleObject.h15
-rw-r--r--src/objects/Projectile.cpp16
11 files changed, 354 insertions, 189 deletions
diff --git a/src/objects/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp
index a7722b8a..3ef257d2 100644
--- a/src/objects/CutsceneHead.cpp
+++ b/src/objects/CutsceneHead.cpp
@@ -1,10 +1,11 @@
#include "common.h"
#include <rpskin.h>
-#include "patcher.h"
+
#include "main.h"
#include "RwHelper.h"
#include "RpAnimBlend.h"
#include "AnimBlendClumpData.h"
+#include "Bones.h"
#include "Directory.h"
#include "CutsceneMgr.h"
#include "Streaming.h"
@@ -17,11 +18,23 @@ 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((RwObject*)atm) == rpATOMIC);
- RpAtomicSetFlags(atm, RpAtomicGetFlags(atm) & ~rpATOMICRENDER);
+#ifdef PED_SKIN
+ unk1 = 0;
+ bIsSkinned = false;
+ m_parentObject = (CCutsceneObject*)obj;
+ // Hide original head
+ if(IsClumpSkinned(obj->GetClump())){
+ m_parentObject->SetRenderHead(false);
+ bIsSkinned = true;
+ }else
+#endif
+ {
+ m_pHeadNode = RpAnimBlendClumpFindFrame((RpClump*)obj->m_rwObject, "Shead")->frame;
+ atm = (RpAtomic*)GetFirstObject(m_pHeadNode);
+ if(atm){
+ assert(RwObjectGetType((RwObject*)atm) == rpATOMIC);
+ RpAtomicSetFlags(atm, RpAtomicGetFlags(atm) & ~rpATOMICRENDER);
+ }
}
}
@@ -48,11 +61,28 @@ CCutsceneHead::ProcessControl(void)
RpAtomic *atm;
RpHAnimHierarchy *hier;
+ // android/xbox calls is at the end
CPhysical::ProcessControl();
- m_matrix.SetRotateY(PI/2);
- m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
- UpdateRwFrame();
+#ifdef PED_SKIN
+ if(bIsSkinned){
+ UpdateRpHAnim();
+ UpdateRwFrame();
+
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump());
+ int idx = RpHAnimIDGetIndex(hier, BONE_head);
+ RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
+ if(RwV3dLength(&mat->pos) > 100.0f){
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(mat) * m_matrix;
+ }
+ }else
+#endif
+ {
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+ UpdateRwFrame(); // android/xbox don't call this
+ }
assert(RwObjectGetType(m_rwObject) == rpCLUMP);
atm = GetFirstAtomic((RpClump*)m_rwObject);
@@ -65,8 +95,25 @@ CCutsceneHead::Render(void)
{
RpAtomic *atm;
- m_matrix.SetRotateY(PI/2);
- m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+#ifdef PED_SKIN
+ if(bIsSkinned){
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump());
+ RpHAnimHierarchyUpdateMatrices(hier);
+ int idx = RpHAnimIDGetIndex(hier, BONE_head);
+ RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
+ if(RwV3dLength(&mat->pos) > 100.0f){
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(mat) * m_matrix;
+ }
+ RenderLimb(BONE_Lhand);
+ RenderLimb(BONE_Rhand);
+ }else
+#endif
+ {
+ m_matrix.SetRotateY(PI/2);
+ m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix;
+ }
+
UpdateRwFrame();
assert(RwObjectGetType(m_rwObject) == rpCLUMP);
@@ -76,6 +123,34 @@ CCutsceneHead::Render(void)
CObject::Render();
}
+#ifdef PED_SKIN
+void
+CCutsceneHead::RenderLimb(int32 bone)
+{
+ RpAtomic *atomic;
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(m_parentObject->GetClump());
+ int idx = RpHAnimIDGetIndex(hier, bone);
+ RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
+ CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ switch(bone){
+ case BONE_Lhand:
+ atomic = mi->getLeftHand();
+ break;
+ case BONE_Rhand:
+ atomic = mi->getRightHand();
+ break;
+ default:
+ return;
+ }
+ if(atomic){
+ RwFrame *frame = RpAtomicGetFrame(atomic);
+ RwMatrixTransform(RwFrameGetMatrix(frame), &mats[idx], rwCOMBINEREPLACE);
+ RwFrameUpdateObjects(frame);
+ RpAtomicRender(atomic);
+ }
+}
+#endif
+
void
CCutsceneHead::PlayAnimation(const char *animName)
{
@@ -109,20 +184,3 @@ CCutsceneHead::PlayAnimation(const char *animName)
RwStreamClose(stream, nil);
}
}
-
-class CCutsceneHead_ : public CCutsceneHead
-{
-public:
- void CreateRwObject_(void) { CCutsceneHead::CreateRwObject(); }
- void DeleteRwObject_(void) { CCutsceneHead::DeleteRwObject(); }
- void ProcessControl_(void) { CCutsceneHead::ProcessControl(); }
- void Render_(void) { CCutsceneHead::Render(); }
-};
-
-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/objects/CutsceneHead.h b/src/objects/CutsceneHead.h
index 52b66ede..0a70353d 100644
--- a/src/objects/CutsceneHead.h
+++ b/src/objects/CutsceneHead.h
@@ -6,6 +6,12 @@ class CCutsceneHead : public CCutsceneObject
{
public:
RwFrame *m_pHeadNode;
+#ifdef PED_SKIN
+ int32 unk1;
+ CCutsceneObject *m_parentObject;
+ int32 unk2;
+ int32 bIsSkinned;
+#endif
CCutsceneHead(CObject *obj);
@@ -13,7 +19,10 @@ public:
void DeleteRwObject(void);
void ProcessControl(void);
void Render(void);
+ void RenderLimb(int32 bone);
void PlayAnimation(const char *animName);
};
+#ifndef PED_SKIN
static_assert(sizeof(CCutsceneHead) == 0x19C, "CCutsceneHead: error");
+#endif
diff --git a/src/objects/CutsceneObject.cpp b/src/objects/CutsceneObject.cpp
index 2f667a5d..7b4ae02b 100644
--- a/src/objects/CutsceneObject.cpp
+++ b/src/objects/CutsceneObject.cpp
@@ -1,10 +1,12 @@
#include "common.h"
-#include "patcher.h"
+
#include "main.h"
+#include "RwHelper.h"
#include "Lights.h"
#include "PointLights.h"
#include "RpAnimBlend.h"
#include "AnimBlendClumpData.h"
+#include "Bones.h"
#include "Renderer.h"
#include "ModelIndices.h"
#include "Shadows.h"
@@ -19,6 +21,12 @@ CCutsceneObject::CCutsceneObject(void)
ObjectCreatedBy = CUTSCENE_OBJECT;
m_fMass = 1.0f;
m_fTurnMass = 1.0f;
+
+#ifdef PED_SKIN
+ bRenderHead = true;
+ bRenderRightHand = true;
+ bRenderLeftHand = true;
+#endif
}
void
@@ -42,12 +50,24 @@ CCutsceneObject::ProcessControl(void)
m_vecMoveSpeed *= 1.0f/CTimer::GetTimeStep();
ApplyMoveSpeed();
+
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump()))
+ UpdateRpHAnim();
+#endif
+}
+
+static RpMaterial*
+MaterialSetAlpha(RpMaterial *material, void *data)
+{
+ ((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uintptr)data;
+ return material;
}
void
CCutsceneObject::PreRender(void)
{
- if(IsPedModel(GetModelIndex()))
+ if(IsPedModel(GetModelIndex())){
CShadows::StoreShadowForPedObject(this,
CTimeCycle::m_fShadowDisplacementX[CTimeCycle::m_CurrentStoredValue],
CTimeCycle::m_fShadowDisplacementY[CTimeCycle::m_CurrentStoredValue],
@@ -55,14 +75,57 @@ CCutsceneObject::PreRender(void)
CTimeCycle::m_fShadowFrontY[CTimeCycle::m_CurrentStoredValue],
CTimeCycle::m_fShadowSideX[CTimeCycle::m_CurrentStoredValue],
CTimeCycle::m_fShadowSideY[CTimeCycle::m_CurrentStoredValue]);
+ // For some reason xbox/android limbs are transparent here...
+ RpGeometry *geometry = RpAtomicGetGeometry(GetFirstAtomic(GetClump()));
+ RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR);
+ RpGeometryForAllMaterials(geometry, MaterialSetAlpha, (void*)255);
+ }
}
void
CCutsceneObject::Render(void)
{
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+ if(bRenderLeftHand) RenderLimb(BONE_Lhand);
+ if(bRenderRightHand) RenderLimb(BONE_Rhand);
+ if(bRenderHead) RenderLimb(BONE_head);
+ }
+#endif
CObject::Render();
}
+#ifdef PED_SKIN
+void
+CCutsceneObject::RenderLimb(int32 bone)
+{
+ RpAtomic *atomic;
+ CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ switch(bone){
+ case BONE_head:
+ atomic = mi->getHead();
+ break;
+ case BONE_Lhand:
+ atomic = mi->getLeftHand();
+ break;
+ case BONE_Rhand:
+ atomic = mi->getRightHand();
+ break;
+ default:
+ return;
+ }
+ if(atomic){
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ int idx = RpHAnimIDGetIndex(hier, bone);
+ RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
+ RwFrame *frame = RpAtomicGetFrame(atomic);
+ *RwFrameGetMatrix(frame) = *mat;
+ RwFrameUpdateObjects(frame);
+ RpAtomicRender(atomic);
+ }
+}
+#endif
+
bool
CCutsceneObject::SetupLighting(void)
{
@@ -88,25 +151,3 @@ CCutsceneObject::RemoveLighting(bool reset)
{
CRenderer::RemoveVehiclePedLights(this, reset);
}
-
-class CCutsceneObject_ : public CCutsceneObject
-{
-public:
- void dtor(void) { this->CCutsceneObject::~CCutsceneObject(); }
- 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); }
-};
-
-STARTPATCHES
- InjectHook(0x4BA960, &CCutsceneObject_::dtor, PATCH_JUMP);
- 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/objects/CutsceneObject.h b/src/objects/CutsceneObject.h
index 31c3a528..9c4036bf 100644
--- a/src/objects/CutsceneObject.h
+++ b/src/objects/CutsceneObject.h
@@ -5,13 +5,29 @@
class CCutsceneObject : public CObject
{
public:
+#ifdef PED_SKIN
+ bool bRenderHead;
+ bool bRenderRightHand;
+ bool bRenderLeftHand;
+
+ bool GetRenderHead(void) { return bRenderHead; }
+ bool GetRenderRightHand(void) { return bRenderRightHand; }
+ bool GetRenderLeftHand(void) { return bRenderLeftHand; }
+ void SetRenderHead(bool render) { bRenderHead = render; }
+ void SetRenderRightHand(bool render) { bRenderRightHand = render; }
+ void SetRenderLeftHand(bool render) { bRenderLeftHand = render; }
+#endif
+
CCutsceneObject(void);
void SetModelIndex(uint32 id);
void ProcessControl(void);
void PreRender(void);
void Render(void);
+ void RenderLimb(int32 bone);
bool SetupLighting(void);
void RemoveLighting(bool reset);
};
+#ifndef PED_SKIN
static_assert(sizeof(CCutsceneObject) == 0x198, "CCutsceneObject: error");
+#endif
diff --git a/src/objects/DummyObject.cpp b/src/objects/DummyObject.cpp
index ba09ac3e..d5805073 100644
--- a/src/objects/DummyObject.cpp
+++ b/src/objects/DummyObject.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "DummyObject.h"
#include "Pools.h"
@@ -11,19 +11,3 @@ CDummyObject::CDummyObject(CObject *obj)
obj->DetachFromRwObject();
m_level = obj->m_level;
}
-
-#include <new>
-
-class CDummyObject_ : public CDummyObject
-{
-public:
- void dtor(void) { CDummyObject::~CDummyObject(); }
- CDummyObject *ctor(void) { return ::new (this) CDummyObject(); }
- CDummyObject *ctor(CObject *obj) { return ::new (this) CDummyObject(obj); }
-};
-
-STARTPATCHES
- InjectHook(0x4BAAF0, (CDummyObject* (CDummyObject::*)(void)) &CDummyObject_::ctor, PATCH_JUMP);
- InjectHook(0x4BAB10, (CDummyObject* (CDummyObject::*)(CObject*)) &CDummyObject_::ctor, PATCH_JUMP);
- InjectHook(0x4BAB70, &CDummyObject_::dtor, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp
index 867624c7..c0ce38f8 100644
--- a/src/objects/Object.cpp
+++ b/src/objects/Object.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "main.h"
#include "Lights.h"
#include "Pools.h"
@@ -12,8 +12,8 @@
#include "World.h"
#include "Floater.h"
-int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2;
-int16 &CObject::nBodyCastHealth = *(int16*)0x5F7D4C; // 1000
+int16 CObject::nNoTempObjects;
+int16 CObject::nBodyCastHealth = 1000;
void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); }
void *CObject::operator new(size_t sz, int handle) { return CPools::GetObjectPool()->New(handle);};
@@ -35,7 +35,7 @@ CObject::CObject(void)
m_colour1 = m_colour2;
m_nBonusValue = 0;
bIsPickup = false;
- m_obj_flag2 = false;
+ bPickupObjWithMessage = false;
bOutOfStock = false;
bGlassCracked = false;
bGlassBroken = false;
@@ -214,7 +214,7 @@ CObject::ObjectDamage(float amount)
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
float fRandom = CGeneral::GetRandomNumberInRange(0.01f, 1.0f);
- RwRGBA randomColor = { color.red * fRandom, color.green * fRandom , color.blue, color.alpha };
+ RwRGBA randomColor = { uint8(color.red * fRandom), uint8(color.green * fRandom) , color.blue, color.alpha };
float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0);
@@ -237,7 +237,7 @@ CObject::ObjectDamage(float amount)
++nFrameGen;
int32 currentFrame = nFrameGen & 3;
float fRandom = CGeneral::GetRandomNumberInRange(0.5f, 0.5f);
- RwRGBA randomColor = { color.red * fRandom, color.green * fRandom , color.blue * fRandom, color.alpha };
+ RwRGBA randomColor = { uint8(color.red * fRandom), uint8(color.green * fRandom), uint8(color.blue * fRandom), color.alpha };
float fSize = CGeneral::GetRandomNumberInRange(0.02f, 0.18f);
int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80);
CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0);
@@ -315,7 +315,7 @@ CObject::Init(void)
ObjectCreatedBy = GAME_OBJECT;
bIsStatic = true;
bIsPickup = false;
- m_obj_flag2 = false;
+ bPickupObjWithMessage = false;
bOutOfStock = false;
bGlassCracked = false;
bGlassBroken = false;
@@ -383,7 +383,7 @@ CObject::DeleteAllTempObjects()
}
void
-CObject::DeleteAllTempObjectInArea(CVector point, float fRadius)
+CObject::DeleteAllTempObjectsInArea(CVector point, float fRadius)
{
CObjectPool *objectPool = CPools::GetObjectPool();
for (int32 i = 0; i < objectPool->GetSize(); i++) {
@@ -394,37 +394,3 @@ CObject::DeleteAllTempObjectInArea(CVector point, float fRadius)
}
}
}
-
-#include <new>
-
-class CObject_ : public CObject
-{
-public:
- CObject *ctor(void) { return ::new (this) CObject(); }
- CObject *ctor(int32 mi, bool createRW) { return ::new (this) CObject(mi, createRW); }
- CObject *ctor(CDummyObject *dummy) { return ::new (this) CObject(dummy); }
- void dtor(void) { CObject::~CObject(); }
- void Render_(void) { CObject::Render(); }
- void ProcessControl_(void) { CObject::ProcessControl(); }
- bool SetupLighting_(void) { return CObject::SetupLighting(); }
- void RemoveLighting_(bool reset) { CObject::RemoveLighting(reset); }
-};
-
-STARTPATCHES
- InjectHook(0x4BABD0, (CObject* (CObject::*)(void)) &CObject_::ctor, PATCH_JUMP);
- InjectHook(0x4BACE0, (CObject* (CObject::*)(int32, bool)) &CObject_::ctor, PATCH_JUMP);
- InjectHook(0x4BAD50, (CObject* (CObject::*)(CDummyObject*)) &CObject_::ctor, PATCH_JUMP);
- InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP);
- InjectHook(0x4BB040, &CObject_::ProcessControl_, PATCH_JUMP);
- InjectHook(0x4BBDA0, &CObject::Teleport, PATCH_JUMP);
- InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP);
- InjectHook(0x4A7C90, &CObject_::SetupLighting_, PATCH_JUMP);
- InjectHook(0x4A7CD0, &CObject_::RemoveLighting_, PATCH_JUMP);
- InjectHook(0x4BB240, &CObject::ObjectDamage, PATCH_JUMP);
- InjectHook(0x4BBD80, &CObject::RefModelInfo, PATCH_JUMP);
- InjectHook(0x4BAEC0, &CObject::Init, PATCH_JUMP);
- InjectHook(0x4BB010, &CObject::CanBeDeleted, PATCH_JUMP);
- InjectHook(0x4BBE60, &CObject::DeleteAllMissionObjects, PATCH_JUMP);
- InjectHook(0x4BBDF0, &CObject::DeleteAllTempObjects, PATCH_JUMP);
- InjectHook(0x4BBED0, &CObject::DeleteAllTempObjectInArea, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/objects/Object.h b/src/objects/Object.h
index 6d04c78a..319ec4bc 100644
--- a/src/objects/Object.h
+++ b/src/objects/Object.h
@@ -47,34 +47,33 @@ public:
float m_fUprootLimit;
int8 ObjectCreatedBy;
int8 bIsPickup : 1;
- int8 m_obj_flag2 : 1;
+ int8 bPickupObjWithMessage : 1;
int8 bOutOfStock : 1;
int8 bGlassCracked : 1;
int8 bGlassBroken : 1;
int8 bHasBeenDamaged : 1;
int8 bUseVehicleColours : 1;
- int8 m_obj_flag80 : 1;
int8 m_nBonusValue;
- int8 field_173;
float m_fCollisionDamageMultiplier;
uint8 m_nCollisionDamageEffect;
uint8 m_nSpecialCollisionResponseCases;
bool m_bCameraToAvoidThisObject;
+
+ // this batch is unused
int8 field_17B;
int8 field_17C;
int8 field_17D;
int8 field_17E;
int8 field_17F;
+
uint32 m_nEndOfLifeTime;
int16 m_nRefModelIndex;
- int8 field_186;
- int8 field_187;
CEntity *m_pCurSurface;
CEntity *m_pCollidingEntity;
int8 m_colour1, m_colour2;
- static int16 &nNoTempObjects;
- static int16 &nBodyCastHealth;
+ static int16 nNoTempObjects;
+ static int16 nBodyCastHealth;
static void *operator new(size_t);
static void *operator new(size_t, int);
@@ -99,6 +98,6 @@ public:
static void DeleteAllMissionObjects();
static void DeleteAllTempObjects();
- static void DeleteAllTempObjectInArea(CVector point, float fRadius);
+ static void DeleteAllTempObjectsInArea(CVector point, float fRadius);
};
static_assert(sizeof(CObject) == 0x198, "CObject: error");
diff --git a/src/objects/ObjectData.cpp b/src/objects/ObjectData.cpp
index aa58a845..589cc3f7 100644
--- a/src/objects/ObjectData.cpp
+++ b/src/objects/ObjectData.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "main.h"
#include "ModelInfo.h"
#include "Object.h"
@@ -96,8 +96,3 @@ CObjectData::SetObjectData(int32 modelId, CObject &object)
object.bExplosionProof = true;
}
}
-
-STARTPATCHES
- InjectHook(0x4BC0E0, CObjectData::Initialise, PATCH_JUMP);
- InjectHook(0x4BC270, CObjectData::SetObjectData, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/objects/ParticleObject.cpp b/src/objects/ParticleObject.cpp
index 60827411..932a0b8a 100644
--- a/src/objects/ParticleObject.cpp
+++ b/src/objects/ParticleObject.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "ParticleObject.h"
#include "Timer.h"
#include "General.h"
@@ -9,11 +9,11 @@
#include "Game.h"
-CParticleObject (&gPObjectArray)[MAX_PARTICLEOBJECTS] = *(CParticleObject(*)[MAX_PARTICLEOBJECTS])*(uintptr*)0x62A58C;
+CParticleObject gPObjectArray[MAX_PARTICLEOBJECTS];
-CParticleObject *&CParticleObject::pCloseListHead = *(CParticleObject **)int(0x8F4340);
-CParticleObject *&CParticleObject::pFarListHead = *(CParticleObject **)int(0x942F78);
-CParticleObject *&CParticleObject::pUnusedListHead = *(CParticleObject **)int(0x94128C);
+CParticleObject *CParticleObject::pCloseListHead;
+CParticleObject *CParticleObject::pFarListHead;
+CParticleObject *CParticleObject::pUnusedListHead;
CAudioHydrant List[MAX_AUDIOHYDRANTS];
@@ -169,7 +169,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_STEAM_NY;
pobj->m_nNumEffectCycles = 1;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 3;
+#else
+ pobj->m_nSkipFrames = 1;
+#endif
pobj->m_nCreationChance = 8;
break;
}
@@ -187,7 +191,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_STEAM_NY;
pobj->m_nNumEffectCycles = 1;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 3;
+#else
+ pobj->m_nSkipFrames = 1;
+#endif
pobj->m_nCreationChance = 8;
break;
}
@@ -205,7 +213,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_STEAM_NY;
pobj->m_nNumEffectCycles = 1;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 3;
+#else
+ pobj->m_nSkipFrames = 1;
+#endif
pobj->m_nCreationChance = 8;
pobj->m_Color = CRGBA(16, 16, 16, 255);
break;
@@ -228,7 +240,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_CAR_SPLASH;
pobj->m_nNumEffectCycles = 0;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 1;
+#else
+ pobj->m_nSkipFrames = 3;
+#endif
pobj->m_nCreationChance = 0;
break;
}
@@ -236,7 +252,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
case POBJECT_SPLASHES_AROUND:
{
pobj->m_ParticleType = PARTICLE_SPLASH;
+#ifdef PC_PARTICLE
pobj->m_nNumEffectCycles = 15;
+#else
+ pobj->m_nNumEffectCycles = 30;
+#endif
pobj->m_nSkipFrames = 2;
pobj->m_nCreationChance = 0;
break;
@@ -246,7 +266,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_FLAME;
pobj->m_nNumEffectCycles = 1;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 2;
+#else
+ pobj->m_nSkipFrames = 1;
+#endif
pobj->m_nCreationChance = 2;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f);
break;
@@ -256,7 +280,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_FLAME;
pobj->m_nNumEffectCycles = 1;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 2;
+#else
+ pobj->m_nSkipFrames = 1;
+#endif
pobj->m_nCreationChance = 4;
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f);
break;
@@ -286,7 +314,11 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
{
pobj->m_ParticleType = PARTICLE_EXPLOSION_MEDIUM;
pobj->m_nNumEffectCycles = 1;
+#ifdef PC_PARTICLE
pobj->m_nSkipFrames = 3;
+#else
+ pobj->m_nSkipFrames = 1;
+#endif
pobj->m_nCreationChance = 2;
pobj->m_fRandVal = 0.01f;
break;
@@ -598,6 +630,7 @@ void CParticleObject::UpdateClose(void)
case POBJECT_PED_WATER_SPLASH:
{
+#ifdef PC_PARTICLE
CRGBA colorsmoke(255, 255, 255, 196);
CVector pos = this->GetPosition();
@@ -699,12 +732,69 @@ void CParticleObject::UpdateClose(void)
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL,
CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color);
}
+#else
+ CVector pos;
+ CVector vel;
+
+ for ( int32 i = -2; i < 2; i++ )
+ {
+ pos = this->GetPosition();
+ pos += CVector(-0.75f, 0.5f * float(i), 0.0f);
+
+ vel = this->m_vecTarget;
+ vel.x += -1.5 * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color);
+
+ pos = this->GetPosition();
+ pos += CVector(0.75f, 0.5f * float(i), 0.0f);
+
+ vel = this->m_vecTarget;
+ vel.x += 1.5f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color);
+
+ pos = this->GetPosition();
+ pos += CVector(0.5f * float(i), -0.75, 0.0f);
+
+ vel = this->m_vecTarget;
+ vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += -1.5f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color);
+
+
+ pos = this->GetPosition();
+ pos += CVector(0.5f * float(i), 0.75, 0.0f);
+
+ vel = this->m_vecTarget;
+ vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += 1.5f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color);
+ }
+
+ for ( int32 i = 0; i < 4; i++ )
+ {
+ pos = this->GetPosition();
+
+ pos.x += CGeneral::GetRandomNumberInRange(-1.5f, 1.5f);
+ pos.y += CGeneral::GetRandomNumberInRange(-1.5f, 1.5f);
+ pos.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+
+ vel = this->m_vecTarget;
+ CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color);
+ }
+#endif
break;
}
case POBJECT_CAR_WATER_SPLASH:
{
+#ifdef PC_PARTICLE
CRGBA colorsmoke(255, 255, 255, 196);
CVector pos = this->GetPosition();
@@ -799,7 +889,65 @@ void CParticleObject::UpdateClose(void)
splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f);
CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color);
}
+#else
+ CVector pos;
+ CVector vel;
+
+ for ( int32 i = -3; i < 4; i++ )
+ {
+ pos = this->GetPosition();
+ pos += CVector(-1.5f, 0.5f * float(i), 0.0f);
+
+
+ vel = this->m_vecTarget;
+ vel.x += -3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color);
+
+
+ pos = this->GetPosition();
+ pos += CVector(1.5f, 0.5f * float(i), 0.0f);
+
+ vel = this->m_vecTarget;
+ vel.x += 3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color);
+
+
+ pos = this->GetPosition();
+ pos += CVector(0.5f * float(i), -1.5f, 0.0f);
+
+ vel = this->m_vecTarget;
+ vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += -3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color);
+
+
+ pos = this->GetPosition();
+ pos += CVector(0.5f * float(i), 1.5f, 0.0f);
+
+
+ vel = this->m_vecTarget;
+ vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.y += 3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f);
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color);
+ }
+ for ( int32 i = 0; i < 8; i++ )
+ {
+ pos = this->GetPosition();
+ pos.x += CGeneral::GetRandomNumberInRange(-3.0f, 3.0f);
+ pos.y += CGeneral::GetRandomNumberInRange(-3.0f, 3.0f);
+
+ vel = this->m_vecTarget;
+ vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f);
+ CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color);
+ }
+#endif
break;
}
@@ -1099,39 +1247,3 @@ CParticleObject::MoveToList(CParticleObject **from, CParticleObject **to, CParti
if ( obj->m_pNext )
obj->m_pNext->m_pPrev = obj;
}
-
-class CParticleObject_ : public CParticleObject
-{
-public:
- void ctor() { CParticleObject::CParticleObject(); }
- void dtor() { CParticleObject::~CParticleObject(); }
-};
-
-STARTPATCHES
- InjectHook(0x4BC330, CAudioHydrant::Add, PATCH_JUMP);
- InjectHook(0x4BC390, CAudioHydrant::Remove, PATCH_JUMP);
-
- InjectHook(0x4BC3E0, &CParticleObject_::ctor, PATCH_JUMP);
- InjectHook(0x4BC420, &CParticleObject_::dtor, PATCH_JUMP);
- InjectHook(0x4BC440, CParticleObject::Initialise, PATCH_JUMP);
-
- InjectHook(0x4BC4D0, (CParticleObject *(*)(uint16, CVector const &, uint8))CParticleObject::AddObject, PATCH_JUMP);
- InjectHook(0x4BC520, (CParticleObject *(*)(uint16, CVector const &, float, uint8))CParticleObject::AddObject, PATCH_JUMP);
- InjectHook(0x4BC570, (CParticleObject *(*)(uint16, CVector const &, CVector const &, float, uint8))CParticleObject::AddObject, PATCH_JUMP);
- InjectHook(0x4BC5B0, (CParticleObject *(*)(uint16, CVector const &, CVector const &, float, uint32, RwRGBA const &, uint8))CParticleObject::AddObject, PATCH_JUMP);
-
- InjectHook(0x4BC9F0, &CParticleObject::RemoveObject, PATCH_JUMP);
- InjectHook(0x4BCA30, CParticleObject::UpdateAll, PATCH_JUMP);
- InjectHook(0x4BCA80, &CParticleObject::UpdateClose, PATCH_JUMP);
- InjectHook(0x4BF9F0, &CParticleObject::UpdateFar, PATCH_JUMP);
- InjectHook(0x4BFA80, CParticleObject::SaveParticle, PATCH_JUMP);
- InjectHook(0x4BFB30, CParticleObject::LoadParticle, PATCH_JUMP);
- InjectHook(0x4BFC80, CParticleObject::RemoveAllParticleObjects, PATCH_JUMP);
- InjectHook(0x4BFD10, CParticleObject::MoveToList, PATCH_JUMP);
- //InjectHook(0x4BFD70, CParticleObject::~CParticleObject, PATCH_JUMP); // virtual
- //InjectHook(0x4BFDB0, `global constructor keyed to'ParticleObject.cpp, PATCH_JUMP);
- //InjectHook(0x4BFE00, CAudioHydrant::CAudioHydrant, PATCH_JUMP);
- //InjectHook(0x4BFE10, sub_4BFE10, PATCH_JUMP); // destroy gPObjectArray array
-
-
-ENDPATCHES
diff --git a/src/objects/ParticleObject.h b/src/objects/ParticleObject.h
index 45a3fa30..34a672bb 100644
--- a/src/objects/ParticleObject.h
+++ b/src/objects/ParticleObject.h
@@ -1,6 +1,8 @@
#pragma once
-#include "Placeable.h"
+
#include "AudioManager.h"
+#include "ParticleType.h"
+#include "Placeable.h"
#define MAX_PARTICLEOBJECTS 100
#define MAX_AUDIOHYDRANTS 8
@@ -37,7 +39,6 @@ enum eParticleObjectState
POBJECTSTATE_FREE,
};
-enum tParticleType;
class CParticle;
class CParticleObject : public CPlaceable
@@ -53,18 +54,16 @@ public:
uint8 m_nSkipFrames;
uint16 m_nFrameCounter;
uint16 m_nState;
- char _pad0[2];
CVector m_vecTarget;
float m_fRandVal;
float m_fSize;
CRGBA m_Color;
uint8 m_bRemove;
int8 m_nCreationChance;
- char _pad1[2];
- static CParticleObject *&pCloseListHead;
- static CParticleObject *&pFarListHead;
- static CParticleObject *&pUnusedListHead;
+ static CParticleObject *pCloseListHead;
+ static CParticleObject *pFarListHead;
+ static CParticleObject *pUnusedListHead;
CParticleObject();
~CParticleObject();
@@ -89,7 +88,7 @@ public:
static void MoveToList(CParticleObject **from, CParticleObject **to, CParticleObject *obj);
};
-extern CParticleObject (&gPObjectArray)[MAX_PARTICLEOBJECTS];
+extern CParticleObject gPObjectArray[MAX_PARTICLEOBJECTS];
class CAudioHydrant
{
diff --git a/src/objects/Projectile.cpp b/src/objects/Projectile.cpp
index 32bc6bdb..fe8b0c68 100644
--- a/src/objects/Projectile.cpp
+++ b/src/objects/Projectile.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "Projectile.h"
CProjectile::CProjectile(int32 model) : CObject()
@@ -13,17 +13,3 @@ CProjectile::CProjectile(int32 model) : CObject()
SetModelIndex(model);
ObjectCreatedBy = MISSION_OBJECT;
}
-
-#include <new>
-
-class CProjectile_ : public CProjectile
-{
-public:
- CProjectile* ctor(int32 model) { return ::new (this) CProjectile(model); }
- void dtor(void) { CProjectile::~CProjectile(); }
-};
-
-STARTPATCHES
- InjectHook(0x4BFE30, &CProjectile_::ctor, PATCH_JUMP);
- InjectHook(0x4BFED0, &CProjectile_::dtor, PATCH_JUMP);
-ENDPATCHES