random ztele: improve bfcaca166f

This commit is contained in:
BotoX 2016-08-23 16:12:32 +02:00
parent bfcaca166f
commit 21c2ac40a8

View File

@ -74,27 +74,17 @@ void ZTele_OnCommandsCreate()
void ZTeleOnRoundStart() void ZTeleOnRoundStart()
{ {
char classname[64]; char classname[64];
// GetMaxEntities() returns the max EDICT count. Multiply by 2 to get max ENTITY count.
// Some maps spawn their spawpoints as logic entities, as does sm-ext-CSSFixes.
int maxentities = GetMaxEntities() * 2;
g_iZTeleSpawnPointsCount = 0; g_iZTeleSpawnPointsCount = 0;
for (int i = MaxClients; i <= maxentities; i++) int entity = INVALID_ENT_REFERENCE;
while((entity = FindEntityByClassname(entity, "info_player_*")) != INVALID_ENT_REFERENCE)
{ {
if (!IsValidEntity(i)) GetEntityClassname(entity, classname, sizeof(classname));
{
continue;
}
GetEntityClassname(i, classname, sizeof(classname));
if (StrEqual(classname, "info_player_terrorist", true) || StrEqual(classname, "info_player_counterterrorist", true)) if (StrEqual(classname, "info_player_terrorist", true) || StrEqual(classname, "info_player_counterterrorist", true))
{ {
GetEntPropVector(i, Prop_Send, "m_vecOrigin", g_vecZTeleSpawnPoints[g_iZTeleSpawnPointsCount]); GetEntPropVector(entity, Prop_Send, "m_vecOrigin", g_vecZTeleSpawnPoints[g_iZTeleSpawnPointsCount]);
g_iZTeleSpawnPointsCount++; g_iZTeleSpawnPointsCount++;
if (g_iZTeleSpawnPointsCount >= MAX_PLAYER_SPAWNS) if (g_iZTeleSpawnPointsCount >= MAX_PLAYER_SPAWNS)
{ {
break; break;