|
In pure DM, this is all you need. So, you can replace your corresponding
functions with these 3 and be sure to change the prototype definition in your
header file and the change the call to SelectSpawnPoint() in
PutClientInServer()..
Here they are:
//=====================================================
void SelectRandomDeathmatchSpawnPoint(vec3_t origin,vec3_t angles) {
edict_t *spot=NULL;
int num_spots=0;
edict_t *telespot[1024];
while ((spot=G_Find(spot,FOFS(classname),"info_player_deathmatch")))
telespot[num_spots++]=spot;
spot=telespot[(int)(rand()%num_spots)-1]; // pick a random destination
VectorCopy(spot->s.origin,origin);
origin[2]+=9;
VectorCopy(spot->s.angles,angles);
}
//=====================================================
void SelectFarthestDeathmatchSpawnPoint(vec3_t origin,vec3_t angles) {
edict_t *spot=NULL;
edict_t *bestspot=NULL;
float bestdistanceSqr=0;
float bestplayerdistanceSqr=0;
while ((spot=G_Find(spot,FOFS(classname),"info_player_deathmatch"))) {
bestplayerdistanceSqr=PlayersRangeSqrFromSpot(spot);
if (bestplayerdistanceSqr>bestdistanceSqr) {
bestspot=spot; // farthest destination spot
bestdistanceSqr=bestplayerdistanceSqr; } }
VectorCopy(bestspot->s.origin,origin);
origin[2]+=9;
VectorCopy(bestspot->s.angles,angles);
}
//=====================================================
void SelectSpawnPoint(vec3_t origin,vec3_t angles) {
if ((int)dmflags->value & DF_SPAWN_FARTHEST)
SelectFarthestDeathmatchSpawnPoint(origin,angles);
else
SelectRandomDeathmatchSpawnPoint(origin,angles);
}
All the original
functionality remains intact while doing away with un-needed code..
Maj.Bitch
|