]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/cvar.qh
Split up common/util.qc
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / cvar.qh
index 81aaffe1380eb20b0c72c20513e21a06846f6456..d79ae11544d5467ccbc93e9d7e3bdbb954cd0b19 100644 (file)
@@ -5,7 +5,18 @@
 #include "progname.qh"
 #include "static.qh"
 
-void RegisterCvars(void(string name, string def, string desc, bool archive, string file)f) {}
+void RegisterCvars(void(string name, string def, string desc, bool archive, string file) f) {}
+
+bool cvar_value_issafe(string s)
+{
+       if (strstrofs(s, "\"", 0) >= 0) return false;
+       if (strstrofs(s, "\\", 0) >= 0) return false;
+       if (strstrofs(s, ";", 0) >= 0) return false;
+       if (strstrofs(s, "$", 0) >= 0) return false;
+       if (strstrofs(s, "\r", 0) >= 0) return false;
+       if (strstrofs(s, "\n", 0) >= 0) return false;
+       return true;
+}
 
 /** escape the string to make it safe for consoles */
 string MakeConsoleSafe(string input)
@@ -64,7 +75,7 @@ const noref vector default_vector = '0 0 0';
 #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) \
+       [[accumulate]] void RegisterCvars(void(string, string, string, bool, string) f) \
        { \
                f( #var, repr_cvar_##type(default), desc, archive, file); \
        } \