- Exhumed: moved nPlayerItem into PlayerList

This commit is contained in:
Christoph Oelckers 2021-05-13 13:44:58 +02:00
parent 71f4946879
commit c9361aff76
8 changed files with 28 additions and 18 deletions

View file

@ -70,6 +70,7 @@ void WriteSavePic(FileWriter* file, int width, int height);
bool WriteZip(const char* filename, TArray<FString>& filenames, TArray<FCompressedBuffer>& content);
extern FString savename;
extern FString BackupSaveGame;
int SaveVersion;
void SerializeMap(FSerializer &arc);
FixedBitArray<MAXSPRITES> activeSprites;
@ -346,6 +347,7 @@ int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu)
// not our business. Leave it alone.
return 0;
}
SaveVersion = savesig.currentsavever;
MapRecord *curLevel = FindMapByName(label);

View file

@ -7,6 +7,7 @@ extern FixedBitArray<MAXSPRITES> activeSprites;
// Savegame utilities
class FileReader;
extern int SaveVersion;
FString G_BuildSaveName (const char *prefix);
int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu);

View file

@ -77,7 +77,7 @@ const char *GetVersionString();
#define SAVEVER_DN3D 10
#define SAVEVER_BLD 11
#define SAVEVER_SW 12
#define SAVEVER_PS 12
#define SAVEVER_PS 13
#define NETGAMEVERSION 1

View file

@ -334,7 +334,7 @@ void GameInterface::Ticker()
if (localInput.actions & SB_INVPREV)
{
int nItem = nPlayerItem[nLocalPlayer];
int nItem = PlayerList[nLocalPlayer].nItem;
int i;
for (i = 6; i > 0; i--)
@ -351,7 +351,7 @@ void GameInterface::Ticker()
if (localInput.actions & SB_INVNEXT)
{
int nItem = nPlayerItem[nLocalPlayer];
int nItem = PlayerList[nLocalPlayer].nItem;
int i;
for (i = 6; i > 0; i--)
@ -368,9 +368,9 @@ void GameInterface::Ticker()
if (localInput.actions & SB_INVUSE)
{
if (nPlayerItem[nLocalPlayer] != -1)
if (PlayerList[nLocalPlayer].nItem != -1)
{
localInput.setItemUsed(nPlayerItem[nLocalPlayer]);
localInput.setItemUsed(PlayerList[nLocalPlayer].nItem);
}
}

View file

@ -175,7 +175,7 @@ void FillItems(short nPlayer)
SetMagicFrame();
}
if (nPlayerItem[nPlayer] == -1) {
if (PlayerList[nPlayer].nItem == -1) {
SetPlayerItem(nPlayer, 0);
}
}
@ -336,7 +336,7 @@ int GrabItem(short nPlayer, short nItem)
PlayerList[nPlayer].items[nItem]++;
if (nPlayerItem[nPlayer] < 0 || nItem == nPlayerItem[nPlayer]) {
if (PlayerList[nPlayer].nItem < 0 || nItem == PlayerList[nPlayer].nItem) {
SetPlayerItem(nPlayer, nItem);
}

View file

@ -104,7 +104,6 @@ short nTauntTimer[kMaxPlayers];
short nPlayerTorch[kMaxPlayers];
uint16_t nPlayerWeapons[kMaxPlayers]; // each set bit represents a weapon the player has
short nPlayerLives[kMaxPlayers];
short nPlayerItem[kMaxPlayers];
Player PlayerList[kMaxPlayers];
short nPlayerInvisible[kMaxPlayers];
short nPlayerDouble[kMaxPlayers];
@ -221,7 +220,7 @@ void InitPlayerInventory(short nPlayer)
{
memset(&PlayerList[nPlayer], 0, sizeof(Player));
nPlayerItem[nPlayer] = -1;
PlayerList[nPlayer].nItem = -1;
nPlayerSwear[nPlayer] = 4;
ResetPlayerWeapons(nPlayer);
@ -2744,6 +2743,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player*
("invincible", w.invincibility)
("air", w.nAir)
("seq", w.nSeq)
("item", w.nItem)
("maskamount", w.nMaskAmount)
("keys", w.keys)
("magic", w.nMagic)
@ -2809,7 +2809,6 @@ void SerializePlayer(FSerializer& arc)
.Array("torch", nPlayerTorch, PlayerCount)
.Array("weapons", nPlayerWeapons, PlayerCount)
.Array("lives", nPlayerLives, PlayerCount)
.Array("item", nPlayerItem, PlayerCount)
.Array("list", PlayerList, PlayerCount)
.Array("invisible", nPlayerInvisible, PlayerCount)
.Array("double", nPlayerDouble, PlayerCount)
@ -2820,8 +2819,16 @@ void SerializePlayer(FSerializer& arc)
.Array("eyelevel", eyelevel, PlayerCount)
.Array("netstartsprite", nNetStartSprite, PlayerCount)
.Array("grenade", nPlayerGrenade, PlayerCount)
.Array("d282a", word_D282A, PlayerCount)
.EndObject();
.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

@ -60,6 +60,7 @@ struct Player
short nMaskAmount;
uint16_t keys;
short nMagic;
short nItem;
char items[8];
short nAmmo[7]; // TODO - kMaxWeapons?
short pad[2];
@ -83,7 +84,6 @@ extern short PlayerCount;
extern short nPlayerTorch[];
extern short nPlayerLives[];
extern short nPlayerItem[];
extern Player PlayerList[];
extern short nPlayerInvisible[];
extern short nPlayerDouble[];

View file

@ -205,7 +205,7 @@ void RefreshStatus()
int val = 37;
SetPlayerItem(nLocalPlayer, nPlayerItem[nLocalPlayer]);
SetPlayerItem(nLocalPlayer, PlayerList[nLocalPlayer].nItem);
SetHealthFrame(0);
SetMagicFrame();
}
@ -320,7 +320,7 @@ void SetCounterDigits()
void SetItemSeq()
{
short nItem = nPlayerItem[nLocalPlayer];
short nItem = PlayerList[nLocalPlayer].nItem;
if (nItem < 0)
{
nItemSeq = -1;
@ -334,7 +334,7 @@ void SetItemSeq()
void SetItemSeq2(int nSeqOffset)
{
short nItem = nPlayerItem[nLocalPlayer];
short nItem = PlayerList[nLocalPlayer].nItem;
if (nItemMagic[nItem] <= PlayerList[nLocalPlayer].nMagic) {
nItemAltSeq = 0;
@ -350,7 +350,7 @@ void SetItemSeq2(int nSeqOffset)
void SetPlayerItem(short nPlayer, short nItem)
{
nPlayerItem[nPlayer] = nItem;
PlayerList[nLocalPlayer].nItem = nItem;
if (nPlayer == nLocalPlayer)
{
@ -741,7 +741,7 @@ private:
format.Format("%d", pp->nMagic / 10);
short nItem = nPlayerItem[nLocalPlayer];
short nItem = PlayerList[nLocalPlayer].nItem;
int timer = ItemTimer(nItem, nLocalPlayer);
if (timer > 0)
{