Skip to content

Commit

Permalink
fix mission_end handling
Browse files Browse the repository at this point in the history
On graceful server termination the state file was getting deleted even
if the campaign was not completed. This is because the mission_end event
is fired any time the mission ends. So we need to filter out cases
where the server is restarting and the campaign is not complete.

Closes: #125
Fixes: 903ade6 ("tickets system: add basic ticket accounting system")
  • Loading branch information
jtoppins committed Jan 30, 2021
1 parent 72ce7f0 commit b212207
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dct/Theater.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,14 @@ end
function Theater:onEvent(event)
self:notify(event)
if event.id == world.event.S_EVENT_MISSION_END then
local ok, err = os.remove(settings.statepath)
if not ok then
Logger:error("unable to remove statepath; "..err)
-- Only delete the state if there is an end mission event
-- and tickets are complete, otherwise when a server is
-- shutdown gracefully the state will be deleted.
if self.tickets:isComplete() then
local ok, err = os.remove(settings.statepath)
if not ok then
Logger:error("unable to remove statepath; "..err)
end
end
end
end
Expand Down

0 comments on commit b212207

Please sign in to comment.