diff --git a/src/d_event.h b/src/d_event.h index b751155df..302ef1aac 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -59,7 +59,7 @@ struct event_t enum gameaction_t : int { ga_nothing, - ga_loadlevel, + ga_loadlevel, // not used. ga_newgame, ga_newgame2, ga_recordgame, diff --git a/src/g_game.cpp b/src/g_game.cpp index 1926c9338..ff06e184f 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1037,9 +1037,6 @@ void G_Ticker () } switch (gameaction) { - case ga_loadlevel: - G_DoLoadLevel (-1, false, false); - break; case ga_recordgame: G_CheckDemoStatus(); G_RecordDemo(newdemoname); @@ -1624,7 +1621,6 @@ void FLevelLocals::DoReborn (int playernum, bool freshbot) BackupSaveName = ""; G_InitNew (level.MapName, false); demoplayback = indemo; -// gameaction = ga_loadlevel; } } else diff --git a/src/g_level.cpp b/src/g_level.cpp index 19052d44f..0017d9334 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -538,7 +538,6 @@ void G_InitNew (const char *mapname, bool bTitleLevel) bglobal.Init (); } - level.MapName = mapname; if (bTitleLevel) { gamestate = GS_TITLELEVEL; @@ -548,7 +547,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel) gamestate = GS_LEVEL; } - G_DoLoadLevel (0, false, !savegamerestore); + G_DoLoadLevel (mapname, 0, false, !savegamerestore); } // @@ -746,47 +745,63 @@ void G_SecretExitLevel (int position) // //========================================================================== -void G_DoCompleted (void) +void G_DoCompleted (void) { - int i; - gameaction = ga_nothing; - + if ( gamestate == GS_DEMOSCREEN || gamestate == GS_FULLCONSOLE || gamestate == GS_STARTUP) { return; } - + if (gamestate == GS_TITLELEVEL) { - level.MapName = nextlevel; - G_DoLoadLevel (startpos, false, false); + G_DoLoadLevel (nextlevel, startpos, false, false); startpos = 0; viewactive = true; return; } - - // [RH] Mark this level as having been visited - if (!(level.flags & LEVEL_CHANGEMAPCHEAT)) - FindLevelInfo (level.MapName)->flags |= LEVEL_VISITED; - + if (automapactive) AM_Stop (); - + // Close the conversation menu if open. P_FreeStrifeConversations (); - wminfo.finished_ep = level.cluster - 1; - wminfo.LName0 = TexMan.CheckForTexture(level.info->PName, ETextureType::MiscPatch); - wminfo.current = level.MapName; + if (level.DoCompleted(nextlevel, wminfo)) + { + gamestate = GS_INTERMISSION; + viewactive = false; + automapactive = false; + + // [RH] If you ever get a statistics driver operational, adapt this. + // if (statcopy) + // memcpy (statcopy, &wminfo, sizeof(wminfo)); + + WI_Start (&wminfo); + } +} + + +bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo) +{ + int i; + + // [RH] Mark this level as having been visited + if (!(flags & LEVEL_CHANGEMAPCHEAT)) + FindLevelInfo (MapName)->flags |= LEVEL_VISITED; + + wminfo.finished_ep = cluster - 1; + wminfo.LName0 = TexMan.CheckForTexture(info->PName, ETextureType::MiscPatch); + wminfo.current = MapName; if (deathmatch && (dmflags & DF_SAME_LEVEL) && - !(level.flags & LEVEL_CHANGEMAPCHEAT)) + !(flags & LEVEL_CHANGEMAPCHEAT)) { - wminfo.next = level.MapName; + wminfo.next = MapName; wminfo.LName1 = wminfo.LName0; } else @@ -808,32 +823,31 @@ void G_DoCompleted (void) nextlevel = wminfo.next; wminfo.next_ep = FindLevelInfo (wminfo.next)->cluster - 1; - wminfo.maxkills = level.total_monsters; - wminfo.maxitems = level.total_items; - wminfo.maxsecret = level.total_secrets; + wminfo.maxkills = total_monsters; + wminfo.maxitems = total_items; + wminfo.maxsecret = total_secrets; wminfo.maxfrags = 0; - wminfo.partime = TICRATE * level.partime; - wminfo.sucktime = level.sucktime; + wminfo.partime = TICRATE * partime; + wminfo.sucktime = sucktime; wminfo.pnum = consoleplayer; - wminfo.totaltime = level.totaltime; + wminfo.totaltime = totaltime; for (i=0 ; iSnapshot.Clean(); + info->Snapshot.Clean(); } } else @@ -887,30 +901,21 @@ void G_DoCompleted (void) { // Reset world variables for the new hub. P_ClearACSVars(false); } - level.time = 0; - level.maptime = 0; - level.spawnindex = 0; + time = 0; + maptime = 0; + spawnindex = 0; } finishstate = mode; if (!deathmatch && - ((level.flags & LEVEL_NOINTERMISSION) || + ((flags & LEVEL_NOINTERMISSION) || ((nextcluster == thiscluster) && (thiscluster->flags & CLUSTER_HUB) && !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION)))) { - level.WorldDone (); - return; + WorldDone (); + return false; } - - gamestate = GS_INTERMISSION; - viewactive = false; - automapactive = false; - -// [RH] If you ever get a statistics driver operational, adapt this. -// if (statcopy) -// memcpy (statcopy, &wminfo, sizeof(wminfo)); - - WI_Start (&wminfo); + return true; } //========================================================================== @@ -942,8 +947,9 @@ void DAutosaver::Tick () extern gamestate_t wipegamestate; -void G_DoLoadLevel (int position, bool autosave, bool newGame) -{ +void G_DoLoadLevel (const FString &nextmapname, int position, bool autosave, bool newGame) +{ + level.MapName = nextmapname; static int lastposition = 0; gamestate_t oldgs = gamestate; int i; @@ -1277,13 +1283,10 @@ void G_DoWorldDone (void) { // Don't crash if no next map is given. Just repeat the current one. Printf ("No next map specified.\n"); - } - else - { - level.MapName = nextlevel; + nextlevel = level.MapName; } G_StartTravel (); - G_DoLoadLevel (startpos, true, false); + G_DoLoadLevel (nextlevel, startpos, true, false); startpos = 0; gameaction = ga_nothing; viewactive = true; diff --git a/src/g_level.h b/src/g_level.h index 9686a4e5c..e8d694dd4 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -475,7 +475,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill void G_StartTravel (); int G_FinishTravel (); -void G_DoLoadLevel (int position, bool autosave, bool newGame); +void G_DoLoadLevel (const FString &MapName, int position, bool autosave, bool newGame); cluster_info_t *FindClusterInfo (int cluster); level_info_t *FindLevelInfo (const char *mapname, bool allowdefault=true); diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 5f7d202b0..b1077fb06 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -91,6 +91,7 @@ class DSpotState; class DSeqNode; struct FStrifeDialogueNode; class DAutomapBase; +struct wbstartstruct_t; typedef TMap FDialogueIDMap; // maps dialogue IDs to dialogue array index (for ACS) typedef TMap FDialogueMap; // maps actor class names to dialogue array index @@ -218,6 +219,7 @@ public: FPlayerStart *SelectRandomDeathmatchSpot (int playernum, unsigned int selections); void DeathMatchSpawnPlayer (int playernum); FPlayerStart *PickPlayerStart(int playernum, int flags = 0); + bool DoCompleted(FString nextlevel, wbstartstruct_t &wminfo); private: