Skip to content

Commit 1e05d11

Browse files
committed
- chase autotest now tracks hit cars and stuck, added on-screen display & re-recording support
1 parent 5b973a4 commit 1e05d11

1 file changed

Lines changed: 69 additions & 25 deletions

File tree

src_rebuild/Game/C/cutrecorder.c

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,50 @@
2121
#include "system.h"
2222
#include "pause.h"
2323
#include "pres.h"
24+
#include "players.h"
2425

2526
#include "../utils/ini.h"
2627

27-
int gCutsceneAsReplay_HitCars = 0;
28+
typedef struct AutoTestStats
29+
{
30+
int numHitCars;
31+
int numHitWalls;
32+
int stuck;
33+
};
34+
35+
AutoTestStats gAutoTestStats[15];
36+
2837
int gCutsceneChaseAutoTest = 0;
38+
int gChaseStuckTimer = 0;
39+
2940
int gCutsceneAsReplay = 0;
3041
int gCutsceneAsReplay_PlayerId = 0;
3142
int gCutsceneAsReplay_PlayerChanged = 0;
3243
int gCutsceneAsReplay_ReserveSlots = 2;
3344
char gCutsceneRecorderPauseText[64] = { 0 };
3445
char gCurrentChasePauseText[64] = { 0 };
3546

47+
extern PAUSEMODE PauseMode;
48+
3649
int CutRec_LoadCutsceneAsReplayFromBuffer(char* buffer);
3750
void InitCutsceneRecorder(char* configFilename);
3851
int LoadCutsceneAsReplay(int subindex);
3952

4053
void CutRec_Reset()
4154
{
42-
if (gCutsceneChaseAutoTest != 0)
55+
if (gCutsceneChaseAutoTest != 0 && gCutsceneChaseAutoTest < 15)
4356
{
44-
gCutsceneAsReplay_HitCars = 0;
57+
gAutoTestStats[gCutsceneChaseAutoTest].numHitCars = 0;
58+
gAutoTestStats[gCutsceneChaseAutoTest].numHitWalls = 0;
59+
gAutoTestStats[gCutsceneChaseAutoTest].stuck = 0;
60+
gChaseStuckTimer = 0;
61+
4562
return;
4663
}
47-
64+
4865
gCutsceneChaseAutoTest = 0;
4966
gCutsceneAsReplay = 0;
67+
5068
gCutsceneAsReplay_PlayerId = 0;
5169
gCutsceneAsReplay_PlayerChanged = 0;
5270
gCutsceneAsReplay_ReserveSlots = 2;
@@ -71,30 +89,48 @@ void CutRec_NextChase(int dir)
7189
void CutRec_Step()
7290
{
7391
if (!pauseflag)
92+
{
93+
if(gCutsceneChaseAutoTest != 0)
94+
{
95+
int carId = player[gCutsceneAsReplay_PlayerId].playerCarId;
96+
97+
if (car_data[carId].hd.speed < 5)
98+
gChaseStuckTimer++;
99+
else
100+
gChaseStuckTimer = 0;
101+
102+
if(gChaseStuckTimer > 45)
103+
{
104+
gAutoTestStats[gCutsceneChaseAutoTest].stuck = 1;
105+
}
106+
}
107+
74108
return;
75-
76-
if(gCutsceneChaseAutoTest != 0)
109+
}
110+
111+
if(gCutsceneChaseAutoTest != 0 && gCutsceneChaseAutoTest < 15 &&
112+
NoPlayerControl && ReplayParameterPtr->RecordingEnd - 2 < CameraCnt)
77113
{
78114
gCutsceneChaseAutoTest++;
79115

80-
if(gCutsceneChaseAutoTest < 15)
116+
// load next replay and restart
117+
if (gCutsceneChaseAutoTest < 15 &&
118+
LoadCutsceneAsReplay(gCutsceneChaseAutoTest))
81119
{
82-
// load next replay and restart
83-
if (LoadCutsceneAsReplay(gCutsceneChaseAutoTest))
84-
{
85-
State_GameComplete(NULL);
120+
State_GameComplete(NULL);
86121

87-
gDrawPauseMenus = 0;
88-
gLoadedReplay = 1;
89-
CurrentGameMode = GAMEMODE_REPLAY;
122+
gDrawPauseMenus = 0;
123+
gLoadedReplay = 1;
124+
CurrentGameMode = GAMEMODE_REPLAY;
90125

91-
SetState(STATE_GAMELAUNCH);
92-
}
126+
SetState(STATE_GAMELAUNCH);
93127
}
94128
else
95129
{
96-
// auto-test complete
97-
gCutsceneChaseAutoTest = 0;
130+
printInfo("------- AUTOTEST RESULTS -------\n");
131+
for(int i = 0; i < 15; i++)
132+
printInfo(" chase %d - hit cars: %d, stuck: %d\n", i, gAutoTestStats[i].numHitCars, gAutoTestStats[i].stuck);
133+
printInfo("------- ---------------- -------\n");
98134
}
99135
}
100136
}
@@ -108,16 +144,24 @@ void CutRec_Draw()
108144

109145
SetTextColour(128, 128, 128);
110146

111-
if (gCutsceneAsReplay_HitCars > 0)
147+
if(gCutsceneChaseAutoTest)
148+
{
149+
sprintf(text, "Chase: %d", gCutsceneChaseAutoTest);
150+
PrintString(text, 5, 120);
151+
}
152+
153+
if (gAutoTestStats[gCutsceneChaseAutoTest].numHitCars > 0)
112154
SetTextColour(128, 0, 0);
113155

114-
sprintf(text, "Hit cars %d", gCutsceneAsReplay_HitCars);
115-
PrintString(text, 15, 140);
156+
sprintf(text, "Hit cars: %d", gAutoTestStats[gCutsceneChaseAutoTest].numHitCars);
157+
PrintString(text, 5, 140);
116158

117-
if(gCutsceneChaseAutoTest)
159+
if(gAutoTestStats[gCutsceneChaseAutoTest].stuck)
118160
{
119-
sprintf(text, "Chase %d", gCutsceneChaseAutoTest);
120-
PrintString(text, 15, 120);
161+
SetTextColour(128, 0, 0);
162+
163+
sprintf(text, "Car is stuck!");
164+
PrintString(text, 5, 60);
121165
}
122166
}
123167

@@ -334,7 +378,7 @@ void CutRec_CheckInvalidatePing(int carId, int howHard)
334378
if (howHard < 60000)
335379
return;
336380

337-
gCutsceneAsReplay_HitCars++;
381+
gAutoTestStats[gCutsceneChaseAutoTest].numHitCars++;
338382

339383
pos = PingBufferPos;
340384

0 commit comments

Comments
 (0)