From c770d4a99ae56ded200b8a43eaa830971d486785 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 17 May 2006 01:38:07 +0000 Subject: [PATCH] - Added support for automatically loading ACS objects (even for Doom-format maps). To use it, compile the ACS files as ordinary libraries placed between A_START/A_END markers. Then outside the markers, create a lump called LOADACS. This is just a plain text lump that lists all the libraries you want to autoload with every map. You can do this with as many libraries as you want, and LOADACS lumps are also cummulative. SVN r123 (trunk) --- docs/rh-log.txt | 8 +++++++- src/g_level.h | 3 --- src/p_acs.cpp | 34 ++++++++++++++++++++++++++++++++++ src/p_acs.h | 1 + src/p_mobj.cpp | 15 ++++++--------- src/p_setup.cpp | 12 ++---------- 6 files changed, 50 insertions(+), 23 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f05ac878d5..b816c4c4d6 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,10 @@ -May 16, 2006 +-May 16, 2006 +- Added support for automatically loading ACS objects (even for Doom-format + maps). To use it, compile the ACS files as ordinary libraries placed + between A_START/A_END markers. Then outside the markers, create a lump + called LOADACS. This is just a plain text lump that lists all the libraries + you want to autoload with every map. You can do this with as many libraries + as you want, and LOADACS lumps are also cummulative. - Fixed: ApplyActorDefault() must ensure that dataint is non-negative before calculating a non-NULL state. When compiling with Visual C++, states are stored in the defaults list as byte values, but when compiling with GCC, diff --git a/src/g_level.h b/src/g_level.h index 08994c38e7..0356cd0494 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -107,7 +107,6 @@ #define LEVEL_CROUCH_YES UCONST64(0x100000000000) struct acsdefered_s; -class FBehavior; struct FSpecialAction { @@ -221,8 +220,6 @@ struct level_locals_s fixed_t airfriction; int airsupply; - FBehavior *behavior; - FSectorScrollValues *Scrolls; // NULL if no DScrollers in this level SBYTE WallVertLight; // Light diffs for vert/horiz walls diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 76c43ae6aa..138ec121d2 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -62,6 +62,8 @@ #include "w_wad.h" #include "r_sky.h" #include "gstrings.h" +#include "gi.h" +#include "sc_man.h" extern FILE *Logfile; @@ -456,6 +458,38 @@ void DPlaneWatcher::Tick () //---- ACS lump manager ----// +// Load user-specified default modules. This must be called after the level's +// own behavior is loaded (if it has one). +void FBehavior::StaticLoadDefaultModules () +{ + // When playing Strife, STRFHELP is always loaded. + if (gameinfo.gametype == GAME_Strife) + { + StaticLoadModule (Wads.CheckNumForName ("STRFHELP", ns_acslibrary)); + } + + // Scan each LOADACS lump and load the specified modules in order + int lump, lastlump = 0; + + while ((lump = Wads.FindLump ("LOADACS", &lastlump)) != -1) + { + SC_OpenLumpNum (lump, "LOADACS"); + while (SC_GetString()) + { + int acslump = Wads.CheckNumForName (sc_String, ns_acslibrary); + if (acslump >= 0) + { + StaticLoadModule (acslump); + } + else + { + Printf ("Could not find autoloaded ACS library %s\n", sc_String); + } + } + SC_Close (); + } +} + FBehavior *FBehavior::StaticLoadModule (int lumpnum) { for (unsigned int i = 0; i < StaticModules.Size(); ++i) diff --git a/src/p_acs.h b/src/p_acs.h index d0974f5c9f..d5940b214d 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -146,6 +146,7 @@ public: SDWORD *MapVars[NUM_MAPVARS]; static FBehavior *StaticLoadModule (int lumpnum); + static void StaticLoadDefaultModules (); static void StaticUnloadModules (); static bool StaticCheckAllGood (); static FBehavior *StaticGetModule (int lib); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index bf6e5184d6..1de4a2ae8e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3471,16 +3471,13 @@ void P_SpawnPlayer (mapthing2_t *mthing) P_PlayerStartStomp (mobj); // [BC] Do script stuff - if (level.behavior != NULL) + if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore)) { - if (state == PST_ENTER || (state == PST_LIVE && !savegamerestore)) - { - FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true); - } - else if (state == PST_REBORN) - { - FBehavior::StaticStartTypedScripts (SCRIPT_Respawn, p->mo, true); - } + FBehavior::StaticStartTypedScripts (SCRIPT_Enter, p->mo, true); + } + else if (state == PST_REBORN) + { + FBehavior::StaticStartTypedScripts (SCRIPT_Respawn, p->mo, true); } } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index f77febaf7d..5aaec2f382 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -2777,12 +2777,11 @@ void P_LoadReject (int lump, bool junk) // void P_LoadBehavior (int lumpnum) { - level.behavior = FBehavior::StaticLoadModule (lumpnum); + FBehavior::StaticLoadModule (lumpnum); if (!FBehavior::StaticCheckAllGood ()) { Printf ("ACS scripts unloaded.\n"); FBehavior::StaticUnloadModules (); - level.behavior = NULL; } } @@ -2866,7 +2865,6 @@ void P_FreeLevelData () level.killed_monsters = level.found_items = level.found_secrets = wminfo.maxfrags = 0; FBehavior::StaticUnloadModules (); - level.behavior = NULL; if (vertexes != NULL) { delete[] vertexes; @@ -3092,7 +3090,6 @@ void P_SetupLevel (char *lumpname, int position) ForceNodeBuild = gennodes; // [RH] Load in the BEHAVIOR lump FBehavior::StaticUnloadModules (); - level.behavior = NULL; if (HasBehavior) { P_LoadBehavior (lumpnum+ML_BEHAVIOR); @@ -3106,13 +3103,8 @@ void P_SetupLevel (char *lumpname, int position) { level.flags &= ~LEVEL_LAXMONSTERACTIVATION; } - // FIXME: Also load STRFHELP for Strife maps with their own BEHAVIOR. - // But since none exist right now, I'm not in a big hurry to do it. - if (gameinfo.gametype == GAME_Strife) - { - P_LoadBehavior (Wads.CheckNumForName ("STRFHELP", ns_acslibrary)); - } } + FBehavior::StaticLoadDefaultModules (); P_LoadStrifeConversations (lumpname);