- added chase auto-testing code

This commit is contained in:
Ilya Shurumov 2021-05-18 21:05:53 +06:00 committed by InspirationByte
parent da9561e873
commit df0b895d42
5 changed files with 114 additions and 16 deletions

View File

@ -1927,7 +1927,6 @@ int dy = 0; // offset 0xAAB44
int dz = 0; // offset 0xAAB48
// [D] [T] [A] - some register is not properly decompiled
// TODO: store pings
int PingInCivCar(int minPingInDist)
{
int model;
@ -1990,7 +1989,7 @@ int PingInCivCar(int minPingInDist)
return 0;
}
if (maxCivCars - 1 <= numCivCars && gInGameChaseActive == 0)
if (numCivCars >= maxCivCars - 1 && gInGameChaseActive == 0)
{
PingOutCivsOnly = 1;
return 0;

View File

@ -1,6 +1,7 @@
#ifdef PSX
#error This file is not applicable for PSX build
#endif
#ifdef CUTSCENE_RECORDER
#include "driver2.h"
@ -18,9 +19,13 @@
#include "replays.h"
#include "state.h"
#include "system.h"
#include "pause.h"
#include "pres.h"
#include "../utils/ini.h"
int gCutsceneAsReplay_HitCars = 0;
int gCutsceneChaseAutoTest = 0;
int gCutsceneAsReplay = 0;
int gCutsceneAsReplay_PlayerId = 0;
int gCutsceneAsReplay_PlayerChanged = 0;
@ -29,9 +34,18 @@ char gCutsceneRecorderPauseText[64] = { 0 };
char gCurrentChasePauseText[64] = { 0 };
int CutRec_LoadCutsceneAsReplayFromBuffer(char* buffer);
void InitCutsceneRecorder(char* configFilename);
int LoadCutsceneAsReplay(int subindex);
void CutRec_Reset()
{
if (gCutsceneChaseAutoTest != 0)
{
gCutsceneAsReplay_HitCars = 0;
return;
}
gCutsceneChaseAutoTest = 0;
gCutsceneAsReplay = 0;
gCutsceneAsReplay_PlayerId = 0;
gCutsceneAsReplay_PlayerChanged = 0;
@ -54,9 +68,61 @@ void CutRec_NextChase(int dir)
sprintf(gCurrentChasePauseText, "Chase ID: %d", gChaseNumber);
}
void CutRec_Step()
{
if (!pauseflag)
return;
if(gCutsceneChaseAutoTest != 0)
{
gCutsceneChaseAutoTest++;
if(gCutsceneChaseAutoTest < 15)
{
// load next replay and restart
if (LoadCutsceneAsReplay(gCutsceneChaseAutoTest))
{
State_GameComplete(NULL);
gDrawPauseMenus = 0;
gLoadedReplay = 1;
CurrentGameMode = GAMEMODE_REPLAY;
SetState(STATE_GAMELAUNCH);
}
}
else
{
// auto-test complete
gCutsceneChaseAutoTest = 0;
}
}
}
void CutRec_Draw()
{
char text[64];
if (gCutsceneAsReplay == 0)
return;
SetTextColour(128, 128, 128);
if (gCutsceneAsReplay_HitCars > 0)
SetTextColour(128, 0, 0);
sprintf(text, "Hit cars %d", gCutsceneAsReplay_HitCars);
PrintString(text, 15, 140);
if(gCutsceneChaseAutoTest)
{
sprintf(text, "Chase %d", gCutsceneChaseAutoTest);
PrintString(text, 15, 120);
}
}
void CutRec_ReserveSlots()
{
// [A] reserve slots to avoid their use for chases
if (gCutsceneAsReplay == 0)
return;
@ -104,10 +170,14 @@ int LoadCutsceneAsReplay(int subindex)
CUTSCENE_HEADER header;
char filename[64];
if (gCutsceneAsReplay < 21)
sprintf(filename, "REPLAYS\\CUT%d.R", gCutsceneAsReplay);
else
sprintf(filename, "REPLAYS\\A\\CUT%d.R", gCutsceneAsReplay);
//sprintf(filename, "REPLAYS\\ReChases\\CUT%d_N.R", gCutsceneAsReplay);
//if(!FileExists(filename))
{
if (gCutsceneAsReplay < 21)
sprintf(filename, "REPLAYS\\CUT%d.R", gCutsceneAsReplay);
else
sprintf(filename, "REPLAYS\\A\\CUT%d.R", gCutsceneAsReplay);
}
if (FileExists(filename))
{
@ -118,8 +188,6 @@ int LoadCutsceneAsReplay(int subindex)
offset = header.data[subindex].offset * 4;
size = header.data[subindex].size;
printWarning("cutscene size: %d\n", size);
LoadfileSeg(filename, (char*)_other_buffer, offset, size);
int result = CutRec_LoadCutsceneAsReplayFromBuffer((char*)_other_buffer);
@ -133,6 +201,12 @@ int LoadCutsceneAsReplay(int subindex)
return 0;
}
void InitChaseAutoTest(char* configFilename)
{
gCutsceneChaseAutoTest = 2;
InitCutsceneRecorder(configFilename);
}
void InitCutsceneRecorder(char* configFilename)
{
ini_t* config;
@ -163,6 +237,11 @@ void InitCutsceneRecorder(char* configFilename)
if (loadExistingCutscene)
{
if(gCutsceneChaseAutoTest != 0)
{
subindex = gCutsceneChaseAutoTest;
}
if (!LoadCutsceneAsReplay(subindex))
{
ini_free(config);
@ -255,6 +334,8 @@ void CutRec_CheckInvalidatePing(int carId, int howHard)
if (howHard < 60000)
return;
gCutsceneAsReplay_HitCars++;
pos = PingBufferPos;
while (pos >= 0)
@ -275,7 +356,7 @@ int CutRec_InitPlayers()
{
if (gCutsceneAsReplay == 0)
return 0;
for (int i = 0; i < NumReplayStreams; i++)
{
PlayerStartInfo[i] = &ReplayStreams[i].SourceType;

View File

@ -8,9 +8,12 @@ extern int gCutsceneAsReplay_ReserveSlots;
extern char gCutsceneRecorderPauseText[64];
extern char gCurrentChasePauseText[64];
extern void InitChaseAutoTest(char* configFilename);
extern void InitCutsceneRecorder(char* configFilename);
extern void CutRec_Reset();
extern void CutRec_Step();
extern void CutRec_Draw();
extern int CutRec_StorePingInfo(int cookieCount, int carId);
extern void CutRec_CheckInvalidatePing(int carId, int howHard);
extern void CutRec_NextChase(int dir);
@ -24,6 +27,8 @@ extern int CutRec_SaveReplayToFile(char* filename);
#ifdef CUTSCENE_RECORDER
#define _CutRec_IsOn() (gCutsceneAsReplay != 0)
#define _CutRec_Step() CutRec_Step()
#define _CutRec_Draw() CutRec_Draw()
#define _CutRec_Reset() CutRec_Reset()
#define _CutRec_StorePingInfo(a,b) CutRec_StorePingInfo(a,b)
#define _CutRec_CheckInvalidatePing(a,b) CutRec_CheckInvalidatePing(a, b)
@ -37,6 +42,8 @@ extern int CutRec_SaveReplayToFile(char* filename);
#else
#define _CutRec_IsOn() (0)
#define _CutRec_Step() (0)
#define _CutRec_Draw() (0)
#define _CutRec_Reset() (0)
#define _CutRec_StorePingInfo(a,b) (0)
#define _CutRec_CheckInvalidatePing(a,b) (0)

View File

@ -1642,10 +1642,14 @@ void State_GameLoop(void* param)
while (--cnt >= 0)
StepGame();
_CutRec_Draw();
DrawGame();
#endif
if (game_over)
SetState(STATE_GAMECOMPLETE);
_CutRec_Step();
}
// TODO: DRAW.C?
@ -1776,6 +1780,7 @@ void PrintCommandLineArguments()
" -replay <filename.d2rp> : starts replay from file\n"
#ifdef CUTSCENE_RECORDER
" -recordcutscene <filename> : starts cutscene recording session. Specify INI filename with it\n"
" -chaseautotest <filename> : starts chase autotesting. Specify INI filename with it\n"
#endif
" -nointro : disable intro screens\n"
" -nofmv : disable all FMVs\n";
@ -2107,6 +2112,16 @@ int redriver2_main(int argc, char** argv)
i++;
}
#ifdef CUTSCENE_RECORDER
else if (!strcmp(argv[i], "-chaseautotest"))
{
SetFEDrawMode();
gInFrontend = 0;
AttractMode = 0;
InitChaseAutoTest(argv[i+1]);
i++;
}
else if (!strcmp(argv[i], "-recordcutscene"))
{
SetFEDrawMode();

View File

@ -353,19 +353,15 @@ char GetPingInfo(char *cookieCount)
}
PingBufferPos++;
return retCarId;
}
return -1;
return retCarId;
}
// [A] returns 1 if can use ping buffer
int IsPingInfoAvailable()
{
// [A] loaded replays pings temporarily disabled...
if (gUseStoredPings == 0 || gInGameChaseActive == 0)// && gLoadedReplay == 0)
if (!_CutRec_IsOn() && (gUseStoredPings == 0 || gInGameChaseActive == 0))// && gLoadedReplay == 0)
return 0;
return PingBuffer != NULL && PingBufferPos < MAX_REPLAY_PINGS;