- turning some of the player arrays into Player members.

For script code we do not want the arrays accessible so all that get accessed need to be moved into the struct first.
This commit is contained in:
Christoph Oelckers 2021-05-13 19:06:38 +02:00
parent 4e182ea5ee
commit 12b7c73393
9 changed files with 11 additions and 57 deletions

View file

@ -209,7 +209,6 @@ static void cmd_Give(int player, uint8_t** stream, bool skip)
{
PlayerList[player].keys = 0xFFFF;
if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_KEYS"));
RefreshStatus();
}
if (buttons & kButtonCheatItems) // LOBOSWAG cheat
{

View file

@ -482,10 +482,6 @@ static void SetTileNames()
void GameInterface::app_init()
{
int i;
//int esi = 1;
//int edi = esi;
#if 0
help_disabled = true;
#endif
@ -510,9 +506,6 @@ void GameInterface::app_init()
seq_LoadSequences();
InitStatus();
for (i = 0; i < kMaxPlayers; i++) {
nPlayerLives[i] = kDefaultLives;
}
resettiming();
GrabPalette();

View file

@ -168,7 +168,7 @@ void GameInterface::LevelCompleted(MapRecord *to_map, int skill)
{
if (to_map->levelNumber > nBestLevel) nBestLevel = to_map->levelNumber - 1;
if (to_map->gameflags & LEVEL_EX_COUNTDOWN) nPlayerLives[0] = 0;
if (to_map->gameflags & LEVEL_EX_COUNTDOWN) PlayerList[0].nLives = 0;
if (to_map->gameflags & LEVEL_EX_TRAINING)
{
gameaction = ga_nextlevel;

View file

@ -227,21 +227,6 @@ void FireWeapon(short nPlayer)
void SetWeaponStatus(short nPlayer)
{
if (nPlayer != nLocalPlayer)
return;
short nWeapon = PlayerList[nPlayer].nCurrentWeapon;
if (nWeapon < 0)
{
nCounterBullet = -1;
SetCounterImmediate(0);
}
else
{
nCounterBullet = WeaponInfo[nWeapon].nAmmoType;
SetCounterImmediate(PlayerList[nPlayer].nAmmo[nCounterBullet]);
}
}
uint8_t WeaponCanFire(short nPlayer)

View file

@ -185,7 +185,6 @@ void InitLevel(MapRecord* map)
}
EndLevel = 0;
lastfps = 0;
InitStatus();
ResetView();
ResetEngine();
totalmoves = 0;
@ -195,8 +194,6 @@ void InitLevel(MapRecord* map)
lPlayerYVel = 0;
movefifopos = movefifoend;
RefreshStatus();
if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->music, true); // Allow non-CD music if defined for the current level
playCDtrack(map->cdSongId, true);
setLevelStarted(currentLevel);

View file

@ -103,7 +103,6 @@ short nPlayerPushSound[kMaxPlayers];
short nTauntTimer[kMaxPlayers];
short nPlayerTorch[kMaxPlayers];
uint16_t nPlayerWeapons[kMaxPlayers]; // each set bit represents a weapon the player has
short nPlayerLives[kMaxPlayers];
Player PlayerList[kMaxPlayers];
short nPlayerInvisible[kMaxPlayers];
short nPlayerDouble[kMaxPlayers];
@ -225,7 +224,7 @@ void InitPlayerInventory(short nPlayer)
ResetPlayerWeapons(nPlayer);
nPlayerLives[nPlayer] = kDefaultLives;
PlayerList[nPlayer].nLives = kDefaultLives;
PlayerList[nPlayer].nSprite = -1;
PlayerList[nPlayer].nRun = -1;
@ -560,19 +559,15 @@ void StartDeathSeq(int nPlayer, int nVal)
if (nTotalPlayers == 1)
{
if (!(currentLevel->gameflags & LEVEL_EX_TRAINING)) { // if not on the training level
nPlayerLives[nPlayer]--;
PlayerList[nPlayer].nLives--;
}
if (nPlayerLives[nPlayer] < 0) {
nPlayerLives[nPlayer] = 0;
if (PlayerList[nPlayer].nLives < 0) {
PlayerList[nPlayer].nLives = 0;
}
}
ototalvel[nPlayer] = totalvel[nPlayer] = 0;
if (nPlayer == nLocalPlayer) {
RefreshStatus();
}
}
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
@ -594,13 +589,6 @@ int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount)
PlayerList[nPlayer].nAmmo[nWeapon] = nAmmoAmount;
if (nPlayer == nLocalPlayer)
{
if (nWeapon == nCounterBullet) {
SetCounter(nAmmoAmount);
}
}
if (nWeapon == 1)
{
if (!nPistolClip[nPlayer]) {
@ -1812,11 +1800,11 @@ do_default_b:
{
var_88 = -1;
if (nPlayerLives[nPlayer] >= kMaxPlayerLives) {
if (PlayerList[nPlayer].nLives >= kMaxPlayerLives) {
break;
}
nPlayerLives[nPlayer]++;
PlayerList[nPlayer].nLives++;
var_8C = 32;
var_44 = 32;
@ -2533,7 +2521,7 @@ loc_1BD2E:
PlayerList[nPlayer].nCurrentWeapon = nPlayerOldWeapon[nPlayer];
if (nPlayerLives[nPlayer] && nNetTime)
if (PlayerList[nPlayer].nLives && nNetTime)
{
if (nAction != 20)
{
@ -2709,6 +2697,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player*
("seq", w.nSeq)
("horizon", w.horizon)
("angle", w.angle)
("lives", w.nLives)
.EndObject();
}
return arc;
@ -2759,7 +2748,6 @@ void SerializePlayer(FSerializer& arc)
.Array("taunttimer", nTauntTimer, PlayerCount)
.Array("torch", nPlayerTorch, PlayerCount)
.Array("weapons", nPlayerWeapons, PlayerCount)
.Array("lives", nPlayerLives, PlayerCount)
.Array("list", PlayerList, PlayerCount)
.Array("invisible", nPlayerInvisible, PlayerCount)
.Array("double", nPlayerDouble, PlayerCount)
@ -2771,14 +2759,6 @@ void SerializePlayer(FSerializer& arc)
.Array("netstartsprite", nNetStartSprite, PlayerCount)
.Array("grenade", nPlayerGrenade, PlayerCount)
.Array("d282a", word_D282A, PlayerCount);
if (SaveVersion < 13) // Item was an external array in older versions.
{
int nPlayerItem[8]{};
arc.Array("item", nPlayerItem, PlayerCount);
for (int i = 0; i < PlayerCount; i++) PlayerList[i].nItem = nPlayerItem[i];
}
arc.EndObject();
}
}

View file

@ -50,6 +50,7 @@ extern int lPlayerYVel;
struct Player
{
short nHealth;
short nLives;
short field_2;
short nAction;
short nSprite;

View file

@ -133,7 +133,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
}
Mus_ResumeSaved();
RefreshStatus();
}
}

View file

@ -488,7 +488,7 @@ private:
DrawStatusSequence(nStatusSeqOffset + 156 + 2* count, 0, 0);
}
short nLives = nPlayerLives[nLocalPlayer];
short nLives = PlayerList[nLocalPlayer].nLives;
DrawStatusSequence(nStatusSeqOffset + 145 + (2 * nLives), 0, 0);
if (nHurt > 0) DrawStatusSequence(nStatusSeqOffset + 4, nHurt - 1, 0);