- complete player and replay streams arrays refactoring

This commit is contained in:
InspirationByte 2022-01-15 16:04:12 +03:00
parent d257a42b22
commit 64a024991e
7 changed files with 25 additions and 29 deletions

View File

@ -1305,19 +1305,15 @@ void StepGame(void)
if ((padd & 0x2000U) && (padd & 0x8000U))
padd &= ~0xA000;
i = NumPlayers;
controller_bits = padd;
pl = player;
while (i >= 0)
for (i = 0; i < NumPlayers; i++)
{
pl = &player[i];
if (pl->horn.time == 0 || pl->horn.on == 0)
pl->horn.time = 0;
else
pl->horn.time--;
i--;
pl++;
}
ModifyCamera();

View File

@ -991,11 +991,13 @@ void DrawMultiplayerMap(void)
DrawMultiplayerTargets();
pl = player;
r = 255;
g = 0;
for (i = 0; i < NumPlayers; i++) {
for (i = 0; i < NumPlayers; i++)
{
pl = &player[i];
target.vx = pl->pos[0];
target.vz = pl->pos[2];
@ -1008,8 +1010,6 @@ void DrawMultiplayerMap(void)
DrawPlayerDot(&target, -pl->dir, r, g, 0, 0x8);
pl++;
r++;
g--;
}

View File

@ -246,17 +246,18 @@ void ChangePedPlayerToCar(int playerID, CAR_DATA *newCar)
// [D] [T]
void UpdatePlayers(void)
{
int carId;
PEDESTRIAN *ped;
PLAYER *locPlayer;
int i, carId;
PEDESTRIAN* ped;
PLAYER* locPlayer;
CAR_DATA* cp;
if(CopsAllowed == 0)
if (CopsAllowed == 0)
pedestrianFelony = 0;
locPlayer = player;
for (i = 0; i < MAX_PLAYERS; i++)
{
locPlayer = &player[i];
do {
if (gInGameCutsceneActive == 0)
locPlayer->playerType = (locPlayer->pPed != NULL) ? 2 : 1;
@ -264,31 +265,29 @@ void UpdatePlayers(void)
{
carId = locPlayer->playerCarId;
if(locPlayer->worldCentreCarId >= 0)
locPlayer->spoolXZ = (VECTOR *)car_data[locPlayer->worldCentreCarId].hd.where.t;
if (locPlayer->worldCentreCarId >= 0)
locPlayer->spoolXZ = (VECTOR*)car_data[locPlayer->worldCentreCarId].hd.where.t;
if (carId >= 0)
{
cp = &car_data[carId];
locPlayer->pos[0] = cp->hd.where.t[0];
locPlayer->pos[1] = cp->hd.where.t[1];
locPlayer->pos[2] = cp->hd.where.t[2];
locPlayer->dir = cp->hd.direction;
}
}
else if (locPlayer->playerType == 2)
else if (locPlayer->playerType == 2)
{
ped = locPlayer->pPed;
locPlayer->pos[0] = ped->position.vx;
locPlayer->pos[1] = -ped->position.vy;
locPlayer->pos[2] = ped->position.vz;
locPlayer->dir = ped->dir.vy + -0x800;
locPlayer->dir = ped->dir.vy - 2048;
}
locPlayer++;
} while (locPlayer <= &player[7]);
}
}
// [D] [T]

View File

@ -1,8 +1,6 @@
#ifndef PLAYERS_H
#define PLAYERS_H
#define MAX_PLAYERS 8
extern PLAYER player[MAX_PLAYERS];
extern void InitPlayer(PLAYER *locPlayer, CAR_DATA *cp, char carCtrlType, int direction, LONGVECTOR4* startPos, int externModel, int palette, char *padid); // 0x000739D8

View File

@ -21,7 +21,7 @@ int gOutOfTape = 0;
REPLAY_PARAMETER_BLOCK *ReplayParameterPtr = NULL;
REPLAY_STREAM ReplayStreams[8];
REPLAY_STREAM ReplayStreams[MAX_REPLAY_STREAMS];
int NumReplayStreams = 1;
char *ReplayStart;

View File

@ -4,7 +4,7 @@
extern int gOutOfTape;
extern REPLAY_PARAMETER_BLOCK *ReplayParameterPtr;
extern REPLAY_STREAM ReplayStreams[8];
extern REPLAY_STREAM ReplayStreams[MAX_REPLAY_STREAMS];
extern int NumReplayStreams;
extern char *ReplayStart;

View File

@ -4,6 +4,8 @@
// DRIVER 2 game engine limits
// please populate this file only with engine limits during refactoring
#define MAX_PLAYERS 8 // used for replay streams mostly
#define MAX_MODEL_SLOTS 1536 // DO NOT CHANGE. No effect in upping it - limited by cell types
#define MAX_CARS 20
@ -37,6 +39,7 @@
// replay definitions.
// DO NOT EDIT, breaks compatibility!
#define MAX_REPLAY_STREAMS MAX_PLAYERS
#define MAX_REPLAY_CAMERAS 60
#define MAX_REPLAY_WAYPOINTS 150
#define MAX_REPLAY_PINGS 400