From: Mario <zacjardine@y7mail.com>
Date: Wed, 15 Apr 2015 23:58:45 +0000 (+1000)
Subject: Add an option to override the default physics set (useful for using cvar based physic... 
X-Git-Tag: xonotic-v0.8.1~48^2~4
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fe7b2b63c1ded887dec452264a5d150a372c0b75;p=xonotic%2Fxonotic-data.pk3dir.git

Add an option to override the default physics set (useful for using cvar based physics sets rather than the regular config scripts)
---

diff --git a/physics.cfg b/physics.cfg
index 0c442ad95..3acf0001b 100644
--- a/physics.cfg
+++ b/physics.cfg
@@ -6,10 +6,11 @@
 // ==============
 //  main options
 // ==============
-seta cl_physics default "client selected physics set"
+seta cl_physics "default" "client selected physics set"
 
 set g_physics_clientselect 0 "allow clients to select their physics set"
 set g_physics_clientselect_options "xonotic nexuiz quake warsow defrag quake3 vecxis quake2"
+set g_physics_clientselect_default "" "override default physics"
 
 // =========
 //  Xonotic
diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh
index 5107bd5a9..4696827b2 100644
--- a/qcsrc/server/autocvars.qh
+++ b/qcsrc/server/autocvars.qh
@@ -836,6 +836,7 @@ float autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath;
 float autocvar_g_physics_clientselect;
 string autocvar_g_physics_clientselect_options;
+string autocvar_g_physics_clientselect_default;
 float autocvar_g_buffs_waypoint_distance;
 float autocvar_g_buffs_randomize;
 float autocvar_g_buffs_random_lifetime;
diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc
index 81c3cfd8b..574d7f54b 100644
--- a/qcsrc/server/cl_physics.qc
+++ b/qcsrc/server/cl_physics.qc
@@ -39,22 +39,28 @@
 // client side physics
 float Physics_Valid(string thecvar)
 {
-	if(!autocvar_g_physics_clientselect) { return FALSE; }
+	if(!autocvar_g_physics_clientselect) { return false; }
 
 	string l = strcat(" ", autocvar_g_physics_clientselect_options, " ");
 
 	if(strstrofs(l, strcat(" ", thecvar, " "), 0) >= 0)
-		return TRUE;
+		return true;
 
-	return FALSE;
+	return false;
 }
 
 float Physics_ClientOption(entity pl, string option)
 {
-	if (Physics_Valid(pl.cvar_cl_physics))
+	if(Physics_Valid(pl.cvar_cl_physics))
 	{
 		string var = sprintf("g_physics_%s_%s", pl.cvar_cl_physics, option);
-		if (cvar_type(var) & 1)
+		if(cvar_type(var) & 1)
+			return cvar(var);
+	}
+	if(autocvar_g_physics_clientselect && autocvar_g_physics_clientselect_default)
+	{
+		string var = sprintf("g_physics_%s_%s", autocvar_g_physics_clientselect_default, option);
+		if(cvar_type(var) & 1)
 			return cvar(var);
 	}
 	return cvar(strcat("sv_", option));