From: Mario Date: Thu, 19 May 2016 19:29:23 +0000 (+1000) Subject: Clean out self uses from spawnpoint code X-Git-Tag: xonotic-v0.8.2~925 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3e22c2d597cb7153805878681ac9db3d3c9e9e95;p=xonotic%2Fxonotic-data.pk3dir.git Clean out self uses from spawnpoint code --- diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 5ed63b538..3ab9bc1cd 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -197,7 +197,7 @@ void buff_Respawn(entity this) if(!MoveToRandomMapLocation(this, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((autocvar_g_buffs_random_location_attempts > 0) ? autocvar_g_buffs_random_location_attempts : 10), 1024, 256)) { - entity spot = SelectSpawnPoint(true); + entity spot = SelectSpawnPoint(this, true); setorigin(this, spot.origin); this.velocity = ((randomvec() * 100) + '0 0 200'); this.angles = spot.angles; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index c157530fa..3ffc73820 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -196,7 +196,7 @@ void PutObserverInServer() } { - entity spot = SelectSpawnPoint(true); + entity spot = SelectSpawnPoint(this, true); if (!spot) LOG_FATAL("No spawnpoints for observers?!?"); this.angles = spot.angles; this.angles_z = 0; @@ -471,7 +471,7 @@ void PutClientInServer() if (this.team < 0) JoinBestTeam(this, false, true); - entity spot = SelectSpawnPoint(false); + entity spot = SelectSpawnPoint(this, false); if (!spot) { Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_NOSPAWNS); return; // spawn failed diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 29374036c..1ad60e868 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -408,7 +408,7 @@ const float ACTIVE_TOGGLE = 3; void PlayerUseKey(); -USING(spawn_evalfunc_t, vector(entity player, entity spot, vector current)); +USING(spawn_evalfunc_t, vector(entity this, entity player, entity spot, vector current)); .spawn_evalfunc_t spawn_evalfunc; string modname; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 675b794ec..b30f2353b 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -726,37 +726,34 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d { Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1); - setself(targ); - entity spot = SelectSpawnPoint (false); + entity spot = SelectSpawnPoint (targ, false); if(spot) { damage = 0; - self.deadflag = DEAD_NO; + targ.deadflag = DEAD_NO; - self.angles = spot.angles; + targ.angles = spot.angles; - self.effects = 0; - self.effects |= EF_TELEPORT_BIT; + targ.effects = 0; + targ.effects |= EF_TELEPORT_BIT; - self.angles_z = 0; // never spawn tilted even if the spot says to - self.fixangle = true; // turn this way immediately - self.velocity = '0 0 0'; - self.avelocity = '0 0 0'; - self.punchangle = '0 0 0'; - self.punchvector = '0 0 0'; - self.oldvelocity = self.velocity; + targ.angles_z = 0; // never spawn tilted even if the spot says to + targ.fixangle = true; // turn this way immediately + targ.velocity = '0 0 0'; + targ.avelocity = '0 0 0'; + targ.punchangle = '0 0 0'; + targ.punchvector = '0 0 0'; + targ.oldvelocity = targ.velocity; - self.spawnorigin = spot.origin; - setorigin (self, spot.origin + '0 0 1' * (1 - self.mins.z - 24)); + targ.spawnorigin = spot.origin; + setorigin (targ, spot.origin + '0 0 1' * (1 - targ.mins.z - 24)); // don't reset back to last position, even if new position is stuck in solid - self.oldorigin = self.origin; - self.prevorigin = self.origin; + targ.oldorigin = targ.origin; + targ.prevorigin = targ.origin; - Send_Effect(EFFECT_TELEPORT, self.origin, '0 0 0', 1); + Send_Effect(EFFECT_TELEPORT, targ.origin, '0 0 0', 1); } - - setself(this); } if(!g_instagib) diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 26038b2bb..d961fa14d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -85,9 +85,9 @@ void assault_objective_use(entity this, entity actor, entity trigger) } } -vector target_objective_spawn_evalfunc(entity player, entity spot, vector current) -{SELFPARAM(); - if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE) +vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current) +{ + if(this.health < 0 || this.health >= ASSAULT_VALUE_INACTIVE) return '-1 0 0'; return current; } diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 5bc93fb33..4bed375b4 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -89,7 +89,7 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated if(!MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256)) { - entity spot = SelectSpawnPoint(true); + entity spot = SelectSpawnPoint(this, true); setorigin(self, spot.origin); self.angles = spot.angles; } diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index e3cba9383..00cc50238 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -440,16 +440,16 @@ void Portal_Damage(entity this, entity inflictor, entity attacker, float damage, Portal_Remove(this, 1); } -void Portal_Think_TryTeleportPlayer(entity e, vector g) -{SELFPARAM(); - if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, self.origin, v_forward, self.maxs.x)) +void Portal_Think_TryTeleportPlayer(entity this, entity e, vector g) +{ + if(!Portal_WillHitPlane(e.origin, e.mins, e.maxs, e.velocity + g, this.origin, v_forward, this.maxs.x)) return; // if e would hit the portal in a frame... // already teleport him tracebox(e.origin, e.mins, e.maxs, e.origin + e.velocity * 2 * frametime, MOVE_NORMAL, e); - if(trace_ent == self) - Portal_TeleportPlayer(self, e); + if(trace_ent == this) + Portal_TeleportPlayer(this, e); } void Portal_Think() @@ -479,10 +479,10 @@ void Portal_Think() continue; // cannot go through someone else's portal if(it != o || time >= self.portal_activatetime) - Portal_Think_TryTeleportPlayer(it, g); + Portal_Think_TryTeleportPlayer(self, it, g); if(it.hook) - Portal_Think_TryTeleportPlayer(it.hook, g); + Portal_Think_TryTeleportPlayer(self, it.hook, g); )); self.solid = SOLID_TRIGGER; self.aiment = o; diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index ba13b14a9..6fb39f6ce 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -741,7 +741,7 @@ void trigger_race_checkpoint_verify(entity this) // race only (middle of the race) g_race_qualifying = false; pl_race_place = 0; - if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out")); } @@ -749,7 +749,7 @@ void trigger_race_checkpoint_verify(entity this) // qualifying only g_race_qualifying = 1; pl_race_place = race_lowest_place_spawn; - if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out")); } @@ -757,7 +757,7 @@ void trigger_race_checkpoint_verify(entity this) g_race_qualifying = 0; for (int p = 1; p <= race_highest_place_spawn; ++p) { pl_race_place = p; - if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for initially spawning in race) - bailing out")); } } @@ -768,7 +768,7 @@ void trigger_race_checkpoint_verify(entity this) pl_race_checkpoint = race_NextCheckpoint(0); g_race_qualifying = 1; pl_race_place = race_lowest_place_spawn; - if (!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, false)) { + if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false)) { error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for qualifying) - bailing out")); } } else { @@ -872,27 +872,26 @@ void trigger_race_checkpoint_verify(entity this) } } -vector trigger_race_checkpoint_spawn_evalfunc(entity player, entity spot, vector current) -{SELFPARAM(); +vector trigger_race_checkpoint_spawn_evalfunc(entity this, entity player, entity spot, vector current) +{ if(g_race_qualifying) { // spawn at first - if(self.race_checkpoint != 0) + if(this.race_checkpoint != 0) return '-1 0 0'; if(spot.race_place != race_lowest_place_spawn) return '-1 0 0'; } else { - if(self.race_checkpoint != player.race_respawn_checkpoint) + if(this.race_checkpoint != player.race_respawn_checkpoint) return '-1 0 0'; // try reusing the previous spawn - if(self == player.race_respawn_spotref || spot == player.race_respawn_spotref) + if(this == player.race_respawn_spotref || spot == player.race_respawn_spotref) current.x += SPAWN_PRIO_RACE_PREVIOUS_SPAWN; - if(self.race_checkpoint == 0) + if(this.race_checkpoint == 0) { - float pl; - pl = player.race_place; + int pl = player.race_place; if(pl > race_highest_place_spawn) pl = 0; if(pl == 0 && !player.race_started) diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index 711b15df5..e7268a88f 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -14,10 +14,10 @@ bool SpawnPoint_Send(entity this, entity to, int sf) { WriteHeader(MSG_ENTITY, ENT_CLIENT_SPAWNPOINT); - WriteByte(MSG_ENTITY, self.team); - WriteCoord(MSG_ENTITY, self.origin.x); - WriteCoord(MSG_ENTITY, self.origin.y); - WriteCoord(MSG_ENTITY, self.origin.z); + WriteByte(MSG_ENTITY, this.team); + WriteCoord(MSG_ENTITY, this.origin.x); + WriteCoord(MSG_ENTITY, this.origin.y); + WriteCoord(MSG_ENTITY, this.origin.z); return true; } @@ -69,24 +69,24 @@ void spawnpoint_use(entity this, entity actor, entity trigger) //LOG_INFO("spawnpoint was used!\n"); } -void relocate_spawnpoint() -{SELFPARAM(); +void relocate_spawnpoint(entity this) +{ // nudge off the floor - setorigin(self, self.origin + '0 0 1'); + setorigin(this, this.origin + '0 0 1'); - tracebox(self.origin, PL_MIN_CONST, PL_MAX_CONST, self.origin, true, self); + tracebox(this.origin, PL_MIN_CONST, PL_MAX_CONST, this.origin, true, this); if (trace_startsolid) { vector o; - o = self.origin; - self.mins = PL_MIN_CONST; - self.maxs = PL_MAX_CONST; - if (!move_out_of_solid(self)) + o = this.origin; + this.mins = PL_MIN_CONST; + this.maxs = PL_MAX_CONST; + if (!move_out_of_solid(this)) objerror("could not get out of solid at all!"); LOG_INFO("^1NOTE: this map needs FIXING. Spawnpoint at ", vtos(o - '0 0 1')); - LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x)); - LOG_INFO(" ", ftos(self.origin.y - o.y)); - LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n"); + LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(this.origin.x - o.x)); + LOG_INFO(" ", ftos(this.origin.y - o.y)); + LOG_INFO(" ", ftos(this.origin.z - o.z), "'\n"); if (autocvar_g_spawnpoints_auto_move_out_of_solid) { if (!spawnpoint_nag) @@ -95,31 +95,31 @@ void relocate_spawnpoint() } else { - setorigin(self, o); - self.mins = self.maxs = '0 0 0'; + setorigin(this, o); + this.mins = this.maxs = '0 0 0'; objerror("player spawn point in solid, mapper sucks!\n"); return; } } - self.use = spawnpoint_use; - self.think = spawnpoint_think; - self.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second - self.team_saved = self.team; - if (!self.cnt) - self.cnt = 1; + this.use = spawnpoint_use; + this.think = spawnpoint_think; + this.nextthink = time + 0.5 + random() * 2; // shouldn't need it for a little second + this.team_saved = this.team; + if (!this.cnt) + this.cnt = 1; if (have_team_spawns != 0) - if (self.team) + if (this.team) have_team_spawns = 1; - have_team_spawns_forteam[self.team] = 1; + have_team_spawns_forteam[this.team] = 1; if (autocvar_r_showbboxes) { // show where spawnpoints point at too - makevectors(self.angles); + makevectors(this.angles); entity e = new(info_player_foo); - setorigin(e, self.origin + v_forward * 24); + setorigin(e, this.origin + v_forward * 24); setsize(e, '-8 -8 -8', '8 8 8'); e.solid = SOLID_TRIGGER; } @@ -131,27 +131,27 @@ void relocate_spawnpoint() !( ( // if this passes, there is a DM spawn on a team match teamplay - && (self.team != NUM_TEAM_1) - && (self.team != NUM_TEAM_2) - && (self.team != NUM_TEAM_3) - && (self.team != NUM_TEAM_4) + && (this.team != NUM_TEAM_1) + && (this.team != NUM_TEAM_2) + && (this.team != NUM_TEAM_3) + && (this.team != NUM_TEAM_4) ) || ( // if this passes, there is a team spawn on a DM match !teamplay && ( - (self.team == NUM_TEAM_1) - || (self.team == NUM_TEAM_2) - || (self.team == NUM_TEAM_3) - || (self.team == NUM_TEAM_4) + (this.team == NUM_TEAM_1) + || (this.team == NUM_TEAM_2) + || (this.team == NUM_TEAM_3) + || (this.team == NUM_TEAM_4) ) ) ) || autocvar_g_spawn_useallspawns ) - { Net_LinkEntity(self, false, 0, SpawnPoint_Send); } + { Net_LinkEntity(this, false, 0, SpawnPoint_Send); } } spawnfunc(info_player_survivor) @@ -166,8 +166,8 @@ spawnfunc(info_player_start) spawnfunc(info_player_deathmatch) { - self.classname = "info_player_deathmatch"; - relocate_spawnpoint(); + this.classname = "info_player_deathmatch"; + relocate_spawnpoint(this); } /*QUAKED spawnfunc_info_player_team1 (1 0 0) (-16 -16 -24) (16 16 24) @@ -211,8 +211,8 @@ spawnfunc(info_player_team4) // Returns: // _x: prio (-1 if unusable) // _y: weight -vector Spawn_Score(entity spot, float mindist, float teamcheck) -{SELFPARAM(); +vector Spawn_Score(entity this, entity spot, float mindist, float teamcheck) +{ float shortest, thisdist; float prio; @@ -227,7 +227,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) if(spot.target == "") return '-1 0 0'; - if(IS_REAL_CLIENT(self)) + if(IS_REAL_CLIENT(this)) { if(spot.restriction == 1) return '-1 0 0'; @@ -239,7 +239,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) } shortest = vlen(world.maxs - world.mins); - FOREACH_CLIENT(IS_PLAYER(it) && it != self, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA( thisdist = vlen(it.origin - spot.origin); if (thisdist < shortest) shortest = thisdist; @@ -261,7 +261,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) ++found; if(ent.spawn_evalfunc) { - WITHSELF(ent, spawn_score = ent.spawn_evalfunc(this, spot, spawn_score)); + spawn_score = ent.spawn_evalfunc(ent, this, spot, spawn_score); if(spawn_score.x < 0) return spawn_score; } @@ -274,25 +274,25 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck) } } - MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score); + MUTATOR_CALLHOOK(Spawn_Score, this, spawn_spot, spawn_score); return spawn_score; } -void Spawn_ScoreAll(entity firstspot, float mindist, float teamcheck) +void Spawn_ScoreAll(entity this, entity firstspot, float mindist, float teamcheck) { entity spot; for(spot = firstspot; spot; spot = spot.chain) - spot.spawnpoint_score = Spawn_Score(spot, mindist, teamcheck); + spot.spawnpoint_score = Spawn_Score(this, spot, mindist, teamcheck); } -entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck) +entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck) { entity spot, spotlist, spotlistend; spotlist = world; spotlistend = world; - Spawn_ScoreAll(firstspot, mindist, teamcheck); + Spawn_ScoreAll(this, firstspot, mindist, teamcheck); for(spot = firstspot; spot; spot = spot.chain) { @@ -331,8 +331,8 @@ SelectSpawnPoint Finds a point to respawn ============= */ -entity SelectSpawnPoint (float anypoint) -{SELFPARAM(); +entity SelectSpawnPoint(entity this, bool anypoint) +{ float teamcheck; entity spot, firstspot; @@ -344,7 +344,7 @@ entity SelectSpawnPoint (float anypoint) teamcheck = -1; else if(have_team_spawns > 0) { - if(have_team_spawns_forteam[self.team] == 0) + if(have_team_spawns_forteam[this.team] == 0) { // we request a spawn for a team, and we have team // spawns, but that team has no spawns? @@ -356,7 +356,7 @@ entity SelectSpawnPoint (float anypoint) teamcheck = -1; } else - teamcheck = self.team; // MUST be team + teamcheck = this.team; // MUST be team } else if(have_team_spawns == 0 && have_team_spawns_forteam[0]) teamcheck = 0; // MUST be noteam @@ -375,7 +375,7 @@ entity SelectSpawnPoint (float anypoint) } else { - firstspot = Spawn_FilterOutBadSpots(firstspot, 100, teamcheck); + firstspot = Spawn_FilterOutBadSpots(this, firstspot, 100, teamcheck); // there is 50/50 chance of choosing a random spot or the furthest spot // (this means that roughly every other spawn will be furthest, so you diff --git a/qcsrc/server/spawnpoints.qh b/qcsrc/server/spawnpoints.qh index a22ebb60c..56e00b5ac 100644 --- a/qcsrc/server/spawnpoints.qh +++ b/qcsrc/server/spawnpoints.qh @@ -3,7 +3,7 @@ .vector spawnpoint_score; float spawnpoint_nag; bool SpawnEvent_Send(entity this, entity to, int sf); -entity Spawn_FilterOutBadSpots(entity firstspot, float mindist, float teamcheck); -entity SelectSpawnPoint (float anypoint); +entity Spawn_FilterOutBadSpots(entity this, entity firstspot, float mindist, float teamcheck); +entity SelectSpawnPoint(entity this, bool anypoint); spawnfunc(info_player_deathmatch); void spawnpoint_use(entity this, entity actor, entity trigger);