From a4e28644b9774813204ff9b4636df5da50624697 Mon Sep 17 00:00:00 2001 From: div0 Date: Mon, 9 Feb 2009 08:38:53 +0000 Subject: [PATCH] verify spawnpoints when loading the map and bail out if the map lacks spawnpoints instead of crashing later git-svn-id: svn://svn.icculus.org/nexuiz/trunk@5806 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/race.qc | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/data/qcsrc/server/race.qc b/data/qcsrc/server/race.qc index f7473fe50..0a76a5a8f 100644 --- a/data/qcsrc/server/race.qc +++ b/data/qcsrc/server/race.qc @@ -395,6 +395,58 @@ float race_waypointsprite_visible_for_player(entity e) return FALSE; } +float have_verified; +void trigger_race_checkpoint_verify() +{ + entity oldself; + float i, p; + float qual; + + if(have_verified) + return; + have_verified = 1; + + qual = g_race_qualifying; + + oldself = self; + self = spawn(); + self.classname = "player"; + + for(i = 0; i <= race_highest_checkpoint; ++i) + { + self.race_checkpoint = race_NextCheckpoint(i); + + // race only (middle of the race) + g_race_qualifying = 0; + self.race_place = 0; + if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE)) + error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for respawning in race) - bailing out")); + + if(i == 0) + { + // qualifying only + g_race_qualifying = 1; + self.race_place = race_lowest_place_spawn; + if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE)) + error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out")); + + // race only (initial spawn) + g_race_qualifying = 0; + for(p = 1; p <= race_highest_place_spawn; ++p) + { + self.race_place = p; + if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), world, 0, FALSE)) + error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for initially spawning in race) - bailing out")); + } + } + } + + g_race_qualifying = qual; + + remove(self); + self = oldself; +} + void spawnfunc_trigger_race_checkpoint() { vector o; @@ -434,6 +486,8 @@ void spawnfunc_trigger_race_checkpoint() WaypointSprite_SpawnFixed("race-finish", o, self, sprite); } self.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player; + + InitializeEntity(self, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET); } void race_AbandonRaceCheck(entity p) -- 2.39.2