Pauses event processing while doing event actions

This commit is contained in:
Heroman
2020-01-11 20:42:49 +10:00
parent 335676d340
commit 2c6bd784c4
2 changed files with 21 additions and 11 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ SUBSYSTEM_DEF(events)
/datum/controller/subsystem/events/fire(resumed)
for(var/datum/event/E in active_events)
E.process()
if(E.processing_active)
E.process()
for(var/i = EVENT_LEVEL_MUNDANE to EVENT_LEVEL_MAJOR)
var/list/datum/event_container/EC = event_containers[i]
+19 -10
View File
@@ -40,15 +40,16 @@
return total_weight
/datum/event //NOTE: Times are measured in master controller ticks!
var/startWhen = 0 //When in the lifetime to call start().
var/announceWhen = 0 //When in the lifetime to call announce().
var/endWhen = 0 //When in the lifetime the event should end.
var/startWhen = 0 //When in the lifetime to call start().
var/announceWhen = 0 //When in the lifetime to call announce().
var/endWhen = 0 //When in the lifetime the event should end.
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/startedAt = 0 //When this event started.
var/endedAt = 0 //When this event ended.
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 = 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())