- 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,9 +937,14 @@ 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)))
// it will use ping buffer
// checks are done internally
for (i = 0; i < 10; i++)
PingInCivCar(15900);
}
else if (numCivCars < maxCivCars && (NumPlayers == 1 || (NumPlayers == 2 && GameType == GAME_COPSANDROBBERS)))
{
// make 5 tries
for (i = 0; i < 5; i++)
@ -948,17 +953,6 @@ void StepSim(void)
break;
}
}
}
else
{
// ping buffer used to spawn civ cars
i = 0;
while (i < 10 && PingBufferPos < 400 && PingBuffer[PingBufferPos].frame <= (CameraCnt - frameStart & 0xffffU))
{
PingInCivCar(15900);
i++;
}
}
SetUpCivCollFlags();
}

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 && PingBufferPos < MAX_REPLAY_PINGS)
{
pp = &PingBuffer[PingBufferPos];
if (PingBuffer != NULL && PingBufferPos < MAX_REPLAY_PINGS)
// accept only valid car pings
if (pp->frame != 0xFFFF)
{
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");
}
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()
{