From dd4daea0205da55b9ddf75ad817a1181061de814 Mon Sep 17 00:00:00 2001 From: Ilya Shurumov Date: Fri, 13 Nov 2020 23:48:25 +0600 Subject: [PATCH] - support randomized attract replays - don't forget to init user replays --- src_rebuild/GAME/C/REPLAYS.C | 28 ++++++++++++++++++++++++++++ src_rebuild/redriver2_psxpc.cpp | 5 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src_rebuild/GAME/C/REPLAYS.C b/src_rebuild/GAME/C/REPLAYS.C index 2a3af3f0..291aa65a 100644 --- a/src_rebuild/GAME/C/REPLAYS.C +++ b/src_rebuild/GAME/C/REPLAYS.C @@ -12,6 +12,7 @@ #include "CIV_AI.H" #include "STRINGS.H" +#include "RAND.H" char AnalogueUnpack[16] = { 0, -51, -63, -75, -87, -99, -111, -123, @@ -616,7 +617,34 @@ int LoadAttractReplay(int mission) { char filename[32]; +#ifndef PSX + int userFolderId; + + // [A] REDRIVER2 PC - custom attract replays + if (gNumUserChases) + { + userFolderId = rand() % (gNumUserChases + 1); + + if (userFolderId == gNumUserChases) + userFolderId = -1; + + if (userFolderId >= 0) + { + // optional randomization + sprintf(filename, "REPLAYS\\ATTRACT.%d.%s", mission, gUserReplayFolderList[userFolderId]); + + if (!FileExists(filename)) + userFolderId = -1; + } + } + else + userFolderId = -1; + + if(userFolderId == -1) + sprintf(filename,"REPLAYS\\ATTRACT.%d", mission); +#else sprintf(filename,"REPLAYS\\ATTRACT.%d", mission); +#endif if (!FileExists(filename)) return 0; diff --git a/src_rebuild/redriver2_psxpc.cpp b/src_rebuild/redriver2_psxpc.cpp index 4df381d2..d4e29f10 100644 --- a/src_rebuild/redriver2_psxpc.cpp +++ b/src_rebuild/redriver2_psxpc.cpp @@ -15,6 +15,7 @@ #include #include +#include "C/CUTSCENE.H" // eq engine console output @@ -412,6 +413,9 @@ int main(int argc, char** argv) if (config) { const char* dataFolderStr = ini_get(config, "fs", "dataFolder"); + const char* userReplaysStr = ini_get(config, "game", "userChases"); + + InitUserReplays(userReplaysStr); ini_sget(config, "render", "windowWidth", "%d", &windowWidth); ini_sget(config, "render", "windowHeight", "%d", &windowHeight); @@ -422,7 +426,6 @@ int main(int argc, char** argv) ini_sget(config, "game", "drawDistance", "%d", &gDrawDistance); ini_sget(config, "game", "freeCamera", "%d", &enableFreecamera); ini_sget(config, "game", "driver1music", "%d", &gDriver1Music); - if (dataFolderStr) {