persistidents cleanup

Restore the old persistidents system from AC 1.0, since it's working as
intended - if used properly.

As a reminder:

  * aliases created by "const" and "tempalias" are never persistent
  * aliases created or altered by "alias" or "=" become persistent, if
    the persistidents flag is set during that operation
  * persistidents if false during the execution of almost all config files
    during game start - those files can create aliases with default values
    which will not be persistent (until changed later while the flag is
    set)
  * before saved.cfg is executed, the flag is set and stays set all
    throughout the game - which means, that all changes (from menus, for
    example) will change the altered alias to "persistent"
  * exceptions for map or model config files are unnecessary, since those
    run restricted and can't create aliases anyway
  * exceptions are necessary for "late run" config files like those in
    config/opt/

The new command "persistidents" may be used to manually set or clear the
flag. It also returns the current state of the flag. If used in a config
file, the flag is restored to its original value when the file ends
execution.

In short: only late-run config files (meaning: run after saved.cfg was
restored) may need to manually set/reset the flag. Use const and tempalias
where appropriate and clear persistidents before creating an alias with a
not-to-save default value that may be changed and made persistent later.

DOCREF persistidents
This commit is contained in:
ac-stef
2017-05-05 15:50:59 +02:00
parent fc82b82b85
commit b650fca2ca
25 changed files with 26 additions and 88 deletions
+4 -4
View File
@@ -1002,6 +1002,7 @@ int main(int argc, char **argv)
entropy_init(time(NULL) + (uint)(size_t)&serverport + (uint)(size_t)entropy_init);
pushscontext(IEXC_CFG);
persistidents = false;
#define initlog(s) clientlogf("init: " s)
@@ -1143,7 +1144,6 @@ 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");
per_idents = false;
autostartscripts("_veryfirst_");
// Main font file, all other font files execute from here.
if(!execfile("config/font.cfg")) fatal("cannot find default font definitions");
@@ -1190,7 +1190,7 @@ int main(int argc, char **argv)
setupautodownload();
int xmn = loadallxmaps();
if(xmn) conoutf("loaded %d xmaps", xmn);
per_idents = true;
persistidents = 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");
@@ -1227,9 +1227,9 @@ int main(int argc, char **argv)
preload_entmodels();
initlog("docs");
per_idents = false;
persistidents = false;
execfile("config/docs.cfg");
per_idents = true;
persistidents = true;
initlog("localconnect");
extern string clientmap;