[nexuiz-commits] r7206 - trunk/data/qcsrc/common
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Jul 12 12:00:07 EDT 2009
Author: div0
Date: 2009-07-12 12:00:05 -0400 (Sun, 12 Jul 2009)
New Revision: 7206
Modified:
trunk/data/qcsrc/common/mapinfo.qc
trunk/data/qcsrc/common/util.qc
Log:
mapinfo: support #include in settemps
Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc 2009-07-12 15:50:48 UTC (rev 7205)
+++ trunk/data/qcsrc/common/mapinfo.qc 2009-07-12 16:00:05 UTC (rev 7206)
@@ -535,6 +535,58 @@
else return 0;
}
+void _MapInfo_Parse_Settemp(string pFilename, string acl, string s, float recurse)
+{
+ string t;
+ float fh;
+ t = car(s); s = cdr(s);
+ if(t == "#include")
+ {
+ if(recurse > 0)
+ {
+ fh = fopen(s, FILE_READ);
+ if(fh < 0)
+ print("Map ", pFilename, " references not existing config file ", s, "\n");
+ else
+ {
+ for(;;)
+ {
+ if not((s = fgets(fh)))
+ break;
+
+ // catch different sorts of comments
+ if(s == "") // empty lines
+ continue;
+ if(substring(s, 0, 1) == "#") // UNIX style
+ continue;
+ if(substring(s, 0, 2) == "//") // C++ style
+ continue;
+ if(substring(s, 0, 1) == "_") // q3map style
+ continue;
+
+ _MapInfo_Parse_Settemp(pFilename, acl, s, recurse - 1);
+ }
+ fclose(fh);
+ }
+ }
+ else
+ print("Map ", pFilename, " uses too many levels of inclusion\n");
+ }
+ else if not(cvar_value_issafe(t))
+ print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
+ else if not (cvar_value_issafe(s))
+ print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
+ else if(substring(t, 0, 10) == "g_mapinfo_")
+ print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
+ else if(matchacl(acl, t) <= 0)
+ print("Map ", pFilename, " contains a denied setting, ignored\n");
+ else
+ {
+ dprint("Applying temporary setting ", t, " := ", s, "\n");
+ cvar_settemp(t, s);
+ }
+}
+
// load info about a map by name into the MapInfo_Map_* globals
float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet)
{
@@ -728,20 +780,7 @@
{
if(f & pGametypeToSet)
{
- t = car(s); s = cdr(s);
- if not(cvar_value_issafe(t))
- print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
- else if not (cvar_value_issafe(s))
- print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
- else if(substring(t, 0, 10) == "g_mapinfo_")
- print("Map ", pFilename, " contains a potentially harmful setting, ignored\n");
- else if(matchacl(acl, t) <= 0)
- print("Map ", pFilename, " contains a denied setting, ignored\n");
- else
- {
- dprint("Applying temporary setting ", t, " := ", s, "\n");
- cvar_settemp(t, s);
- }
+ _MapInfo_Parse_Settemp(pFilename, acl, s, 1);
}
}
else
Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc 2009-07-12 15:50:48 UTC (rev 7205)
+++ trunk/data/qcsrc/common/util.qc 2009-07-12 16:00:05 UTC (rev 7206)
@@ -871,6 +871,8 @@
#else
void cvar_settemp(string pKey, string pValue)
{
+ if(cvar_string(pKey) == pValue)
+ return;
cvar_set("settemp_list", strcat("1 ", pKey, " ", cvar_string("settemp_var"), " ", cvar_string("settemp_list")));
#ifdef MENUQC
registercvar(cvar_string("settemp_var"), "", 0);
More information about the nexuiz-commits
mailing list