11#ifdef PSX
22#error This file is not applicable for PSX build
33#endif
4+
45#ifdef CUTSCENE_RECORDER
56
67#include "driver2.h"
1819#include "replays.h"
1920#include "state.h"
2021#include "system.h"
22+ #include "pause.h"
23+ #include "pres.h"
24+ #include "players.h"
2125
2226#include "../utils/ini.h"
2327
28+ typedef struct AutoTestStats
29+ {
30+ int numHitCars ;
31+ int numHitWalls ;
32+ int stuck ;
33+ } ;
34+
35+ AutoTestStats gAutoTestStats [15 ];
36+
37+ int gCutsceneChaseAutoTest = 0 ;
38+ int gChaseStuckTimer = 0 ;
39+
2440int gCutsceneAsReplay = 0 ;
2541int gCutsceneAsReplay_PlayerId = 0 ;
2642int gCutsceneAsReplay_PlayerChanged = 0 ;
2743int gCutsceneAsReplay_ReserveSlots = 2 ;
2844char gCutsceneRecorderPauseText [64 ] = { 0 };
2945char gCurrentChasePauseText [64 ] = { 0 };
3046
47+ extern int gDieWithFade ;
48+
3149int CutRec_LoadCutsceneAsReplayFromBuffer (char * buffer );
50+ void InitCutsceneRecorder (char * configFilename );
51+ int LoadCutsceneAsReplay (int subindex );
3252
3353void CutRec_Reset ()
3454{
55+ if (gCutsceneChaseAutoTest != 0 && gCutsceneChaseAutoTest < 15 )
56+ {
57+ gAutoTestStats [gCutsceneChaseAutoTest ].numHitCars = 0 ;
58+ gAutoTestStats [gCutsceneChaseAutoTest ].numHitWalls = 0 ;
59+ gAutoTestStats [gCutsceneChaseAutoTest ].stuck = 0 ;
60+ gChaseStuckTimer = 0 ;
61+
62+ return ;
63+ }
64+
65+ gCutsceneChaseAutoTest = 0 ;
3566 gCutsceneAsReplay = 0 ;
67+
3668 gCutsceneAsReplay_PlayerId = 0 ;
3769 gCutsceneAsReplay_PlayerChanged = 0 ;
3870 gCutsceneAsReplay_ReserveSlots = 2 ;
@@ -54,9 +86,88 @@ void CutRec_NextChase(int dir)
5486 sprintf (gCurrentChasePauseText , "Chase ID: %d" , gChaseNumber );
5587}
5688
89+ void CutRec_Step ()
90+ {
91+ 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+ gChaseStuckTimer = 0 ;
106+ }
107+ }
108+
109+ return ;
110+ }
111+
112+ if (gCutsceneChaseAutoTest != 0 && gCutsceneChaseAutoTest < 15 &&
113+ NoPlayerControl && ReplayParameterPtr -> RecordingEnd - 2 < CameraCnt || gDieWithFade )
114+ {
115+ gCutsceneChaseAutoTest ++ ;
116+
117+ // load next replay and restart
118+ if (gCutsceneChaseAutoTest < 15 &&
119+ LoadCutsceneAsReplay (gCutsceneChaseAutoTest ))
120+ {
121+ State_GameComplete (NULL );
122+
123+ gDrawPauseMenus = 0 ;
124+ gLoadedReplay = 1 ;
125+ CurrentGameMode = GAMEMODE_REPLAY ;
126+
127+ SetState (STATE_GAMELAUNCH );
128+ }
129+ else
130+ {
131+ printInfo ("------- AUTOTEST RESULTS -------\n" );
132+ for (int i = 0 ; i < 15 ; i ++ )
133+ printInfo (" chase %d - hit cars: %d, stuck: %d\n" , i , gAutoTestStats [i ].numHitCars , gAutoTestStats [i ].stuck );
134+ printInfo ("------- ---------------- -------\n" );
135+ }
136+ }
137+ }
138+
139+ void CutRec_Draw ()
140+ {
141+ char text [64 ];
142+
143+ if (gCutsceneAsReplay == 0 )
144+ return ;
145+
146+ SetTextColour (128 , 128 , 128 );
147+
148+ if (gCutsceneChaseAutoTest )
149+ {
150+ sprintf (text , "Chase: %d - frame %d of %d" , gCutsceneChaseAutoTest , CameraCnt , ReplayParameterPtr -> RecordingEnd );
151+ PrintString (text , 5 , 120 );
152+ }
153+
154+ if (gAutoTestStats [gCutsceneChaseAutoTest ].numHitCars > 0 )
155+ SetTextColour (128 , 0 , 0 );
156+
157+ sprintf (text , "Hit cars: %d" , gAutoTestStats [gCutsceneChaseAutoTest ].numHitCars );
158+ PrintString (text , 5 , 140 );
159+
160+ if (gAutoTestStats [gCutsceneChaseAutoTest ].stuck )
161+ {
162+ SetTextColour (128 , 0 , 0 );
163+
164+ sprintf (text , "Car is stuck!" );
165+ PrintString (text , 5 , 60 );
166+ }
167+ }
168+
57169void CutRec_ReserveSlots ()
58170{
59- // [A] reserve slots to avoid their use for chases
60171 if (gCutsceneAsReplay == 0 )
61172 return ;
62173
@@ -104,10 +215,14 @@ int LoadCutsceneAsReplay(int subindex)
104215 CUTSCENE_HEADER header ;
105216 char filename [64 ];
106217
107- if (gCutsceneAsReplay < 21 )
108- sprintf (filename , "REPLAYS\\CUT%d.R" , gCutsceneAsReplay );
109- else
110- sprintf (filename , "REPLAYS\\A\\CUT%d.R" , gCutsceneAsReplay );
218+ //sprintf(filename, "REPLAYS\\ReChases\\CUT%d_N.R", gCutsceneAsReplay);
219+ //if(!FileExists(filename))
220+ {
221+ if (gCutsceneAsReplay < 21 )
222+ sprintf (filename , "REPLAYS\\CUT%d.R" , gCutsceneAsReplay );
223+ else
224+ sprintf (filename , "REPLAYS\\A\\CUT%d.R" , gCutsceneAsReplay );
225+ }
111226
112227 if (FileExists (filename ))
113228 {
@@ -118,8 +233,6 @@ int LoadCutsceneAsReplay(int subindex)
118233 offset = header .data [subindex ].offset * 4 ;
119234 size = header .data [subindex ].size ;
120235
121- printWarning ("cutscene size: %d\n" , size );
122-
123236 LoadfileSeg (filename , (char * )_other_buffer , offset , size );
124237
125238 int result = CutRec_LoadCutsceneAsReplayFromBuffer ((char * )_other_buffer );
@@ -133,6 +246,12 @@ int LoadCutsceneAsReplay(int subindex)
133246 return 0 ;
134247}
135248
249+ void InitChaseAutoTest (char * configFilename )
250+ {
251+ gCutsceneChaseAutoTest = 2 ;
252+ InitCutsceneRecorder (configFilename );
253+ }
254+
136255void InitCutsceneRecorder (char * configFilename )
137256{
138257 ini_t * config ;
@@ -163,6 +282,11 @@ void InitCutsceneRecorder(char* configFilename)
163282
164283 if (loadExistingCutscene )
165284 {
285+ if (gCutsceneChaseAutoTest != 0 )
286+ {
287+ subindex = gCutsceneChaseAutoTest ;
288+ }
289+
166290 if (!LoadCutsceneAsReplay (subindex ))
167291 {
168292 ini_free (config );
@@ -255,6 +379,8 @@ void CutRec_CheckInvalidatePing(int carId, int howHard)
255379 if (howHard < 60000 )
256380 return ;
257381
382+ gAutoTestStats [gCutsceneChaseAutoTest ].numHitCars ++ ;
383+
258384 pos = PingBufferPos ;
259385
260386 while (pos >= 0 )
@@ -275,7 +401,7 @@ int CutRec_InitPlayers()
275401{
276402 if (gCutsceneAsReplay == 0 )
277403 return 0 ;
278-
404+
279405 for (int i = 0 ; i < NumReplayStreams ; i ++ )
280406 {
281407 PlayerStartInfo [i ] = & ReplayStreams [i ].SourceType ;
0 commit comments