Permalink
Browse files

- started cleaning up g_level.cpp.

This works up to the point where it tries to apply snapshots, it doesn't start the level yet.
  • Loading branch information...
coelckers committed Jan 11, 2019
1 parent e082672 commit 70ee43a95a4035af2a17d9e567e503cf9db8cdc9
@@ -170,7 +170,7 @@ CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO)
if (playeringame[i] && self <= D_GetFragCount(&players[i]))
{
Printf ("%s\n", GStrings("TXT_FRAGLIMIT"));
G_ExitLevel (0, false);
G_ExitLevel (currentSession->Levelinfo[0], 0, false);
break;
}
}
@@ -2228,8 +2228,9 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
// That was a long time ago. Maybe it works now?
if (currentSession)
{
currentSession->Levelinfo[0]->flags |= LEVEL_CHANGEMAPCHEAT;
G_ChangeLevel(s, pos, 0);
auto Level = currentSession->Levelinfo[0];
Level->flags |= LEVEL_CHANGEMAPCHEAT;
G_ChangeLevel(Level, s, pos, 0);
}
break;

@@ -2667,7 +2668,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)

case DEM_FINISHGAME:
// Simulate an end-of-game action
G_ChangeLevel(NULL, 0, 0);
if (currentSession)
{
auto Level = currentSession->Levelinfo[0];
G_ChangeLevel(Level, nullptr, 0, 0);
}
break;

case DEM_NETEVENT:
@@ -229,7 +229,7 @@ void DThinker::SerializeThinkers(FSerializer &arc, bool hubLoad)
void DThinker::Serialize(FSerializer &arc)
{
Super::Serialize(arc);
Level = &level; // Must be written out once a real object.
Level = arc.Level;
}

//==========================================================================
@@ -242,7 +242,7 @@ DThinker::DThinker (int statnum) throw()
{
NextThinker = NULL;
PrevThinker = NULL;
Level = &level; // do this properly later.
Level = bSerialOverride? nullptr : currentSession->Levelinfo[0]; // do this properly later.
if (bSerialOverride)
{ // The serializer will insert us into the right list
return;
@@ -77,7 +77,7 @@ static void FS_Gimme(const char * what)
//
//==========================================================================

void FS_MapCmd(FScanner &sc)
void FS_MapCmd(FLevelLocals *Level, FScanner &sc)
{
char nextmap[9];
int NextSkill = -1;
@@ -108,7 +108,7 @@ void FS_MapCmd(FScanner &sc)
flags &= ~(CHANGELEVEL_RESETINVENTORY|CHANGELEVEL_RESETHEALTH);
}
}
G_ChangeLevel(nextmap, 0, flags, NextSkill);
G_ChangeLevel(Level, nextmap, 0, flags, NextSkill);
}

//==========================================================================
@@ -168,7 +168,7 @@ void FS_EmulateCmd(FLevelLocals *Level, char * string)
}
else if (sc.Compare("map"))
{
FS_MapCmd(sc);
FS_MapCmd(Level, sc);
}
else if (sc.Compare("gr_fogdensity"))
{
@@ -177,7 +177,7 @@ void FS_EmulateCmd(FLevelLocals *Level, char * string)
Level->fogdensity = sc.Number * 70 / 400;
Level->outsidefogdensity = 0;
Level->skyfog = 0;
Level->info->outsidefog = 0;
Level->outsidefog = 0;
}
else if (sc.Compare("gr_fogcolor"))
{
@@ -635,7 +635,7 @@ void FParser::SF_Clock(void)

void FParser::SF_ExitLevel(void)
{
G_ExitLevel(0, false);
G_ExitLevel(Level, 0, false);
}

//==========================================================================
@@ -2853,7 +2853,7 @@ void FParser::SF_AmbientSound(void)

void FParser::SF_ExitSecret(void)
{
G_SecretExitLevel(0);
G_SecretExitLevel(Level, 0);
}


@@ -150,7 +150,7 @@ void FScriptLoader::ParseInfoCmd(char *line, FString &scriptsrc)
{
sc.MustGetStringName("=");
sc.MustGetString();
Level->info->ExitPic = sc.String;
const_cast<level_info_t*>(Level->info)->ExitPic = sc.String;
}
else if (sc.Compare("gravity"))
{
@@ -179,7 +179,7 @@ void DFsScript::Serialize(FSerializer &arc)
// don't save a reference to the global script, which contains unserializable data.
if (parent == Level->FraggleScriptThinker->GlobalScript) parent = nullptr;

if (arc.isReading()) Level = &level; // must later be written out.
if (arc.isReading()) Level = arc.Level;

arc("data", data)
("scriptnum", scriptnum)
@@ -1028,7 +1028,7 @@ void G_Ticker ()
switch (gameaction)
{
case ga_loadlevel:
G_DoLoadLevel (-1, false, false);
G_DoLoadLevel (currentSession->nextlevel, -1, false, false);
break;
case ga_recordgame:
G_CheckDemoStatus();
@@ -1103,7 +1103,8 @@ void G_Ticker ()
uint32_t rngsum = FRandom::StaticSumSeeds ();

//Added by MC: For some of that bot stuff. The main bot function.
bglobal.Main (currentSession->Levelinfo[0]);
if (currentSession->Levelinfo.Size() > 0)
bglobal.Main (currentSession->Levelinfo[0]);

for (i = 0; i < MAXPLAYERS; i++)
{
@@ -1925,8 +1926,7 @@ void G_DoLoadGame ()
NextSkill = -1;
arc("nextskill", NextSkill);

if (level.info != nullptr)
level.info->Snapshot.Clean();
//currentSession->Snapshots.Remove(MapName); fixme

BackupSaveName = savename;

@@ -2137,7 +2137,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
{
// delete the snapshot. Since the save failed it is broken.
insave = false;
level.info->Snapshot.Clean();
//level.info->Snapshot.Clean();
Printf(PRINT_HIGH, "Save failed\n");
Printf(PRINT_HIGH, "%s\n", err.GetMessage());
// The time freeze must be reset if the save fails.
@@ -2236,8 +2236,8 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio

// delete the JSON buffers we created just above. Everything else will
// either still be needed or taken care of automatically.
savegame_content[1].Clean();
savegame_content[2].Clean();
//savegame_content[1].Clean();
//savegame_content[2].Clean();

// Check whether the file is ok by trying to open it.
FResourceFile *test = FResourceFile::OpenResourceFile(filename, true);
@@ -2253,7 +2253,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
BackupSaveName = filename;

// We don't need the snapshot any longer.
level.info->Snapshot.Clean();
//currentSession->Snapshots.Remove(???);

insave = false;

Oops, something went wrong.

0 comments on commit 70ee43a

Please sign in to comment.