2016-03-01 15:47:10 +00:00
|
|
|
/*
|
|
|
|
** g_level.cpp
|
|
|
|
** controls movement between levels
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2006 Randy Heit
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2021-10-30 08:49:12 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "d_main.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "d_event.h"
|
|
|
|
#include "m_random.h"
|
2020-04-11 10:56:55 +00:00
|
|
|
#include "engineerrors.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "doomstat.h"
|
|
|
|
#include "wi_stuff.h"
|
2020-04-11 11:36:23 +00:00
|
|
|
#include "filesystem.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "am_map.h"
|
|
|
|
#include "c_dispatch.h"
|
2019-01-31 18:38:04 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "p_setup.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "intermission/intermission.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "st_stuff.h"
|
|
|
|
#include "hu_stuff.h"
|
|
|
|
#include "p_saveg.h"
|
|
|
|
#include "p_acs.h"
|
|
|
|
#include "d_protocol.h"
|
|
|
|
#include "v_text.h"
|
|
|
|
#include "s_sndseq.h"
|
|
|
|
#include "b_bot.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
#include "a_lightning.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "sbarinfo.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "d_net.h"
|
|
|
|
#include "d_netinf.h"
|
2020-06-13 22:27:32 +00:00
|
|
|
#include "doommenu.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "r_utility.h"
|
|
|
|
#include "p_spec.h"
|
2020-04-11 17:27:11 +00:00
|
|
|
#include "serializer_doom.h"
|
2017-04-12 23:12:04 +00:00
|
|
|
#include "vm.h"
|
2017-01-22 06:56:57 +00:00
|
|
|
#include "events.h"
|
2018-03-24 12:06:37 +00:00
|
|
|
#include "i_music.h"
|
2019-01-03 08:24:22 +00:00
|
|
|
#include "a_dynlight.h"
|
2019-01-09 01:03:26 +00:00
|
|
|
#include "p_conversation.h"
|
2019-01-29 00:09:02 +00:00
|
|
|
#include "p_effect.h"
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
#include "stringtable.h"
|
2020-04-11 16:00:10 +00:00
|
|
|
#include "c_buttons.h"
|
2022-04-22 09:27:49 +00:00
|
|
|
#include "screenjob.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#include "gi.h"
|
|
|
|
|
|
|
|
#include "g_hub.h"
|
2017-01-08 17:45:30 +00:00
|
|
|
#include "g_levellocals.h"
|
2017-03-11 18:02:00 +00:00
|
|
|
#include "actorinlines.h"
|
2017-11-12 08:06:40 +00:00
|
|
|
#include "i_time.h"
|
2018-11-08 13:26:42 +00:00
|
|
|
#include "p_maputl.h"
|
2019-08-23 15:15:19 +00:00
|
|
|
#include "s_music.h"
|
2020-09-28 21:08:48 +00:00
|
|
|
#include "fragglescript/t_script.h"
|
|
|
|
|
2020-04-11 17:00:07 +00:00
|
|
|
#include "texturemanager.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void STAT_StartNewGame(const char *lev);
|
2019-01-05 21:46:45 +00:00
|
|
|
void STAT_ChangeLevel(const char *newl, FLevelLocals *Level);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 19:57:24 +00:00
|
|
|
EXTERN_CVAR(Bool, save_formatted)
|
2016-03-01 15:47:10 +00:00
|
|
|
EXTERN_CVAR (Float, sv_gravity)
|
|
|
|
EXTERN_CVAR (Float, sv_aircontrol)
|
|
|
|
EXTERN_CVAR (Int, disableautosave)
|
|
|
|
EXTERN_CVAR (String, playerclass)
|
|
|
|
|
2019-08-09 08:39:09 +00:00
|
|
|
extern uint8_t globalfreeze, globalchangefreeze;
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
#define SNAP_ID MAKE_ID('s','n','A','p')
|
|
|
|
#define DSNP_ID MAKE_ID('d','s','N','p')
|
|
|
|
#define VIST_ID MAKE_ID('v','i','S','t')
|
|
|
|
#define ACSD_ID MAKE_ID('a','c','S','d')
|
|
|
|
#define RCLS_ID MAKE_ID('r','c','L','s')
|
|
|
|
#define PCLS_ID MAKE_ID('p','c','L','s')
|
|
|
|
|
|
|
|
void G_VerifySkill();
|
2019-12-25 14:52:57 +00:00
|
|
|
void I_UpdateWindowTitle();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2018-04-01 16:45:27 +00:00
|
|
|
CUSTOM_CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
|
|
|
{
|
2019-01-28 01:41:29 +00:00
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
if (Level->info == nullptr || Level->info->brightfog == -1) Level->brightfog = self;
|
|
|
|
}
|
2018-04-01 16:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CUSTOM_CVAR(Bool, gl_lightadditivesurfaces, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
|
|
|
{
|
2019-01-28 01:41:29 +00:00
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
if (Level->info == nullptr || Level->info->lightadditivesurfaces == -1) Level->lightadditivesurfaces = self;
|
|
|
|
}
|
2018-04-01 16:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CUSTOM_CVAR(Bool, gl_notexturefill, false, CVAR_NOINITCALL)
|
|
|
|
{
|
2019-01-28 01:41:29 +00:00
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
if (Level->info == nullptr || Level->info->notexturefill == -1) Level->notexturefill = self;
|
|
|
|
}
|
2018-04-01 16:45:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CUSTOM_CVAR(Int, gl_lightmode, 3, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
|
|
|
{
|
|
|
|
int newself = self;
|
2020-06-08 18:58:35 +00:00
|
|
|
if (newself > 8) newself = 16; // use 8 and 16 for software lighting to avoid conflicts with the bit mask ( in hindsight a bad idea.)
|
|
|
|
else if (newself > 5) newself = 8;
|
2018-12-15 06:11:28 +00:00
|
|
|
else if (newself < 0) newself = 0;
|
2018-04-01 16:45:27 +00:00
|
|
|
if (self != newself) self = newself;
|
2019-01-28 01:41:29 +00:00
|
|
|
else for (auto Level : AllLevels())
|
|
|
|
{
|
2019-01-29 19:15:06 +00:00
|
|
|
if ((Level->info == nullptr || Level->info->lightmode == ELightMode::NotSet)) Level->lightMode = (ELightMode)*self;
|
2019-01-28 01:41:29 +00:00
|
|
|
}
|
2018-04-01 16:45:27 +00:00
|
|
|
}
|
|
|
|
|
2020-07-25 14:28:08 +00:00
|
|
|
CVAR(Int, sv_alwaystally, 0, CVAR_SERVERINFO)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
static FRandom pr_classchoice ("RandomPlayerClassChoice");
|
|
|
|
|
|
|
|
extern level_info_t TheDefaultLevelInfo;
|
|
|
|
extern bool timingdemo;
|
|
|
|
|
|
|
|
// Start time for timing demos
|
|
|
|
int starttime;
|
|
|
|
|
|
|
|
|
|
|
|
extern FString BackupSaveName;
|
|
|
|
|
|
|
|
bool savegamerestore;
|
2017-11-12 09:03:08 +00:00
|
|
|
int finishstate = FINISH_NoHub;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2020-09-28 20:12:44 +00:00
|
|
|
extern float mousex, mousey;
|
2016-03-01 15:47:10 +00:00
|
|
|
extern bool sendpause, sendsave, sendturn180, SendLand;
|
|
|
|
|
|
|
|
void *statcopy; // for statistics driver
|
|
|
|
|
|
|
|
FLevelLocals level; // info about current level
|
2019-02-01 23:24:43 +00:00
|
|
|
FLevelLocals *primaryLevel = &level; // level for which to display the user interface.
|
2019-02-01 21:02:16 +00:00
|
|
|
FLevelLocals *currentVMLevel = &level; // level which currently ticks. Used as global input to the VM and some functions called by it.
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// G_InitNew
|
|
|
|
// Can be called by the startup code or the menu task,
|
|
|
|
// consoleplayer, playeringame[] should be set.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
static FString d_mapname;
|
|
|
|
static int d_skill=-1;
|
|
|
|
|
|
|
|
void G_DeferedInitNew (const char *mapname, int newskill)
|
|
|
|
{
|
|
|
|
d_mapname = mapname;
|
|
|
|
d_skill = newskill;
|
|
|
|
CheckWarpTransMap (d_mapname, true);
|
|
|
|
gameaction = ga_newgame2;
|
|
|
|
}
|
|
|
|
|
2020-04-22 17:57:14 +00:00
|
|
|
void G_DeferedInitNew (FNewGameStartup *gs)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (gs->PlayerClass != NULL) playerclass = gs->PlayerClass;
|
|
|
|
d_mapname = AllEpisodes[gs->Episode].mEpisodeMap;
|
|
|
|
d_skill = gs->Skill;
|
|
|
|
CheckWarpTransMap (d_mapname, true);
|
|
|
|
gameaction = ga_newgame2;
|
2017-02-24 20:45:53 +00:00
|
|
|
finishstate = FINISH_NoHub;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
CCMD (map)
|
|
|
|
{
|
|
|
|
if (netgame)
|
|
|
|
{
|
|
|
|
Printf ("Use " TEXTCOLOR_BOLD "changemap" TEXTCOLOR_NORMAL " instead. " TEXTCOLOR_BOLD "Map"
|
|
|
|
TEXTCOLOR_NORMAL " is for single-player only.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
2017-04-28 09:39:47 +00:00
|
|
|
const char *mapname = argv[1];
|
2019-02-01 23:24:43 +00:00
|
|
|
if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars();
|
2017-04-28 09:39:47 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
try
|
|
|
|
{
|
2017-04-28 09:39:47 +00:00
|
|
|
if (!P_CheckMapData(mapname))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-04-28 09:39:47 +00:00
|
|
|
Printf ("No map %s\n", mapname);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-01 13:47:01 +00:00
|
|
|
if (argv.argc() > 2 && stricmp(argv[2], "coop") == 0)
|
2016-11-01 07:21:19 +00:00
|
|
|
{
|
|
|
|
deathmatch = false;
|
|
|
|
multiplayernext = true;
|
|
|
|
}
|
2016-11-01 13:47:01 +00:00
|
|
|
else if (argv.argc() > 2 && stricmp(argv[2], "dm") == 0)
|
2016-11-01 07:21:19 +00:00
|
|
|
{
|
|
|
|
deathmatch = true;
|
|
|
|
multiplayernext = true;
|
|
|
|
}
|
2017-04-28 09:39:47 +00:00
|
|
|
G_DeferedInitNew (mapname);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(CRecoverableError &error)
|
|
|
|
{
|
|
|
|
if (error.GetMessage())
|
|
|
|
Printf("%s", error.GetMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-01 07:21:19 +00:00
|
|
|
Printf ("Usage: map <map name> [coop|dm]\n");
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2018-01-20 08:11:28 +00:00
|
|
|
UNSAFE_CCMD(recordmap)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (netgame)
|
|
|
|
{
|
2018-05-11 15:03:57 +00:00
|
|
|
Printf("You cannot record a new game while in a netgame.\n");
|
2016-03-01 15:47:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (argv.argc() > 2)
|
|
|
|
{
|
2017-04-28 09:39:47 +00:00
|
|
|
const char *mapname = argv[2];
|
2019-02-01 23:24:43 +00:00
|
|
|
if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars();
|
2017-04-28 09:39:47 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
try
|
|
|
|
{
|
2017-04-28 09:39:47 +00:00
|
|
|
if (!P_CheckMapData(mapname))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-04-28 09:39:47 +00:00
|
|
|
Printf("No map %s\n", mapname);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-01 13:47:01 +00:00
|
|
|
if (argv.argc() > 3 && stricmp(argv[3], "coop") == 0)
|
2016-11-01 07:21:19 +00:00
|
|
|
{
|
|
|
|
deathmatch = false;
|
|
|
|
multiplayernext = true;
|
|
|
|
}
|
2016-11-01 13:47:01 +00:00
|
|
|
else if (argv.argc() > 3 && stricmp(argv[3], "dm") == 0)
|
2016-11-01 07:21:19 +00:00
|
|
|
{
|
|
|
|
deathmatch = true;
|
|
|
|
multiplayernext = true;
|
|
|
|
}
|
2017-04-28 09:39:47 +00:00
|
|
|
G_DeferedInitNew(mapname);
|
2016-03-01 15:47:10 +00:00
|
|
|
gameaction = ga_recordgame;
|
|
|
|
newdemoname = argv[1];
|
2017-04-30 13:35:28 +00:00
|
|
|
newdemomap = mapname;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (CRecoverableError &error)
|
|
|
|
{
|
|
|
|
if (error.GetMessage())
|
|
|
|
Printf("%s", error.GetMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-01 07:21:19 +00:00
|
|
|
Printf("Usage: recordmap <filename> <map name> [coop|dm]\n");
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2018-01-07 13:03:49 +00:00
|
|
|
UNSAFE_CCMD (open)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (netgame)
|
|
|
|
{
|
|
|
|
Printf ("You cannot use open in multiplayer games.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (argv.argc() > 1)
|
|
|
|
{
|
|
|
|
d_mapname = "file:";
|
|
|
|
d_mapname += argv[1];
|
|
|
|
if (!P_CheckMapData(d_mapname))
|
|
|
|
{
|
|
|
|
Printf ("No map %s\n", d_mapname.GetChars());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-01 13:47:01 +00:00
|
|
|
if (argv.argc() > 2 && stricmp(argv[2], "coop") == 0)
|
2016-10-31 04:29:15 +00:00
|
|
|
{
|
2016-11-01 07:21:19 +00:00
|
|
|
deathmatch = false;
|
2016-10-31 04:29:15 +00:00
|
|
|
multiplayernext = true;
|
|
|
|
}
|
2016-11-01 13:47:01 +00:00
|
|
|
else if (argv.argc() > 2 && stricmp(argv[2], "dm") == 0)
|
2016-10-31 04:29:15 +00:00
|
|
|
{
|
2016-11-01 07:21:19 +00:00
|
|
|
deathmatch = true;
|
2016-10-31 04:29:15 +00:00
|
|
|
multiplayernext = true;
|
|
|
|
}
|
|
|
|
gameaction = ga_newgame2;
|
|
|
|
d_skill = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-01 07:21:19 +00:00
|
|
|
Printf ("Usage: open <map file> [coop|dm]\n");
|
2016-10-31 04:29:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void G_NewInit ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Destory all old player refrences that may still exist
|
2019-02-01 23:24:43 +00:00
|
|
|
TThinkerIterator<AActor> it(primaryLevel, NAME_PlayerPawn, STAT_TRAVELLING);
|
2019-01-03 21:05:49 +00:00
|
|
|
AActor *pawn, *next;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
next = it.Next();
|
|
|
|
while ((pawn = next) != NULL)
|
|
|
|
{
|
|
|
|
next = it.Next();
|
|
|
|
pawn->flags |= MF_NOSECTOR | MF_NOBLOCKMAP;
|
|
|
|
pawn->Destroy();
|
|
|
|
}
|
2020-09-28 21:08:48 +00:00
|
|
|
if (primaryLevel->FraggleScriptThinker) primaryLevel->FraggleScriptThinker->Destroy();
|
|
|
|
primaryLevel->FraggleScriptThinker = nullptr;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2021-08-06 12:10:21 +00:00
|
|
|
// Destroy thinkers that may remain after change level failure
|
|
|
|
// Usually, the list contains just a sentinel when such error occurred
|
|
|
|
primaryLevel->Thinkers.DestroyThinkersInList(STAT_TRAVELLING);
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
G_ClearSnapshots ();
|
|
|
|
netgame = false;
|
2016-10-31 04:29:15 +00:00
|
|
|
multiplayer = multiplayernext;
|
|
|
|
multiplayernext = false;
|
2016-03-01 15:47:10 +00:00
|
|
|
if (demoplayback)
|
|
|
|
{
|
|
|
|
C_RestoreCVars ();
|
|
|
|
demoplayback = false;
|
|
|
|
D_SetupUserInfo ();
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
player_t *p = &players[i];
|
|
|
|
userinfo_t saved_ui;
|
2018-12-21 11:11:33 +00:00
|
|
|
saved_ui.TransferFrom(p->userinfo);
|
|
|
|
const int chasecam = p->cheats & CF_CHASECAM;
|
2018-12-21 11:12:23 +00:00
|
|
|
const bool settings_controller = p->settings_controller;
|
2016-03-01 15:47:10 +00:00
|
|
|
p->~player_t();
|
|
|
|
::new(p) player_t;
|
2018-12-21 11:12:23 +00:00
|
|
|
p->settings_controller = settings_controller;
|
2018-12-21 11:11:33 +00:00
|
|
|
p->cheats |= chasecam;
|
|
|
|
p->playerstate = PST_DEAD;
|
|
|
|
p->userinfo.TransferFrom(saved_ui);
|
|
|
|
playeringame[i] = false;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
BackupSaveName = "";
|
|
|
|
consoleplayer = 0;
|
|
|
|
NextSkill = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void G_DoNewGame (void)
|
|
|
|
{
|
|
|
|
G_NewInit ();
|
|
|
|
playeringame[consoleplayer] = 1;
|
|
|
|
if (d_skill != -1)
|
|
|
|
{
|
|
|
|
gameskill = d_skill;
|
|
|
|
}
|
|
|
|
G_InitNew (d_mapname, false);
|
|
|
|
gameaction = ga_nothing;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Initializes player classes in case they are random.
|
|
|
|
// This gets called at the start of a new game, and the classes
|
|
|
|
// chosen here are used for the remainder of a single-player
|
|
|
|
// or coop game. These are ignored for deathmatch.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
static void InitPlayerClasses ()
|
|
|
|
{
|
|
|
|
if (!savegamerestore)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
SinglePlayerClass[i] = players[i].userinfo.GetPlayerClassNum();
|
|
|
|
if (SinglePlayerClass[i] < 0 || !playeringame[i])
|
|
|
|
{
|
|
|
|
SinglePlayerClass[i] = (pr_classchoice()) % PlayerClasses.Size ();
|
|
|
|
}
|
|
|
|
players[i].cls = NULL;
|
|
|
|
players[i].CurrentPlayerClass = SinglePlayerClass[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void G_InitNew (const char *mapname, bool bTitleLevel)
|
|
|
|
{
|
|
|
|
bool wantFast;
|
|
|
|
int i;
|
|
|
|
|
2017-01-23 22:17:12 +00:00
|
|
|
// did we have any level before?
|
2019-02-01 23:24:43 +00:00
|
|
|
if (primaryLevel->info != nullptr)
|
2021-09-27 17:40:57 +00:00
|
|
|
staticEventManager.WorldUnloaded(FString()); // [MK] don't pass the new map, as it's not a level transition
|
2017-01-23 22:17:12 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
if (!savegamerestore)
|
|
|
|
{
|
2016-06-17 14:14:58 +00:00
|
|
|
G_ClearHubInfo();
|
2016-03-01 15:47:10 +00:00
|
|
|
G_ClearSnapshots ();
|
|
|
|
P_RemoveDefereds ();
|
|
|
|
|
|
|
|
// [RH] Mark all levels as not visited
|
|
|
|
for (unsigned int i = 0; i < wadlevelinfos.Size(); i++)
|
|
|
|
wadlevelinfos[i].flags = wadlevelinfos[i].flags & ~LEVEL_VISITED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnlatchCVars ();
|
|
|
|
G_VerifySkill();
|
|
|
|
UnlatchCVars ();
|
2019-08-09 08:39:09 +00:00
|
|
|
globalfreeze = globalchangefreeze = 0;
|
2019-02-01 23:24:43 +00:00
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
Level->Thinkers.DestroyThinkersInList(STAT_STATIC);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (paused)
|
|
|
|
{
|
|
|
|
paused = 0;
|
|
|
|
S_ResumeSound (false);
|
|
|
|
}
|
|
|
|
|
2017-03-25 17:31:53 +00:00
|
|
|
ST_CreateStatusBar(bTitleLevel);
|
2016-03-01 15:47:10 +00:00
|
|
|
setsizeneeded = true;
|
|
|
|
|
|
|
|
// [RH] If this map doesn't exist, bomb out
|
|
|
|
if (!P_CheckMapData(mapname))
|
|
|
|
{
|
|
|
|
I_Error ("Could not find map %s\n", mapname);
|
|
|
|
}
|
|
|
|
|
|
|
|
wantFast = !!G_SkillProperty(SKILLP_FastMonsters);
|
|
|
|
GameSpeed = wantFast ? SPEED_Fast : SPEED_Normal;
|
|
|
|
|
|
|
|
if (!savegamerestore)
|
|
|
|
{
|
|
|
|
if (!netgame && !demorecording && !demoplayback)
|
|
|
|
{
|
|
|
|
// [RH] Change the random seed for each new single player game
|
|
|
|
// [ED850] The demo already sets the RNG.
|
|
|
|
rngseed = use_staticrng ? staticrngseed : (rngseed + 1);
|
|
|
|
}
|
|
|
|
FRandom::StaticClearRandom ();
|
|
|
|
P_ClearACSVars(true);
|
2019-02-01 23:24:43 +00:00
|
|
|
primaryLevel->time = 0;
|
|
|
|
primaryLevel->maptime = 0;
|
|
|
|
primaryLevel->totaltime = 0;
|
|
|
|
primaryLevel->spawnindex = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (!multiplayer || !deathmatch)
|
|
|
|
{
|
|
|
|
InitPlayerClasses ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// force players to be initialized upon first level load
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
players[i].playerstate = PST_ENTER; // [BC]
|
|
|
|
|
|
|
|
STAT_StartNewGame(mapname);
|
|
|
|
}
|
|
|
|
|
|
|
|
usergame = !bTitleLevel; // will be set false if a demo
|
|
|
|
paused = 0;
|
|
|
|
demoplayback = false;
|
|
|
|
automapactive = false;
|
|
|
|
viewactive = true;
|
|
|
|
|
|
|
|
//Added by MC: Initialize bots.
|
|
|
|
if (!deathmatch)
|
|
|
|
{
|
2019-02-01 23:24:43 +00:00
|
|
|
primaryLevel->BotInfo.Init ();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bTitleLevel)
|
|
|
|
{
|
|
|
|
gamestate = GS_TITLELEVEL;
|
|
|
|
}
|
|
|
|
else if (gamestate != GS_STARTUP)
|
|
|
|
{
|
|
|
|
gamestate = GS_LEVEL;
|
|
|
|
}
|
2018-10-31 07:15:56 +00:00
|
|
|
|
2019-01-29 01:39:14 +00:00
|
|
|
G_DoLoadLevel (mapname, 0, false, !savegamerestore);
|
2019-02-05 12:34:49 +00:00
|
|
|
|
2019-02-05 12:49:07 +00:00
|
|
|
if (!savegamerestore && (gameinfo.gametype == GAME_Strife || (SBarInfoScript[SCRIPT_CUSTOM] != nullptr && SBarInfoScript[SCRIPT_CUSTOM]->GetGameType() == GAME_Strife)))
|
2019-02-05 12:34:49 +00:00
|
|
|
{
|
|
|
|
// Set the initial quest log text for Strife.
|
|
|
|
for (i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
players[i].SetLogText("$TXT_FINDHELP");
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// G_DoCompleted
|
|
|
|
//
|
|
|
|
static FString nextlevel;
|
|
|
|
static int startpos; // [RH] Support for multiple starts per level
|
|
|
|
extern int NoWipe; // [RH] Don't wipe when travelling in hubs
|
|
|
|
static int changeflags;
|
|
|
|
static bool unloading;
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// [RH] The position parameter to these next three functions should
|
|
|
|
// match the first parameter of the single player start spots
|
|
|
|
// that should appear in the next map.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-10-23 10:06:59 +00:00
|
|
|
EXTERN_CVAR(Bool, sv_singleplayerrespawn)
|
|
|
|
|
2020-07-21 17:53:27 +00:00
|
|
|
bool FLevelLocals::ShouldDoIntermission(cluster_info_t* nextcluster, cluster_info_t* thiscluster)
|
|
|
|
{
|
|
|
|
// this is here to remove some code duplication
|
|
|
|
|
|
|
|
if ((sv_alwaystally == 2) || (deathmatch))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ((sv_alwaystally == 0) && (flags & LEVEL_NOINTERMISSION))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool withinSameCluster = (nextcluster == thiscluster);
|
|
|
|
bool clusterIsHub = (thiscluster->flags & CLUSTER_HUB);
|
|
|
|
bool hubNoIntermission = !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION);
|
|
|
|
|
|
|
|
if (withinSameCluster && clusterIsHub && hubNoIntermission)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-02-09 11:07:30 +00:00
|
|
|
void FLevelLocals::ChangeLevel(const char *levelname, int position, int inflags, int nextSkill)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-02-01 20:19:16 +00:00
|
|
|
if (!isPrimaryLevel()) return; // only the primary level may exit.
|
2019-01-29 22:45:14 +00:00
|
|
|
|
|
|
|
FString nextlevel;
|
|
|
|
level_info_t *nextinfo = nullptr;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (unloading)
|
|
|
|
{
|
|
|
|
Printf (TEXTCOLOR_RED "Unloading scripts cannot exit the level again.\n");
|
|
|
|
return;
|
|
|
|
}
|
2019-01-29 22:45:14 +00:00
|
|
|
if (gameaction == ga_completed && !(i_compatflags2 & COMPATF2_MULTIEXIT)) // do not exit multiple times.
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (levelname == NULL || *levelname == 0)
|
|
|
|
{
|
|
|
|
// end the game
|
|
|
|
levelname = NULL;
|
2019-01-29 22:45:14 +00:00
|
|
|
if (!NextMap.Compare("enDSeQ",6))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 22:45:14 +00:00
|
|
|
nextlevel = NextMap; // If there is already an end sequence please leave it alone!
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-11 10:58:38 +00:00
|
|
|
nextlevel.Format("enDSeQ%04x", gameinfo.DefaultEndSequence.GetIndex());
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strncmp(levelname, "enDSeQ", 6) != 0)
|
|
|
|
{
|
|
|
|
FString reallevelname = levelname;
|
|
|
|
CheckWarpTransMap(reallevelname, true);
|
|
|
|
nextinfo = FindLevelInfo (reallevelname, false);
|
|
|
|
if (nextinfo != NULL)
|
|
|
|
{
|
|
|
|
level_info_t *nextredir = nextinfo->CheckLevelRedirect();
|
|
|
|
if (nextredir != NULL)
|
|
|
|
{
|
|
|
|
nextinfo = nextredir;
|
|
|
|
}
|
|
|
|
nextlevel = nextinfo->MapName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nextlevel = levelname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nextlevel = levelname;
|
|
|
|
}
|
|
|
|
|
2020-09-14 07:47:29 +00:00
|
|
|
if (nextSkill != -1)
|
|
|
|
NextSkill = (unsigned)nextSkill < AllSkills.Size() ? nextSkill : -1;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-02-09 11:07:30 +00:00
|
|
|
if (inflags & CHANGELEVEL_NOINTERMISSION)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 22:45:14 +00:00
|
|
|
flags |= LEVEL_NOINTERMISSION;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-29 22:45:14 +00:00
|
|
|
cluster_info_t *thiscluster = FindClusterInfo (cluster);
|
2016-03-01 15:47:10 +00:00
|
|
|
cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL;
|
|
|
|
|
|
|
|
startpos = position;
|
2019-01-29 22:45:14 +00:00
|
|
|
SetMusicVolume(1.0);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (nextinfo != NULL)
|
|
|
|
{
|
|
|
|
if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB)))
|
|
|
|
{
|
|
|
|
if (nextinfo->flags2 & LEVEL2_RESETINVENTORY)
|
|
|
|
{
|
2019-02-09 11:07:30 +00:00
|
|
|
inflags |= CHANGELEVEL_RESETINVENTORY;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (nextinfo->flags2 & LEVEL2_RESETHEALTH)
|
|
|
|
{
|
2019-02-09 11:07:30 +00:00
|
|
|
inflags |= CHANGELEVEL_RESETHEALTH;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-09 11:07:30 +00:00
|
|
|
changeflags = inflags;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-01-30 00:38:18 +00:00
|
|
|
BotInfo.End(); //Added by MC:
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// [RH] Give scripts a chance to do something
|
|
|
|
unloading = true;
|
2019-01-29 22:45:14 +00:00
|
|
|
Behaviors.StartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true);
|
2017-01-23 22:17:12 +00:00
|
|
|
// [ZZ] safe world unload
|
2019-02-02 15:43:11 +00:00
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
// Todo: This must be exolicitly sandboxed!
|
2021-09-27 17:40:57 +00:00
|
|
|
Level->localEventManager->WorldUnloaded(nextlevel);
|
2019-02-02 15:43:11 +00:00
|
|
|
}
|
2017-01-23 22:17:12 +00:00
|
|
|
// [ZZ] unsafe world unload (changemap != map)
|
2021-09-27 17:40:57 +00:00
|
|
|
staticEventManager.WorldUnloaded(nextlevel);
|
2016-03-01 15:47:10 +00:00
|
|
|
unloading = false;
|
|
|
|
|
2019-01-29 22:45:14 +00:00
|
|
|
STAT_ChangeLevel(nextlevel, this);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (thiscluster && (thiscluster->flags & CLUSTER_HUB))
|
|
|
|
{
|
2020-07-21 17:53:27 +00:00
|
|
|
if (!ShouldDoIntermission(nextcluster, thiscluster))
|
2016-03-01 15:47:10 +00:00
|
|
|
NoWipe = 35;
|
|
|
|
D_DrawIcon = "TELEICON";
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
2019-02-01 16:31:11 +00:00
|
|
|
if (PlayerInGame(i))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-02-01 16:31:11 +00:00
|
|
|
player_t *player = Players[i];
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Un-crouch all players here.
|
|
|
|
player->Uncrouch();
|
|
|
|
|
|
|
|
// If this is co-op, respawn any dead players now so they can
|
|
|
|
// keep their inventory on the next map.
|
2019-01-29 22:45:14 +00:00
|
|
|
if ((multiplayer || flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn || !!G_SkillProperty(SKILLP_PlayerRespawn))
|
2018-02-03 14:26:49 +00:00
|
|
|
&& !deathmatch && player->playerstate == PST_DEAD)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
// Copied from the end of P_DeathThink [[
|
|
|
|
player->cls = NULL; // Force a new class if the player is using a random class
|
|
|
|
player->playerstate = PST_REBORN;
|
|
|
|
if (player->mo->special1 > 2)
|
|
|
|
{
|
|
|
|
player->mo->special1 = 0;
|
|
|
|
}
|
|
|
|
// ]]
|
2019-01-29 22:45:14 +00:00
|
|
|
DoReborn(i, false);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-29 22:45:14 +00:00
|
|
|
// Set global transition state.
|
|
|
|
gameaction = ga_completed;
|
|
|
|
::nextlevel = nextlevel;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2020-09-20 19:46:01 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(FLevelLocals, ChangeLevel)
|
|
|
|
{
|
|
|
|
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
|
|
|
PARAM_STRING(levelname);
|
|
|
|
PARAM_INT(position);
|
|
|
|
PARAM_INT(inflags);
|
|
|
|
PARAM_INT(nextSkill);
|
|
|
|
self->ChangeLevel(levelname, position, inflags, nextSkill);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-29 22:45:14 +00:00
|
|
|
const char *FLevelLocals::GetSecretExitMap()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 22:45:14 +00:00
|
|
|
const char *nextmap = NextMap;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-01-29 22:45:14 +00:00
|
|
|
if (NextSecretMap.Len() > 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2020-10-10 09:19:43 +00:00
|
|
|
if (NextSecretMap.Compare("enDSeQ", 6) == 0 || P_CheckMapData(NextSecretMap))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 22:45:14 +00:00
|
|
|
nextmap = NextSecretMap;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nextmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-29 22:45:14 +00:00
|
|
|
|
|
|
|
void FLevelLocals::ExitLevel (int position, bool keepFacing)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 22:45:14 +00:00
|
|
|
flags3 |= LEVEL3_EXITNORMALUSED;
|
|
|
|
ChangeLevel(NextMap, position, keepFacing ? CHANGELEVEL_KEEPFACING : 0);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-06-16 10:29:33 +00:00
|
|
|
static void LevelLocals_ExitLevel(FLevelLocals *self, int position, bool keepFacing)
|
|
|
|
{
|
|
|
|
self->ExitLevel(position, keepFacing);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ExitLevel, LevelLocals_ExitLevel)
|
|
|
|
{
|
|
|
|
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
|
|
|
PARAM_INT(position);
|
|
|
|
PARAM_INT(keepFacing);
|
|
|
|
self->ExitLevel(position, keepFacing);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-29 22:45:14 +00:00
|
|
|
void FLevelLocals::SecretExitLevel (int position)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 22:45:14 +00:00
|
|
|
flags3 |= LEVEL3_EXITSECRETUSED;
|
|
|
|
ChangeLevel(GetSecretExitMap(), position, 0);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-06-16 10:29:33 +00:00
|
|
|
static void LevelLocals_SecretExitLevel(FLevelLocals *self, int position)
|
|
|
|
{
|
|
|
|
self->SecretExitLevel(position);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SecretExitLevel, LevelLocals_SecretExitLevel)
|
|
|
|
{
|
|
|
|
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
|
|
|
PARAM_INT(position);
|
|
|
|
self->SecretExitLevel(position);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2019-02-17 23:43:40 +00:00
|
|
|
static wbstartstruct_t staticWmInfo;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2022-04-10 06:54:45 +00:00
|
|
|
DIntermissionController* FLevelLocals::CreateIntermission()
|
|
|
|
{
|
2022-04-22 09:27:49 +00:00
|
|
|
DIntermissionController* controller = nullptr;
|
2022-04-10 06:54:45 +00:00
|
|
|
cluster_info_t *nextcluster;
|
|
|
|
cluster_info_t *thiscluster;
|
|
|
|
|
|
|
|
if (flags & LEVEL_CHANGEMAPCHEAT)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
thiscluster = FindClusterInfo (cluster);
|
|
|
|
|
2022-04-11 11:12:37 +00:00
|
|
|
bool endgame = strncmp (nextlevel, "enDSeQ", 6) == 0;
|
|
|
|
if (endgame)
|
2022-04-10 06:54:45 +00:00
|
|
|
{
|
|
|
|
FName endsequence = ENamedName(strtoll(nextlevel.GetChars()+6, NULL, 16));
|
|
|
|
// Strife needs a special case here to choose between good and sad ending. Bad is handled elsewhere.
|
|
|
|
if (endsequence == NAME_Inter_Strife)
|
|
|
|
{
|
|
|
|
if (Players[0]->mo->FindInventory (NAME_QuestItem25) ||
|
|
|
|
Players[0]->mo->FindInventory (NAME_QuestItem28))
|
|
|
|
{
|
|
|
|
endsequence = NAME_Inter_Strife_Good;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
endsequence = NAME_Inter_Strife_Sad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ext = info->ExitMapTexts.CheckKey(flags3 & LEVEL3_EXITSECRETUSED ? NAME_Secret : NAME_Normal);
|
|
|
|
if (ext != nullptr && (ext->mDefined & FExitText::DEF_TEXT))
|
|
|
|
{
|
|
|
|
controller = F_StartFinale(ext->mDefined & FExitText::DEF_MUSIC ? ext->mMusic : gameinfo.finaleMusic,
|
|
|
|
ext->mDefined & FExitText::DEF_MUSIC ? ext->mOrder : gameinfo.finaleOrder,
|
|
|
|
-1, 0,
|
|
|
|
ext->mDefined & FExitText::DEF_BACKDROP ? ext->mBackdrop : gameinfo.FinaleFlat,
|
|
|
|
ext->mText,
|
|
|
|
false,
|
|
|
|
ext->mDefined & FExitText::DEF_PIC,
|
|
|
|
ext->mDefined & FExitText::DEF_LOOKUP,
|
|
|
|
true, endsequence);
|
|
|
|
}
|
|
|
|
else if (!(info->flags2 & LEVEL2_NOCLUSTERTEXT))
|
|
|
|
{
|
|
|
|
controller = F_StartFinale(thiscluster->MessageMusic, thiscluster->musicorder,
|
|
|
|
thiscluster->cdtrack, thiscluster->cdid,
|
|
|
|
thiscluster->FinaleFlat, thiscluster->ExitText,
|
|
|
|
thiscluster->flags & CLUSTER_EXITTEXTINLUMP,
|
|
|
|
thiscluster->flags & CLUSTER_FINALEPIC,
|
|
|
|
thiscluster->flags & CLUSTER_LOOKUPEXITTEXT,
|
|
|
|
true, endsequence);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!deathmatch)
|
|
|
|
{
|
|
|
|
FExitText *ext = nullptr;
|
|
|
|
|
|
|
|
if (flags3 & LEVEL3_EXITSECRETUSED) ext = info->ExitMapTexts.CheckKey(NAME_Secret);
|
|
|
|
else if (flags3 & LEVEL3_EXITNORMALUSED) ext = info->ExitMapTexts.CheckKey(NAME_Normal);
|
|
|
|
if (ext == nullptr) ext = info->ExitMapTexts.CheckKey(nextlevel);
|
|
|
|
|
|
|
|
if (ext != nullptr)
|
|
|
|
{
|
|
|
|
if ((ext->mDefined & FExitText::DEF_TEXT))
|
|
|
|
{
|
|
|
|
controller = F_StartFinale(ext->mDefined & FExitText::DEF_MUSIC ? ext->mMusic : gameinfo.finaleMusic,
|
|
|
|
ext->mDefined & FExitText::DEF_MUSIC ? ext->mOrder : gameinfo.finaleOrder,
|
|
|
|
-1, 0,
|
|
|
|
ext->mDefined & FExitText::DEF_BACKDROP ? ext->mBackdrop : gameinfo.FinaleFlat,
|
|
|
|
ext->mText,
|
|
|
|
false,
|
|
|
|
ext->mDefined & FExitText::DEF_PIC,
|
|
|
|
ext->mDefined & FExitText::DEF_LOOKUP,
|
|
|
|
false);
|
|
|
|
}
|
2022-04-11 11:12:37 +00:00
|
|
|
if (controller) controller->mEndGame = false;
|
2022-04-10 06:54:45 +00:00
|
|
|
return controller;
|
|
|
|
}
|
|
|
|
|
|
|
|
nextcluster = FindClusterInfo (FindLevelInfo (nextlevel)->cluster);
|
|
|
|
|
|
|
|
if (nextcluster->cluster != cluster && !(info->flags2 & LEVEL2_NOCLUSTERTEXT))
|
|
|
|
{
|
|
|
|
// Only start the finale if the next level's cluster is different
|
|
|
|
// than the current one and we're not in deathmatch.
|
|
|
|
if (nextcluster->EnterText.IsNotEmpty())
|
|
|
|
{
|
|
|
|
controller = F_StartFinale (nextcluster->MessageMusic, nextcluster->musicorder,
|
|
|
|
nextcluster->cdtrack, nextcluster->cdid,
|
|
|
|
nextcluster->FinaleFlat, nextcluster->EnterText,
|
|
|
|
nextcluster->flags & CLUSTER_ENTERTEXTINLUMP,
|
|
|
|
nextcluster->flags & CLUSTER_FINALEPIC,
|
|
|
|
nextcluster->flags & CLUSTER_LOOKUPENTERTEXT,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
else if (thiscluster->ExitText.IsNotEmpty())
|
|
|
|
{
|
|
|
|
controller = F_StartFinale (thiscluster->MessageMusic, thiscluster->musicorder,
|
|
|
|
thiscluster->cdtrack, nextcluster->cdid,
|
|
|
|
thiscluster->FinaleFlat, thiscluster->ExitText,
|
|
|
|
thiscluster->flags & CLUSTER_EXITTEXTINLUMP,
|
|
|
|
thiscluster->flags & CLUSTER_FINALEPIC,
|
|
|
|
thiscluster->flags & CLUSTER_LOOKUPEXITTEXT,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 11:12:37 +00:00
|
|
|
if (controller) controller->mEndGame = endgame;
|
2022-04-10 06:54:45 +00:00
|
|
|
return controller;
|
|
|
|
}
|
|
|
|
|
2022-04-11 11:12:37 +00:00
|
|
|
void RunIntermission(DIntermissionController* intermissionScreen, DObject* statusScreen, std::function<void(bool)> completionf)
|
|
|
|
{
|
|
|
|
runner = CreateRunner();
|
|
|
|
GC::WriteBarrier(runner);
|
|
|
|
completion = std::move(completionf);
|
|
|
|
|
|
|
|
auto func = LookupFunction("DoomCutscenes.BuildMapTransition");
|
|
|
|
if (func == nullptr)
|
|
|
|
{
|
|
|
|
I_Error("Script function 'DoomCutscenes.BuildMapTransition' not found");
|
|
|
|
}
|
|
|
|
VMValue val[3] = { runner, intermissionScreen, statusScreen };
|
|
|
|
VMCall(func, val, 3, nullptr, 0);
|
|
|
|
|
|
|
|
if (!ScreenJobValidate())
|
|
|
|
{
|
2022-04-22 10:43:08 +00:00
|
|
|
DeleteScreenJob();
|
2022-04-11 11:12:37 +00:00
|
|
|
if (completion) completion(false);
|
|
|
|
completion = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gameaction = ga_intermission;
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
void G_DoCompleted (void)
|
|
|
|
{
|
|
|
|
gameaction = ga_nothing;
|
2019-01-29 01:39:14 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
if ( gamestate == GS_DEMOSCREEN
|
|
|
|
|| gamestate == GS_FULLCONSOLE
|
|
|
|
|| gamestate == GS_STARTUP)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-01-29 01:39:14 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
if (gamestate == GS_TITLELEVEL)
|
|
|
|
{
|
2019-01-29 01:39:14 +00:00
|
|
|
G_DoLoadLevel (nextlevel, startpos, false, false);
|
2016-03-01 15:47:10 +00:00
|
|
|
startpos = 0;
|
|
|
|
viewactive = true;
|
|
|
|
return;
|
|
|
|
}
|
2019-01-29 01:39:14 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
if (automapactive)
|
|
|
|
AM_Stop ();
|
2019-01-29 01:39:14 +00:00
|
|
|
|
2019-01-09 01:03:26 +00:00
|
|
|
// Close the conversation menu if open.
|
|
|
|
P_FreeStrifeConversations ();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2020-09-27 20:23:40 +00:00
|
|
|
bool playinter = primaryLevel->DoCompleted(nextlevel, staticWmInfo);
|
2020-02-23 14:16:23 +00:00
|
|
|
S_StopAllChannels();
|
|
|
|
for (auto Level : AllLevels())
|
|
|
|
{
|
|
|
|
SN_StopAllSequences(Level);
|
|
|
|
}
|
|
|
|
|
2022-04-10 06:54:45 +00:00
|
|
|
// todo: create end of level screenjob
|
2022-04-22 09:27:49 +00:00
|
|
|
DObject* statusScreen = nullptr;
|
|
|
|
DIntermissionController* intermissionScreen = nullptr;
|
2020-09-27 20:23:40 +00:00
|
|
|
if (playinter)
|
2019-01-29 01:39:14 +00:00
|
|
|
{
|
|
|
|
// [RH] If you ever get a statistics driver operational, adapt this.
|
|
|
|
// if (statcopy)
|
|
|
|
// memcpy (statcopy, &wminfo, sizeof(wminfo));
|
|
|
|
|
2022-04-10 06:54:45 +00:00
|
|
|
statusScreen = WI_Start (&staticWmInfo);
|
2019-01-29 01:39:14 +00:00
|
|
|
}
|
2022-04-11 11:12:37 +00:00
|
|
|
bool endgame = intermissionScreen && intermissionScreen->mEndGame;
|
2022-04-10 06:54:45 +00:00
|
|
|
intermissionScreen = primaryLevel->CreateIntermission();
|
2022-04-22 10:43:08 +00:00
|
|
|
RunIntermission(intermissionScreen, statusScreen, [=](bool)
|
|
|
|
{
|
|
|
|
if (!endgame) primaryLevel->WorldDone();
|
|
|
|
|
|
|
|
});
|
2019-01-29 01:39:14 +00:00
|
|
|
}
|
|
|
|
|
2019-02-17 23:43:40 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Prepare the level to be exited and
|
|
|
|
// set up the wminfo struct for the coming intermission screen
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2019-01-29 01:39:14 +00:00
|
|
|
|
|
|
|
bool FLevelLocals::DoCompleted (FString nextlevel, wbstartstruct_t &wminfo)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// [RH] Mark this level as having been visited
|
|
|
|
if (!(flags & LEVEL_CHANGEMAPCHEAT))
|
2019-08-07 10:09:47 +00:00
|
|
|
info->flags |= LEVEL_VISITED;
|
2019-01-29 01:39:14 +00:00
|
|
|
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
uint32_t langtable[2] = {};
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.finished_ep = cluster - 1;
|
|
|
|
wminfo.LName0 = TexMan.CheckForTexture(info->PName, ETextureType::MiscPatch);
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
wminfo.thisname = info->LookupLevelName(&langtable[0]); // re-get the name so we have more info about its origin.
|
2019-08-07 10:09:47 +00:00
|
|
|
if (!wminfo.LName0.isValid() || !(info->flags3 & LEVEL3_HIDEAUTHORNAME)) wminfo.thisauthor = info->AuthorName;
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.current = MapName;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (deathmatch &&
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
(*dmflags & DF_SAME_LEVEL) &&
|
2019-01-29 01:39:14 +00:00
|
|
|
!(flags & LEVEL_CHANGEMAPCHEAT))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.next = MapName;
|
2016-03-01 15:47:10 +00:00
|
|
|
wminfo.LName1 = wminfo.LName0;
|
2019-02-17 23:43:40 +00:00
|
|
|
wminfo.nextname = wminfo.thisname;
|
2019-08-02 07:11:40 +00:00
|
|
|
wminfo.nextauthor = wminfo.thisauthor;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
level_info_t *nextinfo = FindLevelInfo (nextlevel, false);
|
|
|
|
if (nextinfo == NULL || strncmp (nextlevel, "enDSeQ", 6) == 0)
|
|
|
|
{
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
wminfo.next = "";
|
2017-02-23 17:33:49 +00:00
|
|
|
wminfo.LName1.SetInvalid();
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
wminfo.nextname = "";
|
2019-08-02 07:11:40 +00:00
|
|
|
wminfo.nextauthor = "";
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wminfo.next = nextinfo->MapName;
|
2018-03-25 18:26:16 +00:00
|
|
|
wminfo.LName1 = TexMan.CheckForTexture(nextinfo->PName, ETextureType::MiscPatch);
|
2019-02-17 23:43:40 +00:00
|
|
|
wminfo.nextname = nextinfo->LookupLevelName(&langtable[1]);
|
2019-08-07 10:09:47 +00:00
|
|
|
if (!wminfo.LName1.isValid() || !(nextinfo->flags3 & LEVEL3_HIDEAUTHORNAME)) wminfo.nextauthor = nextinfo->AuthorName;
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-19 00:22:12 +00:00
|
|
|
// This cannot use any common localization logic because it may not replace user content at all.
|
|
|
|
// Unlike the menus, replacements here do not merely change the style but also the content.
|
|
|
|
// On the other hand, the IWAD lumps may always be replaced with text, because they are the same style as the BigFont.
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
if (gameinfo.flags & GI_IGNORETITLEPATCHES)
|
|
|
|
{
|
|
|
|
FTextureID *texids[] = { &wminfo.LName0, &wminfo.LName1 };
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
|
|
|
if (texids[i]->isValid() && langtable[i] != FStringTable::default_table)
|
|
|
|
{
|
2020-04-13 22:55:16 +00:00
|
|
|
FGameTexture *tex = TexMan.GetGameTexture(*texids[i]);
|
|
|
|
if (tex != nullptr && !tex->isUserContent())
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
{
|
2020-04-13 22:55:16 +00:00
|
|
|
texids[i]->SetInvalid();
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckWarpTransMap (wminfo.next, true);
|
|
|
|
nextlevel = wminfo.next;
|
|
|
|
|
|
|
|
wminfo.next_ep = FindLevelInfo (wminfo.next)->cluster - 1;
|
2020-08-30 13:34:53 +00:00
|
|
|
wminfo.totalkills = killed_monsters;
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.maxkills = total_monsters;
|
|
|
|
wminfo.maxitems = total_items;
|
|
|
|
wminfo.maxsecret = total_secrets;
|
2016-03-01 15:47:10 +00:00
|
|
|
wminfo.maxfrags = 0;
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.partime = TICRATE * partime;
|
|
|
|
wminfo.sucktime = sucktime;
|
2016-03-01 15:47:10 +00:00
|
|
|
wminfo.pnum = consoleplayer;
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.totaltime = totaltime;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
for (i=0 ; i<MAXPLAYERS ; i++)
|
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
wminfo.plyr[i].skills = Players[i]->killcount;
|
|
|
|
wminfo.plyr[i].sitems = Players[i]->itemcount;
|
|
|
|
wminfo.plyr[i].ssecret = Players[i]->secretcount;
|
2019-01-29 01:39:14 +00:00
|
|
|
wminfo.plyr[i].stime = time;
|
2019-01-30 00:15:32 +00:00
|
|
|
memcpy (wminfo.plyr[i].frags, Players[i]->frags, sizeof(wminfo.plyr[i].frags));
|
|
|
|
wminfo.plyr[i].fragcount = Players[i]->fragcount;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-29 01:39:14 +00:00
|
|
|
// [RH] If we're in a hub and staying within that hub, take a snapshot.
|
|
|
|
// If we're traveling to a new hub, take stuff from
|
2016-03-01 15:47:10 +00:00
|
|
|
// the player and clear the world vars. If this is just an
|
|
|
|
// ordinary cluster (not a hub), take stuff from the player, but
|
|
|
|
// leave the world vars alone.
|
2019-01-29 01:39:14 +00:00
|
|
|
cluster_info_t *thiscluster = FindClusterInfo (cluster);
|
2016-03-01 15:47:10 +00:00
|
|
|
cluster_info_t *nextcluster = FindClusterInfo (wminfo.next_ep+1); // next_ep is cluster-1
|
|
|
|
EFinishLevelType mode;
|
|
|
|
|
|
|
|
if (thiscluster != nextcluster || deathmatch ||
|
|
|
|
!(thiscluster->flags & CLUSTER_HUB))
|
|
|
|
{
|
|
|
|
if (nextcluster->flags & CLUSTER_HUB)
|
|
|
|
{
|
|
|
|
mode = FINISH_NextHub;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mode = FINISH_NoHub;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mode = FINISH_SameHub;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Intermission stats for entire hubs
|
2019-01-29 01:39:14 +00:00
|
|
|
G_LeavingHub(this, mode, thiscluster, &wminfo);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2020-06-09 19:01:14 +00:00
|
|
|
// Do not allow playing sounds in here - they'd never be able to play properly.
|
|
|
|
soundEngine->BlockNewSounds(true);
|
2016-03-01 15:47:10 +00:00
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{ // take away appropriate inventory
|
|
|
|
G_PlayerFinishLevel (i, mode, changeflags);
|
|
|
|
}
|
|
|
|
}
|
2020-06-09 19:01:14 +00:00
|
|
|
soundEngine->BlockNewSounds(false);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
if (mode == FINISH_SameHub)
|
|
|
|
{ // Remember the level's state for re-entry.
|
2019-01-29 01:39:14 +00:00
|
|
|
if (!(flags2 & LEVEL2_FORGETSTATE))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 01:39:14 +00:00
|
|
|
SnapshotLevel ();
|
2016-03-01 15:47:10 +00:00
|
|
|
// Do not free any global strings this level might reference
|
|
|
|
// while it's not loaded.
|
2019-01-29 01:39:14 +00:00
|
|
|
Behaviors.LockLevelVarStrings(levelnum);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Make sure we don't have a snapshot lying around from before.
|
2019-01-29 01:39:14 +00:00
|
|
|
info->Snapshot.Clean();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Forget the states of all existing levels.
|
|
|
|
G_ClearSnapshots ();
|
|
|
|
|
|
|
|
if (mode == FINISH_NextHub)
|
|
|
|
{ // Reset world variables for the new hub.
|
|
|
|
P_ClearACSVars(false);
|
|
|
|
}
|
2019-01-29 01:39:14 +00:00
|
|
|
time = 0;
|
|
|
|
maptime = 0;
|
|
|
|
spawnindex = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 09:03:08 +00:00
|
|
|
finishstate = mode;
|
|
|
|
|
2020-07-21 17:53:27 +00:00
|
|
|
if (!ShouldDoIntermission(nextcluster, thiscluster))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 01:39:14 +00:00
|
|
|
WorldDone ();
|
|
|
|
return false;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2019-01-29 01:39:14 +00:00
|
|
|
return true;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class DAutosaver : public DThinker
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (DAutosaver, DThinker)
|
|
|
|
public:
|
2019-01-27 12:08:54 +00:00
|
|
|
void Construct() {}
|
2016-03-01 15:47:10 +00:00
|
|
|
void Tick ();
|
|
|
|
};
|
|
|
|
|
2016-11-24 20:36:02 +00:00
|
|
|
IMPLEMENT_CLASS(DAutosaver, false, false)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
void DAutosaver::Tick ()
|
|
|
|
{
|
|
|
|
Net_WriteByte (DEM_CHECKAUTOSAVE);
|
|
|
|
Destroy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// G_DoLoadLevel
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
extern gamestate_t wipegamestate;
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
void G_DoLoadLevel(const FString &nextmapname, int position, bool autosave, bool newGame)
|
2019-01-29 01:39:14 +00:00
|
|
|
{
|
2016-03-01 15:47:10 +00:00
|
|
|
gamestate_t oldgs = gamestate;
|
2019-01-29 20:19:16 +00:00
|
|
|
|
|
|
|
// Here the new level needs to be allocated.
|
2019-02-01 23:24:43 +00:00
|
|
|
primaryLevel->DoLoadLevel(nextmapname, position, autosave, newGame);
|
2019-01-29 20:19:16 +00:00
|
|
|
|
|
|
|
// Reset the global state for the new level.
|
|
|
|
if (wipegamestate == GS_LEVEL)
|
|
|
|
wipegamestate = GS_FORCEWIPE;
|
|
|
|
|
|
|
|
if (gamestate != GS_TITLELEVEL)
|
|
|
|
{
|
|
|
|
gamestate = GS_LEVEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gameaction = ga_nothing;
|
|
|
|
|
|
|
|
// clear cmd building stuff
|
2020-04-11 16:09:51 +00:00
|
|
|
buttonMap.ResetButtonStates();
|
2019-01-29 20:19:16 +00:00
|
|
|
|
|
|
|
SendItemUse = nullptr;
|
|
|
|
SendItemDrop = nullptr;
|
|
|
|
mousex = mousey = 0;
|
|
|
|
sendpause = sendsave = sendturn180 = SendLand = false;
|
|
|
|
LocalViewAngle = 0;
|
|
|
|
LocalViewPitch = 0;
|
|
|
|
paused = 0;
|
|
|
|
|
|
|
|
if (demoplayback || oldgs == GS_STARTUP || oldgs == GS_TITLELEVEL)
|
|
|
|
C_HideConsole();
|
|
|
|
|
|
|
|
C_FlushDisplay();
|
|
|
|
P_ResetSightCounters(true);
|
2019-12-25 14:52:57 +00:00
|
|
|
I_UpdateWindowTitle();
|
2019-01-29 20:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FLevelLocals::DoLoadLevel(const FString &nextmapname, int position, bool autosave, bool newGame)
|
|
|
|
{
|
|
|
|
MapName = nextmapname;
|
|
|
|
static int lastposition = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (NextSkill >= 0)
|
|
|
|
{
|
|
|
|
UCVarValue val;
|
|
|
|
val.Int = NextSkill;
|
|
|
|
gameskill.ForceSet (val, CVAR_Int);
|
|
|
|
NextSkill = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position == -1)
|
|
|
|
position = lastposition;
|
|
|
|
else
|
|
|
|
lastposition = position;
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
Init();
|
2016-03-01 15:47:10 +00:00
|
|
|
StatusBar->DetachAllMessages ();
|
|
|
|
|
|
|
|
// Force 'teamplay' to 'true' if need be.
|
2019-01-29 20:19:16 +00:00
|
|
|
if (flags2 & LEVEL2_FORCETEAMPLAYON)
|
2016-03-01 15:47:10 +00:00
|
|
|
teamplay = true;
|
|
|
|
|
|
|
|
// Force 'teamplay' to 'false' if need be.
|
2019-01-29 20:19:16 +00:00
|
|
|
if (flags2 & LEVEL2_FORCETEAMPLAYOFF)
|
2016-03-01 15:47:10 +00:00
|
|
|
teamplay = false;
|
|
|
|
|
2019-02-02 15:43:11 +00:00
|
|
|
if (isPrimaryLevel())
|
|
|
|
{
|
|
|
|
FString mapname = nextmapname;
|
2019-03-16 12:02:38 +00:00
|
|
|
mapname.ToUpper();
|
|
|
|
Printf("\n%s\n\n" TEXTCOLOR_BOLD "%s - %s\n\n", console_bar, mapname.GetChars(), LevelName.GetChars());
|
2019-02-02 15:43:11 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Set the sky map.
|
|
|
|
// First thing, we have a dummy sky texture name,
|
|
|
|
// a flat. The data is in the WAD only because
|
|
|
|
// we look for an actual index, instead of simply
|
|
|
|
// setting one.
|
2018-12-07 01:31:30 +00:00
|
|
|
skyflatnum = TexMan.GetTextureID (gameinfo.SkyFlatName, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// [RH] Set up details about sky rendering
|
2019-01-29 20:19:16 +00:00
|
|
|
InitSkyMap (this);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
if (PlayerInGame(i) && (deathmatch || Players[i]->playerstate == PST_DEAD))
|
|
|
|
Players[i]->playerstate = PST_ENTER; // [BC]
|
|
|
|
memset (Players[i]->frags,0,sizeof(Players[i]->frags));
|
2016-03-01 15:47:10 +00:00
|
|
|
if (!(dmflags2 & DF2_YES_KEEPFRAGS) && (alwaysapplydmflags || deathmatch))
|
2019-01-30 00:15:32 +00:00
|
|
|
Players[i]->fragcount = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changeflags & CHANGELEVEL_NOMONSTERS)
|
|
|
|
{
|
2019-01-29 20:19:16 +00:00
|
|
|
flags2 |= LEVEL2_NOMONSTERS;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-29 20:19:16 +00:00
|
|
|
flags2 &= ~LEVEL2_NOMONSTERS;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (changeflags & CHANGELEVEL_PRERAISEWEAPON)
|
|
|
|
{
|
2019-01-29 20:19:16 +00:00
|
|
|
flags2 |= LEVEL2_PRERAISEWEAPON;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
maptime = 0;
|
2017-02-03 07:04:01 +00:00
|
|
|
|
2018-10-31 07:15:56 +00:00
|
|
|
if (newGame)
|
|
|
|
{
|
2019-02-02 15:43:11 +00:00
|
|
|
staticEventManager.NewGame();
|
2018-10-31 07:15:56 +00:00
|
|
|
}
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
P_SetupLevel (this, position, newGame);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Added by MC: Initialize bots.
|
|
|
|
if (deathmatch)
|
|
|
|
{
|
2019-01-30 00:38:18 +00:00
|
|
|
BotInfo.Init ();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (timingdemo)
|
|
|
|
{
|
|
|
|
static bool firstTime = true;
|
|
|
|
|
|
|
|
if (firstTime)
|
|
|
|
{
|
2017-11-12 02:12:22 +00:00
|
|
|
starttime = I_GetTime ();
|
2016-03-01 15:47:10 +00:00
|
|
|
firstTime = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
starttime = gametic;
|
2017-02-03 07:04:01 +00:00
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
UnSnapshotLevel (!savegamerestore); // [RH] Restore the state of the
|
|
|
|
int pnumerr = FinishTravel ();
|
2018-07-15 08:57:10 +00:00
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
if (!FromSnapshot)
|
2018-07-15 08:57:10 +00:00
|
|
|
{
|
|
|
|
for (int i = 0; i<MAXPLAYERS; i++)
|
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
if (PlayerInGame(i) && Players[i]->mo != nullptr)
|
|
|
|
P_PlayerStartStomp(Players[i]->mo);
|
2018-07-15 08:57:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
// For each player, if they are viewing through a player, make sure it is themselves.
|
|
|
|
for (int ii = 0; ii < MAXPLAYERS; ++ii)
|
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
if (PlayerInGame(ii))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
if (Players[ii]->camera == nullptr || Players[ii]->camera->player != nullptr)
|
2017-02-24 20:45:53 +00:00
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
Players[ii]->camera = Players[ii]->mo;
|
2017-02-24 20:45:53 +00:00
|
|
|
}
|
2017-11-12 09:03:08 +00:00
|
|
|
|
|
|
|
if (savegamerestore)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
const bool fromSnapshot = FromSnapshot;
|
2019-02-02 15:43:11 +00:00
|
|
|
localEventManager->PlayerEntered(ii, fromSnapshot && finishstate == FINISH_SameHub);
|
2017-11-12 09:03:08 +00:00
|
|
|
|
|
|
|
if (fromSnapshot)
|
2017-03-28 19:36:57 +00:00
|
|
|
{
|
2017-11-12 09:03:08 +00:00
|
|
|
// ENTER scripts are being handled when the player gets spawned, this cannot be changed due to its effect on voodoo dolls.
|
2019-01-30 00:15:32 +00:00
|
|
|
Behaviors.StartTypedScripts(SCRIPT_Return, Players[ii]->mo, true);
|
2017-03-28 19:36:57 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-24 20:45:53 +00:00
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
if (FromSnapshot)
|
2017-02-24 20:45:53 +00:00
|
|
|
{
|
|
|
|
// [Nash] run REOPEN scripts upon map re-entry
|
2019-01-29 20:19:16 +00:00
|
|
|
Behaviors.StartTypedScripts(SCRIPT_Reopen, NULL, false);
|
2017-02-24 20:45:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-22 16:29:13 +00:00
|
|
|
StatusBar->AttachToPlayer (&players[consoleplayer]);
|
2017-01-23 22:17:12 +00:00
|
|
|
// unsafe world load
|
2019-02-02 15:43:11 +00:00
|
|
|
staticEventManager.WorldLoaded();
|
2017-01-30 05:50:09 +00:00
|
|
|
// regular world load (savegames are handled internally)
|
2019-02-02 15:43:11 +00:00
|
|
|
localEventManager->WorldLoaded();
|
2019-01-29 20:19:16 +00:00
|
|
|
DoDeferedScripts (); // [RH] Do script actions that were triggered on another map.
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
|
2019-01-29 20:19:16 +00:00
|
|
|
// [RH] Always save the game when entering a new
|
2016-03-01 15:47:10 +00:00
|
|
|
if (autosave && !savegamerestore && disableautosave < 1)
|
|
|
|
{
|
2019-01-29 20:19:16 +00:00
|
|
|
CreateThinker<DAutosaver>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2017-04-25 19:05:36 +00:00
|
|
|
if (pnumerr > 0)
|
|
|
|
{
|
|
|
|
I_Error("no start for player %d found.", pnumerr);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// G_WorldDone
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-27 20:59:19 +00:00
|
|
|
void FLevelLocals::WorldDone (void)
|
2022-04-10 06:54:45 +00:00
|
|
|
{
|
2016-03-01 15:47:10 +00:00
|
|
|
gameaction = ga_worlddone;
|
|
|
|
|
2019-01-29 01:04:31 +00:00
|
|
|
|
|
|
|
//Added by mc
|
|
|
|
if (deathmatch)
|
|
|
|
{
|
2019-01-30 00:38:18 +00:00
|
|
|
BotInfo.RemoveAllBots(this, consoleplayer != Net_Arbitrator);
|
2019-01-29 01:04:31 +00:00
|
|
|
}
|
|
|
|
|
2022-04-10 06:54:45 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-03-18 14:42:34 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(FLevelLocals, WorldDone)
|
|
|
|
{
|
2022-04-10 06:54:45 +00:00
|
|
|
// This is just a dummy to make old status screens happy.
|
2017-03-18 14:42:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void G_DoWorldDone (void)
|
|
|
|
{
|
|
|
|
gamestate = GS_LEVEL;
|
- allow the language table to supersede the title patches, if appropriate
For the Doom IWADs the provided font looks almost identical to the characters used on the title patches. So, for any level name that got replaced in some language, it will now check if the retrieved name comes from the default table, and if not, ignore the title patch and print the name with the specified font.
This also required removing the 'en' label from the default table, because with this present, the text would always be picked from 'en' instead of 'default'. Since 'en' and 'default' had the same contents, in any English locale the 'default' table was never hit, so this won't make any difference for the texts being chosen.
Last but not least, wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect.
2019-02-14 23:29:24 +00:00
|
|
|
if (nextlevel.IsEmpty())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
// Don't crash if no next map is given. Just repeat the current one.
|
|
|
|
Printf ("No next map specified.\n");
|
2019-02-01 23:24:43 +00:00
|
|
|
nextlevel = primaryLevel->MapName;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2019-02-01 23:24:43 +00:00
|
|
|
primaryLevel->StartTravel ();
|
2019-01-29 01:39:14 +00:00
|
|
|
G_DoLoadLevel (nextlevel, startpos, true, false);
|
2016-03-01 15:47:10 +00:00
|
|
|
startpos = 0;
|
|
|
|
gameaction = ga_nothing;
|
|
|
|
viewactive = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// G_StartTravel
|
|
|
|
//
|
|
|
|
// Moves players (and eventually their inventory) to a different statnum,
|
|
|
|
// so they will not be destroyed when switching levels. This only applies
|
|
|
|
// to real players, not voodoo dolls.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-29 15:11:23 +00:00
|
|
|
void FLevelLocals::StartTravel ()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (deathmatch)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
2019-01-30 00:15:32 +00:00
|
|
|
AActor *pawn = Players[i]->mo;
|
2018-12-04 16:00:48 +00:00
|
|
|
AActor *inv;
|
2019-01-30 00:15:32 +00:00
|
|
|
Players[i]->camera = nullptr;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
// Only living players travel. Dead ones get a new body on the new level.
|
2019-01-30 00:15:32 +00:00
|
|
|
if (Players[i]->health > 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-25 21:40:26 +00:00
|
|
|
pawn->UnlinkFromWorld (nullptr);
|
2016-03-01 15:47:10 +00:00
|
|
|
int tid = pawn->tid; // Save TID
|
2019-05-10 08:55:46 +00:00
|
|
|
pawn->SetTID(0);
|
2016-03-01 15:47:10 +00:00
|
|
|
pawn->tid = tid; // Restore TID (but no longer linked into the hash chain)
|
|
|
|
pawn->ChangeStatNum (STAT_TRAVELLING);
|
2019-01-03 22:23:08 +00:00
|
|
|
pawn->DeleteAttachedLights();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory)
|
|
|
|
{
|
|
|
|
inv->ChangeStatNum (STAT_TRAVELLING);
|
2016-12-25 21:40:26 +00:00
|
|
|
inv->UnlinkFromWorld (nullptr);
|
2019-01-03 22:23:08 +00:00
|
|
|
inv->DeleteAttachedLights();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-30 00:38:18 +00:00
|
|
|
BotInfo.StartTravel ();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// G_FinishTravel
|
|
|
|
//
|
|
|
|
// Moves any travelling players so that they occupy their newly-spawned
|
|
|
|
// copies' locations, destroying the new players in the process (because
|
|
|
|
// they are really fake placeholders to show where the travelling players
|
|
|
|
// should go).
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-29 15:11:23 +00:00
|
|
|
int FLevelLocals::FinishTravel ()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 15:11:23 +00:00
|
|
|
auto it = GetThinkerIterator<AActor>(NAME_PlayerPawn, STAT_TRAVELLING);
|
2019-01-03 21:05:49 +00:00
|
|
|
AActor *pawn, *pawndup, *oldpawn, *next;
|
2018-12-04 16:00:48 +00:00
|
|
|
AActor *inv;
|
2016-03-01 15:47:10 +00:00
|
|
|
FPlayerStart *start;
|
|
|
|
int pnum;
|
2017-04-25 19:05:36 +00:00
|
|
|
int failnum = 0;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2017-02-02 18:46:10 +00:00
|
|
|
//
|
2019-01-03 21:05:49 +00:00
|
|
|
AActor* pawns[MAXPLAYERS];
|
2017-02-02 18:46:10 +00:00
|
|
|
int pawnsnum = 0;
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
next = it.Next ();
|
|
|
|
while ( (pawn = next) != NULL)
|
|
|
|
{
|
|
|
|
next = it.Next ();
|
|
|
|
pnum = int(pawn->player - players);
|
|
|
|
pawn->ChangeStatNum (STAT_PLAYER);
|
|
|
|
pawndup = pawn->player->mo;
|
|
|
|
assert (pawn != pawndup);
|
|
|
|
|
2019-01-29 15:11:23 +00:00
|
|
|
start = PickPlayerStart(pnum, 0);
|
2016-03-09 03:51:12 +00:00
|
|
|
if (start == NULL)
|
|
|
|
{
|
2016-09-24 23:28:27 +00:00
|
|
|
if (pawndup != nullptr)
|
2016-03-09 03:51:12 +00:00
|
|
|
{
|
|
|
|
Printf(TEXTCOLOR_RED "No player %d start to travel to!\n", pnum + 1);
|
|
|
|
// Move to the coordinates this player had when they left the level.
|
2016-03-26 08:28:00 +00:00
|
|
|
pawn->SetXYZ(pawndup->Pos());
|
2016-03-09 03:51:12 +00:00
|
|
|
}
|
2016-09-24 23:28:27 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Could not find a start for this player at all. This really should never happen but if it does, let's better abort.
|
2017-04-25 19:05:36 +00:00
|
|
|
if (failnum == 0) failnum = pnum + 1;
|
2016-09-24 23:28:27 +00:00
|
|
|
}
|
2016-03-09 03:51:12 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
oldpawn = pawndup;
|
|
|
|
|
|
|
|
// The player being spawned here is a short lived dummy and
|
|
|
|
// must not start any ENTER script or big problems will happen.
|
2019-01-29 15:11:23 +00:00
|
|
|
pawndup = SpawnPlayer(start, pnum, SPF_TEMPPLAYER);
|
2016-03-09 03:51:12 +00:00
|
|
|
if (pawndup != NULL)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-03-09 03:51:12 +00:00
|
|
|
if (!(changeflags & CHANGELEVEL_KEEPFACING))
|
|
|
|
{
|
2016-03-16 11:41:26 +00:00
|
|
|
pawn->Angles = pawndup->Angles;
|
2016-03-09 03:51:12 +00:00
|
|
|
}
|
2016-03-20 18:52:35 +00:00
|
|
|
pawn->SetXYZ(pawndup->Pos());
|
2016-03-19 23:54:18 +00:00
|
|
|
pawn->Vel = pawndup->Vel;
|
2016-03-09 03:51:12 +00:00
|
|
|
pawn->Sector = pawndup->Sector;
|
|
|
|
pawn->floorz = pawndup->floorz;
|
|
|
|
pawn->ceilingz = pawndup->ceilingz;
|
|
|
|
pawn->dropoffz = pawndup->dropoffz;
|
|
|
|
pawn->floorsector = pawndup->floorsector;
|
|
|
|
pawn->floorpic = pawndup->floorpic;
|
|
|
|
pawn->floorterrain = pawndup->floorterrain;
|
|
|
|
pawn->ceilingsector = pawndup->ceilingsector;
|
|
|
|
pawn->ceilingpic = pawndup->ceilingpic;
|
2016-03-20 22:42:27 +00:00
|
|
|
pawn->Floorclip = pawndup->Floorclip;
|
2016-03-09 03:51:12 +00:00
|
|
|
pawn->waterlevel = pawndup->waterlevel;
|
|
|
|
}
|
2017-04-25 19:05:36 +00:00
|
|
|
else if (failnum == 0) // In the failure case this may run into some undefined data.
|
2016-03-09 03:51:12 +00:00
|
|
|
{
|
|
|
|
P_FindFloorCeiling(pawn);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2019-01-07 08:14:52 +00:00
|
|
|
pawn->target = nullptr;
|
|
|
|
pawn->lastenemy = nullptr;
|
2016-03-01 15:47:10 +00:00
|
|
|
pawn->player->mo = pawn;
|
|
|
|
pawn->player->camera = pawn;
|
2019-01-03 17:01:58 +00:00
|
|
|
pawn->player->viewheight = pawn->player->DefaultViewHeight();
|
2016-03-01 15:47:10 +00:00
|
|
|
pawn->flags2 &= ~MF2_BLASTED;
|
2016-09-24 23:28:27 +00:00
|
|
|
if (oldpawn != nullptr)
|
|
|
|
{
|
2020-04-11 17:22:16 +00:00
|
|
|
StaticPointerSubstitution (oldpawn, pawn);
|
2016-09-24 23:28:27 +00:00
|
|
|
oldpawn->Destroy();
|
|
|
|
}
|
2016-03-09 03:51:12 +00:00
|
|
|
if (pawndup != NULL)
|
|
|
|
{
|
|
|
|
pawndup->Destroy();
|
|
|
|
}
|
2016-12-25 21:40:26 +00:00
|
|
|
pawn->LinkToWorld (nullptr);
|
2016-03-01 15:47:10 +00:00
|
|
|
pawn->ClearInterpolation();
|
2019-05-10 08:55:46 +00:00
|
|
|
const int tid = pawn->tid; // Save TID (actor isn't linked into the hash chain yet)
|
|
|
|
pawn->tid = 0; // Reset TID
|
|
|
|
pawn->SetTID(tid); // Set TID (and link actor into the hash chain)
|
2016-03-01 15:47:10 +00:00
|
|
|
pawn->SetState(pawn->SpawnState);
|
|
|
|
pawn->player->SendPitchLimits();
|
|
|
|
|
|
|
|
for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory)
|
|
|
|
{
|
2016-08-25 19:41:17 +00:00
|
|
|
inv->ChangeStatNum (STAT_INVENTORY);
|
2016-12-25 21:40:26 +00:00
|
|
|
inv->LinkToWorld (nullptr);
|
2020-08-22 07:56:45 +00:00
|
|
|
P_FindFloorCeiling(inv, FFCF_ONLYSPAWNPOS);
|
2017-01-15 18:44:43 +00:00
|
|
|
|
2018-12-04 16:00:48 +00:00
|
|
|
IFVIRTUALPTRNAME(inv, NAME_Inventory, Travelled)
|
2017-01-15 18:44:43 +00:00
|
|
|
{
|
|
|
|
VMValue params[1] = { inv };
|
2017-04-12 23:12:04 +00:00
|
|
|
VMCall(func, params, 1, nullptr, 0);
|
2017-01-15 18:44:43 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (ib_compatflags & BCOMPATF_RESETPLAYERSPEED)
|
|
|
|
{
|
|
|
|
pawn->Speed = pawn->GetDefault()->Speed;
|
|
|
|
}
|
2020-09-02 10:12:58 +00:00
|
|
|
|
|
|
|
IFVIRTUALPTRNAME(pawn, NAME_PlayerPawn, Travelled)
|
|
|
|
{
|
|
|
|
VMValue params[1] = { pawn };
|
|
|
|
VMCall(func, params, 1, nullptr, 0);
|
|
|
|
}
|
2017-02-02 18:46:10 +00:00
|
|
|
// [ZZ] we probably don't want to fire any scripts before all players are in, especially with runNow = true.
|
|
|
|
pawns[pawnsnum++] = pawn;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-30 00:38:18 +00:00
|
|
|
BotInfo.FinishTravel ();
|
2016-08-26 00:16:06 +00:00
|
|
|
|
|
|
|
// make sure that, after travelling has completed, no travelling thinkers are left.
|
|
|
|
// Since this list is excluded from regular thinker cleaning, anything that may survive through here
|
|
|
|
// will endlessly multiply and severely break the following savegames or just simply crash on broken pointers.
|
2019-01-30 01:15:48 +00:00
|
|
|
Thinkers.DestroyThinkersInList(STAT_TRAVELLING);
|
2017-04-25 19:05:36 +00:00
|
|
|
return failnum;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-02-02 16:29:13 +00:00
|
|
|
FLevelLocals::FLevelLocals() : Behaviors(this), tagManager(this)
|
|
|
|
{
|
|
|
|
// Make sure that these point to the right data all the time.
|
|
|
|
// This will be needed for as long as it takes to completely separate global UI state from per-level play state.
|
|
|
|
for (int i = 0; i < MAXPLAYERS; i++)
|
|
|
|
{
|
|
|
|
Players[i] = &players[i];
|
|
|
|
}
|
2019-03-02 12:24:52 +00:00
|
|
|
localEventManager = new EventManager(this);
|
2019-02-02 16:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FLevelLocals::~FLevelLocals()
|
|
|
|
{
|
|
|
|
if (localEventManager) delete localEventManager;
|
2020-04-26 16:54:43 +00:00
|
|
|
if (aabbTree) delete aabbTree;
|
2019-02-02 16:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-25 18:46:03 +00:00
|
|
|
void FLevelLocals::Init()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-29 00:09:02 +00:00
|
|
|
P_InitParticles(this);
|
|
|
|
P_ClearParticles(this);
|
2016-03-01 15:47:10 +00:00
|
|
|
BaseBlendA = 0.0f; // Remove underwater blend effect, if any
|
|
|
|
|
2019-01-25 18:46:03 +00:00
|
|
|
gravity = sv_gravity * 35/TICRATE;
|
|
|
|
aircontrol = sv_aircontrol;
|
2019-02-24 08:57:46 +00:00
|
|
|
AirControlChanged();
|
2019-01-28 14:41:52 +00:00
|
|
|
teamdamage = ::teamdamage;
|
2019-01-25 18:46:03 +00:00
|
|
|
flags = 0;
|
|
|
|
flags2 = 0;
|
|
|
|
flags3 = 0;
|
2019-01-26 22:36:22 +00:00
|
|
|
ImpactDecalCount = 0;
|
2019-08-09 08:39:09 +00:00
|
|
|
frozenstate = 0;
|
2019-01-25 18:46:03 +00:00
|
|
|
|
|
|
|
info = FindLevelInfo (MapName);
|
|
|
|
|
|
|
|
skyspeed1 = info->skyspeed1;
|
|
|
|
skyspeed2 = info->skyspeed2;
|
|
|
|
skytexture1 = TexMan.GetTextureID(info->SkyPic1, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
|
|
|
skytexture2 = TexMan.GetTextureID(info->SkyPic2, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
|
|
|
fadeto = info->fadeto;
|
|
|
|
cdtrack = info->cdtrack;
|
|
|
|
cdid = info->cdid;
|
|
|
|
FromSnapshot = false;
|
|
|
|
if (fadeto == 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (strnicmp (info->FadeTable, "COLORMAP", 8) != 0)
|
|
|
|
{
|
2019-01-25 18:46:03 +00:00
|
|
|
flags |= LEVEL_HASFADETABLE;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-25 18:46:03 +00:00
|
|
|
airsupply = info->airsupply*TICRATE;
|
|
|
|
outsidefog = info->outsidefog;
|
|
|
|
WallVertLight = info->WallVertLight*2;
|
|
|
|
WallHorizLight = info->WallHorizLight*2;
|
2016-03-01 15:47:10 +00:00
|
|
|
if (info->gravity != 0.f)
|
|
|
|
{
|
2019-01-25 18:46:03 +00:00
|
|
|
gravity = info->gravity * 35/TICRATE;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (info->aircontrol != 0.f)
|
|
|
|
{
|
2019-01-25 18:46:03 +00:00
|
|
|
aircontrol = info->aircontrol;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
if (info->teamdamage != 0.f)
|
|
|
|
{
|
2019-01-25 18:46:03 +00:00
|
|
|
teamdamage = info->teamdamage;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2019-01-27 20:59:19 +00:00
|
|
|
AirControlChanged ();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
cluster_info_t *clus = FindClusterInfo (info->cluster);
|
|
|
|
|
2019-01-25 18:46:03 +00:00
|
|
|
partime = info->partime;
|
|
|
|
sucktime = info->sucktime;
|
|
|
|
cluster = info->cluster;
|
|
|
|
clusterflags = clus ? clus->flags : 0;
|
|
|
|
flags |= info->flags;
|
|
|
|
flags2 |= info->flags2;
|
|
|
|
flags3 |= info->flags3;
|
|
|
|
levelnum = info->levelnum;
|
|
|
|
Music = info->Music;
|
|
|
|
musicorder = info->musicorder;
|
|
|
|
MusicVolume = 1.f;
|
|
|
|
HasHeightSecs = false;
|
|
|
|
|
|
|
|
LevelName = info->LookupLevelName();
|
|
|
|
NextMap = info->NextMap;
|
|
|
|
NextSecretMap = info->NextSecretMap;
|
|
|
|
F1Pic = info->F1Pic;
|
2019-08-02 07:11:40 +00:00
|
|
|
AuthorName = info->AuthorName;
|
2019-01-25 18:46:03 +00:00
|
|
|
hazardcolor = info->hazardcolor;
|
|
|
|
hazardflash = info->hazardflash;
|
2017-03-14 12:54:24 +00:00
|
|
|
|
|
|
|
// GL fog stuff modifiable by SetGlobalFogParameter.
|
2019-01-25 18:46:03 +00:00
|
|
|
fogdensity = info->fogdensity;
|
|
|
|
outsidefogdensity = info->outsidefogdensity;
|
|
|
|
skyfog = info->skyfog;
|
|
|
|
deathsequence = info->deathsequence;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2019-01-25 18:46:03 +00:00
|
|
|
pixelstretch = info->pixelstretch;
|
2017-12-29 07:42:03 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
compatflags.Callback();
|
|
|
|
compatflags2.Callback();
|
|
|
|
|
2019-01-25 18:46:03 +00:00
|
|
|
DefaultEnvironment = info->DefaultEnvironment;
|
2018-04-01 16:45:27 +00:00
|
|
|
|
2019-01-25 18:46:03 +00:00
|
|
|
lightMode = info->lightmode == ELightMode::NotSet? (ELightMode)*gl_lightmode : info->lightmode;
|
|
|
|
brightfog = info->brightfog < 0? gl_brightfog : !!info->brightfog;
|
|
|
|
lightadditivesurfaces = info->lightadditivesurfaces < 0 ? gl_lightadditivesurfaces : !!info->lightadditivesurfaces;
|
|
|
|
notexturefill = info->notexturefill < 0 ? gl_notexturefill : !!info->notexturefill;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
FString CalcMapName (int episode, int level)
|
|
|
|
{
|
|
|
|
FString lumpname;
|
|
|
|
|
|
|
|
if (gameinfo.flags & GI_MAPxx)
|
|
|
|
{
|
|
|
|
lumpname.Format("MAP%02d", level);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-27 14:21:28 +00:00
|
|
|
lumpname.Format("E%01dM%01d", episode, level);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
return lumpname;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-27 20:59:19 +00:00
|
|
|
void FLevelLocals::AirControlChanged ()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-27 20:59:19 +00:00
|
|
|
if (aircontrol <= 1/256.)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2019-01-27 20:59:19 +00:00
|
|
|
airfriction = 1.;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Friction is inversely proportional to the amount of control
|
2019-01-27 20:59:19 +00:00
|
|
|
airfriction = aircontrol * -0.0941 + 1.0004;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-09-21 15:37:56 +00:00
|
|
|
void G_WriteSnapshots(TArray<FString> &filenames, TArray<FCompressedBuffer> &buffers)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2016-09-21 15:37:56 +00:00
|
|
|
FString filename;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
for (i = 0; i < wadlevelinfos.Size(); i++)
|
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
if (wadlevelinfos[i].Snapshot.mCompressedSize > 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-22 09:51:29 +00:00
|
|
|
filename.Format("%s.map.json", wadlevelinfos[i].MapName.GetChars());
|
2016-09-21 15:37:56 +00:00
|
|
|
filename.ToLower();
|
|
|
|
filenames.Push(filename);
|
|
|
|
buffers.Push(wadlevelinfos[i].Snapshot);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-21 15:37:56 +00:00
|
|
|
if (TheDefaultLevelInfo.Snapshot.mCompressedSize > 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-22 09:51:29 +00:00
|
|
|
filename.Format("%s.mapd.json", TheDefaultLevelInfo.MapName.GetChars());
|
2016-09-21 15:37:56 +00:00
|
|
|
filename.ToLower();
|
|
|
|
filenames.Push(filename);
|
|
|
|
buffers.Push(TheDefaultLevelInfo.Snapshot);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-09-21 15:37:56 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 15:37:56 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void G_WriteVisited(FSerializer &arc)
|
|
|
|
{
|
|
|
|
if (arc.BeginArray("visited"))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
// Write out which levels have been visited
|
|
|
|
for (auto & wi : wadlevelinfos)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
if (wi.flags & LEVEL_VISITED)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
arc.AddString(nullptr, wi.MapName);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-21 15:37:56 +00:00
|
|
|
arc.EndArray();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Store player classes to be used when spawning a random class
|
|
|
|
if (multiplayer)
|
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
arc.Array("randomclasses", SinglePlayerClass, MAXPLAYERS);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-21 15:37:56 +00:00
|
|
|
if (arc.BeginObject("playerclasses"))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 15:37:56 +00:00
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
FString key;
|
|
|
|
key.Format("%d", i);
|
|
|
|
arc(key, players[i].cls);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-09-21 15:37:56 +00:00
|
|
|
arc.EndObject();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-09-21 23:28:05 +00:00
|
|
|
void G_ReadSnapshots(FResourceFile *resf)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
FString MapName;
|
|
|
|
level_info_t *i;
|
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
G_ClearSnapshots();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 23:28:05 +00:00
|
|
|
for (unsigned j = 0; j < resf->LumpCount(); j++)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 23:28:05 +00:00
|
|
|
FResourceLump * resl = resf->GetLump(j);
|
|
|
|
if (resl != nullptr)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2020-04-11 11:14:52 +00:00
|
|
|
auto name = resl->getName();
|
|
|
|
auto ptr = strstr(name, ".map.json");
|
2016-09-21 23:28:05 +00:00
|
|
|
if (ptr != nullptr)
|
|
|
|
{
|
2020-04-11 11:14:52 +00:00
|
|
|
ptrdiff_t maplen = ptr - name;
|
|
|
|
FString mapname(name, (size_t)maplen);
|
2016-09-21 23:28:05 +00:00
|
|
|
i = FindLevelInfo(mapname);
|
|
|
|
if (i != nullptr)
|
|
|
|
{
|
|
|
|
i->Snapshot = resl->GetRawData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-11 11:14:52 +00:00
|
|
|
auto ptr = strstr(name, ".mapd.json");
|
2016-09-21 23:28:05 +00:00
|
|
|
if (ptr != nullptr)
|
|
|
|
{
|
2020-04-11 11:14:52 +00:00
|
|
|
ptrdiff_t maplen = ptr - name;
|
|
|
|
FString mapname(name, (size_t)maplen);
|
2016-09-21 23:28:05 +00:00
|
|
|
TheDefaultLevelInfo.Snapshot = resl->GetRawData();
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-21 22:18:31 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 23:28:05 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
void G_ReadVisited(FSerializer &arc)
|
|
|
|
{
|
|
|
|
if (arc.BeginArray("visited"))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
for (int s = arc.ArraySize(); s > 0; s--)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
FString str;
|
|
|
|
arc(nullptr, str);
|
|
|
|
auto i = FindLevelInfo(str);
|
|
|
|
if (i != nullptr) i->flags |= LEVEL_VISITED;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-09-21 22:18:31 +00:00
|
|
|
arc.EndArray();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
arc.Array("randomclasses", SinglePlayerClass, MAXPLAYERS);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
if (arc.BeginObject("playerclasses"))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
FString key;
|
|
|
|
key.Format("%d", i);
|
|
|
|
arc(key, players[i].cls);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-09-21 22:18:31 +00:00
|
|
|
arc.EndObject();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:28:05 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
2016-03-01 15:47:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
void P_WriteACSDefereds (FSerializer &arc)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
bool found = false;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 10:19:13 +00:00
|
|
|
// only write this stuff if needed
|
|
|
|
for (auto &wi : wadlevelinfos)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
if (wi.deferred.Size() > 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
found = true;
|
|
|
|
break;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-21 10:19:13 +00:00
|
|
|
if (found && arc.BeginObject("deferred"))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 10:19:13 +00:00
|
|
|
for (auto &wi : wadlevelinfos)
|
|
|
|
{
|
|
|
|
if (wi.deferred.Size() > 0)
|
|
|
|
{
|
2016-09-22 10:36:29 +00:00
|
|
|
if (wi.deferred.Size() > 0)
|
2016-09-21 10:19:13 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
arc(wi.MapName, wi.deferred);
|
2016-09-21 10:19:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arc.EndObject();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
void P_ReadACSDefereds (FSerializer &arc)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
FString MapName;
|
2016-09-21 23:28:05 +00:00
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
P_RemoveDefereds ();
|
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
if (arc.BeginObject("deferred"))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
const char *key;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-09-21 22:18:31 +00:00
|
|
|
while ((key = arc.GetKey()))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
level_info_t *i = FindLevelInfo(key);
|
2016-04-03 18:55:23 +00:00
|
|
|
if (i == NULL)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-21 22:18:31 +00:00
|
|
|
I_Error("Unknown map '%s' in savegame", key);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
- removed the sequential processing of JSON objects because the benefit is too small.
After testing with a savegame on ZDCMP2 which is probably the largest map in existence, timing both methods resulted in a speed difference of less than 40 ms (70 vs 110 ms for reading all sectory, linedefs, sidedefs and objects).
This compares to an overall restoration time, including reloading the level, precaching all textures and setting everything up, of approx. 1.2 s, meaning an increase of 3% of the entire reloading time.
That's simply not worth all the negative side effects that may happen with a method that highly depends on proper code construction.
On the other hand, using random access means that a savegame version change is only needed now when the semantics of a field change, but not if some get added or deleted.
- do not I_Error out in the serializer unless caused by a programming error.
It is better to let the serializer finish, collect all the errors and I_Error out when the game is known to be in a stable enough state to allow unwinding.
2016-09-23 12:04:05 +00:00
|
|
|
arc(nullptr, i->deferred);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-09-21 22:18:31 +00:00
|
|
|
arc.EndObject();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-10 01:00:58 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// This object is responsible for marking sectors during the propagate
|
|
|
|
// stage. In case there are many, many sectors, it lets us break them
|
|
|
|
// up instead of marking them all at once.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
class DSectorMarker : public DObject
|
|
|
|
{
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SECTORSTEPSIZE = 32,
|
|
|
|
POLYSTEPSIZE = 120,
|
|
|
|
SIDEDEFSTEPSIZE = 240
|
|
|
|
};
|
|
|
|
DECLARE_CLASS(DSectorMarker, DObject)
|
|
|
|
public:
|
|
|
|
DSectorMarker(FLevelLocals *l) : Level(l), SecNum(0),PolyNum(0),SideNum(0) {}
|
|
|
|
size_t PropagateMark();
|
|
|
|
FLevelLocals *Level;
|
|
|
|
int SecNum;
|
|
|
|
int PolyNum;
|
|
|
|
int SideNum;
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS(DSectorMarker, true, false)
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// DSectorMarker :: PropagateMark
|
|
|
|
//
|
|
|
|
// Propagates marks across a few sectors and reinserts itself into the
|
|
|
|
// gray list if it didn't do them all.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
size_t DSectorMarker::PropagateMark()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int marked = 0;
|
|
|
|
bool moretodo = false;
|
|
|
|
int numsectors = Level->sectors.Size();
|
|
|
|
|
|
|
|
for (i = 0; i < SECTORSTEPSIZE && SecNum + i < numsectors; ++i)
|
|
|
|
{
|
|
|
|
sector_t *sec = &Level->sectors[SecNum + i];
|
|
|
|
GC::Mark(sec->SoundTarget);
|
|
|
|
GC::Mark(sec->SecActTarget);
|
|
|
|
GC::Mark(sec->floordata);
|
|
|
|
GC::Mark(sec->ceilingdata);
|
|
|
|
GC::Mark(sec->lightingdata);
|
|
|
|
for(int j = 0; j < 4; j++) GC::Mark(sec->interpolations[j]);
|
|
|
|
}
|
|
|
|
marked += i * sizeof(sector_t);
|
|
|
|
if (SecNum + i < numsectors)
|
|
|
|
{
|
|
|
|
SecNum += i;
|
|
|
|
moretodo = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!moretodo && Level->Polyobjects.Size() > 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < POLYSTEPSIZE && PolyNum + i < (int)Level->Polyobjects.Size(); ++i)
|
|
|
|
{
|
|
|
|
GC::Mark(Level->Polyobjects[PolyNum + i].interpolation);
|
|
|
|
}
|
|
|
|
marked += i * sizeof(FPolyObj);
|
|
|
|
if (PolyNum + i < (int)Level->Polyobjects.Size())
|
|
|
|
{
|
|
|
|
PolyNum += i;
|
|
|
|
moretodo = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!moretodo && Level->sides.Size() > 0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < SIDEDEFSTEPSIZE && SideNum + i < (int)Level->sides.Size(); ++i)
|
|
|
|
{
|
|
|
|
side_t *side = &Level->sides[SideNum + i];
|
|
|
|
for (int j = 0; j < 3; j++) GC::Mark(side->textures[j].interpolation);
|
|
|
|
}
|
|
|
|
marked += i * sizeof(side_t);
|
|
|
|
if (SideNum + i < (int)Level->sides.Size())
|
|
|
|
{
|
|
|
|
SideNum += i;
|
|
|
|
moretodo = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If there are more items to mark, put ourself back into the gray list.
|
|
|
|
if (moretodo)
|
|
|
|
{
|
|
|
|
Black2Gray();
|
|
|
|
GCNext = GC::Gray;
|
|
|
|
GC::Gray = this;
|
|
|
|
}
|
|
|
|
return marked;
|
|
|
|
}
|
|
|
|
|
2016-03-01 15:47:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FLevelLocals::Tick ()
|
|
|
|
{
|
|
|
|
// Reset carry sectors
|
2016-09-20 07:11:13 +00:00
|
|
|
if (Scrolls.Size() > 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-09-20 07:11:13 +00:00
|
|
|
memset (&Scrolls[0], 0, sizeof(Scrolls[0])*Scrolls.Size());
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2018-11-19 17:13:23 +00:00
|
|
|
void FLevelLocals::Mark()
|
|
|
|
{
|
2019-01-10 01:00:58 +00:00
|
|
|
if (SectorMarker == nullptr && (sectors.Size() > 0 || Polyobjects.Size() > 0 || sides.Size() > 0))
|
|
|
|
{
|
|
|
|
SectorMarker = Create<DSectorMarker>(this);
|
|
|
|
}
|
|
|
|
else if (sectors.Size() == 0 && Polyobjects.Size() == 0 && sides.Size() == 0)
|
|
|
|
{
|
|
|
|
SectorMarker = nullptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SectorMarker->SecNum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GC::Mark(SectorMarker);
|
2019-01-05 09:04:27 +00:00
|
|
|
GC::Mark(SpotState);
|
2019-01-05 08:40:03 +00:00
|
|
|
GC::Mark(FraggleScriptThinker);
|
2019-01-05 20:59:34 +00:00
|
|
|
GC::Mark(ACSThinker);
|
2019-01-26 14:21:20 +00:00
|
|
|
GC::Mark(automap);
|
2019-01-28 17:26:14 +00:00
|
|
|
GC::Mark(interpolator.Head);
|
2019-01-28 22:53:40 +00:00
|
|
|
GC::Mark(SequenceListHead);
|
2019-01-30 00:38:18 +00:00
|
|
|
GC::Mark(BotInfo.firstthing);
|
|
|
|
GC::Mark(BotInfo.body1);
|
|
|
|
GC::Mark(BotInfo.body2);
|
2019-02-02 16:29:13 +00:00
|
|
|
if (localEventManager)
|
|
|
|
{
|
|
|
|
GC::Mark(localEventManager->FirstEventHandler);
|
|
|
|
GC::Mark(localEventManager->LastEventHandler);
|
|
|
|
}
|
2019-01-30 18:09:21 +00:00
|
|
|
Thinkers.MarkRoots();
|
2018-12-10 23:01:45 +00:00
|
|
|
canvasTextureInfo.Mark();
|
2019-01-05 09:53:06 +00:00
|
|
|
for (auto &c : CorpseQueue)
|
|
|
|
{
|
|
|
|
GC::Mark(c);
|
|
|
|
}
|
2018-11-19 17:13:23 +00:00
|
|
|
for (auto &s : sectorPortals)
|
|
|
|
{
|
|
|
|
GC::Mark(s.mSkybox);
|
|
|
|
}
|
|
|
|
// Mark dead bodies.
|
|
|
|
for (auto &p : bodyque)
|
|
|
|
{
|
|
|
|
GC::Mark(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-03-28 15:27:55 +00:00
|
|
|
void FLevelLocals::AddScroller (int secnum)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (secnum < 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2016-09-20 07:11:13 +00:00
|
|
|
if (Scrolls.Size() == 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2017-01-07 18:32:24 +00:00
|
|
|
Scrolls.Resize(sectors.Size());
|
|
|
|
memset(&Scrolls[0], 0, sizeof(Scrolls[0])*Scrolls.Size());
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-18 18:34:03 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FLevelLocals::SetInterMusic(const char *nextmap)
|
|
|
|
{
|
2019-01-27 23:55:21 +00:00
|
|
|
auto mus = info->MapInterMusic.CheckKey(nextmap);
|
2017-03-18 18:34:03 +00:00
|
|
|
if (mus != nullptr)
|
|
|
|
S_ChangeMusic(mus->first, mus->second);
|
2019-01-27 23:55:21 +00:00
|
|
|
else if (info->InterMusic.IsNotEmpty())
|
|
|
|
S_ChangeMusic(info->InterMusic, info->intermusicorder);
|
2017-03-18 18:34:03 +00:00
|
|
|
else
|
|
|
|
S_ChangeMusic(gameinfo.intermissionMusic.GetChars(), gameinfo.intermissionOrder);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(FLevelLocals, SetInterMusic)
|
|
|
|
{
|
|
|
|
PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals);
|
|
|
|
PARAM_STRING(map);
|
|
|
|
self->SetInterMusic(map);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-01 01:02:14 +00:00
|
|
|
//==========================================================================
|
2018-03-24 12:06:37 +00:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FLevelLocals::SetMusicVolume(float f)
|
|
|
|
{
|
|
|
|
MusicVolume = f;
|
|
|
|
I_SetMusicVolume(f);
|
|
|
|
}
|
|
|
|
|
2019-01-28 13:31:23 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
int FLevelLocals::GetInfighting()
|
|
|
|
{
|
|
|
|
if (flags2 & LEVEL2_TOTALINFIGHTING) return 1;
|
|
|
|
if (flags2 & LEVEL2_NOINFIGHTING) return -1;
|
|
|
|
return G_SkillProperty(SKILLP_Infight);
|
|
|
|
}
|
|
|
|
|
2019-01-29 18:28:22 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// transfers the compatiblity flag for old PointOnLineSide to each line.
|
|
|
|
// This gets checked in a frequently called worker function and the closer
|
|
|
|
// this info is to the data this function works on, the better.
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void FLevelLocals::SetCompatLineOnSide(bool state)
|
|
|
|
{
|
|
|
|
int on = (state && (i_compatflags2 & COMPATF2_POINTONLINE));
|
2019-03-23 14:28:10 +00:00
|
|
|
if (on) for (auto &l : lines) l.flags |= ML_COMPATSIDE;
|
|
|
|
else for (auto &l : lines) l.flags &= ~ML_COMPATSIDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FLevelLocals::GetCompatibility(int mask)
|
|
|
|
{
|
|
|
|
if (info == nullptr) return mask;
|
|
|
|
else return (mask & ~info->compatmask) | (info->compatflags & info->compatmask);
|
|
|
|
}
|
|
|
|
|
|
|
|
int FLevelLocals::GetCompatibility2(int mask)
|
|
|
|
{
|
|
|
|
return (info == nullptr) ? mask
|
|
|
|
: (mask & ~info->compatmask2) | (info->compatflags2 & info->compatmask2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FLevelLocals::ApplyCompatibility()
|
|
|
|
{
|
|
|
|
int old = i_compatflags;
|
|
|
|
i_compatflags = GetCompatibility(compatflags) | ii_compatflags;
|
|
|
|
if ((old ^ i_compatflags) & COMPATF_POLYOBJ)
|
|
|
|
{
|
|
|
|
ClearAllSubsectorLinks();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FLevelLocals::ApplyCompatibility2()
|
|
|
|
{
|
|
|
|
i_compatflags2 = GetCompatibility2(compatflags2) | ii_compatflags2;
|
2019-01-29 18:28:22 +00:00
|
|
|
}
|
|
|
|
|
2018-03-24 12:06:37 +00:00
|
|
|
//==========================================================================
|
2018-11-07 20:03:32 +00:00
|
|
|
// IsPointInMap
|
2018-01-01 01:02:14 +00:00
|
|
|
//
|
2018-11-07 20:03:32 +00:00
|
|
|
// Checks to see if a point is inside the void or not.
|
|
|
|
// Made by dpJudas, modified and implemented by Major Cooke
|
2018-01-01 01:02:14 +00:00
|
|
|
//==========================================================================
|
|
|
|
|
2019-01-29 00:30:41 +00:00
|
|
|
int IsPointInMap(FLevelLocals *Level, double x, double y, double z)
|
2018-11-07 20:03:32 +00:00
|
|
|
{
|
2019-01-29 00:30:41 +00:00
|
|
|
// This uses the render nodes because those are guaranteed to be GL nodes, meaning all subsectors are closed.
|
|
|
|
subsector_t *subsector = Level->PointInRenderSubsector(FLOAT2FIXED(x), FLOAT2FIXED(y));
|
2018-11-07 20:03:32 +00:00
|
|
|
if (!subsector) return false;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < subsector->numlines; i++)
|
|
|
|
{
|
2019-03-10 18:07:48 +00:00
|
|
|
// Skip double sided lines.
|
2018-11-07 20:03:32 +00:00
|
|
|
seg_t *seg = subsector->firstline + i;
|
2019-03-10 18:07:48 +00:00
|
|
|
if (seg->backsector != nullptr || seg->linedef == nullptr) continue;
|
2018-11-08 13:26:42 +00:00
|
|
|
|
|
|
|
divline_t dline;
|
|
|
|
P_MakeDivline(seg->linedef, &dline);
|
2018-12-05 23:28:05 +00:00
|
|
|
bool pol = P_PointOnDivlineSide(x, y, &dline) < 1;
|
2018-11-08 13:26:42 +00:00
|
|
|
if (!pol) return false;
|
2018-11-07 20:03:32 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 23:28:05 +00:00
|
|
|
double ceilingZ = subsector->sector->ceilingplane.ZatPoint(x, y);
|
|
|
|
if (z > ceilingZ) return false;
|
2018-11-07 20:03:32 +00:00
|
|
|
|
2018-12-05 23:28:05 +00:00
|
|
|
double floorZ = subsector->sector->floorplane.ZatPoint(x, y);
|
|
|
|
if (z < floorZ) return false;
|
2018-11-07 20:03:32 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-23 15:15:19 +00:00
|
|
|
|
|
|
|
void FLevelLocals::SetMusic()
|
|
|
|
{
|
2020-02-18 20:52:56 +00:00
|
|
|
S_ChangeMusic(Music, musicorder);
|
2019-08-23 15:15:19 +00:00
|
|
|
}
|