diff --git a/source/exhumed/src/bubbles.cpp b/source/exhumed/src/bubbles.cpp index 2fefeaffc..c90977b93 100644 --- a/source/exhumed/src/bubbles.cpp +++ b/source/exhumed/src/bubbles.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "exhumed.h" #include "engine.h" #include "sequence.h" +#include "mapinfo.h" #include BEGIN_PS_NS @@ -219,7 +220,7 @@ void DoBubbleMachines() void BuildBubbleMachine(int nSprite) { 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); } diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 0092e4c7d..f268a2c70 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -158,7 +158,6 @@ short nCodeMin = 0; short nCodeMax = 0; short nCodeIndex = 0; -short levelnum = -1; //short nScreenWidth = 320; //short nScreenHeight = 200; int moveframes; @@ -458,7 +457,7 @@ void GameMove(void) { FixPalette(); - if (levelnum == kMap20) + if (currentLevel->levelNumber == kMap20) { if (lCountDown <= 0) { @@ -780,7 +779,6 @@ static SavegameHelper sgh("exhumed", SV(nEnergyChan), SV(lCountDown), SV(nEnergyTowers), - SV(levelnum), SV(moveframes), SV(totalmoves), SV(nCurBodyNum), diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index a9ea3bf5b..41d0be968 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -183,7 +183,6 @@ extern short nBodyTotal; extern short bSnakeCam; extern uint8_t nCinemaSeen; -extern short levelnum; //extern short nScreenWidth; //extern short nScreenHeight; diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index be67febbc..4ae2535ba 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -67,8 +67,9 @@ void DoTitle(CompletionFunc completion); static int FinishLevel(TArray &jobs) { - if (levelnum > nBestLevel) { - nBestLevel = levelnum - 1; + int lnum = currentLevel->levelNumber; + if (lnum > nBestLevel) { + nBestLevel = lnum - 1; } @@ -77,8 +78,8 @@ static int FinishLevel(TArray &jobs) bCamera = false; nMapMode = 0; - STAT_Update(levelnum == kMap20); - if (levelnum != kMap20) + STAT_Update(lnum == kMap20); + if (lnum != kMap20) { if (EndLevel != 2) { @@ -90,8 +91,8 @@ static int FinishLevel(TArray &jobs) } else nPlayerLives[0] = 0; - DoAfterCinemaScene(levelnum, jobs); - return levelnum == kMap20? -1 : levelnum + 1; + DoAfterCinemaScene(lnum, jobs); + return lnum == kMap20? -1 : lnum + 1; } @@ -112,7 +113,7 @@ static void showmap(short nLevel, short nLevelNew, short nLevelBest, TArraylevelNumber == kMap20) { DoEnergyTile(); DrawClock(); @@ -184,6 +185,7 @@ void CheckProgression() if (GameAction < 1000) { // start a new game on the given level + currentLevel = nullptr; mylevelnew = GameAction; GameAction = -1; InitNewGame(); @@ -200,7 +202,7 @@ void CheckProgression() } else if (EndLevel) { - if (levelnum == 0) startmainmenu(); + if (currentLevel->levelNumber == 0) startmainmenu(); else mylevelnew = FinishLevel(jobs); EndLevel = false; } @@ -210,7 +212,7 @@ void CheckProgression() // start a new game at the given level if (!nNetPlayerCount && mylevelnew > 0) { - showmap(levelnum, mylevelnew, nBestLevel, jobs); + showmap(currentLevel? currentLevel->levelNumber : -1, mylevelnew, nBestLevel, jobs); } else jobs.Push({ Create() }); // we need something in here even in the multiplayer case. diff --git a/source/exhumed/src/init.cpp b/source/exhumed/src/init.cpp index a7a752f3f..2252dd9de 100644 --- a/source/exhumed/src/init.cpp +++ b/source/exhumed/src/init.cpp @@ -173,15 +173,11 @@ uint8_t LoadLevel(int nMap) precache(); LoadObjects(); - - levelnum = nMap; - return true; } void InitLevel(int level) { - levelnum = level; StopCD(); if (!LoadLevel(level)) { I_Error("Can't load level %d...\n", level); diff --git a/source/exhumed/src/items.cpp b/source/exhumed/src/items.cpp index 954297699..35d1a57c0 100644 --- a/source/exhumed/src/items.cpp +++ b/source/exhumed/src/items.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "status.h" #include "engine.h" #include "ps_input.h" +#include "mapinfo.h" BEGIN_PS_NS @@ -435,7 +436,7 @@ void StartRegenerate(short nSprite) pSprite->extra = 1350; pSprite->ang = nFirstRegenerate; - if (levelnum <= kMap20) + if (currentLevel->levelNumber <= kMap20) { pSprite->ang /= 5; } diff --git a/source/exhumed/src/menu.cpp b/source/exhumed/src/menu.cpp index 6c95f586e..8afcb487e 100644 --- a/source/exhumed/src/menu.cpp +++ b/source/exhumed/src/menu.cpp @@ -293,7 +293,7 @@ void menu_GameSave2(FILE* fp) { memset(&GameStats, 0, sizeof(GameStats)); - GameStats.nMap = (uint8_t)levelnum; + //GameStats.nMap = (uint8_t)levelnum; GameStats.nWeapons = nPlayerWeapons[nLocalPlayer]; GameStats.nCurrentWeapon = PlayerList[nLocalPlayer].nCurrentWeapon; GameStats.clip = nPlayerClip[nLocalPlayer]; diff --git a/source/exhumed/src/move.cpp b/source/exhumed/src/move.cpp index 693a7126d..8cdcba7fd 100644 --- a/source/exhumed/src/move.cpp +++ b/source/exhumed/src/move.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "view.h" #include "status.h" #include "sound.h" +#include "mapinfo.h" #include #include @@ -180,7 +181,7 @@ void MoveThings() DoMovingSects(); DoRegenerates(); - if (levelnum == kMap20) + if (currentLevel->levelNumber == kMap20) { DoFinale(); if (lCountDown < 1800 && nDronePitch < 2400 && !lFinaleStart) diff --git a/source/exhumed/src/object.cpp b/source/exhumed/src/object.cpp index 0dd8350c3..1d0028913 100644 --- a/source/exhumed/src/object.cpp +++ b/source/exhumed/src/object.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "names.h" #include "sequence.h" #include "player.h" +#include "mapinfo.h" #include #include @@ -2099,7 +2100,7 @@ FUNCOBJECT_GOTO: } } - if (levelnum <= 20 || nStat != kStatExplodeTrigger) + if (currentLevel->levelNumber <= 20 || nStat != kStatExplodeTrigger) { runlist_SubRunRec(sprite[nSprite].owner); runlist_SubRunRec(ObjectList[nObject].field_4); @@ -2554,7 +2555,7 @@ void PostProcess() } } - if (levelnum != kMap20) + if (currentLevel->levelNumber != kMap20) { // esi is i for (i = 0; i < numsectors; i++) diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 6f13ee940..e0648f9c2 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "buildtiles.h" #include "gstrings.h" #include "gamestate.h" +#include "mapinfo.h" #include #include #include @@ -628,7 +629,7 @@ void RestartPlayer(short nPlayer) PlayerList[nPlayer].nAir = 100; airpages = 0; - if (levelnum <= kMap20) + if (currentLevel->levelNumber <= kMap20) { RestoreMinAmmo(nPlayer); } @@ -789,7 +790,7 @@ void StartDeathSeq(int nPlayer, int nVal) 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]--; } @@ -1265,7 +1266,7 @@ void FuncPlayer(int a, int nDamage, int nRun) nDestVertPan[nPlayer] = F16(92); - if (levelnum == 11) + if (currentLevel->levelNumber == 11) { nDestVertPan[nPlayer] += F16(46); } @@ -1728,7 +1729,7 @@ do_default: // loc_1B3C7 // 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); mydeletesprite(nValB); @@ -2184,7 +2185,7 @@ do_default_b: if (weapons & var_18) { - if (levelnum > 20) + if (currentLevel->levelNumber > 20) { AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); } @@ -2246,7 +2247,7 @@ do_default_b: if (weapons & var_18) { - if (levelnum > 20) + if (currentLevel->levelNumber > 20) { AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); } @@ -2308,7 +2309,7 @@ do_default_b: if (weapons & var_18) { - if (levelnum > 20) + if (currentLevel->levelNumber > 20) { AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); } @@ -2370,7 +2371,7 @@ do_default_b: if (weapons & var_18) { - if (levelnum > 20) + if (currentLevel->levelNumber > 20) { AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); } @@ -2432,7 +2433,7 @@ do_default_b: if (weapons & var_18) { - if (levelnum > 20) + if (currentLevel->levelNumber > 20) { AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); } @@ -2494,7 +2495,7 @@ do_default_b: if (weapons & var_18) { - if (levelnum > 20) + if (currentLevel->levelNumber > 20) { AddAmmo(nPlayer, WeaponInfo[var_40].nAmmoType, ebx); } @@ -2954,7 +2955,7 @@ loc_1BD2E: } else { - DoGameOverScene((levelnum == 20)); + DoGameOverScene((currentLevel->levelNumber == 20)); return; } } diff --git a/source/exhumed/src/ramses.cpp b/source/exhumed/src/ramses.cpp index 380a891d9..df7266ddc 100644 --- a/source/exhumed/src/ramses.cpp +++ b/source/exhumed/src/ramses.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "names.h" #include "aistuff.h" #include "player.h" +#include "mapinfo.h" BEGIN_PS_NS @@ -137,7 +138,7 @@ void InitSpiritHead() int nTrack; - if (levelnum == 1) + if (currentLevel->levelNumber == 1) { nTrack = 3; } @@ -150,7 +151,7 @@ void InitSpiritHead() StartSwirlies(); - sprintf(filename, "LEV%d.PUP", levelnum); + sprintf(filename, "LEV%d.PUP", currentLevel->levelNumber); lNextStateChange = (int)totalclock; lHeadStartClock = (int)totalclock; diff --git a/source/exhumed/src/save.cpp b/source/exhumed/src/save.cpp index fb0bbe156..c3c5f7e55 100644 --- a/source/exhumed/src/save.cpp +++ b/source/exhumed/src/save.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "mmulti.h" #include "savegamehelp.h" #include "sound.h" +#include "mapinfo.h" BEGIN_PS_NS @@ -62,7 +63,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) ototalclock = totalclock; GameAction = 1000; - if (levelnum > 15) + if (currentLevel->levelNumber > 15) { nSwitchSound = 35; nStoneSound = 23; diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index 1c9154dff..cf9f4b11a 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" #include "sequence.h" #include "raze_sound.h" +#include "mapinfo.h" BEGIN_PS_NS @@ -656,7 +657,7 @@ void CheckAmbience(short nSector) void UpdateCreepySounds() { - if (levelnum == 20 || nFreeze) + if (currentLevel->levelNumber == 20 || nFreeze) return; spritetype* pSprite = &sprite[PlayerList[nLocalPlayer].nSprite]; nCreepyTimer--; diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 12ea1601b..f86a44442 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "aistuff.h" #include "menu.h" #include "sound.h" +#include "mapinfo.h" #include "v_video.h" #include "glbackend/glbackend.h" #include @@ -433,7 +434,7 @@ void DrawView(int smoothRatio, bool sceneonly) if (bSubTitles) { subtitleOverlay.Start(totalclock); - if (levelnum == 1) + if (currentLevel->levelNumber == 1) subtitleOverlay.ReadyCinemaText(1); else subtitleOverlay.ReadyCinemaText(5);