introduce temporary aliases

An alias, that was at least once used with the new "tempalias" will not be
written to saved.cfg.

So, now there are four ways to create aliases:

1) alias (or "=")
  General alias, who's value gets saved at game exit in saved.cfg, and
  restored at the next restart - unless the alias was created at a time,
  where persistidents was zero (usually during execution of the game's own
  config files during startup).

2) const
  Creates an alias, that can not be changed. Makes it harder for users
  to destroy their config.

3) push
  Reassigns an alias with a new value. After "pop", the old value is
  restored. Allows the use of "local" aliases in scripts. Also avoids
  name conflicts.

4) tempalias
  Like "alias", but the value will not be written to saved.cfg.

The commit also changes aliases, written by the engine itself, to "temp":
gametimestart, __getmaprevisions

DOCREF tempalias
This commit is contained in:
ac-stef
2015-03-06 14:17:08 +01:00
parent 32db3e5e88
commit 0f8dbf69aa
7 changed files with 30 additions and 24 deletions
+14 -13
View File
@@ -11,7 +11,6 @@ struct ident
{
int type; // one of ID_* above
const char *name;
bool isconst;
union
{
int minval; // ID_VAR
@@ -42,39 +41,41 @@ struct ident
int defaultval; // ID_VAR
float defaultvalf; // ID_FVAR
};
short context;
bool persist;
short context; // one of IEXC_* below
bool persist; // if true, value gets written to saved.cfg on exit; set to true, if it's an ID_ALIAS and the value gets changed
bool isconst; // ID_ALIAS: value may not be overwritten
bool istemp; // ID_ALIAS: if value is changed, "persist" will not be set true
ident() {}
// ID_VAR
ident(int type, const char *name, int minval, int maxval, int *i, int defval, void (*fun)(), bool persist, int context)
: type(type), name(name), isconst(false), minval(minval), maxval(maxval), fun(fun),
sig(NULL), action(NULL), defaultval(defval), context(context), persist(persist)
: type(type), name(name), minval(minval), maxval(maxval), fun(fun),
sig(NULL), action(NULL), defaultval(defval), context(context), persist(persist), isconst(false), istemp(false)
{ storage.i = i; }
// ID_FVAR
ident(int type, const char *name, float minval, float maxval, float *f, float defval, void (*fun)(), bool persist, int context)
: type(type), name(name), isconst(false), minvalf(minval), maxvalf(maxval), fun(fun),
sig(NULL), action(NULL), defaultvalf(defval), context(context), persist(persist)
: type(type), name(name), minvalf(minval), maxvalf(maxval), fun(fun),
sig(NULL), action(NULL), defaultvalf(defval), context(context), persist(persist), isconst(false), istemp(false)
{ storage.f = f; }
// ID_SVAR
ident(int type, const char *name, char **s, void (*fun)(), void (*getfun)(), bool persist, int context)
: type(type), name(name), isconst(false), minval(0), maxval(0), fun(fun),
sig(NULL), action(NULL), getfun(getfun), context(context), persist(persist)
: type(type), name(name), minval(0), maxval(0), fun(fun),
sig(NULL), action(NULL), getfun(getfun), context(context), persist(persist), isconst(false), istemp(false)
{ storage.s = s; }
// ID_ALIAS
ident(int type, const char *name, char *action, bool persist, int context)
: type(type), name(name), isconst(false), minval(0), maxval(0), stack(0),
sig(NULL), action(action), executing(NULL), context(context), persist(persist)
: type(type), name(name), minval(0), maxval(0), stack(0),
sig(NULL), action(action), executing(NULL), context(context), persist(persist), isconst(false), istemp(false)
{ storage.i = NULL; }
// ID_COMMAND
ident(int type, const char *name, void (*fun)(), const char *sig, int context)
: type(type), name(name), isconst(false), minval(0), maxval(0), fun(fun),
sig(sig), action(NULL), executing(NULL), context(context), persist(false)
: type(type), name(name), minval(0), maxval(0), fun(fun),
sig(sig), action(NULL), executing(NULL), context(context), persist(false), isconst(false), istemp(false)
{ storage.i = NULL; }
};