Merge pull request #5537 from obrakmann/more-lua-crash-fixes

More lua crash fixes
This commit is contained in:
Matthias Mailänder
2014-06-04 11:03:19 +02:00
4 changed files with 16 additions and 24 deletions

View File

@@ -43,10 +43,8 @@ end
BuildNod1 = function() BuildNod1 = function()
Production.BuildTeamFromTemplate(nod, Nod1Template, function(team) Production.BuildTeamFromTemplate(nod, Nod1Template, function(team)
Team.Do(team, function(actor) Team.Do(team, function(actor)
if not Actor.IsDead(actor) then Actor.OnIdle(actor, Actor.Hunt)
Actor.OnIdle(actor, Actor.Hunt) Actor.OnKilled(actor, KillCounter)
Actor.OnKilled(actor, KillCounter)
end
end) end)
Team.AddEventHandler(team.OnAllKilled, BuildNod1) Team.AddEventHandler(team.OnAllKilled, BuildNod1)
end) end)
@@ -55,10 +53,8 @@ end
BuildAuto1 = function() BuildAuto1 = function()
Production.BuildTeamFromTemplate(nod, Auto1Template, function(team) Production.BuildTeamFromTemplate(nod, Auto1Template, function(team)
Team.Do(team, function(actor) Team.Do(team, function(actor)
if not Actor.IsDead(actor) then Actor.OnIdle(actor, Actor.Hunt)
Actor.OnIdle(actor, Actor.Hunt) Actor.OnKilled(actor, KillCounter)
Actor.OnKilled(actor, KillCounter)
end
end) end)
end) end)
end end

View File

@@ -38,11 +38,7 @@ end
Build = function(template, repeats, func) Build = function(template, repeats, func)
Production.BuildTeamFromTemplate(nod, template, function(team) Production.BuildTeamFromTemplate(nod, template, function(team)
Team.Do(team, function(actor) Team.Do(team, func)
if not Actor.IsDead(actor) then
func(actor)
end
end)
if repeats then if repeats then
Team.AddEventHandler(team.OnAllKilled, function() Team.AddEventHandler(team.OnAllKilled, function()
Build(template, repeats, func) Build(template, repeats, func)

View File

@@ -57,7 +57,11 @@ Team.Contains = function(team, actor)
end end
Team.Do = function(team, func) Team.Do = function(team, func)
Utils.Do(team.Actors, func) Utils.Do(team.Actors, function(actor)
if not Actor.IsDead(actor) then
func(actor)
end
end)
end end
Team.Patrol = function(team, waypoints, wait, loop) Team.Patrol = function(team, waypoints, wait, loop)

View File

@@ -77,12 +77,10 @@ FollowWaypoints = function(team, waypoints)
end end
PlaneExitMap = function(actor, exitPoint) PlaneExitMap = function(actor, exitPoint)
if not Actor.IsDead(actor) then Actor.Stop(actor)
Actor.Stop(actor) Actor.Fly(actor, exitPoint.CenterPosition)
Actor.Fly(actor, exitPoint.CenterPosition) Actor.FlyOffMap(actor)
Actor.FlyOffMap(actor) Actor.RemoveSelf(actor)
Actor.RemoveSelf(actor)
end
end end
BaseRaid = function() BaseRaid = function()
@@ -192,10 +190,8 @@ SetupWorld = function()
Utils.Do(SovietHarvesters, function(harvester) Utils.Do(SovietHarvesters, function(harvester)
Actor.OnDamaged(harvester, function(h) Actor.OnDamaged(harvester, function(h)
Team.Do(harvesterGuard, function(g) Team.Do(harvesterGuard, function(g)
if not Actor.IsDead(g) then Actor.Stop(g)
Actor.Stop(g) Actor.AttackMove(g, h.Location, 3)
Actor.AttackMove(g, h.Location, 3)
end
end) end)
end) end)
end) end)