- renamed the level variables.

currentUILevel is now primaryLevel.
For ZScript, currentVMLevel was added. This is also exported as 'level' and will change as needed.
This also means that no breaking deprecations will be needed in the future, because in order to sandbox a level only 4 variables need to be handled: level, players, playeringame and consoleplayer.
The remaining global variables are not relevant for the level state.

The static 'level' has been mostly removed from the code except some places that still need work.
This commit is contained in:
Christoph Oelckers 2019-02-02 00:24:43 +01:00
commit 45dc9a7b47
44 changed files with 266 additions and 264 deletions

View file

@ -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)