mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 01:34:01 +00:00
[MIRROR] Fix halloweens races [MDB IGNORE] (#17270)
* Fix halloweens races * update modular * Apply suggestions from code review Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,7 @@ SUBSYSTEM_DEF(communications)
|
||||
* * user - Mob who called the meeting
|
||||
*/
|
||||
/datum/controller/subsystem/communications/proc/can_make_emergency_meeting(mob/living/user)
|
||||
if(!(SSevents.holidays && SSevents.holidays[APRIL_FOOLS]))
|
||||
if(!check_holidays(APRIL_FOOLS))
|
||||
return FALSE
|
||||
else if(COOLDOWN_FINISHED(src, emergency_meeting_cooldown))
|
||||
return TRUE
|
||||
|
||||
@@ -11,7 +11,6 @@ SUBSYSTEM_DEF(events)
|
||||
var/frequency_lower = 1800 //3 minutes lower bound.
|
||||
var/frequency_upper = 6000 //10 minutes upper bound. Basically an event will happen every 3 to 10 minutes.
|
||||
|
||||
var/list/holidays //List of all holidays occuring today or null if no holidays
|
||||
var/wizardmode = FALSE
|
||||
|
||||
var/list/previously_run = list() //SKYRAT EDIT ADDITION
|
||||
@@ -23,7 +22,9 @@ SUBSYSTEM_DEF(events)
|
||||
continue //don't want this one! leave it for the garbage collector
|
||||
control += E //add it to the list of all events (controls)
|
||||
reschedule()
|
||||
getHoliday()
|
||||
// Instantiate our holidays list if it hasn't been already
|
||||
if(isnull(GLOB.holidays))
|
||||
fill_holidays()
|
||||
// SKYRAT EDIT ADDITION
|
||||
if(CONFIG_GET(flag/low_chaos_event_system))
|
||||
reschedule_low_chaos()
|
||||
@@ -123,33 +124,58 @@ SUBSYSTEM_DEF(events)
|
||||
else if(. == EVENT_READY)
|
||||
E.runEvent(random = TRUE)
|
||||
|
||||
/*
|
||||
//////////////
|
||||
// HOLIDAYS //
|
||||
//////////////
|
||||
//Uncommenting ALLOW_HOLIDAYS in config.txt will enable holidays
|
||||
|
||||
//It's easy to add stuff. Just add a holiday datum in code/modules/holiday/holidays.dm
|
||||
//You can then check if it's a special day in any code in the game by doing if(SSevents.holidays["Groundhog Day"])
|
||||
/datum/controller/subsystem/events/proc/toggleWizardmode()
|
||||
wizardmode = !wizardmode
|
||||
message_admins("Summon Events has been [wizardmode ? "enabled, events will occur every [SSevents.frequency_lower / 600] to [SSevents.frequency_upper / 600] minutes" : "disabled"]!")
|
||||
log_game("Summon Events was [wizardmode ? "enabled" : "disabled"]!")
|
||||
|
||||
//You can also make holiday random events easily thanks to Pete/Gia's system.
|
||||
//simply make a random event normally, then assign it a holidayID string which matches the holiday's name.
|
||||
//Anything with a holidayID, which isn't in the holidays list, will never occur.
|
||||
|
||||
//Please, Don't spam stuff up with stupid stuff (key example being april-fools Pooh/ERP/etc),
|
||||
//And don't forget: CHECK YOUR CODE!!!! We don't want any zero-day bugs which happen only on holidays and never get found/fixed!
|
||||
/datum/controller/subsystem/events/proc/resetFrequency()
|
||||
frequency_lower = initial(frequency_lower)
|
||||
frequency_upper = initial(frequency_upper)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//ALSO, MOST IMPORTANTLY: Don't add stupid stuff! Discuss bonus content with Project-Heads first please!//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
/**
|
||||
* HOLIDAYS
|
||||
*
|
||||
* Uncommenting ALLOW_HOLIDAYS in config.txt will enable holidays
|
||||
*
|
||||
* It's easy to add stuff. Just add a holiday datum in code/modules/holiday/holidays.dm
|
||||
* You can then check if it's a special day in any code in the game by calling check_holidays("Groundhog Day")
|
||||
*
|
||||
* You can also make holiday random events easily thanks to Pete/Gia's system.
|
||||
* simply make a random event normally, then assign it a holidayID string which matches the holiday's name.
|
||||
* Anything with a holidayID, which isn't in the holidays list, will never occur.
|
||||
*
|
||||
* Please, Don't spam stuff up with stupid stuff (key example being april-fools Pooh/ERP/etc),
|
||||
* and don't forget: CHECK YOUR CODE!!!! We don't want any zero-day bugs which happen only on holidays and never get found/fixed!
|
||||
*/
|
||||
GLOBAL_LIST(holidays)
|
||||
|
||||
//sets up the holidays and holidays list
|
||||
/datum/controller/subsystem/events/proc/getHoliday()
|
||||
/**
|
||||
* Checks that the passed holiday is located in the global holidays list.
|
||||
*
|
||||
* Returns a holiday datum, or null if it's not that holiday.
|
||||
*/
|
||||
/proc/check_holidays(holiday_to_find)
|
||||
if(!CONFIG_GET(flag/allow_holidays))
|
||||
return // Holiday stuff was not enabled in the config!
|
||||
for(var/H in subtypesof(/datum/holiday))
|
||||
var/datum/holiday/holiday = new H()
|
||||
|
||||
if(isnull(GLOB.holidays) && !fill_holidays())
|
||||
return // Failed to generate holidays, for some reason
|
||||
|
||||
return GLOB.holidays[holiday_to_find]
|
||||
|
||||
/**
|
||||
* Fills the holidays list if applicable, or leaves it an empty list.
|
||||
*/
|
||||
/proc/fill_holidays()
|
||||
if(!CONFIG_GET(flag/allow_holidays))
|
||||
return FALSE // Holiday stuff was not enabled in the config!
|
||||
|
||||
GLOB.holidays = list()
|
||||
for(var/holiday_type in subtypesof(/datum/holiday))
|
||||
var/datum/holiday/holiday = new holiday_type()
|
||||
var/delete_holiday = TRUE
|
||||
for(var/timezone in holiday.timezones)
|
||||
var/time_in_timezone = world.realtime + timezone HOURS
|
||||
@@ -161,24 +187,16 @@ SUBSYSTEM_DEF(events)
|
||||
|
||||
if(holiday.shouldCelebrate(DD, MM, YYYY, DDD))
|
||||
holiday.celebrate()
|
||||
LAZYSET(holidays, holiday.name, holiday)
|
||||
GLOB.holidays[holiday.name] = holiday
|
||||
delete_holiday = FALSE
|
||||
break
|
||||
if(delete_holiday)
|
||||
qdel(holiday)
|
||||
|
||||
if(holidays)
|
||||
holidays = shuffle(holidays)
|
||||
if(GLOB.holidays.len)
|
||||
shuffle_inplace(GLOB.holidays)
|
||||
// regenerate station name because holiday prefixes.
|
||||
set_station_name(new_station_name())
|
||||
world.update_status()
|
||||
|
||||
/datum/controller/subsystem/events/proc/toggleWizardmode()
|
||||
wizardmode = !wizardmode
|
||||
message_admins("Summon Events has been [wizardmode ? "enabled, events will occur every [SSevents.frequency_lower / 600] to [SSevents.frequency_upper / 600] minutes" : "disabled"]!")
|
||||
log_game("Summon Events was [wizardmode ? "enabled" : "disabled"]!")
|
||||
|
||||
|
||||
/datum/controller/subsystem/events/proc/resetFrequency()
|
||||
frequency_lower = initial(frequency_lower)
|
||||
frequency_upper = initial(frequency_upper)
|
||||
return TRUE
|
||||
|
||||
@@ -284,10 +284,10 @@ SUBSYSTEM_DEF(ticker)
|
||||
current_state = GAME_STATE_PLAYING
|
||||
Master.SetRunLevel(RUNLEVEL_GAME)
|
||||
|
||||
if(SSevents.holidays)
|
||||
if(length(GLOB.holidays))
|
||||
to_chat(world, span_notice("and..."))
|
||||
for(var/holidayname in SSevents.holidays)
|
||||
var/datum/holiday/holiday = SSevents.holidays[holidayname]
|
||||
for(var/holidayname in GLOB.holidays)
|
||||
var/datum/holiday/holiday = GLOB.holidays[holidayname]
|
||||
to_chat(world, "<h4>[holiday.greet()]</h4>")
|
||||
|
||||
PostSetup()
|
||||
|
||||
Reference in New Issue
Block a user