Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Merge pull request #369 from erorcun/erorcun
CShotInfo, CWanted done, Frontend fix
  • Loading branch information
erorcun committed Mar 29, 2020
2 parents 0cbdca6 + a3b519e commit 6704a62b32ac989121b9ba77838d9366051d1e61
Showing with 329 additions and 53 deletions.
  1. +0 −7 README.md
  2. +3 −15 src/core/EventList.cpp
  3. +33 −10 src/core/Frontend.cpp
  4. +111 −14 src/core/Wanted.cpp
  5. +3 −1 src/core/Wanted.h
  6. +14 −0 src/core/World.cpp
  7. +1 −0 src/core/World.h
  8. +1 −0 src/core/config.h
  9. +0 −6 src/skel/win/win.cpp
  10. +140 −0 src/weapons/ShotInfo.cpp
  11. +23 −0 src/weapons/ShotInfo.h
@@ -42,7 +42,6 @@ cAudioManager - WIP
CBoat CBoat
CBrightLights CBrightLights
CBulletInfo CBulletInfo
CBulletTraces
CCamera CCamera
CCrane CCrane
CCranes CCranes
@@ -52,7 +51,6 @@ CExplosion
CFallingGlassPane CFallingGlassPane
CFire CFire
CFireManager CFireManager
CGame
CGarage CGarage
CGarages CGarages
CGlass CGlass
@@ -66,15 +64,10 @@ CRoadBlocks
CRubbish CRubbish
CSceneEdit CSceneEdit
CSkidmarks CSkidmarks
CShotInfo
CSpecialFX CSpecialFX
CStats CStats
CTrafficLights CTrafficLights
CWanted
CWaterCannon
CWaterCannons
CWeapon CWeapon
CWeaponEffects
CWeather CWeather
CWorld CWorld
``` ```
@@ -209,21 +209,9 @@ CEventList::ReportCrimeForEvent(eEventType type, int32 crimeId, bool copsDontCar
case EVENT_CAR_SET_ON_FIRE: crime = CRIME_VEHICLE_BURNED; break; case EVENT_CAR_SET_ON_FIRE: crime = CRIME_VEHICLE_BURNED; break;
default: crime = CRIME_NONE; break; default: crime = CRIME_NONE; break;
} }


#ifdef VC_PED_PORTS if(crime == CRIME_NONE)
if (crime == CRIME_HIT_PED && ((CPed*)crimeId)->IsPointerValid() && return;
FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 && ((CPed*)crimeId)->bBeingChasedByPolice) {

if(!((CPed*)crimeId)->DyingOrDead()) {
sprintf(gString, "$50 Good Citizen Bonus!");
AsciiToUnicode(gString, gUString);
CMessages::AddBigMessage(gUString, 5000, 0);
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 50;
}
} else
#endif
if(crime == CRIME_NONE)
return;


CVector playerPedCoors = FindPlayerPed()->GetPosition(); CVector playerPedCoors = FindPlayerPed()->GetPosition();
CVector playerCoors = FindPlayerCoors(); CVector playerCoors = FindPlayerCoors();
@@ -1354,23 +1354,39 @@ void CMenuManager::DrawFrontEndNormal()


m_aFrontEndSprites[currentSprite].Draw(CRect(MENU_X_LEFT_ALIGNED(50.0f), MENU_Y(50.0f), MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(95.0f)), CRGBA(255, 255, 255, m_nMenuFadeAlpha > 255 ? 255 : m_nMenuFadeAlpha)); m_aFrontEndSprites[currentSprite].Draw(CRect(MENU_X_LEFT_ALIGNED(50.0f), MENU_Y(50.0f), MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(95.0f)), CRGBA(255, 255, 255, m_nMenuFadeAlpha > 255 ? 255 : m_nMenuFadeAlpha));


static float fadeAlpha = 0.0f;
static int lastState = 0;

// reverseAlpha = PS2 fading (wait for 255->0, then change screen)
if (m_nMenuFadeAlpha < 255) { if (m_nMenuFadeAlpha < 255) {
static uint32 LastFade = 0; if (lastState == 1 && !reverseAlpha)
fadeAlpha = 0.f;


if (m_nMenuFadeAlpha <= 0 && reverseAlpha) { if (m_nMenuFadeAlpha <= 0 && reverseAlpha) {
reverseAlpha = false; reverseAlpha = false;
ChangeScreen(pendingScreen, pendingOption, true, false); ChangeScreen(pendingScreen, pendingOption, true, false);
} else { } else {
float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();

// +20 per every 33 ms (1000.f/30.f - original frame limiter fps)
if (!reverseAlpha) if (!reverseAlpha)
m_nMenuFadeAlpha += min((CTimer::GetTimeInMillisecondsPauseMode() - LastFade) / 33.0f, 1.0f) * 20.0f; fadeAlpha += (timestep * 100.f) * 20.f / 33.f;
else else
m_nMenuFadeAlpha = max(0, m_nMenuFadeAlpha - min((CTimer::GetTimeInMillisecondsPauseMode() - LastFade) / 33.0f, 1.0f) * 30.0f); fadeAlpha = max(0.0f, fadeAlpha - (timestep * 100.f) * 30.f / 33.f);


LastFade = CTimer::GetTimeInMillisecondsPauseMode(); m_nMenuFadeAlpha = fadeAlpha;
} }
lastState = 0;
} else { } else {
if (reverseAlpha) if (lastState == 0) fadeAlpha = 255.f;
m_nMenuFadeAlpha -= 20;
if (reverseAlpha) {
float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
fadeAlpha -= (timestep * 100.f) * 30.f / 33.f;

m_nMenuFadeAlpha = fadeAlpha;
}
lastState = 1;


// TODO: what is this? waiting mouse? // TODO: what is this? waiting mouse?
if(field_518 == 4){ if(field_518 == 4){
@@ -1568,13 +1584,20 @@ void CMenuManager::DrawFrontEndNormal()
} }


if (m_nMenuFadeAlpha < 255) { if (m_nMenuFadeAlpha < 255) {
static uint32 LastFade = 0;


// Famous transparent menu bug. 33.0f = 1000.f/30.f (original frame limiter fps) // Famous transparent menu bug
#ifdef FIX_BUGS #ifdef FIX_BUGS
m_nMenuFadeAlpha += min((CTimer::GetTimeInMillisecondsPauseMode() - LastFade) / 33.0f, 1.0f) * 20.0f; static float fadeAlpha = 0.0f;
LastFade = CTimer::GetTimeInMillisecondsPauseMode(); if (m_nMenuFadeAlpha == 0 && fadeAlpha > 1.0f) fadeAlpha = 0.0f;

float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();

// +20 per every 33 ms (1000.f/30.f - original frame limiter fps)
fadeAlpha += (timestep * 100.f) * 20.f / 33.f;
m_nMenuFadeAlpha = fadeAlpha;
#else #else
static uint32 LastFade = 0;

if(CTimer::GetTimeInMillisecondsPauseMode() - LastFade > 10){ if(CTimer::GetTimeInMillisecondsPauseMode() - LastFade > 10){
m_nMenuFadeAlpha += 20; m_nMenuFadeAlpha += 20;
LastFade = CTimer::GetTimeInMillisecondsPauseMode(); LastFade = CTimer::GetTimeInMillisecondsPauseMode();
@@ -7,19 +7,16 @@
#include "ZoneCull.h" #include "ZoneCull.h"
#include "Darkel.h" #include "Darkel.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "CopPed.h"
#include "Wanted.h" #include "Wanted.h"
#include "General.h"


int32 &CWanted::MaximumWantedLevel = *(int32*)0x5F7714; // 6 int32 &CWanted::MaximumWantedLevel = *(int32*)0x5F7714; // 6
int32 &CWanted::nMaximumWantedLevel = *(int32*)0x5F7718; // 6400 int32 &CWanted::nMaximumWantedLevel = *(int32*)0x5F7718; // 6400


WRAPPER void CWanted::Reset() { EAXJMP(0x4AD790) };
WRAPPER void CWanted::Update() { EAXJMP(0x4AD7B0) };

void void
CWanted::Initialise() CWanted::Initialise()
{ {
int i;

m_nChaos = 0; m_nChaos = 0;
m_nLastUpdateTime = 0; m_nLastUpdateTime = 0;
m_nLastWantedLevelChange = 0; m_nLastWantedLevelChange = 0;
@@ -34,10 +31,12 @@ CWanted::Initialise()
m_bArmyRequired = false; m_bArmyRequired = false;
m_fCrimeSensitivity = 1.0f; m_fCrimeSensitivity = 1.0f;
m_nWantedLevel = 0; m_nWantedLevel = 0;
m_CopsBeatingSuspect = 0; m_CopsBeatingSuspect = 0;
for(i = 0; i < 10; i++)
for (int i = 0; i < ARRAY_SIZE(m_pCops); i++)
m_pCops[i] = nil; m_pCops[i] = nil;
ClearQdCrimes();
ClearQdCrimes();
} }


bool bool
@@ -61,7 +60,7 @@ CWanted::AreArmyRequired()
int32 int32
CWanted::NumOfHelisRequired() CWanted::NumOfHelisRequired()
{ {
if (m_bIgnoredByCops) if (m_bIgnoredByCops || m_bIgnoredByEveryone)
return 0; return 0;


switch (m_nWantedLevel) { switch (m_nWantedLevel) {
@@ -79,9 +78,10 @@ CWanted::NumOfHelisRequired()
void void
CWanted::SetWantedLevel(int32 level) CWanted::SetWantedLevel(int32 level)
{ {
ClearQdCrimes();
if (level > MaximumWantedLevel) if (level > MaximumWantedLevel)
level = MaximumWantedLevel; level = MaximumWantedLevel;

ClearQdCrimes();
switch (level) { switch (level) {
case 0: case 0:
m_nChaos = 0; m_nChaos = 0;
@@ -360,10 +360,107 @@ CWanted::WorkOutPolicePresence(CVector posn, float radius)
return numPolice; return numPolice;
} }


void
CWanted::Update(void)
{
if (CTimer::GetTimeInMilliseconds() - m_nLastUpdateTime > 1000) {
if (m_nWantedLevel > 1) {
m_nLastUpdateTime = CTimer::GetTimeInMilliseconds();
} else {
float radius = 18.0f;
CVector playerPos = FindPlayerCoors();
if (WorkOutPolicePresence(playerPos, radius) == 0) {
m_nLastUpdateTime = CTimer::GetTimeInMilliseconds();
m_nChaos = max(0, m_nChaos - 1);
UpdateWantedLevel();
}
}
UpdateCrimesQ();
bool orderMessedUp = false;
int currCopNum = 0;
bool foundEmptySlot = false;
for (int i = 0; i < ARRAY_SIZE(m_pCops); i++) {
if (m_pCops[i]) {
++currCopNum;
if (foundEmptySlot)
orderMessedUp = true;
} else {
foundEmptySlot = true;
}
}
if (currCopNum != m_CurrentCops) {
printf("CopPursuit total messed up: re-setting\n");
m_CurrentCops = currCopNum;
}
if (orderMessedUp) {
printf("CopPursuit pointer list messed up: re-sorting\n");
bool fixed = true;
for (int i = 0; i < ARRAY_SIZE(m_pCops); i++) {
if (!m_pCops[i]) {
for (int j = i; j < ARRAY_SIZE(m_pCops); j++) {
if (m_pCops[j]) {
m_pCops[i] = m_pCops[j];
m_pCops[j] = nil;
fixed = false;
break;
}
}
if (fixed)
break;
}
}
}
}
}

void
CWanted::ResetPolicePursuit(void)
{
for(int i = 0; i < ARRAY_SIZE(m_pCops); i++) {
CCopPed *cop = m_pCops[i];
if (!cop)
continue;

cop->m_bIsInPursuit = false;
cop->m_objective = OBJECTIVE_NONE;
cop->m_prevObjective = OBJECTIVE_NONE;
cop->m_nLastPedState = PED_NONE;
if (!cop->DyingOrDead()) {
cop->SetWanderPath(CGeneral::GetRandomNumberInRange(0.0f, 8.0f));
}
m_pCops[i] = nil;
}
m_CurrentCops = 0;
}

void
CWanted::Reset(void)
{
ResetPolicePursuit();
Initialise();
}

void
CWanted::UpdateCrimesQ(void)
{
for(int i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {

CCrimeBeingQd &crime = m_aCrimes[i];
if (crime.m_nType != CRIME_NONE) {
if (CTimer::GetTimeInMilliseconds() > crime.m_nTime + 500 && !crime.m_bReported) {
ReportCrimeNow(crime.m_nType, crime.m_vecPosn, crime.m_bPoliceDoesntCare);
crime.m_bReported = true;
}
if (CTimer::GetTimeInMilliseconds() > crime.m_nTime + 10000)
crime.m_nType = CRIME_NONE;
}
}
}

STARTPATCHES STARTPATCHES
InjectHook(0x4AD6E0, &CWanted::Initialise, PATCH_JUMP); InjectHook(0x4AD6E0, &CWanted::Initialise, PATCH_JUMP);
// InjectHook(0x4AD790, &CWanted::Reset, PATCH_JUMP); InjectHook(0x4AD790, &CWanted::Reset, PATCH_JUMP);
// InjectHook(0x4AD7B0, &CWanted::Update, PATCH_JUMP); InjectHook(0x4AD7B0, &CWanted::Update, PATCH_JUMP);
InjectHook(0x4AD900, &CWanted::UpdateWantedLevel, PATCH_JUMP); InjectHook(0x4AD900, &CWanted::UpdateWantedLevel, PATCH_JUMP);
InjectHook(0x4AD9F0, &CWanted::RegisterCrime, PATCH_JUMP); InjectHook(0x4AD9F0, &CWanted::RegisterCrime, PATCH_JUMP);
InjectHook(0x4ADA10, &CWanted::RegisterCrime_Immediately, PATCH_JUMP); InjectHook(0x4ADA10, &CWanted::RegisterCrime_Immediately, PATCH_JUMP);
@@ -374,10 +471,10 @@ STARTPATCHES
InjectHook(0x4ADBC0, &CWanted::AreFbiRequired, PATCH_JUMP); InjectHook(0x4ADBC0, &CWanted::AreFbiRequired, PATCH_JUMP);
InjectHook(0x4ADBE0, &CWanted::AreArmyRequired, PATCH_JUMP); InjectHook(0x4ADBE0, &CWanted::AreArmyRequired, PATCH_JUMP);
InjectHook(0x4ADC00, &CWanted::NumOfHelisRequired, PATCH_JUMP); InjectHook(0x4ADC00, &CWanted::NumOfHelisRequired, PATCH_JUMP);
// InjectHook(0x4ADC40, &CWanted::ResetPolicePursuit, PATCH_JUMP); InjectHook(0x4ADC40, &CWanted::ResetPolicePursuit, PATCH_JUMP);
InjectHook(0x4ADD00, &CWanted::WorkOutPolicePresence, PATCH_JUMP); InjectHook(0x4ADD00, &CWanted::WorkOutPolicePresence, PATCH_JUMP);
InjectHook(0x4ADF20, &CWanted::ClearQdCrimes, PATCH_JUMP); InjectHook(0x4ADF20, &CWanted::ClearQdCrimes, PATCH_JUMP);
InjectHook(0x4ADFD0, &CWanted::AddCrimeToQ, PATCH_JUMP); InjectHook(0x4ADFD0, &CWanted::AddCrimeToQ, PATCH_JUMP);
// InjectHook(0x4AE090, &CWanted::UpdateCrimesQ, PATCH_JUMP); InjectHook(0x4AE090, &CWanted::UpdateCrimesQ, PATCH_JUMP);
InjectHook(0x4AE110, &CWanted::ReportCrimeNow, PATCH_JUMP); InjectHook(0x4AE110, &CWanted::ReportCrimeNow, PATCH_JUMP);
ENDPATCHES ENDPATCHES
@@ -30,7 +30,7 @@ class CCrimeBeingQd
public: public:
eCrimeType m_nType; eCrimeType m_nType;
uint32 m_nId; uint32 m_nId;
int32 m_nTime; uint32 m_nTime;
CVector m_vecPosn; CVector m_vecPosn;
bool m_bReported; bool m_bReported;
bool m_bPoliceDoesntCare; bool m_bPoliceDoesntCare;
@@ -78,6 +78,8 @@ class CWanted
void ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesntCare); void ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesntCare);
void UpdateWantedLevel(); void UpdateWantedLevel();
void Reset(); void Reset();
void ResetPolicePursuit();
void UpdateCrimesQ();
void Update(); void Update();


bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; } bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; }
@@ -19,6 +19,7 @@
#include "Messages.h" #include "Messages.h"
#include "Replay.h" #include "Replay.h"
#include "Population.h" #include "Population.h"
#include "Fire.h"


CColPoint *gaTempSphereColPoints = (CColPoint*)0x6E64C0; // [32] CColPoint *gaTempSphereColPoints = (CColPoint*)0x6E64C0; // [32]


@@ -1052,6 +1053,19 @@ CWorld::ExtinguishAllCarFiresInArea(CVector point, float range)
} }
} }


void
CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason)
{
int poolSize = CPools::GetVehiclePool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
if (veh && veh->m_status != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) {
if (Abs(veh->GetPosition().z - z) < 5.0f && Abs(veh->GetPosition().x - x) < radius && Abs(veh->GetPosition().y - y) < radius)
gFireManager.StartFire(veh, reason, 0.8f, true);
}
}
}

void void
CWorld::Process(void) CWorld::Process(void)
{ {
@@ -130,6 +130,7 @@ class CWorld
static void StopAllLawEnforcersInTheirTracks(); static void StopAllLawEnforcersInTheirTracks();
static void SetAllCarsCanBeDamaged(bool); static void SetAllCarsCanBeDamaged(bool);
static void ExtinguishAllCarFiresInArea(CVector, float); static void ExtinguishAllCarFiresInArea(CVector, float);
static void SetCarsOnFire(float, float, float, float, CEntity*);


static void Initialise(); static void Initialise();
static void AddParticles(); static void AddParticles();
@@ -100,6 +100,7 @@ enum Config {
NUMPHONES = 50, NUMPHONES = 50,
NUMPEDGROUPS = 31, NUMPEDGROUPS = 31,
NUMMODELSPERPEDGROUP = 8, NUMMODELSPERPEDGROUP = 8,
NUMSHOTINFOS = 100,


NUMROADBLOCKS = 600, NUMROADBLOCKS = 600,


@@ -2056,13 +2056,7 @@ _WinMain(HINSTANCE instance,
{ {
GetWindowPlacement(PSGLOBAL(window), &wp); GetWindowPlacement(PSGLOBAL(window), &wp);


// Famous transparent menu bug. Also see the fix in Frontend.cpp
#ifdef FIX_BUGS
float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
if ((1000.0f / 100.0f) < ms && wp.showCmd != SW_SHOWMINIMIZED)
#else
if (wp.showCmd != SW_SHOWMINIMIZED) if (wp.showCmd != SW_SHOWMINIMIZED)
#endif
RsEventHandler(rsFRONTENDIDLE, nil); RsEventHandler(rsFRONTENDIDLE, nil);


if ( !FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bLoadingSavedGame ) if ( !FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bLoadingSavedGame )

0 comments on commit 6704a62

Please sign in to comment.