ProcessButtonPresses and fixes

This commit is contained in:
eray orçunus
2020-03-17 21:03:13 +03:00
parent 31d16d395e
commit d5a6e17079
18 changed files with 1763 additions and 756 deletions

View File

@ -259,17 +259,17 @@ CCopPed::ScanForCrimes(void)
}
}
// Look for stolen cop cars (it was broken until now)
// Look for stolen cop cars
if (!m_bIsInPursuit) {
CPlayerPed *player = FindPlayerPed();
#ifdef FIX_BUGS
if ((player->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || player->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER)
#else
if ((m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER)
#endif
&& player->m_pWanted->m_nWantedLevel == 0 && player->m_pMyVehicle) {
&& player->m_pWanted->m_nWantedLevel == 0) {
if (player->m_pMyVehicle->bIsLawEnforcer)
if (player->m_pMyVehicle
#ifdef FIX_BUGS
&& m_pMyVehicle == player->m_pMyVehicle
#endif
&& player->m_pMyVehicle->bIsLawEnforcer)
player->SetWantedLevelNoDrop(1);
}
}

View File

@ -2261,7 +2261,7 @@ CPed::SetModelIndex(uint32 mi)
RpAnimBlendClumpInit(GetClump());
RpAnimBlendClumpFillFrameArray(GetClump(), m_pFrames);
CPedModelInfo *modelInfo = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
SetPedStats((ePedStats) modelInfo->m_pedStatType);
SetPedStats(modelInfo->m_pedStatType);
m_headingRate = m_pedStats->m_headingChangeRate;
m_animGroup = (AssocGroupId) modelInfo->m_animGroup;
CAnimManager::AddAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE);
@ -6928,11 +6928,9 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg)
if (obstacle) {
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
#ifndef VC_PED_PORTS
// ANIM_HIT_WALL in VC (which makes more sense)
CAnimBlendAssociation *handsCoverAssoc = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_HANDSCOWER, 8.0f);
#else
CAnimBlendAssociation* handsCoverAssoc = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_HIT_WALL, 8.0f);
#endif
handsCoverAssoc->flags &= ~ASSOC_FADEOUTWHENDONE;
handsCoverAssoc->SetFinishCallback(FinishHitHeadCB, ped);
ped->bIsLanding = true;

View File

@ -4,7 +4,8 @@
#include "FileMgr.h"
#include "PedStats.h"
CPedStats *(&CPedStats::ms_apPedStats)[NUM_PEDSTATS] = *(CPedStats *(*)[NUM_PEDSTATS]) *(uintptr*)0x9404D4;
//CPedStats *(&CPedStats::ms_apPedStats)[NUM_PEDSTATS] = *(CPedStats *(*)[NUM_PEDSTATS]) *(uintptr*)0x9404D4;
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
void
CPedStats::Initialise(void)
@ -68,9 +69,9 @@ CPedStats::LoadPedStats(void)
line[linelen++] = ' ';
else
line[linelen++] = buf[bp];
line[linelen] = '\0';
}
bp++;
line[linelen] = '\0';
// skip white space
for(lp = 0; line[lp] <= ' '; lp++);
@ -107,14 +108,13 @@ CPedStats::LoadPedStats(void)
delete[] buf;
}
int32
ePedStats
CPedStats::GetPedStatType(char *name)
{
int type;
for(type = 0; type < NUM_PEDSTATS; type++)
for(uint16 type = 0; type < NUM_PEDSTATS; type++)
if(!CGeneral::faststrcmp(ms_apPedStats[type]->m_name, name))
return type;
return (ePedStats) type;
return NUM_PEDSTATS;
}

View File

@ -69,11 +69,11 @@ public:
float m_defendWeakness;
int16 m_flags;
static CPedStats* (&ms_apPedStats)[NUM_PEDSTATS];
static CPedStats *ms_apPedStats[NUM_PEDSTATS];
static void Initialise(void);
static void Shutdown(void);
static void LoadPedStats(void);
static int32 GetPedStatType(char *name);
static ePedStats GetPedStatType(char *name);
};
static_assert(sizeof(CPedStats) == 0x34, "CPedStats: error");

View File

@ -63,9 +63,9 @@ CPedType::LoadPedData(void)
line[linelen++] = ' ';
else
line[linelen++] = buf[bp];
line[linelen] = '\0';
}
bp++;
line[linelen] = '\0';
// skip white space
for(lp = 0; line[lp] <= ' '; lp++);
@ -74,7 +74,7 @@ CPedType::LoadPedData(void)
line[lp] == '#')
continue;
// FIX: game just uses line here
// Game uses just "line" here since sscanf already trims whitespace, but this is safer
sscanf(&line[lp], "%s", word);
if(strncmp(word, "Threat", 7) == 0){
@ -195,7 +195,8 @@ void
CPedType::Load(uint8 *buf, uint32 size)
{
INITSAVEBUF
CheckSaveHeader(buf, 'P','T','P','\0', size - SAVE_HEADER_SIZE);
// original: SkipSaveBuf(buf, SAVE_HEADER_SIZE);
CheckSaveHeader(buf, 'P', 'T', 'P', '\0', size - SAVE_HEADER_SIZE);
for(int i = 0; i < NUM_PEDTYPES; i++)
*ms_apPedType[i] = ReadSaveBuf<CPedType>(buf);

View File

@ -30,7 +30,8 @@
// More clearly they're transition areas between zones.
RegenerationPoint (&aSafeZones)[8] = *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578;
PedGroup (&CPopulation::ms_pPedGroups)[NUMPEDGROUPS] = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248;
//PedGroup (&CPopulation::ms_pPedGroups)[NUMPEDGROUPS] = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248;
PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS];
bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6;
int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570;
float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C;
@ -80,7 +81,7 @@ CPopulation::Initialise()
ms_nNumDummy = 0;
m_AllRandomPedsThisType = -1;
PedDensityMultiplier = 1.0;
PedDensityMultiplier = 1.0f;
bZoneChangeHasHappened = false;
m_CountDownToPedsAtStart = 2;
@ -511,9 +512,9 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
uint32 weapon;
if (CGeneral::GetRandomNumberInRange(0, 100) >= 50)
weapon = ped->GiveWeapon(CGangs::GetGangWeapon2(pedType - PEDTYPE_GANG1), 25001);
weapon = ped->GiveWeapon(CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon2, 25001);
else
weapon = ped->GiveWeapon(CGangs::GetGangWeapon1(pedType - PEDTYPE_GANG1), 25001);
weapon = ped->GiveWeapon(CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon1, 25001);
ped->SetCurrentWeapon(weapon);
return ped;
}
@ -770,7 +771,7 @@ CPopulation::AddPedInCar(CVehicle* car)
// fall through
default:
int gangOfPed = GANG_MAFIA;
int gangOfPed = 0;
imSureThatModelIsLoaded = false;
while (gangOfPed < NUM_GANGS && CGangs::GetGangInfo(gangOfPed)->m_nVehicleMI != car->m_modelIndex)

View File

@ -33,7 +33,7 @@ struct RegenerationPoint
class CPopulation
{
public:
static PedGroup (&ms_pPedGroups)[NUMPEDGROUPS];
static PedGroup ms_pPedGroups[NUMPEDGROUPS];
static bool &ms_bGivePedsWeapons;
static int32 &m_AllRandomPedsThisType;
static float &PedDensityMultiplier;