Skip to content

Commit

Permalink
-Exhumed: changed key display on status bar to be controlled from the…
Browse files Browse the repository at this point in the history
… status bar itself.

First of 6 externally controlled status bar indicators.
  • Loading branch information
coelckers committed May 15, 2021
1 parent 3172381 commit 35c0750
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 98 deletions.
94 changes: 8 additions & 86 deletions source/games/exhumed/src/player.cpp
Expand Up @@ -41,6 +41,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

BEGIN_PS_NS

extern short nStatusSeqOffset;

struct PlayerSave
{
int x;
Expand Down Expand Up @@ -1429,11 +1431,11 @@ void FuncPlayer(int a, int nDamage, int nRun)
int var_44 = 0;

// item lotags start at 6 (1-5 reserved?) so 0-offset them
int var_6C = var_70 - 6;
int itemtype = var_70 - 6;

if (var_6C <= 54)
if (itemtype <= 54)
{
switch (var_6C)
switch (itemtype)
{
do_default:
default:
Expand Down Expand Up @@ -2276,98 +2278,18 @@ void FuncPlayer(int a, int nDamage, int nRun)
break;
}

// Lots of repeated code for door key handling
case 39: // Power key
{
int ecx = 4096;

var_88 = -1;

if (PlayerList[nPlayer].keys != ecx)
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36, 0);
}

PlayerList[nPlayer].keys |= ecx;

if (nTotalPlayers > 1)
{
goto do_default_b;
}
else
{
goto do_default;
}
}

break;
}
case 40: // Time key
{
int ecx = 4096 << 1;

var_88 = -1;

if (PlayerList[nPlayer].keys != ecx)
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36 + 2, 0);
}

PlayerList[nPlayer].keys |= ecx;

if (nTotalPlayers > 1)
{
goto do_default_b;
}
else
{
goto do_default;
}
}

break;
}
case 41: // War key
{
int ecx = 4096 << 2;

var_88 = -1;

if (PlayerList[nPlayer].keys != ecx)
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36 + 4, 0);
}

PlayerList[nPlayer].keys |= ecx;

if (nTotalPlayers > 1)
{
goto do_default_b;
}
else
{
goto do_default;
}
}

break;
}
case 42: // Earth key
{
int ecx = 4096 << 3;
int keybit = 4096 << (itemtype - 39);

var_88 = -1;

if (PlayerList[nPlayer].keys != ecx)
if (!(PlayerList[nPlayer].keys & keybit))
{
if (nPlayer == nLocalPlayer) {
BuildStatusAnim(36 + 6, 0);
}

PlayerList[nPlayer].keys |= ecx;
PlayerList[nPlayer].keys |= keybit;

if (nTotalPlayers > 1)
{
Expand Down
48 changes: 36 additions & 12 deletions source/games/exhumed/src/status.cpp
Expand Up @@ -211,16 +211,6 @@ void RefreshStatus()

int val = 37;

for (int i = 0; i < 4; i++)
{
if (nKeys & 0x1000) {
BuildStatusAnim(val, 0);
}

nKeys >>= 1;
val += 2;
}

SetPlayerItem(nLocalPlayer, nPlayerItem[nLocalPlayer]);
SetHealthFrame(0);
SetMagicFrame();
Expand Down Expand Up @@ -525,6 +515,12 @@ class DExhumedStatusBar : public DBaseStatusBar
HAS_OBJECT_POINTERS

TObjPtr<DHUDFont*> textfont, numberFont;
int keyanims[4];

enum EConst
{
KeySeq = 36,
};

public:
DExhumedStatusBar()
Expand Down Expand Up @@ -636,7 +632,7 @@ class DExhumedStatusBar : public DBaseStatusBar
for (int i = nFirstAnim; i >= 0; i = StatusAnim[i].nPrevAnim)
{
int nSequence = nStatusSeqOffset + StatusAnim[i].s1;
DrawStatusSequence(nSequence, StatusAnim[i].s2, StatusAnim[i].s1 >= 37 && StatusAnim[i].s1 <= 43 ? 0.5 : 0, 0.5);
DrawStatusSequence(nSequence, StatusAnim[i].s2, 0, 0);
}
}

Expand Down Expand Up @@ -874,6 +870,14 @@ class DExhumedStatusBar : public DBaseStatusBar
return;
}

for (int i = 0; i < 4; i++)
{
if (PlayerList[nLocalPlayer].keys & (4096 << i))
{
DrawStatusSequence(nStatusSeqOffset + KeySeq + 2 * i, keyanims[i], 0.5, 0.5);
}
}

if (/*!bFullScreen &&*/ nNetTime)
{
DrawStatusSequence(nStatusSeqOffset + 127, 0, 0);
Expand Down Expand Up @@ -956,15 +960,35 @@ class DExhumedStatusBar : public DBaseStatusBar
}


void Tick() override
{
for (int i = 0; i < 4; i++)
{
int seq = nStatusSeqOffset + KeySeq + 2 * i;
if (PlayerList[nLocalPlayer].keys & (4096 << i))
{
if (keyanims[i] < SeqSize[seq] - 1)
{
seq_MoveSequence(-1, seq, 0); // this plays the pickup sound.
keyanims[i]++;
}
}
else
{
keyanims[i] = 0;
}
}
}


public:
void UpdateStatusBar()
{
Tick(); // temporary.
if (hud_size <= Hud_full)
{
DrawStatus();
}
}
PrintLevelStats(hud_size == Hud_Nothing ? 0 : hud_size == Hud_full? 22 : 40);
}
};
Expand Down

0 comments on commit 35c0750

Please sign in to comment.