Skip to content

Commit

Permalink
Renamed dword_21EFB0/dword_21EFD0
Browse files Browse the repository at this point in the history
Added new function playerResetScores()
Reset scores for cft when changing to new level
Don't shift text position on screen when in non-vanillamode cft
  • Loading branch information
carnivoroussociety authored and Hendricks266 committed Sep 12, 2021
1 parent 3ad666c commit ffa53fd
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
6 changes: 4 additions & 2 deletions source/blood/src/blood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void StartLevel(GAMEOPTIONS *gameOptions)
evInit();
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
if (!(gameOptions->uGameFlags&1))
if (!(gameOptions->uGameFlags&1)) // if new game
{
if (numplayers == 1)
{
Expand All @@ -729,6 +729,8 @@ void StartLevel(GAMEOPTIONS *gameOptions)
}
playerInit(i,0);
}
else if ((gGameOptions.nGameType == 3) && !VanillaMode()) // if ctf mode and went to next level, reset scores
playerResetScores(i);
playerStart(i, 1);
}
if (gameOptions->uGameFlags&1)
Expand Down Expand Up @@ -774,7 +776,7 @@ void StartLevel(GAMEOPTIONS *gameOptions)
// viewSetMessage("");
viewSetErrorMessage("");
viewResizeView(gViewSize);
if (gGameOptions.nGameType == 3)
if ((gGameOptions.nGameType == 3) && VanillaMode())
gGameMessageMgr.SetCoordinates(gViewX0S+1,gViewY0S+15);
netWaitForEveryone(0);
totalclock = 0;
Expand Down
38 changes: 22 additions & 16 deletions source/blood/src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,17 @@ void playerReset(PLAYER *pPlayer)

}

int dword_21EFB0[8];
ClockTicks dword_21EFD0[8];
int gPlayerScores[kMaxPlayers];
ClockTicks gPlayerScoreTicks[kMaxPlayers];

void playerResetScores(int nPlayer)
{
PLAYER *pPlayer = &gPlayer[nPlayer];
pPlayer->fragCount = 0;
memset(pPlayer->fragInfo, 0, sizeof(pPlayer->fragInfo));
memset(gPlayerScores, 0, sizeof(gPlayerScores));
memset(gPlayerScoreTicks, 0, sizeof(gPlayerScoreTicks));
}

void playerInit(int nPlayer, unsigned int a2)
{
Expand All @@ -874,10 +883,7 @@ void playerInit(int nPlayer, unsigned int a2)
pPlayer->teamId = nPlayer;
if (gGameOptions.nGameType == 3)
pPlayer->teamId = nPlayer&1;
pPlayer->fragCount = 0;
memset(dword_21EFB0, 0, sizeof(dword_21EFB0));
memset(dword_21EFD0, 0, sizeof(dword_21EFD0));
memset(pPlayer->fragInfo, 0, sizeof(pPlayer->fragInfo));
playerResetScores(nPlayer);

if (!(a2&1))
playerReset(pPlayer);
Expand Down Expand Up @@ -958,8 +964,8 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
if ((pPlayer->hasFlag & 2) != 0 && pXItem->state) {
pPlayer->hasFlag &= ~2;
pPlayer->used2[1] = -1;
dword_21EFB0[pPlayer->teamId] += 10;
dword_21EFD0[pPlayer->teamId] += 240;
gPlayerScores[pPlayer->teamId] += 10;
gPlayerScoreTicks[pPlayer->teamId] += 240;
evSend(0, 0, 81, kCmdOn);
sprintf(buffer, "%s captured Red Flag!", gProfile[pPlayer->nPlayer].name);
sndStartSample(8001, 255, 2, 0);
Expand Down Expand Up @@ -1002,8 +1008,8 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
{
pPlayer->hasFlag &= ~1;
pPlayer->used2[0] = -1;
dword_21EFB0[pPlayer->teamId] += 10;
dword_21EFD0[pPlayer->teamId] += 240;
gPlayerScores[pPlayer->teamId] += 10;
gPlayerScoreTicks[pPlayer->teamId] += 240;
evSend(0, 0, 80, kCmdOn);
sprintf(buffer, "%s captured Blue Flag!", gProfile[pPlayer->nPlayer].name);
sndStartSample(8000, 255, 2, 0);
Expand Down Expand Up @@ -1880,7 +1886,7 @@ void playerFrag(PLAYER *pKiller, PLAYER *pVictim)
pVictim->fragInfo[nVictim]--;
}
if (gGameOptions.nGameType == 3)
dword_21EFB0[pVictim->teamId]--;
gPlayerScores[pVictim->teamId]--;
int nMessage = Random(5);
int nSound = gSuicide[nMessage].at4;
if (pVictim == gMe && gMe->handTime <= 0)
Expand All @@ -1904,11 +1910,11 @@ void playerFrag(PLAYER *pKiller, PLAYER *pVictim)
if (gGameOptions.nGameType == 3)
{
if (pKiller->teamId == pVictim->teamId)
dword_21EFB0[pKiller->teamId]--;
gPlayerScores[pKiller->teamId]--;
else
{
dword_21EFB0[pKiller->teamId]++;
dword_21EFD0[pKiller->teamId]+=120;
gPlayerScores[pKiller->teamId]++;
gPlayerScoreTicks[pKiller->teamId]+=120;
}
}
int nMessage = Random(25);
Expand Down Expand Up @@ -2276,7 +2282,7 @@ class PlayerLoadSave : public LoadSave
void PlayerLoadSave::Load(void)
{

Read(dword_21EFB0, sizeof(dword_21EFB0));
Read(gPlayerScores, sizeof(gPlayerScores));
Read(&gNetPlayers, sizeof(gNetPlayers));
Read(&gProfile, sizeof(gProfile));
Read(&gPlayer, sizeof(gPlayer));
Expand Down Expand Up @@ -2310,7 +2316,7 @@ void PlayerLoadSave::Load(void)

void PlayerLoadSave::Save(void)
{
Write(dword_21EFB0, sizeof(dword_21EFB0));
Write(gPlayerScores, sizeof(gPlayerScores));
Write(&gNetPlayers, sizeof(gNetPlayers));
Write(&gProfile, sizeof(gProfile));
Write(&gPlayer, sizeof(gPlayer));
Expand Down
5 changes: 3 additions & 2 deletions source/blood/src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ extern bool gRedFlagDropped;

extern PROFILE gProfile[kMaxPlayers];

extern int dword_21EFB0[kMaxPlayers];
extern ClockTicks dword_21EFD0[kMaxPlayers];
extern int gPlayerScores[kMaxPlayers];
extern ClockTicks gPlayerScoreTicks[kMaxPlayers];
extern AMMOINFO gAmmoInfo[];
extern POWERUPINFO gPowerUpInfo[kMaxPowerUps];

Expand Down Expand Up @@ -282,6 +282,7 @@ void playerSetGodMode(PLAYER *pPlayer, char bGodMode);
void playerResetInertia(PLAYER *pPlayer);
void playerCorrectInertia(PLAYER *pPlayer, vec3_t const *oldpos);
void playerStart(int nPlayer, int bNewLevel = 0);
void playerResetScores(int nPlayer);
void playerReset(PLAYER *pPlayer);
void playerInit(int nPlayer, unsigned int a2);
char sub_3A158(PLAYER *a1, spritetype *a2);
Expand Down
30 changes: 15 additions & 15 deletions source/blood/src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,23 +1486,23 @@ void viewDrawPlayerFlags(void)
void viewDrawCtfHudVanilla(ClockTicks arg)
{
int x = 1, y = 1;
if (dword_21EFD0[0] == 0 || ((int)totalclock & 8))
if (gPlayerScoreTicks[0] == 0 || ((int)totalclock & 8))
{
viewDrawText(0, "BLUE", x, y, -128, 10, 0, 0, 256);
dword_21EFD0[0] = dword_21EFD0[0] - arg;
if (dword_21EFD0[0] < 0)
dword_21EFD0[0] = 0;
sprintf(gTempStr, "%-3d", dword_21EFB0[0]);
gPlayerScoreTicks[0] = gPlayerScoreTicks[0] - arg;
if (gPlayerScoreTicks[0] < 0)
gPlayerScoreTicks[0] = 0;
sprintf(gTempStr, "%-3d", gPlayerScores[0]);
viewDrawText(0, gTempStr, x, y + 10, -128, 10, 0, 0, 256);
}
x = 319;
if (dword_21EFD0[1] == 0 || ((int)totalclock & 8))
if (gPlayerScoreTicks[1] == 0 || ((int)totalclock & 8))
{
viewDrawText(0, "RED", x, y, -128, 7, 2, 0, 512);
dword_21EFD0[1] = dword_21EFD0[1] - arg;
if (dword_21EFD0[1] < 0)
dword_21EFD0[1] = 0;
sprintf(gTempStr, "%3d", dword_21EFB0[1]);
gPlayerScoreTicks[1] = gPlayerScoreTicks[1] - arg;
if (gPlayerScoreTicks[1] < 0)
gPlayerScoreTicks[1] = 0;
sprintf(gTempStr, "%3d", gPlayerScores[1]);
viewDrawText(0, gTempStr, x, y + 10, -128, 7, 2, 0, 512);
}
}
Expand All @@ -1511,14 +1511,14 @@ void flashTeamScore(ClockTicks arg, int team, bool show)
{
dassert(0 == team || 1 == team); // 0: blue, 1: red

if (dword_21EFD0[team] == 0 || ((int)totalclock & 8))
if (gPlayerScoreTicks[team] == 0 || ((int)totalclock & 8))
{
dword_21EFD0[team] = dword_21EFD0[team] - arg;
if (dword_21EFD0[team] < 0)
dword_21EFD0[team] = 0;
gPlayerScoreTicks[team] = gPlayerScoreTicks[team] - arg;
if (gPlayerScoreTicks[team] < 0)
gPlayerScoreTicks[team] = 0;

if (show)
DrawStatNumber("%d", dword_21EFB0[team], kSBarNumberInv, 290, team ? 125 : 90, 0, team ? 2 : 10, 512, 65536 * 0.75);
DrawStatNumber("%d", gPlayerScores[team], kSBarNumberInv, 290, team ? 125 : 90, 0, team ? 2 : 10, 512, 65536 * 0.75);
}
}

Expand Down

0 comments on commit ffa53fd

Please sign in to comment.