- Exhumed: made all nPlayer variables ints

This looks safe
This commit is contained in:
Christoph Oelckers 2021-11-16 18:50:02 +01:00
parent b9b4f1e037
commit 4f493d3de1
13 changed files with 70 additions and 70 deletions

View file

@ -97,7 +97,7 @@ enum { kMaxGrenades = 50 };
void BuildGrenade(int nPlayer);
void DestroyGrenade(short nGrenade);
void ThrowGrenade(short nPlayer, int edx, int ebx, int ecx, int push1);
void ThrowGrenade(int nPlayer, int edx, int ebx, int ecx, int push1);
void FuncGrenade(int, int, int, int);
// gun
@ -130,18 +130,18 @@ struct Weapon
extern Weapon WeaponInfo[];
extern short nTemperature[];
void RestoreMinAmmo(short nPlayer);
void FillWeapons(short nPlayer);
void ResetPlayerWeapons(short nPlayer);
void RestoreMinAmmo(int nPlayer);
void FillWeapons(int nPlayer);
void ResetPlayerWeapons(int nPlayer);
void InitWeapons();
void SetNewWeapon(short nPlayer, short nWeapon);
void SetNewWeaponImmediate(short nPlayer, short nWeapon);
void SetNewWeaponIfBetter(short nPlayer, short nWeapon);
void SelectNewWeapon(short nPlayer);
void StopFiringWeapon(short nPlayer);
void FireWeapon(short nPlayer);
void CheckClip(short nPlayer);
void MoveWeapons(short nPlayer);
void SetNewWeapon(int nPlayer, short nWeapon);
void SetNewWeaponImmediate(int nPlayer, short nWeapon);
void SetNewWeaponIfBetter(int nPlayer, short nWeapon);
void SelectNewWeapon(int nPlayer);
void StopFiringWeapon(int nPlayer);
void FireWeapon(int nPlayer);
void CheckClip(int nPlayer);
void MoveWeapons(int nPlayer);
void DrawWeapons(double smooth);
// items
@ -160,10 +160,10 @@ extern short nItemMagic[];
void BuildItemAnim(DExhumedActor* nSprite);
void ItemFlash();
void FillItems(short nPlayer);
void UseItem(short nPlayer, int nItem);
void UseCurItem(short nPlayer);
int GrabItem(short nPlayer, int nItem);
void FillItems(int nPlayer);
void UseItem(int nPlayer, int nItem);
void UseCurItem(int nPlayer);
int GrabItem(int nPlayer, int nItem);
void DropMagic(DExhumedActor* actor);
void InitItems();
void StartRegenerate(DExhumedActor* nSprite);
@ -318,16 +318,16 @@ struct RA
short nRun;
short field_A;
short field_C;
short nPlayer;
int nPlayer;
};
// ra
extern RA Ra[];
void FreeRa(short nPlayer);
void BuildRa(short nPlayer);
void FreeRa(int nPlayer);
void BuildRa(int nPlayer);
void InitRa();
void MoveRaToEnemy(short nPlayer);
void MoveRaToEnemy(int nPlayer);
void FuncRa(int, int, int, int);
// rat
@ -741,7 +741,7 @@ extern FreeListArray<Snake, kMaxSnakes> SnakeList;
void InitSnakes();
short GrabSnake();
void BuildSnake(short nPlayer, short zVal);
void BuildSnake(int nPlayer, short zVal);
void FuncSnake(int, int, int, int);
// spider

View file

@ -470,7 +470,7 @@ HITSPRITE:
auto hitsprite = &hitactor->s();
if (pSprite->pal == 5 && hitsprite->statnum == 100)
{
short nPlayer = GetPlayerFromActor(hitactor);
int nPlayer = GetPlayerFromActor(hitactor);
if (!PlayerList[nPlayer].bIsMummified)
{
PlayerList[nPlayer].bIsMummified = true;

View file

@ -47,7 +47,7 @@ void BounceGrenade(DExhumedActor* pActor, int nAngle)
D3PlayFX(StaticSound[kSound3], pActor);
}
void ThrowGrenade(short nPlayer, int, int, int ecx, int push1)
void ThrowGrenade(int nPlayer, int, int, int ecx, int push1)
{
if (PlayerList[nPlayer].pPlayerGrenade == nullptr)
return;
@ -231,7 +231,7 @@ void AIGrenade::Tick(RunListEvent* ev)
pActor->nIndex2--;
if (!pActor->nIndex2)
{
short nPlayer = pGrenadeSprite->owner;
int nPlayer = pGrenadeSprite->owner;
if (pActor->nTurn < 0)
{

View file

@ -73,7 +73,7 @@ void SerializeGun(FSerializer& arc)
}
}
void RestoreMinAmmo(short nPlayer)
void RestoreMinAmmo(int nPlayer)
{
for (int i = 0; i < kMaxWeapons; i++)
{
@ -92,7 +92,7 @@ void RestoreMinAmmo(short nPlayer)
CheckClip(nPlayer);
}
void FillWeapons(short nPlayer)
void FillWeapons(int nPlayer)
{
PlayerList[nPlayer].nPlayerWeapons = 0xFFFF; // turn on all bits
@ -106,7 +106,7 @@ void FillWeapons(short nPlayer)
CheckClip(nPlayer);
}
void ResetPlayerWeapons(short nPlayer)
void ResetPlayerWeapons(int nPlayer)
{
for (int i = 0; i < kMaxWeapons; i++)
{
@ -126,7 +126,7 @@ void InitWeapons()
for (auto& p : PlayerList) p.pPlayerGrenade = nullptr;
}
void SetNewWeapon(short nPlayer, short nWeapon)
void SetNewWeapon(int nPlayer, short nWeapon)
{
if (nWeapon == kWeaponMummified)
{
@ -167,7 +167,7 @@ void SetNewWeapon(short nPlayer, short nWeapon)
PlayerList[nPlayer].field_38 = nWeapon;
}
void SetNewWeaponImmediate(short nPlayer, short nWeapon)
void SetNewWeaponImmediate(int nPlayer, short nWeapon)
{
SetNewWeapon(nPlayer, nWeapon);
@ -177,14 +177,14 @@ void SetNewWeaponImmediate(short nPlayer, short nWeapon)
PlayerList[nPlayer].field_3A = 0;
}
void SetNewWeaponIfBetter(short nPlayer, short nWeapon)
void SetNewWeaponIfBetter(int nPlayer, short nWeapon)
{
if (nWeapon > PlayerList[nPlayer].nCurrentWeapon) {
SetNewWeapon(nPlayer, nWeapon);
}
}
void SelectNewWeapon(short nPlayer)
void SelectNewWeapon(int nPlayer)
{
int nWeapon = kWeaponRing; // start at the highest weapon number
@ -212,23 +212,23 @@ void SelectNewWeapon(short nPlayer)
SetNewWeapon(nPlayer, nWeapon);
}
void StopFiringWeapon(short nPlayer)
void StopFiringWeapon(int nPlayer)
{
PlayerList[nPlayer].bIsFiring = false;
}
void FireWeapon(short nPlayer)
void FireWeapon(int nPlayer)
{
if (!PlayerList[nPlayer].bIsFiring) {
PlayerList[nPlayer].bIsFiring = true;
}
}
void SetWeaponStatus(short nPlayer)
void SetWeaponStatus(int nPlayer)
{
}
uint8_t WeaponCanFire(short nPlayer)
uint8_t WeaponCanFire(int nPlayer)
{
short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
int nSector =PlayerList[nPlayer].nPlayerViewSect;
@ -252,7 +252,7 @@ void ResetSwordSeqs()
WeaponInfo[kWeaponSword].b[3] = 7;
}
Collision CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
Collision CheckCloseRange(int nPlayer, int *x, int *y, int *z, short *nSector)
{
short hitSect, hitWall, hitSprite;
int hitX, hitY, hitZ;
@ -305,7 +305,7 @@ Collision CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
return c;
}
void CheckClip(short nPlayer)
void CheckClip(int nPlayer)
{
if (PlayerList[nPlayer].nPlayerClip <= 0)
{
@ -320,7 +320,7 @@ void CheckClip(short nPlayer)
PlayerList[nPlayer].nPistolClip = PlayerList[nPlayer].nAmmo[kWeaponPistol] % 6;
}
void MoveWeapons(short nPlayer)
void MoveWeapons(int nPlayer)
{
static int dword_96E22 = 0;

View file

@ -27,7 +27,7 @@ BEGIN_PS_NS
PlayerInput sPlayerInput[kMaxPlayers];
void ClearSpaceBar(short nPlayer)
void ClearSpaceBar(int nPlayer)
{
sPlayerInput[nPlayer].actions &= SB_OPEN;
buttonMap.ClearButton(gamefunc_Open);

View file

@ -54,7 +54,7 @@ struct PlayerInput
};
void ClearSpaceBar(short nPlayer);
void ClearSpaceBar(int nPlayer);
int GetLocalInput();

View file

@ -155,7 +155,7 @@ void ItemFlash()
TintPalette(16, 16, 16);
}
void FillItems(short nPlayer)
void FillItems(int nPlayer)
{
for (int i = 0; i < 6; i++)
{
@ -174,7 +174,7 @@ void FillItems(short nPlayer)
}
}
static bool UseEye(short nPlayer)
static bool UseEye(int nPlayer)
{
if (PlayerList[nPlayer].nInvisible >= 0)
PlayerList[nPlayer].nInvisible = 900;
@ -196,7 +196,7 @@ static bool UseEye(short nPlayer)
return true;
}
static bool UseMask(short nPlayer)
static bool UseMask(int nPlayer)
{
PlayerList[nPlayer].nMaskAmount = 1350;
PlayerList[nPlayer].nAir = 100;
@ -208,7 +208,7 @@ static bool UseMask(short nPlayer)
return true;
}
bool UseTorch(short nPlayer)
bool UseTorch(int nPlayer)
{
if (!PlayerList[nPlayer].nTorch)
{
@ -219,7 +219,7 @@ bool UseTorch(short nPlayer)
return true;
}
bool UseHeart(short nPlayer)
bool UseHeart(int nPlayer)
{
if (PlayerList[nPlayer].nHealth < kMaxHealth) {
PlayerList[nPlayer].nHealth = kMaxHealth;
@ -235,7 +235,7 @@ bool UseHeart(short nPlayer)
}
// invincibility
bool UseScarab(short nPlayer)
bool UseScarab(int nPlayer)
{
if (PlayerList[nPlayer].invincibility >= 0 && PlayerList[nPlayer].invincibility < 900)
PlayerList[nPlayer].invincibility = 900;
@ -249,7 +249,7 @@ bool UseScarab(short nPlayer)
}
// faster firing
static bool UseHand(short nPlayer)
static bool UseHand(int nPlayer)
{
PlayerList[nPlayer].nDouble = 1350;
@ -261,7 +261,7 @@ static bool UseHand(short nPlayer)
return true;
}
void UseItem(short nPlayer, int nItem)
void UseItem(int nPlayer, int nItem)
{
bool didit = false;
switch (nItem)
@ -313,7 +313,7 @@ void UseItem(short nPlayer, int nItem)
}
// TODO - bool return type?
int GrabItem(short nPlayer, int nItem)
int GrabItem(int nPlayer, int nItem)
{
if (PlayerList[nPlayer].items[nItem] >= 5) {
return 0;

View file

@ -548,7 +548,7 @@ Collision movesprite(DExhumedActor* pActor, int dx, int dy, int dz, int ceildist
if (pSprite->statnum == 100)
{
short nPlayer = GetPlayerFromActor(pActor);
int nPlayer = GetPlayerFromActor(pActor);
int varA = 0;
int varB = 0;

View file

@ -172,12 +172,12 @@ void InitPlayer()
}
}
void InitPlayerKeys(short nPlayer)
void InitPlayerKeys(int nPlayer)
{
PlayerList[nPlayer].keys = 0;
}
void InitPlayerInventory(short nPlayer)
void InitPlayerInventory(int nPlayer)
{
memset(&PlayerList[nPlayer], 0, sizeof(Player));
@ -213,7 +213,7 @@ short GetPlayerFromActor(DExhumedActor* pActor)
return RunData[pSprite->owner].nObjIndex;
}
void RestartPlayer(short nPlayer)
void RestartPlayer(int nPlayer)
{
auto plr = &PlayerList[nPlayer];
auto pActor = plr->Actor();
@ -614,7 +614,7 @@ void UpdatePlayerSpriteAngle(Player* pPlayer)
void AIPlayer::Draw(RunListEvent* ev)
{
short nPlayer = RunData[ev->nRun].nObjIndex;
int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
short nAction = PlayerList[nPlayer].nAction;
@ -623,7 +623,7 @@ void AIPlayer::Draw(RunListEvent* ev)
void AIPlayer::RadialDamage(RunListEvent* ev)
{
short nPlayer = RunData[ev->nRun].nObjIndex;
int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
auto pPlayerActor = PlayerList[nPlayer].Actor();
@ -640,7 +640,7 @@ void AIPlayer::RadialDamage(RunListEvent* ev)
void AIPlayer::Damage(RunListEvent* ev)
{
int nDamage = ev->nDamage;
short nPlayer = RunData[ev->nRun].nObjIndex;
int nPlayer = RunData[ev->nRun].nObjIndex;
auto pPlayerActor = PlayerList[nPlayer].Actor();
short nAction = PlayerList[nPlayer].nAction;
auto pPlayerSprite = &pPlayerActor->s();
@ -749,7 +749,7 @@ void AIPlayer::Tick(RunListEvent* ev)
int var_40;
bool mplevel = (currentLevel->gameflags & LEVEL_EX_MULTI);
short nPlayer = RunData[ev->nRun].nObjIndex;
int nPlayer = RunData[ev->nRun].nObjIndex;
assert(nPlayer >= 0 && nPlayer < kMaxPlayers);
auto pPlayerActor = PlayerList[nPlayer].Actor();

View file

@ -27,10 +27,10 @@ BEGIN_PS_NS
void RestoreSavePoint(int nPlayer, int *x, int *y, int *z, short *nSector, short *nAngle);
void SetSavePoint(int nPlayer, int x, int y, int z, int nSector, int nAngle);
void InitPlayer();
void InitPlayerKeys(short nPlayer);
void InitPlayerKeys(int nPlayer);
int GrabPlayer();
void InitPlayerInventory(short nPlayer);
void RestartPlayer(short nPlayer);
void InitPlayerInventory(int nPlayer);
void RestartPlayer(int nPlayer);
void FuncPlayer(int, int nSector, int nSprite, int nRun);

View file

@ -60,7 +60,7 @@ void SerializeRa(FSerializer& arc)
arc.Array("ra", Ra, PlayerCount);
}
void FreeRa(short nPlayer)
void FreeRa(int nPlayer)
{
int nRun = Ra[nPlayer].nRun;
auto pActor = Ra[nPlayer].pActor;
@ -73,7 +73,7 @@ void FreeRa(short nPlayer)
DeleteActor(pActor);
}
void BuildRa(short nPlayer)
void BuildRa(int nPlayer)
{
auto pPlayerActor = PlayerList[nPlayer].Actor();
auto pPlayerSprite = &pPlayerActor->s();
@ -111,7 +111,7 @@ void InitRa()
memset(Ra, 0, sizeof(RA) * kMaxPlayers);
}
void MoveRaToEnemy(short nPlayer)
void MoveRaToEnemy(int nPlayer)
{
auto pTarget = Ra[nPlayer].pTarget;
auto pActor = Ra[nPlayer].pActor;
@ -168,7 +168,7 @@ void MoveRaToEnemy(short nPlayer)
void AIRa::Tick(RunListEvent* ev)
{
short nPlayer = RunData[ev->nRun].nObjIndex;
int nPlayer = RunData[ev->nRun].nObjIndex;
short nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon;
short nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a;
@ -291,7 +291,7 @@ void AIRa::Tick(RunListEvent* ev)
void AIRa::Draw(RunListEvent* ev)
{
short nPlayer = RunData[ev->nRun].nObjIndex;
int nPlayer = RunData[ev->nRun].nObjIndex;
short nSeq = SeqOffsets[kSeqEyeHit] + RaSeq[Ra[nPlayer].nAction].a;
seq_PlotSequence(ev->nParam, nSeq, Ra[nPlayer].nFrame, 1);

View file

@ -1775,7 +1775,7 @@ void runlist_DamageEnemy(DExhumedActor* pActor, DExhumedActor* pActor2, short nD
return;
}
short nPlayer = GetPlayerFromActor(pActor2);
int nPlayer = GetPlayerFromActor(pActor2);
PlayerList[nPlayer].nTauntTimer--;
if (PlayerList[nPlayer].nTauntTimer <= 0)

View file

@ -92,7 +92,7 @@ void DestroySnake(int nSnake)
}
}
void ExplodeSnakeSprite(DExhumedActor* pActor, short nPlayer)
void ExplodeSnakeSprite(DExhumedActor* pActor, int nPlayer)
{
auto pSprite = &pActor->s();
short nDamage = BulletInfo[kWeaponStaff].nDamage;
@ -116,7 +116,7 @@ void ExplodeSnakeSprite(DExhumedActor* pActor, short nPlayer)
StopActorSound(pActor);
}
void BuildSnake(short nPlayer, short zVal)
void BuildSnake(int nPlayer, short zVal)
{
zVal -= 1280;
@ -266,7 +266,7 @@ void BuildSnake(short nPlayer, short zVal)
DExhumedActor* FindSnakeEnemy(short nSnake)
{
short nPlayer = SnakeList[nSnake].nSnakePlayer;
int nPlayer = SnakeList[nSnake].nSnakePlayer;
auto pPlayerActor = PlayerList[nPlayer].Actor();
auto pActor = SnakeList[nSnake].pSprites[0]; // CHECKME
@ -360,7 +360,7 @@ void AISnake::Tick(RunListEvent* ev)
if (nMov.type || nMov.exbits)
{
short nPlayer = SnakeList[nSnake].nSnakePlayer;
int nPlayer = SnakeList[nSnake].nSnakePlayer;
ExplodeSnakeSprite(SnakeList[nSnake].pSprites[0], nPlayer);
nPlayerSnake[nPlayer] = -1;