From df665474154273d055a2489359282d4e0e053cd8 Mon Sep 17 00:00:00 2001
From: TimePath <andrew.hardaker1995@gmail.com>
Date: Sat, 14 Nov 2015 20:45:48 +1100
Subject: [PATCH] Reset: `this` param

---
 .../gamemodes/gamemode/nexball/nexball.qc     |  10 +-
 .../gamemodes/gamemode/onslaught/onslaught.qc |  90 +++++------
 qcsrc/common/monsters/monster/shambler.qc     |   2 +-
 qcsrc/common/monsters/sv_monsters.qc          |  28 ++--
 qcsrc/common/mutators/mutator/buffs/buffs.qc  |  14 +-
 qcsrc/common/mutators/mutator/nades/nades.qc  |   2 +-
 .../mutators/mutator/overkill/overkill.qc     |   8 +-
 qcsrc/common/net_notice.qc                    |   2 +-
 qcsrc/common/triggers/func/breakable.qc       | 104 ++++++-------
 qcsrc/common/triggers/func/conveyor.qc        |  31 ++--
 qcsrc/common/triggers/func/door.qc            | 114 +++++++-------
 qcsrc/common/triggers/func/door_rotating.qc   |  14 +-
 qcsrc/common/triggers/func/door_secret.qc     |  70 ++++-----
 qcsrc/common/triggers/func/plat.qc            | 147 +++++++++---------
 qcsrc/common/triggers/func/pointparticles.qc  |  60 +++----
 qcsrc/common/triggers/misc/laser.qc           |  74 ++++-----
 qcsrc/common/triggers/platforms.qc            |  18 +--
 qcsrc/common/triggers/subs.qh                 |   1 -
 qcsrc/common/triggers/target/music.qc         |  35 ++---
 qcsrc/common/triggers/target/speaker.qc       |  12 +-
 qcsrc/common/triggers/trigger/counter.qc      |   8 +-
 qcsrc/common/triggers/trigger/delay.qc        |   8 +-
 qcsrc/common/triggers/trigger/flipflop.qc     |  10 +-
 qcsrc/common/triggers/trigger/gamestart.qc    |  16 +-
 qcsrc/common/triggers/trigger/jumppads.qc     |  44 +++---
 qcsrc/common/triggers/trigger/monoflop.qc     |   8 +-
 qcsrc/common/triggers/trigger/multi.qc        |  22 +--
 qcsrc/common/triggers/trigger/multi.qh        |   2 +-
 qcsrc/common/triggers/trigger/relay.qc        |   6 +-
 .../triggers/trigger/relay_teamcheck.qc       |  12 +-
 qcsrc/common/turrets/util.qc                  |   1 -
 qcsrc/common/vehicles/sv_vehicles.qc          |   4 +-
 qcsrc/common/weapons/weapon/blaster.qc        |   8 +-
 qcsrc/common/weapons/weapon/crylink.qc        |   8 +-
 qcsrc/common/weapons/weapon/hlac.qc           |   4 +-
 qcsrc/common/weapons/weapon/machinegun.qc     |  16 +-
 qcsrc/common/weapons/weapon/seeker.qc         |   2 +-
 qcsrc/common/weapons/weapon/shotgun.qc        |   2 +-
 qcsrc/common/weapons/weapon/vaporizer.qc      |   2 +-
 qcsrc/lib/defer.qh                            |  18 +--
 qcsrc/lib/net.qh                              |   2 +-
 qcsrc/lib/spawnfunc.qh                        |  13 +-
 qcsrc/lib/warpzone/server.qc                  |   2 +-
 qcsrc/server/command/vote.qc                  |   2 +-
 qcsrc/server/defs.qh                          |   2 +-
 qcsrc/server/g_damage.qc                      |   2 +-
 qcsrc/server/g_hook.qc                        |  10 +-
 qcsrc/server/g_subs.qh                        |   8 -
 qcsrc/server/miscfunctions.qh                 |   1 -
 .../mutators/mutator/gamemode_assault.qc      |  26 ++--
 qcsrc/server/mutators/mutator/gamemode_ctf.qc |  11 +-
 .../mutators/mutator/gamemode_domination.qc   |  12 +-
 .../mutators/mutator/gamemode_invasion.qc     |   2 +-
 .../mutators/mutator/gamemode_keepaway.qc     |  15 +-
 .../mutators/mutator/gamemode_keyhunt.qc      |   8 +-
 qcsrc/server/pathlib/debug.qc                 |   6 +-
 qcsrc/server/pathlib/main.qc                  |   6 +-
 qcsrc/server/t_items.qc                       |   2 +-
 qcsrc/server/t_quake3.qc                      |   2 +-
 59 files changed, 567 insertions(+), 602 deletions(-)

diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
index b4becb3979..1850b460c7 100644
--- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
+++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
@@ -78,10 +78,10 @@ void LogNB(string mode, entity actor)
 	GameLogEcho(s);
 }
 
-void ball_restart()
-{SELFPARAM();
-	if(self.owner)
-		DropBall(self, self.owner.origin, '0 0 0');
+void ball_restart(entity this)
+{
+	if(this.owner)
+		DropBall(this, this.owner.origin, '0 0 0');
 	ResetBall();
 }
 
@@ -816,7 +816,7 @@ void W_Nexball_Attack2()
 	W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
 	missile.angles = vectoangles(missile.velocity);
 	missile.touch = W_Nexball_Touch;
-	missile.think = SUB_Remove;
+	missile.think = SUB_Remove_self;
 	missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead?
 
 	missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
index 04b5a3f7bf..ae62e5db79 100644
--- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
+++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
@@ -195,10 +195,10 @@ void ons_CaptureShield_Touch()
 	}
 }
 
-void ons_CaptureShield_Reset()
-{SELFPARAM();
-	self.colormap = self.enemy.colormap;
-	self.team = self.enemy.team;
+void ons_CaptureShield_Reset(entity this)
+{
+	this.colormap = this.enemy.colormap;
+	this.team = this.enemy.team;
 }
 
 void ons_CaptureShield_Spawn(entity generator, bool is_generator)
@@ -845,31 +845,31 @@ void ons_ControlPoint_Think()
 	CSQCMODEL_AUTOUPDATE(self);
 }
 
-void ons_ControlPoint_Reset()
-{SELFPARAM();
-	if(self.goalentity)
-		remove(self.goalentity);
-
-	self.goalentity = world;
-	self.team = 0;
-	self.colormap = 1024;
-	self.iscaptured = false;
-	self.islinked = false;
-	self.isshielded = true;
-	self.think = ons_ControlPoint_Think;
-	self.ons_toucher = world;
-	self.nextthink = time + ONS_CP_THINKRATE;
-	setmodel_fixsize(self, MDL_ONS_CP_PAD1);
-
-	WaypointSprite_UpdateMaxHealth(self.sprite, 0);
-	WaypointSprite_UpdateRule(self.sprite,self.team,SPRITERULE_TEAMPLAY);
+void ons_ControlPoint_Reset(entity this)
+{
+	if(this.goalentity)
+		remove(this.goalentity);
+
+	this.goalentity = world;
+	this.team = 0;
+	this.colormap = 1024;
+	this.iscaptured = false;
+	this.islinked = false;
+	this.isshielded = true;
+	this.think = ons_ControlPoint_Think;
+	this.ons_toucher = world;
+	this.nextthink = time + ONS_CP_THINKRATE;
+	setmodel_fixsize(this, MDL_ONS_CP_PAD1);
+
+	WaypointSprite_UpdateMaxHealth(this.sprite, 0);
+	WaypointSprite_UpdateRule(this.sprite,this.team,SPRITERULE_TEAMPLAY);
 
 	onslaught_updatelinks();
 
-	activator = self;
+	activator = this;
 	SUB_UseTargets(); // to reset the structures, playerspawns etc.
 
-	CSQCMODEL_AUTOUPDATE(self);
+	CSQCMODEL_AUTOUPDATE(this);
 }
 
 void ons_DelayedControlPoint_Setup()
@@ -1076,27 +1076,27 @@ void ons_GeneratorThink()
 	}
 }
 
-void ons_GeneratorReset()
-{SELFPARAM();
-	self.team = self.team_saved;
-	self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
-	self.takedamage = DAMAGE_AIM;
-	self.bot_attack = true;
-	self.iscaptured = true;
-	self.islinked = true;
-	self.isshielded = true;
-	self.event_damage = ons_GeneratorDamage;
-	self.think = ons_GeneratorThink;
-	self.nextthink = time + GEN_THINKRATE;
-
-	Net_LinkEntity(self, false, 0, generator_send);
-
-	self.SendFlags = GSF_SETUP; // just incase
-	self.SendFlags |= GSF_STATUS;
-
-	WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
-	WaypointSprite_UpdateHealth(self.sprite, self.health);
-	WaypointSprite_UpdateRule(self.sprite,self.team,SPRITERULE_TEAMPLAY);
+void ons_GeneratorReset(entity this)
+{
+	this.team = this.team_saved;
+	this.lasthealth = this.max_health = this.health = autocvar_g_onslaught_gen_health;
+	this.takedamage = DAMAGE_AIM;
+	this.bot_attack = true;
+	this.iscaptured = true;
+	this.islinked = true;
+	this.isshielded = true;
+	this.event_damage = ons_GeneratorDamage;
+	this.think = ons_GeneratorThink;
+	this.nextthink = time + GEN_THINKRATE;
+
+	Net_LinkEntity(this, false, 0, generator_send);
+
+	this.SendFlags = GSF_SETUP; // just incase
+	this.SendFlags |= GSF_STATUS;
+
+	WaypointSprite_UpdateMaxHealth(this.sprite, this.max_health);
+	WaypointSprite_UpdateHealth(this.sprite, this.health);
+	WaypointSprite_UpdateRule(this.sprite,this.team,SPRITERULE_TEAMPLAY);
 
 	onslaught_updatelinks();
 }
diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc
index 67b6808cc7..f30d36065f 100644
--- a/qcsrc/common/monsters/monster/shambler.qc
+++ b/qcsrc/common/monsters/monster/shambler.qc
@@ -107,7 +107,7 @@ void M_Shambler_Attack_Lightning_Explode()
 		Damage(head, self, self.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(self), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0');
 	}
 
-	self.think = SUB_Remove;
+	self.think = SUB_Remove_self;
 	self.nextthink = time + 0.2;
 }
 
diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc
index a3610e17f7..64ef0581de 100644
--- a/qcsrc/common/monsters/sv_monsters.qc
+++ b/qcsrc/common/monsters/sv_monsters.qc
@@ -207,7 +207,7 @@ void Monster_Delay_Action()
 	}
 	else
 	{
-		oldself.think = SUB_Remove;
+		oldself.think = SUB_Remove_self;
 		oldself.nextthink = time;
 	}
 }
@@ -955,19 +955,19 @@ float Monster_Appear_Check(entity ent, float monster_id)
 	return true;
 }
 
-void Monster_Reset()
-{SELFPARAM();
-	setorigin(self, self.pos1);
-	self.angles = self.pos2;
+void Monster_Reset(entity this)
+{
+	setorigin(this, this.pos1);
+	this.angles = this.pos2;
 
-	Unfreeze(self); // remove any icy remains
+	Unfreeze(this); // remove any icy remains
 
-	self.health = self.max_health;
-	self.velocity = '0 0 0';
-	self.enemy = world;
-	self.goalentity = world;
-	self.attack_finished_single[0] = 0;
-	self.moveto = self.origin;
+	this.health = this.max_health;
+	this.velocity = '0 0 0';
+	this.enemy = world;
+	this.goalentity = world;
+	this.attack_finished_single[0] = 0;
+	this.moveto = this.origin;
 }
 
 void Monster_Dead_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
@@ -983,7 +983,7 @@ void Monster_Dead_Damage(entity inflictor, entity attacker, float damage, int de
 		// number of monsters spawned with mobspawn command
 		totalspawned -= 1;
 
-		self.think = SUB_Remove;
+		self.think = SUB_Remove_self;
 		self.nextthink = time + 0.1;
 		self.event_damage = func_null;
 	}
@@ -1121,7 +1121,7 @@ void Monster_Damage(entity inflictor, entity attacker, float damage, int deathty
 		{
 			Violence_GibSplash(self, 1, 0.5, attacker);
 
-			self.think = SUB_Remove;
+			self.think = SUB_Remove_self;
 			self.nextthink = time + 0.1;
 		}
 	}
diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc
index 08f1aa3b50..9eb113a96f 100644
--- a/qcsrc/common/mutators/mutator/buffs/buffs.qc
+++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc
@@ -381,17 +381,17 @@ void buff_Waypoint_Reset()
 	if(self.buff_activetime) { buff_Waypoint_Spawn(self); }
 }
 
-void buff_Reset()
-{SELFPARAM();
+void buff_Reset(entity this)
+{
 	if(autocvar_g_buffs_randomize)
-		buff_NewType(self, self.buffs);
-	self.owner = world;
+		buff_NewType(this, this.buffs);
+	this.owner = world;
 	buff_SetCooldown(autocvar_g_buffs_cooldown_activate);
 	buff_Waypoint_Reset();
-	self.buff_activetime_updated = false;
+	this.buff_activetime_updated = false;
 
-	if(autocvar_g_buffs_random_location || (self.spawnflags & 64))
-		buff_Respawn(self);
+	if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
+		buff_Respawn(this);
 }
 
 float buff_Customize()
diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc
index ef021bbdcb..12a53ff139 100644
--- a/qcsrc/common/mutators/mutator/nades/nades.qc
+++ b/qcsrc/common/mutators/mutator/nades/nades.qc
@@ -958,7 +958,7 @@ void nade_prime()
 	fn.colormod = Nades_from(n.nade_type).m_color;
 	fn.colormap = self.colormap;
 	fn.glowmod = self.glowmod;
-	fn.think = SUB_Remove;
+	fn.think = SUB_Remove_self;
 	fn.nextthink = n.wait;
 
 	self.nade = n;
diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc
index c146f1c1a0..151e094c9e 100644
--- a/qcsrc/common/mutators/mutator/overkill/overkill.qc
+++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc
@@ -260,8 +260,8 @@ MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
 	return false;
 }
 
-void _spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); }
-void _spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); }
+void self_spawnfunc_weapon_hmg() { SELFPARAM(); spawnfunc_weapon_hmg(this); }
+void self_spawnfunc_weapon_rpc() { SELFPARAM(); spawnfunc_weapon_rpc(this); }
 
 MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
 {SELFPARAM();
@@ -279,7 +279,7 @@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
 			wep.team = self.team;
 			wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
 			wep.pickup_anyway = true;
-			wep.think = _spawnfunc_weapon_hmg;
+			wep.think = self_spawnfunc_weapon_hmg;
 			wep.nextthink = time + 0.1;
 			return true;
 		}
@@ -295,7 +295,7 @@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn)
 			wep.team = self.team;
 			wep.respawntime = autocvar_g_overkill_superguns_respawn_time;
 			wep.pickup_anyway = true;
-			wep.think = _spawnfunc_weapon_rpc;
+			wep.think = self_spawnfunc_weapon_rpc;
 			wep.nextthink = time + 0.1;
 			return true;
 		}
diff --git a/qcsrc/common/net_notice.qc b/qcsrc/common/net_notice.qc
index 63e318d2f7..5deb0960e2 100644
--- a/qcsrc/common/net_notice.qc
+++ b/qcsrc/common/net_notice.qc
@@ -103,7 +103,7 @@ float cl_notice_run()
 
         if(_notes.alpha <= time)
         {
-            _notes.think = SUB_Remove;
+            _notes.think = SUB_Remove_self;
             _notes.nextthink = time;
         }
 
diff --git a/qcsrc/common/triggers/func/breakable.qc b/qcsrc/common/triggers/func/breakable.qc
index e03e23ea73..6305c53402 100644
--- a/qcsrc/common/triggers/func/breakable.qc
+++ b/qcsrc/common/triggers/func/breakable.qc
@@ -264,85 +264,85 @@ void func_breakable_damage(entity inflictor, entity attacker, float damage, int
 	}
 }
 
-void func_breakable_reset()
-{SELFPARAM();
-	self.team = self.team_saved;
+void func_breakable_reset(entity this)
+{
+	this.team = this.team_saved;
 	func_breakable_look_restore();
-	if(self.spawnflags & 1)
+	if(this.spawnflags & 1)
 		func_breakable_behave_destroyed();
 	else
 		func_breakable_behave_restore();
 
-	CSQCMODEL_AUTOUPDATE(self);
+	CSQCMODEL_AUTOUPDATE(this);
 }
 
 // destructible walls that can be used to trigger target_objective_decrease
 spawnfunc(func_breakable)
 {
 	float n, i;
-	if(!self.health)
-		self.health = 100;
-	self.max_health = self.health;
+	if(!this.health)
+		this.health = 100;
+	this.max_health = this.health;
 
 	// yes, I know, MOVETYPE_NONE is not available here, not that one would want it here anyway
-	if(!self.debrismovetype) self.debrismovetype = MOVETYPE_BOUNCE;
-	if(!self.debrissolid) self.debrissolid = SOLID_NOT;
-	if(self.debrisvelocity == '0 0 0') self.debrisvelocity = '0 0 140';
-	if(self.debrisvelocityjitter == '0 0 0') self.debrisvelocityjitter = '70 70 70';
-	if(self.debrisavelocityjitter == '0 0 0') self.debrisavelocityjitter = '600 600 600';
-	if(!self.debristime) self.debristime = 3.5;
-	if(!self.debristimejitter) self.debristime = 2.5;
-
-	if(self.mdl != "")
-		self.cnt = _particleeffectnum(self.mdl);
-	if(self.count == 0)
-		self.count = 1;
-
-	if(self.message == "")
-		self.message = "got too close to an explosion";
-	if(self.message2 == "")
-		self.message2 = "was pushed into an explosion by";
-	if(!self.dmg_radius)
-		self.dmg_radius = 150;
-	if(!self.dmg_force)
-		self.dmg_force = 200;
-
-	self.mdl = self.model;
+	if(!this.debrismovetype) this.debrismovetype = MOVETYPE_BOUNCE;
+	if(!this.debrissolid) this.debrissolid = SOLID_NOT;
+	if(this.debrisvelocity == '0 0 0') this.debrisvelocity = '0 0 140';
+	if(this.debrisvelocityjitter == '0 0 0') this.debrisvelocityjitter = '70 70 70';
+	if(this.debrisavelocityjitter == '0 0 0') this.debrisavelocityjitter = '600 600 600';
+	if(!this.debristime) this.debristime = 3.5;
+	if(!this.debristimejitter) this.debristime = 2.5;
+
+	if(this.mdl != "")
+		this.cnt = _particleeffectnum(this.mdl);
+	if(this.count == 0)
+		this.count = 1;
+
+	if(this.message == "")
+		this.message = "got too close to an explosion";
+	if(this.message2 == "")
+		this.message2 = "was pushed into an explosion by";
+	if(!this.dmg_radius)
+		this.dmg_radius = 150;
+	if(!this.dmg_force)
+		this.dmg_force = 200;
+
+	this.mdl = this.model;
 	SetBrushEntityModel();
 
-	if(self.spawnflags & 4)
-		self.use = func_breakable_destroy;
+	if(this.spawnflags & 4)
+		this.use = func_breakable_destroy;
 	else
-		self.use = func_breakable_restore;
+		this.use = func_breakable_restore;
 
-	if(self.spawnflags & 4)
+	if(this.spawnflags & 4)
 	{
-		self.takedamage = DAMAGE_NO;
-		self.event_damage = func_null;
-		self.bot_attack = false;
+		this.takedamage = DAMAGE_NO;
+		this.event_damage = func_null;
+		this.bot_attack = false;
 	}
 
 	// precache all the models
-	if (self.mdl_dead)
-		precache_model(self.mdl_dead);
-	n = tokenize_console(self.debris);
+	if (this.mdl_dead)
+		precache_model(this.mdl_dead);
+	n = tokenize_console(this.debris);
 	for(i = 0; i < n; ++i)
 		precache_model(argv(i));
-	if(self.noise)
-		precache_sound(self.noise);
-	if(self.noise1)
-		precache_sound(self.noise1);
+	if(this.noise)
+		precache_sound(this.noise);
+	if(this.noise1)
+		precache_sound(this.noise1);
 
-	self.team_saved = self.team;
-	self.dropped_origin = self.origin;
+	this.team_saved = this.team;
+	this.dropped_origin = this.origin;
 
-	self.reset = func_breakable_reset;
-	func_breakable_reset();
+	this.reset = func_breakable_reset;
+	this.reset(this);
 
-	self.init_for_player_needed = 1;
-	self.init_for_player = func_breakable_init_for_player;
+	this.init_for_player_needed = 1;
+	this.init_for_player = func_breakable_init_for_player;
 
-	CSQCMODEL_AUTOINIT(self);
+	CSQCMODEL_AUTOINIT(this);
 }
 
 // for use in maps with a "model" key set
diff --git a/qcsrc/common/triggers/func/conveyor.qc b/qcsrc/common/triggers/func/conveyor.qc
index ac30dda43d..fb50a6613c 100644
--- a/qcsrc/common/triggers/func/conveyor.qc
+++ b/qcsrc/common/triggers/func/conveyor.qc
@@ -65,11 +65,11 @@ void conveyor_use()
 	self.SendFlags |= 2;
 }
 
-void conveyor_reset()
-{SELFPARAM();
-	self.state = (self.spawnflags & 1);
+void conveyor_reset(entity this)
+{
+	this.state = (this.spawnflags & 1);
 
-	self.SendFlags |= 2;
+	this.SendFlags |= 2;
 }
 
 bool conveyor_send(entity this, entity to, int sf)
@@ -110,25 +110,24 @@ bool conveyor_send(entity this, entity to, int sf)
 
 void conveyor_init()
 {SELFPARAM();
-	if (!self.speed)
-		self.speed = 200;
-	self.movedir = self.movedir * self.speed;
-	self.think = conveyor_think;
-	self.nextthink = time;
+	if (!this.speed) this.speed = 200;
+	this.movedir *= this.speed;
+	this.think = conveyor_think;
+	this.nextthink = time;
 	IFTARGETED
 	{
-		self.use = conveyor_use;
-		self.reset = conveyor_reset;
-		conveyor_reset();
+		this.use = conveyor_use;
+		this.reset = conveyor_reset;
+		this.reset(this);
 	}
 	else
-		self.state = 1;
+		this.state = 1;
 
-	FixSize(self);
+	FixSize(this);
 
-	Net_LinkEntity(self, 0, false, conveyor_send);
+	Net_LinkEntity(this, 0, false, conveyor_send);
 
-	self.SendFlags |= 1;
+	this.SendFlags |= 1;
 }
 
 spawnfunc(trigger_conveyor)
diff --git a/qcsrc/common/triggers/func/door.qc b/qcsrc/common/triggers/func/door.qc
index 6c82565566..c93ccc4881 100644
--- a/qcsrc/common/triggers/func/door.qc
+++ b/qcsrc/common/triggers/func/door.qc
@@ -704,16 +704,16 @@ void door_init_startopen()
 #endif
 }
 
-void door_reset()
-{SELFPARAM();
-	SUB_SETORIGIN(self, self.pos1);
-	self.SUB_VELOCITY = '0 0 0';
-	self.state = STATE_BOTTOM;
-	self.SUB_THINK = func_null;
-	self.SUB_NEXTTHINK = 0;
+void door_reset(entity this)
+{
+	SUB_SETORIGIN(this, this.pos1);
+	this.SUB_VELOCITY = '0 0 0';
+	this.state = STATE_BOTTOM;
+	this.SUB_THINK = func_null;
+	this.SUB_NEXTTHINK = 0;
 
 #ifdef SVQC
-	self.SendFlags |= SF_TRIGGER_RESET;
+	this.SendFlags |= SF_TRIGGER_RESET;
 #endif
 }
 
@@ -812,69 +812,75 @@ NET_HANDLE(ENT_CLIENT_DOOR, bool isnew)
 
 	if(sf & SF_TRIGGER_INIT)
 	{
-		self.classname = strzone(ReadString());
-		self.spawnflags = ReadByte();
+		this.classname = strzone(ReadString());
+		this.spawnflags = ReadByte();
 
-		self.mdl = strzone(ReadString());
-		_setmodel(self, self.mdl);
+		this.mdl = strzone(ReadString());
+		_setmodel(this, this.mdl);
 
 		trigger_common_read(true);
 
-		self.pos1_x = ReadCoord();
-		self.pos1_y = ReadCoord();
-		self.pos1_z = ReadCoord();
-		self.pos2_x = ReadCoord();
-		self.pos2_y = ReadCoord();
-		self.pos2_z = ReadCoord();
-
-		self.size_x = ReadCoord();
-		self.size_y = ReadCoord();
-		self.size_z = ReadCoord();
-
-		self.wait = ReadShort();
-		self.speed = ReadShort();
-		self.lip = ReadByte();
-		self.state = ReadByte();
-		self.SUB_LTIME = ReadCoord();
-
-		self.solid = SOLID_BSP;
-		self.movetype = MOVETYPE_PUSH;
-		self.trigger_touch = door_touch;
-		self.draw = door_draw;
-		self.drawmask = MASK_NORMAL;
-		self.use = door_use;
+		vector v;
+
+		v.x = ReadCoord();
+		v.y = ReadCoord();
+		v.z = ReadCoord();
+		this.pos1 = v;
+
+		v.x = ReadCoord();
+		v.y = ReadCoord();
+		v.z = ReadCoord();
+		this.pos2 = v;
+
+		v.x = ReadCoord();
+		v.y = ReadCoord();
+		v.z = ReadCoord();
+		this.size = v;
+
+		this.wait = ReadShort();
+		this.speed = ReadShort();
+		this.lip = ReadByte();
+		this.state = ReadByte();
+		this.SUB_LTIME = ReadCoord();
+
+		this.solid = SOLID_BSP;
+		this.movetype = MOVETYPE_PUSH;
+		this.trigger_touch = door_touch;
+		this.draw = door_draw;
+		this.drawmask = MASK_NORMAL;
+		this.use = door_use;
 
 		LinkDoors();
 
-		if(self.spawnflags & DOOR_START_OPEN)
+		if(this.spawnflags & DOOR_START_OPEN)
 			door_init_startopen();
 
-		self.move_time = time;
-		self.move_origin = self.origin;
-		self.move_movetype = MOVETYPE_PUSH;
-		self.move_angles = self.angles;
-		self.move_blocked = door_blocked;
+		this.move_time = time;
+		this.move_origin = this.origin;
+		this.move_movetype = MOVETYPE_PUSH;
+		this.move_angles = this.angles;
+		this.move_blocked = door_blocked;
 	}
 
 	if(sf & SF_TRIGGER_RESET)
 	{
-		door_reset();
+		door_reset(this);
 	}
 
 	if(sf & SF_TRIGGER_UPDATE)
 	{
-		self.origin_x = ReadCoord();
-		self.origin_y = ReadCoord();
-		self.origin_z = ReadCoord();
-		setorigin(self, self.origin);
-		self.move_origin = self.origin;
-
-		self.pos1_x = ReadCoord();
-		self.pos1_y = ReadCoord();
-		self.pos1_z = ReadCoord();
-		self.pos2_x = ReadCoord();
-		self.pos2_y = ReadCoord();
-		self.pos2_z = ReadCoord();
+		this.origin_x = ReadCoord();
+		this.origin_y = ReadCoord();
+		this.origin_z = ReadCoord();
+		setorigin(this, this.origin);
+		this.move_origin = this.origin;
+
+		this.pos1_x = ReadCoord();
+		this.pos1_y = ReadCoord();
+		this.pos1_z = ReadCoord();
+		this.pos2_x = ReadCoord();
+		this.pos2_y = ReadCoord();
+		this.pos2_z = ReadCoord();
 	}
 	return true;
 }
diff --git a/qcsrc/common/triggers/func/door_rotating.qc b/qcsrc/common/triggers/func/door_rotating.qc
index e01a7e73e2..4f88e9e9b5 100644
--- a/qcsrc/common/triggers/func/door_rotating.qc
+++ b/qcsrc/common/triggers/func/door_rotating.qc
@@ -27,13 +27,13 @@ START_OPEN causes the door to move to its destination when spawned, and operate
 FIXME: only one sound set available at the time being
 */
 
-void door_rotating_reset()
-{SELFPARAM();
-	self.angles = self.pos1;
-	self.avelocity = '0 0 0';
-	self.state = STATE_BOTTOM;
-	self.think = func_null;
-	self.nextthink = 0;
+void door_rotating_reset(entity this)
+{
+	this.angles = this.pos1;
+	this.avelocity = '0 0 0';
+	this.state = STATE_BOTTOM;
+	this.think = func_null;
+	this.nextthink = 0;
 }
 
 void door_rotating_init_startopen()
diff --git a/qcsrc/common/triggers/func/door_secret.qc b/qcsrc/common/triggers/func/door_secret.qc
index 4d6b9b48a1..3fabc3fb1d 100644
--- a/qcsrc/common/triggers/func/door_secret.qc
+++ b/qcsrc/common/triggers/func/door_secret.qc
@@ -167,16 +167,16 @@ void secret_touch()
 	}
 }
 
-void secret_reset()
-{SELFPARAM();
-	if (self.spawnflags&SECRET_YES_SHOOT)
+void secret_reset(entity this)
+{
+	if (this.spawnflags & SECRET_YES_SHOOT)
 	{
-		self.health = 10000;
-		self.takedamage = DAMAGE_YES;
+		this.health = 10000;
+		this.takedamage = DAMAGE_YES;
 	}
-	setorigin(self, self.oldorigin);
-	self.think = func_null;
-	self.SUB_NEXTTHINK = 0;
+	setorigin(this, this.oldorigin);
+	this.think = func_null;
+	this.SUB_NEXTTHINK = 0;
 }
 
 /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
@@ -198,45 +198,41 @@ If a secret door has a targetname, it will only be opened by it's botton or trig
 
 spawnfunc(func_door_secret)
 {
-	/*if (!self.deathtype) // map makers can override this
-		self.deathtype = " got in the way";*/
+	/*if (!this.deathtype) // map makers can override this
+		this.deathtype = " got in the way";*/
 
-	if (!self.dmg)
-		self.dmg = 2;
+	if (!this.dmg) this.dmg = 2;
 
 	// Magic formula...
-	self.mangle = self.angles;
-	self.angles = '0 0 0';
-	self.classname = "door";
-	if (!InitMovingBrushTrigger())
-		return;
-	self.effects |= EF_LOWPRECISION;
-
-	if(self.noise == "")
-		self.noise = "misc/talk.wav";
-	precache_sound(self.noise);
-
-	self.touch = secret_touch;
-	self.blocked = secret_blocked;
-	self.speed = 50;
-	self.use = fd_secret_use;
+	this.mangle = this.angles;
+	this.angles = '0 0 0';
+	this.classname = "door";
+	if (!InitMovingBrushTrigger()) return;
+	this.effects |= EF_LOWPRECISION;
+
+	if (this.noise == "") this.noise = "misc/talk.wav";
+	precache_sound(this.noise);
+
+	this.touch = secret_touch;
+	this.blocked = secret_blocked;
+	this.speed = 50;
+	this.use = fd_secret_use;
 	IFTARGETED
 	{
 	}
 	else
-		self.spawnflags |= SECRET_YES_SHOOT;
+		this.spawnflags |= SECRET_YES_SHOOT;
 
-	if(self.spawnflags&SECRET_YES_SHOOT)
+	if (this.spawnflags & SECRET_YES_SHOOT)
 	{
-		self.health = 10000;
-		self.takedamage = DAMAGE_YES;
-		self.event_damage = fd_secret_damage;
+		this.health = 10000;
+		this.takedamage = DAMAGE_YES;
+		this.event_damage = fd_secret_damage;
 	}
-	self.oldorigin = self.origin;
-	if (!self.wait)
-		self.wait = 5;		// 5 seconds before closing
+	this.oldorigin = this.origin;
+	if (!this.wait) this.wait = 5; // seconds before closing
 
-	self.reset = secret_reset;
-	secret_reset();
+	this.reset = secret_reset;
+	this.reset(this);
 }
 #endif
diff --git a/qcsrc/common/triggers/func/plat.qc b/qcsrc/common/triggers/func/plat.qc
index cb2cc3a49c..a419e62106 100644
--- a/qcsrc/common/triggers/func/plat.qc
+++ b/qcsrc/common/triggers/func/plat.qc
@@ -63,70 +63,63 @@ void plat_link()
 
 spawnfunc(func_plat)
 {
-	if (self.sounds == 0)
-		self.sounds = 2;
+	if (this.sounds == 0) this.sounds = 2;
 
-    if(self.spawnflags & 4)
-        self.dmg = 10000;
+    if (this.spawnflags & 4) this.dmg = 10000;
 
-    if(self.dmg && (self.message == ""))
-		self.message = "was squished";
-    if(self.dmg && (self.message2 == ""))
-		self.message2 = "was squished by";
+    if (this.dmg && (this.message == "")) this.message = "was squished";
+    if (this.dmg && (this.message2 == "")) this.message2 = "was squished by";
 
-	if (self.sounds == 1)
+	if (this.sounds == 1)
 	{
 		precache_sound ("plats/plat1.wav");
 		precache_sound ("plats/plat2.wav");
-		self.noise = "plats/plat1.wav";
-		self.noise1 = "plats/plat2.wav";
+		this.noise = "plats/plat1.wav";
+		this.noise1 = "plats/plat2.wav";
 	}
 
-	if (self.sounds == 2)
+	if (this.sounds == 2)
 	{
 		precache_sound ("plats/medplat1.wav");
 		precache_sound ("plats/medplat2.wav");
-		self.noise = "plats/medplat1.wav";
-		self.noise1 = "plats/medplat2.wav";
+		this.noise = "plats/medplat1.wav";
+		this.noise1 = "plats/medplat2.wav";
 	}
 
-	if (self.sound1)
+	if (this.sound1)
 	{
-		precache_sound (self.sound1);
-		self.noise = self.sound1;
+		precache_sound (this.sound1);
+		this.noise = this.sound1;
 	}
-	if (self.sound2)
+	if (this.sound2)
 	{
-		precache_sound (self.sound2);
-		self.noise1 = self.sound2;
+		precache_sound (this.sound2);
+		this.noise1 = this.sound2;
 	}
 
-	self.mangle = self.angles;
-	self.angles = '0 0 0';
+	this.mangle = this.angles;
+	this.angles = '0 0 0';
 
-	self.classname = "plat";
+	this.classname = "plat";
 	if (!InitMovingBrushTrigger())
 		return;
-	self.effects |= EF_LOWPRECISION;
-	setsize (self, self.mins , self.maxs);
+	this.effects |= EF_LOWPRECISION;
+	setsize (this, this.mins , this.maxs);
 
-	self.blocked = plat_crush;
+	this.blocked = plat_crush;
 
-	if (!self.speed)
-		self.speed = 150;
-	if (!self.lip)
-		self.lip = 16;
-	if (!self.height)
-		self.height = self.size_z - self.lip;
+	if (!this.speed) this.speed = 150;
+	if (!this.lip) this.lip = 16;
+	if (!this.height) this.height = this.size.z - this.lip;
 
-	self.pos1 = self.origin;
-	self.pos2 = self.origin;
-	self.pos2_z = self.origin_z - self.height;
+	this.pos1 = this.origin;
+	this.pos2 = this.origin;
+	this.pos2_z = this.origin.z - this.height;
 
-	self.reset = plat_reset;
-	plat_reset();
+	this.reset = plat_reset;
+	this.reset(this);
 
-	InitializeEntity(self, plat_delayedinit, INITPRIO_FINDTARGET);
+	InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET);
 }
 #elif defined(CSQC)
 void plat_draw(entity this)
@@ -141,63 +134,63 @@ NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
 
 	if(sf & SF_TRIGGER_INIT)
 	{
-		self.platmovetype_start = ReadByte();
-		self.platmovetype_turn = ReadByte();
-		self.platmovetype_end = ReadByte();
-		self.spawnflags = ReadByte();
+		this.platmovetype_start = ReadByte();
+		this.platmovetype_turn = ReadByte();
+		this.platmovetype_end = ReadByte();
+		this.spawnflags = ReadByte();
 
-		self.model = strzone(ReadString());
-		_setmodel(self, self.model);
+		this.model = strzone(ReadString());
+		_setmodel(this, this.model);
 
 		trigger_common_read(true);
 
-		self.pos1_x = ReadCoord();
-		self.pos1_y = ReadCoord();
-		self.pos1_z = ReadCoord();
-		self.pos2_x = ReadCoord();
-		self.pos2_y = ReadCoord();
-		self.pos2_z = ReadCoord();
+		this.pos1_x = ReadCoord();
+		this.pos1_y = ReadCoord();
+		this.pos1_z = ReadCoord();
+		this.pos2_x = ReadCoord();
+		this.pos2_y = ReadCoord();
+		this.pos2_z = ReadCoord();
 
-		self.size_x = ReadCoord();
-		self.size_y = ReadCoord();
-		self.size_z = ReadCoord();
+		this.size_x = ReadCoord();
+		this.size_y = ReadCoord();
+		this.size_z = ReadCoord();
 
-		self.mangle_x = ReadAngle();
-		self.mangle_y = ReadAngle();
-		self.mangle_z = ReadAngle();
+		this.mangle_x = ReadAngle();
+		this.mangle_y = ReadAngle();
+		this.mangle_z = ReadAngle();
 
-		self.speed = ReadShort();
-		self.height = ReadShort();
-		self.lip = ReadByte();
-		self.state = ReadByte();
+		this.speed = ReadShort();
+		this.height = ReadShort();
+		this.lip = ReadByte();
+		this.state = ReadByte();
 
-		self.dmg = ReadShort();
+		this.dmg = ReadShort();
 
-		self.classname = "plat";
-		self.solid = SOLID_BSP;
-		self.movetype = MOVETYPE_PUSH;
-		self.drawmask = MASK_NORMAL;
-		self.draw = plat_draw;
-		self.use = plat_use;
-		self.entremove = trigger_remove_generic;
+		this.classname = "plat";
+		this.solid = SOLID_BSP;
+		this.movetype = MOVETYPE_PUSH;
+		this.drawmask = MASK_NORMAL;
+		this.draw = plat_draw;
+		this.use = plat_use;
+		this.entremove = trigger_remove_generic;
 
-		plat_reset(); // also called here
+		plat_reset(this); // also called here
 
-		self.move_movetype = MOVETYPE_PUSH;
-		self.move_origin = self.origin;
-		self.move_angles = self.angles;
-		self.move_time = time;
+		this.move_movetype = MOVETYPE_PUSH;
+		this.move_origin = this.origin;
+		this.move_angles = this.angles;
+		this.move_time = time;
 
 		plat_spawn_inside_trigger();
 	}
 
 	if(sf & SF_TRIGGER_RESET)
 	{
-		plat_reset();
+		plat_reset(this);
 
-		self.move_origin = self.origin;
-		self.move_angles = self.angles;
-		self.move_time = time;
+		this.move_origin = this.origin;
+		this.move_angles = this.angles;
+		this.move_time = time;
 	}
 	return true;
 }
diff --git a/qcsrc/common/triggers/func/pointparticles.qc b/qcsrc/common/triggers/func/pointparticles.qc
index ef42c93eb0..c3a059aa24 100644
--- a/qcsrc/common/triggers/func/pointparticles.qc
+++ b/qcsrc/common/triggers/func/pointparticles.qc
@@ -102,57 +102,47 @@ void pointparticles_think()
 	self.nextthink = time;
 }
 
-void pointparticles_reset()
-{SELFPARAM();
-	if(self.spawnflags & 1)
-		self.state = 1;
+void pointparticles_reset(entity this)
+{
+	if(this.spawnflags & 1)
+		this.state = 1;
 	else
-		self.state = 0;
+		this.state = 0;
 }
 
 spawnfunc(func_pointparticles)
 {
-	if(self.model != "")
-		_setmodel(self, self.model);
-	if(self.noise != "")
-		precache_sound (self.noise);
+	if(this.model != "") _setmodel(this, this.model);
+	if(this.noise != "") precache_sound(this.noise);
 
-	if(!self.bgmscriptsustain)
-		self.bgmscriptsustain = 1;
-	else if(self.bgmscriptsustain < 0)
-		self.bgmscriptsustain = 0;
+	if(!this.bgmscriptsustain) this.bgmscriptsustain = 1;
+	else if(this.bgmscriptsustain < 0) this.bgmscriptsustain = 0;
 
-	if(!self.atten)
-		self.atten = ATTEN_NORM;
-	else if(self.atten < 0)
-		self.atten = 0;
-	if(!self.volume)
-		self.volume = 1;
-	if(!self.count)
-		self.count = 1;
-	if(!self.impulse)
-		self.impulse = 1;
+	if(!this.atten) this.atten = ATTEN_NORM;
+	else if(this.atten < 0) this.atten = 0;
+	if(!this.volume) this.volume = 1;
+	if(!this.count) this.count = 1;
+	if(!this.impulse) this.impulse = 1;
 
-	if(!self.modelindex)
+	if(!this.modelindex)
 	{
-		setorigin(self, self.origin + self.mins);
-		setsize(self, '0 0 0', self.maxs - self.mins);
+		setorigin(this, this.origin + this.mins);
+		setsize(this, '0 0 0', this.maxs - this.mins);
 	}
-	if(!self.cnt)
-		self.cnt = _particleeffectnum(self.mdl);
+	if(!this.cnt) this.cnt = _particleeffectnum(this.mdl);
 
-	Net_LinkEntity(self, (self.spawnflags & 4), 0, pointparticles_SendEntity);
+	Net_LinkEntity(this, (this.spawnflags & 4), 0, pointparticles_SendEntity);
 
 	IFTARGETED
 	{
-		self.use = pointparticles_use;
-		self.reset = pointparticles_reset;
-		self.reset();
+		this.use = pointparticles_use;
+		this.reset = pointparticles_reset;
+		this.reset(this);
 	}
 	else
-		self.state = 1;
-	self.think = pointparticles_think;
-	self.nextthink = time;
+		this.state = 1;
+	this.think = pointparticles_think;
+	this.nextthink = time;
 }
 
 spawnfunc(func_sparks)
diff --git a/qcsrc/common/triggers/misc/laser.qc b/qcsrc/common/triggers/misc/laser.qc
index 8bfa35f40d..8fe240f6f7 100644
--- a/qcsrc/common/triggers/misc/laser.qc
+++ b/qcsrc/common/triggers/misc/laser.qc
@@ -195,67 +195,61 @@ void laser_use()
 	misc_laser_aim();
 }
 
-void laser_reset()
-{SELFPARAM();
-	if(self.spawnflags & 1)
-		self.state = 1;
+void laser_reset(entity this)
+{
+	if(this.spawnflags & 1)
+		this.state = 1;
 	else
-		self.state = 0;
+		this.state = 0;
 }
 
 spawnfunc(misc_laser)
 {
-	if(self.mdl)
+	if(this.mdl)
 	{
-		if(self.mdl == "none")
-			self.cnt = -1;
+		if(this.mdl == "none")
+			this.cnt = -1;
 		else
 		{
-			self.cnt = _particleeffectnum(self.mdl);
-			if(self.cnt < 0)
-				if(self.dmg)
-					self.cnt = particleeffectnum(EFFECT_LASER_DEADLY);
+			this.cnt = _particleeffectnum(this.mdl);
+			if(this.cnt < 0 && this.dmg)
+                this.cnt = particleeffectnum(EFFECT_LASER_DEADLY);
 		}
 	}
-	else if(!self.cnt)
+	else if(!this.cnt)
 	{
-		if(self.dmg)
-			self.cnt = particleeffectnum(EFFECT_LASER_DEADLY);
+		if(this.dmg)
+			this.cnt = particleeffectnum(EFFECT_LASER_DEADLY);
 		else
-			self.cnt = -1;
+			this.cnt = -1;
 	}
-	if(self.cnt < 0)
-		self.cnt = -1;
+	if(this.cnt < 0)
+		this.cnt = -1;
 
-	if(self.colormod == '0 0 0')
-		if(!self.alpha)
-			self.colormod = '1 0 0';
-	if(self.message == "")
-		self.message = "saw the light";
-	if (self.message2 == "")
-		self.message2 = "was pushed into a laser by";
-	if(!self.scale)
-		self.scale = 1;
-	if(!self.modelscale)
-		self.modelscale = 1;
-	else if(self.modelscale < 0)
-		self.modelscale = 0;
-	self.think = misc_laser_think;
-	self.nextthink = time;
-	InitializeEntity(self, misc_laser_init, INITPRIO_FINDTARGET);
+	if(this.colormod == '0 0 0')
+		if(!this.alpha)
+			this.colormod = '1 0 0';
+	if(this.message == "") this.message = "saw the light";
+	if (this.message2 == "") this.message2 = "was pushed into a laser by";
+	if(!this.scale) this.scale = 1;
+	if(!this.modelscale) this.modelscale = 1;
+	else if(this.modelscale < 0) this.modelscale = 0;
+	this.think = misc_laser_think;
+	this.nextthink = time;
+	InitializeEntity(this, misc_laser_init, INITPRIO_FINDTARGET);
 
-	self.mangle = self.angles;
+	this.mangle = this.angles;
 
-	Net_LinkEntity(self, false, 0, laser_SendEntity);
+	Net_LinkEntity(this, false, 0, laser_SendEntity);
 
 	IFTARGETED
 	{
-		self.reset = laser_reset;
-		laser_reset();
-		self.use = laser_use;
+		this.reset = laser_reset;
+		this.reset(this);
+		this.use = laser_use;
 	}
 	else
-		self.state = 1;
+		this.state = 1;
 }
 #elif defined(CSQC)
 
diff --git a/qcsrc/common/triggers/platforms.qc b/qcsrc/common/triggers/platforms.qc
index 1c8a8bbad4..11f0bd0024 100644
--- a/qcsrc/common/triggers/platforms.qc
+++ b/qcsrc/common/triggers/platforms.qc
@@ -185,23 +185,23 @@ void plat_use()
 
 .string sound1, sound2;
 
-void plat_reset()
-{SELFPARAM();
+void plat_reset(entity this)
+{
 	IFTARGETED
 	{
-		setorigin (self, self.pos1);
-		self.state = 4;
-		self.use = plat_use;
+		setorigin (this, this.pos1);
+		this.state = 4;
+		this.use = plat_use;
 	}
 	else
 	{
-		setorigin (self, self.pos2);
-		self.state = 2;
-		self.use = plat_trigger_use;
+		setorigin (this, this.pos2);
+		this.state = 2;
+		this.use = plat_trigger_use;
 	}
 
 #ifdef SVQC
-	self.SendFlags |= SF_TRIGGER_RESET;
+	this.SendFlags |= SF_TRIGGER_RESET;
 #endif
 }
 
diff --git a/qcsrc/common/triggers/subs.qh b/qcsrc/common/triggers/subs.qh
index 95cc59904a..e3b9c2e696 100644
--- a/qcsrc/common/triggers/subs.qh
+++ b/qcsrc/common/triggers/subs.qh
@@ -36,7 +36,6 @@
 
 #endif
 
-void SUB_Remove();
 void SUB_SetFade (entity ent, float when, float fading_time);
 void SUB_VanishOrRemove (entity ent);
 
diff --git a/qcsrc/common/triggers/target/music.qc b/qcsrc/common/triggers/target/music.qc
index 283b8afb47..3f38914f47 100644
--- a/qcsrc/common/triggers/target/music.qc
+++ b/qcsrc/common/triggers/target/music.qc
@@ -30,10 +30,9 @@ void target_music_sendto(float to, float is)
 	WriteByte(to, self.lifetime);
 	WriteString(to, self.noise);
 }
-void target_music_reset()
-{SELFPARAM();
-	if(self.targetname == "")
-		target_music_sendto(MSG_ALL, 1);
+void target_music_reset(entity this)
+{
+	if (this.targetname == "") target_music_sendto(MSG_ALL, 1);
 }
 void target_music_kill()
 {
@@ -127,10 +126,10 @@ bool trigger_music_SendEntity(entity this, entity to, float sf)
 	}
 	return 1;
 }
-void trigger_music_reset()
-{SELFPARAM();
-	self.cnt = !(self.spawnflags & 1);
-	self.SendFlags |= 0x80;
+void trigger_music_reset(entity this)
+{
+	this.cnt = !(this.spawnflags & 1);
+	this.SendFlags |= 0x80;
 }
 void trigger_music_use()
 {SELFPARAM();
@@ -139,21 +138,19 @@ void trigger_music_use()
 }
 spawnfunc(trigger_music)
 {
-	if(self.model != "")
-		_setmodel(self, self.model);
-	if(!self.volume)
-		self.volume = 1;
-	if(!self.modelindex)
+	if(this.model != "") _setmodel(this, this.model);
+	if(!this.volume) this.volume = 1;
+	if(!this.modelindex)
 	{
-		setorigin(self, self.origin + self.mins);
-		setsize(self, '0 0 0', self.maxs - self.mins);
+		setorigin(this, this.origin + this.mins);
+		setsize(this, '0 0 0', this.maxs - this.mins);
 	}
-	trigger_music_reset();
+	trigger_music_reset(this);
 
-	self.use = trigger_music_use;
-	self.reset = trigger_music_reset;
+	this.use = trigger_music_use;
+	this.reset = trigger_music_reset;
 
-	Net_LinkEntity(self, false, 0, trigger_music_SendEntity);
+	Net_LinkEntity(this, false, 0, trigger_music_SendEntity);
 }
 #elif defined(CSQC)
 
diff --git a/qcsrc/common/triggers/target/speaker.qc b/qcsrc/common/triggers/target/speaker.qc
index 0b3767ff65..3c43b0e9ea 100644
--- a/qcsrc/common/triggers/target/speaker.qc
+++ b/qcsrc/common/triggers/target/speaker.qc
@@ -61,16 +61,16 @@ void target_speaker_use_off()
 	sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASE * self.volume, self.atten);
 	self.use = target_speaker_use_on;
 }
-void target_speaker_reset()
-{SELFPARAM();
-	if(self.spawnflags & 1) // LOOPED_ON
+void target_speaker_reset(entity this)
+{
+	if(this.spawnflags & 1) // LOOPED_ON
 	{
-		if(self.use == target_speaker_use_on)
+		if(this.use == target_speaker_use_on)
 			target_speaker_use_on();
 	}
-	else if(self.spawnflags & 2)
+	else if(this.spawnflags & 2)
 	{
-		if(self.use == target_speaker_use_off)
+		if(this.use == target_speaker_use_off)
 			target_speaker_use_off();
 	}
 }
diff --git a/qcsrc/common/triggers/trigger/counter.qc b/qcsrc/common/triggers/trigger/counter.qc
index 41f9f79ecc..d5811e479e 100644
--- a/qcsrc/common/triggers/trigger/counter.qc
+++ b/qcsrc/common/triggers/trigger/counter.qc
@@ -23,10 +23,10 @@ void counter_use()
 	}
 }
 
-void counter_reset()
-{SELFPARAM();
-	self.count = self.cnt;
-	multi_reset();
+void counter_reset(entity this)
+{
+	this.count = this.cnt;
+	multi_reset(this);
 }
 
 /*QUAKED spawnfunc_trigger_counter (.5 .5 .5) ? nomessage
diff --git a/qcsrc/common/triggers/trigger/delay.qc b/qcsrc/common/triggers/trigger/delay.qc
index eb0c0af775..fb341ebb77 100644
--- a/qcsrc/common/triggers/trigger/delay.qc
+++ b/qcsrc/common/triggers/trigger/delay.qc
@@ -5,10 +5,10 @@ void delay_use()
    self.nextthink = self.wait;
 }
 
-void delay_reset()
-{SELFPARAM();
-	self.think = func_null;
-	self.nextthink = 0;
+void delay_reset(entity this)
+{
+	this.think = func_null;
+	this.nextthink = 0;
 }
 
 spawnfunc(trigger_delay)
diff --git a/qcsrc/common/triggers/trigger/flipflop.qc b/qcsrc/common/triggers/trigger/flipflop.qc
index e039173fb0..d2549f6c50 100644
--- a/qcsrc/common/triggers/trigger/flipflop.qc
+++ b/qcsrc/common/triggers/trigger/flipflop.qc
@@ -9,14 +9,12 @@ void flipflop_use()
         SUB_UseTargets();
 }
 
-void _spawnfunc_trigger_flipflop();
 spawnfunc(trigger_flipflop)
 {
-    if(self.spawnflags & 1)
-        self.state = 1;
-    self.use = flipflop_use;
-    self.reset = _spawnfunc_trigger_flipflop; // perfect resetter
+    if(this.spawnflags & 1)
+        this.state = 1;
+    this.use = flipflop_use;
+    this.reset = spawnfunc_trigger_flipflop; // perfect resetter
 }
-void _spawnfunc_trigger_flipflop() { SELFPARAM(); spawnfunc_trigger_flipflop(this); }
 
 #endif
diff --git a/qcsrc/common/triggers/trigger/gamestart.qc b/qcsrc/common/triggers/trigger/gamestart.qc
index 30e6ebae70..d90e3418ca 100644
--- a/qcsrc/common/triggers/trigger/gamestart.qc
+++ b/qcsrc/common/triggers/trigger/gamestart.qc
@@ -6,20 +6,20 @@ void gamestart_use()
 	remove(self);
 }
 
-void _spawnfunc_trigger_gamestart();
+void self_spawnfunc_trigger_gamestart();
 spawnfunc(trigger_gamestart)
 {
-	self.use = gamestart_use;
-	self.reset2 = _spawnfunc_trigger_gamestart;
+	this.use = gamestart_use;
+	this.reset2 = self_spawnfunc_trigger_gamestart;
 
-	if(self.wait)
+	if(this.wait)
 	{
-		self.think = self.use;
-		self.nextthink = game_starttime + self.wait;
+		this.think = this.use;
+		this.nextthink = game_starttime + this.wait;
 	}
 	else
-		InitializeEntity(self, gamestart_use, INITPRIO_FINDTARGET);
+		InitializeEntity(this, gamestart_use, INITPRIO_FINDTARGET);
 }
-void _spawnfunc_trigger_gamestart() { SELFPARAM(); spawnfunc_trigger_gamestart(this); }
+void self_spawnfunc_trigger_gamestart() { SELFPARAM(); spawnfunc_trigger_gamestart(this); }
 
 #endif
diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc
index 0b3be0056d..c124a06453 100644
--- a/qcsrc/common/triggers/trigger/jumppads.qc
+++ b/qcsrc/common/triggers/trigger/jumppads.qc
@@ -131,7 +131,7 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht)
 
 void trigger_push_touch()
 {SELFPARAM();
-	if (self.active == ACTIVE_NOT)
+	if (this.active == ACTIVE_NOT)
 		return;
 
 #ifdef SVQC
@@ -139,34 +139,34 @@ void trigger_push_touch()
 		return;
 #endif
 
-	if(self.team)
-		if(((self.spawnflags & 4) == 0) == (DIFF_TEAM(self, other)))
+	if(this.team)
+		if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, other)))
 			return;
 
 	EXACTTRIGGER_TOUCH;
 
-	if(self.enemy)
+	if(this.enemy)
 	{
-		other.velocity = trigger_push_calculatevelocity(other.origin, self.enemy, self.height);
+		other.velocity = trigger_push_calculatevelocity(other.origin, this.enemy, this.height);
 		other.move_velocity = other.velocity;
 	}
-	else if(self.target)
+	else if(this.target)
 	{
 		entity e;
 		RandomSelection_Init();
-		for(e = world; (e = find(e, targetname, self.target)); )
+		for(e = world; (e = find(e, targetname, this.target)); )
 		{
 			if(e.cnt)
 				RandomSelection_Add(e, 0, string_null, e.cnt, 1);
 			else
 				RandomSelection_Add(e, 0, string_null, 1, 1);
 		}
-		other.velocity = trigger_push_calculatevelocity(other.origin, RandomSelection_chosen_ent, self.height);
+		other.velocity = trigger_push_calculatevelocity(other.origin, RandomSelection_chosen_ent, this.height);
 		other.move_velocity = other.velocity;
 	}
 	else
 	{
-		other.velocity = self.movedir;
+		other.velocity = this.movedir;
 		other.move_velocity = other.velocity;
 	}
 
@@ -180,29 +180,29 @@ void trigger_push_touch()
 		// reset tracking of oldvelocity for impact damage (sudden velocity changes)
 		other.oldvelocity = other.velocity;
 
-		if(self.pushltime < time)  // prevent "snorring" sound when a player hits the jumppad more than once
+		if(this.pushltime < time)  // prevent "snorring" sound when a player hits the jumppad more than once
 		{
 			// flash when activated
 			Send_Effect(EFFECT_JUMPPAD, other.origin, other.velocity, 1);
-			_sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTEN_NORM);
-			self.pushltime = time + 0.2;
+			_sound (other, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
+			this.pushltime = time + 0.2;
 		}
 		if(IS_REAL_CLIENT(other) || IS_BOT_CLIENT(other))
 		{
 			bool found = false;
 			for(int i = 0; i < other.jumppadcount && i < NUM_JUMPPADSUSED; ++i)
-				if(other.(jumppadsused[i]) == self)
+				if(other.(jumppadsused[i]) == this)
 					found = true;
 			if(!found)
 			{
-				other.(jumppadsused[other.jumppadcount % NUM_JUMPPADSUSED]) = self;
+				other.(jumppadsused[other.jumppadcount % NUM_JUMPPADSUSED]) = this;
 				other.jumppadcount = other.jumppadcount + 1;
 			}
 
 			if(IS_REAL_CLIENT(other))
 			{
-				if(self.message)
-					centerprint(other, self.message);
+				if(this.message)
+					centerprint(other, this.message);
 			}
 			else
 				other.lastteleporttime = time;
@@ -218,10 +218,10 @@ void trigger_push_touch()
 		other.istypefrag = 0;
 	}
 
-	if(self.enemy.target)
+	if(this.enemy.target)
 	{
 		activator = other;
-		WITH(entity, self, self.enemy, SUB_UseTargets());
+		WITH(entity, self, this.enemy, SUB_UseTargets());
 	}
 
 	if (other.flags & FL_PROJECTILE)
@@ -241,11 +241,11 @@ void trigger_push_touch()
 		UpdateCSQCProjectile(other);
 	}
 
-	if (self.spawnflags & PUSH_ONCE)
+	if (this.spawnflags & PUSH_ONCE)
 	{
-		self.touch = func_null;
-		self.think = SUB_Remove;
-		self.nextthink = time;
+		this.touch = func_null;
+		this.think = SUB_Remove_self;
+		this.nextthink = time;
 	}
 #endif
 }
diff --git a/qcsrc/common/triggers/trigger/monoflop.qc b/qcsrc/common/triggers/trigger/monoflop.qc
index d81f6e3719..26975ab6d1 100644
--- a/qcsrc/common/triggers/trigger/monoflop.qc
+++ b/qcsrc/common/triggers/trigger/monoflop.qc
@@ -28,10 +28,10 @@ void monoflop_think()
 	SUB_UseTargets();
 }
 
-void monoflop_reset()
-{SELFPARAM();
-	self.state = 0;
-	self.nextthink = 0;
+void monoflop_reset(entity this)
+{
+	this.state = 0;
+	this.nextthink = 0;
 }
 
 spawnfunc(trigger_monoflop)
diff --git a/qcsrc/common/triggers/trigger/multi.qc b/qcsrc/common/triggers/trigger/multi.qc
index 91bfc99834..fd3917d33b 100644
--- a/qcsrc/common/triggers/trigger/multi.qc
+++ b/qcsrc/common/triggers/trigger/multi.qc
@@ -115,19 +115,19 @@ void multi_eventdamage (entity inflictor, entity attacker, float damage, int dea
 	}
 }
 
-void multi_reset()
-{SELFPARAM();
-	if ( !(self.spawnflags & SPAWNFLAG_NOTOUCH) )
-		self.touch = multi_touch;
-	if (self.max_health)
+void multi_reset(entity this)
+{
+	if ( !(this.spawnflags & SPAWNFLAG_NOTOUCH) )
+		this.touch = multi_touch;
+	if (this.max_health)
 	{
-		self.health = self.max_health;
-		self.takedamage = DAMAGE_YES;
-		self.solid = SOLID_BBOX;
+		this.health = this.max_health;
+		this.takedamage = DAMAGE_YES;
+		this.solid = SOLID_BBOX;
 	}
-	self.think = func_null;
-	self.nextthink = 0;
-	self.team = self.team_saved;
+	this.think = func_null;
+	this.nextthink = 0;
+	this.team = this.team_saved;
 }
 
 /*QUAKED spawnfunc_trigger_multiple (.5 .5 .5) ? notouch
diff --git a/qcsrc/common/triggers/trigger/multi.qh b/qcsrc/common/triggers/trigger/multi.qh
index 5e72a96a2f..32a3c3131e 100644
--- a/qcsrc/common/triggers/trigger/multi.qh
+++ b/qcsrc/common/triggers/trigger/multi.qh
@@ -1,6 +1,6 @@
 #ifdef SVQC
 void multi_trigger();
-void multi_reset();
+void multi_reset(entity this);
 
 spawnfunc(trigger_once);
 #endif
diff --git a/qcsrc/common/triggers/trigger/relay.qc b/qcsrc/common/triggers/trigger/relay.qc
index 178daad90e..1df446ba32 100644
--- a/qcsrc/common/triggers/trigger/relay.qc
+++ b/qcsrc/common/triggers/trigger/relay.qc
@@ -1,12 +1,10 @@
 #ifdef SVQC
-void _spawnfunc_trigger_relay();
 /*QUAKED spawnfunc_trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8)
 This fixed size trigger cannot be touched, it can only be fired by other events.  It can contain killtargets, targets, delays, and messages.
 */
 spawnfunc(trigger_relay)
 {
-	self.use = SUB_UseTargets;
-	self.reset = _spawnfunc_trigger_relay; // this spawnfunc resets fully
+	this.use = SUB_UseTargets;
+	this.reset = spawnfunc_trigger_relay; // this spawnfunc resets fully
 }
-void _spawnfunc_trigger_relay() { SELFPARAM(); spawnfunc_trigger_relay(this); }
 #endif
diff --git a/qcsrc/common/triggers/trigger/relay_teamcheck.qc b/qcsrc/common/triggers/trigger/relay_teamcheck.qc
index ab2b87aaa0..193dba3682 100644
--- a/qcsrc/common/triggers/trigger/relay_teamcheck.qc
+++ b/qcsrc/common/triggers/trigger/relay_teamcheck.qc
@@ -21,15 +21,15 @@ void trigger_relay_teamcheck_use()
 	}
 }
 
-void trigger_relay_teamcheck_reset()
-{SELFPARAM();
-	self.team = self.team_saved;
+void trigger_relay_teamcheck_reset(entity this)
+{
+	this.team = this.team_saved;
 }
 
 spawnfunc(trigger_relay_teamcheck)
 {
-	self.team_saved = self.team;
-	self.use = trigger_relay_teamcheck_use;
-	self.reset = trigger_relay_teamcheck_reset;
+	this.team_saved = this.team;
+	this.use = trigger_relay_teamcheck_use;
+	this.reset = trigger_relay_teamcheck_reset;
 }
 #endif
diff --git a/qcsrc/common/turrets/util.qc b/qcsrc/common/turrets/util.qc
index b0667c89af..c56ba66e96 100644
--- a/qcsrc/common/turrets/util.qc
+++ b/qcsrc/common/turrets/util.qc
@@ -204,7 +204,6 @@ void FireImoBeam (vector start, vector end, vector smin, vector smax,
 }
 
 #ifdef TURRET_DEBUG
-void SUB_Remove();
 void marker_think()
 {SELFPARAM();
 	if(self.cnt)
diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc
index 7f0537eeb5..0068a51e24 100644
--- a/qcsrc/common/vehicles/sv_vehicles.qc
+++ b/qcsrc/common/vehicles/sv_vehicles.qc
@@ -274,7 +274,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
 	proj.use			  = vehicles_projectile_explode;
 	proj.owner			= self;
 	proj.realowner		= _owner;
-	proj.think			= SUB_Remove;
+	proj.think			= SUB_Remove_self;
 	proj.nextthink		= time + 30;
 
 	if(_health)
@@ -460,7 +460,7 @@ void vehicles_clearreturn(entity veh)
 		if(ret.wp00 == veh)
 		{
 			ret.classname   = "";
-			ret.think	   = SUB_Remove;
+			ret.think	   = SUB_Remove_self;
 			ret.nextthink   = time + 0.1;
 
 			if(ret.waypointsprite_attached)
diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc
index 055293e930..23ea7e1c8c 100644
--- a/qcsrc/common/weapons/weapon/blaster.qc
+++ b/qcsrc/common/weapons/weapon/blaster.qc
@@ -77,10 +77,10 @@ void W_Blaster_Touch()
 
 void W_Blaster_Think()
 {SELFPARAM();
-	self.movetype = MOVETYPE_FLY;
-	self.think = SUB_Remove;
-	self.nextthink = time + self.blaster_lifetime;
-	CSQCProjectile(self, true, PROJECTILE_BLASTER, true);
+	this.movetype = MOVETYPE_FLY;
+	this.think = SUB_Remove_self;
+	this.nextthink = time + this.blaster_lifetime;
+	CSQCProjectile(this, true, PROJECTILE_BLASTER, true);
 }
 
 void W_Blaster_Attack(
diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc
index 252cc56dc8..209bd2dd0e 100644
--- a/qcsrc/common/weapons/weapon/crylink.qc
+++ b/qcsrc/common/weapons/weapon/crylink.qc
@@ -108,10 +108,10 @@ void W_Crylink_Dequeue(entity e)
 	W_Crylink_Dequeue_Raw(e.realowner, e.queueprev, e, e.queuenext);
 }
 
-void W_Crylink_Reset()
-{SELFPARAM();
-	W_Crylink_Dequeue(self);
-	remove(self);
+void W_Crylink_Reset(entity this)
+{
+	W_Crylink_Dequeue(this);
+	remove(this);
 }
 
 // force projectile to explode
diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc
index 9c4d8b2a66..252cc96e34 100644
--- a/qcsrc/common/weapons/weapon/hlac.qc
+++ b/qcsrc/common/weapons/weapon/hlac.qc
@@ -103,7 +103,7 @@ void W_HLAC_Attack(Weapon thiswep)
 	//missile.angles = vectoangles(missile.velocity); // csqc
 
 	missile.touch = W_HLAC_Touch;
-	missile.think = SUB_Remove;
+	missile.think = SUB_Remove_self;
 
     missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime);
 
@@ -145,7 +145,7 @@ void W_HLAC_Attack2()
 	//missile.angles = vectoangles(missile.velocity); // csqc
 
 	missile.touch = W_HLAC_Touch;
-	missile.think = SUB_Remove;
+	missile.think = SUB_Remove_self;
 
     missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime);
 
diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc
index 4679ef38f7..5533818183 100644
--- a/qcsrc/common/weapons/weapon/machinegun.qc
+++ b/qcsrc/common/weapons/weapon/machinegun.qc
@@ -71,16 +71,16 @@ spawnfunc(weapon_uzi) { spawnfunc_weapon_machinegun(this); }
 
 void W_MachineGun_MuzzleFlash_Think()
 {SELFPARAM();
-	self.frame = self.frame + 2;
-	self.scale = self.scale * 0.5;
-	self.alpha = self.alpha - 0.25;
-	self.nextthink = time + 0.05;
+	this.frame += 2;
+	this.scale *= 0.5;
+	this.alpha -= 0.25;
+	this.nextthink = time + 0.05;
 
-	if(self.alpha <= 0)
+	if(this.alpha <= 0)
 	{
-		self.think = SUB_Remove;
-		self.nextthink = time;
-		self.realowner.muzzle_flash = world;
+		this.think = SUB_Remove_self;
+		this.nextthink = time;
+		this.realowner.muzzle_flash = world;
 		return;
 	}
 
diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc
index faf20a4fb9..533b7c944a 100644
--- a/qcsrc/common/weapons/weapon/seeker.qc
+++ b/qcsrc/common/weapons/weapon/seeker.qc
@@ -565,7 +565,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
 	missile.bot_dodge       = true;
 	missile.bot_dodgerating = 50;
 	missile.touch           = W_Seeker_Tag_Touch;
-	missile.think           = SUB_Remove;
+	missile.think           = SUB_Remove_self;
 	missile.nextthink       = time + WEP_CVAR(seeker, tag_lifetime);
 	missile.movetype        = MOVETYPE_FLY;
 	missile.solid           = SOLID_BBOX;
diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc
index e7ad8b0420..3ac26958ad 100644
--- a/qcsrc/common/weapons/weapon/shotgun.qc
+++ b/qcsrc/common/weapons/weapon/shotgun.qc
@@ -77,7 +77,7 @@ void W_Shotgun_Attack(Weapon thiswep, float isprimary)
 	// muzzle flash for 1st person view
 	flash = spawn();
 	setmodel(flash, MDL_SHOTGUN_MUZZLEFLASH); // precision set below
-	flash.think = SUB_Remove;
+	flash.think = SUB_Remove_self;
 	flash.nextthink = time + 0.06;
 	flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
 	W_AttachToShotorg(self, flash, '5 0 0');
diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc
index dc449d35d0..8059f3272b 100644
--- a/qcsrc/common/weapons/weapon/vaporizer.qc
+++ b/qcsrc/common/weapons/weapon/vaporizer.qc
@@ -125,7 +125,7 @@ void VaporizerBeam_Draw(entity this)
 NET_HANDLE(TE_CSQC_VAPORBEAMPARTICLE, bool isNew)
 {
 	Net_Accept(vortex_beam);
-	this.think = SUB_Remove;
+	this.think = SUB_Remove_self;
 	this.nextthink = time + bound(0, autocvar_cl_vaporizerbeam_lifetime, 10);
 	this.draw = VaporizerBeam_Draw;
 	this.drawmask = MASK_NORMAL;
diff --git a/qcsrc/lib/defer.qh b/qcsrc/lib/defer.qh
index 749e4a665e..0fa2974754 100644
--- a/qcsrc/lib/defer.qh
+++ b/qcsrc/lib/defer.qh
@@ -10,23 +10,23 @@
 	class(Defer).void() think;
 	class(Defer).float nextthink;
 
-/*
-==================
-SUB_Remove
+	/** Remove self */
+	void SUB_Remove(entity this)
+	{
+		remove(this);
+	}
 
-Remove self
-==================
-*/
-	void SUB_Remove()
+	/** Remove self */
+	void SUB_Remove_self()
 	{
 		SELFPARAM();
-		remove(self);
+		remove(this);
 	}
 
 	void defer_think()
 	{
 		SELFPARAM();
-		self.think     = SUB_Remove;
+		self.think     = SUB_Remove_self;
 		self.nextthink = time;
 		WITH(entity, self, self.owner, self.use());
 	}
diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh
index 3daa1cede5..45b377a00e 100644
--- a/qcsrc/lib/net.qh
+++ b/qcsrc/lib/net.qh
@@ -30,7 +30,7 @@
 		if (dt)
 		{
 			e.nextthink = time + dt;
-			e.think = SUB_Remove;
+			e.think = SUB_Remove_self;
 		}
 	}
 
diff --git a/qcsrc/lib/spawnfunc.qh b/qcsrc/lib/spawnfunc.qh
index 8a17854cb9..75f56a23d0 100644
--- a/qcsrc/lib/spawnfunc.qh
+++ b/qcsrc/lib/spawnfunc.qh
@@ -28,9 +28,12 @@ noref bool require_spawnfunc_prefix;
 	#define _spawnfunc_check(fld) \
 		if (fieldname == #fld) continue;
 
-		#define spawnfunc_1(id, whitelist) spawnfunc_2(id, whitelist)
+	bool __spawnfunc_unreachable_workaround = true;
+
+	#define spawnfunc_1(id) spawnfunc_2(id, FIELDS_UNION)
 	#define spawnfunc_2(id, whitelist) \
-		void spawnfunc_##id(entity this) \
+		void __spawnfunc_##id(entity this); \
+		[[accumulate]] void spawnfunc_##id(entity this) \
 		{ \
 			this = self; \
 			if (!this.sourceLocFile) \
@@ -53,8 +56,10 @@ noref bool require_spawnfunc_prefix;
 				} \
 				this.spawnfunc_checked = true; \
 			} \
+			__spawnfunc_##id(this); \
+			if (__spawnfunc_unreachable_workaround) return; \
 		} \
-		[[accumulate]] void spawnfunc_##id(entity this)
+		void __spawnfunc_##id(entity this)
 
 	#define FIELD_SCALAR(fld, n) \
 		fld(n)
@@ -176,6 +181,6 @@ noref bool require_spawnfunc_prefix;
 		FIELD_VEC(fld, velocity) \
 		/**/
 
-	#define spawnfunc(...) EVAL(OVERLOAD(spawnfunc, __VA_ARGS__, FIELDS_UNION))
+	#define spawnfunc(...) EVAL(OVERLOAD(spawnfunc, __VA_ARGS__))
 
 #endif
diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc
index 27640770a1..0cd85cba62 100644
--- a/qcsrc/lib/warpzone/server.qc
+++ b/qcsrc/lib/warpzone/server.qc
@@ -142,7 +142,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
 		ts.SendEntity = WarpZone_Teleported_Send;
 		ts.SendFlags = 0xFFFFFF;
 		ts.drawonlytoclient = player;
-		ts.think = SUB_Remove;
+		ts.think = SUB_Remove_self;
 		ts.nextthink = time + 1;
 		ts.owner = player;
 		ts.enemy = wz;
diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc
index d861fbc7c0..eb9c24d67a 100644
--- a/qcsrc/server/command/vote.qc
+++ b/qcsrc/server/command/vote.qc
@@ -355,7 +355,7 @@ void reset_map(bool dorespawn)
 		{
 			if (e.reset)
 			{
-				WITH(entity, self, e, e.reset());
+				WITH(entity, self, e, e.reset(e));
 				continue;
 			}
 			if (e.team_saved) e.team = e.team_saved;
diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh
index 094eb45319..23855b603a 100644
--- a/qcsrc/server/defs.qh
+++ b/qcsrc/server/defs.qh
@@ -355,7 +355,7 @@ float g_nexball_meter_period;
 void SUB_DontUseTargets();
 void SUB_UseTargets();
 
-.void() reset; // if set, an entity is reset using this
+.void(entity this) reset; // if set, an entity is reset using this
 .void() reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities)
 
 void ClientData_Touch(entity e);
diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc
index 147c03ca26..87c28825ac 100644
--- a/qcsrc/server/g_damage.qc
+++ b/qcsrc/server/g_damage.qc
@@ -857,7 +857,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
 			farcent.origin = hitloc;
 			farcent.forcetype = FORCETYPE_FORCEATPOS;
 			farcent.nextthink = time + 0.1;
-			farcent.think = SUB_Remove;
+			farcent.think = SUB_Remove_self;
 		}
 		else
 		{
diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc
index 99bd819495..360078d2a3 100644
--- a/qcsrc/server/g_hook.qc
+++ b/qcsrc/server/g_hook.qc
@@ -80,12 +80,12 @@ void RemoveGrapplingHook(entity pl)
 	//pl.disableclientprediction = false;
 }
 
-void GrapplingHookReset()
-{SELFPARAM();
-	if(self.realowner.hook == self)
-		RemoveGrapplingHook(self.owner);
+void GrapplingHookReset(entity this)
+{
+	if(this.realowner.hook == this)
+		RemoveGrapplingHook(this.owner);
 	else // in any case:
-		remove(self);
+		remove(this);
 }
 
 void GrapplingHookThink();
diff --git a/qcsrc/server/g_subs.qh b/qcsrc/server/g_subs.qh
index a50885a7fe..cebf61b704 100644
--- a/qcsrc/server/g_subs.qh
+++ b/qcsrc/server/g_subs.qh
@@ -6,7 +6,6 @@ void SUB_NullThink();
 void()  SUB_CalcMoveDone;
 void() SUB_CalcAngleMoveDone;
 //void() SUB_UseTargets;
-void() SUB_Remove;
 
 spawnfunc(info_null);
 
@@ -14,14 +13,7 @@ void setanim(entity e, vector anim, float looping, float override, float restart
 
 void updateanim(entity e);
 
-/*
-==================
-SUB_Remove
 
-Remove self
-==================
-*/
-void SUB_Remove ();
 
 /*
 ==================
diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh
index 4193ff29ad..f7479af965 100644
--- a/qcsrc/server/miscfunctions.qh
+++ b/qcsrc/server/miscfunctions.qh
@@ -58,7 +58,6 @@ void soundtoat(float _dest, entity e, vector o, float chan, string samp, float v
 
 void objerror(string s);
 void droptofloor();
-void() SUB_Remove;
 
 void attach_sameorigin(entity e, entity to, string tag);
 
diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc
index fdc2662659..68d23f4860 100644
--- a/qcsrc/server/mutators/mutator/gamemode_assault.qc
+++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc
@@ -94,9 +94,9 @@ vector target_objective_spawn_evalfunc(entity player, entity spot, vector curren
 
 // reset this objective. Used when spawning an objective
 // and when a new round starts
-void assault_objective_reset()
-{SELFPARAM();
-	self.health = ASSAULT_VALUE_INACTIVE;
+void assault_objective_reset(entity this)
+{
+	this.health = ASSAULT_VALUE_INACTIVE;
 }
 
 // decrease the health of targeted objectives
@@ -212,11 +212,11 @@ void target_objective_decrease_findtarget()
 	assault_setenemytoobjective();
 }
 
-void target_assault_roundend_reset()
-{SELFPARAM();
+void target_assault_roundend_reset(entity this)
+{
 	//print("round end reset\n");
-	self.cnt = self.cnt + 1; // up round counter
-	self.winning = 0; // up round
+	++this.cnt; // up round counter
+	this.winning = false; // up round
 }
 
 void target_assault_roundend_use()
@@ -330,13 +330,13 @@ spawnfunc(info_player_defender)
 
 spawnfunc(target_objective)
 {
-	if (!g_assault) { remove(self); return; }
+	if (!g_assault) { remove(this); return; }
 
-	self.classname = "target_objective";
-	self.use = assault_objective_use;
-	assault_objective_reset();
-	self.reset = assault_objective_reset;
-	self.spawn_evalfunc = target_objective_spawn_evalfunc;
+	this.classname = "target_objective";
+	this.use = assault_objective_use;
+	this.reset = assault_objective_reset;
+	this.reset(this);
+	this.spawn_evalfunc = target_objective_spawn_evalfunc;
 }
 
 spawnfunc(target_objective_decrease)
diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc
index d16b168778..ca38f2107b 100644
--- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc
+++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc
@@ -1325,13 +1325,12 @@ void ctf_RespawnFlag(entity flag)
 	ctf_CheckStalemate();
 }
 
-void ctf_Reset()
-{SELFPARAM();
-	if(self.owner)
-		if(IS_PLAYER(self.owner))
-			ctf_Handle_Throw(self.owner, world, DROP_RESET);
+void ctf_Reset(entity this)
+{
+	if(this.owner && IS_PLAYER(this.owner))
+        ctf_Handle_Throw(this.owner, world, DROP_RESET);
 
-	ctf_RespawnFlag(self);
+	ctf_RespawnFlag(this);
 }
 
 void ctf_DelayedFlagSetup() // called after a flag is placed on a map by ctf_FlagSetup()
diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc
index 8c5d5159d5..9be5e108aa 100644
--- a/qcsrc/server/mutators/mutator/gamemode_domination.qc
+++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc
@@ -315,8 +315,10 @@ void dompointtouch()
 	dompoint_captured();
 }
 
-void dom_controlpoint_setup()
-{SELFPARAM();
+void dom_controlpoint_setup(entity this);
+void dom_controlpoint_setup_self() { SELFPARAM(); dom_controlpoint_setup(this); }
+void dom_controlpoint_setup(entity this)
+{
 	entity head;
 	// find the spawnfunc_dom_team representing unclaimed points
 	head = find(world, classname, "dom_team");
@@ -551,7 +553,7 @@ spawnfunc(dom_controlpoint)
 		remove(self);
 		return;
 	}
-	self.think = dom_controlpoint_setup;
+	self.think = dom_controlpoint_setup_self;
 	self.nextthink = time + 0.1;
 	self.reset = dom_controlpoint_setup;
 
@@ -664,12 +666,12 @@ void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float p
 	setself(this);
 }
 
-void _spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); }
+void self_spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); }
 void dom_spawnpoint(vector org)
 {SELFPARAM();
 	setself(spawn());
 	self.classname = "dom_controlpoint";
-	self.think = _spawnfunc_dom_controlpoint;
+	self.think = self_spawnfunc_dom_controlpoint;
 	self.nextthink = time;
 	setorigin(self, org);
 	spawnfunc_dom_controlpoint(this);
diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc
index 1fa986483b..26a7b91dbb 100644
--- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc
+++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc
@@ -140,7 +140,7 @@ void invasion_SpawnChosenMonster(float mon)
 			monster = spawnmonster("", mon, world, world, e.origin, false, false, 2);
 		else return;
 
-		e.think = SUB_Remove;
+		e.think = SUB_Remove_self;
 		e.nextthink = time + 0.1;
 	}
 	else
diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc
index ea14243709..1e593d0eff 100644
--- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc
+++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc
@@ -221,16 +221,17 @@ void ka_DropEvent(entity plyr) // runs any time that a player is supposed to los
 	WaypointSprite_Kill(plyr.waypointsprite_attachedforcarrier);
 }
 
-void ka_Reset() // used to clear the ballcarrier whenever the match switches from warmup to normal
-{SELFPARAM();
-	if((self.owner) && (IS_PLAYER(self.owner)))
-		ka_DropEvent(self.owner);
+/** used to clear the ballcarrier whenever the match switches from warmup to normal */
+void ka_Reset(entity this)
+{
+	if((this.owner) && (IS_PLAYER(this.owner)))
+		ka_DropEvent(this.owner);
 
 	if(time < game_starttime)
 	{
-		self.think = ka_RespawnBall;
-		self.touch = func_null;
-		self.nextthink = game_starttime;
+		this.think = ka_RespawnBall;
+		this.touch = func_null;
+		this.nextthink = game_starttime;
 	}
 	else
 		ka_RespawnBall();
diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
index 8d4240e29a..cbfc8f814f 100644
--- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
+++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
@@ -793,10 +793,10 @@ void kh_Key_Think()  // runs all the time
 	self.nextthink = time + 0.05;
 }
 
-void key_reset()
-{SELFPARAM();
-	kh_Key_AssignTo(self, world);
-	kh_Key_Remove(self);
+void key_reset(entity this)
+{
+	kh_Key_AssignTo(this, world);
+	kh_Key_Remove(this);
 }
 
 const string STR_ITEM_KH_KEY = "item_kh_key";
diff --git a/qcsrc/server/pathlib/debug.qc b/qcsrc/server/pathlib/debug.qc
index 434f50b864..abdfcbaed8 100644
--- a/qcsrc/server/pathlib/debug.qc
+++ b/qcsrc/server/pathlib/debug.qc
@@ -70,8 +70,6 @@ void pathlib_showsquare2(entity node ,vector ncolor,float align)
     }
 }
 
-void SUB_Remove();
-
 void pathlib_showsquare(vector where,float goodsquare,float _lifetime)
 {
     entity s;
@@ -83,7 +81,7 @@ void pathlib_showsquare(vector where,float goodsquare,float _lifetime)
 
     s           = spawn();
     s.alpha     = 0.25;
-    s.think     = SUB_Remove;
+    s.think     = SUB_Remove_self;
     s.nextthink = _lifetime;
     s.scale     = pathlib_gridsize / 512.001;
     s.solid     = SOLID_NOT;
@@ -108,7 +106,7 @@ void pathlib_showedge(vector where,float _lifetime,float rot)
 
     e           = spawn();
     e.alpha     = 0.25;
-    e.think     = SUB_Remove;
+    e.think     = SUB_Remove_self;
     e.nextthink = _lifetime;
     e.scale     = pathlib_gridsize / 512;
     e.solid     = SOLID_NOT;
diff --git a/qcsrc/server/pathlib/main.qc b/qcsrc/server/pathlib/main.qc
index 9a199bd626..c78fc9320d 100644
--- a/qcsrc/server/pathlib/main.qc
+++ b/qcsrc/server/pathlib/main.qc
@@ -10,7 +10,7 @@ void pathlib_deletepath(entity start)
     e = findchainentity(owner, start);
     while(e)
     {
-        e.think = SUB_Remove;
+        e.think = SUB_Remove_self;
         e.nextthink = time;
         e = e.chain;
     }
@@ -22,7 +22,7 @@ const float PATHLIB_NODEEXPIRE = 20;
 void dumpnode(entity n)
 {
     n.is_path_node = false;
-    n.think        = SUB_Remove;
+    n.think        = SUB_Remove_self;
     n.nextthink    = time;
 }
 
@@ -49,7 +49,7 @@ entity pathlib_mknode(vector where,entity parent)
 
     node = spawn();
 
-    node.think        = SUB_Remove;
+    node.think        = SUB_Remove_self;
     node.nextthink    = time + PATHLIB_NODEEXPIRE;
     node.is_path_node = true;
     node.owner        = openlist;
diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc
index f295777db7..f55402f0ec 100644
--- a/qcsrc/server/t_items.qc
+++ b/qcsrc/server/t_items.qc
@@ -1066,7 +1066,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
 		if(this.angles != '0 0 0')
 			this.SendFlags |= ISF_ANGLES;
 
-		this.reset = Item_Reset_self;
+		this.reset = Item_Reset;
 		// it's a level item
 		if(this.spawnflags & 1)
 			this.noalign = 1;
diff --git a/qcsrc/server/t_quake3.qc b/qcsrc/server/t_quake3.qc
index 82646da26a..88e9c2a666 100644
--- a/qcsrc/server/t_quake3.qc
+++ b/qcsrc/server/t_quake3.qc
@@ -128,7 +128,7 @@ void target_give_init()
 		else if (targ.classname == "item_health_mega")
 			self.health = 200;
 		//remove(targ); // removing ents in init functions causes havoc, workaround:
-        targ.think = SUB_Remove;
+        targ.think = SUB_Remove_self;
         targ.nextthink = time;
 	}
 	self.spawnflags = 2;
-- 
2.39.5