From c2eff98d05238c51184ec103f53f2bfb65eb484e Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Sat, 4 Jun 2005 11:25:40 +0000 Subject: [PATCH] now uses a spawn furthest algorithm when choosing spawn points, with a high randomization so it is pretty unpredictable when there isn't a big difference between choices git-svn-id: svn://svn.icculus.org/nexuiz/trunk@433 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- qcsrc/gamec/cl_client.c | 42 ++++++++++++++++++++--------------------- qcsrc/gamec/g_world.c | 3 --- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/qcsrc/gamec/cl_client.c b/qcsrc/gamec/cl_client.c index 80a7a1b71..b7aba52d6 100644 --- a/qcsrc/gamec/cl_client.c +++ b/qcsrc/gamec/cl_client.c @@ -16,38 +16,36 @@ Finds a point to respawn */ entity SelectSpawnPoint (void) { - local entity spot, thing; - local float pcount; + local entity spot, thing, best, player, playerlist; + local float pcount, rating, bestrating; spot = find (world, classname, "testplayerstart"); if (spot) return spot; - spot = lastspawn; - while (1) + best = world; + bestrating = -1; + playerlist = findchain(classname, "player"); + spot = find(world, classname, "info_player_deathmatch"); + while (spot) { - spot = find(spot, classname, "info_player_deathmatch"); - if (spot != world) + rating = random() * 256; + player = playerlist; + while (player) { - if (spot == lastspawn) - return lastspawn; - pcount = 0; - thing = findradius(spot.origin, 70); - while(thing) - { - if (thing.classname == "player") - pcount = pcount + 1; - thing = thing.chain; - } - if (pcount == 0) - { - lastspawn = spot; - return spot; - } + if (player != self) + rating = rating + vlen(player.origin - spot.origin); + player = player.chain; + } + if (bestrating < rating) + { + best = spot; + bestrating = rating; } + spot = find(spot, classname, "info_player_deathmatch"); } + spot = best; - spot = find (world, classname, "info_player_start"); if (!spot) error ("PutClientInServer: no info_player_start on level"); diff --git a/qcsrc/gamec/g_world.c b/qcsrc/gamec/g_world.c index 26edcaa44..2eef3752b 100644 --- a/qcsrc/gamec/g_world.c +++ b/qcsrc/gamec/g_world.c @@ -1,10 +1,7 @@ -entity lastspawn; - void() dom_init; void worldspawn (void) { - lastspawn = world; BotInit(); game = cvar ("gamecfg"); // load game options -- 2.39.2