From 4f1d6123dd939f87a1798a3ebb447106a8c1ff73 Mon Sep 17 00:00:00 2001
From: Nikolay Korolev <nickvnuk@gmail.com>
Date: Mon, 6 Apr 2020 19:31:08 +0300
Subject: [PATCH] stats fix

---
 src/control/Garages.cpp |   2 +-
 src/core/Stats.cpp      | 108 +++++++++++++++++++---------------------
 src/core/Stats.h        |   3 --
 3 files changed, 51 insertions(+), 62 deletions(-)

diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index 64020602..9e10af2d 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -526,7 +526,7 @@ void CGarage::Update()
 					((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed();
 					if (m_eGarageType == GARAGE_BOMBSHOP3)
 						CGarages::GivePlayerDetonator();
-					CStats::KgOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
+					CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
 				}
 				switch (m_eGarageType) {
 				case GARAGE_BOMBSHOP1:
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index cdd20b66..aeb7afe5 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -63,62 +63,56 @@ void CStats::Init()
 	PeopleKilledByOthers = 0;
 	PeopleKilledByPlayer = 0;
 	ShotsMade = 0;
-    CarsExploded = 0;
-    HelisDestroyed = 0;
-    ProgressMade = 0;
-    KgsOfExplosivesUsed = 0;
-    InstantHitsFiredByPlayer = 0;
-    InstantHitsHitByPlayer = 0;
-    CarsCrushed = 0;
-    HeadsPopped = 0;
-    TimesArrested = 0;
-    TimesDied = 0;
-    DaysPassed = 0;
-    NumberOfUniqueJumpsFound = 0;
-    mmRain = 0;
-    MaximumJumpFlips = 0;
-    MaximumJumpSpins = 0;
-    MaximumJumpDistance = 0;
-    MaximumJumpHeight = 0;
-    BestStuntJump = 0;
-    TotalNumberOfUniqueJumps = 0;
-    Record4x4One = 0;
-    LongestFlightInDodo = 0;
-    Record4x4Two = 0;
-    PassengersDroppedOffWithTaxi = 0;
-    Record4x4Three = 0;
-    MoneyMadeWithTaxi = 0;
-    Record4x4Mayhem = 0;
-    LivesSavedWithAmbulance = 0;
-    ElBurroTime = 0;
-    CriminalsCaught = 0;
-    MissionsGiven = 0;
-    HighestLevelAmbulanceMission = 0;
-    MissionsPassed = 0;
-    FiresExtinguished = 0;
-    DistanceTravelledOnFoot = 0;
-    TimeTakenDefuseMission = 0;
-    NumberKillFrenziesPassed = 0;
-    DistanceTravelledInVehicle = 0;
-    TotalNumberKillFrenzies = 0;
-    TotalNumberMissions = 0;
-    KillsSinceLastCheckpoint = 0;
-    TotalLegitimateKills = 0;
-    for (int i = 0; i < TOTAL_FASTEST_TIMES; i++)
-    {
-        FastestTimes[i] = 0;
-    }
-    for (int i = 0; i < TOTAL_HIGHEST_SCORES; i++)
-    {
-        HighestScores[i] = 0;
-    }
-    for (int i = 0; i < NUM_PEDTYPES; i++)
-    {
-        PedsKilledOfThisType[i] = 0;
-    }
-    IndustrialPassed = 0;
-    CommercialPassed = 0;
-    SuburbanPassed = 0;
+	CarsExploded = 0;
+	HelisDestroyed = 0;
+	ProgressMade = 0;
+	KgsOfExplosivesUsed = 0;
+	InstantHitsFiredByPlayer = 0;
+	InstantHitsHitByPlayer = 0;
+	CarsCrushed = 0;
+	HeadsPopped = 0;
+	TimesArrested = 0;
+	TimesDied = 0;
+	DaysPassed = 0;
+	NumberOfUniqueJumpsFound = 0;
+	mmRain = 0;
+	MaximumJumpFlips = 0;
+	MaximumJumpSpins = 0;
+	MaximumJumpDistance = 0;
+	MaximumJumpHeight = 0;
+	BestStuntJump = 0;
+	TotalNumberOfUniqueJumps = 0;
+	Record4x4One = 0;
+	LongestFlightInDodo = 0;
+	Record4x4Two = 0;
+	PassengersDroppedOffWithTaxi = 0;
+	Record4x4Three = 0;
+	MoneyMadeWithTaxi = 0;
+	Record4x4Mayhem = 0;
+	LivesSavedWithAmbulance = 0;
+	ElBurroTime = 0;
+	CriminalsCaught = 0;
+	MissionsGiven = 0;
+	HighestLevelAmbulanceMission = 0;
+	MissionsPassed = 0;
+	FiresExtinguished = 0;
+	DistanceTravelledOnFoot = 0;
+	TimeTakenDefuseMission = 0;
+	NumberKillFrenziesPassed = 0;
+	DistanceTravelledInVehicle = 0;
+	TotalNumberKillFrenzies = 0;
+	TotalNumberMissions = 0;
+	KillsSinceLastCheckpoint = 0;
+	TotalLegitimateKills = 0;
+	for (int i = 0; i < TOTAL_FASTEST_TIMES; i++)
+		FastestTimes[i] = 0;
+	for (int i = 0; i < TOTAL_HIGHEST_SCORES; i++)
+		HighestScores[i] = 0;
+	for (int i = 0; i < NUM_PEDTYPES; i++)
+		PedsKilledOfThisType[i] = 0;
+	IndustrialPassed = 0;
+	CommercialPassed = 0;
+	SuburbanPassed = 0;
 }
 
 void CStats::RegisterFastestTime(int32 index, int32 time)
@@ -206,8 +200,6 @@ void CStats::SetTotalNumberMissions(int32 total)
 	TotalNumberMissions = total;
 }
 
-//WRAPPER void CStats::Init() { EAXJMP(0x4AAC60); }
-
 STARTPATCHES
 	InjectHook(0x48C5A3, CStats::Init, PATCH_JUMP); // CGame::ReInitGameObjectVariables
 ENDPATCHES
\ No newline at end of file
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 41d926e6..029b2307 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -62,8 +62,6 @@ public:
     static int32 &CarsCrushed;
 	static int32(&FastestTimes)[TOTAL_FASTEST_TIMES];
 	static int32(&HighestScores)[TOTAL_HIGHEST_SCORES];
-	static int32 &KgOfExplosivesUsed;
-	static int32 &CarsCrushed;
 
 public:
 	static void RegisterFastestTime(int32, int32);
@@ -85,6 +83,5 @@ public:
 	static void CheckPointReachedSuccessfully() { TotalLegitimateKills += KillsSinceLastCheckpoint; KillsSinceLastCheckpoint = 0; };
 	static void RegisterElBurroTime(int32);
 	static void SaveStats(uint8 *buf, uint32 *size);
-
 	static void Init(void);
 };