- chase recorder - auto delete cars after hard collision

This commit is contained in:
Ilya Shurumov 2021-05-04 22:36:05 +06:00
parent 13b7486685
commit 3a34de9b7b
4 changed files with 63 additions and 46 deletions

View File

@ -2927,16 +2927,14 @@ void SetUpCivCollFlags(void)
dont = 0;
i = 0;
do {
for (i = 0; i < 2; i++)
{
if (horncarflag[i] == cp0)
{
dont = 1;
break;
}
i++;
} while (i < 2);
}
if (dont)
{
@ -2944,8 +2942,8 @@ void SetUpCivCollFlags(void)
continue;
}
i = 0;
do {
for (i = 0; i < 2; i++)
{
if (hornchanflag[i] == 0)
{
int sample;
@ -2972,9 +2970,7 @@ void SetUpCivCollFlags(void)
channels[hornchanflag[i]].time += rnd - (rnd / 30) * 30;
break;
}
i++;
} while (i < 2);
}
}
}
@ -2985,8 +2981,8 @@ void SetUpCivCollFlags(void)
}
// clear on timeout
i = 0;
do {
for (i = 0; i < 2; i++)
{
if (hornchanflag[i] != 0 && channels[hornchanflag[i]].time == 0)
{
horncarflag[i] = NULL;
@ -2994,10 +2990,7 @@ void SetUpCivCollFlags(void)
SpuSetVoiceAR(0, 35);
}
i++;
} while (i < 2);
}
}
// [D] [T]

View File

@ -432,6 +432,13 @@ void CarHitByPlayer(CAR_DATA *victim, int howHard)
{
char type;
#ifdef CUTSCENE_RECORDER
extern void InvalidatePing(int carId);
if(howHard > 60000)
InvalidatePing(victim->id);
#endif
if (howHard > 0 && victim->controlType != CONTROL_TYPE_PURSUER_AI)
{
if ((victim->controlFlags & 1) == 0)

View File

@ -937,26 +937,20 @@ void StepSim(void)
// control civcars pingin/pingout
if (requestStationaryCivCar != 1 && requestRoadblock == 0)
{
if (gInGameChaseActive == 0)
if (gInGameChaseActive)
{
if (numCivCars < maxCivCars && (NumPlayers == 1 || (NumPlayers == 2 && GameType == GAME_COPSANDROBBERS)))
{
// make 5 tries
for (i = 0; i < 5; i++)
{
if (PingInCivCar(15900))
break;
}
}
}
else
{
// ping buffer used to spawn civ cars
i = 0;
while (i < 10 && PingBufferPos < 400 && PingBuffer[PingBufferPos].frame <= (CameraCnt - frameStart & 0xffffU))
{
// it will use ping buffer
// checks are done internally
for (i = 0; i < 10; i++)
PingInCivCar(15900);
i++;
}
else if (numCivCars < maxCivCars && (NumPlayers == 1 || (NumPlayers == 2 && GameType == GAME_COPSANDROBBERS)))
{
// make 5 tries
for (i = 0; i < 5; i++)
{
if (PingInCivCar(15900))
break;
}
}

View File

@ -9,6 +9,7 @@
#include "mission.h"
#include "director.h"
#include "camera.h"
#include "cars.h"
#include "civ_ai.h"
#include "state.h"
@ -563,24 +564,21 @@ char GetPingInfo(char *cookieCount)
retCarId = -1;
pp = PingBuffer + PingBufferPos;
if (PingBuffer != NULL && PingBufferPos < MAX_REPLAY_PINGS)
if (PingBuffer && PingBufferPos < MAX_REPLAY_PINGS)
{
if (pp->frame != 0xffff)
pp = &PingBuffer[PingBufferPos];
// accept only valid car pings
if (pp->frame != 0xFFFF)
{
if ((CameraCnt - frameStart & 0xffffU) < pp->frame)
if (CameraCnt - frameStart < pp->frame)
return -1;
retCarId = pp->carId;
*cookieCount = pp->cookieCount;
}
PingBufferPos++;
}
else
{
printInfo("-1 frame!\n");
}
PingBufferPos++;
return retCarId;
}
@ -604,7 +602,7 @@ int StorePingInfo(int cookieCount, int carId)
if(PingBuffer != NULL && PingBufferPos < MAX_REPLAY_PINGS)
{
packet = &PingBuffer[PingBufferPos++];
packet->frame = (CameraCnt - frameStart & 0xffffU);
packet->frame = CameraCnt - frameStart;
packet->carId = carId;
packet->cookieCount = cookieCount;
@ -615,6 +613,31 @@ int StorePingInfo(int cookieCount, int carId)
return 0;
}
#ifdef CUTSCENE_RECORDER
void InvalidatePing(int carId)
{
int pos;
if (gCutsceneAsReplay == 0)
return;
pos = PingBufferPos;
while(pos >= 0)
{
pos--;
if (PingBuffer[pos].carId == carId)
{
printWarning("Removing ping at %d\n", PingBuffer[pos].frame);
PingBuffer[pos].carId = -1;
PingOutCar(&car_data[carId]);
break;
}
}
}
#endif
// [A] returns 1 if can use ping buffer
int IsPingInfoAvailable()
{