Fix: Event manager list index out of bounds

This commit prevents a runtime of "list index out of bounds" with events
by adding a simple sanity checking system, so that the list checked always
has a valid check, regardless of if the event has a valid variable. NOTE:
May result in unintended behaviour if an event tries to complete with an
invalid severity level. It will always be set to moderate, as that is a
safe assumption for the code to make.
This commit is contained in:
Tigercat2000
2015-05-12 18:33:24 -07:00
parent b192bfd34c
commit f85be9e742
+12 -1
View File
@@ -39,8 +39,19 @@
finished_events += E
var/theseverity
if(!E.severity)
theseverity = EVENT_LEVEL_MODERATE
if(!E.severity == EVENT_LEVEL_MUNDANE && !E.severity == EVENT_LEVEL_MODERATE && !E.severity == EVENT_LEVEL_MAJOR)
theseverity = EVENT_LEVEL_MODERATE //just to be careful
if(E.severity)
theseverity = E.severity
// Add the event back to the list of available events
var/datum/event_container/EC = event_containers[E.severity]
var/datum/event_container/EC = event_containers[theseverity]
var/datum/event_meta/EM = E.event_meta
EC.available_events += EM