From 34d8212d648b3bcfe0edef89ed328986f4c121d3 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 18 Jun 2010 03:35:41 +0000 Subject: [PATCH] - Changed G_ChangeLevel()'s parameter list to match the ACS version's. - Added resethealth to complement resetinventory. SVN r2377 (trunk) --- src/d_net.cpp | 2 +- src/g_game.cpp | 12 ++++++++++-- src/g_game.h | 2 +- src/g_level.cpp | 36 ++++++++++++++++++++---------------- src/g_level.h | 14 ++++++++++++-- src/g_mapinfo.cpp | 1 + src/p_acs.cpp | 7 +------ src/p_acs.h | 10 ---------- src/p_lnspec.cpp | 2 +- 9 files changed, 47 insertions(+), 39 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 264aed1df..997919963 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2021,7 +2021,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) // Using LEVEL_NOINTERMISSION tends to throw the game out of sync. // That was a long time ago. Maybe it works now? level.flags |= LEVEL_CHANGEMAPCHEAT; - G_ChangeLevel(s, pos, false); + G_ChangeLevel(s, pos, 0); break; case DEM_SUICIDE: diff --git a/src/g_game.cpp b/src/g_game.cpp index fc4a21772..d68ead9ef 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1163,7 +1163,9 @@ void G_Ticker () // G_PlayerFinishLevel // Called when a player completes a level. // -void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory) +// flags is checked for RESETINVENTORY and RESETHEALTH only. + +void G_PlayerFinishLevel (int player, EFinishLevelType mode, int flags) { AInventory *item, *next; player_t *p; @@ -1235,8 +1237,14 @@ void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory P_UndoPlayerMorph (p, p, 0, true); } + // Resets player health to default + if (flags & CHANGELEVEL_RESETHEALTH) + { + p->health = p->mo->health = p->mo->SpawnHealth(); + } + // Clears the entire inventory and gives back the defaults for starting a game - if (resetinventory) + if (flags & CHANGELEVEL_RESETINVENTORY) { AInventory *inv = p->mo->Inventory; diff --git a/src/g_game.h b/src/g_game.h index 56f16081b..20fdae892 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -71,7 +71,7 @@ enum EFinishLevelType FINISH_NoHub }; -void G_PlayerFinishLevel (int player, EFinishLevelType mode, bool resetinventory); +void G_PlayerFinishLevel (int player, EFinishLevelType mode, int flags); void G_DoReborn (int playernum, bool freshbot); diff --git a/src/g_level.cpp b/src/g_level.cpp index fbefb011d..b14959efe 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -529,10 +529,8 @@ void G_InitNew (const char *mapname, bool bTitleLevel) 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 bool startkeepfacing; // [RH] Support for keeping your facing angle -static bool resetinventory; // Reset the inventory to the player's default for the next level +static int changeflags; static bool unloading; -static bool g_nomonsters; //========================================================================== // @@ -543,8 +541,7 @@ static bool g_nomonsters; //========================================================================== -void G_ChangeLevel(const char *levelname, int position, bool keepFacing, int nextSkill, - bool nointermission, bool resetinv, bool nomonsters) +void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill) { level_info_t *nextinfo = NULL; @@ -573,25 +570,32 @@ void G_ChangeLevel(const char *levelname, int position, bool keepFacing, int nex if (nextSkill != -1) NextSkill = nextSkill; - g_nomonsters = nomonsters; - - if (nointermission) level.flags |= LEVEL_NOINTERMISSION; + if (flags & CHANGELEVEL_NOINTERMISSION) + { + level.flags |= LEVEL_NOINTERMISSION; + } cluster_info_t *thiscluster = FindClusterInfo (level.cluster); cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL; startpos = position; - startkeepfacing = keepFacing; gameaction = ga_completed; - resetinventory = resetinv; if (nextinfo != NULL) { if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB))) { - resetinventory |= !!(nextinfo->flags2 & LEVEL2_RESETINVENTORY); + if (nextinfo->flags2 & LEVEL2_RESETINVENTORY) + { + flags |= CHANGELEVEL_RESETINVENTORY; + } + if (nextinfo->flags2 & LEVEL2_RESETHEALTH) + { + flags |= CHANGELEVEL_RESETHEALTH; + } } } + changeflags = flags; bglobal.End(); //Added by MC: @@ -667,12 +671,12 @@ const char *G_GetSecretExitMap() void G_ExitLevel (int position, bool keepFacing) { - G_ChangeLevel(G_GetExitMap(), position, keepFacing); + G_ChangeLevel(G_GetExitMap(), position, keepFacing ? CHANGELEVEL_KEEPFACING : 0); } void G_SecretExitLevel (int position) { - G_ChangeLevel(G_GetSecretExitMap(), position, false); + G_ChangeLevel(G_GetSecretExitMap(), position, 0); } //========================================================================== @@ -786,7 +790,7 @@ void G_DoCompleted (void) { if (playeringame[i]) { // take away appropriate inventory - G_PlayerFinishLevel (i, mode, resetinventory); + G_PlayerFinishLevel (i, mode, changeflags); } } @@ -927,7 +931,7 @@ void G_DoLoadLevel (int position, bool autosave) players[i].fragcount = 0; } - if (g_nomonsters) + if (changeflags & CHANGELEVEL_NOMONSTERS) { level.flags2 |= LEVEL2_NOMONSTERS; } @@ -1164,7 +1168,7 @@ void G_FinishTravel () // The player being spawned here is a short lived dummy and // must not start any ENTER script or big problems will happen. pawndup = P_SpawnPlayer (&playerstarts[pawn->player - players], true); - if (!startkeepfacing) + if (!changeflags & CHANGELEVEL_KEEPFACING) { pawn->angle = pawndup->angle; pawn->pitch = pawndup->pitch; diff --git a/src/g_level.h b/src/g_level.h index 4edf4409e..701437452 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -201,6 +201,7 @@ enum ELevelFlags LEVEL2_SMOOTHLIGHTING = 0x01000000, // Level uses the smooth lighting feature. LEVEL2_POLYGRIND = 0x02000000, // Polyobjects grind corpses to gibs. LEVEL2_RESETINVENTORY = 0x04000000, // Resets player inventory when starting this level (unless in a hub) + LEVEL2_RESETHEALTH = 0x08000000, // Resets player health when starting this level (unless in a hub) }; @@ -491,8 +492,17 @@ void G_SecretExitLevel (int position); const char *G_GetExitMap(); const char *G_GetSecretExitMap(); -void G_ChangeLevel(const char * levelname, int position, bool keepFacing, int nextSkill=-1, - bool nointermission=false, bool resetinventory=false, bool nomonsters=false); +enum +{ + CHANGELEVEL_KEEPFACING = 1, + CHANGELEVEL_RESETINVENTORY = 2, + CHANGELEVEL_NOMONSTERS = 4, + CHANGELEVEL_CHANGESKILL = 8, + CHANGELEVEL_NOINTERMISSION = 16, + CHANGELEVEL_RESETHEALTH = 32, +}; + +void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill=-1); void G_SetForEndGame (char *nextmap); diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 53cd9ee5c..004b47a2f 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1373,6 +1373,7 @@ MapFlagHandlers[] = { "grinding_polyobj", MITYPE_SETFLAG2, LEVEL2_POLYGRIND, 0 }, { "no_grinding_polyobj", MITYPE_CLRFLAG2, LEVEL2_POLYGRIND, 0 }, { "resetinventory", MITYPE_SETFLAG2, LEVEL2_RESETINVENTORY, 0 }, + { "resethealth", MITYPE_SETFLAG2, LEVEL2_RESETHEALTH, 0 }, { "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 }, { "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes { "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX}, diff --git a/src/p_acs.cpp b/src/p_acs.cpp index c8afb1f26..eb69c60be 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -6250,12 +6250,7 @@ int DLevelScript::RunScript () case PCD_CHANGELEVEL: { - int flags = STACK(2); - G_ChangeLevel(FBehavior::StaticLookupString(STACK(4)), STACK(3), - !!(flags & CHANGELEVEL_KEEPFACING), STACK(1), - !!(flags & CHANGELEVEL_NOINTERMISSION), - !!(flags & CHANGELEVEL_RESETINVENTORY), - !!(flags & CHANGELEVEL_NOMONSTERS)); + G_ChangeLevel(FBehavior::StaticLookupString(STACK(4)), STACK(3), STACK(2), STACK(1)); sp -= 4; } break; diff --git a/src/p_acs.h b/src/p_acs.h index c57af5793..8e193d41e 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -667,16 +667,6 @@ public: SCRIPT_ModulusBy0, }; - enum - { - CHANGELEVEL_KEEPFACING = 1, - CHANGELEVEL_RESETINVENTORY = 2, - CHANGELEVEL_NOMONSTERS = 4, - CHANGELEVEL_CHANGESKILL = 8, - CHANGELEVEL_NOINTERMISSION = 16 - }; - - DLevelScript (AActor *who, line_t *where, int num, const ScriptPtr *code, FBehavior *module, bool backSide, int arg0, int arg1, int arg2, int always); ~DLevelScript (); diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index cf79e376b..fb0bd31ab 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -792,7 +792,7 @@ FUNC(LS_Teleport_NewMap) if (info && CheckIfExitIsGood (it, info)) { - G_ChangeLevel(info->mapname, arg1, !!arg2); + G_ChangeLevel(info->mapname, arg1, arg2 ? CHANGELEVEL_KEEPFACING : 0); return true; } }