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

View file

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

View file

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

View file

@ -334,7 +334,7 @@ void GameInterface::Ticker()
if (localInput.actions & SB_INVPREV) if (localInput.actions & SB_INVPREV)
{ {
int nItem = nPlayerItem[nLocalPlayer]; int nItem = PlayerList[nLocalPlayer].nItem;
int i; int i;
for (i = 6; i > 0; i--) for (i = 6; i > 0; i--)
@ -351,7 +351,7 @@ void GameInterface::Ticker()
if (localInput.actions & SB_INVNEXT) if (localInput.actions & SB_INVNEXT)
{ {
int nItem = nPlayerItem[nLocalPlayer]; int nItem = PlayerList[nLocalPlayer].nItem;
int i; int i;
for (i = 6; i > 0; i--) for (i = 6; i > 0; i--)
@ -368,9 +368,9 @@ void GameInterface::Ticker()
if (localInput.actions & SB_INVUSE) 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(); SetMagicFrame();
} }
if (nPlayerItem[nPlayer] == -1) { if (PlayerList[nPlayer].nItem == -1) {
SetPlayerItem(nPlayer, 0); SetPlayerItem(nPlayer, 0);
} }
} }
@ -336,7 +336,7 @@ int GrabItem(short nPlayer, short nItem)
PlayerList[nPlayer].items[nItem]++; PlayerList[nPlayer].items[nItem]++;
if (nPlayerItem[nPlayer] < 0 || nItem == nPlayerItem[nPlayer]) { if (PlayerList[nPlayer].nItem < 0 || nItem == PlayerList[nPlayer].nItem) {
SetPlayerItem(nPlayer, nItem); SetPlayerItem(nPlayer, nItem);
} }

View file

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

View file

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