- support reserving car slots (configurable) for cutscene/chase recorder

This commit is contained in:
Ilya Shurumov 2020-11-17 16:10:59 +06:00
parent 109ecfa036
commit 81370a7273
3 changed files with 41 additions and 26 deletions

View File

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

View File

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

View File

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