Merge pull request #6620 from Heroman3003/eventpause

Pauses event processing while doing event actions
This commit is contained in:
Atermonera
2020-01-15 20:43:25 -08:00
committed by VirgoBot
parent 708e0b477e
commit 4fb26a6429
2 changed files with 21 additions and 11 deletions

View File

@@ -21,6 +21,7 @@ SUBSYSTEM_DEF(events)
/datum/controller/subsystem/events/fire(resumed)
for(var/datum/event/E in active_events)
if(E.processing_active)
E.process()
for(var/i = EVENT_LEVEL_MUNDANE to EVENT_LEVEL_MAJOR)

View File

@@ -46,9 +46,10 @@
var/severity = 0 //Severity. Lower means less severe, higher means more severe. Does not have to be supported. Is set on New().
var/activeFor = 0 //How long the event has existed. You don't need to change this.
var/isRunning = 1 //If this event is currently running. You should not change this.
var/isRunning = TRUE //If this event is currently running. You should not change this.
var/startedAt = 0 //When this event started.
var/endedAt = 0 //When this event ended.
var/processing_active = TRUE
var/datum/event_meta/event_meta = null
/datum/event/nothing
@@ -96,18 +97,26 @@
//This proc will handle the calls to the appropiate procs.
/datum/event/process()
if(activeFor > startWhen && activeFor < endWhen)
processing_active = FALSE
tick()
processing_active = TRUE
if(activeFor == startWhen)
isRunning = 1
isRunning = TRUE
processing_active = FALSE
start()
processing_active = TRUE
if(activeFor == announceWhen)
processing_active = FALSE
announce()
processing_active = TRUE
if(activeFor == endWhen)
isRunning = 0
isRunning = FALSE
processing_active = FALSE
end()
processing_active = TRUE
// Everything is done, let's clean up.
if(activeFor >= lastProcessAt())