Merge pull request #209 from erorcun/erorcun

Peds, a fix and a tad of VC
This commit is contained in:
Nikolay Korolev 2019-09-17 23:43:43 +03:00 committed by GitHub
commit 5d98e12b85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 827 additions and 123 deletions

View File

@ -696,7 +696,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
} }
if (pVehicle->bExtendedRange) if (pVehicle->bExtendedRange)
threshold *= 1.5f; threshold *= 1.5f;
if (distanceToPlayer > threshold && !CGarages::IsPointWithinHideOutGarage(&pVehicle->GetPosition())){ if (distanceToPlayer > threshold && !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
if (pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle)){ if (pVehicle->GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(pVehicle)){
pVehicle->bFadeOut = true; pVehicle->bFadeOut = true;
}else{ }else{
@ -712,9 +712,10 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
(pVehicle->GetPosition() - vecPlayerPos).Magnitude2D() > 25.0f && (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D() > 25.0f &&
!IsThisVehicleInteresting(pVehicle) && !IsThisVehicleInteresting(pVehicle) &&
!pVehicle->bIsLocked && !pVehicle->bIsLocked &&
pVehicle->CanBeDeleted() &&
!CTrafficLights::ShouldCarStopForLight(pVehicle, true) && !CTrafficLights::ShouldCarStopForLight(pVehicle, true) &&
!CTrafficLights::ShouldCarStopForBridge(pVehicle) && !CTrafficLights::ShouldCarStopForBridge(pVehicle) &&
!CGarages::IsPointWithinHideOutGarage(&pVehicle->GetPosition())){ !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
CWorld::Remove(pVehicle); CWorld::Remove(pVehicle);
delete pVehicle; delete pVehicle;
return; return;
@ -724,7 +725,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 && if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 &&
(!pVehicle->GetIsOnScreen() || !CRenderer::IsEntityCullZoneVisible(pVehicle))){ (!pVehicle->GetIsOnScreen() || !CRenderer::IsEntityCullZoneVisible(pVehicle))){
if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)){ if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(7.5f)){
if (!CGarages::IsPointWithinHideOutGarage(&pVehicle->GetPosition())){ if (!CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){
CWorld::Remove(pVehicle); CWorld::Remove(pVehicle);
delete pVehicle; delete pVehicle;
} }

View File

@ -69,7 +69,8 @@ bool CGarages::HasCarBeenCrushed(int32 handle)
} }
WRAPPER void CGarages::TriggerMessage(const char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); } WRAPPER void CGarages::TriggerMessage(const char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector*) { EAXJMP(0x428260); } WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
#if 0 #if 0
WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); } WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }

View File

@ -25,5 +25,6 @@ public:
static void TriggerMessage(const char *text, int16, uint16 time, int16); static void TriggerMessage(const char *text, int16, uint16 time, int16);
static void PrintMessages(void); static void PrintMessages(void);
static bool HasCarBeenCrushed(int32); static bool HasCarBeenCrushed(int32);
static bool IsPointWithinHideOutGarage(CVector*); static bool IsPointWithinHideOutGarage(CVector&);
static bool IsPointWithinAnyGarage(CVector&);
}; };

View File

@ -54,14 +54,7 @@ public:
static float LimitRadianAngle(float angle) static float LimitRadianAngle(float angle)
{ {
float result; float result = clamp(angle, -25.0f, 25.0f);
if (angle < -25.0f)
result = -25.0f;
else if (angle > 25.0f)
result = 25.0f;
else
result = angle;
while (result >= PI) { while (result >= PI) {
result -= 2 * PI; result -= 2 * PI;

View File

@ -56,9 +56,10 @@ class CWorld
static CPtrList &ms_listMovingEntityPtrs; static CPtrList &ms_listMovingEntityPtrs;
static CSector (*ms_aSectors)[NUMSECTORS_X]; // [NUMSECTORS_Y][NUMSECTORS_X]; static CSector (*ms_aSectors)[NUMSECTORS_X]; // [NUMSECTORS_Y][NUMSECTORS_X];
static uint16 &ms_nCurrentScanCode; static uint16 &ms_nCurrentScanCode;
static CColPoint &ms_testSpherePoint;
public: public:
static CColPoint& ms_testSpherePoint;
static uint8 &PlayerInFocus; static uint8 &PlayerInFocus;
static CPlayerInfo *Players; static CPlayerInfo *Players;
static CEntity *&pIgnoreEntity; static CEntity *&pIgnoreEntity;

View File

@ -8,34 +8,11 @@ WRAPPER void CCivilianPed::ProcessControl(void) { EAXJMP(0x4BFFE0); }
CCivilianPed::CCivilianPed(int pedtype, int mi) : CPed(pedtype) CCivilianPed::CCivilianPed(int pedtype, int mi) : CPed(pedtype)
{ {
SetModelIndex(mi); SetModelIndex(mi);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++) {
{
m_nearPeds[i] = nil; m_nearPeds[i] = nil;
} }
} }
bool
CCivilianPed::ProcessNearestFreePhone(int unused)
{
if (m_nPedState == PED_SEEK_POS)
return false;
int phoneId = gPhoneInfo.FindNearestFreePhone(&GetPosition());
if (phoneId == -1)
return false;
if (gPhoneInfo.m_aPhones[phoneId].m_nState != PHONE_STATE_FREE)
return false;
bRunningToPhone = true;
SetMoveState(PEDMOVE_RUN);
SetSeek(gPhoneInfo.m_aPhones[phoneId].m_vecPos, 0.3f);
m_phoneId = phoneId;
m_lookingForPhone = unused;
return true;
}
class CCivilianPed_ : public CCivilianPed class CCivilianPed_ : public CCivilianPed
{ {
public: public:
@ -46,5 +23,4 @@ public:
STARTPATCHES STARTPATCHES
InjectHook(0x4BFF30, &CCivilianPed_::ctor, PATCH_JUMP); InjectHook(0x4BFF30, &CCivilianPed_::ctor, PATCH_JUMP);
InjectHook(0x4BFFC0, &CCivilianPed_::dtor, PATCH_JUMP); InjectHook(0x4BFFC0, &CCivilianPed_::dtor, PATCH_JUMP);
InjectHook(0x4C10C0, &CCivilianPed::ProcessNearestFreePhone, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View File

@ -9,6 +9,5 @@ public:
~CCivilianPed(void) { } ~CCivilianPed(void) { }
void ProcessControl(void); void ProcessControl(void);
bool ProcessNearestFreePhone(int);
}; };
static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error"); static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error");

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@
#include "EventList.h" #include "EventList.h"
struct CPathNode; struct CPathNode;
class CAccident;
struct CPedAudioData struct CPedAudioData
{ {
@ -57,6 +58,7 @@ struct FightMove
}; };
static_assert(sizeof(FightMove) == 0x18, "FightMove: error"); static_assert(sizeof(FightMove) == 0x18, "FightMove: error");
// TO-DO: This is eFightState on mobile.
enum PedFightMoves enum PedFightMoves
{ {
FIGHTMOVE_NULL, FIGHTMOVE_NULL,
@ -169,7 +171,7 @@ enum {
enum PedLineUpPhase { enum PedLineUpPhase {
LINE_UP_TO_CAR_START, LINE_UP_TO_CAR_START,
LINE_UP_TO_CAR_END, LINE_UP_TO_CAR_END,
LINE_UP_TO_CAR_2 LINE_UP_TO_CAR_2 // Buggy. Used for cops arresting you from passenger door
}; };
enum PedOnGroundState { enum PedOnGroundState {
@ -330,7 +332,7 @@ public:
uint8 bClearObjective : 1; uint8 bClearObjective : 1;
uint8 m_ped_flagH10 : 1; uint8 m_ped_flagH10 : 1;
uint8 bCollidedWithMyVehicle : 1; uint8 bCollidedWithMyVehicle : 1;
uint8 m_ped_flagH40 : 1; uint8 bRichFromMugging : 1; // ped has lots of cash from mugging people - will drop money if someone points gun to him
uint8 m_ped_flagH80 : 1; uint8 m_ped_flagH80 : 1;
uint8 bShakeFist : 1; // test shake hand at look entity uint8 bShakeFist : 1; // test shake hand at look entity
@ -411,9 +413,9 @@ public:
bool bRunningToPhone; bool bRunningToPhone;
uint8 field_31D; uint8 field_31D;
int16 m_phoneId; int16 m_phoneId;
uint32 m_lookingForPhone; // unused eCrimeType m_crimeToReportOnPhone;
uint32 m_phoneTalkTimer; uint32 m_phoneTalkTimer;
void *m_lastAccident; CAccident *m_lastAccident;
int32 m_nPedType; int32 m_nPedType;
CPedStats *m_pedStats; CPedStats *m_pedStats;
float m_fleeFromPosX; float m_fleeFromPosX;
@ -646,6 +648,8 @@ public:
void SeekCar(void); void SeekCar(void);
void SeekBoatPosition(void); void SeekBoatPosition(void);
bool PositionPedOutOfCollision(void); bool PositionPedOutOfCollision(void);
bool RunToReportCrime(eCrimeType);
bool PlacePedOnDryLand(void);
// Static methods // Static methods
static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset); static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset);
@ -724,6 +728,7 @@ public:
PedState GetPedState(void) { return m_nPedState; } PedState GetPedState(void) { return m_nPedState; }
void SetPedState(PedState state) { m_nPedState = state; } void SetPedState(PedState state) { m_nPedState = state; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
void GiveWeaponBackAfterExitingCar(void);
// set by 0482:set_threat_reaction_range_multiplier opcode // set by 0482:set_threat_reaction_range_multiplier opcode
static uint16 &nThreatReactionRangeMultiplier; static uint16 &nThreatReactionRangeMultiplier;