diff --git a/code/__DEFINES/MC.dm b/code/__DEFINES/MC.dm index fe48edd266..65be8258a1 100644 --- a/code/__DEFINES/MC.dm +++ b/code/__DEFINES/MC.dm @@ -20,7 +20,7 @@ #define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;} #define START_PROCESSING(Processor, Datum) if (!(Datum.datum_flags & DF_ISPROCESSING)) {Datum.datum_flags |= DF_ISPROCESSING;Processor.processing += Datum} -#define STOP_PROCESSING(Processor, Datum) Datum.datum_flags &= ~DF_ISPROCESSING;Processor.processing -= Datum +#define STOP_PROCESSING(Processor, Datum) Datum.datum_flags &= ~DF_ISPROCESSING;Processor.processing -= Datum;Processor.currentrun -= Datum //SubSystem flags (Please design any new flags so that the default is off, to make adding flags to subsystems easier) diff --git a/code/controllers/subsystem/weather.dm b/code/controllers/subsystem/processing/weather.dm similarity index 77% rename from code/controllers/subsystem/weather.dm rename to code/controllers/subsystem/processing/weather.dm index 5e44f2e4c3..0a1b4fc609 100644 --- a/code/controllers/subsystem/weather.dm +++ b/code/controllers/subsystem/processing/weather.dm @@ -4,25 +4,16 @@ #define END_STAGE 4 //Used for all kinds of weather, ex. lavaland ash storms. -SUBSYSTEM_DEF(weather) +PROCESSING_SUBSYSTEM_DEF(weather) name = "Weather" flags = SS_BACKGROUND wait = 10 runlevels = RUNLEVEL_GAME - var/list/processing = list() var/list/eligible_zlevels = list() var/list/next_hit_by_zlevel = list() //Used by barometers to know when the next storm is coming -/datum/controller/subsystem/weather/fire() - // process active weather - for(var/V in processing) - var/datum/weather/W = V - if(W.aesthetic || W.stage != MAIN_STAGE) - continue - for(var/i in GLOB.mob_living_list) - var/mob/living/L = i - if(W.can_weather_act(L)) - W.weather_act(L) +/datum/controller/subsystem/processing/weather/fire() + . = ..() //Active weather is handled by . = ..() processing subsystem base fire(). // start random weather on relevant levels for(var/z in eligible_zlevels) @@ -34,7 +25,7 @@ SUBSYSTEM_DEF(weather) addtimer(CALLBACK(src, .proc/make_eligible, z, possible_weather), randTime + initial(W.weather_duration_upper), TIMER_UNIQUE) //Around 5-10 minutes between weathers next_hit_by_zlevel["[z]"] = world.time + randTime + initial(W.telegraph_duration) -/datum/controller/subsystem/weather/Initialize(start_timeofday) +/datum/controller/subsystem/processing/weather/Initialize(start_timeofday) for(var/V in subtypesof(/datum/weather)) var/datum/weather/W = V var/probability = initial(W.probability) @@ -47,7 +38,7 @@ SUBSYSTEM_DEF(weather) eligible_zlevels["[z]"][W] = probability return ..() -/datum/controller/subsystem/weather/proc/run_weather(datum/weather/weather_datum_type, z_levels) +/datum/controller/subsystem/processing/weather/proc/run_weather(datum/weather/weather_datum_type, z_levels) if (istext(weather_datum_type)) for (var/V in subtypesof(/datum/weather)) var/datum/weather/W = V @@ -69,11 +60,11 @@ SUBSYSTEM_DEF(weather) var/datum/weather/W = new weather_datum_type(z_levels) W.telegraph() -/datum/controller/subsystem/weather/proc/make_eligible(z, possible_weather) +/datum/controller/subsystem/processing/weather/proc/make_eligible(z, possible_weather) eligible_zlevels[z] = possible_weather next_hit_by_zlevel["[z]"] = null -/datum/controller/subsystem/weather/proc/get_weather(z, area/active_area) +/datum/controller/subsystem/processing/weather/proc/get_weather(z, area/active_area) var/datum/weather/A for(var/V in processing) var/datum/weather/W = V diff --git a/code/datums/weather/weather.dm b/code/datums/weather/weather.dm index 01b9facbb8..6761ecbb4c 100644 --- a/code/datums/weather/weather.dm +++ b/code/datums/weather/weather.dm @@ -61,7 +61,7 @@ if(A.z in impacted_z_levels) impacted_areas |= A weather_duration = rand(weather_duration_lower, weather_duration_upper) - START_PROCESSING(SSweather, src) + START_PROCESSING(SSweather, src) //The reason this doesn't start and stop at main stage is because processing list is also used to see active running weathers (for example, you wouldn't want two ash storms starting at once.) update_areas() for(var/M in GLOB.player_list) var/turf/mob_turf = get_turf(M) @@ -107,6 +107,14 @@ STOP_PROCESSING(SSweather, src) update_areas() +/datum/weather/process() + if(aesthetic || (stage != MAIN_STAGE)) + return + for(var/i in GLOB.mob_living_list) + var/mob/living/L = i + if(can_weather_act(L)) + weather_act(L) + /datum/weather/proc/can_weather_act(mob/living/L) //Can this weather impact a mob? var/turf/mob_turf = get_turf(L) if(mob_turf && !(mob_turf.z in impacted_z_levels)) diff --git a/tgstation.dme b/tgstation.dme index 927027d448..e7d5e50b54 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -292,7 +292,6 @@ #include "code\controllers\subsystem\vis_overlays.dm" #include "code\controllers\subsystem\vore.dm" #include "code\controllers\subsystem\vote.dm" -#include "code\controllers\subsystem\weather.dm" #include "code\controllers\subsystem\processing\chemistry.dm" #include "code\controllers\subsystem\processing\circuit.dm" #include "code\controllers\subsystem\processing\fastprocess.dm" @@ -303,6 +302,7 @@ #include "code\controllers\subsystem\processing\processing.dm" #include "code\controllers\subsystem\processing\projectiles.dm" #include "code\controllers\subsystem\processing\quirks.dm" +#include "code\controllers\subsystem\processing\weather.dm" #include "code\controllers\subsystem\processing\wet_floors.dm" #include "code\datums\action.dm" #include "code\datums\ai_laws.dm"