From 81370a7273618f8e618755efd59ac1266d330a99 Mon Sep 17 00:00:00 2001 From: Ilya Shurumov Date: Tue, 17 Nov 2020 16:10:59 +0600 Subject: [PATCH] - support reserving car slots (configurable) for cutscene/chase recorder --- src_rebuild/GAME/C/CIV_AI.C | 42 ++++++++++++++++++------------------ src_rebuild/GAME/C/MISSION.C | 13 +++++++++++ src_rebuild/GAME/C/REPLAYS.C | 12 ++++++----- 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src_rebuild/GAME/C/CIV_AI.C b/src_rebuild/GAME/C/CIV_AI.C index 8da91a75..3b898590 100644 --- a/src_rebuild/GAME/C/CIV_AI.C +++ b/src_rebuild/GAME/C/CIV_AI.C @@ -3329,27 +3329,6 @@ int PingInCivCar(int minPingInDist) newCar = NULL; - // find a free slot - carCnt = car_data; - slot = reservedSlots; - - do { - if (carCnt->controlType == CONTROL_TYPE_NONE && *slot == 0) - { - newCar = carCnt; - break; - } - - carCnt++; - slot++; - } while (carCnt < &car_data[MAX_TRAFFIC_CARS]); - - if (newCar == NULL) - { - PingOutCivsOnly = 1; - return 0; - } - ClearMem((char*)&civDat, sizeof(civDat)); baseLoc.vx = player[playerNum].spoolXZ->vx; @@ -3410,6 +3389,27 @@ int PingInCivCar(int minPingInDist) cookieCountStart = cookieCount; + // find a free slot + carCnt = car_data; + slot = reservedSlots; + + do { + if (carCnt->controlType == CONTROL_TYPE_NONE && *slot == 0) + { + newCar = carCnt; + break; + } + + carCnt++; + slot++; + } while (carCnt < &car_data[MAX_TRAFFIC_CARS]); + + if (newCar == NULL) + { + PingOutCivsOnly = 1; + return 0; + } + do { if (cookieCount < maxCookies) cookieCount++; diff --git a/src_rebuild/GAME/C/MISSION.C b/src_rebuild/GAME/C/MISSION.C index fb7761f1..3ffc2bdf 100644 --- a/src_rebuild/GAME/C/MISSION.C +++ b/src_rebuild/GAME/C/MISSION.C @@ -288,6 +288,19 @@ void InitialiseMissionDefaults(void) last_flag = -1; ClearMem((char *)reservedSlots, sizeof(reservedSlots)); + +#ifdef CUTSCENE_RECORDER + // [A] reserve slots to avoid their use for chases + extern int gCutsceneAsReplay; + if (gCutsceneAsReplay) + { + extern int gCutsceneAsReplay_ReserveSlots; + + for (int i = 0; i < gCutsceneAsReplay_ReserveSlots; i++) + reservedSlots[i] = 1; + } +#endif // CUTSCENE_RECORDER + cop_adjust = 0; playercollected[0] = 0; playercollected[1] = 0; diff --git a/src_rebuild/GAME/C/REPLAYS.C b/src_rebuild/GAME/C/REPLAYS.C index 73362e3f..e0585677 100644 --- a/src_rebuild/GAME/C/REPLAYS.C +++ b/src_rebuild/GAME/C/REPLAYS.C @@ -298,6 +298,7 @@ int SaveReplayToBuffer(char *buffer) int gCutsceneAsReplay = 0; int gCutsceneAsReplay_PlayerId = 0; int gCutsceneAsReplay_PlayerChanged = 0; +int gCutsceneAsReplay_ReserveSlots = 2; char gCutsceneRecorderPauseText[64] = { 0 }; char gCurrentChasePauseText[64] = { 0 }; @@ -400,7 +401,12 @@ void LoadCutsceneRecorder(char* configFilename) ini_sget(config, "settings", "mission", "%d", &gCutsceneAsReplay); ini_sget(config, "settings", "baseMission", "%d", &gCurrentMissionNumber); ini_sget(config, "settings", "player", "%d", &gCutsceneAsReplay_PlayerId); + ini_sget(config, "settings", "reserveSlots", "%d", &gCutsceneAsReplay_ReserveSlots); ini_sget(config, "settings", "subindex", "%d", &subindex); + + // totally limited by streams + if(gCutsceneAsReplay_ReserveSlots > 8) + gCutsceneAsReplay_ReserveSlots = 8; if(loadExistingCutscene) { @@ -736,11 +742,7 @@ int StorePingInfo(int cookieCount, int carId) { packet = &PingBuffer[PingBufferPos++]; packet->frame = (CameraCnt - frameStart & 0xffffU); - - if(carId == 1) - packet->carId = MAX_CARS-1; - else - packet->carId = carId; + packet->carId = carId; packet->cookieCount = cookieCount;