Skip to content

Commit

Permalink
fix crash at line 340 when shooting fire twice in a row
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Feb 4, 2018
1 parent f620671 commit 8241364
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions project/src/states/Game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,14 @@ local function initializePlayerCharacter(spawnX,spawnY)
-- world:DestroyBody(sprite_list[k].body)

for kk,vv in pairs(destroy_queue) do
sprite_list[destroy_queue[kk]].body:destroy()
sprite_list[destroy_queue[kk]] = nil --actually remove agents from game
destroy_queue[kk] = nil
if destroy_queue[kk]~= nil and -- prevents crashes when shooting too fast
sprite_list[destroy_queue[kk]] ~= nil and
sprite_list[destroy_queue[kk]].body ~= nil then

sprite_list[destroy_queue[kk]].body:destroy()
sprite_list[destroy_queue[kk]] = nil --actually remove agents from game
destroy_queue[kk] = nil
end
end
--sprite_list[k] = nil
end)
Expand Down

0 comments on commit 8241364

Please sign in to comment.