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:
@@ -1,5 +1,3 @@
|
||||
persistidents 0
|
||||
|
||||
const kick [if $numargs [if (> $numargs 1) [loop i (- $numargs 2) [alias arg2 (concat $arg2 (getalias (concatword arg (+ $i 3)))) ] ] [] ; callvote 0 $arg1 $arg2 ] ]
|
||||
const ban [if $numargs [if (> $numargs 1) [loop i (- $numargs 2) [alias arg2 (concat $arg2 (getalias (concatword arg (+ $i 3)))) ] ] [] ; callvote 1 $arg1 $arg2 ] ]
|
||||
const removebans [ callvote 2 $arg1 ]
|
||||
@@ -25,4 +23,3 @@ const demo [
|
||||
]
|
||||
]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
// arg1: mapname, arg2: gamemode number, arg3: ping, arg4: minutesremaining, arg5: number of players, arg6: maxclients, arg7: IP, arg8: port, arg9: pongflags
|
||||
// pongflags is bit-coded: bit 0: passworded, bit 1: banned, bit 2: blacklisted, bit 6: mastermode
|
||||
|
||||
persistidents 0
|
||||
|
||||
offmap = [ (+ 1 (findlist $defaultmaps $arg1)) ]
|
||||
|
||||
|
||||
@@ -107,4 +105,3 @@ sbfavourite_SEARCH_alpha = 0
|
||||
sbfavourite_SEARCH_weight = 1
|
||||
sbfavourite_SEARCH_ignore = 1
|
||||
|
||||
persistidents 1
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
// To add your own fonts, create a seperate font file and execute like this:
|
||||
persistidents 0
|
||||
|
||||
exec config/font_default.cfg // Must be executed! DO NOT MODIFY.
|
||||
exec config/font_monospace.cfg // Must be executed! DO NOT MODIFY.
|
||||
@@ -75,4 +74,4 @@ fontchar 0 192 64 64 //M red circle
|
||||
fontchar 64 192 64 64 //N blue circle
|
||||
fontchar 128 192 64 64 //O green circle
|
||||
|
||||
persistidents 1
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
persistidents 0
|
||||
|
||||
// standard menu definitions
|
||||
|
||||
newmenu main
|
||||
@@ -137,4 +135,3 @@ exec config/menus_multiplayer.cfg
|
||||
exec config/menus_voicecom.cfg
|
||||
exec config/favourites.cfg
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// bot menus and tools
|
||||
|
||||
persistidents 0
|
||||
|
||||
newmenu botmaps
|
||||
|
||||
const genbotmaps [
|
||||
@@ -177,4 +175,3 @@ menuinit [ delallwps = 0 ] // Ensures this menu works correctly.
|
||||
menuitemcheckbox "Yes, delete all waypoints: " [delallwps = 1] [delallwps = $arg1]
|
||||
menuitem "\f2\t\t Apply!" [ if $delallwps wpclear [ showmenu [] ] ]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
persistidents 0
|
||||
|
||||
newmenu editing
|
||||
|
||||
menuinit [ if (! $editing) [menuheader "" "\f3You are not in edit mode"] [menuheader] ]
|
||||
@@ -1188,5 +1186,3 @@ menuinit [
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
persistidents 0
|
||||
|
||||
// Decides whether to open the admin or normal in-game menu.
|
||||
const ingamemenu [ if (player1 role) [ showmenu [In-game admin] ] [ showmenu In-game ] ]
|
||||
|
||||
@@ -257,4 +255,3 @@ menuitem "\f2 [ Download the servers map version and join the game ]" [ g
|
||||
menuitem "\f3 [ Keep the local map version and disconnect from the server ]" [ showmenu ""; disconnect ]
|
||||
menuinitselection 4
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
persistidents 0
|
||||
|
||||
newmenu settings
|
||||
|
||||
menuitem [Video settings] [ showmenu video ]
|
||||
@@ -580,7 +578,7 @@ menuitemslider [ Radar zoom: ] 5 500 [
|
||||
menuitemslider [ Votes: ] 0 2 "$hidevote" 1 ["Always show" "Show until you vote" "Never show"] [ hidevote $arg1 ]
|
||||
menuitemslider [ Graphics statistics: ] 0 2 "$showstats" 1 [None "FPS Only" All] [ showstats $arg1 ]
|
||||
menuitemslider [ Game time: ] 0 2 "$gametimedisplay" 1 [None "Count backward" "Count forward"] [ gametimedisplay $arg1 ]
|
||||
menuitemslider [ Wall clock: ] 0 6 [findlist $wallclockformatlist $wallclockformat] 1 [None "HH:MM (local, 24h)" "HH:MM:SS (local, 24h)" "HH:MM (local, 12h)" "HH:MM:SS (local, 12h)" "HH:MM (UTC/GMT)" "HH:MM:SS (UTC/GMT)"] [ persistidents 1; alias wallclockformat (at $wallclockformatlist $arg1); persistidents 0 ]
|
||||
menuitemslider [ Wall clock: ] 0 6 [findlist $wallclockformatlist $wallclockformat] 1 [None "HH:MM (local, 24h)" "HH:MM:SS (local, 24h)" "HH:MM (local, 12h)" "HH:MM:SS (local, 12h)" "HH:MM (UTC/GMT)" "HH:MM:SS (UTC/GMT)"] [ alias wallclockformat (at $wallclockformatlist $arg1)]
|
||||
menuitemslider [ Extra messages: ] 0 3 "$hudextras" 1 ["No extra messages" "Show extra messages in console" "Pop up extra messages!" "SPAM EXTRA MESSAGES!"] [ hudextras $arg1 ]
|
||||
menuitemslider [ Hand alignment: ] 0 1 "$righthanded" 1 [Left-handed Right-handed] [ righthanded $arg1 ]
|
||||
menuitemslider [ Max-roll: ] 0 (getvarrange max maxroll) "$maxroll" 1 [] [ maxroll $arg1 ]
|
||||
@@ -916,5 +914,3 @@ const checkaccount [
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
persistidents 0
|
||||
|
||||
newmenu voicecom 1 1
|
||||
|
||||
menuitem [1. Team Replies] [ showmenu [Team Replies] ]
|
||||
@@ -66,5 +64,3 @@ newmenu [Public Talk] 1 1
|
||||
genvcitem [Nice shot] niceshot 1
|
||||
genvcitem [Thanks! "Thanks, man"] [thanks_1 thanks_2] 2
|
||||
genvcitem [Awesome Awesome!] [awesome_1 awesome_2] 3
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// old autosave system (superseded by autosaved xmaps)
|
||||
// (write "load_autosave" into your autoexec.cfg to load)
|
||||
|
||||
persistidents 0
|
||||
persistidents 0 // don't save default values
|
||||
|
||||
checkinit mapstartalways [numAutoSaves = 0; autoSaveCheck]
|
||||
checkinit onNewMap [numAutoSaves = 0; autoSaveCheck]
|
||||
@@ -39,5 +39,3 @@ newmenu [Editing settings]
|
||||
menuitemcheckbox "Enable auto save map: " "$autosavemap" [ autosavemap = $arg1 ]
|
||||
menuitemslider "Time between auto saves (in minutes): " 2 60 "(div $timeBetAutoSaves 60000)" 1 [] [ timeBetAutoSaves = (* $arg1 60000) ]
|
||||
menuitemtextinput "Make a map backup (.BAK) every: " "$numAutoSaveBackups" [ numAutoSaveBackups = $arg1 ] [ if (! $showedBAKinfo) [ echo This setting effects the number of autosavemaps between making a map backup file. "(.BAK)"; showedBAKinfo = 1 ] ] 4
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Makes very old cubescripts compatible with newer versions of the game
|
||||
// (write "load_compatibility" into your autoexec.cfg to load)
|
||||
|
||||
persistidents 0
|
||||
|
||||
const alive [ if (&& $numargs (isclient $arg1)) [ result (player $arg1 alive) ] [ result (player1 alive) ] ]
|
||||
const currole [ if (&& $numargs (isclient $arg1)) [ result (player $arg1 role) ] [ result (player1 role) ] ]
|
||||
const curmode [ result $gamemode ]
|
||||
@@ -39,4 +37,3 @@ const orderscorecolumns [
|
||||
]
|
||||
]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// assisted AC map conversion
|
||||
|
||||
// - keeps a list of "maps to process" stored as aliases in saved.cfg
|
||||
// - each run of the script adds the maps listed in "convmaplist", if they are not already on the listallmapmodelattributes
|
||||
// - script can be run multiple times19
|
||||
// - each run of the script adds the maps listed in "convmaplist", if they are not already on the list
|
||||
// - script can be run multiple times
|
||||
// - amends the main menu (temporarily) with an entry to the batch conversion menu
|
||||
// - to add many maps, add something like convmaplist = [ac_2fort ac_abandoned ac_abyss ac_accomply ac_adventure3 ac_africa] to your autoexec
|
||||
// - this toolset converts maps to map format 10 and helps to fix a lot of errors on maps
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
// * The difficulty is "increased" over time, by spawning more and increasing the skill level of bots at "checkpoints".
|
||||
// * If the player dies, or leaves the "zone" for too long of a duration, the game ends.
|
||||
// * Total seconds survived, total number of enemies killed during, average amount of time between kills, and total damage dealt while alive are reported as stats when the game ends.
|
||||
persistidents 0
|
||||
|
||||
persistidents 0 // don't save default values
|
||||
|
||||
// set defaults - may be overwritten by saved.cfg
|
||||
looplist [
|
||||
@@ -293,5 +294,3 @@ const endSurvival [
|
||||
tdm (rndmap)
|
||||
]
|
||||
]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// arch of 2xN cubes, i.e. 3 vertices [0..2]
|
||||
// archvertex <cubespan> <vertex> <delta>
|
||||
// vertices not defined have a 0 delta
|
||||
persistidents 0
|
||||
|
||||
const av [
|
||||
push vn (+ $arg1 1)
|
||||
@@ -45,5 +44,3 @@ const av_measure [
|
||||
loop i (listlen $ii) [ if $i [ res = (concat $res (- (at $ii $i) $offs)) ] ]
|
||||
result (pop res offs ii)
|
||||
]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
// Do not modify.
|
||||
|
||||
persistidents 0
|
||||
|
||||
alias key_console_end [ conskip -1000 ]
|
||||
alias key_console_forward [ conskip -5 ]
|
||||
alias key_console_rewind [ conskip 5 ]
|
||||
@@ -274,4 +272,3 @@ _defaultbinds 0
|
||||
|
||||
omitunchangeddefaults 1 // switch to a clean saved.cfg when keybinds are reset
|
||||
|
||||
persistidents 1
|
||||
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
// define script security contexts to restrict commands to certain contexts
|
||||
// do NOT modify
|
||||
|
||||
persistidents 0
|
||||
|
||||
// supported contexts
|
||||
const context_core 0 // hardcoded scripts
|
||||
const context_cfg 1 // known scripts
|
||||
@@ -25,4 +23,4 @@ isolatecontext $context_mdlcfg
|
||||
// secure this configuration for the rest of the game
|
||||
sealcontexts
|
||||
|
||||
persistidents 1
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
// CubeScript placed in this file is automatically executed on each startup.
|
||||
|
||||
persistidents 0
|
||||
|
||||
const MODES [tdm coop dm surv tsurv ctf pf btdm bdm lss osok tosok bosok htf tktf ktf tpf tlss bpf blss btsurv btosok]
|
||||
const MODEALIASES [map lms vip sendmap]
|
||||
|
||||
@@ -573,5 +571,3 @@ tempalias load_parsestring [ run opt/parsestring ; alias load_parsestring [] ]
|
||||
tempalias load_faq [ run opt/faq ; alias load_faq [] ]
|
||||
tempalias load_convmap [ saycommand "/run opt/convmap " ]
|
||||
tempalias load_mapeditscripts [ run opt/mapeditscripts ]
|
||||
|
||||
persistidents 1
|
||||
|
||||
@@ -18,11 +18,12 @@ int loop_level = 0; // avoid bad calls of b
|
||||
|
||||
hashtable<const char *, ident> *idents = NULL; // contains ALL vars/commands/aliases
|
||||
|
||||
VAR(persistidents, 0, 1, 1);
|
||||
bool persistidents = false;
|
||||
|
||||
bool per_idents = true, neverpersist = false;
|
||||
COMMANDF(per_idents, "i", (int *on) {
|
||||
per_idents = neverpersist ? false : (*on != 0);
|
||||
COMMANDF(persistidents, "s", (char *on)
|
||||
{
|
||||
if(on && *on) persistidents = ATOI(on) != 0;
|
||||
intret(persistidents ? 1 : 0);
|
||||
});
|
||||
|
||||
void clearstack(ident &id)
|
||||
@@ -66,7 +67,7 @@ ident *newident(const char *name, int context = execcontext)
|
||||
ident *id = idents->access(name);
|
||||
if(!id)
|
||||
{
|
||||
ident init(ID_ALIAS, newstring(name), newstring(""), per_idents, context);
|
||||
ident init(ID_ALIAS, newstring(name), newstring(""), persistidents, context);
|
||||
id = &idents->access(init.name, init);
|
||||
}
|
||||
return id;
|
||||
@@ -1047,6 +1048,7 @@ bool execfile(const char *cfgfile)
|
||||
string s;
|
||||
copystring(s, cfgfile);
|
||||
setcontext("file", cfgfile);
|
||||
bool oldpersist = persistidents;
|
||||
char *buf = loadfile(path(s), NULL);
|
||||
if(!buf)
|
||||
{
|
||||
@@ -1056,6 +1058,7 @@ bool execfile(const char *cfgfile)
|
||||
execute(buf);
|
||||
delete[] buf;
|
||||
resetcontext();
|
||||
persistidents = oldpersist;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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;
|
||||
|
||||
+1
-4
@@ -259,16 +259,13 @@ struct md2 : vertmodel
|
||||
loopv(mdl.meshes) mdl.meshes[i]->skin = skin;
|
||||
if(skin==notexture) { conoutf("could not load model skin for %s", name1); flagmapconfigerror(LWW_MODELERR); }
|
||||
loadingmd2 = this;
|
||||
ASSERT(execcontext == IEXC_MDLCFG);
|
||||
defformatstring(name2)("packages/models/%s/md2.cfg", loadname);
|
||||
per_idents = false;
|
||||
neverpersist = true;
|
||||
if(!execfile(name2))
|
||||
{
|
||||
formatstring(name2)("packages/models/%s/md2.cfg", pname);
|
||||
execfile(name2);
|
||||
}
|
||||
neverpersist = false;
|
||||
per_idents = true;
|
||||
loadingmd2 = 0;
|
||||
loopv(parts) parts[i]->scaleverts(scale/16.0f, vec(translate.x, -translate.y, translate.z));
|
||||
radius = calcradius(zradius);
|
||||
|
||||
+1
-5
@@ -218,19 +218,15 @@ struct md3 : vertmodel
|
||||
defformatstring(cfgname)("packages/models/%s/md3.cfg", loadname);
|
||||
|
||||
loadingmd3 = this;
|
||||
per_idents = false;
|
||||
neverpersist = true;
|
||||
ASSERT(execcontext == IEXC_MDLCFG);
|
||||
if(execfile(cfgname) && parts.length()) // configured md3, will call the md3* commands below
|
||||
{
|
||||
neverpersist = false;
|
||||
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
|
||||
{
|
||||
per_idents = false;
|
||||
loadingmd3 = NULL;
|
||||
md3part &mdl = *new md3part;
|
||||
parts.add(&mdl);
|
||||
|
||||
+1
-1
@@ -985,7 +985,7 @@ extern bool checkchallenge(const char *answerstr, void *correct);
|
||||
extern void conoutf(const char *s, ...) PRINTFARGS(1, 2);
|
||||
|
||||
// command
|
||||
extern bool per_idents, neverpersist;
|
||||
extern bool persistidents;
|
||||
extern char *exchangestr(char *o, const char *n);
|
||||
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);
|
||||
|
||||
@@ -787,8 +787,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 = per_idents;
|
||||
per_idents = false; // only keep changed values
|
||||
bool oldpersist = persistidents;
|
||||
persistidents = false; // only keep changed values
|
||||
loopi(FC_NUM) alx[i] = getalias(favcatargname(text, i)) ? 1 : 0;
|
||||
loopi(3)
|
||||
{
|
||||
@@ -799,7 +799,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]); }
|
||||
per_idents = oldpersist;
|
||||
persistidents = oldpersist;
|
||||
intret(favcats.length());
|
||||
}
|
||||
|
||||
|
||||
@@ -728,11 +728,7 @@ bool empty_world(int factor, bool force) // main empty world creation routine
|
||||
if(clearmap)
|
||||
{
|
||||
pushscontext(IEXC_MAPCFG);
|
||||
per_idents = false;
|
||||
neverpersist = true;
|
||||
execfile("config/default_map_settings.cfg");
|
||||
neverpersist = false;
|
||||
per_idents = true;
|
||||
popscontext();
|
||||
setvar("fullbright", 1);
|
||||
fullbrightlight();
|
||||
|
||||
@@ -983,8 +983,6 @@ int load_world(char *mname) // still supports all map formats that have e
|
||||
conoutf("%s", hdr.maptitle);
|
||||
mapconfigerror = 0;
|
||||
pushscontext(IEXC_MAPCFG); // untrusted altogether
|
||||
per_idents = false;
|
||||
neverpersist = true;
|
||||
if(hdr.flags & MHF_AUTOMAPCONFIG)
|
||||
{ // full featured embedded config: no need to read any other map config files
|
||||
copystring(lastloadedconfigfile, "");
|
||||
@@ -996,8 +994,6 @@ int load_world(char *mname) // still supports all map formats that have e
|
||||
copystring(lastloadedconfigfile, mcfname);
|
||||
}
|
||||
parseheaderextra();
|
||||
neverpersist = false;
|
||||
per_idents = true;
|
||||
popscontext();
|
||||
|
||||
c2skeepalive();
|
||||
@@ -1183,8 +1179,6 @@ struct xmap
|
||||
calclight(); // includes full remip()
|
||||
loopv(headerextras) ::headerextras.add(headerextras[i]->duplicate());
|
||||
pushscontext(IEXC_MAPCFG); // untrusted altogether
|
||||
per_idents = false;
|
||||
neverpersist = true;
|
||||
if(mapconfig.length()) execute(mapconfig.getbuf());
|
||||
else
|
||||
{
|
||||
@@ -1192,8 +1186,6 @@ struct xmap
|
||||
execfile(lastloadedconfigfile);
|
||||
}
|
||||
parseheaderextra(true, mapconfig.length() ? (1<<HX_CONFIG) : 0); // don't execute headerextra config, if we already executed an autostored config
|
||||
neverpersist = false;
|
||||
per_idents = true;
|
||||
popscontext();
|
||||
loadskymap(true);
|
||||
startmap(name, false, true); // "start" but don't respawn: basically just set clientmap
|
||||
|
||||
Reference in New Issue
Block a user