From 04cffeb37c3a504cbab96bb458c7050ff0dfdb80 Mon Sep 17 00:00:00 2001 From: InspirationByte Date: Sat, 15 Jan 2022 16:27:38 +0300 Subject: [PATCH] - cutscene recorder to handle pedestrian pads recording --- src_rebuild/Game/C/cutrecorder.c | 23 ++++++- src_rebuild/Game/C/cutrecorder.h | 5 +- src_rebuild/Game/C/main.c | 104 +++++++++++++++---------------- 3 files changed, 77 insertions(+), 55 deletions(-) diff --git a/src_rebuild/Game/C/cutrecorder.c b/src_rebuild/Game/C/cutrecorder.c index d9a09731..85aadd83 100644 --- a/src_rebuild/Game/C/cutrecorder.c +++ b/src_rebuild/Game/C/cutrecorder.c @@ -775,7 +775,7 @@ int CutRec_SaveChase() return 0; } -int CutRec_RecordPad(CAR_DATA* cp, uint* t0, char* t1, char* t2) +int CutRec_RecordCarPad(CAR_DATA* cp, uint* t0, char* t1, char* t2) { if (gCutsceneAsReplay == 0 || NoPlayerControl || (-*cp->ai.padid) != gCutsceneAsReplay_PlayerId) return 0; @@ -800,6 +800,27 @@ int CutRec_RecordPad(CAR_DATA* cp, uint* t0, char* t1, char* t2) return 1; } +int CutRec_RecordPad(PLAYER* pl, uint* t0, char* t1, char* t2) +{ + if (gCutsceneAsReplay == 0 || NoPlayerControl || (-pl->padid) != gCutsceneAsReplay_PlayerId) + return 0; + + *t0 = Pads[0].mapped; + *t1 = Pads[0].mapanalog[2]; + *t2 = Pads[0].type & 4; + + // [A] handle REDRIVER2 dedicated car entry button + if (*t0 & TANNER_PAD_ACTION_DED) + { + *t0 &= ~TANNER_PAD_ACTION_DED; + *t0 |= TANNER_PAD_ACTION; + } + + cjpRecord(-pl->padid, t0, t1, t2); + + return 1; +} + int CutRec_IsRecording() { if (gCutsceneAsReplay == 0) diff --git a/src_rebuild/Game/C/cutrecorder.h b/src_rebuild/Game/C/cutrecorder.h index a7a24bdf..4863b529 100644 --- a/src_rebuild/Game/C/cutrecorder.h +++ b/src_rebuild/Game/C/cutrecorder.h @@ -25,7 +25,8 @@ extern void CutRec_ReserveSlots(); extern void CutRec_HandleCarRequest(); extern int CutRec_InitPlayers(); extern int CutRec_InitMission(char* filename); -extern int CutRec_RecordPad(CAR_DATA* cp, uint* t0, char* t1, char* t2); +extern int CutRec_RecordCarPad(CAR_DATA* cp, uint* t0, char* t1, char* t2); +extern int CutRec_RecordPad(PLAYER* pl, uint* t0, char* t1, char* t2); extern int CutRec_SaveChase(); #ifdef CUTSCENE_RECORDER @@ -44,6 +45,7 @@ extern int CutRec_SaveChase(); #define _CutRec_HandleCarRequest() CutRec_HandleCarRequest() #define _CutRec_InitPlayers() CutRec_InitPlayers() #define _CutRec_InitMission(a) CutRec_InitMission(a) +#define _CutRec_RecordCarPad(a, b, c, d) CutRec_RecordCarPad(a, b, c, d) #define _CutRec_RecordPad(a, b, c, d) CutRec_RecordPad(a, b, c, d) #else @@ -62,6 +64,7 @@ extern int CutRec_SaveChase(); #define _CutRec_HandleCarRequest() (0) #define _CutRec_InitPlayers() (0) #define _CutRec_InitMission(a) (0) +#define _CutRec_RecordCarPad(a, b, c, d) (0) #define _CutRec_RecordPad(a, b, c, d) (0) #endif diff --git a/src_rebuild/Game/C/main.c b/src_rebuild/Game/C/main.c index 6581a008..5f9eae54 100644 --- a/src_rebuild/Game/C/main.c +++ b/src_rebuild/Game/C/main.c @@ -1061,7 +1061,7 @@ void StepSim(void) break; case CONTROL_TYPE_CUTSCENE: - if (!_CutRec_RecordPad(cp, &t0, &t1, &t2)) + if (!_CutRec_RecordCarPad(cp, &t0, &t1, &t2)) cjpPlay(-*cp->ai.padid, &t0, &t1, &t2); ProcessCarPad(cp, t0, t1, t2); @@ -1081,64 +1081,62 @@ void StepSim(void) stream = pl->padid; - if (stream < 0) + if (stream < 0) // Is cutscene stream? { - if (cjpPlay(-stream, &t0, &t1, &t2) != 0) + if (!_CutRec_RecordPad(pl, &t0, &t1, &t2) && cjpPlay(-stream, &t0, &t1, &t2) != 0) ProcessTannerPad(pl->pPed, t0, t1, t2); + + continue; + } + + if (Pads[stream].type == 4) + { + padAcc = Pads[stream].mapanalog[3]; + + // walk back + if (padAcc < -64) + { + if(padAcc < -100) + Pads[stream].mapped |= 0x1000; + else + Pads[stream].mapped |= 0x1008; + } + else if (padAcc > 32) + { + stream = pl->padid; + Pads[stream].mapped |= 0x4000; + } + } + + t0 = Pads[stream].mapped; + t1 = Pads[stream].mapanalog[2]; + t2 = Pads[stream].type & 4; + + // [A] handle REDRIVER2 dedicated car entry button + if (t0 & TANNER_PAD_ACTION_DED) + { + t0 &= ~TANNER_PAD_ACTION_DED; + t0 |= TANNER_PAD_ACTION; + } + + if (NoPlayerControl == 0) + { + if (gStopPadReads) + { + t2 = 0; + t1 = 0; + t0 = 0; + } + + cjpRecord(stream, &t0, &t1, &t2); } else { - if (Pads[stream].type == 4) - { - padAcc = Pads[stream].mapanalog[3]; - - // walk back - if (padAcc < -64) - { - if(padAcc < -100) - Pads[stream].mapped |= 0x1000; - else - Pads[stream].mapped |= 0x1008; - } - else if (padAcc > 32) - { - stream = pl->padid; - Pads[stream].mapped |= 0x4000; - } - } - - stream = pl->padid; - - t0 = Pads[stream].mapped; - t1 = Pads[stream].mapanalog[2]; - t2 = Pads[stream].type & 4; - - // [A] handle REDRIVER2 dedicated car entry button - if (t0 & TANNER_PAD_ACTION_DED) - { - t0 &= ~TANNER_PAD_ACTION_DED; - t0 |= TANNER_PAD_ACTION; - } - - if (NoPlayerControl == 0) - { - if (gStopPadReads) - { - t2 = 0; - t1 = 0; - t0 = 0; - } - - cjpRecord(stream, &t0, &t1, &t2); - } - else - { - if (cjpPlay(stream, &t0, &t1, &t2) == 0) - continue; - } - - ProcessTannerPad(pl->pPed, t0, t1, t2); + if (cjpPlay(stream, &t0, &t1, &t2) == 0) + continue; } + + ProcessTannerPad(pl->pPed, t0, t1, t2); } if (requestStationaryCivCar == 1 && (numCivCars < maxCivCars || (PingOutCar(&car_data[furthestCivID]), numCivCars < maxCivCars)))