From: Mario Date: Fri, 10 Jun 2016 09:45:29 +0000 (+1000) Subject: Cleanse GetPressedKeys X-Git-Tag: xonotic-v0.8.2~858 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a1e294343b57d63849164cbb7e16cfdde86f1c44;p=xonotic%2Fxonotic-data.pk3dir.git Cleanse GetPressedKeys --- diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index ba899548b..fe5bb7afb 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -95,7 +95,6 @@ MUTATOR_HOOKFUNCTION(spiderweb, MonsterSpawn) SOUND(SpiderAttack_FIRE, W_Sound("electro_fire")); METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity weaponentity, int fire)) { - SELFPARAM(); TC(SpiderAttack, thiswep); bool isPlayer = IS_PLAYER(actor); if (fire & 1) @@ -119,7 +118,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, .entity actor.enemy = Monster_FindTarget(actor); actor.attack_range = 60; } - Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? self.anim_melee : self.anim_shoot), self.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true); + Monster_Attack_Melee(actor, actor.enemy, (autocvar_g_monster_spider_attack_bite_damage), ((random() > 0.5) ? actor.anim_melee : actor.anim_shoot), actor.attack_range, (autocvar_g_monster_spider_attack_bite_delay), DEATH_MONSTER_SPIDER.m_id, true); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready); } } @@ -137,31 +136,30 @@ const float spider_anim_attack = 2; const float spider_anim_attack2 = 3; */ -void M_Spider_Attack_Web_Explode() -{SELFPARAM(); - entity e; - if(self) +void M_Spider_Attack_Web_Explode(entity this) +{ + if(this) { - Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1); - RadiusDamage(self, self.realowner, 0, 0, 25, world, world, 25, self.projectiledeathtype, world); + Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1); + RadiusDamage(this, this.realowner, 0, 0, 25, world, world, 25, this.projectiledeathtype, world); - for(e = findradius(self.origin, 25); e; e = e.chain) if(e != self) if(e.takedamage && !IS_DEAD(e)) if(e.health > 0) if(e.monsterid != MON_SPIDER.monsterid) + for(entity e = findradius(this.origin, 25); e; e = e.chain) if(e != this) if(e.takedamage && !IS_DEAD(e)) if(e.health > 0) if(e.monsterid != MON_SPIDER.monsterid) e.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime); - remove(self); + remove(this); } } void M_Spider_Attack_Web_Explode_use(entity this, entity actor, entity trigger) { - WITHSELF(this, M_Spider_Attack_Web_Explode()); + M_Spider_Attack_Web_Explode(this); } void M_Spider_Attack_Web_Touch(entity this) { PROJECTILE_TOUCH(this); - M_Spider_Attack_Web_Explode(); + M_Spider_Attack_Web_Explode(this); } void adaptor_think2use_hittype_splash(entity this); diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 776d36b3f..dbddbfc84 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -142,13 +142,13 @@ vector buff_GlowColor(entity buff) } void buff_Effect(entity player, string eff) -{SELFPARAM(); +{ if(!autocvar_g_buffs_effects) { return; } - if(time >= self.buff_effect_delay) + if(time >= player.buff_effect_delay) { Send_Effect_(eff, player.origin + ((player.mins + player.maxs) * 0.5), '0 0 0', 1); - self.buff_effect_delay = time + 0.05; // prevent spam + player.buff_effect_delay = time + 0.05; // prevent spam } } diff --git a/qcsrc/common/mutators/mutator/dodging/dodging.qc b/qcsrc/common/mutators/mutator/dodging/dodging.qc index 98ebe9c98..0d20ff7af 100644 --- a/qcsrc/common/mutators/mutator/dodging/dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/dodging.qc @@ -280,9 +280,9 @@ REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout"); MUTATOR_HOOKFUNCTION(dodging, GetPressedKeys) { - SELFPARAM(); - PM_dodging_checkpressedkeys(self); - return false; + entity player = M_ARGV(0, entity); + + PM_dodging_checkpressedkeys(player); } #endif diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 3e5c495d5..09badf84e 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -338,15 +338,15 @@ void nade_napalm_boom(entity this) fountain = spawn(); - fountain.owner = self.owner; - fountain.realowner = self.realowner; - fountain.origin = self.origin; + fountain.owner = this.owner; + fountain.realowner = this.realowner; + fountain.origin = this.origin; setorigin(fountain, fountain.origin); setthink(fountain, napalm_fountain_think); fountain.nextthink = time; fountain.ltime = time + autocvar_g_nades_napalm_fountain_lifetime; fountain.pushltime = fountain.ltime; - fountain.team = self.team; + fountain.team = this.team; fountain.movetype = MOVETYPE_TOSS; fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id; fountain.bot_dodge = true; @@ -367,33 +367,32 @@ void nade_ice_freeze(entity freezefield, entity frost_target, float freeze_time) void nade_ice_think(entity this) { - if(round_handler_IsActive()) if(!round_handler_IsRoundStarted()) { - remove(self); + remove(this); return; } - if(time >= self.ltime) + if(time >= this.ltime) { if ( autocvar_g_nades_ice_explode ) { - entity expef = EFFECT_NADE_EXPLODE(self.realowner.team); - Send_Effect(expef, self.origin + '0 0 1', '0 0 0', 1); - sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); - - RadiusDamage(self, self.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, - autocvar_g_nades_nade_radius, self, world, autocvar_g_nades_nade_force, self.projectiledeathtype, self.enemy); - Damage_DamageInfo(self.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, - autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, self.projectiledeathtype, 0, self); + entity expef = EFFECT_NADE_EXPLODE(this.realowner.team); + Send_Effect(expef, this.origin + '0 0 1', '0 0 0', 1); + sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); + + RadiusDamage(this, this.realowner, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, + autocvar_g_nades_nade_radius, this, world, autocvar_g_nades_nade_force, this.projectiledeathtype, this.enemy); + Damage_DamageInfo(this.origin, autocvar_g_nades_nade_damage, autocvar_g_nades_nade_edgedamage, + autocvar_g_nades_nade_radius, '1 1 1' * autocvar_g_nades_nade_force, this.projectiledeathtype, 0, this); } - remove(self); + remove(this); return; } - self.nextthink = time+0.1; + this.nextthink = time+0.1; // gaussian float randomr; @@ -405,29 +404,29 @@ void nade_ice_think(entity this) randomp.x = randomr*cos(randomw); randomp.y = randomr*sin(randomw); randomp.z = 1; - Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, self.origin + randomp, '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1); - if(time >= self.nade_special_time) + if(time >= this.nade_special_time) { - self.nade_special_time = time+0.7; + this.nade_special_time = time+0.7; - Send_Effect(EFFECT_ELECTRO_IMPACT, self.origin, '0 0 0', 1); - Send_Effect(EFFECT_ICEFIELD, self.origin, '0 0 0', 1); + Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1); + Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1); } - float current_freeze_time = self.ltime - time - 0.1; + float current_freeze_time = this.ltime - time - 0.1; entity e; - for(e = findradius(self.origin, autocvar_g_nades_nade_radius); e; e = e.chain) - if(e != self) - if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, self.realowner) || e == self.realowner)) + for(e = findradius(this.origin, autocvar_g_nades_nade_radius); e; e = e.chain) + if(e != this) + if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, this.realowner) || e == this.realowner)) if(e.takedamage && !IS_DEAD(e)) if(e.health > 0) if(!e.revival_time || ((time - e.revival_time) >= 1.5)) if(!STAT(FROZEN, e)) if(current_freeze_time > 0) - nade_ice_freeze(self, e, current_freeze_time); + nade_ice_freeze(this, e, current_freeze_time); } void nade_ice_boom(entity this) @@ -506,21 +505,21 @@ void nade_spawn_boom(entity this) void nade_heal_think(entity this) { - if(time >= self.ltime) + if(time >= this.ltime) { - remove(self); + remove(this); return; } - self.nextthink = time; + this.nextthink = time; - if(time >= self.nade_special_time) + if(time >= this.nade_special_time) { - self.nade_special_time = time+0.25; - self.nade_show_particles = 1; + this.nade_special_time = time+0.25; + this.nade_show_particles = 1; } else - self.nade_show_particles = 0; + this.nade_show_particles = 0; } void nade_heal_touch(entity this) @@ -532,9 +531,9 @@ void nade_heal_touch(entity this) if(!STAT(FROZEN, other)) { health_factor = autocvar_g_nades_heal_rate*frametime/2; - if ( other != self.realowner ) + if ( other != this.realowner ) { - if ( SAME_TEAM(other,self) ) + if ( SAME_TEAM(other,this) ) health_factor *= autocvar_g_nades_heal_friend; else health_factor *= autocvar_g_nades_heal_foe; @@ -544,7 +543,7 @@ void nade_heal_touch(entity this) maxhealth = (IS_MONSTER(other)) ? other.max_health : g_pickup_healthmega_max; if ( other.health < maxhealth ) { - if ( self.nade_show_particles ) + if ( this.nade_show_particles ) Send_Effect(EFFECT_HEALING, other.origin, '0 0 0', 1); other.health = min(other.health+health_factor, maxhealth); } @@ -552,7 +551,7 @@ void nade_heal_touch(entity this) } else if ( health_factor < 0 ) { - Damage(other,self,self.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0'); + Damage(other,this,this.realowner,-health_factor,DEATH_NADE_HEAL.m_id,other.origin,'0 0 0'); } } @@ -561,7 +560,7 @@ void nade_heal_touch(entity this) { entity show_red = (IS_VEHICLE(other)) ? other.owner : other; show_red.stat_healing_orb = time+0.1; - show_red.stat_healing_orb_alpha = 0.75 * (self.ltime - time) / self.healer_lifetime; + show_red.stat_healing_orb_alpha = 0.75 * (this.ltime - time) / this.healer_lifetime; } } @@ -693,21 +692,21 @@ bool CanThrowNade(entity this); void nade_touch(entity this) { if(other) - UpdateCSQCProjectile(self); + UpdateCSQCProjectile(this); - if(other == self.realowner) - return; // no self impacts + if(other == this.realowner) + return; // no this impacts if(autocvar_g_nades_pickup) - if(time >= self.spawnshieldtime) - if(!other.nade && self.health == self.max_health) // no boosted shot pickups, thank you very much + if(time >= this.spawnshieldtime) + if(!other.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much if(!other.frozen) if(CanThrowNade(other)) // prevent some obvious things, like dead players if(IS_REAL_CLIENT(other)) // above checks for IS_PLAYER, don't need to do it here { - nade_pickup(other, self); - sound(self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); - remove(self); + nade_pickup(other, this); + sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); + remove(this); return; } /*float is_weapclip = 0; @@ -717,27 +716,27 @@ void nade_touch(entity this) is_weapclip = 1;*/ if(ITEM_TOUCH_NEEDKILL()) // || is_weapclip) { - FOREACH_ENTITY_ENT(aiment, self, + FOREACH_ENTITY_ENT(aiment, this, { if(it.classname == "grapplinghook") RemoveGrapplingHook(it.realowner); }); - remove(self); + remove(this); return; } PROJECTILE_TOUCH(this); - //setsize(self, '-2 -2 -2', '2 2 2'); - //UpdateCSQCProjectile(self); - if(self.health == self.max_health) + //setsize(this, '-2 -2 -2', '2 2 2'); + //UpdateCSQCProjectile(this); + if(this.health == this.max_health) { - spamsound(self, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM); + spamsound(this, CH_SHOTS, SND(GRENADE_BOUNCE_RANDOM()), VOL_BASE, ATTEN_NORM); return; } - self.enemy = other; - nade_boom(self); + this.enemy = other; + nade_boom(this); } void nade_beep(entity this) @@ -936,20 +935,20 @@ MUTATOR_HOOKFUNCTION(nades, PutClientInServer) float nade_customize(entity this) { //if(IS_SPEC(other)) { return false; } - if(other == self.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == self.exteriormodeltoclient)) + if(other == this.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == this.exteriormodeltoclient)) { // somewhat hide the model, but keep the glow - //self.effects = 0; - if(self.traileffectnum) - self.traileffectnum = 0; - self.alpha = -1; + //this.effects = 0; + if(this.traileffectnum) + this.traileffectnum = 0; + this.alpha = -1; } else { - //self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - if(!self.traileffectnum) - self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(self.nade_type).m_projectile[false], self.team).eent_eff_name); - self.alpha = 1; + //this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; + if(!this.traileffectnum) + this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(this.nade_type).m_projectile[false], this.team).eent_eff_name); + this.alpha = 1; } return true; @@ -991,36 +990,36 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin player.fake_nade = fn; } -void nade_prime() -{SELFPARAM(); +void nade_prime(entity this) +{ if(autocvar_g_nades_bonus_only) - if(!self.bonus_nades) + if(!this.bonus_nades) return; // only allow bonus nades - if(self.nade) - remove(self.nade); + if(this.nade) + remove(this.nade); - if(self.fake_nade) - remove(self.fake_nade); + if(this.fake_nade) + remove(this.fake_nade); int ntype; - string pntype = self.pokenade_type; + string pntype = this.pokenade_type; - if(self.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength) - ntype = self.nade_type; - else if (self.bonus_nades >= 1) + if(this.items & ITEM_Strength.m_itemid && autocvar_g_nades_bonus_onstrength) + ntype = this.nade_type; + else if (this.bonus_nades >= 1) { - ntype = self.nade_type; - pntype = self.pokenade_type; - self.bonus_nades -= 1; + ntype = this.nade_type; + pntype = this.pokenade_type; + this.bonus_nades -= 1; } else { - ntype = ((autocvar_g_nades_client_select) ? self.cvar_cl_nade_type : autocvar_g_nades_nade_type); - pntype = ((autocvar_g_nades_client_select) ? self.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type); + ntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_nade_type : autocvar_g_nades_nade_type); + pntype = ((autocvar_g_nades_client_select) ? this.cvar_cl_pokenade_type : autocvar_g_nades_pokenade_monster_type); } - spawn_held_nade(self, self, autocvar_g_nades_nade_lifetime, ntype, pntype); + spawn_held_nade(this, this, autocvar_g_nades_nade_lifetime, ntype, pntype); } bool CanThrowNade(entity this) @@ -1048,33 +1047,33 @@ bool CanThrowNade(entity this) .bool nade_altbutton; -void nades_CheckThrow() -{SELFPARAM(); - if(!CanThrowNade(self)) +void nades_CheckThrow(entity this) +{ + if(!CanThrowNade(this)) return; - entity held_nade = self.nade; + entity held_nade = this.nade; if (!held_nade) { - self.nade_altbutton = true; - if(time > self.nade_refire) + this.nade_altbutton = true; + if(time > this.nade_refire) { - Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_NADE_THROW); - nade_prime(); - self.nade_refire = time + autocvar_g_nades_nade_refire; + Send_Notification(NOTIF_ONE, this, MSG_CENTER, CENTER_NADE_THROW); + nade_prime(this); + this.nade_refire = time + autocvar_g_nades_nade_refire; } } else { - self.nade_altbutton = false; + this.nade_altbutton = false; if (time >= held_nade.nade_time_primed + 1) { - makevectors(self.v_angle); + makevectors(this.v_angle); float _force = time - held_nade.nade_time_primed; _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); vector dir = (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05); dir = W_CalculateSpread(dir, autocvar_g_nades_spread, g_weaponspreadfactor, autocvar_g_projectiles_spread_style); - toss_nade(self, true, dir * _force, 0); + toss_nade(this, true, dir * _force, 0); } } } @@ -1119,7 +1118,7 @@ CLASS(NadeOffhand, OffhandWeapon) if (!(time > player.nade_refire)) return; if (key_pressed) { if (!held_nade) { - nade_prime(); + nade_prime(player); held_nade = player.nade; } } else if (time >= held_nade.nade_time_primed + 1) { @@ -1142,7 +1141,7 @@ MUTATOR_HOOKFUNCTION(nades, ForbidThrowCurrentWeapon, CBC_ORDER_LAST) entity player = M_ARGV(0, entity); if (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)) || autocvar_g_nades_override_dropweapon) { - WITHSELF(player, nades_CheckThrow()); + nades_CheckThrow(player); return true; } return false; diff --git a/qcsrc/common/mutators/mutator/nix/nix.qc b/qcsrc/common/mutators/mutator/nix/nix.qc index 19faf090f..c94198c80 100644 --- a/qcsrc/common/mutators/mutator/nix/nix.qc +++ b/qcsrc/common/mutators/mutator/nix/nix.qc @@ -36,7 +36,6 @@ bool NIX_CanChooseWeapon(int wpn); REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill")) { - SELFPARAM(); MUTATOR_ONADD { g_nix_with_blaster = autocvar_g_nix_with_blaster; @@ -64,7 +63,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill" it.ammo_fuel = start_ammo_fuel; it.weapons = start_weapons; if(!client_hasweapon(it, PS(it).m_weapon, true, false)) - PS(it).m_switchweapon = w_getbestweapon(self); + PS(it).m_switchweapon = w_getbestweapon(it); }); } diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 6459ad7a8..0169c4b08 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -142,16 +142,18 @@ spawnfunc(weapon_nex) { spawnfunc_weapon_vortex(this); } REGISTER_MUTATOR(vortex_charge, true); MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + // WEAPONTODO - float xyspeed = vlen(vec2(this.velocity)); - if (PS(this).m_weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) + float xyspeed = vlen(vec2(player.velocity)); + if (PS(player).m_weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) { // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); // add the extra charge - this.vortex_charge = min(1, this.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); + player.vortex_charge = min(1, player.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); } } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index fb0b1eb93..3b8efff55 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1551,10 +1551,9 @@ void SetZoomState(float z) zoomstate_set = true; } -void GetPressedKeys() +void GetPressedKeys(entity this) { - SELFPARAM(); - MUTATOR_CALLHOOK(GetPressedKeys); + MUTATOR_CALLHOOK(GetPressedKeys, this); int keys = this.pressedkeys; keys = BITSET(keys, KEY_FORWARD, this.movement.x > 0); keys = BITSET(keys, KEY_BACKWARD, this.movement.x < 0); @@ -2462,7 +2461,7 @@ void PlayerPostThink () UpdateChatBubble(); if (this.impulse) ImpulseCommands(this); if (intermission_running) return; // intermission or finale - GetPressedKeys(); + GetPressedKeys(this); } if (this.waypointsprite_attachedforcarrier) { diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index f5bc6c379..a7b3daca0 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -197,7 +197,10 @@ MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_OnEntityPreSpawn); MUTATOR_HOOKABLE(PlayerPreThink, EV_PlayerPreThink); /** TODO change this into a general PlayerPostThink hook? */ -MUTATOR_HOOKABLE(GetPressedKeys, EV_NO_ARGS); +#define EV_GetPressedKeys(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /**/ +MUTATOR_HOOKABLE(GetPressedKeys, EV_GetPressedKeys); /** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */ #define EV_GetCvars(i, o) \ diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 5f2a7eeed..e54e1801f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -309,26 +309,28 @@ MUTATOR_HOOKFUNCTION(cts, HavocBot_ChooseRole) } MUTATOR_HOOKFUNCTION(cts, GetPressedKeys) -{SELFPARAM(); - if(self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1) +{ + entity player = M_ARGV(0, entity); + + if(player.cvar_cl_allow_uidtracking == 1 && player.cvar_cl_allow_uid2name == 1) { - if (!self.stored_netname) - self.stored_netname = strzone(uid2name(self.crypto_idfp)); - if(self.stored_netname != self.netname) + if (!player.stored_netname) + player.stored_netname = strzone(uid2name(player.crypto_idfp)); + if(player.stored_netname != player.netname) { - db_put(ServerProgsDB, strcat("/uid2name/", self.crypto_idfp), self.netname); - strunzone(self.stored_netname); - self.stored_netname = strzone(self.netname); + db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname); + strunzone(player.stored_netname); + player.stored_netname = strzone(player.netname); } } - if (!IS_OBSERVER(self)) + if (!IS_OBSERVER(player)) { - if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) + if(vdist(player.velocity - player.velocity_z * '0 0 1', >, speedaward_speed)) { - speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1'); - speedaward_holder = self.netname; - speedaward_uid = self.crypto_idfp; + speedaward_speed = vlen(player.velocity - player.velocity_z * '0 0 1'); + speedaward_holder = player.netname; + speedaward_uid = player.crypto_idfp; speedaward_lastupdate = time; } if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1) @@ -347,8 +349,6 @@ MUTATOR_HOOKFUNCTION(cts, GetPressedKeys) } } } - - return false; } MUTATOR_HOOKFUNCTION(cts, ForbidThrowCurrentWeapon) diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 2b68bf6d3..f58004f7b 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -340,26 +340,28 @@ MUTATOR_HOOKFUNCTION(rc, HavocBot_ChooseRole) } MUTATOR_HOOKFUNCTION(rc, GetPressedKeys) -{SELFPARAM(); - if(self.cvar_cl_allow_uidtracking == 1 && self.cvar_cl_allow_uid2name == 1) +{ + entity player = M_ARGV(0, entity); + + if(player.cvar_cl_allow_uidtracking == 1 && player.cvar_cl_allow_uid2name == 1) { - if (!self.stored_netname) - self.stored_netname = strzone(uid2name(self.crypto_idfp)); - if(self.stored_netname != self.netname) + if (!player.stored_netname) + player.stored_netname = strzone(uid2name(player.crypto_idfp)); + if(player.stored_netname != player.netname) { - db_put(ServerProgsDB, strcat("/uid2name/", self.crypto_idfp), self.netname); - strunzone(self.stored_netname); - self.stored_netname = strzone(self.netname); + db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname); + strunzone(player.stored_netname); + player.stored_netname = strzone(player.netname); } } - if (!IS_OBSERVER(self)) + if (!IS_OBSERVER(player)) { - if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) + if(vdist(player.velocity - player.velocity_z * '0 0 1', >, speedaward_speed)) { - speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1'); - speedaward_holder = self.netname; - speedaward_uid = self.crypto_idfp; + speedaward_speed = vlen(player.velocity - player.velocity_z * '0 0 1'); + speedaward_holder = player.netname; + speedaward_uid = player.crypto_idfp; speedaward_lastupdate = time; } if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1) @@ -378,7 +380,6 @@ MUTATOR_HOOKFUNCTION(rc, GetPressedKeys) } } } - return false; } MUTATOR_HOOKFUNCTION(rc, ForbidPlayerScore_Clear)