2020-12-28 09:51:40 +01:00
|
|
|
#include "driver2.h"
|
|
|
|
#include "cutscene.h"
|
|
|
|
#include "mission.h"
|
|
|
|
#include "cars.h"
|
|
|
|
#include "players.h"
|
|
|
|
#include "replays.h"
|
|
|
|
#include "gamesnd.h"
|
|
|
|
#include "glaunch.h"
|
|
|
|
#include "civ_ai.h"
|
|
|
|
#include "pedest.h"
|
|
|
|
#include "pres.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "camera.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "mc_snd.h"
|
|
|
|
#include "handling.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "denting.h"
|
|
|
|
#include "pause.h"
|
|
|
|
#include "overmap.h"
|
|
|
|
#include "director.h"
|
|
|
|
#include "xaplay.h"
|
2021-01-19 13:10:45 +01:00
|
|
|
#include "overlay.h"
|
2020-05-18 14:12:37 +02:00
|
|
|
|
2020-09-26 20:20:22 +02:00
|
|
|
int gSkipInGameCutscene = 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-04-12 23:30:03 +02:00
|
|
|
int gInGameCutsceneActive = 0;
|
|
|
|
int gInGameCutsceneDelay = 0;
|
2020-04-17 21:55:31 +02:00
|
|
|
int gInGameChaseActive = 0;
|
|
|
|
int gInGameCutsceneID = -1;
|
2020-05-16 20:10:40 +02:00
|
|
|
int gCutsceneAtEnd = 0;
|
2020-04-17 21:55:31 +02:00
|
|
|
int gThePlayerCar = -1;
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-05-17 09:47:23 +02:00
|
|
|
static int CutsceneStreamIndex = 0;
|
|
|
|
int CutsceneFrameCnt = 0;
|
2020-11-17 17:01:20 +01:00
|
|
|
int NumCutsceneStreams = 0;
|
2020-05-17 09:47:23 +02:00
|
|
|
static int gHaveInGameCutscene = 0;
|
|
|
|
static int gCSDestroyPlayer = 0;
|
|
|
|
static int PreLoadedCutscene = -1;
|
|
|
|
static char *CutsceneReplayStart = NULL;
|
|
|
|
static int CutsceneInReplayBuffer = 0;
|
|
|
|
static int CutsceneLength = 0;
|
|
|
|
static int BlackBorderHeight = 0;
|
|
|
|
int JustReturnedFromCutscene = 0;
|
2020-05-20 20:30:02 +02:00
|
|
|
int CutsceneEventTrigger = 0;
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
CUTSCENE_BUFFER CutsceneBuffer = { 0 };
|
|
|
|
|
|
|
|
static PLAYBACKCAMERA *CutLastChange;
|
|
|
|
static PLAYBACKCAMERA *CutNextChange;
|
|
|
|
PLAYBACKCAMERA *CutsceneCamera = NULL;
|
|
|
|
|
|
|
|
static int CutsceneCameraOffset = 0;
|
|
|
|
|
2020-12-08 20:20:53 +01:00
|
|
|
int LoadInGameCutscene(int subindex);
|
|
|
|
int TriggerInGameCutsceneSystem(int cutscene);
|
|
|
|
void SetNullPlayer(int plr);
|
|
|
|
void SetNullPlayerDontKill(int plr);
|
|
|
|
void DestroyPlayer(int plr, int fully);
|
|
|
|
void FindNextCutChange(int cameracnt);
|
|
|
|
int LoadCutsceneToReplayBuffer(int residentCutscene);
|
|
|
|
int LoadCutsceneToBuffer(int subindex);
|
|
|
|
void ShowCutsceneError();
|
|
|
|
int LoadCutsceneInformation(int cutscene);
|
|
|
|
void FreeCutsceneBuffer();
|
|
|
|
int IsCutsceneResident(int cutscene);
|
|
|
|
|
2020-12-28 11:07:24 +01:00
|
|
|
|
|
|
|
#ifndef PSX
|
|
|
|
char* gCustomCutsceneBuffer;
|
|
|
|
|
|
|
|
char gUserReplayFolderList[MAX_USER_REPLAYS][48];
|
|
|
|
int gNumUserChases = 0;
|
|
|
|
int gUserChaseLoaded = -1;
|
|
|
|
|
2020-11-13 18:23:00 +01:00
|
|
|
// [A] user replay folders initialization
|
|
|
|
void InitUserReplays(const char* str)
|
|
|
|
{
|
|
|
|
int quit;
|
|
|
|
char* ptr;
|
|
|
|
char* strStart;
|
|
|
|
gNumUserChases = 0;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ptr = (char*)str;
|
|
|
|
strStart = NULL;
|
|
|
|
memset(gUserReplayFolderList, 0, sizeof(gUserReplayFolderList));
|
|
|
|
|
|
|
|
quit = 0;
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
if (strStart == NULL)
|
|
|
|
strStart = ptr;
|
|
|
|
|
|
|
|
// if we're encountered string end go on
|
|
|
|
if(*ptr == ',' || *ptr == ' ' || *ptr == '\0')
|
|
|
|
{
|
|
|
|
if (*ptr == '\0')
|
|
|
|
quit = 1;
|
|
|
|
|
|
|
|
*ptr = '\0';
|
|
|
|
strcpy(gUserReplayFolderList[gNumUserChases++], strStart);
|
|
|
|
strStart = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
if (quit)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-08 17:25:40 +02:00
|
|
|
#endif
|
|
|
|
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void InitInGameCutsceneVariables(void)
|
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
CutsceneStreamIndex = 0;
|
|
|
|
CutsceneFrameCnt = 0;
|
|
|
|
NumCutsceneStreams = 0;
|
|
|
|
gHaveInGameCutscene = 0;
|
|
|
|
gInGameChaseActive = 0;
|
|
|
|
gInGameCutsceneActive = 0;
|
|
|
|
gCSDestroyPlayer = 0;
|
|
|
|
PreLoadedCutscene = -1;
|
2020-10-17 09:00:28 +02:00
|
|
|
CutsceneReplayStart = NULL;
|
|
|
|
CutsceneCamera = NULL;
|
2020-04-03 00:42:41 +02:00
|
|
|
CutsceneInReplayBuffer = 0;
|
|
|
|
CutsceneEventTrigger = 0;
|
|
|
|
CutsceneLength = 0;
|
|
|
|
BlackBorderHeight = 0;
|
|
|
|
gInGameCutsceneDelay = 0;
|
|
|
|
gInGameCutsceneID = -1;
|
|
|
|
gCutsceneAtEnd = 0;
|
|
|
|
JustReturnedFromCutscene = 0;
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2020-09-26 20:20:22 +02:00
|
|
|
gSkipInGameCutscene = 0;
|
|
|
|
|
2020-11-13 19:40:56 +01:00
|
|
|
#ifndef PSX
|
|
|
|
gUserChaseLoaded = -1;
|
|
|
|
#endif
|
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
FreeCutsceneBuffer();
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void HandleInGameCutscene(void)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
if (gInGameCutsceneDelay != 0)
|
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
BlackBorderHeight = gInGameCutsceneDelay;
|
2020-05-18 20:34:26 +02:00
|
|
|
gInGameCutsceneDelay++;
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
if (gInGameCutsceneDelay > 27)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
TriggerInGameCutscene(gInGameCutsceneID);
|
|
|
|
gInGameCutsceneDelay = 0;
|
2020-09-07 20:10:08 +02:00
|
|
|
BlackBorderHeight = 28;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (gHaveInGameCutscene == 0)
|
2020-04-03 00:42:41 +02:00
|
|
|
return;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (pauseflag != 0)
|
2020-04-03 00:42:41 +02:00
|
|
|
return;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (CameraCnt < 2)
|
|
|
|
BlackBorderHeight = 28;
|
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
gCameraOffset.vx = 0;
|
|
|
|
gCameraOffset.vy = 0;
|
|
|
|
gCameraOffset.vz = 0;
|
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
if (CutsceneLength-28 < CutsceneFrameCnt)
|
|
|
|
{
|
2020-09-26 20:29:09 +02:00
|
|
|
// disable cutscene skip when it's about to end
|
|
|
|
if (gSkipInGameCutscene)
|
|
|
|
{
|
|
|
|
FastForward = 0;
|
|
|
|
gSkipInGameCutscene = 0;
|
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
if (BlackBorderHeight > 0)
|
|
|
|
BlackBorderHeight--;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
else
|
|
|
|
{
|
2020-09-07 20:10:08 +02:00
|
|
|
if (BlackBorderHeight < 28)
|
|
|
|
BlackBorderHeight++;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
CutsceneFrameCnt++;
|
|
|
|
|
2020-09-26 20:20:22 +02:00
|
|
|
if (gSkipInGameCutscene)
|
|
|
|
{
|
2020-09-26 20:29:09 +02:00
|
|
|
// fast forward and stop XA
|
2020-09-26 20:20:22 +02:00
|
|
|
FastForward = 1;
|
|
|
|
StopXA();
|
|
|
|
UnprepareXA();
|
|
|
|
}
|
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
if (CutsceneFrameCnt == CutsceneLength)
|
|
|
|
{
|
2020-09-26 20:20:22 +02:00
|
|
|
gSkipInGameCutscene = 0;
|
2020-04-03 00:42:41 +02:00
|
|
|
gHaveInGameCutscene = 0;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (gInGameCutsceneActive != 0)
|
2020-04-03 00:42:41 +02:00
|
|
|
JustReturnedFromCutscene = 1;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
ReleaseInGameCutscene();
|
|
|
|
InitOverheadMap();
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void DrawInGameCutscene(void)
|
|
|
|
{
|
2020-06-16 20:20:03 +02:00
|
|
|
TILE *tile;
|
|
|
|
|
2020-10-09 18:12:14 +02:00
|
|
|
#ifndef PSX
|
|
|
|
PrintXASubtitles();
|
|
|
|
#endif
|
|
|
|
|
2020-06-16 20:20:03 +02:00
|
|
|
if (gInGameCutsceneActive == 0 && gInGameCutsceneDelay == 0)
|
2020-11-13 18:23:00 +01:00
|
|
|
{
|
|
|
|
#ifndef PSX
|
2020-11-13 19:40:56 +01:00
|
|
|
if(gInGameChaseActive && gUserChaseLoaded != -1 && (CameraCnt - frameStart) < 200)
|
2020-11-13 18:23:00 +01:00
|
|
|
{
|
|
|
|
// [A] print user chaser name on screen
|
|
|
|
char tempStr[80];
|
|
|
|
|
2021-01-19 13:10:45 +01:00
|
|
|
sprintf(tempStr, "%s %s", G_LTXT(GTXT_GetawayIs), gUserReplayFolderList[gUserChaseLoaded]);
|
2020-11-13 18:23:00 +01:00
|
|
|
|
|
|
|
SetTextColour(128, 128, 64);
|
2021-01-19 13:10:45 +01:00
|
|
|
PrintString(tempStr, gOverlayXPos, 230);
|
2020-11-13 18:23:00 +01:00
|
|
|
}
|
|
|
|
#endif
|
2020-06-16 20:20:03 +02:00
|
|
|
return;
|
2020-11-13 18:23:00 +01:00
|
|
|
}
|
2020-06-16 20:20:03 +02:00
|
|
|
|
|
|
|
tile = (TILE *)current->primptr;
|
|
|
|
SetTile(tile);
|
|
|
|
tile->r0 = 0;
|
|
|
|
tile->g0 = 0;
|
|
|
|
tile->b0 = 0;
|
2020-09-03 09:06:23 +02:00
|
|
|
|
|
|
|
#ifdef PSX
|
2020-06-16 20:20:03 +02:00
|
|
|
tile->x0 = 0;
|
|
|
|
tile->w = 320;
|
2020-09-03 09:06:23 +02:00
|
|
|
#else
|
|
|
|
tile->x0 = -500;
|
|
|
|
tile->w = 1200;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tile->y0 = 0;
|
2020-06-16 20:20:03 +02:00
|
|
|
tile->h = BlackBorderHeight;
|
|
|
|
|
|
|
|
addPrim(current->ot, tile);
|
|
|
|
tile++;
|
|
|
|
|
|
|
|
SetTile(tile);
|
|
|
|
tile->r0 = 0;
|
|
|
|
tile->g0 = 0;
|
|
|
|
tile->b0 = 0;
|
|
|
|
|
2020-09-03 09:06:23 +02:00
|
|
|
#ifdef PSX
|
2020-06-16 20:20:03 +02:00
|
|
|
tile->x0 = 0;
|
|
|
|
tile->w = 320;
|
2020-09-03 09:06:23 +02:00
|
|
|
#else
|
|
|
|
tile->x0 = -500;
|
|
|
|
tile->w = 1200;
|
|
|
|
#endif
|
|
|
|
|
2020-06-16 20:20:03 +02:00
|
|
|
tile->y0 = 256 - BlackBorderHeight;
|
|
|
|
tile->h = BlackBorderHeight;
|
|
|
|
|
|
|
|
addPrim(current->ot, tile);
|
|
|
|
|
|
|
|
current->primptr += sizeof(TILE) * 2;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-04-03 00:42:41 +02:00
|
|
|
void TriggerChase(int *car, int cutscene)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
int *inform;
|
|
|
|
int i;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
inform = car_data[*car].inform;
|
2020-05-17 09:47:23 +02:00
|
|
|
car_data[*car].inform = NULL;
|
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
gInGameChaseActive = TriggerInGameCutsceneSystem(gRandomChase);
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
if (gInGameChaseActive)
|
2020-05-17 09:47:23 +02:00
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
length = 0;
|
|
|
|
|
|
|
|
// find maximum length of cutscene
|
|
|
|
for (i = CutsceneStreamIndex; i < NumReplayStreams; i++)
|
|
|
|
{
|
|
|
|
if (ReplayStreams[i].length > length)
|
|
|
|
length = ReplayStreams[i].length;
|
|
|
|
}
|
2020-05-17 09:47:23 +02:00
|
|
|
|
|
|
|
switch (gCurrentMissionNumber)
|
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 6:
|
|
|
|
case 10:
|
|
|
|
case 18:
|
|
|
|
Mission.timer[0].count = (15000 + (length / 30) * 3000);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Mission.timer[0].count = (length / 30) * 3000 - 15000;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2021-01-29 20:12:56 +01:00
|
|
|
Mission.timer[0].flags = TIMER_FLAG_ACTIVE;
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
*car = CutsceneStreamIndex;
|
|
|
|
player[0].targetCarId = CutsceneStreamIndex;
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
InitLeadHorn();
|
|
|
|
}
|
2020-05-17 09:47:23 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
car_data[*car].inform = inform;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
static int SavedCameraView = 0;
|
|
|
|
static int SavedWorldCentreCarId = 0;
|
|
|
|
static VECTOR *SavedSpoolXZ = NULL;
|
|
|
|
static int SavedCameraCarId = 0;
|
|
|
|
static int SavedCameraAngle = 0;
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void TriggerInGameCutscene(int cutscene)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
if (IsCutsceneResident(cutscene) == 0)
|
|
|
|
return;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
gInGameCutsceneID = cutscene;
|
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CameraCnt < 3 || gInGameCutsceneDelay > 27)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
|
|
|
SavedCameraCarId = player[0].cameraCarId;
|
|
|
|
SavedCameraView = cameraview;
|
|
|
|
SavedWorldCentreCarId = player[0].worldCentreCarId;
|
|
|
|
SavedCameraAngle = gCameraAngle;
|
|
|
|
SavedSpoolXZ = player[0].spoolXZ;
|
|
|
|
|
|
|
|
gInGameCutsceneActive = TriggerInGameCutsceneSystem(cutscene);
|
|
|
|
|
2021-02-23 07:57:30 +01:00
|
|
|
if (gInGameCutsceneActive)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
|
|
|
TerminateSkidding(0);
|
|
|
|
TerminateSkidding(1);
|
|
|
|
|
|
|
|
gStopPadReads = 1;
|
2020-10-17 09:00:28 +02:00
|
|
|
scr_z = 256;
|
2020-05-18 20:51:17 +02:00
|
|
|
|
|
|
|
if (gCSDestroyPlayer)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
DestroyPlayer(0, 1);
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gCutsceneAtEnd = 1;
|
|
|
|
gInGameCutsceneDelay = gInGameCutsceneDelay + 1;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int CalcInGameCutsceneSize(void)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
CUTSCENE_HEADER header;
|
|
|
|
char filename[64];
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
if (gCurrentMissionNumber < 21)
|
2020-05-19 18:57:43 +02:00
|
|
|
sprintf(filename, "REPLAYS\\CUT%d.R", gCurrentMissionNumber);
|
2020-05-18 20:34:26 +02:00
|
|
|
else
|
2020-05-19 18:57:43 +02:00
|
|
|
sprintf(filename, "REPLAYS\\A\\CUT%d.R", gCurrentMissionNumber);
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (FileExists(filename) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
LoadfileSeg(filename, (char *)&header, 0, sizeof(CUTSCENE_HEADER));
|
|
|
|
|
|
|
|
return header.maxsize;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void ReleaseInGameCutscene(void)
|
|
|
|
{
|
2020-09-07 20:10:08 +02:00
|
|
|
int i;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2021-02-23 08:32:38 +01:00
|
|
|
if (gInGameChaseActive && Mission.ChaseTarget)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-05-18 20:51:17 +02:00
|
|
|
player[1].padid = -128;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (gInGameCutsceneActive != 0)
|
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
PingOutAllCivCarsAndCopCars();
|
|
|
|
InitCivCars();
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
for (i = CutsceneStreamIndex; i < NumReplayStreams; i++)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-09-07 20:10:08 +02:00
|
|
|
if (PlayerStartInfo[i]->flags & 4)
|
|
|
|
{
|
2020-12-28 11:07:24 +01:00
|
|
|
memcpy((u_char*)&player[0], (u_char*)&player[i], sizeof(PLAYER));
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
if (player[0].playerType == 2)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-09-07 20:10:08 +02:00
|
|
|
player[0].pPed->padId = 0;
|
|
|
|
SavedWorldCentreCarId = -1;
|
|
|
|
SavedSpoolXZ = (VECTOR *)&player[0].pPed->position;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-09-07 20:10:08 +02:00
|
|
|
else
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-09-07 20:10:08 +02:00
|
|
|
Swap2Cars(player[0].playerCarId, 0);
|
|
|
|
SavedWorldCentreCarId = player[0].playerCarId;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
SavedSpoolXZ = (VECTOR *)car_data[SavedWorldCentreCarId].hd.where.t;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
car_data[SavedWorldCentreCarId].ai.padid = &player[0].padid;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
SavedCameraCarId = SavedWorldCentreCarId;
|
|
|
|
|
|
|
|
DestroyPlayer(i, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DestroyPlayer(i, 1);
|
|
|
|
}
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
gThePlayerCar = -1;
|
2020-05-18 20:34:26 +02:00
|
|
|
player[0].targetCarId = -1;
|
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
DestroyCivPedestrians();
|
|
|
|
AdjustPlayerCarVolume();
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
i = player[0].playerCarId;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
player[0].padid = 0;
|
|
|
|
player[0].worldCentreCarId = SavedWorldCentreCarId;
|
|
|
|
player[0].spoolXZ = SavedSpoolXZ;
|
|
|
|
player[0].cameraCarId = SavedCameraCarId;
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
if (i != -1)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-09-07 20:10:08 +02:00
|
|
|
car_data[i].ai.padid = &player[0].padid;
|
2020-09-27 11:03:11 +02:00
|
|
|
car_data[i].controlType = CONTROL_TYPE_PLAYER;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
cameraview = SavedCameraView;
|
2020-04-03 00:42:41 +02:00
|
|
|
gCameraAngle = SavedCameraAngle;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
InitCamera(&player[0]);
|
|
|
|
|
|
|
|
player[0].cameraAngle = 0;
|
|
|
|
player[0].cameraDist = 1000;
|
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
CutsceneEventTrigger = 0;
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
if (CutsceneReplayStart != NULL)
|
2020-04-03 00:42:41 +02:00
|
|
|
replayptr = CutsceneReplayStart;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-05-19 17:46:05 +02:00
|
|
|
NumReplayStreams -= NumCutsceneStreams;
|
2020-11-17 17:01:20 +01:00
|
|
|
NumCutsceneStreams = 0;
|
2020-05-19 17:46:05 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
CutsceneReplayStart = NULL;
|
2020-04-03 00:42:41 +02:00
|
|
|
CutsceneStreamIndex = 0;
|
2020-11-17 17:01:20 +01:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
PreLoadedCutscene = -1;
|
|
|
|
gHaveInGameCutscene = 0;
|
|
|
|
gCSDestroyPlayer = 0;
|
|
|
|
CutsceneLength = 0;
|
|
|
|
BlackBorderHeight = 0;
|
2020-05-18 20:34:26 +02:00
|
|
|
CutsceneCamera = NULL;
|
2020-04-03 00:42:41 +02:00
|
|
|
gInGameChaseActive = 0;
|
|
|
|
gInGameCutsceneActive = 0;
|
|
|
|
CutsceneFrameCnt = 0;
|
|
|
|
gInGameCutsceneDelay = 0;
|
|
|
|
gStopPadReads = 0;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 07:44:43 +02:00
|
|
|
gCameraOffset.vx = 0;
|
|
|
|
gCameraOffset.vy = 0;
|
|
|
|
gCameraOffset.vz = 0;
|
|
|
|
gCameraMaxDistance = 0;
|
|
|
|
|
2020-09-20 13:25:20 +02:00
|
|
|
xa_timeout = 120;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int PreLoadInGameCutscene(int chase)
|
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
return LoadInGameCutscene(chase) != 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int CutsceneCameraChange(int cameracnt)
|
|
|
|
{
|
2020-05-18 20:51:17 +02:00
|
|
|
cameracnt -= CutsceneCameraOffset;
|
|
|
|
|
|
|
|
if (CutNextChange->FrameCnt != cameracnt)
|
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CutNextChange->FrameCnt > cameracnt)
|
2020-05-18 20:51:17 +02:00
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
IsMovingCamera(CutLastChange, CutNextChange, cameracnt);
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-18 20:51:17 +02:00
|
|
|
|
2021-04-09 18:00:28 +02:00
|
|
|
if (CutNextChange->next == 254)
|
2020-04-03 00:42:41 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2020-05-18 20:51:17 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CutLastChange != CutNextChange && CutNextChange->angle.pad > -1)
|
2020-05-18 20:51:17 +02:00
|
|
|
CutNextChange->angle.pad += CutsceneStreamIndex;
|
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
SetPlaybackCamera(CutNextChange);
|
2020-05-18 20:51:17 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (cameracnt > -1)
|
2020-05-18 20:51:17 +02:00
|
|
|
{
|
|
|
|
InvalidCamera(player[0].cameraCarId);
|
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
CutLastChange = CutNextChange;
|
|
|
|
FindNextCutChange(cameracnt + 1);
|
|
|
|
}
|
2020-05-18 20:51:17 +02:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
return 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int LoadInGameCutscene(int subindex)
|
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
if (CutsceneInReplayBuffer)
|
|
|
|
return LoadCutsceneToBuffer(subindex);
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-12-08 20:50:28 +01:00
|
|
|
if (LoadCutsceneToBuffer(subindex))
|
2020-05-18 14:12:37 +02:00
|
|
|
{
|
2020-12-08 20:50:28 +01:00
|
|
|
if (LoadCutsceneToReplayBuffer(0))
|
2020-05-18 14:12:37 +02:00
|
|
|
{
|
|
|
|
CutsceneInReplayBuffer = 1;
|
|
|
|
PreLoadedCutscene = subindex;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 14:12:37 +02:00
|
|
|
|
|
|
|
FreeCutsceneBuffer();
|
2020-12-08 20:50:28 +01:00
|
|
|
return 1;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-12-08 20:50:28 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int TriggerInGameCutsceneSystem(int cutscene)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
static char padid[8];
|
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
int slot;
|
2020-10-31 01:11:58 +01:00
|
|
|
CAR_DATA *cp;
|
2020-05-18 20:34:26 +02:00
|
|
|
REPLAY_STREAM *stream;
|
2020-04-03 00:42:41 +02:00
|
|
|
int player_id;
|
2020-05-18 20:34:26 +02:00
|
|
|
int bDamageOverride;
|
|
|
|
|
|
|
|
bDamageOverride = 0;
|
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if(cutscene > -1)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
gHaveInGameCutscene = LoadCutsceneInformation(cutscene);
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (gHaveInGameCutscene != 0)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
PingOutAllCivCarsAndCopCars();
|
|
|
|
InitCivCars();
|
|
|
|
DestroyCivPedestrians();
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CutsceneStreamIndex <= player[0].playerCarId)
|
|
|
|
{
|
|
|
|
Swap2Cars(player[0].playerCarId, 0);
|
|
|
|
SavedCameraCarId = player[0].cameraCarId;
|
|
|
|
SavedWorldCentreCarId = player[0].playerCarId;
|
|
|
|
SavedSpoolXZ = player[0].spoolXZ;
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CutsceneEventTrigger != 0)
|
|
|
|
{
|
|
|
|
TriggerEvent(CutsceneEventTrigger);
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
gThePlayerCar = -1;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CutsceneStreamIndex < NumReplayStreams)
|
|
|
|
{
|
|
|
|
stream = ReplayStreams + CutsceneStreamIndex;
|
|
|
|
player_id = CutsceneStreamIndex;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
do {
|
|
|
|
PlayerStartInfo[player_id] = &stream->SourceType;
|
2020-05-19 17:46:05 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if ((stream->SourceType.flags & 4) != 0)
|
2020-05-19 17:46:05 +02:00
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
gCSDestroyPlayer = 1;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (stream->SourceType.type == 1)
|
2020-05-19 17:46:05 +02:00
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
gThePlayerCar = player_id;
|
2020-05-19 17:46:05 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (gCutsceneAtEnd != 0 && player[0].playerType == 1)
|
|
|
|
{
|
|
|
|
stream->SourceType.palette = car_data[player[0].playerCarId].ap.palette;
|
|
|
|
stream->SourceType.model = MissionHeader->residentModels[car_data[player[0].playerCarId].ap.model];
|
|
|
|
|
|
|
|
bDamageOverride = 1;
|
|
|
|
gCutsceneAtEnd = 0;
|
|
|
|
}
|
2020-05-19 17:46:05 +02:00
|
|
|
}
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
padid[player_id] = -player_id;
|
|
|
|
gStartOnFoot = stream->SourceType.type == 2;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (gStartOnFoot || (stream->SourceType.flags & 1) == 0)
|
|
|
|
{
|
|
|
|
TerminateSkidding(player_id);
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
cp = &car_data[player_id];
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
InitPlayer(&player[player_id], cp,
|
|
|
|
stream->SourceType.controlType,
|
|
|
|
stream->SourceType.rotation,
|
2020-12-08 17:45:14 +01:00
|
|
|
(LONGVECTOR4* )&stream->SourceType.position,
|
2020-10-17 09:00:28 +02:00
|
|
|
stream->SourceType.model,
|
|
|
|
stream->SourceType.palette,
|
|
|
|
&padid[player_id]);
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-02-23 08:32:38 +01:00
|
|
|
if (bDamageOverride)
|
2020-10-17 09:00:28 +02:00
|
|
|
{
|
|
|
|
slot = player[0].playerCarId;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
cp->ap.needsDenting = 1;
|
|
|
|
cp->ap.damage[0] = car_data[slot].ap.damage[0];
|
|
|
|
cp->ap.damage[1] = car_data[slot].ap.damage[1];
|
|
|
|
cp->ap.damage[2] = car_data[slot].ap.damage[2];
|
|
|
|
cp->ap.damage[3] = car_data[slot].ap.damage[3];
|
|
|
|
cp->ap.damage[4] = car_data[slot].ap.damage[4];
|
|
|
|
cp->ap.damage[5] = car_data[slot].ap.damage[5];
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
bDamageOverride = 0;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
cp->totalDamage = car_data[slot].totalDamage;
|
|
|
|
DentCar(cp);
|
|
|
|
}
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-10-17 09:00:28 +02:00
|
|
|
else
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
slot = CreateStationaryCivCar(stream->SourceType.rotation, 0, 1024,
|
2020-12-08 17:45:14 +01:00
|
|
|
(LONGVECTOR4* )&stream->SourceType.position,
|
2020-10-17 09:00:28 +02:00
|
|
|
stream->SourceType.model,
|
|
|
|
stream->SourceType.palette, 0);
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (slot != -1)
|
|
|
|
{
|
|
|
|
player[player_id].playerCarId = slot;
|
|
|
|
SetNullPlayer(player_id);
|
|
|
|
}
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-10-17 09:00:28 +02:00
|
|
|
|
|
|
|
if (player_id == CutsceneStreamIndex)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-10-17 09:00:28 +02:00
|
|
|
if (gStartOnFoot == 0)
|
|
|
|
{
|
|
|
|
player[0].spoolXZ = (VECTOR *)car_data[player_id].hd.where.t;
|
|
|
|
player[0].worldCentreCarId = CutsceneStreamIndex;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player[0].worldCentreCarId = -1;
|
|
|
|
player[0].spoolXZ = (VECTOR *)&player[player_id].pPed->position;
|
|
|
|
}
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
if (CutsceneLength < stream->length)
|
|
|
|
CutsceneLength = stream->length;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
stream++;
|
|
|
|
player_id++;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
} while (player_id < NumReplayStreams);
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
CutsceneCameraOffset = CameraCnt + 1;
|
|
|
|
CutNextChange = CutsceneCamera;
|
|
|
|
CutLastChange = NULL;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-10-17 09:00:28 +02:00
|
|
|
|
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
ShowCutsceneError();
|
2020-05-18 20:34:26 +02:00
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void SetNullPlayer(int plr)
|
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
int carId = player[plr].playerCarId;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
if (carId != -1)
|
|
|
|
{
|
2020-09-27 11:03:11 +02:00
|
|
|
car_data[carId].controlType = CONTROL_TYPE_CIV_AI;
|
2020-05-18 14:12:37 +02:00
|
|
|
car_data[carId].ai.c.thrustState = 3;
|
|
|
|
car_data[carId].ai.c.ctrlState = 7;
|
|
|
|
car_data[carId].ai.c.ctrlNode = NULL;
|
2020-10-17 09:00:28 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
player[plr].playerCarId = -1;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 14:12:37 +02:00
|
|
|
|
|
|
|
player[plr].playerType = 3;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void SetNullPlayerDontKill(int plr)
|
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
int carId = player[plr].playerCarId;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
if (carId != -1)
|
|
|
|
{
|
2020-09-27 11:03:11 +02:00
|
|
|
car_data[carId].controlType = CONTROL_TYPE_CUTSCENE;
|
2020-05-18 14:12:37 +02:00
|
|
|
car_data[carId].ai.c.thrustState = 3;
|
|
|
|
car_data[carId].ai.c.ctrlState = 7;
|
|
|
|
car_data[carId].ai.c.ctrlNode = NULL;
|
2020-10-17 09:00:28 +02:00
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
player[plr].playerCarId = -1;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 14:12:37 +02:00
|
|
|
|
|
|
|
player[plr].playerType = 3;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-04-03 00:42:41 +02:00
|
|
|
void DestroyPlayer(int plr, int fully)
|
2020-03-27 21:47:29 +01:00
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
if (PlayerStartInfo[plr]->flags & 2)
|
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
SetNullPlayerDontKill(plr);
|
2020-05-18 14:12:37 +02:00
|
|
|
return;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 14:12:37 +02:00
|
|
|
|
|
|
|
if (fully)
|
|
|
|
{
|
|
|
|
if (player[plr].playerType == 1 && player[plr].playerCarId != gThePlayerCar)
|
|
|
|
PingOutCar(&car_data[player[plr].playerCarId]);
|
|
|
|
|
|
|
|
if (player[plr].pPed != NULL)
|
|
|
|
DestroyPedestrian(player[plr].pPed);
|
|
|
|
}
|
|
|
|
|
|
|
|
player[plr].playerType = 3;
|
|
|
|
player[plr].playerCarId = -1;
|
|
|
|
player[plr].pPed = NULL;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void FindNextCutChange(int cameracnt)
|
|
|
|
{
|
2020-05-18 21:10:55 +02:00
|
|
|
bool found;
|
|
|
|
int nextframe;
|
2020-09-07 20:10:08 +02:00
|
|
|
int count;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 21:10:55 +02:00
|
|
|
found = false;
|
|
|
|
nextframe = 100001;
|
2020-09-07 20:10:08 +02:00
|
|
|
count = 0;
|
2020-05-18 21:10:55 +02:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
do {
|
2020-09-07 20:10:08 +02:00
|
|
|
if (cameracnt <= CutsceneCamera[count].FrameCnt &&
|
|
|
|
CutsceneCamera[count].FrameCnt < nextframe)
|
2020-05-18 21:10:55 +02:00
|
|
|
{
|
|
|
|
found = true;
|
2020-09-07 20:10:08 +02:00
|
|
|
nextframe = CutsceneCamera[count].FrameCnt;
|
|
|
|
CutNextChange = &CutsceneCamera[count];
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 21:10:55 +02:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
count++;
|
2020-10-17 08:45:09 +02:00
|
|
|
} while (count < MAX_REPLAY_CAMERAS);
|
2020-05-18 21:10:55 +02:00
|
|
|
|
|
|
|
if (!found)
|
2020-04-03 00:42:41 +02:00
|
|
|
CutNextChange->next = -2;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int LoadCutsceneToReplayBuffer(int residentCutscene)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
REPLAY_SAVE_HEADER *rheader;
|
|
|
|
REPLAY_STREAM_HEADER *sheader;
|
|
|
|
char *pt;
|
|
|
|
|
|
|
|
rheader = (REPLAY_SAVE_HEADER *)CutsceneBuffer.residentPointers[residentCutscene];
|
|
|
|
|
2021-02-15 17:27:55 +01:00
|
|
|
if (rheader == NULL ||
|
|
|
|
rheader && (rheader->magic != DRIVER2_REPLAY_MAGIC &&
|
|
|
|
rheader->magic != REDRIVER2_CHASE_MAGIC || // [A]
|
|
|
|
rheader->NumReplayStreams == 0) )
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
ShowCutsceneError();
|
2020-05-18 20:34:26 +02:00
|
|
|
return 0;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-20 23:33:21 +02:00
|
|
|
|
2020-11-17 17:01:20 +01:00
|
|
|
CutsceneStreamIndex = NumReplayStreams; //rheader->NumReplayStreams;
|
2020-05-18 20:34:26 +02:00
|
|
|
NumCutsceneStreams = rheader->NumReplayStreams;
|
|
|
|
|
|
|
|
CutsceneReplayStart = replayptr;
|
|
|
|
CutsceneEventTrigger = rheader->CutsceneEvent;
|
|
|
|
|
|
|
|
pt = (char *)(rheader + 1);
|
|
|
|
|
|
|
|
// add to existing replay streams
|
|
|
|
for (int i = NumReplayStreams; i < (NumReplayStreams + rheader->NumReplayStreams); i++)
|
|
|
|
{
|
|
|
|
sheader = (REPLAY_STREAM_HEADER *)pt;
|
|
|
|
pt += sizeof(REPLAY_STREAM_HEADER);
|
|
|
|
|
|
|
|
REPLAY_STREAM* destStream = &ReplayStreams[i];
|
|
|
|
|
|
|
|
// copy source type
|
2020-12-28 11:07:24 +01:00
|
|
|
memcpy((u_char*)&destStream->SourceType, (u_char*)&sheader->SourceType, sizeof(STREAM_SOURCE));
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
// init buffers
|
2020-05-20 20:30:02 +02:00
|
|
|
destStream->InitialPadRecordBuffer = (PADRECORD*)replayptr;
|
|
|
|
destStream->PadRecordBuffer = (PADRECORD*)replayptr;
|
|
|
|
destStream->PadRecordBufferEnd = (PADRECORD *)(replayptr + sheader->Size);
|
2020-10-05 17:26:22 +02:00
|
|
|
destStream->padCount = sheader->Size;
|
2020-05-20 20:30:02 +02:00
|
|
|
destStream->length = sheader->Length;
|
2020-08-10 18:10:01 +02:00
|
|
|
destStream->playbackrun = 0;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-05-20 13:06:29 +02:00
|
|
|
int size = (sheader->Size + sizeof(PADRECORD)) & -4;
|
2020-05-20 10:28:23 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
// copy pad data and advance buffer
|
2021-04-18 21:52:27 +02:00
|
|
|
memcpy((u_char*)replayptr, (u_char*)pt, size);
|
2020-05-20 10:28:23 +02:00
|
|
|
replayptr += size;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-05-20 13:06:29 +02:00
|
|
|
pt += size;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-20 10:28:23 +02:00
|
|
|
|
2020-11-17 17:01:20 +01:00
|
|
|
NumReplayStreams += NumCutsceneStreams;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-02-15 17:27:55 +01:00
|
|
|
// [A] REDRIVER2 chase replays skip cameras
|
|
|
|
if (rheader->magic == REDRIVER2_CHASE_MAGIC)
|
|
|
|
{
|
|
|
|
CutsceneCamera = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// copy cutscene cameras and pings
|
|
|
|
CutsceneCamera = (PLAYBACKCAMERA*)replayptr;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-04-18 21:52:27 +02:00
|
|
|
memcpy((u_char*)CutsceneCamera, (u_char*)pt, sizeof(PLAYBACKCAMERA) * MAX_REPLAY_CAMERAS);
|
2021-02-15 17:27:55 +01:00
|
|
|
replayptr += sizeof(PLAYBACKCAMERA) * MAX_REPLAY_CAMERAS;
|
|
|
|
pt += sizeof(PLAYBACKCAMERA) * MAX_REPLAY_CAMERAS;
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-04-18 21:52:27 +02:00
|
|
|
memcpy((u_char*)PingBuffer, (u_char*)pt, sizeof(PING_PACKET) * MAX_REPLAY_PINGS);
|
2020-05-18 20:34:26 +02:00
|
|
|
PingBufferPos = 0;
|
|
|
|
|
|
|
|
return 1;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-14 04:50:33 +01:00
|
|
|
#ifndef PSX
|
2021-02-15 09:25:39 +01:00
|
|
|
int LoadChaseReplayFromFile(char *filename, int subindex, int userId = -1)
|
2020-11-14 04:50:33 +01:00
|
|
|
{
|
|
|
|
gUserChaseLoaded = userId;
|
|
|
|
|
|
|
|
int size = LoadfileSeg(filename, gCustomCutsceneBuffer, 0, 0xffff);
|
|
|
|
|
|
|
|
if (size != 0)
|
|
|
|
{
|
|
|
|
// load into custom buffer
|
|
|
|
printInfo("Custom chase '%s' loaded\n", filename);
|
|
|
|
|
|
|
|
CutsceneBuffer.residentCutscenes[CutsceneBuffer.numResident] = subindex;
|
|
|
|
CutsceneBuffer.residentPointers[CutsceneBuffer.numResident] = gCustomCutsceneBuffer;
|
|
|
|
CutsceneBuffer.numResident++;
|
|
|
|
|
|
|
|
gCustomCutsceneBuffer += size;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-11-14 04:50:33 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2020-03-27 21:47:29 +01:00
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int LoadCutsceneToBuffer(int subindex)
|
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
int offset;
|
2020-05-18 20:34:26 +02:00
|
|
|
int size;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
CUTSCENE_HEADER header;
|
|
|
|
char filename[64];
|
2021-02-15 09:25:39 +01:00
|
|
|
|
|
|
|
filename[0] = '\0';
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-02-14 22:45:45 +01:00
|
|
|
// try load replacement bundle
|
2021-02-15 09:25:39 +01:00
|
|
|
if(subindex >= 2)
|
|
|
|
{
|
2021-02-14 22:45:45 +01:00
|
|
|
#ifndef PSX
|
2021-02-15 09:25:39 +01:00
|
|
|
int userId = -1;
|
|
|
|
|
|
|
|
// [A] REDRIVER2 PC - custom user chases
|
|
|
|
if (gNumUserChases)
|
|
|
|
{
|
|
|
|
userId = rand() % (gNumUserChases + 1);
|
2021-02-14 22:45:45 +01:00
|
|
|
|
2021-02-15 09:25:39 +01:00
|
|
|
// if random decides to have no user chase - get og or replacement one
|
|
|
|
if (userId == gNumUserChases)
|
|
|
|
userId = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// try loading user chase
|
|
|
|
if (userId != -1)
|
|
|
|
sprintf(filename, "REPLAYS\\UserChases\\%s\\CUT%d_N.R", (char*)gUserReplayFolderList[userId], gCurrentMissionNumber);
|
2021-02-15 17:27:55 +01:00
|
|
|
|
|
|
|
//gUserChaseLoaded = userId;
|
2021-02-14 22:45:45 +01:00
|
|
|
#endif
|
2021-02-15 09:25:39 +01:00
|
|
|
|
|
|
|
if (!FileExists(filename)) // fallback
|
|
|
|
sprintf(filename, "REPLAYS\\ReChases\\CUT%d_N.R", gCurrentMissionNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!FileExists(filename))
|
2021-02-14 22:45:45 +01:00
|
|
|
{
|
|
|
|
if (gCurrentMissionNumber < 21)
|
|
|
|
sprintf(filename, "REPLAYS\\CUT%d.R", gCurrentMissionNumber);
|
|
|
|
else
|
|
|
|
sprintf(filename, "REPLAYS\\A\\CUT%d.R", gCurrentMissionNumber);
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-05-20 17:34:30 +02:00
|
|
|
printInfo("Loading cutscene '%s' (%d)\n", filename, subindex);
|
|
|
|
|
2020-11-14 04:50:33 +01:00
|
|
|
if (FileExists(filename))
|
|
|
|
{
|
|
|
|
LoadfileSeg(filename, (char *)&header, 0, sizeof(CUTSCENE_HEADER));
|
|
|
|
|
|
|
|
if (header.data[subindex].offset != 0xffff)
|
|
|
|
{
|
2020-11-13 18:23:00 +01:00
|
|
|
offset = header.data[subindex].offset * 4;
|
|
|
|
size = header.data[subindex].size;
|
|
|
|
|
2021-02-15 17:27:55 +01:00
|
|
|
if (size > CutsceneBuffer.bytesFree)
|
2020-05-18 20:34:26 +02:00
|
|
|
{
|
2021-02-15 17:27:55 +01:00
|
|
|
printWarning("WARNING - Using leadAI/pathAI buffer for cutscene!\n");
|
|
|
|
|
2021-02-14 22:17:44 +01:00
|
|
|
// load into lead/path AI buffer
|
2021-02-15 17:27:55 +01:00
|
|
|
leadAILoaded = 0;
|
2020-04-03 00:42:41 +02:00
|
|
|
pathAILoaded = 0;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-04-04 11:24:16 +02:00
|
|
|
CutsceneBuffer.currentPointer = (char*)_other_buffer2;
|
2021-02-15 17:27:55 +01:00
|
|
|
CutsceneBuffer.bytesFree = 0xC000;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2021-02-15 17:27:55 +01:00
|
|
|
LoadfileSeg(filename, CutsceneBuffer.currentPointer, offset, size);
|
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
CutsceneBuffer.residentCutscenes[CutsceneBuffer.numResident] = subindex;
|
2020-04-03 00:42:41 +02:00
|
|
|
CutsceneBuffer.residentPointers[CutsceneBuffer.numResident] = CutsceneBuffer.currentPointer;
|
2020-05-18 20:34:26 +02:00
|
|
|
CutsceneBuffer.numResident++;
|
2020-05-20 17:34:30 +02:00
|
|
|
CutsceneBuffer.currentPointer += size;
|
|
|
|
CutsceneBuffer.bytesFree -= size;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
2020-04-03 00:42:41 +02:00
|
|
|
ShowCutsceneError();
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-05-18 14:12:37 +02:00
|
|
|
// [A] From Code Review
|
2020-03-27 21:47:29 +01:00
|
|
|
void ShowCutsceneError(void)
|
|
|
|
{
|
2020-05-18 14:12:37 +02:00
|
|
|
RECT16 rect;
|
|
|
|
|
2021-02-14 22:17:44 +01:00
|
|
|
printError("Cutscene initialisation error!\n");
|
2020-05-18 14:12:37 +02:00
|
|
|
SetDispMask(0);
|
|
|
|
DrawSync(0);
|
|
|
|
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
|
|
|
rect.w = 320;
|
|
|
|
rect.h = 256;
|
|
|
|
|
|
|
|
ClearImage2(&rect, 0,0,0);
|
|
|
|
DrawSync(0);
|
|
|
|
|
|
|
|
SetTextColour(128, 0, 0);
|
|
|
|
PrintStringCentred("CUTSCENE ERROR!", 0x78);
|
|
|
|
|
|
|
|
DrawSync(0);
|
|
|
|
SetDispMask(1);
|
|
|
|
|
|
|
|
VSync(20);
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int LoadCutsceneInformation(int cutscene)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
int i;
|
2020-04-03 00:42:41 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
if (cutscene == PreLoadedCutscene)
|
|
|
|
{
|
2020-04-03 00:42:41 +02:00
|
|
|
PreLoadedCutscene = -1;
|
2020-05-18 20:34:26 +02:00
|
|
|
return 1;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
ReleaseInGameCutscene();
|
|
|
|
|
|
|
|
for(i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if (cutscene == CutsceneBuffer.residentCutscenes[i])
|
|
|
|
{
|
|
|
|
if (LoadCutsceneToReplayBuffer(i))
|
|
|
|
{
|
|
|
|
CutsceneBuffer.residentCutscenes[i] = 0xFF;
|
|
|
|
CutsceneBuffer.residentPointers[i] = NULL;
|
2020-04-03 00:42:41 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
void FreeCutsceneBuffer(void)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
int i;
|
2020-09-07 20:10:08 +02:00
|
|
|
|
2020-05-18 20:34:26 +02:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
CutsceneBuffer.residentCutscenes[i] = -1;
|
|
|
|
CutsceneBuffer.residentPointers[i] = NULL;
|
|
|
|
}
|
2020-04-03 00:42:41 +02:00
|
|
|
|
|
|
|
CutsceneBuffer.numResident = 0;
|
|
|
|
CutsceneBuffer.currentPointer = CutsceneBuffer.buffer;
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
CutsceneBuffer.bytesFree = sizeof(CutsceneBuffer.buffer);
|
|
|
|
ClearMem(CutsceneBuffer.buffer, sizeof(CutsceneBuffer.buffer));
|
2020-10-08 17:25:40 +02:00
|
|
|
|
|
|
|
#ifndef PSX
|
2021-04-04 11:24:16 +02:00
|
|
|
gCustomCutsceneBuffer = (char*)_other_buffer2;
|
2020-10-08 17:25:40 +02:00
|
|
|
#endif
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
2020-09-07 20:10:08 +02:00
|
|
|
// [D] [T]
|
2020-03-27 21:47:29 +01:00
|
|
|
int IsCutsceneResident(int cutscene)
|
|
|
|
{
|
2020-05-18 20:34:26 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (cutscene == PreLoadedCutscene)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if (CutsceneBuffer.residentCutscenes[i] == cutscene)
|
|
|
|
return 1;
|
2020-04-03 00:42:41 +02:00
|
|
|
}
|
2020-05-18 20:34:26 +02:00
|
|
|
|
|
|
|
return 0;
|
2020-03-27 21:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|