-
Notifications
You must be signed in to change notification settings - Fork 3
/
RaceFixesStuff.h
147 lines (119 loc) · 5.79 KB
/
RaceFixesStuff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#include "stdafx.h"
#include "stdio.h"
#include <string>
#include <windows.h>
#include "includes\IniReader.h"
#include "includes\injector\injector.hpp"
#include "CustomRaceOptions.h"
#include "InGameFunctions.h"
#include "GRaceCustom.h"
#include "cFrontendDatabase.h"
#include "SetupStat.h"
#include "LANStuff.h"
#include "CashgrabStuff.h"
#include "InRaceStuff.h"
#include "PostRaceResults.h"
#include "PostRaceLapStats.h"
#include "PostRaceRacerStats.h"
#include "RaceOverMessage.h"
#include "CopDensity.h"
#include "StartingPursuitCondition.h"
#include "UIQRChallengeSeries.h"
#include "UIQRModeSelect.h"
#include "UIQRTrackSelect.h"
#include "UIQRTrackOptions.h"
#include "Game.h"
DWORD SetupRacerStats_JumpTable1[10] = { 0x59710B, 0x597112, 0x59710B, 0x597112, 0x597136, 0x597124, 0x59710B, (DWORD)RacerStats_Cashgrab_Footer, 0x59710B, 0x59714E };
DWORD SetupRacerStats_JumpTable2[10] = { 0x597176, 0x5971CD, 0x597210, 0x5971CD, 0x597278, 0x59725F, 0x597278, (DWORD)RacerStats_Cashgrab_Data, 0x597176, 0x59729F };
DWORD SetupLapStats_JumpTable1[10] = { 0x59732B, 0x597381, 0x59732B, 0x597381, 0x5974B3, 0x597414, 0x59732B, (DWORD)LapStats_Cashgrab_Header, 0x59732B, 0x59752C };
DWORD SetupLapStats_JumpTable2[10] = { 0x597558, 0x597702, 0x597558, 0x597702, 0x59795F, 0x597840, 0x597558, 0x597840, 0x597558, 0x597B25 };
int Init()
{
CIniReader RaceFixesSettings("NFSMWRaceFixesSettings.ini");
// Read settings
bool QuickRaceModeSelectHook = RaceFixesSettings.ReadInteger("Main", "QuickRaceModeSelectHook", 1) != 0;
bool QuickRaceTrackSelectHook = RaceFixesSettings.ReadInteger("Main", "QuickRaceTrackSelectHook", 1) != 0;
bool QuickRaceTrackOptionsHook = RaceFixesSettings.ReadInteger("Main", "QuickRaceTrackOptionsHook", 1) != 0;
bool ChallengeSeriesFixes = RaceFixesSettings.ReadInteger("Main", "ChallengeSeriesFixes", 1) != 0;
bool LANFixes = RaceFixesSettings.ReadInteger("Main", "LANFixes", 1) != 0;
bool OutroFix = RaceFixesSettings.ReadInteger("Fields", "OutroMovieFix", 0) != 0;
MinHeat = RaceFixesSettings.ReadInteger("StartingPursuitCondition", "Minimum", 1);
MaxHeat = RaceFixesSettings.ReadInteger("StartingPursuitCondition", "Maximum", 5);
bool ShowCashbagMessage = RaceFixesSettings.ReadInteger("Cashgrab", "ShowCashbagMessage", 1) != 0;
// Hook Quick Race Mode Select Menu to allow customization of it
if (QuickRaceModeSelectHook)
{
injector::MakeCALL(0x7BA4D7, UIQRModeSelect_Setup, true);
injector::WriteMemory(0x8B7E28, &UIQRModeSelect_Setup, true);
}
// Hook Quick Race Track Select Menu to allow customization of it
if (QuickRaceTrackSelectHook)
{
injector::MakeCALL(0x7C1473, UIQRTrackSelect_Setup, true);
injector::WriteMemory(0x8B7E38, &UIQRTrackSelect_Setup, true);
}
// Hook Track Options to allow customization of it
if (QuickRaceTrackOptionsHook)
{
injector::MakeCALL(0x7BF73D, UIQRTrackOptions_Setup, true);
injector::WriteMemory(0x8B7FB8, &UIQRTrackOptions_Setup, true);
// Disable forced 0 AI Opponents in tollbooth
injector::MakeNOP(0x61DC9D, 6, true); // Game_InitRacers()
// Default race settings
injector::MakeJMP(0x58FEA0, cFrontendDatabase_DefaultRaceSettings, true); // 4 references
// Custom race options
injector::MakeJMP(0x56DD20, cFrontendDatabase_FillCustomRace, true); // 2 references
}
if (LANFixes)
{
// Fix Crash
injector::MakeRangedNOP(0x7AA8E7, LANRaceSelectFixCodeCaveExit, true);
injector::MakeJMP(0x7AA8E7, LANRaceSelectFixCodeCave, true);
// Fix Icons and Strings - 1
injector::MakeRangedNOP(0x539562, LANRaceModeFixCodeCaveExit, true);
injector::MakeJMP(0x539562, LANRaceModeFixCodeCave, true);
// Fix Icons and Strings - 2
injector::MakeRangedNOP(0x535E8A, LANRaceModeFixCodeCave2Exit, true);
injector::MakeJMP(0x535E8A, LANRaceModeFixCodeCave2, true);
}
injector::MakeJMP(0x56E090, cFrontendDatabase_GetRaceIconHash, true); // Icon Fixes
injector::MakeJMP(0x56DEA0, cFrontendDatabase_GetMilestoneIconHash, true); // Milestone Icon Fixes
injector::MakeJMP(0x56E010, cFrontendDatabase_GetRaceNameHash, true); // Name Fixes
// Bring Back Cashgrab
injector::MakeJMP(0x58C325, CashgrabLeaderboardCodeCave, true); // LeaderBoard::Update
injector::MakeJMP(0x7AB20C, CashgrabTrackSelectCodeCave, true); // UIQRTrackSelect::RefreshHeader
// Flash cash icon and amount when a cashbag is grabbed
if (ShowCashbagMessage)
{
injector::MakeJMP(0x60E098, AwardPointsCodeCave, true); // Game_AwardPoints
}
// Call NotifyRaceFinished to update score for CashGrab races
injector::MakeJMP(0x58BDEE, CashgrabNotifyRaceFinishedCodeCave, true); // RaceOverMessage::RequestRaceOverMessage
// Results - PostRaceResultsScreen::SetupResults
injector::MakeJMP(0x596500, PostRaceResultsHeadingsCodeCave, true);
injector::MakeJMP(0x5965C9, PostRaceResultsStandingsCodeCave, true);
// Standings - PostRaceResultsScreen::SetupLapStats
injector::WriteMemory<BYTE>(0x59731D, 9, true);
injector::WriteMemory(0x597327, SetupLapStats_JumpTable1, true);
injector::WriteMemory<BYTE>(0x597549, 9, true);
injector::WriteMemory(0x597554, SetupLapStats_JumpTable2, true);
// Stats - PostRaceResultsScreen::SetupRacerStats
injector::WriteMemory<BYTE>(0x597101, 9, true);
injector::WriteMemory(0x597107, SetupRacerStats_JumpTable1, true);
injector::WriteMemory<BYTE>(0x597168, 9, true);
injector::WriteMemory(0x597172, SetupRacerStats_JumpTable2, true);
if (ChallengeSeriesFixes)
{
// Un-hardcode Challenge Series icon
injector::MakeJMP(0x7AE8CA, AddRaceIconCodeCave, true); // UIQRChallengeSeries::AddRace
injector::MakeJMP(0x7A42C4, RefreshHeaderIconCodeCave, true); // UIQRChallengeSeries::RefreshHeader
// Fix custom gauges on pursuits
injector::MakeNOP(0x58C7B4, 2, true); // HudResourceManager::GetCarPart
}
// Outro Movie Fix (BROKEN)
if (OutroFix)
{
//injector::WriteMemory(0x61EA2C, Game_EnterPostRaceFlow, true); // LuaBindery::BindToGameCode
}
return 0;
}