From 2cc219c0762e106241165f3b08fac54a516cda89 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 10 Jun 2016 12:30:42 +1000 Subject: [PATCH] Purify PutClientInServer and PlayerSpawn mutator hooks --- .../gamemodes/gamemode/nexball/nexball.qc | 11 +- .../gamemodes/gamemode/onslaught/onslaught.qc | 34 ++--- qcsrc/common/monsters/monster/spider.qc | 5 +- qcsrc/common/mutators/mutator/buffs/buffs.qc | 12 +- .../mutators/mutator/campcheck/campcheck.qc | 8 +- qcsrc/common/mutators/mutator/hook/hook.qc | 5 +- .../mutators/mutator/instagib/instagib.qc | 7 +- qcsrc/common/mutators/mutator/itemstime.qc | 6 +- .../common/mutators/mutator/midair/midair.qc | 8 +- qcsrc/common/mutators/mutator/nades/nades.qc | 31 +++-- qcsrc/common/mutators/mutator/nix/nix.qc | 120 +++++++++--------- .../mutators/mutator/overkill/overkill.qc | 18 +-- .../spawn_near_teammate.qc | 49 +++---- .../weaponarena_random/weaponarena_random.qc | 12 +- qcsrc/server/cl_client.qc | 2 +- qcsrc/server/mutators/events.qh | 7 +- .../mutators/mutator/gamemode_assault.qc | 10 +- qcsrc/server/mutators/mutator/gamemode_ca.qc | 18 +-- qcsrc/server/mutators/mutator/gamemode_cts.qc | 27 ++-- .../mutators/mutator/gamemode_domination.qc | 8 +- .../mutators/mutator/gamemode_freezetag.qc | 14 +- .../mutators/mutator/gamemode_invasion.qc | 6 +- qcsrc/server/mutators/mutator/gamemode_lms.qc | 10 +- .../server/mutators/mutator/gamemode_race.qc | 27 ++-- 24 files changed, 250 insertions(+), 205 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 6c6bcac9e..57539be68 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -1014,15 +1014,16 @@ MUTATOR_HOOKFUNCTION(nb, SpectateCopy) MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) { - SELFPARAM(); - this.metertime = 0; + entity player = M_ARGV(0, entity); + + player.metertime = 0; .entity weaponentity = weaponentities[0]; - this.(weaponentity).weapons = '0 0 0'; + player.(weaponentity).weapons = '0 0 0'; if (nexball_mode & NBM_BASKETBALL) - this.weapons |= WEPSET(NEXBALL); + player.weapons |= WEPSET(NEXBALL); else - this.weapons = '0 0 0'; + player.weapons = '0 0 0'; return false; } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 08d0183e3..617af7c76 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -1777,10 +1777,12 @@ MUTATOR_HOOKFUNCTION(ons, MakePlayerObserver) } MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + if(!round_handler_IsRoundStarted()) { - self.player_blocked = true; + player.player_blocked = true; return false; } @@ -1794,13 +1796,13 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) l.sprite.SendFlags |= 16; } - if(ons_stalemate) { Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT); } + if(ons_stalemate) { Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT); } if ( autocvar_g_onslaught_spawn_choose ) - if ( self.ons_spawn_by ) - if ( ons_Teleport(self,self.ons_spawn_by,autocvar_g_onslaught_teleport_radius,false) ) + if ( player.ons_spawn_by ) + if ( ons_Teleport(player,player.ons_spawn_by,autocvar_g_onslaught_teleport_radius,false) ) { - self.ons_spawn_by = world; + player.ons_spawn_by = world; return false; } @@ -1809,7 +1811,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) { float random_target = autocvar_g_onslaught_spawn_at_controlpoints_random; entity tmp_entity, closest_target = world; - vector spawn_loc = self.ons_deathloc; + vector spawn_loc = player.ons_deathloc; // new joining player or round reset, don't bother checking if(spawn_loc == '0 0 0') { return false; } @@ -1818,7 +1820,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext) { - if(SAME_TEAM(tmp_entity, self)) + if(SAME_TEAM(tmp_entity, player)) if(random_target) RandomSelection_Add(tmp_entity, 0, string_null, 1, 1); else if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world) @@ -1837,14 +1839,14 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) iteration_scale -= i / 10; loc = closest_target.origin + '0 0 96' * iteration_scale; loc += ('0 1 0' * random()) * 128 * iteration_scale; - tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, self); + tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player); if(trace_fraction == 1.0 && !trace_startsolid) { traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the world if(trace_fraction == 1.0 && !trace_startsolid) { - setorigin(self, loc); - self.angles = normalize(loc - closest_target.origin) * RAD2DEG; + setorigin(player, loc); + player.angles = normalize(loc - closest_target.origin) * RAD2DEG; return false; } } @@ -1857,7 +1859,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) { float random_target = autocvar_g_onslaught_spawn_at_generator_random; entity tmp_entity, closest_target = world; - vector spawn_loc = self.ons_deathloc; + vector spawn_loc = player.ons_deathloc; // new joining player or round reset, don't bother checking if(spawn_loc == '0 0 0') { return false; } @@ -1870,7 +1872,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) RandomSelection_Add(tmp_entity, 0, string_null, 1, 1); else { - if(SAME_TEAM(tmp_entity, self)) + if(SAME_TEAM(tmp_entity, player)) if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world) closest_target = tmp_entity; } @@ -1888,14 +1890,14 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) iteration_scale -= i / 10; loc = closest_target.origin + '0 0 128' * iteration_scale; loc += ('0 1 0' * random()) * 256 * iteration_scale; - tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, self); + tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player); if(trace_fraction == 1.0 && !trace_startsolid) { traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the world if(trace_fraction == 1.0 && !trace_startsolid) { - setorigin(self, loc); - self.angles = normalize(loc - closest_target.origin) * RAD2DEG; + setorigin(player, loc); + player.angles = normalize(loc - closest_target.origin) * RAD2DEG; return false; } } diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index b9f9bfc21..a3651812b 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -79,8 +79,9 @@ MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove) MUTATOR_HOOKFUNCTION(spiderweb, PlayerSpawn) { - SELFPARAM(); - self.spider_slowness = 0; + entity player = M_ARGV(0, entity); + + player.spider_slowness = 0; return false; } diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index d15f18feb..869dbcb62 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -620,12 +620,14 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate) return false; } -MUTATOR_HOOKFUNCTION(buffs,PlayerSpawn) -{SELFPARAM(); - self.buffs = 0; +MUTATOR_HOOKFUNCTION(buffs, PlayerSpawn) +{ + entity player = M_ARGV(0, entity); + + player.buffs = 0; // reset timers here to prevent them continuing after re-spawn - self.buff_disability_time = 0; - self.buff_disability_effect_time = 0; + player.buff_disability_time = 0; + player.buff_disability_effect_time = 0; return false; } diff --git a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc index 067fa1895..b6d17a3ee 100644 --- a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc +++ b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc @@ -77,11 +77,11 @@ MUTATOR_HOOKFUNCTION(campcheck, PlayerPreThink) } MUTATOR_HOOKFUNCTION(campcheck, PlayerSpawn) -{SELFPARAM(); - self.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2; - self.campcheck_traveled_distance = 0; +{ + entity player = M_ARGV(0, entity); - return false; + player.campcheck_nextcheck = time + autocvar_g_campcheck_interval * 2; + player.campcheck_traveled_distance = 0; } MUTATOR_HOOKFUNCTION(campcheck, BuildMutatorsString) diff --git a/qcsrc/common/mutators/mutator/hook/hook.qc b/qcsrc/common/mutators/mutator/hook/hook.qc index 388ee81a0..3dbce74f2 100644 --- a/qcsrc/common/mutators/mutator/hook/hook.qc +++ b/qcsrc/common/mutators/mutator/hook/hook.qc @@ -29,8 +29,9 @@ MUTATOR_HOOKFUNCTION(hook, BuildGameplayTipsString) MUTATOR_HOOKFUNCTION(hook, PlayerSpawn) { - SELFPARAM(); - self.offhand = OFFHAND_HOOK; + entity player = M_ARGV(0, entity); + + player.offhand = OFFHAND_HOOK; } MUTATOR_HOOKFUNCTION(hook, FilterItem) diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index 8b1b3bf40..fa8ce9734 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -174,9 +174,10 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, MakePlayerObserver) } MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerSpawn) -{SELFPARAM(); - self.effects |= EF_FULLBRIGHT; - return false; +{ + entity player = M_ARGV(0, entity); + + player.effects |= EF_FULLBRIGHT; } MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPreThink) diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index 34e6e3275..089f03abb 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -176,9 +176,11 @@ MUTATOR_HOOKFUNCTION(itemstime, ClientConnect, CBC_ORDER_LAST) } MUTATOR_HOOKFUNCTION(itemstime, PlayerSpawn) -{SELFPARAM(); +{ if (warmup_stage) return; - Item_ItemsTime_ResetTimesForPlayer(self); + entity player = M_ARGV(0, entity); + + Item_ItemsTime_ResetTimesForPlayer(player); } #endif diff --git a/qcsrc/common/mutators/mutator/midair/midair.qc b/qcsrc/common/mutators/mutator/midair/midair.qc index adf3c3a1f..c9a62f349 100644 --- a/qcsrc/common/mutators/mutator/midair/midair.qc +++ b/qcsrc/common/mutators/mutator/midair/midair.qc @@ -32,9 +32,11 @@ MUTATOR_HOOKFUNCTION(midair, PlayerPowerups) } MUTATOR_HOOKFUNCTION(midair, PlayerSpawn) -{SELFPARAM(); - if(IS_BOT_CLIENT(self)) - self.bot_moveskill = 0; // disable bunnyhopping +{ + entity player = M_ARGV(0, entity); + + if(IS_BOT_CLIENT(player)) + player.bot_moveskill = 0; // disable bunnyhopping return false; } diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index e1efa8e06..6b2782286 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -928,8 +928,9 @@ void nades_RemoveBonus(entity player) MUTATOR_HOOKFUNCTION(nades, PutClientInServer) { - SELFPARAM(); - nades_RemoveBonus(self); + entity player = M_ARGV(0, entity); + + nades_RemoveBonus(player); } float nade_customize(entity this) @@ -1237,28 +1238,30 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) } MUTATOR_HOOKFUNCTION(nades, PlayerSpawn) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + if(autocvar_g_nades_spawn) - self.nade_refire = time + autocvar_g_spawnshieldtime; + player.nade_refire = time + autocvar_g_spawnshieldtime; else - self.nade_refire = time + autocvar_g_nades_nade_refire; + player.nade_refire = time + autocvar_g_nades_nade_refire; if(autocvar_g_nades_bonus_client_select) - self.nade_type = self.cvar_cl_nade_type; + player.nade_type = player.cvar_cl_nade_type; - self.nade_timer = 0; + player.nade_timer = 0; - if (!self.offhand) self.offhand = OFFHAND_NADE; + if (!player.offhand) player.offhand = OFFHAND_NADE; - if(self.nade_spawnloc) + if(player.nade_spawnloc) { - setorigin(self, self.nade_spawnloc.origin); - self.nade_spawnloc.cnt -= 1; + setorigin(player, player.nade_spawnloc.origin); + player.nade_spawnloc.cnt -= 1; - if(self.nade_spawnloc.cnt <= 0) + if(player.nade_spawnloc.cnt <= 0) { - remove(self.nade_spawnloc); - self.nade_spawnloc = world; + remove(player.nade_spawnloc); + player.nade_spawnloc = world; } } diff --git a/qcsrc/common/mutators/mutator/nix/nix.qc b/qcsrc/common/mutators/mutator/nix/nix.qc index e51003204..5a4df3ea4 100644 --- a/qcsrc/common/mutators/mutator/nix/nix.qc +++ b/qcsrc/common/mutators/mutator/nix/nix.qc @@ -68,7 +68,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill" }); } - return 0; + return false; } bool NIX_CanChooseWeapon(int wpn) @@ -101,8 +101,8 @@ void NIX_ChooseNextWeapon() nix_nextweapon = RandomSelection_chosen_float; } -void NIX_GiveCurrentWeapon() -{SELFPARAM(); +void NIX_GiveCurrentWeapon(entity this) +{ float dt; if(!nix_nextweapon) @@ -127,107 +127,107 @@ void NIX_GiveCurrentWeapon() if(nix_nextchange != self.nix_lastchange_id) // this shall only be called once per round! { - self.ammo_shells = self.ammo_nails = self.ammo_rockets = self.ammo_cells = self.ammo_plasma = self.ammo_fuel = 0; + this.ammo_shells = this.ammo_nails = this.ammo_rockets = this.ammo_cells = this.ammo_plasma = this.ammo_fuel = 0; - if(self.items & IT_UNLIMITED_WEAPON_AMMO) + if(this.items & IT_UNLIMITED_WEAPON_AMMO) { switch(e.ammo_field) { - case ammo_shells: self.ammo_shells = autocvar_g_pickup_shells_max; break; - case ammo_nails: self.ammo_nails = autocvar_g_pickup_nails_max; break; - case ammo_rockets: self.ammo_rockets = autocvar_g_pickup_rockets_max; break; - case ammo_cells: self.ammo_cells = autocvar_g_pickup_cells_max; break; - case ammo_plasma: self.ammo_plasma = autocvar_g_pickup_plasma_max; break; - case ammo_fuel: self.ammo_fuel = autocvar_g_pickup_fuel_max; break; + case ammo_shells: this.ammo_shells = autocvar_g_pickup_shells_max; break; + case ammo_nails: this.ammo_nails = autocvar_g_pickup_nails_max; break; + case ammo_rockets: this.ammo_rockets = autocvar_g_pickup_rockets_max; break; + case ammo_cells: this.ammo_cells = autocvar_g_pickup_cells_max; break; + case ammo_plasma: this.ammo_plasma = autocvar_g_pickup_plasma_max; break; + case ammo_fuel: this.ammo_fuel = autocvar_g_pickup_fuel_max; break; } } else { switch(e.ammo_field) { - case ammo_shells: self.ammo_shells = autocvar_g_balance_nix_ammo_shells; break; - case ammo_nails: self.ammo_nails = autocvar_g_balance_nix_ammo_nails; break; - case ammo_rockets: self.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break; - case ammo_cells: self.ammo_cells = autocvar_g_balance_nix_ammo_cells; break; - case ammo_plasma: self.ammo_plasma = autocvar_g_balance_nix_ammo_plasma; break; - case ammo_fuel: self.ammo_fuel = autocvar_g_balance_nix_ammo_fuel; break; + case ammo_shells: this.ammo_shells = autocvar_g_balance_nix_ammo_shells; break; + case ammo_nails: this.ammo_nails = autocvar_g_balance_nix_ammo_nails; break; + case ammo_rockets: this.ammo_rockets = autocvar_g_balance_nix_ammo_rockets; break; + case ammo_cells: this.ammo_cells = autocvar_g_balance_nix_ammo_cells; break; + case ammo_plasma: this.ammo_plasma = autocvar_g_balance_nix_ammo_plasma; break; + case ammo_fuel: this.ammo_fuel = autocvar_g_balance_nix_ammo_fuel; break; } } - self.nix_nextincr = time + autocvar_g_balance_nix_incrtime; + this.nix_nextincr = time + autocvar_g_balance_nix_incrtime; if(dt >= 1 && dt <= 5) - self.nix_lastinfotime = -42; + this.nix_lastinfotime = -42; else - Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon); + Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_NIX_NEWWEAPON, nix_weapon); - e.wr_resetplayer(e, self); + WITHSELF(this, e.wr_resetplayer(e, this)); // all weapons must be fully loaded when we spawn if(e.spawnflags & WEP_FLAG_RELOADABLE) // prevent accessing undefined cvars - self.(weapon_load[nix_weapon]) = e.reloading_ammo; + this.(weapon_load[nix_weapon]) = e.reloading_ammo; // vortex too if(WEP_CVAR(vortex, charge)) { if(WEP_CVAR_SEC(vortex, chargepool)) - self.vortex_chargepool_ammo = 1; - self.vortex_charge = WEP_CVAR(vortex, charge_start); + this.vortex_chargepool_ammo = 1; + this.vortex_charge = WEP_CVAR(vortex, charge_start); } // set last change info - self.nix_lastchange_id = nix_nextchange; + this.nix_lastchange_id = nix_nextchange; } - if(self.nix_lastinfotime != dt) + if(this.nix_lastinfotime != dt) { - self.nix_lastinfotime = dt; // initial value 0 should count as "not seen" + this.nix_lastinfotime = dt; // initial value 0 should count as "not seen" if(dt >= 1 && dt <= 5) - Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CENTER_NIX_COUNTDOWN, nix_nextweapon, dt); + Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_NIX_COUNTDOWN, nix_nextweapon, dt); } - if(!(self.items & IT_UNLIMITED_WEAPON_AMMO) && time > self.nix_nextincr) + if(!(this.items & IT_UNLIMITED_WEAPON_AMMO) && time > this.nix_nextincr) { switch(e.ammo_field) { - case ammo_shells: self.ammo_shells += autocvar_g_balance_nix_ammoincr_shells; break; - case ammo_nails: self.ammo_nails += autocvar_g_balance_nix_ammoincr_nails; break; - case ammo_rockets: self.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break; - case ammo_cells: self.ammo_cells += autocvar_g_balance_nix_ammoincr_cells; break; - case ammo_plasma: self.ammo_plasma += autocvar_g_balance_nix_ammoincr_plasma; break; - case ammo_fuel: self.ammo_fuel += autocvar_g_balance_nix_ammoincr_fuel; break; + case ammo_shells: this.ammo_shells += autocvar_g_balance_nix_ammoincr_shells; break; + case ammo_nails: this.ammo_nails += autocvar_g_balance_nix_ammoincr_nails; break; + case ammo_rockets: this.ammo_rockets += autocvar_g_balance_nix_ammoincr_rockets; break; + case ammo_cells: this.ammo_cells += autocvar_g_balance_nix_ammoincr_cells; break; + case ammo_plasma: this.ammo_plasma += autocvar_g_balance_nix_ammoincr_plasma; break; + case ammo_fuel: this.ammo_fuel += autocvar_g_balance_nix_ammoincr_fuel; break; } - self.nix_nextincr = time + autocvar_g_balance_nix_incrtime; + this.nix_nextincr = time + autocvar_g_balance_nix_incrtime; } - self.weapons = '0 0 0'; + this.weapons = '0 0 0'; if(g_nix_with_blaster) - self.weapons |= WEPSET(BLASTER); - self.weapons |= e.m_wepset; + this.weapons |= WEPSET(BLASTER); + this.weapons |= e.m_wepset; Weapon w = Weapons_from(nix_weapon); - if(PS(self).m_switchweapon != w) - if(!client_hasweapon(self, PS(self).m_switchweapon, true, false)) + if(PS(this).m_switchweapon != w) + if(!client_hasweapon(this, PS(this).m_switchweapon, true, false)) { - if(client_hasweapon(self, w, true, false)) - W_SwitchWeapon(self, w); + if(client_hasweapon(this, w, true, false)) + W_SwitchWeapon(this, w); } } MUTATOR_HOOKFUNCTION(nix, ForbidThrowCurrentWeapon) { - return 1; // no throwing in NIX + return true; // no throwing in NIX } MUTATOR_HOOKFUNCTION(nix, BuildMutatorsString) { ret_string = strcat(ret_string, ":NIX"); - return 0; + return false; } MUTATOR_HOOKFUNCTION(nix, BuildMutatorsPrettyString) { ret_string = strcat(ret_string, ", NIX"); - return 0; + return false; } MUTATOR_HOOKFUNCTION(nix, FilterItem) @@ -243,23 +243,23 @@ MUTATOR_HOOKFUNCTION(nix, FilterItem) case ITEM_ArmorLarge.m_itemid: case ITEM_ArmorMega.m_itemid: if (autocvar_g_nix_with_healtharmor) - return 0; + return false; break; case ITEM_Strength.m_itemid: case ITEM_Shield.m_itemid: if (autocvar_g_nix_with_powerups) - return 0; + return false; break; } - return 1; // delete all other items + return true; // delete all other items } MUTATOR_HOOKFUNCTION(nix, OnEntityPreSpawn) {SELFPARAM(); if(self.classname == "target_items") // items triggers cannot work in nix (as they change weapons/ammo) - return 1; - return 0; + return true; + return false; } MUTATOR_HOOKFUNCTION(nix, PlayerPreThink) @@ -267,21 +267,23 @@ MUTATOR_HOOKFUNCTION(nix, PlayerPreThink) if(!intermission_running) if(!IS_DEAD(self)) if(IS_PLAYER(self)) - NIX_GiveCurrentWeapon(); - return 0; + NIX_GiveCurrentWeapon(this); + return false; } MUTATOR_HOOKFUNCTION(nix, PlayerSpawn) -{SELFPARAM(); - self.nix_lastchange_id = -1; - NIX_GiveCurrentWeapon(); // overrides the weapons you got when spawning - self.items |= IT_UNLIMITED_SUPERWEAPONS; - return 0; +{ + entity player = M_ARGV(0, entity); + + player.nix_lastchange_id = -1; + NIX_GiveCurrentWeapon(player); // overrides the weapons you got when spawning + player.items |= IT_UNLIMITED_SUPERWEAPONS; + return false; } MUTATOR_HOOKFUNCTION(nix, SetModname, CBC_ORDER_LAST) { modname = "NIX"; - return 0; + return false; } #endif diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index 611dc6e0a..b8a203990 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -256,22 +256,24 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) } MUTATOR_HOOKFUNCTION(ok, PlayerSpawn) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + if(autocvar_g_overkill_ammo_charge) { - FOREACH(Weapons, it != WEP_Null, LAMBDA(self.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit)); + FOREACH(Weapons, it != WEP_Null, LAMBDA(player.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit)); - self.ok_use_ammocharge = 1; - self.ok_notice_time = time; + player.ok_use_ammocharge = 1; + player.ok_notice_time = time; } else - self.ok_use_ammocharge = 0; + player.ok_use_ammocharge = 0; // if player changed their weapon while dead, don't switch to their death weapon - if(self.impulse) - self.ok_lastwep = 0; + if(player.impulse) + player.ok_lastwep = 0; - self.ok_pauseregen_finished = time + 2; + player.ok_pauseregen_finished = time + 2; return false; } diff --git a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc index 23348f39d..3d2c17f33 100644 --- a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc +++ b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc @@ -19,12 +19,12 @@ REGISTER_MUTATOR(spawn_near_teammate, cvar("g_spawn_near_teammate")); MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score) {SELFPARAM(); if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate)) - return 0; + return false; spawn_spot.msnt_lookat = world; if(!teamplay) - return 0; + return false; RandomSelection_Init(); FOREACH_CLIENT(IS_PLAYER(it) && it != self && SAME_TEAM(it, self) && !IS_DEAD(it), LAMBDA( @@ -45,12 +45,13 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, Spawn_Score) else if(self.team == spawn_spot.team) spawn_score.x += SPAWN_PRIO_NEAR_TEAMMATE_SAMETEAM; // prefer same team, if we can't find a spawn near teammate - return 0; + return false; } MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) -{SELFPARAM(); +{ if(!teamplay) { return false; } + entity player = M_ARGV(0, entity); int num_red = 0, num_blue = 0, num_yellow = 0, num_pink = 0; FOREACH_CLIENT(IS_PLAYER(it), @@ -68,10 +69,10 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) return false; // at least 1 team has only 1 player, let's not give the bigger team too much of an advantage! // Note: when entering this, fixangle is already set. - if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && self.cvar_cl_spawn_near_teammate)) + if(autocvar_g_spawn_near_teammate_ignore_spawnpoint == 1 || (autocvar_g_spawn_near_teammate_ignore_spawnpoint == 2 && player.cvar_cl_spawn_near_teammate)) { if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death) - self.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death; + player.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death; entity best_mate = world; vector best_spot = '0 0 0'; @@ -80,10 +81,10 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) if((autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health >= 0 && it.health >= autocvar_g_balance_health_regenstable) || autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health == 0) if(!IS_DEAD(it)) if(it.msnt_timer < time) - if(SAME_TEAM(self, it)) + if(SAME_TEAM(player, it)) if(time > it.spawnshieldtime) // spawn shielding if(STAT(FROZEN, it) == 0) - if(it != self) + if(it != player) { tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - '0 0 100', MOVE_NOMONSTERS, it); if(trace_fraction != 1.0) @@ -125,7 +126,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) { if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath) { - dist = vlen(trace_endpos - self.msnt_deathloc); + dist = vlen(trace_endpos - player.msnt_deathloc); if(dist < best_dist || best_dist == 0) { best_dist = dist; @@ -135,11 +136,11 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) } else { - setorigin(self, trace_endpos); - self.angles = it.angles; - self.angles_z = 0; // never spawn tilted even if the spot says to + setorigin(player, trace_endpos); + player.angles = it.angles; + player.angles_z = 0; // never spawn tilted even if the spot says to it.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay; - return 0; + return false; } } } @@ -152,31 +153,31 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn) if(autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath) if(best_dist) { - setorigin(self, best_spot); - self.angles = best_mate.angles; - self.angles_z = 0; // never spawn tilted even if the spot says to + setorigin(player, best_spot); + player.angles = best_mate.angles; + player.angles_z = 0; // never spawn tilted even if the spot says to best_mate.msnt_timer = time + autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay; } } else if(spawn_spot.msnt_lookat) { - self.angles = vectoangles(spawn_spot.msnt_lookat.origin - self.origin); - self.angles_x = -self.angles.x; - self.angles_z = 0; // never spawn tilted even if the spot says to + player.angles = vectoangles(spawn_spot.msnt_lookat.origin - player.origin); + player.angles_x = -player.angles.x; + player.angles_z = 0; // never spawn tilted even if the spot says to /* - sprint(self, "You should be looking at ", spawn_spot.msnt_lookat.netname, "^7.\n"); - sprint(self, "distance: ", vtos(spawn_spot.msnt_lookat.origin - self.origin), "\n"); - sprint(self, "angles: ", vtos(self.angles), "\n"); + sprint(player, "You should be looking at ", spawn_spot.msnt_lookat.netname, "^7.\n"); + sprint(player, "distance: ", vtos(spawn_spot.msnt_lookat.origin - player.origin), "\n"); + sprint(player, "angles: ", vtos(player.angles), "\n"); */ } - return 0; + return false; } MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerDies) { frag_target.msnt_deathloc = frag_target.origin; - return 0; + return false; } REPLICATE(cvar_cl_spawn_near_teammate, bool, "cl_spawn_near_teammate"); diff --git a/qcsrc/common/mutators/mutator/weaponarena_random/weaponarena_random.qc b/qcsrc/common/mutators/mutator/weaponarena_random/weaponarena_random.qc index 5c8210077..e4d400db7 100644 --- a/qcsrc/common/mutators/mutator/weaponarena_random/weaponarena_random.qc +++ b/qcsrc/common/mutators/mutator/weaponarena_random/weaponarena_random.qc @@ -2,12 +2,14 @@ // WEAPONTODO: rename the cvars REGISTER_MUTATOR(weaponarena_random, true); -MUTATOR_HOOKFUNCTION(weaponarena_random, PlayerSpawn) { - SELFPARAM(); +MUTATOR_HOOKFUNCTION(weaponarena_random, PlayerSpawn) +{ if (!g_weaponarena_random) return; - if (g_weaponarena_random_with_blaster) this.weapons &= ~WEPSET(BLASTER); - W_RandomWeapons(this, g_weaponarena_random); - if (g_weaponarena_random_with_blaster) this.weapons |= WEPSET(BLASTER); + entity player = M_ARGV(0, entity); + + if (g_weaponarena_random_with_blaster) player.weapons &= ~WEPSET(BLASTER); + W_RandomWeapons(player, g_weaponarena_random); + if (g_weaponarena_random_with_blaster) player.weapons |= WEPSET(BLASTER); } #endif diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index fe0c3a547..6f0e1d3ae 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -635,7 +635,7 @@ void PutClientInServer() Unfreeze(this); - MUTATOR_CALLHOOK(PlayerSpawn, spot); + MUTATOR_CALLHOOK(PlayerSpawn, this, spot); if (autocvar_spawn_debug) { diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 05adcf173..91b74335d 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -11,15 +11,15 @@ MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver) /** */ #define EV_PutClientInServer(i, o) \ - /** client wanting to spawn */ i(entity, __self) \ + /** client wanting to spawn */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(PutClientInServer, EV_PutClientInServer); /** called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) */ #define EV_PlayerSpawn(i, o) \ - /** spot that was used, or world */ i(entity, spawn_spot) \ + /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \ + /** spot that was used, or world */ i(entity, MUTATOR_ARGV_1_entity) \ /**/ -entity spawn_spot; MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn); /** called in reset_map */ @@ -437,6 +437,7 @@ MUTATOR_HOOKABLE(SV_ParseServerCommand, EV_SV_ParseServerCommand); /** _x is priority, _y is "distance" */ i(vector, spawn_score) \ /**/ o(vector, spawn_score) \ /**/ +entity spawn_spot; vector spawn_score; MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score); diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 47544dacd..c8519a76e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -613,11 +613,13 @@ void havocbot_ast_reset_role(entity this) // mutator hooks MUTATOR_HOOKFUNCTION(as, PlayerSpawn) -{SELFPARAM(); - if(self.team == assault_attacker_team) - Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_ASSAULT_ATTACKING); +{ + entity player = M_ARGV(0, entity); + + if(player.team == assault_attacker_team) + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ASSAULT_ATTACKING); else - Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_ASSAULT_DEFENDING); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_ASSAULT_DEFENDING); return false; } diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index c49bfa218..c7c1c7e83 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -220,22 +220,24 @@ entity CA_SpectateNext(entity player, entity start) MUTATOR_HOOKFUNCTION(ca, PlayerSpawn) { - SELFPARAM(); - this.caplayer = 1; + entity player = M_ARGV(0, entity); + + player.caplayer = 1; if (!warmup_stage) eliminatedPlayers.SendFlags |= 1; } MUTATOR_HOOKFUNCTION(ca, PutClientInServer) { - SELFPARAM(); - if (!allowed_to_spawn && IS_PLAYER(this)) // this is true even when player is trying to join + entity player = M_ARGV(0, entity); + + if (!allowed_to_spawn && IS_PLAYER(player)) // this is true even when player is trying to join { - TRANSMUTE(Observer, this); - if (this.jointime != time && !this.caplayer) // not when connecting + TRANSMUTE(Observer, player); + if (player.jointime != time && !player.caplayer) // not when connecting { - this.caplayer = 0.5; - Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CA_JOIN_LATE); + player.caplayer = 0.5; + Send_Notification(NOTIF_ONE_ONLY, player, MSG_INFO, INFO_CA_JOIN_LATE); } } } diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 88464a934..777cf1fa0 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -253,31 +253,36 @@ MUTATOR_HOOKFUNCTION(cts, MakePlayerObserver) } MUTATOR_HOOKFUNCTION(cts, PlayerSpawn) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + entity spawn_spot = M_ARGV(1, entity); + if(spawn_spot.target == "") // Emergency: this wasn't a real spawnpoint. Can this ever happen? - race_PreparePlayer(this); + race_PreparePlayer(player); // if we need to respawn, do it right - self.race_respawn_checkpoint = self.race_checkpoint; - self.race_respawn_spotref = spawn_spot; + player.race_respawn_checkpoint = player.race_checkpoint; + player.race_respawn_spotref = spawn_spot; - self.race_place = 0; + player.race_place = 0; return false; } MUTATOR_HOOKFUNCTION(cts, PutClientInServer) -{SELFPARAM(); - if(IS_PLAYER(self)) +{ + entity player = M_ARGV(0, entity); + + if(IS_PLAYER(player)) if(!gameover) { - if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn - race_PreparePlayer(this); + if(player.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn + race_PreparePlayer(player); else // respawn - race_RetractPlayer(this); + race_RetractPlayer(player); - race_AbandonRaceCheck(self); + race_AbandonRaceCheck(player); } return false; } diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 84d7200b5..abee018be 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -507,12 +507,14 @@ MUTATOR_HOOKFUNCTION(dom, reset_map_players) } MUTATOR_HOOKFUNCTION(dom, PlayerSpawn) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + if(domination_roundbased) if(!round_handler_IsRoundStarted()) - self.player_blocked = 1; + player.player_blocked = 1; else - self.player_blocked = 0; + player.player_blocked = 0; return false; } diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index 5e11666b8..7700e074a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -428,13 +428,15 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies) } MUTATOR_HOOKFUNCTION(ft, PlayerSpawn) -{SELFPARAM(); - if(self.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players +{ + entity player = M_ARGV(0, entity); + + if(player.freezetag_frozen_timeout == -1) // if PlayerSpawn is called by reset_map_players return 1; // do nothing, round is starting right now - if(self.freezetag_frozen_timeout == -2) // player was dead + if(player.freezetag_frozen_timeout == -2) // player was dead { - freezetag_Freeze(world); + WITHSELF(player, freezetag_Freeze(world)); return 1; } @@ -443,8 +445,8 @@ MUTATOR_HOOKFUNCTION(ft, PlayerSpawn) if(round_handler_IsActive()) if(round_handler_IsRoundStarted()) { - Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE); - freezetag_Freeze(world); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_SPAWN_LATE); + WITHSELF(player, freezetag_Freeze(world)); } return 1; diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index 6fcfc1913..db4f85731 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -396,8 +396,10 @@ MUTATOR_HOOKFUNCTION(inv, PlayerRegen) } MUTATOR_HOOKFUNCTION(inv, PlayerSpawn) -{SELFPARAM(); - self.bot_attack = false; +{ + entity player = M_ARGV(0, entity); + + player.bot_attack = false; return false; } diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index 98eb9cdcf..dac0e148a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -168,13 +168,15 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_players) } MUTATOR_HOOKFUNCTION(lms, PutClientInServer) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + // player is dead and becomes observer // FIXME fix LMS scoring for new system - if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0) + if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0) { - TRANSMUTE(Observer, self); - Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES); + TRANSMUTE(Observer, player); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_LMS_NOLIVES); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index fc87ae979..95a97db50 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -286,31 +286,36 @@ MUTATOR_HOOKFUNCTION(rc, MakePlayerObserver) } MUTATOR_HOOKFUNCTION(rc, PlayerSpawn) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + entity spawn_spot = M_ARGV(1, entity); + if(spawn_spot.target == "") // Emergency: this wasn't a real spawnpoint. Can this ever happen? - race_PreparePlayer(this); + race_PreparePlayer(player); // if we need to respawn, do it right - self.race_respawn_checkpoint = self.race_checkpoint; - self.race_respawn_spotref = spawn_spot; + player.race_respawn_checkpoint = player.race_checkpoint; + player.race_respawn_spotref = spawn_spot; - self.race_place = 0; + player.race_place = 0; return false; } MUTATOR_HOOKFUNCTION(rc, PutClientInServer) -{SELFPARAM(); - if(IS_PLAYER(self)) +{ + entity player = M_ARGV(0, entity); + + if(IS_PLAYER(player)) if(!gameover) { - if(self.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn - race_PreparePlayer(this); + if(player.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn + race_PreparePlayer(player); else // respawn - race_RetractPlayer(this); + race_RetractPlayer(player); - race_AbandonRaceCheck(self); + race_AbandonRaceCheck(player); } return false; } -- 2.39.2