diff --git a/src/am_map.cpp b/src/am_map.cpp index 7958402185..d2bb52ca69 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -130,8 +130,8 @@ CVAR(Int, am_showsubsector, -1, 0); CUSTOM_CVAR(Int, am_showalllines, -1, CVAR_NOINITCALL) // This is a cheat so don't save it. { - if (currentUILevel && currentUILevel->automap) - currentUILevel->automap->UpdateShowAllLines(); + if (primaryLevel && primaryLevel->automap) + primaryLevel->automap->UpdateShowAllLines(); } EXTERN_CVAR(Bool, sv_cheats) @@ -171,9 +171,9 @@ CUSTOM_CVAR(Int, am_emptyspacemargin, 0, CVAR_ARCHIVE) self = 90; } - if (nullptr != StatusBar && currentUILevel && currentUILevel->automap) + if (nullptr != StatusBar && primaryLevel && primaryLevel->automap) { - currentUILevel->automap->NewResolution(); + primaryLevel->automap->NewResolution(); } } @@ -191,8 +191,8 @@ CVAR(Float, am_zoomdir, 0, CVAR_ARCHIVE) CCMD(am_togglefollow) { am_followplayer = !am_followplayer; - if (currentUILevel && currentUILevel->automap) - currentUILevel->automap->ResetFollowLocation(); + if (primaryLevel && primaryLevel->automap) + primaryLevel->automap->ResetFollowLocation(); Printf("%s\n", GStrings(am_followplayer ? "AMSTR_FOLLOWON" : "AMSTR_FOLLOWOFF")); } @@ -210,9 +210,9 @@ CCMD(am_toggletexture) CCMD(am_setmark) { - if (currentUILevel && currentUILevel->automap) + if (primaryLevel && primaryLevel->automap) { - int m = currentUILevel->automap->addMark(); + int m = primaryLevel->automap->addMark(); if (m >= 0) { Printf("%s %d\n", GStrings("AMSTR_MARKEDSPOT"), m); @@ -222,7 +222,7 @@ CCMD(am_setmark) CCMD(am_clearmarks) { - if (currentUILevel && currentUILevel->automap && currentUILevel->automap->clearMarks()) + if (primaryLevel && primaryLevel->automap && primaryLevel->automap->clearMarks()) { Printf("%s\n", GStrings("AMSTR_MARKSCLEARED")); } @@ -230,8 +230,8 @@ CCMD(am_clearmarks) CCMD(am_gobig) { - if (currentUILevel && currentUILevel->automap) - currentUILevel->automap->GoBig(); + if (primaryLevel && primaryLevel->automap) + primaryLevel->automap->GoBig(); } CCMD(togglemap) @@ -3300,7 +3300,7 @@ void AM_ToggleMap() return; // ... or if there is no automap. - if (!currentUILevel || !currentUILevel->automap) + if (!primaryLevel || !primaryLevel->automap) return; if (!automapactive) @@ -3313,7 +3313,7 @@ void AM_ToggleMap() Button_AM_ZoomIn.Reset(); Button_AM_ZoomOut.Reset(); - currentUILevel->automap->startDisplay(); + primaryLevel->automap->startDisplay(); automapactive = true; viewactive = (am_overlay != 0.f); } diff --git a/src/b_bot.cpp b/src/b_bot.cpp index 6924c9c93a..bb15fc8bc4 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -173,9 +173,9 @@ CCMD (addbot) } if (argv.argc() > 1) - currentUILevel->BotInfo.SpawnBot (argv[1]); + primaryLevel->BotInfo.SpawnBot (argv[1]); else - currentUILevel->BotInfo.SpawnBot (nullptr); + primaryLevel->BotInfo.SpawnBot (nullptr); } void FCajunMaster::ClearPlayer (int i, bool keepTeam) @@ -232,7 +232,7 @@ CCMD (freeze) CCMD (listbots) { - botinfo_t *thebot = currentUILevel->BotInfo.botinfo; + botinfo_t *thebot = primaryLevel->BotInfo.botinfo; int count = 0; while (thebot) diff --git a/src/bbannouncer.cpp b/src/bbannouncer.cpp index 58243ea5c1..f0533cac17 100644 --- a/src/bbannouncer.cpp +++ b/src/bbannouncer.cpp @@ -182,9 +182,9 @@ static FRandom pr_bbannounce ("BBAnnounce"); void DoVoiceAnnounce (const char *sound) { // Don't play announcements too close together - if (LastAnnounceTime == 0 || LastAnnounceTime <= currentUILevel->time-5) + if (LastAnnounceTime == 0 || LastAnnounceTime <= primaryLevel->time-5) { - LastAnnounceTime = currentUILevel->time; + LastAnnounceTime = primaryLevel->time; S_Sound (CHAN_VOICE, sound, 1, ATTN_NONE); } } diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 44ddbe3e44..b33dd91ce0 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -366,7 +366,7 @@ CCMD (changemap) if (argv.argc() > 1) { const char *mapname = argv[1]; - if (!strcmp(mapname, "*")) mapname = currentUILevel->MapName.GetChars(); + if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars(); try { @@ -946,7 +946,7 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha } } // This only works on the primary level. - auto it = currentUILevel->GetThinkerIterator(); + auto it = primaryLevel->GetThinkerIterator(); while ( (mo = it.Next()) ) { @@ -1063,14 +1063,14 @@ CCMD(changesky) FTextureID newsky = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst); if (newsky.Exists()) { - currentUILevel->skytexture1 = newsky; + primaryLevel->skytexture1 = newsky; } else { Printf("changesky: Texture '%s' not found\n", sky1name); } } - InitSkyMap (currentUILevel); + InitSkyMap (primaryLevel); } //----------------------------------------------------------------------------- @@ -1101,9 +1101,9 @@ CCMD(nextmap) return; } - if (currentUILevel->NextMap.Len() > 0 && currentUILevel->NextMap.Compare("enDSeQ", 6)) + if (primaryLevel->NextMap.Len() > 0 && primaryLevel->NextMap.Compare("enDSeQ", 6)) { - G_DeferedInitNew(currentUILevel->NextMap); + G_DeferedInitNew(primaryLevel->NextMap); } else { @@ -1125,9 +1125,9 @@ CCMD(nextsecret) return; } - if (currentUILevel->NextSecretMap.Len() > 0 && currentUILevel->NextSecretMap.Compare("enDSeQ", 6)) + if (primaryLevel->NextSecretMap.Len() > 0 && primaryLevel->NextSecretMap.Compare("enDSeQ", 6)) { - G_DeferedInitNew(currentUILevel->NextSecretMap); + G_DeferedInitNew(primaryLevel->NextSecretMap); } else { @@ -1172,10 +1172,10 @@ static void PrintSecretString(const char *string, bool thislevel) { auto secnum = (unsigned)strtoull(string+2, (char**)&string, 10); if (*string == ';') string++; - if (thislevel && secnum < currentUILevel->sectors.Size()) + if (thislevel && secnum < primaryLevel->sectors.Size()) { - if (currentUILevel->sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED; - else if (currentUILevel->sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN; + if (primaryLevel->sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED; + else if (primaryLevel->sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN; else colstr = TEXTCOLOR_ORANGE; } } @@ -1183,7 +1183,7 @@ static void PrintSecretString(const char *string, bool thislevel) { long tid = (long)strtoll(string+2, (char**)&string, 10); if (*string == ';') string++; - auto it = currentUILevel->GetActorIterator(tid); + auto it = primaryLevel->GetActorIterator(tid); AActor *actor; bool foundone = false; if (thislevel) @@ -1216,8 +1216,8 @@ static void PrintSecretString(const char *string, bool thislevel) CCMD(secret) { - const char *mapname = argv.argc() < 2? currentUILevel->MapName.GetChars() : argv[1]; - bool thislevel = !stricmp(mapname, currentUILevel->MapName); + const char *mapname = argv.argc() < 2? primaryLevel->MapName.GetChars() : argv[1]; + bool thislevel = !stricmp(mapname, primaryLevel->MapName); bool foundsome = false; int lumpno=Wads.CheckNumForName("SECRETS"); diff --git a/src/c_console.cpp b/src/c_console.cpp index b05e4c5a15..b25303c266 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1243,7 +1243,7 @@ void C_FullConsole () if (gamestate != GS_STARTUP) { gamestate = GS_FULLCONSOLE; - currentUILevel->Music = ""; + primaryLevel->Music = ""; S_Start (); P_FreeLevelData (); V_SetBlend (0,0,0,0); diff --git a/src/d_main.cpp b/src/d_main.cpp index 871323fc3f..71c9da650a 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -172,7 +172,7 @@ CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO) if (playeringame[i] && self <= D_GetFragCount(&players[i])) { Printf ("%s\n", GStrings("TXT_FRAGLIMIT")); - level.ExitLevel (0, false); + primaryLevel->ExitLevel (0, false); break; } } @@ -789,7 +789,7 @@ void D_Display () screen->DrawBlend(viewsec); if (automapactive) { - currentUILevel->automap->Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar()); + primaryLevel->automap->Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar()); } // for timing the statusbar code. @@ -959,7 +959,7 @@ void D_Display () void D_ErrorCleanup () { savegamerestore = false; - level.BotInfo.RemoveAllBots (&level, true); + primaryLevel->BotInfo.RemoveAllBots (primaryLevel, true); D_QuitNetGame (); if (demorecording || demoplayback) G_CheckDemoStatus (); @@ -2555,14 +2555,14 @@ void D_DoomMain (void) PClassActor::StaticSetActorNums(); //Added by MC: - level.BotInfo.getspawned.Clear(); + primaryLevel->BotInfo.getspawned.Clear(); argcount = Args->CheckParmList("-bots", &args); for (p = 0; p < argcount; ++p) { - level.BotInfo.getspawned.Push(args[p]); + primaryLevel->BotInfo.getspawned.Push(args[p]); } - level.BotInfo.spawn_tries = 0; - level.BotInfo.wanted_botnum = level.BotInfo.getspawned.Size(); + primaryLevel->BotInfo.spawn_tries = 0; + primaryLevel->BotInfo.wanted_botnum = primaryLevel->BotInfo.getspawned.Size(); if (!batchrun) Printf ("P_Init: Init Playloop state.\n"); StartScreen->LoadingStatus ("Init game engine", 0x3f); diff --git a/src/d_net.cpp b/src/d_net.cpp index 4b5906f468..6ad9b564d2 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2222,8 +2222,8 @@ void Net_DoCommand (int type, uint8_t **stream, int player) s = ReadString (stream); // Using LEVEL_NOINTERMISSION tends to throw the game out of sync. // That was a long time ago. Maybe it works now? - level.flags |= LEVEL_CHANGEMAPCHEAT; - level.ChangeLevel(s, pos, 0); + primaryLevel->flags |= LEVEL_CHANGEMAPCHEAT; + primaryLevel->ChangeLevel(s, pos, 0); break; case DEM_SUICIDE: @@ -2231,11 +2231,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player) break; case DEM_ADDBOT: - level.BotInfo.TryAddBot (&level, stream, player); + primaryLevel->BotInfo.TryAddBot (primaryLevel, stream, player); break; case DEM_KILLBOTS: - level.BotInfo.RemoveAllBots (&level, true); + primaryLevel->BotInfo.RemoveAllBots (primaryLevel, true); Printf ("Removed all bots\n"); break; @@ -2330,14 +2330,14 @@ void Net_DoCommand (int type, uint8_t **stream, int player) const AActor *def = GetDefaultByType (typeinfo); DVector3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->Angles.Yaw, 8.); - AActor *spawned = Spawn (&level, typeinfo, spawnpos, ALLOW_REPLACE); + AActor *spawned = Spawn (primaryLevel, typeinfo, spawnpos, ALLOW_REPLACE); if (spawned != NULL) { if (type == DEM_SUMMONFRIEND || type == DEM_SUMMONFRIEND2 || type == DEM_SUMMONMBF) { if (spawned->CountsAsKill()) { - level.total_monsters--; + primaryLevel->total_monsters--; } spawned->FriendPlayer = player + 1; spawned->flags |= MF_FRIENDLY; @@ -2507,7 +2507,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) } if (!CheckCheatmode(player == consoleplayer)) { - P_ExecuteSpecial(&level, snum, NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]); + P_ExecuteSpecial(primaryLevel, snum, NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]); } } break; @@ -2560,11 +2560,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player) if (cls != NULL) { - killcount = currentUILevel->Massacre(false, cls->TypeName); + killcount = primaryLevel->Massacre(false, cls->TypeName); PClassActor *cls_rep = cls->GetReplacement(); if (cls != cls_rep) { - killcount += currentUILevel->Massacre(false, cls_rep->TypeName); + killcount += primaryLevel->Massacre(false, cls_rep->TypeName); } Printf ("Killed %d monsters of type %s.\n",killcount, s); } @@ -2582,11 +2582,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player) PClassActor *cls = PClass::FindActor(s); if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor))) { - removecount = RemoveClass(&level, cls); + removecount = RemoveClass(primaryLevel, cls); const PClass *cls_rep = cls->GetReplacement(); if (cls != cls_rep) { - removecount += RemoveClass(&level, cls_rep); + removecount += RemoveClass(primaryLevel, cls_rep); } Printf("Removed %d actors of type %s.\n", removecount, s); } @@ -2660,7 +2660,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player) case DEM_FINISHGAME: // Simulate an end-of-game action - level.ChangeLevel(NULL, 0, 0); + primaryLevel->ChangeLevel(NULL, 0, 0); break; case DEM_NETEVENT: @@ -2698,7 +2698,7 @@ static void RunScript(uint8_t **stream, AActor *pawn, int snum, int argn, int al arg[i] = argval; } } - P_StartScript(pawn->Level, pawn, NULL, snum, level.MapName, arg, MIN(countof(arg), argn), ACS_NET | always); + P_StartScript(pawn->Level, pawn, NULL, snum, primaryLevel->MapName, arg, MIN(countof(arg), argn), ACS_NET | always); } void Net_SkipCommand (int type, uint8_t **stream) diff --git a/src/g_dumpinfo.cpp b/src/g_dumpinfo.cpp index e967f724b3..c07f36e601 100644 --- a/src/g_dumpinfo.cpp +++ b/src/g_dumpinfo.cpp @@ -259,12 +259,12 @@ CCMD(dump3df) // Print 3D floor info for a single sector. // This only checks the primary level. int sec = (int)strtoll(argv[1], NULL, 10); - if ((unsigned)sec >= currentUILevel->sectors.Size()) + if ((unsigned)sec >= primaryLevel->sectors.Size()) { Printf("Sector %d does not exist.\n", sec); return; } - sector_t *sector = ¤tUILevel->sectors[sec]; + sector_t *sector = &primaryLevel->sectors[sec]; TArray & ffloors = sector->e->XFloor.ffloors; for (unsigned int i = 0; i < ffloors.Size(); i++) diff --git a/src/g_game.cpp b/src/g_game.cpp index fe9404bff0..a021fb2819 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -773,7 +773,7 @@ void G_AddViewPitch (int look, bool mouse) return; } look = LookAdjust(look); - if (!currentUILevel->IsFreelookAllowed()) + if (!primaryLevel->IsFreelookAllowed()) { LocalViewPitch = 0; } @@ -959,7 +959,7 @@ bool G_Responder (event_t *ev) { if (ST_Responder (ev)) return true; // status window ate it - if (!viewactive && currentUILevel->automap->Responder (ev, false)) + if (!viewactive && primaryLevel->automap->Responder (ev, false)) return true; // automap ate it } else if (gamestate == GS_FINALE) @@ -990,7 +990,7 @@ bool G_Responder (event_t *ev) // the events *last* so that any bound keys get precedence. if (gamestate == GS_LEVEL && viewactive) - return currentUILevel->automap->Responder (ev, true); + return primaryLevel->automap->Responder (ev, true); return (ev->type == EV_KeyDown || ev->type == EV_Mouse); @@ -1018,7 +1018,7 @@ void G_Ticker () } if (players[i].playerstate == PST_REBORN || players[i].playerstate == PST_ENTER) { - level.DoReborn(i, false); + primaryLevel->DoReborn(i, false); } } } @@ -1114,7 +1114,7 @@ void G_Ticker () uint32_t rngsum = FRandom::StaticSumSeeds (); //Added by MC: For some of that bot stuff. The main bot function. - level.BotInfo.Main (&level); + primaryLevel->BotInfo.Main (primaryLevel); for (i = 0; i < MAXPLAYERS; i++) { @@ -1181,7 +1181,7 @@ void G_Ticker () { case GS_LEVEL: P_Ticker (); - currentUILevel->automap->Ticker (); + primaryLevel->automap->Ticker (); break; case GS_TITLELEVEL: @@ -1897,7 +1897,7 @@ void G_DoLoadGame () // Read intermission data for hubs G_SerializeHub(arc); - level.BotInfo.RemoveAllBots(&level, true); + primaryLevel->BotInfo.RemoveAllBots(primaryLevel, true); FString cvar; arc("importantcvars", cvar); @@ -2039,14 +2039,14 @@ void G_DoAutoSave () file = G_BuildSaveName ("auto", nextautosave); // The hint flag is only relevant on the primary level. - if (!(currentUILevel->flags2 & LEVEL2_NOAUTOSAVEHINT)) + if (!(primaryLevel->flags2 & LEVEL2_NOAUTOSAVEHINT)) { nextautosave = (nextautosave + 1) % count; } else { // This flag can only be used once per level - currentUILevel->flags2 &= ~LEVEL2_NOAUTOSAVEHINT; + primaryLevel->flags2 &= ~LEVEL2_NOAUTOSAVEHINT; } readableTime = myasctime (); @@ -2064,9 +2064,9 @@ static void PutSaveWads (FSerializer &arc) arc.AddString("Game WAD", name); // Name of wad the map resides in - if (Wads.GetLumpFile (level.lumpnum) > Wads.GetIwadNum()) + if (Wads.GetLumpFile (primaryLevel->lumpnum) > Wads.GetIwadNum()) { - name = Wads.GetWadName (Wads.GetLumpFile (level.lumpnum)); + name = Wads.GetWadName (Wads.GetLumpFile (primaryLevel->lumpnum)); arc.AddString("Map WAD", name); } } @@ -2085,12 +2085,11 @@ static void PutSaveComment (FSerializer &arc) arc.AddString("Creation Time", comment); // Get level name - //strcpy (comment, level.level_name); - comment.Format("%s - %s\n", level.MapName.GetChars(), level.LevelName.GetChars()); + comment.Format("%s - %s\n", primaryLevel->MapName.GetChars(), primaryLevel->LevelName.GetChars()); // Append elapsed time const char *const time = GStrings("SAVECOMMENT_TIME"); - levelTime = level.time / TICRATE; + levelTime = primaryLevel->time / TICRATE; comment.AppendFormat("%s: %02d:%02d:%02d", time, levelTime/3600, (levelTime%3600)/60, levelTime%60); // Write out the comment @@ -2121,7 +2120,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio // Do not even try, if we're not in a level. (Can happen after // a demo finishes playback.) - if (level.lines.Size() == 0 || level.sectors.Size() == 0 || gamestate != GS_LEVEL) + if (primaryLevel->lines.Size() == 0 || primaryLevel->sectors.Size() == 0 || gamestate != GS_LEVEL) { return; } @@ -2172,7 +2171,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio // put some basic info into the PNG so that this isn't lost when the image gets extracted. M_AppendPNGText(&savepic, "Software", buf); M_AppendPNGText(&savepic, "Title", description); - M_AppendPNGText(&savepic, "Current Map", level.MapName); + M_AppendPNGText(&savepic, "Current Map", primaryLevel->MapName); M_FinishPNG(&savepic); int ver = SAVEVER; @@ -2180,7 +2179,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio .AddString("Engine", GAMESIG) ("Save Version", ver) .AddString("Title", description) - .AddString("Current Map", level.MapName); + .AddString("Current Map", primaryLevel->MapName); PutSaveWads (savegameinfo); @@ -2390,7 +2389,7 @@ void G_BeginRecording (const char *startmap) if (startmap == NULL) { - startmap = level.MapName; + startmap = primaryLevel->MapName; } demo_p = demobuffer; @@ -2715,7 +2714,7 @@ void G_DoPlayDemo (void) { G_InitNew (mapname, false); } - else if (level.sectors.Size() == 0) + else if (primaryLevel->sectors.Size() == 0) { I_Error("Cannot play demo without its savegame\n"); } @@ -2886,6 +2885,7 @@ DEFINE_GLOBAL_NAMED(Skins, PlayerSkins) DEFINE_GLOBAL(consoleplayer) DEFINE_GLOBAL_NAMED(PClass::AllClasses, AllClasses) DEFINE_GLOBAL_NAMED(PClassActor::AllActorClasses, AllActorClasses) +DEFINE_GLOBAL_NAMED(primaryLevel, Level) DEFINE_GLOBAL(validcount) DEFINE_GLOBAL(multiplayer) DEFINE_GLOBAL(gameaction) diff --git a/src/g_level.cpp b/src/g_level.cpp index 193ba957ce..9a91e19971 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -167,7 +167,7 @@ extern bool sendpause, sendsave, sendturn180, SendLand; void *statcopy; // for statistics driver FLevelLocals level; // info about current level -FLevelLocals *currentUILevel = &level; // level for which to display the user interface. +FLevelLocals *primaryLevel = &level; // level for which to display the user interface. FLevelLocals *currentVMLevel = &level; // level which currently ticks. Used as global input to the VM and some functions called by it. @@ -216,7 +216,7 @@ CCMD (map) if (argv.argc() > 1) { const char *mapname = argv[1]; - if (!strcmp(mapname, "*")) mapname = currentUILevel->MapName.GetChars(); + if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars(); try { @@ -266,7 +266,7 @@ UNSAFE_CCMD(recordmap) if (argv.argc() > 2) { const char *mapname = argv[2]; - if (!strcmp(mapname, "*")) mapname = currentUILevel->MapName.GetChars(); + if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars(); try { @@ -357,7 +357,7 @@ void G_NewInit () int i; // Destory all old player refrences that may still exist - TThinkerIterator it(&level, NAME_PlayerPawn, STAT_TRAVELLING); + TThinkerIterator it(primaryLevel, NAME_PlayerPawn, STAT_TRAVELLING); AActor *pawn, *next; next = it.Next(); @@ -453,7 +453,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel) int i; // did we have any level before? - if (level.info != nullptr) + if (primaryLevel->info != nullptr) E_WorldUnloadedUnsafe(); if (!savegamerestore) @@ -470,7 +470,10 @@ void G_InitNew (const char *mapname, bool bTitleLevel) UnlatchCVars (); G_VerifySkill(); UnlatchCVars (); - level.Thinkers.DestroyThinkersInList(STAT_STATIC); + for (auto Level : AllLevels()) + { + Level->Thinkers.DestroyThinkersInList(STAT_STATIC); + } if (paused) { @@ -510,10 +513,10 @@ void G_InitNew (const char *mapname, bool bTitleLevel) } FRandom::StaticClearRandom (); P_ClearACSVars(true); - level.time = 0; - level.maptime = 0; - level.totaltime = 0; - level.spawnindex = 0; + primaryLevel->time = 0; + primaryLevel->maptime = 0; + primaryLevel->totaltime = 0; + primaryLevel->spawnindex = 0; if (!multiplayer || !deathmatch) { @@ -536,7 +539,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel) //Added by MC: Initialize bots. if (!deathmatch) { - level.BotInfo.Init (); + primaryLevel->BotInfo.Init (); } if (bTitleLevel) @@ -772,7 +775,7 @@ void G_DoCompleted (void) // Close the conversation menu if open. P_FreeStrifeConversations (); - if (level.DoCompleted(nextlevel, wminfo)) + if (primaryLevel->DoCompleted(nextlevel, wminfo)) { gamestate = GS_INTERMISSION; viewactive = false; @@ -954,7 +957,7 @@ void G_DoLoadLevel(const FString &nextmapname, int position, bool autosave, bool gamestate_t oldgs = gamestate; // Here the new level needs to be allocated. - level.DoLoadLevel(nextmapname, position, autosave, newGame); + primaryLevel->DoLoadLevel(nextmapname, position, autosave, newGame); // Reset the global state for the new level. if (wipegamestate == GS_LEVEL) @@ -1274,7 +1277,7 @@ void FLevelLocals::WorldDone (void) DEFINE_ACTION_FUNCTION(FLevelLocals, WorldDone) { - currentUILevel->WorldDone(); + primaryLevel->WorldDone(); return 0; } @@ -1290,9 +1293,9 @@ void G_DoWorldDone (void) { // Don't crash if no next map is given. Just repeat the current one. Printf ("No next map specified.\n"); - nextlevel = level.MapName; + nextlevel = primaryLevel->MapName; } - level.StartTravel (); + primaryLevel->StartTravel (); G_DoLoadLevel (nextlevel, startpos, true, false); startpos = 0; gameaction = ga_nothing; @@ -2282,7 +2285,7 @@ CCMD(skyfog) if (argv.argc()>1) { // Do this only on the primary level. - currentUILevel->skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0)); + primaryLevel->skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0)); } } diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 1d4cec550b..e43b27445e 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -672,7 +672,7 @@ public: extern FLevelLocals level; -extern FLevelLocals *currentUILevel; // level for which to display the user interface. This will always be the one the current consoleplayer is in. +extern FLevelLocals *primaryLevel; // level for which to display the user interface. This will always be the one the current consoleplayer is in. extern FLevelLocals *currentVMLevel; inline FSectorPortal *line_t::GetTransferredPortal() @@ -774,5 +774,5 @@ inline bool line_t::hitSkyWall(AActor* mo) const // It is meant for code that needs to iterate over all levels to make some global changes, e.g. configuation CCMDs. inline TArrayView AllLevels() { - return TArrayView(¤tUILevel, 1); + return TArrayView(&primaryLevel, 1); } diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 22f6d9ae45..58ad5ac110 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -1076,7 +1076,7 @@ public: lastHud = hud; // Handle inventory bar drawing - if(CPlayer->inventorytics > 0 && !(currentUILevel->flags & LEVEL_NOINVENTORYBAR) && (state == HUD_StatusBar || state == HUD_Fullscreen)) + if(CPlayer->inventorytics > 0 && !(primaryLevel->flags & LEVEL_NOINVENTORYBAR) && (state == HUD_StatusBar || state == HUD_Fullscreen)) { SBarInfoMainBlock *inventoryBar = state == HUD_StatusBar ? script->huds[STBAR_INVENTORY] : script->huds[STBAR_INVENTORYFULLSCREEN]; if(inventoryBar != lastInventoryBar) diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index dd21c089f5..2cfea843ec 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -850,26 +850,26 @@ class CommandDrawString : public SBarInfoCommand switch(strValue) { case LEVELNAME: - if(currentUILevel->lumpnum != cache) + if(primaryLevel->lumpnum != cache) { - cache = currentUILevel->lumpnum; - str = currentUILevel->LevelName; + cache = primaryLevel->lumpnum; + str = primaryLevel->LevelName; RealignString(); } break; case LEVELLUMP: - if(currentUILevel->lumpnum != cache) + if(primaryLevel->lumpnum != cache) { - cache = currentUILevel->lumpnum; - str = currentUILevel->MapName; + cache = primaryLevel->lumpnum; + str = primaryLevel->MapName; str.ToUpper(); RealignString(); } break; case SKILLNAME: - if(currentUILevel->lumpnum != cache) // Can only change skill between currentUILevel-> + if(primaryLevel->lumpnum != cache) // Can only change skill between primaryLevel-> { - cache = currentUILevel->lumpnum; + cache = primaryLevel->lumpnum; str = G_SkillName(); RealignString(); } @@ -904,7 +904,7 @@ class CommandDrawString : public SBarInfoCommand if(ACS_GlobalVars[valueArgument] != cache) { cache = ACS_GlobalVars[valueArgument]; - str = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[valueArgument]); + str = primaryLevel->Behaviors.LookupString(ACS_GlobalVars[valueArgument]); RealignString(); } break; @@ -912,13 +912,13 @@ class CommandDrawString : public SBarInfoCommand if(ACS_GlobalArrays[valueArgument][consoleplayer] != cache) { cache = ACS_GlobalArrays[valueArgument][consoleplayer]; - str = currentUILevel->Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]); + str = primaryLevel->Behaviors.LookupString(ACS_GlobalArrays[valueArgument][consoleplayer]); RealignString(); } break; case TIME: { - int sec = Tics2Seconds(currentUILevel->time); + int sec = Tics2Seconds(primaryLevel->time); str.Format("%02d:%02d:%02d", sec / 3600, (sec % 3600) / 60, sec % 60); break; } @@ -1389,25 +1389,25 @@ class CommandDrawNumber : public CommandDrawString num = statusBar->CPlayer->fragcount; break; case KILLS: - num = currentUILevel->killed_monsters; + num = primaryLevel->killed_monsters; break; case MONSTERS: - num = currentUILevel->total_monsters; + num = primaryLevel->total_monsters; break; case ITEMS: - num = currentUILevel->found_items; + num = primaryLevel->found_items; break; case TOTALITEMS: - num = currentUILevel->total_items; + num = primaryLevel->total_items; break; case SECRETS: - num = currentUILevel->found_secrets; + num = primaryLevel->found_secrets; break; case SCORE: num = statusBar->CPlayer->mo->Score; break; case TOTALSECRETS: - num = currentUILevel->total_secrets; + num = primaryLevel->total_secrets; break; case ARMORCLASS: case SAVEPERCENT: @@ -1459,9 +1459,9 @@ class CommandDrawNumber : public CommandDrawString case AIRTIME: { if(statusBar->CPlayer->mo->waterlevel < 3) - num = currentUILevel->airsupply/TICRATE; + num = primaryLevel->airsupply/TICRATE; else - num = clamp((statusBar->CPlayer->air_finished - currentUILevel->time + (TICRATE-1))/TICRATE, 0, INT_MAX); + num = clamp((statusBar->CPlayer->air_finished - primaryLevel->time + (TICRATE-1))/TICRATE, 0, INT_MAX); break; } case SELECTEDINVENTORY: @@ -1502,7 +1502,7 @@ class CommandDrawNumber : public CommandDrawString } default: break; } - if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1)) + if(interpolationSpeed != 0 && (!hudChanged || primaryLevel->time == 1)) { if(num < drawValue) drawValue -= clamp((drawValue - num) >> 2, 1, interpolationSpeed); @@ -1691,7 +1691,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra if(alternateOnEmpty) SBarInfoCommandFlowControl::Draw(block, statusBar); - if(statusBar->CPlayer->mo->PointerVar(NAME_InvSel) != NULL && !(currentUILevel->flags & LEVEL_NOINVENTORYBAR)) + if(statusBar->CPlayer->mo->PointerVar(NAME_InvSel) != NULL && !(primaryLevel->flags & LEVEL_NOINVENTORYBAR)) { if(artiflash && statusBar->wrapper->artiflashTick) { @@ -1791,7 +1791,7 @@ class CommandDrawSelectedInventory : public CommandDrawImage, private CommandDra { SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); - SetTruth(statusBar->CPlayer->mo->PointerVar(NAME_InvSel) == NULL || (currentUILevel->flags & LEVEL_NOINVENTORYBAR), block, statusBar); + SetTruth(statusBar->CPlayer->mo->PointerVar(NAME_InvSel) == NULL || (primaryLevel->flags & LEVEL_NOINVENTORYBAR), block, statusBar); CommandDrawImage::Tick(block, statusBar, hudChanged); CommandDrawNumber::Tick(block, statusBar, hudChanged); @@ -1910,7 +1910,7 @@ class CommandInventoryBarNotVisible : public SBarInfoCommandFlowControl { SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); - SetTruth(statusBar->CPlayer->inventorytics <= 0 || (currentUILevel->flags & LEVEL_NOINVENTORYBAR), block, statusBar); + SetTruth(statusBar->CPlayer->inventorytics <= 0 || (primaryLevel->flags & LEVEL_NOINVENTORYBAR), block, statusBar); } }; @@ -2727,16 +2727,16 @@ class CommandDrawBar : public SBarInfoCommand max = fraglimit; break; case KILLS: - value = currentUILevel->killed_monsters; - max = currentUILevel->total_monsters; + value = primaryLevel->killed_monsters; + max = primaryLevel->total_monsters; break; case ITEMS: - value = currentUILevel->found_items; - max = currentUILevel->total_items; + value = primaryLevel->found_items; + max = primaryLevel->total_items; break; case SECRETS: - value = currentUILevel->found_secrets; - max = currentUILevel->total_secrets; + value = primaryLevel->found_secrets; + max = primaryLevel->total_secrets; break; case INVENTORY: { @@ -2751,8 +2751,8 @@ class CommandDrawBar : public SBarInfoCommand break; } case AIRTIME: - value = clamp(statusBar->CPlayer->air_finished - currentUILevel->time, 0, INT_MAX); - max = currentUILevel->airsupply; + value = clamp(statusBar->CPlayer->air_finished - primaryLevel->time, 0, INT_MAX); + max = primaryLevel->airsupply; break; case POWERUPTIME: { @@ -2798,7 +2798,7 @@ class CommandDrawBar : public SBarInfoCommand } else value = 0; - if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1)) + if(interpolationSpeed != 0 && (!hudChanged || primaryLevel->time == 1)) { // [BL] Since we used a percentage (in order to get the most fluid animation) // we need to establish a cut off point so the last pixel won't hang as the animation slows @@ -3192,7 +3192,7 @@ class CommandDrawGem : public SBarInfoCommand goalValue = reverse ? 100 - goalValue : goalValue; - if(interpolationSpeed != 0 && (!hudChanged || currentUILevel->time == 1)) // At the start force an animation + if(interpolationSpeed != 0 && (!hudChanged || primaryLevel->time == 1)) // At the start force an animation { if(goalValue < drawValue) drawValue -= clamp((drawValue - goalValue) >> 2, 1, interpolationSpeed); @@ -3202,7 +3202,7 @@ class CommandDrawGem : public SBarInfoCommand else drawValue = goalValue; - if(wiggle && currentUILevel->time & 1) + if(wiggle && primaryLevel->time & 1) chainWiggle = pr_chainwiggle() & 1; } protected: diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index 2c012c81d4..80c5f365ca 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -789,7 +789,7 @@ void DBaseStatusBar::RefreshViewBorder () { return; } - auto tex = GetBorderTexture(currentUILevel); + auto tex = GetBorderTexture(primaryLevel); screen->DrawBorder (tex, 0, 0, Width, viewwindowy); screen->DrawBorder (tex, 0, viewwindowy, viewwindowx, viewheight + viewwindowy); screen->DrawBorder (tex, viewwindowx + viewwidth, viewwindowy, Width, viewheight + viewwindowy); @@ -815,7 +815,7 @@ void DBaseStatusBar::RefreshBackground () const if (x == 0 && y == SCREENHEIGHT) return; - auto tex = GetBorderTexture(currentUILevel); + auto tex = GetBorderTexture(primaryLevel); if(!CompleteBorder) { diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 0826b160af..f5f45fdca2 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -2285,8 +2285,8 @@ static void ClearMapinfo() AllSkills.Clear(); DefaultSkill = -1; DeinitIntermissions(); - level.info = NULL; - level.F1Pic = ""; + primaryLevel->info = nullptr; + primaryLevel->F1Pic = ""; } //========================================================================== diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 2906218847..26252c7bb4 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -369,7 +369,7 @@ static void HU_DrawTimeRemaining (int y) if (deathmatch && timelimit && gamestate == GS_LEVEL) { char str[80]; - int timeleft = (int)(timelimit * TICRATE * 60) - currentUILevel->maptime; + int timeleft = (int)(timelimit * TICRATE * 60) - primaryLevel->maptime; int hours, minutes, seconds; if (timeleft < 0) diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 2d395a48e4..a01f5325a0 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -787,7 +787,7 @@ void DIntermissionController::Ticker () switch (mGameState) { case FSTATE_InLevel: - currentUILevel->SetMusic(); + primaryLevel->SetMusic(); gamestate = GS_LEVEL; wipegamestate = GS_LEVEL; P_ResumeConversation (); diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 31e9853704..6d47dd2fc6 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -324,7 +324,7 @@ void cht_DoCheat (player_t *player, int cheat) case CHT_MASSACRE: case CHT_MASSACRE2: { - int killcount = currentUILevel->Massacre (cheat == CHT_MASSACRE2); + int killcount = primaryLevel->Massacre (cheat == CHT_MASSACRE2); // killough 3/22/98: make more intelligent about plural // Ty 03/27/98 - string(s) *not* externalized mysnprintf (msgbuild, countof(msgbuild), "%d %s%s Killed", killcount, diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index cee4e897d6..130c090898 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -823,7 +823,7 @@ void CopyPlayer(player_t *dst, player_t *src, const char *name) if (dst->Bot != nullptr) { - botinfo_t *thebot = level.BotInfo.botinfo; + botinfo_t *thebot = src->mo->Level->BotInfo.botinfo; while (thebot && stricmp(name, thebot->name)) { thebot = thebot->next; @@ -832,7 +832,7 @@ void CopyPlayer(player_t *dst, player_t *src, const char *name) { thebot->inuse = BOTINUSE_Yes; } - level.BotInfo.botnum++; + src->mo->Level->BotInfo.botnum++; dst->userinfo.TransferFrom(uibackup2); } else diff --git a/src/p_setup.cpp b/src/p_setup.cpp index abf4fadbd2..fd3bc85378 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -353,7 +353,11 @@ void P_FreeLevelData () E_Shutdown(true); R_FreePastViewers(); - level.ClearLevelData(); + for (auto Level : AllLevels()) + { + Level->ClearLevelData(); + } + // primaryLevel->FreeSecondaryLevels(); } //=========================================================================== @@ -577,7 +581,10 @@ void P_Init () static void P_Shutdown () { - level.Thinkers.DestroyThinkersInList(STAT_STATIC); + for (auto Level : AllLevels()) + { + Level->Thinkers.DestroyThinkersInList(STAT_STATIC); + } P_FreeLevelData (); // [ZZ] delete global event handlers E_Shutdown(false); diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 8d1b7481d3..a2f4da5100 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -65,7 +65,7 @@ bool P_CheckTickerPaused () && wipegamestate == gamestate) { // Only the current UI level's settings are relevant for sound. - S_PauseSound (!(currentUILevel->flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false); + S_PauseSound (!(primaryLevel->flags2 & LEVEL2_PAUSE_MUSIC_IN_MENUS), false); return true; } return false; @@ -99,7 +99,7 @@ void P_Ticker (void) // [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer(). // This may not be perfect but it is not really relevant for sublevels that tracer homing behavior is preserved. - if ((currentUILevel->maptime & 3) == 0) + if ((primaryLevel->maptime & 3) == 0) { if (globalchangefreeze) { @@ -151,18 +151,22 @@ void P_Ticker (void) // [ZZ] call the WorldTick hook E_WorldTick(); StatusBar->CallTick (); // [RH] moved this here - level.Tick (); // [RH] let the level tick - level.Thinkers.RunThinkers(&level); - - //if added by MC: Freeze mode. - if (!level.isFrozen()) + for (auto Level : AllLevels()) { - P_UpdateSpecials (&level); - P_RunEffects(&level); // [RH] Run particle effects - } + // todo: set up a sandbox for secondary levels here. + Level->Tick(); // [RH] let the level tick + Level->Thinkers.RunThinkers(Level); + + //if added by MC: Freeze mode. + if (!Level->isFrozen()) + { + P_UpdateSpecials(Level); + P_RunEffects(Level); // [RH] Run particle effects + } // for par times - level.time++; - level.maptime++; - level.totaltime++; + Level->time++; + Level->maptime++; + Level->totaltime++; + } } diff --git a/src/p_user.cpp b/src/p_user.cpp index dea310a8a1..1535ff993c 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -956,8 +956,8 @@ void P_CheckPlayerSprite(AActor *actor, int &spritenum, DVector2 &scale) CUSTOM_CVAR (Float, sv_aircontrol, 0.00390625f, CVAR_SERVERINFO|CVAR_NOSAVE) { - currentUILevel->aircontrol = self; - currentUILevel->AirControlChanged (); + primaryLevel->aircontrol = self; + primaryLevel->AirControlChanged (); } //========================================================================== diff --git a/src/posix/sdl/i_main.cpp b/src/posix/sdl/i_main.cpp index 4ea48c4019..caddfcf870 100644 --- a/src/posix/sdl/i_main.cpp +++ b/src/posix/sdl/i_main.cpp @@ -165,7 +165,7 @@ static int DoomSpecificInfo (char *buffer, char *end) } else { - p += snprintf (buffer+p, size-p, "\n\nCurrent map: %s", currentUILevel->MapName.GetChars()); + p += snprintf (buffer+p, size-p, "\n\nCurrent map: %s", primaryLevel->MapName.GetChars()); if (!viewactive) { diff --git a/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp b/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp index 74a60a4521..e563814e1a 100644 --- a/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp +++ b/src/rendering/hwrenderer/dynlights/hw_shadowmap.cpp @@ -112,9 +112,10 @@ void IShadowMap::CollectLights() { if (mLights.Size() != 1024 * 4) mLights.Resize(1024 * 4); int lightindex = 0; + auto Level = &level; // Todo: this should go through the blockmap in a spiral pattern around the player so that closer lights are preferred. - for (auto light = level.lights; light; light = light->next) + for (auto light = Level->lights; light; light = light->next) { LightsProcessed++; if (light->shadowmapped && light->IsActive() && lightindex < 1024 * 4) diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 0bf1da0ad2..ee40d6241f 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -403,16 +403,16 @@ void S_Start () FString LocalSndSeq; // To be certain better check whether level is valid! - if (currentUILevel->info) + if (primaryLevel->info) { - LocalSndInfo = currentUILevel->info->SoundInfo; - LocalSndSeq = currentUILevel->info->SndSeq; + LocalSndInfo = primaryLevel->info->SoundInfo; + LocalSndSeq = primaryLevel->info->SndSeq; } bool parse_ss = false; // This level uses a different local SNDINFO - if (LastLocalSndInfo.CompareNoCase(LocalSndInfo) != 0 || !currentUILevel->info) + if (LastLocalSndInfo.CompareNoCase(LocalSndInfo) != 0 || !primaryLevel->info) { // First delete the old sound list for(unsigned i = 1; i < S_sfx.Size(); i++) @@ -457,9 +457,9 @@ void S_Start () // Don't start the music if loading a savegame, because the music is stored there. // Don't start the music if revisiting a level in a hub for the same reason. - if (!currentUILevel->IsReentering()) + if (!primaryLevel->IsReentering()) { - currentUILevel->SetMusic(); + primaryLevel->SetMusic(); } } @@ -475,7 +475,7 @@ void S_PrecacheLevel (FLevelLocals *Level) { unsigned int i; - if (GSnd && Level == currentUILevel) + if (GSnd && Level == primaryLevel) { for (i = 0; i < S_sfx.Size(); ++i) { @@ -499,7 +499,7 @@ void S_PrecacheLevel (FLevelLocals *Level) FSoundID(snd).MarkUsed(); } // Precache all extra sounds requested by this map. - for (auto snd : currentUILevel->info->PrecacheSounds) + for (auto snd : primaryLevel->info->PrecacheSounds) { FSoundID(snd).MarkUsed(); } @@ -705,8 +705,8 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, // on static analysis. if(type == SOURCE_Unattached) { - sector_t *sec = currentUILevel->PointInSector(pt[0], pt[2]); - DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, sec->PortalGroup); + sector_t *sec = primaryLevel->PointInSector(pt[0], pt[2]); + DVector2 disp = primaryLevel->Displacements.getOffset(pgroup, sec->PortalGroup); pos->X = pt[0] - (float)disp.X; pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z; pos->Z = pt[2] - (float)disp.Y; @@ -723,7 +723,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, //assert(actor != NULL); if (actor != NULL) { - DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, actor->Sector->PortalGroup); + DVector2 disp = primaryLevel->Displacements.getOffset(pgroup, actor->Sector->PortalGroup); DVector3 posi = actor->Pos() - disp; *pos = { (float)posi.X, (float)posi.Z, (float)posi.Y }; } @@ -733,7 +733,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, assert(sector != NULL); if (sector != NULL) { - DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, sector->PortalGroup); + DVector2 disp = primaryLevel->Displacements.getOffset(pgroup, sector->PortalGroup); if (chanflags & CHAN_AREA) { // listener must be reversely offset to calculate the proper sound origin. @@ -755,7 +755,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, assert(poly != NULL); if (poly != NULL) { - DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, poly->CenterSubsector->sector->PortalGroup); + DVector2 disp = primaryLevel->Displacements.getOffset(pgroup, poly->CenterSubsector->sector->PortalGroup); CalcPolyobjSoundOrg(listenpos + disp, poly, *pos); pos->X -= (float)disp.X; pos->Z -= (float)disp.Y; @@ -852,7 +852,7 @@ static void CalcSectorSoundOrg(const DVector3 &listenpos, const sector_t *sec, i if (!(sec->Level->i_compatflags & COMPATF_SECTORSOUNDS)) { // Are we inside the sector? If yes, the closest point is the one we're on. - if (currentUILevel->PointInSector(listenpos.X, listenpos.Y) == sec) + if (primaryLevel->PointInSector(listenpos.X, listenpos.Y) == sec) { pos.X = (float)listenpos.X; pos.Z = (float)listenpos.Y; @@ -916,7 +916,7 @@ static void CalcPolyobjSoundOrg(const DVector3 &listenpos, const FPolyObj *poly, // // S_StartSound // -// 0 attenuation means full volume over whole currentUILevel-> +// 0 attenuation means full volume over whole primaryLevel-> // 0 < attenuation means to scale the distance by that amount when // calculating volume. // @@ -1337,7 +1337,7 @@ DEFINE_ACTION_FUNCTION(DObject, S_Sound) void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float attenuation) { - if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != currentUILevel) + if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != primaryLevel) return; S_StartSound (ent, nullptr, nullptr, nullptr, channel, sound_id, volume, attenuation); } @@ -1352,7 +1352,7 @@ void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float a void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume, float mindist, float maxdist) { - if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != currentUILevel) + if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != primaryLevel) return; FRolloffInfo rolloff; @@ -1371,7 +1371,7 @@ void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume, float attenuation) { - if (poly->Level != currentUILevel) return; + if (poly->Level != primaryLevel) return; S_StartSound (nullptr, nullptr, poly, nullptr, channel, sound_id, volume, attenuation); } @@ -1383,7 +1383,7 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sound_id, float volume, float attenuation) { - if (Level != currentUILevel) return; + if (Level != primaryLevel) return; // The sound system switches Y and Z around. FVector3 p((float)pos.X, (float)pos.Z, (float)pos.Y); S_StartSound (nullptr, nullptr, nullptr, &p, channel, sound_id, volume, attenuation); @@ -1397,7 +1397,7 @@ void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sou void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation) { - if (sec->Level != currentUILevel) return; + if (sec->Level != primaryLevel) return; S_StartSound (nullptr, sec, nullptr, nullptr, channel, sfxid, volume, attenuation); } @@ -1411,7 +1411,7 @@ void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, fl void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local) { - if (a == nullptr || a->Sector->Flags & SECF_SILENT || a->Level != currentUILevel) + if (a == nullptr || a->Sector->Flags & SECF_SILENT || a->Level != primaryLevel) return; if (!local) @@ -2190,7 +2190,7 @@ void S_UpdateSounds (AActor *listenactor) GSnd->UpdateListener(&listener); GSnd->UpdateSounds(); - if (currentUILevel->time >= RestartEvictionsAt) + if (primaryLevel->time >= RestartEvictionsAt) { RestartEvictionsAt = 0; S_RestoreEvictedChannels(); @@ -2216,8 +2216,8 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor) listener.velocity.Zero(); listener.position = listenactor->SoundPos(); listener.underwater = listenactor->waterlevel == 3; - assert(currentUILevel->Zones.Size() > listenactor->Sector->ZoneNumber); - listener.Environment = currentUILevel->Zones[listenactor->Sector->ZoneNumber].Environment; + assert(primaryLevel->Zones.Size() > listenactor->Sector->ZoneNumber); + listener.Environment = primaryLevel->Zones[listenactor->Sector->ZoneNumber].Environment; listener.valid = true; } else @@ -2495,7 +2495,7 @@ void S_SerializeSounds(FSerializer &arc) // playing before the wipe, and depending on the synchronization // between the main thread and the mixer thread at the time, the // sounds might be heard briefly before pausing for the wipe. - RestartEvictionsAt = currentUILevel->time + 2; + RestartEvictionsAt = primaryLevel->time + 2; } GSnd->Sync(false); GSnd->UpdateSounds(); @@ -2585,8 +2585,8 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force) { if (gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL) { - musicname = currentUILevel->Music; - order = currentUILevel->musicorder; + musicname = primaryLevel->Music; + order = primaryLevel->musicorder; } else { @@ -2866,7 +2866,7 @@ CCMD (loopsound) } else { - AActor *icon = Spawn(&level, "SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32.), ALLOW_REPLACE); + AActor *icon = Spawn(primaryLevel, "SpeakerIcon", players[consoleplayer].mo->PosPlusZ(32.), ALLOW_REPLACE); if (icon != NULL) { S_Sound(icon, CHAN_BODY | CHAN_LOOP, id, 1.f, ATTN_IDLE); diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index e78707413b..96e63c0374 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2359,7 +2359,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, SetClipRect, SBar_SetClipRect) static void GetGlobalACSString(int index, FString *result) { - *result = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[index]); + *result = primaryLevel->Behaviors.LookupString(ACS_GlobalVars[index]); } DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSString, GetGlobalACSString) @@ -2373,7 +2373,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSString, GetGlobalACSSt static void GetGlobalACSArrayString(int arrayno, int index, FString *result) { - *result = currentUILevel->Behaviors.LookupString(ACS_GlobalVars[index]); + *result = primaryLevel->Behaviors.LookupString(ACS_GlobalVars[index]); } DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetGlobalACSArrayString, GetGlobalACSArrayString) @@ -2846,8 +2846,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_AltHUD, GetLatency, Net_GetLatency) // // //========================================================================== -DEFINE_GLOBAL(level); -DEFINE_GLOBAL(currentUILevel); +DEFINE_GLOBAL(currentVMLevel, level); DEFINE_FIELD(FLevelLocals, sectors) DEFINE_FIELD(FLevelLocals, lines) DEFINE_FIELD(FLevelLocals, sides) diff --git a/src/st_stuff.cpp b/src/st_stuff.cpp index 8213171386..ffa79fe01b 100644 --- a/src/st_stuff.cpp +++ b/src/st_stuff.cpp @@ -489,7 +489,7 @@ static bool Cht_ChangeStartSpot (cheatseq_t *cheat) { char cmd[64]; - mysnprintf (cmd, countof(cmd), "changemap %s %c", currentUILevel->MapName.GetChars(), cheat->Args[0]); + mysnprintf (cmd, countof(cmd), "changemap %s %c", primaryLevel->MapName.GetChars(), cheat->Args[0]); C_DoCommand (cmd); return true; } diff --git a/src/statistics.cpp b/src/statistics.cpp index 04c780f340..db17201302 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -577,7 +577,7 @@ FString GetStatString() CCMD(printstats) { - StoreLevelStats(currentUILevel); // Refresh the current level's results. + StoreLevelStats(primaryLevel); // Refresh the current level's results. Printf("%s", GetStatString().GetChars()); } @@ -596,6 +596,6 @@ CCMD(finishgame) ADD_STAT(statistics) { - StoreLevelStats(currentUILevel); // Refresh the current level's results. + StoreLevelStats(primaryLevel); // Refresh the current level's results. return GetStatString(); } diff --git a/src/v_2ddrawer.cpp b/src/v_2ddrawer.cpp index 21b860b9d3..ca0cec6b4f 100644 --- a/src/v_2ddrawer.cpp +++ b/src/v_2ddrawer.cpp @@ -428,7 +428,7 @@ void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints, // is necessary in order to best reproduce Doom's original lighting. double fadelevel; - if (vid_rendermode != 4 || currentUILevel->lightMode == ELightMode::Doom || currentUILevel->lightMode == ELightMode::ZDoomSoftware || currentUILevel->lightMode == ELightMode::DoomSoftware) + if (vid_rendermode != 4 || primaryLevel->lightMode == ELightMode::Doom || primaryLevel->lightMode == ELightMode::ZDoomSoftware || primaryLevel->lightMode == ELightMode::DoomSoftware) { double map = (NUMCOLORMAPS * 2.) - ((lightlevel + 12) * (NUMCOLORMAPS / 128.)); fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0); diff --git a/src/v_video.cpp b/src/v_video.cpp index 8c8dccf97a..b971a9eb32 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -595,8 +595,8 @@ void V_OutputResized (int width, int height) C_NewModeAdjust(); // Reload crosshair if transitioned to a different size ST_LoadCrosshair(true); - if (currentUILevel && currentUILevel->automap) - currentUILevel->automap->NewResolution(); + if (primaryLevel && primaryLevel->automap) + primaryLevel->automap->NewResolution(); } void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2) diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 2a35242d6b..4ca5bdce4d 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1105,7 +1105,7 @@ void DoomSpecificInfo (char *buffer, size_t bufflen) } else { - buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", currentUILevel->MapName.GetChars()); + buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", primaryLevel->MapName.GetChars()); if (!viewactive) { diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 070f3f0337..2a81b410e9 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -1,3 +1,4 @@ + struct _ native // These are the global variables, the struct is only here to avoid extending the parser for this. { native readonly Array AllClasses; @@ -7,20 +8,16 @@ struct _ native // These are the global variables, the struct is only here to av native readonly Array<@Team> Teams; native int validcount; native readonly bool multiplayer; - deprecated("3.8") native play @LevelLocals level; native @KeyBindings Bindings; native @KeyBindings AutomapBindings; native play @DehInfo deh; native readonly @GameInfoStruct gameinfo; - native play @PlayerInfo players[MAXPLAYERS]; - native readonly bool playeringame[MAXPLAYERS]; native readonly ui bool netgame; native readonly bool automapactive; native play uint gameaction; native readonly int gamestate; native readonly TextureID skyflatnum; - native readonly int consoleplayer; native readonly Font smallfont; native readonly Font smallfont2; native readonly Font bigfont; @@ -43,10 +40,16 @@ struct _ native // These are the global variables, the struct is only here to av native readonly int Net_Arbitrator; native ui BaseStatusBar StatusBar; native readonly Weapon WP_NOCHANGE; - native int LocalViewPitch; - native ui readonly LevelLocals currentUILevel; deprecated("3.8") native readonly bool globalfreeze; - + native int LocalViewPitch; + +// sandbox state in multi-level setups: + + native play @PlayerInfo players[MAXPLAYERS]; + native readonly bool playeringame[MAXPLAYERS]; + native readonly int consoleplayer; + native play LevelLocals Level; + } struct TexMan diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 02e78fe7f8..4a1154febf 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -97,15 +97,15 @@ struct Side native play int GetUDMFInt(Name nm) { - return sector.Level.GetUDMFInt(LevelLocals.UDMF_Side, Index(), nm); + return Level.GetUDMFInt(LevelLocals.UDMF_Side, Index(), nm); } double GetUDMFFloat(Name nm) { - return sector.Level.GetUDMFFloat(LevelLocals.UDMF_Side, Index(), nm); + return Level.GetUDMFFloat(LevelLocals.UDMF_Side, Index(), nm); } String GetUDMFString(Name nm) { - return sector.Level.GetUDMFString(LevelLocals.UDMF_Side, Index(), nm); + return Level.GetUDMFString(LevelLocals.UDMF_Side, Index(), nm); } }; @@ -180,15 +180,15 @@ struct Line native play int GetUDMFInt(Name nm) { - return frontsector.Level.GetUDMFInt(LevelLocals.UDMF_Line, Index(), nm); + return Level.GetUDMFInt(LevelLocals.UDMF_Line, Index(), nm); } double GetUDMFFloat(Name nm) { - return frontsector.Level.GetUDMFFloat(LevelLocals.UDMF_Line, Index(), nm); + return Level.GetUDMFFloat(LevelLocals.UDMF_Line, Index(), nm); } String GetUDMFString(Name nm) { - return frontsector.Level.GetUDMFString(LevelLocals.UDMF_Line, Index(), nm); + return Level.GetUDMFString(LevelLocals.UDMF_Line, Index(), nm); } native clearscope int GetHealth(); @@ -259,7 +259,6 @@ struct Sector native play native SectorEffect floordata; native SectorEffect ceilingdata; native SectorEffect lightingdata; - native readonly LevelLocals Level; enum EPlane { diff --git a/wadsrc/static/zscript/menu/conversationmenu.txt b/wadsrc/static/zscript/menu/conversationmenu.txt index 271381ae3f..02201a0ddf 100644 --- a/wadsrc/static/zscript/menu/conversationmenu.txt +++ b/wadsrc/static/zscript/menu/conversationmenu.txt @@ -509,7 +509,7 @@ class ConversationMenu : Menu override void Ticker() { // [CW] Freeze the game depending on MAPINFO options. - if (ConversationPauseTic < gametic && !multiplayer && !currentUILevel.no_dlg_freeze) + if (ConversationPauseTic < gametic && !multiplayer && !Level.no_dlg_freeze) { menuactive = Menu.On; } diff --git a/wadsrc/static/zscript/menu/readthis.txt b/wadsrc/static/zscript/menu/readthis.txt index d1581d9675..58904b0f4e 100644 --- a/wadsrc/static/zscript/menu/readthis.txt +++ b/wadsrc/static/zscript/menu/readthis.txt @@ -57,9 +57,9 @@ class ReadThisMenu : GenericMenu TextureID tex, prevpic; // Did the mapper choose a custom help page via MAPINFO? - if (currentUILevel.F1Pic.Length() != 0) + if (Level.F1Pic.Length() != 0) { - tex = TexMan.CheckForTexture(currentUILevel.F1Pic, TexMan.Type_MiscPatch); + tex = TexMan.CheckForTexture(Level.F1Pic, TexMan.Type_MiscPatch); mScreen = 1; } @@ -98,7 +98,7 @@ class ReadThisMenu : GenericMenu MenuSound("menu/choose"); mScreen++; mInfoTic = gametic; - if (currentUILevel.F1Pic.Length() != 0 || mScreen > gameinfo.infoPages.Size()) + if (Level.F1Pic.Length() != 0 || mScreen > gameinfo.infoPages.Size()) { Close(); } diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 0394fbcbdd..d9cddda07e 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -334,13 +334,6 @@ class PlayerPawn : Actor { let player = self.player; - // [SO] 9/2/02: People were able to do an awful lot of damage - // when they were observers... - if (player.Bot == null && bot_observer) - { - return; - } - let weapn = player.ReadyWeapon; if (weapn == null || !weapn.CheckAmmo (Weapon.PrimaryFire, true)) { @@ -369,13 +362,6 @@ class PlayerPawn : Actor virtual void FireWeaponAlt (State stat) { - // [SO] 9/2/02: People were able to do an awful lot of damage - // when they were observers... - if (player.Bot == null && bot_observer) - { - return; - } - let weapn = player.ReadyWeapon; if (weapn == null || weapn.FindState('AltFire') == null || !weapn.CheckAmmo (Weapon.AltFire, true)) { diff --git a/wadsrc/static/zscript/statscreen/statscreen.txt b/wadsrc/static/zscript/statscreen/statscreen.txt index 084d9a2567..dc6fd446fd 100644 --- a/wadsrc/static/zscript/statscreen/statscreen.txt +++ b/wadsrc/static/zscript/statscreen/statscreen.txt @@ -461,7 +461,7 @@ class StatusScreen abstract play version("2.5") if (cnt == 0) { End(); - currentUILevel.WorldDone(); + Level.WorldDone(); } } @@ -477,7 +477,7 @@ class StatusScreen abstract play version("2.5") { // Last map in episode - there is no next location! End(); - currentUILevel.WorldDone(); + Level.WorldDone(); return; } @@ -608,7 +608,7 @@ class StatusScreen abstract play version("2.5") virtual void StartMusic() { - currentUILevel.SetInterMusic(wbs.next); + Level.SetInterMusic(wbs.next); } //==================================================================== @@ -706,7 +706,7 @@ class StatusScreen abstract play version("2.5") Par = TexMan.CheckForTexture("WIPAR", TexMan.Type_MiscPatch); // "par" // Use the local level structure which can be overridden by hubs - lnametexts[0] = currentUILevel.LevelName; + lnametexts[0] = Level.LevelName; lnametexts[1] = wbstartstruct.nextname; bg = InterBackground.Create(wbs); diff --git a/wadsrc/static/zscript/statusbar/alt_hud.txt b/wadsrc/static/zscript/statusbar/alt_hud.txt index 7fd694c988..f8befa09f3 100644 --- a/wadsrc/static/zscript/statusbar/alt_hud.txt +++ b/wadsrc/static/zscript/statusbar/alt_hud.txt @@ -200,17 +200,17 @@ class AltHud ui // work in cooperative hub games if (hud_showsecrets) { - DrawStatLine(x, y, "S:", String.Format("%i/%i ", multiplayer? CPlayer.secretcount : currentUILevel.found_secrets, currentUILevel.total_secrets)); + DrawStatLine(x, y, "S:", String.Format("%i/%i ", multiplayer? CPlayer.secretcount : Level.found_secrets, Level.total_secrets)); } if (hud_showitems) { - DrawStatLine(x, y, "I:", String.Format("%i/%i ", multiplayer? CPlayer.itemcount : currentUILevel.found_items, currentUILevel.total_items)); + DrawStatLine(x, y, "I:", String.Format("%i/%i ", multiplayer? CPlayer.itemcount : Level.found_items, Level.total_items)); } if (hud_showmonsters) { - DrawStatLine(x, y, "K:", String.Format("%i/%i ", multiplayer? CPlayer.killcount : currentUILevel.killed_monsters, currentUILevel.total_monsters)); + DrawStatLine(x, y, "K:", String.Format("%i/%i ", multiplayer? CPlayer.killcount : Level.killed_monsters, Level.total_monsters)); } } } @@ -734,18 +734,18 @@ class AltHud ui } else { - pos.xy = currentUILevel.GetAutomapPosition(); - pos.z = currentUILevel.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy); + pos.xy = Level.GetAutomapPosition(); + pos.z = Level.PointInSector(pos.xy).floorplane.ZatPoint(pos.xy); } int xpos = hudwidth - SmallFont.StringWidth("X: -00000")-6; int ypos = 18; - screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(currentUILevel.MapName), ypos, currentUILevel.MapName, + screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(Level.MapName), ypos, Level.MapName, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); - screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(currentUILevel.LevelName), ypos + h, currentUILevel.LevelName, + screen.DrawText(SmallFont, hudcolor_titl, hudwidth - 6 - SmallFont.StringWidth(Level.LevelName), ypos + h, Level.LevelName, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); @@ -788,10 +788,10 @@ class AltHud ui { int timeTicks = hud_showtime < 4 - ? currentUILevel.maptime + ? Level.maptime : (hud_showtime < 6 - ? currentUILevel.time - : currentUILevel.totaltime); + ? Level.time + : Level.totaltime); timeSeconds = Thinker.Tics2Seconds(timeTicks); } else @@ -810,7 +810,7 @@ class AltHud ui if (showMillis) { - int millis = (currentUILevel.time % Thinker.TICRATE) * (1000 / Thinker.TICRATE); + int millis = (Level.time % Thinker.TICRATE) * (1000 / Thinker.TICRATE); timeString = String.Format("%02i:%02i:%02i.%03i", hours, minutes, seconds, millis); } else if (showSeconds) @@ -941,23 +941,23 @@ class AltHud ui if (am_showtotaltime) { - DrawTimeString(SmallFont, hudcolor_ttim, currentUILevel.totaltime, hudwidth-2, bottom, 1); + DrawTimeString(SmallFont, hudcolor_ttim, Level.totaltime, hudwidth-2, bottom, 1); bottom -= fonth; } if (am_showtime) { - if (currentUILevel.clusterflags & currentUILevel.CLUSTER_HUB) + if (Level.clusterflags & Level.CLUSTER_HUB) { - DrawTimeString(SmallFont, hudcolor_time, currentUILevel.time, hudwidth-2, bottom, 1); + DrawTimeString(SmallFont, hudcolor_time, Level.time, hudwidth-2, bottom, 1); bottom -= fonth; } // Single level time for hubs - DrawTimeString(SmallFont, hudcolor_ltim, currentUILevel.maptime, hudwidth-2, bottom, 1); + DrawTimeString(SmallFont, hudcolor_ltim, Level.maptime, hudwidth-2, bottom, 1); } - screen.DrawText(SmallFont, 0, 1, hudheight - fonth - 1, currentUILevel.FormatMapName(hudcolor_titl), + screen.DrawText(SmallFont, 0, 1, hudheight - fonth - 1, Level.FormatMapName(hudcolor_titl), DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight); diff --git a/wadsrc/static/zscript/statusbar/doom_sbar.txt b/wadsrc/static/zscript/statusbar/doom_sbar.txt index eb775d7f94..bd2681a053 100644 --- a/wadsrc/static/zscript/statusbar/doom_sbar.txt +++ b/wadsrc/static/zscript/statusbar/doom_sbar.txt @@ -105,7 +105,7 @@ class DoomStatusBar : BaseStatusBar DrawImage("STFBANY", (143, 168), DI_ITEM_OFFSETS|DI_TRANSLATABLE); } - if (CPlayer.mo.InvSel != null && !currentUILevel.NoInventoryBar) + if (CPlayer.mo.InvSel != null && !Level.NoInventoryBar) { DrawInventoryIcon(CPlayer.mo.InvSel, (160, 198)); if (CPlayer.mo.InvSel.Amount > 1) @@ -153,7 +153,7 @@ class DoomStatusBar : BaseStatusBar DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); invY -= 20; } - if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null) + if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); diff --git a/wadsrc/static/zscript/statusbar/harm_sbar.txt b/wadsrc/static/zscript/statusbar/harm_sbar.txt index bb800ccc40..f640bd993c 100644 --- a/wadsrc/static/zscript/statusbar/harm_sbar.txt +++ b/wadsrc/static/zscript/statusbar/harm_sbar.txt @@ -60,7 +60,7 @@ class HarmonyStatusBar : DoomStatusBar DrawString(mHUDFont, FormatNumber(ammotype2.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); invY -= 20; } - if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null) + if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { DrawInventoryIcon(CPlayer.mo.InvSel, (-14, invY + 17)); DrawString(mHUDFont, FormatNumber(CPlayer.mo.InvSel.Amount, 3), (-30, invY), DI_TEXT_ALIGN_RIGHT); diff --git a/wadsrc/static/zscript/statusbar/heretic_sbar.txt b/wadsrc/static/zscript/statusbar/heretic_sbar.txt index edcfd13c7d..38569ac936 100644 --- a/wadsrc/static/zscript/statusbar/heretic_sbar.txt +++ b/wadsrc/static/zscript/statusbar/heretic_sbar.txt @@ -43,7 +43,7 @@ class HereticStatusBar : BaseStatusBar mHealthInterpolator.Update(CPlayer.health); // wiggle the chain if it moves - if (currentUILevel.time & 1) + if (Level.time & 1) { wiggle = (mHealthInterpolator.GetValue() != CPlayer.health) && Random[ChainWiggle](0, 1); } @@ -200,7 +200,7 @@ class HereticStatusBar : BaseStatusBar y -= 40; } - if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null) + if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. diff --git a/wadsrc/static/zscript/statusbar/hexen_sbar.txt b/wadsrc/static/zscript/statusbar/hexen_sbar.txt index 033982e20a..a39244a498 100644 --- a/wadsrc/static/zscript/statusbar/hexen_sbar.txt +++ b/wadsrc/static/zscript/statusbar/hexen_sbar.txt @@ -74,7 +74,7 @@ class HexenStatusBar : BaseStatusBar DrawString(mHUDFont, FormatNumber(CPlayer.FragCount, 3), (70, -16)); } - if (!isInventoryBarVisible() && !currentUILevel.NoInventoryBar && CPlayer.mo.InvSel != null) + if (!isInventoryBarVisible() && !Level.NoInventoryBar && CPlayer.mo.InvSel != null) { // This code was changed to always fit the item into the box, regardless of alignment or sprite size. // Heretic's ARTIBOX is 30x30 pixels. diff --git a/wadsrc/static/zscript/statusbar/statusbar.txt b/wadsrc/static/zscript/statusbar/statusbar.txt index cd16ed94db..170e26a8d0 100644 --- a/wadsrc/static/zscript/statusbar/statusbar.txt +++ b/wadsrc/static/zscript/statusbar/statusbar.txt @@ -597,9 +597,9 @@ class BaseStatusBar native ui int GetAirTime() { if(CPlayer.mo.waterlevel < 3) - return currentUILevel.airsupply; + return Level.airsupply; else - return max(CPlayer.air_finished - currentUILevel.time, 0); + return max(CPlayer.air_finished - Level.time, 0); } int GetSelectedInventoryAmount() @@ -654,7 +654,7 @@ class BaseStatusBar native ui bool isInventoryBarVisible() { if (CPlayer == null) return false; - return (CPlayer.inventorytics > 0 && !currentUILevel.NoInventoryBar); + return (CPlayer.inventorytics > 0 && !Level.NoInventoryBar); } //============================================================================ @@ -850,13 +850,13 @@ class BaseStatusBar native ui let width = SmallFont.StringWidth("00:00:00"); if (am_showtime) { - printtext = currentUILevel.TimeFormatted(); - DrawString(mSmallFont, currentUILevel.TimeFormatted(), (-textdist-width, y), 0, crdefault); + printtext = Level.TimeFormatted(); + DrawString(mSmallFont, Level.TimeFormatted(), (-textdist-width, y), 0, crdefault); y += height; } if (am_showtotaltime) { - DrawString(mSmallFont, currentUILevel.TimeFormatted(true), (-textdist-width, y), 0, crdefault); + DrawString(mSmallFont, Level.TimeFormatted(true), (-textdist-width, y), 0, crdefault); } if (!deathmatch) @@ -866,25 +866,25 @@ class BaseStatusBar native ui // Draw monster count if (am_showmonsters) { - DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_MONSTERS"), crdefault+65, currentUILevel.killed_monsters, currentUILevel.total_monsters), (textdist, y), 0, highlight); + DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_MONSTERS"), crdefault+65, Level.killed_monsters, Level.total_monsters), (textdist, y), 0, highlight); y += height; } // Draw secret count if (am_showsecrets) { - DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_SECRETS"), crdefault+65, currentUILevel.found_secrets, currentUILevel.total_secrets), (textdist, y), 0, highlight); + DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_SECRETS"), crdefault+65, Level.found_secrets, Level.total_secrets), (textdist, y), 0, highlight); y += height; } // Draw item count if (am_showitems) { - DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_ITEMS"), crdefault+65, currentUILevel.found_items, currentUILevel.total_items), (textdist, y), 0, highlight); + DrawString(mSmallFont, String.Format("%s\34%c %d/%d", Stringtable.Localize("$AM_ITEMS"), crdefault+65, Level.found_items, Level.total_items), (textdist, y), 0, highlight); } } - String mapname = currentUILevel.FormatMapName(crdefault); + String mapname = Level.FormatMapName(crdefault); BrokenLines lines = SmallFont.BreakLines(mapname, int(SCREENWIDTH / scale.X)); int numlines = lines.Count(); int finalwidth = int(SmallFont.StringWidth(lines.StringAt(numlines-1)) * scale.X); diff --git a/wadsrc/static/zscript/statusbar/strife_sbar.txt b/wadsrc/static/zscript/statusbar/strife_sbar.txt index 1a1a12e5a2..866c4a32a3 100644 --- a/wadsrc/static/zscript/statusbar/strife_sbar.txt +++ b/wadsrc/static/zscript/statusbar/strife_sbar.txt @@ -427,7 +427,7 @@ class StrifeStatusBar : BaseStatusBar case POP_Log: { // Draw the latest log message. - screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, currentUILevel.TimeFormatted(), + screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, left + 210 * xscale, top + 8 * yscale, Level.TimeFormatted(), DTA_CleanNoMove, true); if (CPlayer.LogText.Length() > 0)