hopefully this prevents occasionaly edicts going over limit related to mapchanges?

This commit is contained in:
jenz 2024-11-27 16:12:11 +01:00
parent d2a8f3a49d
commit 044ffb7847

View File

@ -659,6 +659,8 @@ public void unloze_zoneEntry(int client, char[] zone)
} }
} }
public void handle_pings(int i, int pingtype) public void handle_pings(int i, int pingtype)
{ {
if (!g_is_zh_map) if (!g_is_zh_map)
@ -1074,12 +1076,38 @@ stock void ReplaceStrings(char[] str, char[] strReplace)
Format(str, sizeof(l_cstrFix), l_cstrFix); Format(str, sizeof(l_cstrFix), l_cstrFix);
} }
public void OnMapEnd()
{
if (g_is_zh_map)
{
for (int i = 0; i <= g_zoneCount; i++)
{
for (int j = zone_pings[i]; j < zone_pings[i + 1]; j++)
{
RemovePing(j);
/* Should hopefully help prevent these crashes
L 11/26/2024 - 16:59:11: (70.62%) 1447 prop_dynamic
Nov 26 16:59:11 unloze script[1920069]: L 11/26/2024 - 16:59:11: Total edicts: 2049
Nov 26 16:59:11 unloze script[1920069]: ED_Alloc: no free edicts
Nov 26 16:59:11 unloze script[1920069]: L 11/26/2024 - 16:59:11: Engine error: ED_Alloc: no free edicts
*/
}
}
}
}
public void SpawnPing(int skin, float pos[3], int index) public void SpawnPing(int skin, float pos[3], int index)
{ {
if (!g_is_zh_map) if (!g_is_zh_map)
{ {
return; return;
} }
if (GetEntityCount() > 1900)
{
//this should probably never happen tbh.
PrintToChatAll("Fail safe was activated. skipped spawning ping to prevent edict limit");
return;
}
int Ent = CreateEntityByName("prop_dynamic"); int Ent = CreateEntityByName("prop_dynamic");
SetEntityModel(Ent, "models/unloze/unloze_ping.mdl"); SetEntityModel(Ent, "models/unloze/unloze_ping.mdl");
DispatchKeyValue(Ent, "modelscale", "1.5"); DispatchKeyValue(Ent, "modelscale", "1.5");