summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-06-29 11:09:33 +0200
committeraap <aap@papnet.eu>2019-06-29 11:09:33 +0200
commitb2f8c7eb23f9def86acb84ba2936041ded0db748 (patch)
treedf7bda7922a10f05de1ca758a3fa463786ed28ea /src/entities
parentforgot the actual file... (diff)
downloadre3-b2f8c7eb23f9def86acb84ba2936041ded0db748.tar
re3-b2f8c7eb23f9def86acb84ba2936041ded0db748.tar.gz
re3-b2f8c7eb23f9def86acb84ba2936041ded0db748.tar.bz2
re3-b2f8c7eb23f9def86acb84ba2936041ded0db748.tar.lz
re3-b2f8c7eb23f9def86acb84ba2936041ded0db748.tar.xz
re3-b2f8c7eb23f9def86acb84ba2936041ded0db748.tar.zst
re3-b2f8c7eb23f9def86acb84ba2936041ded0db748.zip
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/Dummy.cpp52
-rw-r--r--src/entities/Dummy.h7
-rw-r--r--src/entities/Ped.cpp24
-rw-r--r--src/entities/Physical.cpp2
-rw-r--r--src/entities/Physical.h7
-rw-r--r--src/entities/PlayerInfo.h20
6 files changed, 81 insertions, 31 deletions
diff --git a/src/entities/Dummy.cpp b/src/entities/Dummy.cpp
index a4880175..68b67b5c 100644
--- a/src/entities/Dummy.cpp
+++ b/src/entities/Dummy.cpp
@@ -1,7 +1,57 @@
#include "common.h"
#include "patcher.h"
-#include "Dummy.h"
#include "Pools.h"
+#include "World.h"
+#include "Dummy.h"
void *CDummy::operator new(size_t sz) { return CPools::GetDummyPool()->New(); }
void CDummy::operator delete(void *p, size_t sz) { CPools::GetDummyPool()->Delete((CDummy*)p); }
+
+void
+CDummy::Add(void)
+{
+ int x, xstart, xmid, xend;
+ int y, ystart, ymid, yend;
+ CSector *s;
+ CPtrList *list;
+
+ CRect bounds = GetBoundRect();
+ xstart = CWorld::GetSectorIndexX(bounds.left);
+ xend = CWorld::GetSectorIndexX(bounds.right);
+ xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f);
+ ystart = CWorld::GetSectorIndexY(bounds.top);
+ yend = CWorld::GetSectorIndexY(bounds.bottom);
+ ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f);
+ assert(xstart >= 0);
+ assert(xend < NUMSECTORS_X);
+ assert(ystart >= 0);
+ assert(yend < NUMSECTORS_Y);
+
+ for(y = ystart; y <= yend; y++)
+ for(x = xstart; x <= xend; x++){
+ s = CWorld::GetSector(x, y);
+ if(x == xmid && y == ymid)
+ list = &s->m_lists[ENTITYLIST_OBJECTS];
+ else
+ list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP];
+ CPtrNode *node = list->InsertItem(this);
+ assert(node);
+ m_entryInfoList.InsertItem(list, node, s);
+ }
+}
+
+void
+CDummy::Remove(void)
+{
+ CEntryInfoNode *node, *next;
+ for(node = m_entryInfoList.first; node; node = next){
+ next = node->next;
+ node->list->DeleteNode(node->listnode);
+ m_entryInfoList.DeleteNode(node);
+ }
+}
+
+STARTPATCHES
+ InjectHook(0x473860, &CDummy::Add_, PATCH_JUMP);
+ InjectHook(0x473AD0, &CDummy::Remove_, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/entities/Dummy.h b/src/entities/Dummy.h
index 034d4c57..4cfef2e2 100644
--- a/src/entities/Dummy.h
+++ b/src/entities/Dummy.h
@@ -9,9 +9,14 @@ public:
CEntryInfoList m_entryInfoList;
CDummy(void) { m_type = ENTITY_TYPE_DUMMY; }
- // TODO: Add, Remove
+ void Add(void);
+ void Remove(void);
static void *operator new(size_t);
static void operator delete(void*, size_t);
+
+ // to make patching virtual functions possible
+ void Add_(void) { CDummy::Add(); }
+ void Remove_(void) { CDummy::Remove(); }
};
static_assert(sizeof(CDummy) == 0x68, "CDummy: error");
diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp
index 74cdab09..4ca66dd7 100644
--- a/src/entities/Ped.cpp
+++ b/src/entities/Ped.cpp
@@ -771,9 +771,9 @@ CPed::Attack(void)
}
} else {
if (weaponAnimAssoc->animId == ANIM_WEAPON_BAT_V || weaponAnimAssoc->animId == ANIM_WEAPON_BAT_H) {
- DMAudio.PlayOneShot(uAudioEntityId, SOUND_WEAPON_BAT_ATTACK, 1.0f);
+ DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, 1.0f);
} else if (weaponAnimAssoc->animId == ANIM_FIGHT_PPUNCH) {
- DMAudio.PlayOneShot(uAudioEntityId, SOUND_WEAPON_PUNCH_ATTACK, 0.0f);
+ DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_PUNCH_ATTACK, 0.0f);
}
weaponAnimAssoc->speed = 0.5f;
@@ -843,13 +843,13 @@ CPed::Attack(void)
if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep <= ourWeapon->m_fAnimLoopEnd) {
switch (ourWeaponType) {
case WEAPONTYPE_UZI:
- DMAudio.PlayOneShot(uAudioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
+ DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
break;
case WEAPONTYPE_AK47:
- DMAudio.PlayOneShot(uAudioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f);
+ DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f);
break;
case WEAPONTYPE_M16:
- DMAudio.PlayOneShot(uAudioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f);
+ DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f);
break;
default:
break;
@@ -1281,19 +1281,19 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) {
if (vehIsUpsideDown) {
- m_fRotationDest = -PI + atan2(-veh->GetForward().x, veh->GetForward().y);
+ m_fRotationDest = -PI + veh->GetForward().Heading();
} else if (veh->bIsBus) {
- m_fRotationDest = 0.5 * PI + atan2(-veh->GetForward().x, veh->GetForward().y);
+ m_fRotationDest = 0.5 * PI + veh->GetForward().Heading();
} else {
- m_fRotationDest = atan2(-veh->GetForward().x, veh->GetForward().y);
+ m_fRotationDest = GetForward().Heading();
}
} else if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) {
if (vehIsUpsideDown) {
- m_fRotationDest = atan2(-veh->GetForward().x, veh->GetForward().y);
+ m_fRotationDest = veh->GetForward().Heading();
} else if (veh->bIsBus) {
- m_fRotationDest = -0.5 * PI + atan2(-veh->GetForward().x, veh->GetForward().y);
+ m_fRotationDest = -0.5 * PI + veh->GetForward().Heading();
} else {
- m_fRotationDest = atan2(-veh->GetForward().x, veh->GetForward().y);
+ m_fRotationDest = veh->GetForward().Heading();
}
}
@@ -1539,7 +1539,7 @@ CPed::PlayFootSteps(void)
stepPart = 2;
if (stepPart != 0) {
- DMAudio.PlayOneShot(uAudioEntityId, stepPart == 1 ? SOUND_STEP_START : SOUND_STEP_END, 1.0f);
+ DMAudio.PlayOneShot(m_audioEntityId, stepPart == 1 ? SOUND_STEP_START : SOUND_STEP_END, 1.0f);
CVector footPos(0.0f, 0.0f, 0.0f);
for (RwFrame *frame = GetNodeFrame(stepPart == 1 ? PED_FOOTL : PED_FOOTR); frame; frame = RwFrameGetParent(frame))
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 3e043a32..64e0fb8b 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -42,7 +42,7 @@ CPhysical::CPhysical(void)
m_vecDamageNormal = CVector(0.0f, 0.0f, 0.0f);
bUsesCollision = true;
- uAudioEntityId = -5;
+ m_audioEntityId = -5;
unk1 = 100.0f;
m_vecCentreOfMass = CVector(0.0f, 0.0f, 0.0f);
field_EC = 0;
diff --git a/src/entities/Physical.h b/src/entities/Physical.h
index 11d2a1f9..749e2dd8 100644
--- a/src/entities/Physical.h
+++ b/src/entities/Physical.h
@@ -14,7 +14,7 @@ class CPhysical : public CEntity
public:
// The not properly indented fields haven't been checked properly yet
- int uAudioEntityId;
+ int32 m_audioEntityId;
float unk1;
CTreadable *m_carTreadable;
CTreadable *m_pedTreadable;
@@ -58,9 +58,8 @@ public:
uint8 bHitByTrain : 1; // from nick
uint8 m_phy_flagA80 : 1;
- uint8 m_nLastCollType;
- uint8 m_nZoneLevel;
- uint8 pad[3];
+ uint8 m_nLastCollType;
+ uint8 m_nZoneLevel;
CPhysical(void);
~CPhysical(void);
diff --git a/src/entities/PlayerInfo.h b/src/entities/PlayerInfo.h
index abda1b23..79f379d5 100644
--- a/src/entities/PlayerInfo.h
+++ b/src/entities/PlayerInfo.h
@@ -1,6 +1,6 @@
#pragma once
-#include "Automobile.h"
-#include "PlayerPed.h"
+
+#include "Collision.h"
enum eWastedBustedState
{
@@ -10,10 +10,9 @@ enum eWastedBustedState
WBSTATE_FAILED_CRITICAL_MISSION,
};
-struct CCivilianPed
-{
-
-};
+class CVehicle;
+class CPlayerPed;
+class CCivilianPed;
class CPlayerInfo
{
@@ -22,10 +21,7 @@ public:
CVehicle *m_pRemoteVehicle;
CColModel m_ColModel;
CVehicle *m_pVehicleEx;
- char m_aszPlayerName[70];
-private:
- int8 _pad0[2];
-public:
+ char m_aPlayerName[70];
int32 m_nMoney;
int32 m_nVisibleMoney;
int32 m_nCollectedPackages;
@@ -40,7 +36,7 @@ public:
int32 m_nNextSexMoneyUpdateTime;
int32 m_nSexFrequency;
CCivilianPed *m_pHooker;
- int8 m_bWBState; // eWastedBustedState
+ int8 m_WBState; // eWastedBustedState
int8 field_217;
int8 field_218;
int8 field_219;
@@ -71,4 +67,4 @@ public:
RwTexture *m_pSkinTexture;
};
-static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerPed: error");
+static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error");