- removed redundant levelnum variable.

Better use the global map record.
This commit is contained in:
Christoph Oelckers 2020-08-23 16:24:54 +02:00
parent 1a0e413d5c
commit f7fcd341ec
14 changed files with 43 additions and 39 deletions

View file

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "exhumed.h" #include "exhumed.h"
#include "engine.h" #include "engine.h"
#include "sequence.h" #include "sequence.h"
#include "mapinfo.h"
#include <assert.h> #include <assert.h>
BEGIN_PS_NS BEGIN_PS_NS
@ -219,7 +220,7 @@ void DoBubbleMachines()
void BuildBubbleMachine(int nSprite) void BuildBubbleMachine(int nSprite)
{ {
if (nMachineCount >= kMaxMachines) { if (nMachineCount >= kMaxMachines) {
I_Error("too many bubble machines in level %d\n", levelnum); I_Error("too many bubble machines in level %d\n", currentLevel->levelNumber);
exit(-1); exit(-1);
} }

View file

@ -158,7 +158,6 @@ short nCodeMin = 0;
short nCodeMax = 0; short nCodeMax = 0;
short nCodeIndex = 0; short nCodeIndex = 0;
short levelnum = -1;
//short nScreenWidth = 320; //short nScreenWidth = 320;
//short nScreenHeight = 200; //short nScreenHeight = 200;
int moveframes; int moveframes;
@ -458,7 +457,7 @@ void GameMove(void)
{ {
FixPalette(); FixPalette();
if (levelnum == kMap20) if (currentLevel->levelNumber == kMap20)
{ {
if (lCountDown <= 0) if (lCountDown <= 0)
{ {
@ -780,7 +779,6 @@ static SavegameHelper sgh("exhumed",
SV(nEnergyChan), SV(nEnergyChan),
SV(lCountDown), SV(lCountDown),
SV(nEnergyTowers), SV(nEnergyTowers),
SV(levelnum),
SV(moveframes), SV(moveframes),
SV(totalmoves), SV(totalmoves),
SV(nCurBodyNum), SV(nCurBodyNum),

View file

@ -183,7 +183,6 @@ extern short nBodyTotal;
extern short bSnakeCam; extern short bSnakeCam;
extern uint8_t nCinemaSeen; extern uint8_t nCinemaSeen;
extern short levelnum;
//extern short nScreenWidth; //extern short nScreenWidth;
//extern short nScreenHeight; //extern short nScreenHeight;

View file

@ -67,8 +67,9 @@ void DoTitle(CompletionFunc completion);
static int FinishLevel(TArray<JobDesc> &jobs) static int FinishLevel(TArray<JobDesc> &jobs)
{ {
if (levelnum > nBestLevel) { int lnum = currentLevel->levelNumber;
nBestLevel = levelnum - 1; if (lnum > nBestLevel) {
nBestLevel = lnum - 1;
} }
@ -77,8 +78,8 @@ static int FinishLevel(TArray<JobDesc> &jobs)
bCamera = false; bCamera = false;
nMapMode = 0; nMapMode = 0;
STAT_Update(levelnum == kMap20); STAT_Update(lnum == kMap20);
if (levelnum != kMap20) if (lnum != kMap20)
{ {
if (EndLevel != 2) if (EndLevel != 2)
{ {
@ -90,8 +91,8 @@ static int FinishLevel(TArray<JobDesc> &jobs)
} }
else nPlayerLives[0] = 0; else nPlayerLives[0] = 0;
DoAfterCinemaScene(levelnum, jobs); DoAfterCinemaScene(lnum, jobs);
return levelnum == kMap20? -1 : levelnum + 1; return lnum == kMap20? -1 : lnum + 1;
} }
@ -112,7 +113,7 @@ static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArray<JobD
static void GameDisplay(void) static void GameDisplay(void)
{ {
if (levelnum == kMap20) if (currentLevel->levelNumber == kMap20)
{ {
DoEnergyTile(); DoEnergyTile();
DrawClock(); DrawClock();
@ -184,6 +185,7 @@ void CheckProgression()
if (GameAction < 1000) if (GameAction < 1000)
{ {
// start a new game on the given level // start a new game on the given level
currentLevel = nullptr;
mylevelnew = GameAction; mylevelnew = GameAction;
GameAction = -1; GameAction = -1;
InitNewGame(); InitNewGame();
@ -200,7 +202,7 @@ void CheckProgression()
} }
else if (EndLevel) else if (EndLevel)
{ {
if (levelnum == 0) startmainmenu(); if (currentLevel->levelNumber == 0) startmainmenu();
else mylevelnew = FinishLevel(jobs); else mylevelnew = FinishLevel(jobs);
EndLevel = false; EndLevel = false;
} }
@ -210,7 +212,7 @@ void CheckProgression()
// start a new game at the given level // start a new game at the given level
if (!nNetPlayerCount && mylevelnew > 0) if (!nNetPlayerCount && mylevelnew > 0)
{ {
showmap(levelnum, mylevelnew, nBestLevel, jobs); showmap(currentLevel? currentLevel->levelNumber : -1, mylevelnew, nBestLevel, jobs);
} }
else else
jobs.Push({ Create<DScreenJob>() }); // we need something in here even in the multiplayer case. jobs.Push({ Create<DScreenJob>() }); // we need something in here even in the multiplayer case.

View file

@ -173,15 +173,11 @@ uint8_t LoadLevel(int nMap)
precache(); precache();
LoadObjects(); LoadObjects();
levelnum = nMap;
return true; return true;
} }
void InitLevel(int level) void InitLevel(int level)
{ {
levelnum = level;
StopCD(); StopCD();
if (!LoadLevel(level)) { if (!LoadLevel(level)) {
I_Error("Can't load level %d...\n", level); I_Error("Can't load level %d...\n", level);

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "status.h" #include "status.h"
#include "engine.h" #include "engine.h"
#include "ps_input.h" #include "ps_input.h"
#include "mapinfo.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -435,7 +436,7 @@ void StartRegenerate(short nSprite)
pSprite->extra = 1350; pSprite->extra = 1350;
pSprite->ang = nFirstRegenerate; pSprite->ang = nFirstRegenerate;
if (levelnum <= kMap20) if (currentLevel->levelNumber <= kMap20)
{ {
pSprite->ang /= 5; pSprite->ang /= 5;
} }

View file

@ -293,7 +293,7 @@ void menu_GameSave2(FILE* fp)
{ {
memset(&GameStats, 0, sizeof(GameStats)); memset(&GameStats, 0, sizeof(GameStats));
GameStats.nMap = (uint8_t)levelnum; //GameStats.nMap = (uint8_t)levelnum;
GameStats.nWeapons = nPlayerWeapons[nLocalPlayer]; GameStats.nWeapons = nPlayerWeapons[nLocalPlayer];
GameStats.nCurrentWeapon = PlayerList[nLocalPlayer].nCurrentWeapon; GameStats.nCurrentWeapon = PlayerList[nLocalPlayer].nCurrentWeapon;
GameStats.clip = nPlayerClip[nLocalPlayer]; GameStats.clip = nPlayerClip[nLocalPlayer];

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "view.h" #include "view.h"
#include "status.h" #include "status.h"
#include "sound.h" #include "sound.h"
#include "mapinfo.h"
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
@ -180,7 +181,7 @@ void MoveThings()
DoMovingSects(); DoMovingSects();
DoRegenerates(); DoRegenerates();
if (levelnum == kMap20) if (currentLevel->levelNumber == kMap20)
{ {
DoFinale(); DoFinale();
if (lCountDown < 1800 && nDronePitch < 2400 && !lFinaleStart) if (lCountDown < 1800 && nDronePitch < 2400 && !lFinaleStart)

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "names.h" #include "names.h"
#include "sequence.h" #include "sequence.h"
#include "player.h" #include "player.h"
#include "mapinfo.h"
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
@ -2099,7 +2100,7 @@ FUNCOBJECT_GOTO:
} }
} }
if (levelnum <= 20 || nStat != kStatExplodeTrigger) if (currentLevel->levelNumber <= 20 || nStat != kStatExplodeTrigger)
{ {
runlist_SubRunRec(sprite[nSprite].owner); runlist_SubRunRec(sprite[nSprite].owner);
runlist_SubRunRec(ObjectList[nObject].field_4); runlist_SubRunRec(ObjectList[nObject].field_4);
@ -2554,7 +2555,7 @@ void PostProcess()
} }
} }
if (levelnum != kMap20) if (currentLevel->levelNumber != kMap20)
{ {
// esi is i // esi is i
for (i = 0; i < numsectors; i++) for (i = 0; i < numsectors; i++)

View file

@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "buildtiles.h" #include "buildtiles.h"
#include "gstrings.h" #include "gstrings.h"
#include "gamestate.h" #include "gamestate.h"
#include "mapinfo.h"
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -628,7 +629,7 @@ void RestartPlayer(short nPlayer)
PlayerList[nPlayer].nAir = 100; PlayerList[nPlayer].nAir = 100;
airpages = 0; airpages = 0;
if (levelnum <= kMap20) if (currentLevel->levelNumber <= kMap20)
{ {
RestoreMinAmmo(nPlayer); RestoreMinAmmo(nPlayer);
} }
@ -789,7 +790,7 @@ void StartDeathSeq(int nPlayer, int nVal)
BuildStatusAnim((3 * (nLives - 1)) + 7, 0); BuildStatusAnim((3 * (nLives - 1)) + 7, 0);
} }
if (levelnum > 0) { // if not on the training level if (currentLevel->levelNumber > 0) { // if not on the training level
nPlayerLives[nPlayer]--; nPlayerLives[nPlayer]--;
} }
@ -1265,7 +1266,7 @@ void FuncPlayer(int a, int nDamage, int nRun)
nDestVertPan[nPlayer] = F16(92); nDestVertPan[nPlayer] = F16(92);
if (levelnum == 11) if (currentLevel->levelNumber == 11)
{ {
nDestVertPan[nPlayer] += F16(46); nDestVertPan[nPlayer] += F16(46);
} }
@ -1728,7 +1729,7 @@ do_default:
// loc_1B3C7 // loc_1B3C7
// CHECKME - is order of evaluation correct? // CHECKME - is order of evaluation correct?
if (levelnum <= 20 || (var_70 >= 25 && (var_70 <= 25 || var_70 == 50))) if (currentLevel->levelNumber <= 20 || (var_70 >= 25 && (var_70 <= 25 || var_70 == 50)))
{ {
DestroyItemAnim(nValB); DestroyItemAnim(nValB);
mydeletesprite(nValB); mydeletesprite(nValB);
@ -2184,7 +2185,7 @@ do_default_b:
if (weapons & var_18) if (weapons & var_18)
{ {
if (levelnum > 20) if (currentLevel->levelNumber > 20)
{ {
AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx);
} }
@ -2246,7 +2247,7 @@ do_default_b:
if (weapons & var_18) if (weapons & var_18)
{ {
if (levelnum > 20) if (currentLevel->levelNumber > 20)
{ {
AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx);
} }
@ -2308,7 +2309,7 @@ do_default_b:
if (weapons & var_18) if (weapons & var_18)
{ {
if (levelnum > 20) if (currentLevel->levelNumber > 20)
{ {
AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx);
} }
@ -2370,7 +2371,7 @@ do_default_b:
if (weapons & var_18) if (weapons & var_18)
{ {
if (levelnum > 20) if (currentLevel->levelNumber > 20)
{ {
AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx);
} }
@ -2432,7 +2433,7 @@ do_default_b:
if (weapons & var_18) if (weapons & var_18)
{ {
if (levelnum > 20) if (currentLevel->levelNumber > 20)
{ {
AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx);
} }
@ -2494,7 +2495,7 @@ do_default_b:
if (weapons & var_18) if (weapons & var_18)
{ {
if (levelnum > 20) if (currentLevel->levelNumber > 20)
{ {
AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx);
} }
@ -2954,7 +2955,7 @@ loc_1BD2E:
} }
else else
{ {
DoGameOverScene((levelnum == 20)); DoGameOverScene((currentLevel->levelNumber == 20));
return; return;
} }
} }

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "names.h" #include "names.h"
#include "aistuff.h" #include "aistuff.h"
#include "player.h" #include "player.h"
#include "mapinfo.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -137,7 +138,7 @@ void InitSpiritHead()
int nTrack; int nTrack;
if (levelnum == 1) if (currentLevel->levelNumber == 1)
{ {
nTrack = 3; nTrack = 3;
} }
@ -150,7 +151,7 @@ void InitSpiritHead()
StartSwirlies(); StartSwirlies();
sprintf(filename, "LEV%d.PUP", levelnum); sprintf(filename, "LEV%d.PUP", currentLevel->levelNumber);
lNextStateChange = (int)totalclock; lNextStateChange = (int)totalclock;
lHeadStartClock = (int)totalclock; lHeadStartClock = (int)totalclock;

View file

@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mmulti.h" #include "mmulti.h"
#include "savegamehelp.h" #include "savegamehelp.h"
#include "sound.h" #include "sound.h"
#include "mapinfo.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -62,7 +63,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
ototalclock = totalclock; ototalclock = totalclock;
GameAction = 1000; GameAction = 1000;
if (levelnum > 15) if (currentLevel->levelNumber > 15)
{ {
nSwitchSound = 35; nSwitchSound = 35;
nStoneSound = 23; nStoneSound = 23;

View file

@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "player.h" #include "player.h"
#include "sequence.h" #include "sequence.h"
#include "raze_sound.h" #include "raze_sound.h"
#include "mapinfo.h"
BEGIN_PS_NS BEGIN_PS_NS
@ -656,7 +657,7 @@ void CheckAmbience(short nSector)
void UpdateCreepySounds() void UpdateCreepySounds()
{ {
if (levelnum == 20 || nFreeze) if (currentLevel->levelNumber == 20 || nFreeze)
return; return;
spritetype* pSprite = &sprite[PlayerList[nLocalPlayer].nSprite]; spritetype* pSprite = &sprite[PlayerList[nLocalPlayer].nSprite];
nCreepyTimer--; nCreepyTimer--;

View file

@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "aistuff.h" #include "aistuff.h"
#include "menu.h" #include "menu.h"
#include "sound.h" #include "sound.h"
#include "mapinfo.h"
#include "v_video.h" #include "v_video.h"
#include "glbackend/glbackend.h" #include "glbackend/glbackend.h"
#include <string.h> #include <string.h>
@ -433,7 +434,7 @@ void DrawView(int smoothRatio, bool sceneonly)
if (bSubTitles) if (bSubTitles)
{ {
subtitleOverlay.Start(totalclock); subtitleOverlay.Start(totalclock);
if (levelnum == 1) if (currentLevel->levelNumber == 1)
subtitleOverlay.ReadyCinemaText(1); subtitleOverlay.ReadyCinemaText(1);
else else
subtitleOverlay.ReadyCinemaText(5); subtitleOverlay.ReadyCinemaText(5);