Core/Map: Change all foreach loops over objects in maps to for loops, Fixes Collection was modified enumeration operation may not execute

This commit is contained in:
hondacrx
2021-01-03 14:58:09 -05:00
parent f929746c3d
commit d605ebca38
6 changed files with 320 additions and 210 deletions
+10 -4
View File
@@ -1663,15 +1663,21 @@ namespace Game
public override void Visit(IList<Creature> objs)
{
foreach (var creature in objs)
for (var i = 0; i < objs.Count; ++i)
{
Creature creature = objs[i];
if (creature.IsInWorld && creature.IsAIEnabled)
creature.GetAI().OnGameEvent(_activate, _eventId);
}
}
public override void Visit(IList<GameObject> objs)
{
foreach (var gameobject in objs)
if (gameobject.IsInWorld)
gameobject.GetAI().OnGameEvent(_activate, _eventId);
for (var i = 0; i < objs.Count; ++i)
{
GameObject gameObject = objs[i];
if (gameObject.IsInWorld)
gameObject.GetAI().OnGameEvent(_activate, _eventId);
}
}
ushort _eventId;