From 0071121b663dc3d841a2c28d27c1015899f0f402 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 4 Aug 2017 16:48:33 +1000 Subject: [PATCH] Some optimizations to client side items and spawn points --- qcsrc/client/main.qc | 12 ++++++++++- qcsrc/client/view.qc | 1 + qcsrc/common/minigames/sv_minigames.qc | 2 +- qcsrc/common/monsters/monster/mage.qc | 2 +- qcsrc/common/mutators/mutator/overkill/rpc.qc | 2 +- qcsrc/common/t_items.qc | 21 ++++++++++++------- qcsrc/common/triggers/subs.qc | 2 +- qcsrc/common/triggers/trigger/multi.qc | 2 +- qcsrc/common/triggers/trigger/secret.qc | 2 +- qcsrc/common/turrets/turret/walker.qc | 2 +- qcsrc/common/vehicles/sv_vehicles.qc | 2 +- 11 files changed, 34 insertions(+), 16 deletions(-) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index c621e9fab3..2e55584eda 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -657,6 +657,9 @@ NET_HANDLE(ENT_CLIENT_ACCURACY, bool isnew) void Spawn_Draw(entity this) { + if(this.alpha <= 0) + return; + __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1)); } @@ -665,7 +668,14 @@ void Spawn_PreDraw(entity this) float alph; vector org = getpropertyvec(VF_ORIGIN); if(this.fade_start) - alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1); + { + if(vdist(org - this.origin, >, this.fade_end)) + alph = 0; // save on some processing + else if(vdist(org - this.origin, <, this.fade_start)) + alph = 1; // more processing saved + else + alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1); + } else alph = 1; //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs)); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 70de314efd..ece38598ec 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -311,6 +311,7 @@ void viewmodel_draw(entity this) e.csqcmodel_effects = fx; CSQCModel_Effects_Apply(e); } + if(a >= 0) { string name = wep.mdl; string newname = wep.wr_viewmodel(wep, this); diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 4f1cd5dc2d..415417b465 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -28,7 +28,7 @@ void minigame_rmplayer(entity minigame_session, entity player) GameLogEcho(strcat(":minigame:part:",minigame_session.netname,":", ftos(etof(player)),":",player.netname)); minigame_session.minigame_players = p.list_next; - delete ( p ); + delete( p ); player_clear_minigame(player); } else diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index f6f8b803ba..32383af571 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -120,7 +120,7 @@ void M_Mage_Attack_Spike_Explode(entity this, entity directhitentity) Send_Effect(EFFECT_EXPLOSION_SMALL, this.origin, '0 0 0', 1); RadiusDamage (this, this.realowner, (autocvar_g_monster_mage_attack_spike_damage), (autocvar_g_monster_mage_attack_spike_damage) * 0.5, (autocvar_g_monster_mage_attack_spike_radius), NULL, NULL, 0, DEATH_MONSTER_MAGE.m_id, directhitentity); - delete (this); + delete(this); } void M_Mage_Attack_Spike_Touch(entity this, entity toucher) diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index a09a6a637c..e9a5ce2c3f 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -10,7 +10,7 @@ void W_RocketPropelledChainsaw_Explode(entity this, entity directhitentity) RadiusDamage (this, this.realowner, WEP_CVAR(rpc, damage), WEP_CVAR(rpc, edgedamage), WEP_CVAR(rpc, radius), NULL, NULL, WEP_CVAR(rpc, force), this.projectiledeathtype, directhitentity); - delete (this); + delete(this); } void W_RocketPropelledChainsaw_Explode_think(entity this) diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index d85cf78614..1e5f8284cb 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -134,10 +134,17 @@ void Item_PreDraw(entity this) } float alph; vector org = getpropertyvec(VF_ORIGIN); - if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones - alph = 0; - else if(this.fade_start) - alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1); + //if(!checkpvs(org, this)) // this makes sense as long as we don't support recursive warpzones + //alph = 0; // this shouldn't be needed, since items behind walls are culled anyway + if(this.fade_start) + { + if(vdist(org - this.origin, >, this.fade_end)) + alph = 0; // save on some processing + else if(vdist(org - this.origin, <, this.fade_start)) + alph = 1; // more processing saved + else + alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1); + } else alph = 1; //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs)); @@ -868,7 +875,7 @@ LABEL(pickup) _sound (toucher, (this.itemdef.instanceOfPowerup ? CH_TRIGGER_SINGLE : CH_TRIGGER), (this.item_pickupsound ? this.item_pickupsound : Sound_fixpath(this.item_pickupsound_ent)), VOL_BASE, ATTEN_NORM); if (this.classname == "droppedweapon") - delete (this); + delete(this); else if (this.spawnshieldtime) { entity e; @@ -1172,7 +1179,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default if(!have_pickup_item(this)) { startitem_failed = true; - delete (this); + delete(this); return; } @@ -1210,7 +1217,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default // target_give not yet supported; maybe later print("removed targeted ", this.classname, "\n"); startitem_failed = true; - remove (this); + delete(this); return; } */ diff --git a/qcsrc/common/triggers/subs.qc b/qcsrc/common/triggers/subs.qc index 18fab59d1c..5b6182e0ab 100644 --- a/qcsrc/common/triggers/subs.qc +++ b/qcsrc/common/triggers/subs.qc @@ -41,7 +41,7 @@ void SUB_VanishOrRemove (entity ent) else { // remove - delete (ent); + delete(ent); } } diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc index 808d08101b..5e8c641be5 100644 --- a/qcsrc/common/triggers/trigger/multi.qc +++ b/qcsrc/common/triggers/trigger/multi.qc @@ -54,7 +54,7 @@ void multi_trigger(entity this) multi_wait(this); // waiting finished } else - { // we can't just remove (this) here, because this is a touch function + { // we can't just delete(this) here, because this is a touch function // called while C code is looping through area links... settouch(this, func_null); } diff --git a/qcsrc/common/triggers/trigger/secret.qc b/qcsrc/common/triggers/trigger/secret.qc index 1c0a328a13..c3c2c7474e 100644 --- a/qcsrc/common/triggers/trigger/secret.qc +++ b/qcsrc/common/triggers/trigger/secret.qc @@ -34,7 +34,7 @@ void trigger_secret_touch(entity this, entity toucher) // handle normal trigger features multi_touch(this, toucher); - // we can't just remove (this) here, because this is a touch function + // we can't just delete(this) here, because this is a touch function // called while C code is looping through area links... //delete(this); } diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index d8c0a675d5..2f651589d7 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -78,7 +78,7 @@ void walker_setnoanim(entity this) void walker_rocket_explode(entity this) { RadiusDamage (this, this.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), this, NULL, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, NULL); - delete (this); + delete(this); } void walker_rocket_touch(entity this, entity toucher) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 47991b4239..1fbd802104 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -234,7 +234,7 @@ void vehicles_projectile_explode(entity this, entity toucher) this.event_damage = func_null; RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, toucher); - delete (this); + delete(this); } void vehicles_projectile_explode_think(entity this) -- 2.39.2