Skip to content

Commit e19f22b

Browse files
authored
Merge pull request #101 from OpenDriver2/develop-SoapyMan
Beta finalize
2 parents 0dcc54c + aad351f commit e19f22b

File tree

9 files changed

+190
-21
lines changed

9 files changed

+190
-21
lines changed
0 Bytes
Binary file not shown.
-2 KB
Binary file not shown.

src_rebuild/Game/C/civ_ai.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,6 @@ int dy = 0; // offset 0xAAB44
19271927
int dz = 0; // offset 0xAAB48
19281928

19291929
// [D] [T] [A] - some register is not properly decompiled
1930-
// TODO: store pings
19311930
int PingInCivCar(int minPingInDist)
19321931
{
19331932
int model;
@@ -1990,7 +1989,7 @@ int PingInCivCar(int minPingInDist)
19901989
return 0;
19911990
}
19921991

1993-
if (maxCivCars - 1 <= numCivCars && gInGameChaseActive == 0)
1992+
if (numCivCars >= maxCivCars - 1 && gInGameChaseActive == 0)
19941993
{
19951994
PingOutCivsOnly = 1;
19961995
return 0;

src_rebuild/Game/C/cutrecorder.c

Lines changed: 134 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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"
@@ -18,21 +19,52 @@
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+
2440
int gCutsceneAsReplay = 0;
2541
int gCutsceneAsReplay_PlayerId = 0;
2642
int gCutsceneAsReplay_PlayerChanged = 0;
2743
int gCutsceneAsReplay_ReserveSlots = 2;
2844
char gCutsceneRecorderPauseText[64] = { 0 };
2945
char gCurrentChasePauseText[64] = { 0 };
3046

47+
extern int gDieWithFade;
48+
3149
int CutRec_LoadCutsceneAsReplayFromBuffer(char* buffer);
50+
void InitCutsceneRecorder(char* configFilename);
51+
int LoadCutsceneAsReplay(int subindex);
3252

3353
void 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+
57169
void 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+
136255
void 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;

src_rebuild/Game/C/cutrecorder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ extern int gCutsceneAsReplay_ReserveSlots;
88
extern char gCutsceneRecorderPauseText[64];
99
extern char gCurrentChasePauseText[64];
1010

11+
extern void InitChaseAutoTest(char* configFilename);
1112
extern void InitCutsceneRecorder(char* configFilename);
1213

1314
extern void CutRec_Reset();
15+
extern void CutRec_Step();
16+
extern void CutRec_Draw();
1417
extern int CutRec_StorePingInfo(int cookieCount, int carId);
1518
extern void CutRec_CheckInvalidatePing(int carId, int howHard);
1619
extern void CutRec_NextChase(int dir);
@@ -24,6 +27,8 @@ extern int CutRec_SaveReplayToFile(char* filename);
2427
#ifdef CUTSCENE_RECORDER
2528

2629
#define _CutRec_IsOn() (gCutsceneAsReplay != 0)
30+
#define _CutRec_Step() CutRec_Step()
31+
#define _CutRec_Draw() CutRec_Draw()
2732
#define _CutRec_Reset() CutRec_Reset()
2833
#define _CutRec_StorePingInfo(a,b) CutRec_StorePingInfo(a,b)
2934
#define _CutRec_CheckInvalidatePing(a,b) CutRec_CheckInvalidatePing(a, b)
@@ -37,6 +42,8 @@ extern int CutRec_SaveReplayToFile(char* filename);
3742
#else
3843

3944
#define _CutRec_IsOn() (0)
45+
#define _CutRec_Step() (0)
46+
#define _CutRec_Draw() (0)
4047
#define _CutRec_Reset() (0)
4148
#define _CutRec_StorePingInfo(a,b) (0)
4249
#define _CutRec_CheckInvalidatePing(a,b) (0)

src_rebuild/Game/C/cutscene.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ void TriggerInGameCutscene(int cutscene)
382382
}
383383

384384
// [A] Function detects user chases and re-chases
385-
void SelectCutsceneFile(char* filename, int init, int subindex)
385+
int SelectCutsceneFile(char* filename, int init, int subindex)
386386
{
387387
filename[0] = '\0';
388388

@@ -439,6 +439,8 @@ void SelectCutsceneFile(char* filename, int init, int subindex)
439439
else
440440
sprintf(filename, "REPLAYS\\A\\CUT%d.R", gCurrentMissionNumber);
441441
}
442+
443+
return FileExists(filename);
442444
}
443445

444446
// [D] [T]
@@ -449,13 +451,16 @@ int CalcInGameCutsceneSize(void)
449451

450452
if (NewLevel)
451453
{
454+
ClearMem((char*)&CutsceneHeader, sizeof(CUTSCENE_HEADER));
455+
ClearMem((char*)&ChaseHeader, sizeof(CUTSCENE_HEADER));
456+
452457
// init user/re-chases and load cutscene file header
453-
SelectCutsceneFile(filename, 1, 0);
454-
LoadfileSeg(filename, (char*)&CutsceneHeader, 0, sizeof(CUTSCENE_HEADER));
458+
if(SelectCutsceneFile(filename, 1, 0))
459+
LoadfileSeg(filename, (char*)&CutsceneHeader, 0, sizeof(CUTSCENE_HEADER));
455460

456461
// load re-chase file header
457-
SelectCutsceneFile(filename, 0, 2);
458-
LoadfileSeg(filename, (char*)&ChaseHeader, 0, sizeof(CUTSCENE_HEADER));
462+
if(SelectCutsceneFile(filename, 0, 2))
463+
LoadfileSeg(filename, (char*)&ChaseHeader, 0, sizeof(CUTSCENE_HEADER));
459464

460465
maxSize = 0;
461466
for (i = 2; i < 15; i++)

src_rebuild/Game/C/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,10 +1642,14 @@ void State_GameLoop(void* param)
16421642
while (--cnt >= 0)
16431643
StepGame();
16441644

1645+
_CutRec_Draw();
16451646
DrawGame();
16461647
#endif
1648+
16471649
if (game_over)
16481650
SetState(STATE_GAMECOMPLETE);
1651+
1652+
_CutRec_Step();
16491653
}
16501654

16511655
// TODO: DRAW.C?
@@ -1776,6 +1780,7 @@ void PrintCommandLineArguments()
17761780
" -replay <filename.d2rp> : starts replay from file\n"
17771781
#ifdef CUTSCENE_RECORDER
17781782
" -recordcutscene <filename> : starts cutscene recording session. Specify INI filename with it\n"
1783+
" -chaseautotest <filename> : starts chase autotesting. Specify INI filename with it\n"
17791784
#endif
17801785
" -nointro : disable intro screens\n"
17811786
" -nofmv : disable all FMVs\n";
@@ -2107,6 +2112,16 @@ int redriver2_main(int argc, char** argv)
21072112
i++;
21082113
}
21092114
#ifdef CUTSCENE_RECORDER
2115+
else if (!strcmp(argv[i], "-chaseautotest"))
2116+
{
2117+
SetFEDrawMode();
2118+
2119+
gInFrontend = 0;
2120+
AttractMode = 0;
2121+
2122+
InitChaseAutoTest(argv[i+1]);
2123+
i++;
2124+
}
21102125
else if (!strcmp(argv[i], "-recordcutscene"))
21112126
{
21122127
SetFEDrawMode();

src_rebuild/Game/C/replays.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,15 @@ char GetPingInfo(char *cookieCount)
353353
}
354354

355355
PingBufferPos++;
356-
357-
return retCarId;
358356
}
359357

360-
return -1;
358+
return retCarId;
361359
}
362360

363361
// [A] returns 1 if can use ping buffer
364362
int IsPingInfoAvailable()
365363
{
366-
// [A] loaded replays pings temporarily disabled...
367-
368-
if (gUseStoredPings == 0 || gInGameChaseActive == 0)// && gLoadedReplay == 0)
364+
if (!_CutRec_IsOn() && (gUseStoredPings == 0 || gInGameChaseActive == 0))// && gLoadedReplay == 0)
369365
return 0;
370366

371367
return PingBuffer != NULL && PingBufferPos < MAX_REPLAY_PINGS;

src_rebuild/PsyX/src/psx/LIBETC.C

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,24 @@ long GetVideoMode()
7070
{
7171
return g_vmode;
7272
}
73+
74+
void PadInit(int mode)
75+
{
76+
PSYX_UNIMPLEMENTED();
77+
78+
// TODO: call PadInitDirect
79+
}
80+
81+
u_long PadRead(int id)
82+
{
83+
PSYX_UNIMPLEMENTED();
84+
85+
// TODO: return pad data as u_long
86+
}
87+
88+
void PadStop(void)
89+
{
90+
PSYX_UNIMPLEMENTED();
91+
92+
// TODO: stop pad reads
93+
}

0 commit comments

Comments
 (0)