persistidents fixes (plz review/test)

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7213 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Bukz
2013-02-16 01:43:47 +00:00
parent 7ab718f74e
commit 7480f036d3
31 changed files with 126 additions and 46 deletions
+2 -2
View File
@@ -1155,9 +1155,9 @@ void startmap(const char *name, bool reset) // called just after a map load
// run once
if(firstrun)
{
persistidents = false;
per_idents = false;
execfile("config/firstrun.cfg");
persistidents = true;
per_idents = true;
firstrun = false;
}
// execute mapstart event once
+18 -6
View File
@@ -17,11 +17,23 @@ int loop_level = 0; // avoid bad calls of b
hashtable<const char *, ident> *idents = NULL; // contains ALL vars/commands/aliases
bool persistidents = true, neverpersist = false;
COMMANDF(persistidents, "i", (int *on) {
persistidents = neverpersist ? false : *on;
VAR(persistidents, 0, 1, 1);
bool per_idents = true, neverpersist = false;
COMMANDF(per_idents, "i", (int *on) {
per_idents = neverpersist ? false : *on;
});
void ispersist()
{
if (persistidents)
conoutf("persistidents is on");
else
conoutf("persistidents is off");
}
COMMAND(ispersist, "");
void clearstack(ident &id)
{
identstack *stack = id.stack;
@@ -63,7 +75,7 @@ ident *newident(const char *name, int context = execcontext)
ident *id = idents->access(name);
if(!id)
{
ident init(ID_ALIAS, newstring(name), newstring(""), persistidents, context);
ident init(ID_ALIAS, newstring(name), newstring(""), per_idents, context);
id = &idents->access(init.name, init);
}
return id;
@@ -153,7 +165,7 @@ void constant(const char *name, const char *action)
ident *b = idents->access(name);
if(!b)
{
ident b(ID_ALIAS, newstring(name), newstring(action), persistidents, execcontext);
ident b(ID_ALIAS, newstring(name), newstring(action), false, execcontext); // never write consts to saved.cfg, too error prone - Bukz
b.isconst = true;
idents->access(b.name, b);
return;
@@ -177,7 +189,7 @@ void constant(const char *name, const char *action)
{
if(b->action!=b->executing) delete[] b->action;
b->action = newstring(action);
if(b->persist!=persistidents) b->persist = persistidents;
//if(b->persist!=persistidents) b->persist = persistidents;
}
}
else
+6 -6
View File
@@ -1110,7 +1110,7 @@ int main(int argc, char **argv)
if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)");
initlog("console");
persistidents = false;
per_idents = false;
// Main font file, all other font files execute from here.
if(!execfile("config/font.cfg")) fatal("cannot find default font definitions");
// Check these 2 standard fonts have been executed.
@@ -1147,7 +1147,7 @@ int main(int argc, char **argv)
exec("config/securemaps.cfg");
exec("config/admin.cfg");
execfile("config/servers.cfg");
persistidents = true;
per_idents = true;
static char resdata[] = { 112, 97, 99, 107, 97, 103, 101, 115, 47, 116, 101, 120, 116, 117, 114, 101, 115, 47, 107, 117, 114, 116, 47, 107, 108, 105, 116, 101, 50, 46, 106, 112, 103, 0 };
stream *f = opengzfile(resdata, "rb");
@@ -1173,9 +1173,9 @@ int main(int argc, char **argv)
if(identexists("afterinit")) execute("afterinit");
if(compatibilitymode)
{
persistidents = false;
per_idents = false;
exec("config/compatibility.cfg"); // exec after saved.cfg to get "compatibilitymode", but before user scripts..
persistidents = true;
per_idents = true;
}
execfile("config/autoexec.cfg");
execfile("config/auth.cfg");
@@ -1189,9 +1189,9 @@ int main(int argc, char **argv)
preload_entmodels();
initlog("docs");
persistidents = false;
per_idents = false;
execfile("config/docs.cfg");
persistidents = true;
per_idents = true;
initlog("localconnect");
extern string clientmap;
+2 -2
View File
@@ -258,7 +258,7 @@ struct md2 : vertmodel
if(skin==notexture) conoutf(_("could not load model skin for %s"), name1);
loadingmd2 = this;
defformatstring(name2)("packages/models/%s/md2.cfg", loadname);
persistidents = false;
per_idents = false;
neverpersist = true;
if(!execfile(name2))
{
@@ -266,7 +266,7 @@ struct md2 : vertmodel
execfile(name2);
}
neverpersist = false;
persistidents = true;
per_idents = true;
loadingmd2 = 0;
loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z));
radius = calcradius();
+3 -3
View File
@@ -215,19 +215,19 @@ struct md3 : vertmodel
defformatstring(cfgname)("packages/models/%s/md3.cfg", loadname);
loadingmd3 = this;
persistidents = false;
per_idents = false;
neverpersist = true;
if(execfile(cfgname) && parts.length()) // configured md3, will call the md3* commands below
{
neverpersist = false;
persistidents = true;
per_idents = true;
loadingmd3 = NULL;
if(parts.empty()) return false;
loopv(parts) if(!parts[i]->filename) return false;
}
else // md3 without configuration, try default tris and skin
{
persistidents = false;
per_idents = false;
loadingmd3 = NULL;
md3part &mdl = *new md3part;
parts.add(&mdl);
+1 -1
View File
@@ -781,7 +781,7 @@ extern bool checkchallenge(const char *answerstr, void *correct);
extern void conoutf(const char *s, ...);
// command
extern bool persistidents, neverpersist;
extern bool per_idents, neverpersist;
extern int variable(const char *name, int min, int cur, int max, int *storage, void (*fun)(), bool persist);
extern float fvariable(const char *name, float min, float cur, float max, float *storage, void (*fun)(), bool persist);
extern char *svariable(const char *name, const char *cur, char **storage, void (*fun)(), bool persist);
+3 -3
View File
@@ -786,8 +786,8 @@ void addfavcategory(const char *refdes)
if(!text[0]) { intret(0); return; }
loopv(favcats) if(!strcmp(favcats[i], text)) { intret(i + 1); return; }
favcats.add(newstring(text));
bool oldpersist = persistidents;
persistidents = false; // only keep changed values
bool oldpersist = per_idents;
per_idents = false; // only keep changed values
loopi(FC_NUM) alx[i] = getalias(favcatargname(text, i)) ? 1 : 0;
loopi(3)
{
@@ -798,7 +798,7 @@ void addfavcategory(const char *refdes)
const int defk[] = { FC_WEIGHT, FC_DESC, FC_TAG, FC_KEYS, FC_IGNORE, FC_ALPHA };
const char *defv[] = { "0", val, refdes, "", "", "20" };
loopi(sizeof(defk)/sizeof(defk[0])) { if(!alx[defk[i]]) alias(favcatargname(text, defk[i]), defv[i]); }
persistidents = oldpersist;
per_idents = oldpersist;
intret(favcats.length());
}
+2 -2
View File
@@ -514,11 +514,11 @@ bool empty_world(int factor, bool force) // main empty world creation routine
if(clearmap)
{
pushscontext(IEXC_MAPCFG);
persistidents = false;
per_idents = false;
neverpersist = true;
execfile("config/default_map_settings.cfg");
neverpersist = false;
persistidents = true;
per_idents = true;
popscontext();
setvar("fullbright", 1);
fullbrightlight();
+4 -4
View File
@@ -690,13 +690,13 @@ bool load_world(char *mname) // still supports all map formats that have
conoutf("read map %s rev %d (%d milliseconds)", cgzname, hdr.maprevision, watch.stop());
conoutf("%s", hdr.maptitle);
pushscontext(IEXC_MAPCFG); // untrusted altogether
persistidents = false;
per_idents = false;
neverpersist = true;
execfile("config/default_map_settings.cfg");
execfile(pcfname);
execfile(mcfname);
neverpersist = false;
persistidents = true;
per_idents = true;
popscontext();
c2skeepalive();
@@ -841,13 +841,13 @@ void listmapdependencies(char *mapname) // print map dependencies to file
allmods[0] = '\0';
enumeratek(usedmods, const char *, key, concatformatstring(allmods, "%s%s",*allmods ? ", " : "", key); delete key; usedm++);
pushscontext(IEXC_MAPCFG); // untrusted altogether
persistidents = false;
per_idents = false;
neverpersist = true;
execfile(mcfname);
f->printf(" used: %s%s %d total packages (%s.cfg)\n", allmods, usedm ? ", " : "", usedm, mapname);
if(usedm) conoutf(" used: %s (%s.cfg) in %s", allmods, mapname, mapname);
neverpersist = false;
persistidents = true;
per_idents = true;
popscontext();
f->printf("\n\n");
}