Skip to content

Commit 463753e

Browse files
authored
Merge pull request #9 from nahimr/fix-cutscene-tool
Refactoring cutscene tool and allow intro/outro to be packed without chases
2 parents c057a2d + e2530da commit 463753e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

Driver2CutsceneTool/cutscene_tool.cpp

+13-16
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,12 @@ void PackCutsceneFile(const char* foldername)
260260

261261
int numCutsceneReplays = 0;
262262
int numChaseReplays = 0;
263-
bool hasChases = false;
264263
for (int i = 0; i < MAX_FILE_CUTSCENES; i++)
265264
{
266265
String folderPath = String::fromPrintf("%s/%s_%d.D2RP", foldername, foldername, i);
267266
FILE* fp = fopen(String::fromPrintf("%s/%s_%d.D2RP", foldername, foldername, i), "rb");
268267
if (fp)
269268
{
270-
if (i > 1) hasChases = true;
271269
if (i == 0)
272270
{
273271
MsgAccept("Got intro cutscene\n");
@@ -368,7 +366,7 @@ void PackCutsceneFile(const char* foldername)
368366
MsgWarning("No chase replays\n");
369367
}
370368

371-
String folderPath = String::fromPrintf("%s.R", foldername);
369+
String folderPath = String::fromPrintf(replays[0] || replays[1] ? "%s.R" : "%s_N.R", foldername);
372370

373371
FILE* wp = fopen(folderPath, "wb");
374372

@@ -387,7 +385,7 @@ void PackCutsceneFile(const char* foldername)
387385
char* bufptr = buffer;
388386
offset = 2048;
389387

390-
for (int i = 0; i < (hasChases ? MAX_FILE_CUTSCENES : 2); i++)
388+
for (int i = 0; i < MAX_FILE_CUTSCENES; i++)
391389
{
392390
int replayId = i;
393391

@@ -400,27 +398,26 @@ void PackCutsceneFile(const char* foldername)
400398
if (i == 0 || i == 1)
401399
continue;
402400

403-
if (numChaseReplays > 0)
401+
if (numChaseReplays < 1) break;
402+
403+
do
404404
{
405-
do
406-
{
407-
replayId = 2 + (rand() % (MAX_FILE_CUTSCENES - 2));
408-
} while (replayId == i || !replays[replayId]);
409-
MsgInfo("Picked random replay %d for chase %d\n", replayId, i);
410-
}
405+
replayId = 2 + (rand() % (MAX_FILE_CUTSCENES - 2));
406+
} while (replayId == i || !replays[replayId]);
407+
MsgInfo("Picked random replay %d for chase %d\n", replayId, i);
411408
}
412-
409+
413410
// write to file
414411
memcpy(bufptr, replays[replayId], repsizes[replayId]);
415-
412+
416413
header.data[i].offset = offset / 4; // because it use shorts we have an multiplier
417414
header.data[i].size = repsizes[replayId];
418-
415+
419416
int sizeStep = ((repsizes[replayId] + 1024) / 2048) * 2048;
420-
417+
421418
if (sizeStep < 2048)
422419
sizeStep = 2048;
423-
420+
424421
bufptr += sizeStep;
425422
offset += sizeStep;
426423
}

0 commit comments

Comments
 (0)