Fix manuell loading of most maps in coop mode

This changes ports my magic "find the right coop spawnpoint if target is
unset"-heuristic from baseq2 to Xatrix. This code was originally written
by me and is hereby licensed (additionally to the GPL) to the Quake II
SDK license.
This commit is contained in:
Yamagi Burmeister 2013-03-10 11:58:29 +01:00
parent 05931b1520
commit 5ca8d29816

View file

@ -1035,6 +1035,10 @@ void
SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles)
{
edict_t *spot = NULL;
edict_t *coopspot = NULL;
int index;
int counter = 0;
vec3_t d;
if (!ent)
{
@ -1086,6 +1090,44 @@ SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles)
}
}
/* If we are in coop and we didn't find a coop
spawnpoint due to map bugs (not correctly
connected or the map was loaded via console
and thus no previously map is known to the
client) use one in 550 units radius. */
if (coop->value)
{
index = ent->client - game.clients;
if (Q_stricmp(spot->classname, "info_player_start") == 0 && index != 0)
{
while(counter < 3)
{
coopspot = G_Find(coopspot, FOFS(classname), "info_player_coop");
if (!coopspot)
{
break;
}
VectorSubtract(coopspot->s.origin, spot->s.origin, d);
if ((VectorLength(d) < 550))
{
if (index == counter)
{
spot = coopspot;
break;
}
else
{
counter++;
}
}
}
}
}
VectorCopy(spot->s.origin, origin);
origin[2] += 9;
VectorCopy(spot->s.angles, angles);