miscellaneous, mostly world related

This commit is contained in:
aap
2019-06-29 11:09:33 +02:00
parent f2d1ceb043
commit b2f8c7eb23
20 changed files with 244 additions and 69 deletions

View File

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

View File

@ -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");

View File

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

View File

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

View File

@ -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);

View File

@ -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");