diff --git a/config/scontext.cfg b/config/scontext.cfg index 99544393..414239be 100644 --- a/config/scontext.cfg +++ b/config/scontext.cfg @@ -5,16 +5,19 @@ context_core = 0 // hardcoded scripts context_cfg = 1 // known scripts context_prompt = 2 // command prompt -context_mapcfg = 3 // map configs, we don't trust them +context_mdlcfg = 4 // mdl configs, same // set allowed commands for the map config context mapcfgidents = [ loadnotexture loadsky mapmodelreset mapmodel texturereset texture fog fogcolour mapsoundreset mapsound watercolour shadowyaw ] +mdlcfgidents = [ md2anim md2emit md2tag md3anim md3emit md3link md3load md3skin mdlalphatest mdlcachelimit mdlcullface mdlscale mdlshadowdist mdltrans mdltranslucent mdlvertexlight] loop i (listlen $mapcfgidents) [ scriptcontext $context_mapcfg (at $mapcfgidents $i) ] +loop i (listlen $mdlcfgidents) [ scriptcontext $context_mdlcfg (at $mdlcfgidents $i) ] // isolate the map config context // this disables access from this context to identifiers located in other contexts // also it removes all aliases created in this context once the running context changes isolatecontext $context_mapcfg +isolatecontext $context_mdlcfg // secure this configuration for the rest of the game sealcontexts \ No newline at end of file diff --git a/source/src/command.h b/source/src/command.h index a7f78695..767a9fc7 100644 --- a/source/src/command.h +++ b/source/src/command.h @@ -87,7 +87,7 @@ enum // function signatures for script functions, see command.cpp ARG_VARI }; -enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_NUM }; // script execution context +enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_MDLCFG, IEXC_NUM }; // script execution context // nasty macros for registering script functions, abuses globals to avoid excessive infrastructure #define COMMANDN(name, fun, nargs) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, nargs) diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index b8b185f0..5e4f45fe 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -116,6 +116,7 @@ model *loadmodel(const char *name, int i) if(mm) m = *mm; else { + pushscontext(IEXC_MDLCFG); m = new md2(name); loadingmodel = m; if(!m->load()) @@ -127,9 +128,10 @@ model *loadmodel(const char *name, int i) { delete m; loadingmodel = NULL; - return NULL; } } + popscontext(); + if(!loadingmodel) return NULL; loadingmodel = NULL; mdllookup.access(m->name(), m); }