Skip to content

Commit

Permalink
fixed nuclear caravans. resolves pyanodon/pybugreports#334
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Nov 19, 2023
1 parent 69259ca commit 10b163e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Date: ???
- removed unused xyhiphoe blood prototype (https://github.com/pyanodon/pybugreports/issues/341)
- fixed the logistic station to display units in megawatts instead of milliwatts
- fixed that fawogae spores name did not have mk numbers
- fixed nuclear caravans (https://github.com/pyanodon/pybugreports/issues/334)
---------------------------------------------------------------------------------------------------
Version: 2.1.9
Date: 2023-9-4
Expand Down
13 changes: 4 additions & 9 deletions scripts/caravan/caravan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ end
Caravan.events.ai_command_completed = function(event)
local unit_number = event.unit_number
local caravan_data = global.caravans[unit_number]
if not Caravan.validity_check(caravan_data) then return end
if not caravan_data or not Caravan.validity_check(caravan_data) then return end
local schedule = caravan_data.schedule[caravan_data.schedule_id]
local status = event.result
if not schedule then stop_actions(caravan_data); goto update_gui end
Expand Down Expand Up @@ -414,7 +414,7 @@ Caravan.events.ai_command_completed = function(event)
}
local prototype = prototypes[entity.name]
if prototype.requeue_required then
Caravan.requeue(prototype)
global.caravan_queue = nil
caravan_data.arrival_tick = game.tick
end
end
Expand All @@ -426,10 +426,6 @@ Caravan.events.ai_command_completed = function(event)
end
end

function Caravan.requeue(prototype)
if prototype and prototype.requeue_required then global.caravan_queue = nil end
end

local function caravan_sort_function(a, b)
return (a.arrival_tick or 0) < (b.arrival_tick or 0)
end
Expand Down Expand Up @@ -585,7 +581,7 @@ Caravan.events.on_built = function(event)
Caravan.instantiate_caravan(entity)
end
script.register_on_entity_destroyed(entity)
Caravan.requeue(prototype)
global.caravan_queue = nil
end

Caravan.events.on_destroyed = function(event)
Expand All @@ -597,8 +593,7 @@ Caravan.events.on_destroyed = function(event)
if buffer then
buffer[1].tags = {unit_number = entity.unit_number}
end

Caravan.requeue(prototype)
global.caravan_queue = nil
end

Caravan.events.on_entity_destroyed = function(event)
Expand Down

0 comments on commit 10b163e

Please sign in to comment.