REDRIVER2/src_rebuild/GAME/C/PLAYERS.C

483 lines
12 KiB
C

#include "THISDUST.H"
#include "PLAYERS.H"
#include "SYSTEM.H"
#include "MISSION.H"
#include "CIV_AI.H"
#include "COP_AI.H"
#include "PEDEST.H"
#include "CUTSCENE.H"
#include "CARS.H"
// decompiled code
// original method signature:
// void /*$ra*/ InitPlayer(struct _PLAYER *locPlayer /*$s1*/, struct _CAR_DATA *cp /*$s2*/, char carCtrlType /*$s3*/, int direction /*$s6*/, long (*startPos)[4] /*stack 16*/, int externModel /*stack 20*/, int palette /*stack 24*/, char *padid /*stack 28*/)
// line 75, offset 0x000739d8
/* begin block 1 */
// Start line: 76
// Start offset: 0x000739D8
/* end block 1 */
// End offset: 0x00073C0C
// End Line: 127
/* begin block 2 */
// Start line: 454
/* end block 2 */
// End Line: 455
/* begin block 3 */
// Start line: 150
/* end block 3 */
// End Line: 151
PEDESTRIAN *pPlayerPed = NULL;
_PLAYER player[8];
// [D]
void InitPlayer(_PLAYER *locPlayer, _CAR_DATA *cp, char carCtrlType, int direction, long(*startPos)[4], int externModel, int palette, char *padid)
{
int model;
uint playerType;
playerType = externModel & 0xFF;
ClearMem((char *)locPlayer, sizeof(_PLAYER));
if (gStartOnFoot == 0 || carCtrlType == 4)
{
model = 0xFF;
if (MissionHeader->residentModels[0] == playerType)
model = 0;
else if(MissionHeader->residentModels[1] == playerType)
model = 1;
else if (MissionHeader->residentModels[2] == playerType)
model = 2;
else if (MissionHeader->residentModels[3] == playerType)
model = 3;
else if (MissionHeader->residentModels[4] == playerType)
model = 4;
InitCar(cp, direction, startPos, carCtrlType, model, palette & 0xff, &locPlayer->padid);
cp->controlFlags |= 4;
locPlayer->worldCentreCarId = cp->id;
locPlayer->cameraView = (NumPlayers == 2) << 1;
locPlayer->playerCarId = cp->id;
locPlayer->playerType = 1;
locPlayer->spoolXZ = (VECTOR *)cp->hd.where.t;
locPlayer->cameraCarId = cp->id;
locPlayer->car_is_sounding = 0;
locPlayer->pos[1] = cp->hd.where.t[1];
}
else
{
ActivatePlayerPedestrian(NULL, padid, direction, startPos, playerType);
locPlayer->playerType = 2;
locPlayer->spoolXZ = (VECTOR *)&pPlayerPed->position;
locPlayer->playerCarId = -1;
locPlayer->car_is_sounding = 2;
locPlayer->cameraView = 0;
locPlayer->pos[1] = -pPlayerPed->position.vy;
}
locPlayer->pos[0] = (*startPos)[0];
locPlayer->pos[2] = (*startPos)[2];
locPlayer->cameraAngle = 2048;
locPlayer->headPos = 0;
locPlayer->headTarget = 0;
locPlayer->headTimer = 0;
locPlayer->targetCarId = -1;
locPlayer->car_sound_timer = -1;
locPlayer->wheelnoise.chan = -1;
locPlayer->wheelnoise.sound = -1;
locPlayer->skidding.chan = -1;
locPlayer->skidding.sound = -1;
locPlayer->padid = *padid;
}
// decompiled code
// original method signature:
// void /*$ra*/ ChangeCarPlayerToPed(int playerID /*$s0*/)
// line 130, offset 0x00073334
/* begin block 1 */
// Start line: 131
// Start offset: 0x00073334
// Variables:
// struct _CAR_DATA *lcp; // $s2
/* end block 1 */
// End offset: 0x0007350C
// End Line: 181
/* begin block 2 */
// Start line: 260
/* end block 2 */
// End Line: 261
void ChangeCarPlayerToPed(int playerID)
{
UNIMPLEMENTED();
/*
char cVar1;
PEDESTRIAN *pPVar2;
int channel;
int iVar3;
iVar3 = (int)(&player)[playerID].playerCarId;
my_sly_var = playerID;
(&player)[playerID].headTimer = '\0';
(&player)[playerID].cameraView = '\0';
channel = 0x1000;
if (NoPlayerControl == 0) {
channel = car_data[iVar3].hd.direction + 0x600;
}
(&player)[playerID].cameraAngle = channel;
(&player)[playerID].headTimer = '\0';
(&player)[playerID].playerType = '\x02';
channel = gInGameCutsceneActive;
(&player)[playerID].headPos = 0;
(&player)[playerID].headTarget = 0;
(&player)[playerID].playerCarId = -1;
(&player)[playerID].cameraCarId = -1;
(&player)[playerID].targetCarId = -1;
pPVar2 = pPlayerPed;
if ((channel == 0) && (gInGameChaseActive == 0)) {
(&player)[playerID].worldCentreCarId = -1;
(&player)[playerID].spoolXZ = (VECTOR *)&pPVar2->position;
}
channel = 1;
car_data[iVar3].controlType = '\x02';
car_data[iVar3].wheel_angle = 0;
car_data[iVar3].ai[0xf9] = 3;
car_data[iVar3].ai[0xc] = 7;
if (playerID != 0) {
channel = 4;
}
StopChannel(channel);
cVar1 = (&player)[playerID].skidding.chan;
(&player)[playerID].skidding.sound = -1;
StopChannel((int)cVar1);
UnlockChannel((int)(&player)[playerID].skidding.chan);
cVar1 = (&player)[playerID].wheelnoise.chan;
(&player)[playerID].wheelnoise.sound = -1;
StopChannel((int)cVar1);
UnlockChannel((int)(&player)[playerID].wheelnoise.chan);
Start3DSoundVolPitch
(-1, 6, 3, car_data[iVar3].hd.where.t[0], car_data[iVar3].hd.where.t[1],
car_data[iVar3].hd.where.t[2], 0, 0x1000);
first_offence = '\x01';
channel = CarHasSiren((uint)(byte)car_data[iVar3].ap.model);
if (channel != 0) {
(&player)[playerID].horn.on = '\0';
}
return;*/
}
// decompiled code
// original method signature:
// void /*$ra*/ ChangePedPlayerToCar(int playerID /*$s4*/, struct _CAR_DATA *newCar /*$s2*/)
// line 184, offset 0x0007350c
/* begin block 1 */
// Start line: 185
// Start offset: 0x0007350C
// Variables:
// struct _PLAYER *lPlayer; // $s1
// int siren; // $s5
// long *pos; // $s3
// int carParked; // $s6
/* end block 1 */
// End offset: 0x00073898
// End Line: 244
/* begin block 2 */
// Start line: 400
/* end block 2 */
// End Line: 401
/* begin block 3 */
// Start line: 404
/* end block 3 */
// End Line: 405
/* begin block 4 */
// Start line: 408
/* end block 4 */
// End Line: 409
void ChangePedPlayerToCar(int playerID, _CAR_DATA *newCar)
{
UNIMPLEMENTED();
/*
bool bVar1;
char cVar2;
byte bVar3;
bool bVar4;
uint uVar5;
int channel;
uint uVar6;
int channel_00;
long *plVar7;
bVar4 = false;
uVar5 = CarHasSiren((uint)(byte)(newCar->ap).model);
plVar7 = (newCar->hd).where.t;
if ((((newCar->controlType != '\x02') && (newCar->controlType != '\a')) || (newCar->ai[0xf9] != 3)
) || ((newCar->ai[0xc] != 7 && (newCar->ai[0xc] != 5)))) {
bVar4 = true;
}
(&player)[playerID].playerType = '\x01';
(&player)[playerID].playerCarId = newCar->id;
bVar1 = gInGameCutsceneActive == 0;
(&player)[playerID].cameraCarId = newCar->id;
if ((bVar1) && (gInGameChaseActive == 0)) {
cVar2 = newCar->id;
(&player)[playerID].spoolXZ = (VECTOR *)(newCar->hd).where.t;
(&player)[playerID].worldCentreCarId = cVar2;
}
bVar3 = NoPlayerControl;
(&player)[playerID].cameraView = (char)lastCarCameraView;
channel = 0x1000;
if (bVar3 == 0) {
channel = (newCar->hd).direction + 0x600;
}
(&player)[playerID].cameraAngle = channel;
(&player)[playerID].headPos = 0;
(&player)[playerID].headTarget = 0;
(&player)[playerID].headTimer = '\0';
(&player)[playerID].padid = '\0';
(&player)[playerID].pPed = (PEDESTRIAN *)0x0;
if (playerID * 0x74 == 0) {
newCar->controlType = '\x01';
*(undefined4 *)newCar->ai = 0xd9772;
newCar->hndType = '\0';
if ((gCurrentMissionNumber != 0x20) &&
(MissionHeader->residentModels[(byte)(newCar->ap).model] == 0)) {
NoteFelony(&felonyData, '\v', 0x1000);
}
}
if ((gCurrentMissionNumber == 0x21) && ((newCar->ap).model == '\x04')) {
makeLimoPullOver = '\0';
}
Start3DSoundVolPitch(-1, 6, 3, *plVar7, (newCar->hd).where.t[1], (newCar->hd).where.t[2], 0, 0x1000);
bVar3 = (newCar->ap).model;
if (bVar3 == 4) {
uVar6 = ResidentModelsBodge();
}
else {
if (bVar3 < 3) {
uVar6 = (uint)(byte)(newCar->ap).model;
}
else {
uVar6 = (uint)(byte)(newCar->ap).model - 1;
}
}
channel = 1;
if (playerID != 0) {
channel = 4;
}
Start3DSoundVolPitch
(channel, 3, uVar6 * 3 + 1, *plVar7, (newCar->hd).where.t[1], (newCar->hd).where.t[2], -10000,
0x1000);
bVar3 = (newCar->ap).model;
if (bVar3 == 4) {
channel_00 = ResidentModelsBodge();
channel = channel_00 << 1;
}
else {
if (bVar3 < 3) {
channel = (uint)(byte)(newCar->ap).model * 3;
goto LAB_000737d4;
}
channel_00 = (uint)(byte)(newCar->ap).model - 1;
channel = channel_00 * 2;
}
channel = channel + channel_00;
LAB_000737d4:
channel_00 = 0;
if (playerID != 0) {
channel_00 = 3;
}
Start3DSoundVolPitch
(channel_00, 3, channel, *plVar7, (newCar->hd).where.t[1], (newCar->hd).where.t[2], -10000,
0x1000);
if (uVar5 != 0) {
channel = 2;
if (playerID != 0) {
channel = 5;
}
Start3DSoundVolPitch
(channel, (uVar5 & 0xff00) >> 8, uVar5 & 0xff, *plVar7, (newCar->hd).where.t[1],
(newCar->hd).where.t[2], -10000, 0x81);
}
if (bVar4) {
HaveCarSoundStraightAway((char)playerID);
}
else {
RequestSlightPauseBeforeCarSoundStarts((char)playerID);
}
return;
*/
}
// decompiled code
// original method signature:
// void /*$ra*/ UpdatePlayers()
// line 247, offset 0x00073898
/* begin block 1 */
// Start line: 249
// Start offset: 0x00073898
// Variables:
// struct _PLAYER *locPlayer; // $t0
// struct _CAR_DATA *cp; // $v1
/* end block 1 */
// End offset: 0x000739D8
// End Line: 286
/* begin block 2 */
// Start line: 550
/* end block 2 */
// End Line: 551
/* begin block 3 */
// Start line: 554
/* end block 3 */
// End Line: 555
/* begin block 4 */
// Start line: 555
/* end block 4 */
// End Line: 556
/* begin block 5 */
// Start line: 561
/* end block 5 */
// End Line: 562
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
void UpdatePlayers(void)
{
int carId;
PEDESTRIAN *ped;
_PLAYER *locPlayer;
pedestrianFelony = 0;
if (gInGameCutsceneActive == 0)
player[0].playerType = (player[0].pPed != NULL) ? 2 : 1;
locPlayer = player;
// [A] cycle might be wrong
do {
if (locPlayer->playerType == 1)
{
carId = locPlayer->playerCarId;
locPlayer->spoolXZ = (VECTOR *)car_data[locPlayer->worldCentreCarId].hd.where.t;
locPlayer->pos[0] = car_data[carId].hd.where.t[0];
locPlayer->pos[1] = car_data[carId].hd.where.t[1];
locPlayer->pos[2] = car_data[carId].hd.where.t[2];
locPlayer->dir = car_data[carId].hd.direction;
}
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++;
} while (locPlayer <= &player[7]);
}
// decompiled code
// original method signature:
// void /*$ra*/ RequestSlightPauseBeforeCarSoundStarts(char player_id /*$a0*/)
// line 298, offset 0x00073c0c
/* begin block 1 */
// Start line: 771
/* end block 1 */
// End Line: 772
/* begin block 2 */
// Start line: 943
/* end block 2 */
// End Line: 944
void RequestSlightPauseBeforeCarSoundStarts(char player_id)
{
UNIMPLEMENTED();
/*
uint uVar1;
uVar1 = (uint)(byte)player_id;
(&player)[uVar1].car_is_sounding = '\x02';
(&player)[uVar1].car_sound_timer = 10;
(&player)[uVar1].idlevol = -10000;
(&player)[uVar1].revsvol = -10000;
return;
*/
}
// decompiled code
// original method signature:
// void /*$ra*/ HaveCarSoundStraightAway(char player_id /*$a0*/)
// line 305, offset 0x00073c54
/* begin block 1 */
// Start line: 960
/* end block 1 */
// End Line: 961
void HaveCarSoundStraightAway(char player_id)
{
UNIMPLEMENTED();
/*
(&player)[(byte)player_id].car_is_sounding = '\0';
(&player)[(byte)player_id].car_sound_timer = -1;
return;
*/
}
// decompiled code
// original method signature:
// void /*$ra*/ MakeTheCarShutUp(char player_id /*$a0*/)
// line 310, offset 0x00073c8c
/* begin block 1 */
// Start line: 971
/* end block 1 */
// End Line: 972
void MakeTheCarShutUp(char player_id)
{
UNIMPLEMENTED();
/*
(&player)[(byte)player_id].car_is_sounding = '\x01';
(&player)[(byte)player_id].car_sound_timer = -1;
return;
*/
}