From: Mario Date: Mon, 20 Apr 2015 07:31:37 +0000 (+1000) Subject: Turn the global hitbox/view offset cvars into stats (sv_ cvars shouldn't be used... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=11017e881a4cd3277db10735d647ad510f3505e1;p=xonotic%2Fxonotic-data.pk3dir.git Turn the global hitbox/view offset cvars into stats (sv_ cvars shouldn't be used for anything client side) --- diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 6553d4cb4..9c6c13d2d 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -328,6 +328,8 @@ vector autocvar_sv_player_crouch_mins = '-16 -16 -24'; vector autocvar_sv_player_crouch_viewoffset = '0 0 20'; vector autocvar_sv_player_headsize = '24 24 12'; + +#ifdef SVQC #define PL_VIEW_OFS autocvar_sv_player_viewoffset #define PL_MIN autocvar_sv_player_mins #define PL_MAX autocvar_sv_player_maxs @@ -335,16 +337,14 @@ vector autocvar_sv_player_headsize = '24 24 12'; #define PL_CROUCH_MIN autocvar_sv_player_crouch_mins #define PL_CROUCH_MAX autocvar_sv_player_crouch_maxs #define PL_HEAD autocvar_sv_player_headsize - -// helpers -#define PL_VIEW_OFS_z autocvar_sv_player_viewoffset.z -#define PL_MIN_z autocvar_sv_player_mins.z -#define PL_MAX_z autocvar_sv_player_maxs.z -#define PL_CROUCH_VIEW_OFS_z autocvar_sv_player_crouch_viewoffset.z -#define PL_CROUCH_MIN_z autocvar_sv_player_mins.z -#define PL_HEAD_x autocvar_sv_player_headsize.x -#define PL_HEAD_y autocvar_sv_player_headsize.y -#define PL_HEAD_z autocvar_sv_player_headsize.z +#elif defined(CSQC) +#define PL_VIEW_OFS vec3(getstatf(STAT_PL_VIEW_OFS1), getstatf(STAT_PL_VIEW_OFS2), getstatf(STAT_PL_VIEW_OFS3)) +#define PL_MIN vec3(getstatf(STAT_PL_MIN1), getstatf(STAT_PL_MIN2), getstatf(STAT_PL_MIN3)) +#define PL_MAX vec3(getstatf(STAT_PL_MAX1), getstatf(STAT_PL_MAX2), getstatf(STAT_PL_MAX3)) +#define PL_CROUCH_VIEW_OFS vec3(getstatf(STAT_PL_CROUCH_VIEW_OFS1), getstatf(STAT_PL_CROUCH_VIEW_OFS2), getstatf(STAT_PL_CROUCH_VIEW_OFS3)) +#define PL_CROUCH_MIN vec3(getstatf(STAT_PL_CROUCH_MIN1), getstatf(STAT_PL_CROUCH_MIN2), getstatf(STAT_PL_CROUCH_MIN3)) +#define PL_CROUCH_MAX vec3(getstatf(STAT_PL_CROUCH_MAX1), getstatf(STAT_PL_CROUCH_MAX2), getstatf(STAT_PL_CROUCH_MAX3)) +#endif // spawnpoint prios const int SPAWN_PRIO_NEAR_TEAMMATE_FOUND = 200; diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index 18126aaa9..442a9939b 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -27,6 +27,28 @@ float Physics_ClientOption(entity pl, string option) void Physics_AddStats() { + // static view offset and hitbox vectors + // networked for all you bandwidth pigs out there + addstat(STAT_PL_VIEW_OFS1, AS_FLOAT, stat_pl_view_ofs_x); + addstat(STAT_PL_VIEW_OFS2, AS_FLOAT, stat_pl_view_ofs_y); + addstat(STAT_PL_VIEW_OFS3, AS_FLOAT, stat_pl_view_ofs_z); + addstat(STAT_PL_CROUCH_VIEW_OFS1, AS_FLOAT, stat_pl_crouch_view_ofs_x); + addstat(STAT_PL_CROUCH_VIEW_OFS2, AS_FLOAT, stat_pl_crouch_view_ofs_y); + addstat(STAT_PL_CROUCH_VIEW_OFS3, AS_FLOAT, stat_pl_crouch_view_ofs_z); + + addstat(STAT_PL_MIN1, AS_FLOAT, stat_pl_min_x); + addstat(STAT_PL_MIN2, AS_FLOAT, stat_pl_min_y); + addstat(STAT_PL_MIN3, AS_FLOAT, stat_pl_min_z); + addstat(STAT_PL_MAX1, AS_FLOAT, stat_pl_max_x); + addstat(STAT_PL_MAX2, AS_FLOAT, stat_pl_max_y); + addstat(STAT_PL_MAX3, AS_FLOAT, stat_pl_max_z); + addstat(STAT_PL_CROUCH_MIN1, AS_FLOAT, stat_pl_crouch_min_x); + addstat(STAT_PL_CROUCH_MIN2, AS_FLOAT, stat_pl_crouch_min_y); + addstat(STAT_PL_CROUCH_MIN3, AS_FLOAT, stat_pl_crouch_min_z); + addstat(STAT_PL_CROUCH_MAX1, AS_FLOAT, stat_pl_crouch_max_x); + addstat(STAT_PL_CROUCH_MAX2, AS_FLOAT, stat_pl_crouch_max_y); + addstat(STAT_PL_CROUCH_MAX3, AS_FLOAT, stat_pl_crouch_max_z); + // g_movementspeed hack addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw); addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed); @@ -85,6 +107,16 @@ void Physics_AddStats() void Physics_UpdateStats(float maxspd_mod) { + // blah + self.stat_pl_view_ofs = PL_VIEW_OFS; + self.stat_pl_crouch_view_ofs = PL_CROUCH_VIEW_OFS; + + self.stat_pl_min = PL_MIN; + self.stat_pl_max = PL_MAX; + self.stat_pl_crouch_min = PL_CROUCH_MIN; + self.stat_pl_crouch_max = PL_CROUCH_MAX; + + self.stat_sv_airaccel_qw = AdjustAirAccelQW(Physics_ClientOption(self, "airaccel_qw"), maxspd_mod); if(Physics_ClientOption(self, "airstrafeaccel_qw")) self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(Physics_ClientOption(self, "airstrafeaccel_qw"), maxspd_mod); diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh index 0544d53ae..d8c4d870c 100644 --- a/qcsrc/common/physics.qh +++ b/qcsrc/common/physics.qh @@ -175,6 +175,14 @@ bool IsFlying(entity a); .float discomode; + .vector stat_pl_view_ofs; + .vector stat_pl_crouch_view_ofs; + + .vector stat_pl_min; + .vector stat_pl_max; + .vector stat_pl_crouch_min; + .vector stat_pl_crouch_max; + .float stat_sv_airaccel_qw; .float stat_sv_airstrafeaccel_qw; .float stat_sv_airspeedlimit_nonqw; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index edbe4ecde..f5f987fe3 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -132,24 +132,24 @@ const int STAT_VIP_PINK = 104; /* Gamemode-specific stats end here */ -// 105 empty? -// 106 empty? -// 107 empty? -// 108 empty? -// 109 empty? -// 110 empty? -// 111 empty? -// 112 empty? -// 113 empty? -// 114 empty? -// 115 empty? -// 116 empty? -// 117 empty? -// 118 empty? -// 119 empty? -// 120 empty? -// 121 empty? -// 122 empty? +const int STAT_PL_VIEW_OFS1 = 105; +const int STAT_PL_VIEW_OFS2 = 106; +const int STAT_PL_VIEW_OFS3 = 107; +const int STAT_PL_MIN1 = 108; +const int STAT_PL_MIN2 = 109; +const int STAT_PL_MIN3 = 110; +const int STAT_PL_MAX1 = 111; +const int STAT_PL_MAX2 = 112; +const int STAT_PL_MAX3 = 113; +const int STAT_PL_CROUCH_MIN1 = 114; +const int STAT_PL_CROUCH_MIN2 = 115; +const int STAT_PL_CROUCH_MIN3 = 116; +const int STAT_PL_CROUCH_MAX1 = 117; +const int STAT_PL_CROUCH_MAX2 = 118; +const int STAT_PL_CROUCH_MAX3 = 119; +const int STAT_PL_CROUCH_VIEW_OFS1 = 117; +const int STAT_PL_CROUCH_VIEW_OFS2 = 118; +const int STAT_PL_CROUCH_VIEW_OFS3 = 119; // 123 empty? // 124 empty? // 125 empty? diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 5095e015a..9ba5f4a12 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -263,7 +263,7 @@ void trigger_push_findtarget() // first calculate a typical start point for the jump org = (self.absmin + self.absmax) * 0.5; - org_z = self.absmax.z - PL_MIN_z; + org_z = self.absmax.z - PL_MIN.z; if (self.target) { diff --git a/qcsrc/common/weapons/w_porto.qc b/qcsrc/common/weapons/w_porto.qc index 06a53b346..2bb0cc2d1 100644 --- a/qcsrc/common/weapons/w_porto.qc +++ b/qcsrc/common/weapons/w_porto.qc @@ -125,7 +125,7 @@ void W_Porto_Touch(void) norm = trace_plane_normal; if(trace_ent.iscreature) { - traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_z, MOVE_WORLDONLY, self); + traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN.z, MOVE_WORLDONLY, self); if(trace_fraction >= 1) return; if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP) diff --git a/qcsrc/csqcmodellib/cl_player.qc b/qcsrc/csqcmodellib/cl_player.qc index e3717d275..b659f6f7d 100644 --- a/qcsrc/csqcmodellib/cl_player.qc +++ b/qcsrc/csqcmodellib/cl_player.qc @@ -220,9 +220,9 @@ void CSQCPlayer_SetCamera() self.view_ofs = '0 0 1' * getstati(STAT_VIEWHEIGHT); // get crouch state from the server - if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z) + if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z) self.flags &= ~FL_DUCKED; - else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z) + else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z) self.flags |= FL_DUCKED; // get onground state from the server @@ -258,9 +258,9 @@ void CSQCPlayer_SetCamera() self.velocity = v; // get crouch state from the server - if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z) + if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z) self.flags &= ~FL_DUCKED; - else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z) + else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z) self.flags |= FL_DUCKED; // get onground state from the server @@ -276,9 +276,9 @@ void CSQCPlayer_SetCamera() //#ifdef CSQCMODEL_SERVERSIDE_CROUCH // get crouch state from the server (LAG) if(!autocvar_cl_crouch) - if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z) + if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS.z) self.flags &= ~FL_DUCKED; - else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS_z) + else if(getstati(STAT_VIEWHEIGHT) == PL_CROUCH_VIEW_OFS.z) self.flags |= FL_DUCKED; //#endif diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index d545963cf..1535cf6b6 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1084,4 +1084,5 @@ string autocvar_g_itemeditor_storage_name = "default"; string autocvar_sv_weapons_modeloverride; string autocvar_sv_weapons_sounddir; string autocvar_sv_items_modeloverride; +float autocvar_sv_player_scale; #endif diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index ba1055fac..90c57e814 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -469,7 +469,7 @@ void havocbot_movetogoal() // Flying self.BUTTON_HOOK = true; - if(self.navigation_jetpack_point.z - PL_MAX_z + PL_MIN_z < self.origin.z) + if(self.navigation_jetpack_point.z - PL_MAX.z + PL_MIN.z < self.origin.z) { self.movement_x = dir * v_forward * maxspeed; self.movement_y = dir * v_right * maxspeed; diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index d80f8336c..67353587b 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -387,7 +387,7 @@ entity navigation_findnearestwaypoint_withdist_except(entity ent, float walkfrom } org = ent.origin + 0.5 * (ent.mins + ent.maxs); - org.z = ent.origin.z + ent.mins.z - PL_MIN_z; // player height + org.z = ent.origin.z + ent.mins.z - PL_MIN.z; // player height // TODO possibly make other code have the same support for bboxes if(ent.tag_entity) org = org + ent.tag_entity.origin; @@ -710,7 +710,7 @@ void navigation_routerating(entity e, float f, float rangebias) float zdistance, xydistance, cost, t, fuel; vector down, npa, npb; - down = '0 0 -1' * (PL_MAX_z - PL_MIN_z) * 10; + down = '0 0 -1' * (PL_MAX.z - PL_MIN.z) * 10; do{ npa = pointa + down; diff --git a/qcsrc/server/bot/waypoints.qc b/qcsrc/server/bot/waypoints.qc index 23e7af3f9..4877e98b3 100644 --- a/qcsrc/server/bot/waypoints.qc +++ b/qcsrc/server/bot/waypoints.qc @@ -196,7 +196,7 @@ void waypoint_think() navigation_testtracewalk = 0; if (!self.wpisbox) { - tracebox(sv - PL_MIN_z * '0 0 1', PL_MIN, PL_MAX, sv, false, self); + tracebox(sv - PL_MIN.z * '0 0 1', PL_MIN, PL_MAX, sv, false, self); if (!trace_startsolid) { //dprint("sv deviation", vtos(trace_endpos - sv), "\n"); @@ -205,7 +205,7 @@ void waypoint_think() } if (!e.wpisbox) { - tracebox(ev - PL_MIN_z * '0 0 1', PL_MIN, PL_MAX, ev, false, e); + tracebox(ev - PL_MIN.z * '0 0 1', PL_MIN, PL_MAX, ev, false, e); if (!trace_startsolid) { //dprint("ev deviation", vtos(trace_endpos - ev), "\n"); @@ -719,7 +719,7 @@ float waypoint_loadall() vector waypoint_fixorigin(vector position) { - tracebox(position + '0 0 1' * (1 - PL_MIN_z), PL_MIN, PL_MAX, position + '0 0 -512', MOVE_NOMONSTERS, world); + tracebox(position + '0 0 1' * (1 - PL_MIN.z), PL_MIN, PL_MAX, position + '0 0 -512', MOVE_NOMONSTERS, world); if(trace_fraction < 1) position = trace_endpos; //traceline(position, position + '0 0 -512', MOVE_NOMONSTERS, world); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 6c1cd6b47..2e87836ed 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -688,7 +688,7 @@ void PutClientInServer (void) self.respawn_flags = 0; self.respawn_time = 0; self.stat_respawn_time = 0; - self.scale = 0; + self.scale = autocvar_sv_player_scale; self.fade_time = 0; self.pain_frame = 0; self.pain_finished = 0; diff --git a/qcsrc/server/mutators/gamemode_ctf.qh b/qcsrc/server/mutators/gamemode_ctf.qh index 450e83721..93d976cef 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qh +++ b/qcsrc/server/mutators/gamemode_ctf.qh @@ -27,7 +27,7 @@ const float WPFE_THINKRATE = 0.5; const vector FLAG_DROP_OFFSET = ('0 0 32'); const vector FLAG_CARRY_OFFSET = ('-16 0 8'); -#define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13)) +#define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX.z - 13)) const vector FLAG_WAYPOINT_OFFSET = ('0 0 64'); const vector FLAG_FLOAT_OFFSET = ('0 0 32'); const vector FLAG_PASS_ARC_OFFSET = ('0 0 -10'); diff --git a/qcsrc/server/mutators/gamemode_keyhunt.qh b/qcsrc/server/mutators/gamemode_keyhunt.qh index 33b70a2c8..6c0c684a2 100644 --- a/qcsrc/server/mutators/gamemode_keyhunt.qh +++ b/qcsrc/server/mutators/gamemode_keyhunt.qh @@ -31,7 +31,7 @@ const float KEY_TOUCHRATE = 0.5; const vector KEY_DROP_OFFSET = ('0 0 16'); const vector KEY_CARRY_OFFSET = ('-16 0 8'); -#define KEY_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13)) +#define KEY_SPAWN_OFFSET ('0 0 1' * (PL_MAX.z - 13)) const vector KEY_WAYPOINT_OFFSET = ('0 0 64'); const vector KEY_FLOAT_OFFSET = ('0 0 16'); const vector KEY_PASS_ARC_OFFSET = ('0 0 -10'); diff --git a/qcsrc/server/mutators/gamemode_onslaught.qh b/qcsrc/server/mutators/gamemode_onslaught.qh index 58afe0a8c..2eab141b3 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qh +++ b/qcsrc/server/mutators/gamemode_onslaught.qh @@ -7,7 +7,7 @@ // control point / generator constants #define ONS_CP_THINKRATE 0.2 #define GEN_THINKRATE 1 -#define CPGEN_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13)) +#define CPGEN_SPAWN_OFFSET ('0 0 1' * (PL_MAX.z - 13)) #define CPGEN_WAYPOINT_OFFSET ('0 0 128') #define CPICON_OFFSET ('0 0 96') diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index e6e606f5f..9ce48d8e3 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -315,8 +315,8 @@ void Portal_Touch() return; /* - if(other.mins_x < PL_MIN_x || other.mins_y < PL_MIN_y || other.mins_z < PL_MIN_z - || other.maxs_x > PL_MAX_x || other.maxs_y > PL_MAX_y || other.maxs_z > PL_MAX_z) + if(other.mins_x < PL_MIN.x || other.mins_y < PL_MIN.y || other.mins_z < PL_MIN.z + || other.maxs_x > PL_MAX.x || other.maxs_y > PL_MAX.y || other.maxs_z > PL_MAX.z) { // can't teleport this return;