- support randomized attract replays

- don't forget to init user replays
This commit is contained in:
Ilya Shurumov 2020-11-13 23:48:25 +06:00
parent 44355fd68a
commit dd4daea020
2 changed files with 32 additions and 1 deletions

View File

@ -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;

View File

@ -15,6 +15,7 @@
#include <stdlib.h>
#include <SDL_scancode.h>
#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)
{