]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Hook: fix server cfg
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 5 Oct 2015 11:27:46 +0000 (22:27 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 5 Oct 2015 11:27:46 +0000 (22:27 +1100)
defaultXonotic.cfg
qcsrc/lib/cvar.qh
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/server/mutators/mutator_hook.qc

index 9e7405ed72a87d69efcf873465b469f330c11bb5..c51dfc1a26d29a261d76defc752415d489eecadc 100644 (file)
@@ -469,6 +469,8 @@ seta menu_monsters_edit_movetarget 1
 set g_playerclip_collisions 1 "0 = disable collision testing against playerclips, might be useful on some defrag maps"
 set g_botclip_collisions 1 "0 = disable collision testing against botclips, might be useful on some defrag maps"
 
 set g_playerclip_collisions 1 "0 = disable collision testing against playerclips, might be useful on some defrag maps"
 set g_botclip_collisions 1 "0 = disable collision testing against botclips, might be useful on some defrag maps"
 
+set g_grappling_hook 0 "let players spawn with the grappling hook which allows them to pull themselves up"
+
 set g_spawn_alloweffects 1 "allow clients to enable spawn point and event effects such as particles and sounds, see cl_spawn_ cvars for more info"
 set g_spawn_furthest 0.5 "this amount of the spawns shall be far away from any players"
 set g_spawn_useallspawns 0 "use all spawns, e.g. also team spawns in non-teamplay, and all spawns, even enemy spawns, in teamplay"
 set g_spawn_alloweffects 1 "allow clients to enable spawn point and event effects such as particles and sounds, see cl_spawn_ cvars for more info"
 set g_spawn_furthest 0.5 "this amount of the spawns shall be far away from any players"
 set g_spawn_useallspawns 0 "use all spawns, e.g. also team spawns in non-teamplay, and all spawns, even enemy spawns, in teamplay"
index 1da1f276dfb158bf3327d82af0313207ba71092a..a02ec0f00e56288b312e4312b2d3316e0933e1d8 100644 (file)
@@ -1,22 +1,48 @@
 #ifndef CVAR_H
 #define CVAR_H
 
 #ifndef CVAR_H
 #define CVAR_H
 
+#include "nil.qh"
 #include "static.qh"
 
 #include "static.qh"
 
-void RegisterCvars(void(string name, string desc, bool archive, string file) f) { }
+void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) { }
 
 
-void RegisterCvars_Set(string name, string desc, bool archive, string file)
+void RegisterCvars_Set(string name, string def, string desc, bool archive, string file)
 {
 {
-    localcmd(sprintf("\n%1$s %2$s \"$%2$s\" \"%3$s\"\n", (archive ? "seta" : "set"), name, desc));
+    string val = string_null;
+    if (cvar_type(name) & CVAR_TYPEFLAG_EXISTS) {
+        val = cvar_string(name);
+        // Need to unset first to change the default
+        localcmd(sprintf("\nunset %s\n", name));
+    }
+    localcmd(sprintf("\n%s %s \"%s\" \"%s\"\n", (archive ? "seta" : "set"), name, def, desc));
+    if (val) {
+        localcmd(sprintf("\n%s \"%s\"\n", name, val));
+    }
 }
 
 }
 
+#ifndef SVQC
 STATIC_INIT_LATE(Cvars) { RegisterCvars(RegisterCvars_Set); }
 STATIC_INIT_LATE(Cvars) { RegisterCvars(RegisterCvars_Set); }
+#endif
+
+const noref bool default_bool = false;
+const noref int default_int = 0;
+const noref float default_float = 0;
+const noref string default_string = "";
+const noref vector default_vector = '0 0 0';
+
+#define repr_cvar_bool(x)   ((x) ? "1" : "0")
+#define repr_cvar_int(x)    (ftos(x))
+#define repr_cvar_float(x)  (ftos(x))
+#define repr_cvar_string(x) (x)
+#define repr_cvar_vector(x) (sprintf("%v", x))
 
 
+#define __AUTOCVAR(file, archive, var, type, desc, default) \
+    [[accumulate]] void RegisterCvars(void(string, string, string, bool, string) f) { f(#var, repr_cvar_##type(default), desc, archive, file); } \
+    type autocvar_##var = default
 #define AUTOCVAR_5(file, archive, var, type, desc) \
 #define AUTOCVAR_5(file, archive, var, type, desc) \
-    [[accumulate]] void RegisterCvars(void(string, string, bool, string) f) { f(#var, desc, archive, file); } \
-    type autocvar_##var
+    __AUTOCVAR(file, archive, var, type, desc, default_##type)
 #define AUTOCVAR_6(file, archive, var, type, default, desc) \
 #define AUTOCVAR_6(file, archive, var, type, default, desc) \
-    AUTOCVAR_5(file, archive, var, type, desc) = default
+    __AUTOCVAR(file, archive, var, type, desc, default)
 #define _AUTOCVAR(...) EVAL(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__))
 #define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__)
 #define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__)
 #define _AUTOCVAR(...) EVAL(OVERLOAD(AUTOCVAR, __FILE__, __VA_ARGS__))
 #define AUTOCVAR_SAVE(...) _AUTOCVAR(true, __VA_ARGS__)
 #define AUTOCVAR(...) _AUTOCVAR(false, __VA_ARGS__)
index 0329f1ee7657837c1797a882e0cb11fa09c4e5cb..c751671a46960d8f1ee71311957f345591a2cc08 100644 (file)
@@ -64,6 +64,8 @@ string WeaponArenaString()
        return weaponarenastring;
 }
 
        return weaponarenastring;
 }
 
+AUTOCVAR(g_grappling_hook, bool, _("let players spawn with the grappling hook which allows them to pull themselves up"));
+
 string XonoticMutatorsDialog_toString(entity me)
 {
        string s;
 string XonoticMutatorsDialog_toString(entity me)
 {
        string s;
@@ -88,7 +90,7 @@ string XonoticMutatorsDialog_toString(entity me)
                s = strcat(s, ", ", _("Low gravity"));
        if(cvar("g_cloaked"))
                s = strcat(s, ", ", _("Cloaked"));
                s = strcat(s, ", ", _("Low gravity"));
        if(cvar("g_cloaked"))
                s = strcat(s, ", ", _("Cloaked"));
-       if(cvar("g_grappling_hook"))
+       if(autocvar_g_grappling_hook)
                s = strcat(s, ", ", _("Hook"));
        if(cvar("g_midair"))
                s = strcat(s, ", ", _("Midair"));
                s = strcat(s, ", ", _("Hook"));
        if(cvar("g_midair"))
                s = strcat(s, ", ", _("Midair"));
index 4c162634fcdeb1a1d12ab780c9e89ea5f575a616..bfbe02ea699af95787a68e8a1b5de67e75fdb9ae 100644 (file)
@@ -1,4 +1,5 @@
-AUTOCVAR(g_grappling_hook, bool, _("let players spawn with the grappling hook which allows them to pull themselves up"));
+AUTOCVAR(g_grappling_hook, bool, false, _("let players spawn with the grappling hook which allows them to pull themselves up"));
+#ifdef SVQC
 REGISTER_MUTATOR(hook, autocvar_g_grappling_hook) {
     MUTATOR_ONADD {
         g_grappling_hook = true;
 REGISTER_MUTATOR(hook, autocvar_g_grappling_hook) {
     MUTATOR_ONADD {
         g_grappling_hook = true;
@@ -40,3 +41,4 @@ MUTATOR_HOOKFUNCTION(hook, SetStartItems)
     start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
     warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
 }
     start_ammo_fuel = max(start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
     warmup_start_ammo_fuel = max(warmup_start_ammo_fuel, cvar("g_balance_fuel_rotstable"));
 }
+#endif