]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into martin-t/maxshotdist
authorMario <mario@smbclan.net>
Sat, 31 Dec 2016 01:28:57 +0000 (11:28 +1000)
committerMario <mario@smbclan.net>
Sat, 31 Dec 2016 01:28:57 +0000 (11:28 +1000)
21 files changed:
qcsrc/client/view.qc
qcsrc/common/debug.qh
qcsrc/common/mutators/mutator/spawn_near_teammate/sv_spawn_near_teammate.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret/plasma.qc
qcsrc/common/turrets/turret/plasma_dual.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/lib/float.qh [new file with mode: 0644]
qcsrc/server/cheats.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/teamplay.qc
qcsrc/server/weapons/hitplot.qc
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/tracing.qh

index 5f88e78edf4b13bcc8702fc030edb6f22cc1d8ac..2521548e15b0d1e4671c8029953cecfacb00ccae 100644 (file)
@@ -653,7 +653,7 @@ float TrueAimCheck()
                        mv = MOVE_NORMAL;
                        if(zoomscript_caught)
                        {
-                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
+                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * max_shot_distance, mv, ta);
                                return EnemyHitCheck();
                        }
                        break;
@@ -679,7 +679,7 @@ float TrueAimCheck()
 
        vecs = decompressShotOrigin(STAT(SHOTORG));
 
-       traceline(traceorigin, traceorigin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
+       traceline(traceorigin, traceorigin + view_forward * max_shot_distance, mv, ta);
        trueaimpoint = trace_endpos;
 
        if(vdist((trueaimpoint - traceorigin), <, g_trueaim_minrange))
@@ -972,7 +972,7 @@ void HUD_Crosshair(entity this)
                float shottype;
 
                // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
-               wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward);
+               wcross_origin = project_3d_to_2d(view_origin + max_shot_distance * view_forward);
                wcross_origin.z = 0;
                if(autocvar_crosshair_hittest)
                {
index 6d580bd2d69a8b65631a465d0adee730e6bca07d..10a69a70685ebdfdc79c481295410179215fe40d 100644 (file)
@@ -280,7 +280,7 @@ MUTATOR_HOOKFUNCTION(trace, SV_StartFrame)
                vector forward = '0 0 0'; vector right = '0 0 0'; vector up = '0 0 0';
                MAKEVECTORS(makevectors, it.v_angle, forward, right, up);
                vector pos = it.origin + it.view_ofs;
-               traceline(pos, pos + forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, it);
+               traceline(pos, pos + forward * max_shot_distance, MOVE_NORMAL, it);
                FOREACH_ENTITY(true, {
                    it.solid = it.solid_prev;
             it.solid_prev = 0;
index a0017f94df23dd9a10fabc590af2f856ca074a42..ee75728630e2e5623f988e1d7efaf7b31d9f37d7 100644 (file)
@@ -1,6 +1,6 @@
 #include "sv_spawn_near_teammate.qh"
 
-const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
+#include <lib/float.qh>
 
 float autocvar_g_spawn_near_teammate_distance;
 int autocvar_g_spawn_near_teammate_ignore_spawnpoint;
index c90eaff1fe98fdb22bc7918fefedd1f28c703738..83db075b422a7efe3f75dd1bab2a9220102d8060 100644 (file)
@@ -1224,13 +1224,13 @@ void turret_initparams(entity tur)
        tur.shot_force                  = bound(0.001,           (TRY(tur.shot_force)                :  tur.shot_dmg * 0.5 + tur.shot_radius * 0.5 ), 5000);
        tur.shot_volly                  = bound(1,               (TRY(tur.shot_volly)                :  1                                          ), floor(tur.ammo_max / tur.shot_dmg));
        tur.shot_volly_refire           = bound(tur.shot_refire, (TRY(tur.shot_volly_refire)         :  tur.shot_refire * tur.shot_volly           ), 60);
-       tur.target_range                = bound(0,               (TRY(tur.target_range)              :  tur.shot_speed * 0.5                       ), MAX_SHOT_DISTANCE);
-       tur.target_range_min            = bound(0,               (TRY(tur.target_range_min)          :  tur.shot_radius * 2                        ), MAX_SHOT_DISTANCE);
-       tur.target_range_optimal        = bound(0,               (TRY(tur.target_range_optimal)      :  tur.target_range * 0.5                     ), MAX_SHOT_DISTANCE);
+       tur.target_range                = bound(0,               (TRY(tur.target_range)              :  tur.shot_speed * 0.5                       ), max_shot_distance);
+       tur.target_range_min            = bound(0,               (TRY(tur.target_range_min)          :  tur.shot_radius * 2                        ), max_shot_distance);
+       tur.target_range_optimal        = bound(0,               (TRY(tur.target_range_optimal)      :  tur.target_range * 0.5                     ), max_shot_distance);
        tur.aim_maxrotate               = bound(0,               (TRY(tur.aim_maxrotate)             :  90                                         ), 360);
        tur.aim_maxpitch                = bound(0,               (TRY(tur.aim_maxpitch)              :  20                                         ), 90);
        tur.aim_speed                   = bound(0.1,             (TRY(tur.aim_speed)                 :  36                                         ), 1000);
-       tur.aim_firetolerance_dist      = bound(0.1,             (TRY(tur.aim_firetolerance_dist)    :  5 + (tur.shot_radius * 2)                  ), MAX_SHOT_DISTANCE);
+       tur.aim_firetolerance_dist      = bound(0.1,             (TRY(tur.aim_firetolerance_dist)    :  5 + (tur.shot_radius * 2)                  ), max_shot_distance);
        tur.target_select_rangebias     = bound(-10,             (TRY(tur.target_select_rangebias)   :  1                                          ), 10);
        tur.target_select_samebias      = bound(-10,             (TRY(tur.target_select_samebias)    :  1                                          ), 10);
        tur.target_select_anglebias     = bound(-10,             (TRY(tur.target_select_anglebias)   :  1                                          ), 10);
@@ -1270,7 +1270,7 @@ bool turret_initialize(entity this, Turret tur)
        this.netname = tur.netname;
        load_unit_settings(this, 0);
 
-       if(!this.team || !teamplay)             { this.team = MAX_SHOT_DISTANCE; }
+       if(!this.team || !teamplay)             { this.team = FLOAT_MAX; }
        if(!this.ticrate)                               { this.ticrate = ((this.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
        if(!this.health)                                { this.health = 1000; }
        if(!this.shot_refire)                   { this.shot_refire = 1; }
index d161436ab0807041b4bff31e65205cea02a15264..283cf6e514cbf91d91241e2223ebfa69b3013b02 100644 (file)
@@ -10,7 +10,7 @@ METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it))
 {
     if(g_instagib)
     {
-        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * max_shot_distance, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
         Send_Effect(EFFECT_VORTEX_MUZZLEFLASH, it.tur_shotorg, it.tur_shotdir_updated * 1000, 1);
index 9e6d80b2fd830f165117630e685779d19afb82ca..7859d26e343f50127d302578582bac73a6fb1de9 100644 (file)
@@ -9,7 +9,7 @@ spawnfunc(turret_plasma_dual) { if (!turret_initialize(this, TUR_PLASMA_DUAL)) d
 METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it))
 {
     if (g_instagib) {
-        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * MAX_SHOT_DISTANCE, 10000000000,
+        FireRailgunBullet (it, it.tur_shotorg, it.tur_shotorg + it.tur_shotdir_updated * max_shot_distance, 10000000000,
                            800, 0, 0, 0, 0, DEATH_TURRET_PLASMA.m_id);
 
 
index 573e46aa77fa522973d97aca965f0d1388d7b4d4..ad376e809b0d86a3804bce1ab2ba1592211a47c8 100644 (file)
@@ -167,7 +167,7 @@ bool bumblebee_gunner_frame(entity this, float dt)
                VEHICLE_UPDATE_PLAYER(this, vehic, shield, bumblebee);
 
        ad = gettaginfo(gun, gettagindex(gun, "fire"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, gun);
 
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' *(1 - this.vehicle_reload1)), 0);
 
index 7c433f9c76f69dce59cbdba280418880c8210fe1..cd2335665d52210300d32750f28a0338413d46a8 100644 (file)
@@ -351,7 +351,7 @@ bool raptor_frame(entity this, float dt)
        /*
        ad = ad * 0.5;
        v_forward = vf * 0.5;
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
        */
 
index 6ad46946d70927728dd7447d96d8314a907cc5f9..a259e0c1ebe79c8f3249f538a4114aefe801e6ed 100644 (file)
@@ -72,15 +72,15 @@ bool spiderbot_frame(entity this, float dt)
        vf += v_forward;
        ad = ad * 0.5;
        v_forward = vf * 0.5;
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
 #else
        vector ad = gettaginfo(vehic.gun1, gettagindex(vehic.gun1, "barrels"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
        vector vf = ad;
        ad = gettaginfo(vehic.gun2, gettagindex(vehic.gun2, "barrels"));
-       traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, vehic);
+       traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
        UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 1);
        ad = 0.5 * (ad + vf);
 #endif
index 5f7a2c31c8a928cbbc5efec1d99e869a0c01a6fc..1fde99b3fcc48e87014fa84f57e1d1a0d11bd9b2 100644 (file)
@@ -221,11 +221,11 @@ void spiderbot_rocket_do(entity this)
             rocket.pos1           = trace_endpos + randomvec() * (0.75 * autocvar_g_vehicle_spiderbot_rocket_radius);
             rocket.pos1_z         = trace_endpos_z;
 
-            traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, this);
+            traceline(v, v + '0 0 1' * max_shot_distance, MOVE_WORLDONLY, this);
             float h1 = 0.75 * vlen(v - trace_endpos);
 
             //v = trace_endpos;
-            traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, this);
+            traceline(v , rocket.pos1 + '0 0 1' * max_shot_distance, MOVE_WORLDONLY, this);
             float h2 = 0.75 * vlen(rocket.pos1 - v);
 
             rocket.velocity  = spiberbot_calcartillery(v, rocket.pos1, ((h1 < h2) ? h1 : h2));
index b287b148f3175727cebf8fa1e44a288099ae8e2b..6220a0cea9723fc94493d67747f287df67910337 100644 (file)
@@ -175,7 +175,7 @@ ENDCLASS(OffhandWeapon)
 .OffhandWeapon offhand;
 #endif
 
-const int MAX_SHOT_DISTANCE = 32768;
+int max_shot_distance = 32768; // determined by world mins/maxs when map loads
 
 // weapon flags
 const int WEP_TYPE_OTHER          =  0x00; // not for damaging people
index 91042b613b7a425c8fc354a395a2392108a4697e..79892920abd0b144bd4f6c9838579fcf59e8f96e 100644 (file)
@@ -193,7 +193,7 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
+       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, vaporizer_damage, 800, 0, 0, 0, 0, WEP_VAPORIZER.m_id);
 
        // do this now, as goodhits is disabled below
        SendCSQCVaporizerBeamParticle(actor, damage_goodhits);
index bf3ce8185f2f33168e3da300b5722447151d14c3..f7f20d2e8d4933ca5c39d65a4d5a66f7f08fb2a6 100644 (file)
@@ -193,7 +193,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i
 
        yoda = 0;
        damage_goodhits = 0;
-       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
+       FireRailgunBullet(actor, w_shotorg, w_shotorg + w_shotdir * max_shot_distance, mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, WEP_VORTEX.m_id);
 
        if(yoda && flying)
                Send_Notification(NOTIF_ONE, actor, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
diff --git a/qcsrc/lib/float.qh b/qcsrc/lib/float.qh
new file mode 100644 (file)
index 0000000..946319e
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+const float FLOAT_MAX = 340282346638528859811704183484516925440.0f;
index 3d569222cd25d29238562501d6ae78a9633d7058..631f382278becf7486a0b5dd9d47d905d0e7f10d 100644 (file)
@@ -324,7 +324,7 @@ float CheatCommand(entity this, int argc)
                                //   effectname
                                effectnum = _particleeffectnum(argv(1));
                                W_SetupShot(this, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
-                               traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, this);
+                               traceline(w_shotorg, w_shotorg + w_shotdir * max_shot_distance, MOVE_NORMAL, this);
                                __trailparticles(this, effectnum, w_shotorg, trace_endpos);
                                DID_CHEAT();
                                break;
index 39c42a55695f3e585ecf9f440fe89435d382342b..634530244e7534496f5251a5dc66de2449d7f286 100644 (file)
@@ -32,7 +32,7 @@
 
 void crosshair_trace(entity pl)
 {
-       traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * MAX_SHOT_DISTANCE, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
+       traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * max_shot_distance, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
 }
 .bool ctrace_solidchanged;
 void crosshair_trace_plusvisibletriggers(entity pl)
@@ -56,7 +56,7 @@ void crosshair_trace_plusvisibletriggers(entity pl)
 }
 void WarpZone_crosshair_trace(entity pl)
 {
-       WarpZone_traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * MAX_SHOT_DISTANCE, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
+       WarpZone_traceline_antilag(pl, pl.cursor_trace_start, pl.cursor_trace_start + normalize(pl.cursor_trace_endpos - pl.cursor_trace_start) * max_shot_distance, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
 }
 
 
index 39987414348d0d3a37556741a320eb755e3a1cb3..28e91f26a3668181c9a0b83b68c483d0fa5673fa 100644 (file)
@@ -1,5 +1,7 @@
 #include "gamemode_assault.qh"
 
+#include <lib/float.qh>
+
 .entity sprite;
 #define AS_ROUND_DELAY 5
 
@@ -549,7 +551,7 @@ MUTATOR_HOOKFUNCTION(as, TurretSpawn)
 {
        entity turret = M_ARGV(0, entity);
 
-       if(!turret.team || turret.team == MAX_SHOT_DISTANCE)
+       if(!turret.team || turret.team == FLOAT_MAX)
                turret.team = 5; // this gets reversed when match starts?
 }
 
index 0918130159a737e83e63f5bd076af7320e3dc533..fd9f340f5f1965bdbdd370cde24121517abcdfb1 100644 (file)
@@ -52,6 +52,11 @@ void InitGameplayMode()
        get_mi_min_max(1);
        world.mins = mi_min;
        world.maxs = mi_max;
+       // currently, NetRadiant's limit is 131072 qu for each side
+       // distance from one corner of a 131072qu cube to the opposite corner is approx. 227023 qu
+       // set the distance according to map size but don't go over the limit to avoid issues with float precision
+       // in case somebody makes extremely large maps
+       max_shot_distance = min(230000, vlen(world.maxs - world.mins));
 
        MapInfo_LoadMapSettings(mapname);
        serverflags &= ~SERVERFLAG_TEAMPLAY;
index 372f7357b4057a95d63cba482b826d87b23a441d..355b3afbb87da95d777b1d9391b3982f11e8d885 100644 (file)
@@ -66,7 +66,7 @@ void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright,
                        lag = 0; // only antilag for clients
 
                org = player.origin + player.view_ofs;
-               traceline_antilag_force(player, org, org + screenforward * MAX_SHOT_DISTANCE, MOVE_NORMAL, player, lag);
+               traceline_antilag_force(player, org, org + screenforward * max_shot_distance, MOVE_NORMAL, player, lag);
                if(IS_CLIENT(trace_ent) || IS_MONSTER(trace_ent))
                {
                    entity store = IS_CLIENT(trace_ent) ? CS(trace_ent) : trace_ent;
index b49ed88f596ca00a7ef4e6b3467b7e5a3f36c2e2..fd78c9120a7f1ea42e5e8678aed2c64a33be8dc4 100644 (file)
@@ -354,7 +354,7 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s
        vector  end;
 
        dir = normalize(dir + randomvec() * spread);
-       end = start + dir * MAX_SHOT_DISTANCE;
+       end = start + dir * max_shot_distance;
 
        fireBullet_last_hit = NULL;
        float solid_penetration_left = 1;
@@ -399,6 +399,10 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s
                start = trace_endpos;
                entity hit = trace_ent;
 
+               // traced up to max_shot_distance and didn't hit anything at all
+               if (trace_fraction == 1.0)
+                       break;
+
                // When hitting sky, stop.
                if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
                        break;
index 21f12c1e4c02633ef9d16f658b99990a87cf74b9..ed046465bc9890329b2140693e0156f031887120 100644 (file)
@@ -9,7 +9,7 @@ vector w_shotend;
 // make sure you call makevectors first (FIXME?)
 void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range);
 
-#define W_SetupShot_Dir_ProjectileSize(ent,wepent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, MAX_SHOT_DISTANCE)
+#define W_SetupShot_Dir_ProjectileSize(ent,wepent,s_forward,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, wepent, s_forward, mi, ma, antilag, recoil, snd, chan, maxdamage, max_shot_distance)
 #define W_SetupShot_ProjectileSize(ent,wepent,mi,ma,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, wepent, v_forward, mi, ma, antilag, recoil, snd, chan, maxdamage)
 #define W_SetupShot_Dir(ent,wepent,s_forward,antilag,recoil,snd,chan,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, wepent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage)
 #define W_SetupShot(ent,wepent,antilag,recoil,snd,chan,maxdamage) W_SetupShot_ProjectileSize(ent, wepent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage)