Ensure LuaValues are disposed.

Adding in these missing calls prevents these instances from having to be finalized.
This commit is contained in:
RoosterDragon
2015-12-23 16:04:58 +00:00
parent 387d0d0e3f
commit 6ab6d774a7
11 changed files with 184 additions and 142 deletions

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Traits;
@@ -34,34 +33,14 @@ namespace OpenRA.Mods.Common.Scripting
public Actor[] ActorsInCircle(WPos location, WDist radius, LuaFunction filter = null)
{
var actors = Context.World.FindActorsInCircle(location, radius);
if (filter != null)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(Context)))
return f.First().ToBoolean();
});
}
return actors.ToArray();
return FilteredObjects(actors, filter).ToArray();
}
[Desc("Returns a table of all actors within the requested rectangle, filtered using the specified function.")]
public Actor[] ActorsInBox(WPos topLeft, WPos bottomRight, LuaFunction filter = null)
{
var actors = Context.World.ActorMap.ActorsInBox(topLeft, bottomRight);
if (filter != null)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(Context)))
return f.First().ToBoolean();
});
}
return actors.ToArray();
return FilteredObjects(actors, filter).ToArray();
}
[Desc("Returns the location of the top-left corner of the map (assuming zero terrain height).")]