Update DMM Suite (#2711)

Updates the DMM Suite from /tg/ upstream, adding the ability to load tgm format maps, tick-checks, and better compatibility with SSatoms / Initialize().

Also adds some framework for random ruin generation, though it is not functional yet.
This commit is contained in:
Lohikar
2017-06-15 04:41:45 -05:00
committed by skull132
parent 4552fae7f5
commit 1423250412
16 changed files with 515 additions and 363 deletions

View File

@@ -17,3 +17,9 @@
// Called when SSexplosives finishes processing all queued explosions.
/datum/controller/proc/ExplosionEnd()
//when we enter dmm_suite.load_map
/datum/controller/proc/StartLoadingMap()
//when we exit dmm_suite.load_map
/datum/controller/proc/StopLoadingMap()

View File

@@ -7,10 +7,6 @@
*
**/
var/datum/controller/master/Master = new()
var/MC_restart_clear = 0
var/MC_restart_timeout = 0
var/MC_restart_count = 0
//current tick limit, assigned by the queue controller before running a subsystem.
//used by check_tick as well so that the procs subsystems call can obey that SS's tick limits
@@ -53,6 +49,11 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
var/datum/controller/subsystem/queue_tail //End of queue linked list (used for appending to the list)
var/queue_priority_count = 0 //Running total so that we don't have to loop thru the queue each run to split up the tick
var/queue_priority_count_bg = 0 //Same, but for background subsystems
var/map_loading = FALSE //Are we loading in a new map?
var/static/restart_clear = 0
var/static/restart_timeout = 0
var/static/restart_count = 0
/datum/controller/master/New()
// Highlander-style: there can only be one! Kill off the old and replace it with the new.
@@ -79,14 +80,14 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
// -1 if we encountered a runtime trying to recreate it
/proc/Recreate_MC()
. = -1 //so if we runtime, things know we failed
if (world.time < MC_restart_timeout)
if (world.time < Master.restart_timeout)
return 0
if (world.time < MC_restart_clear)
MC_restart_count *= 0.5
if (world.time < Master.restart_clear)
Master.restart_count *= 0.5
var/delay = 50 * ++MC_restart_count
MC_restart_timeout = world.time + delay
MC_restart_clear = world.time + (delay * 2)
var/delay = 50 * ++Master.restart_count
Master.restart_timeout = world.time + delay
Master.restart_clear = world.time + (delay * 2)
Master.processing = 0 //stop ticking this one
try
new/datum/controller/master()
@@ -553,3 +554,18 @@ var/CURRENT_TICKLIMIT = TICK_LIMIT_RUNNING
if (SSticker.current_state >= GAME_STATE_PLAYING)
return TRUE
return FALSE
/datum/controller/master/StartLoadingMap()
//disallow more than one map to load at once, multithreading it will just cause race conditions
while(map_loading)
stoplag()
for(var/S in subsystems)
var/datum/controller/subsystem/SS = S
SS.StartLoadingMap()
map_loading = TRUE
/datum/controller/master/StopLoadingMap(bounds = null)
map_loading = FALSE
for(var/S in subsystems)
var/datum/controller/subsystem/SS = S
SS.StopLoadingMap()

View File

@@ -144,6 +144,13 @@ var/datum/controller/subsystem/atoms/SSatoms
InitializeAtoms()
old_initialized = SSatoms.old_initialized
/datum/controller/subsystem/atoms/proc/map_loader_begin()
old_initialized = initialized
initialized = INITIALIZATION_INSSATOMS
/datum/controller/subsystem/atoms/proc/map_loader_stop()
initialized = old_initialized
#undef BAD_INIT_QDEL_BEFORE
#undef BAD_INIT_DIDNT_INIT
#undef BAD_INIT_SLEPT

View File

@@ -7,8 +7,8 @@
flags = SS_NO_FIRE | SS_NO_DISPLAY
/datum/controller/subsystem/misc_late/Initialize(timeofday)
// Sort the area list.
sortTim(all_areas, /proc/cmp_name_asc)
// Generate the area list.
resort_all_areas()
var/turf/picked
// Setup the teleport locs.
@@ -38,3 +38,15 @@
shuttle_controller.setup_shuttle_docks()
..(timeofday, TRUE)
/proc/resort_all_areas()
all_areas = list()
for (var/area/A in world)
all_areas += A
sortTim(all_areas, /proc/cmp_text_asc)
/proc/sorted_add_area(area/A)
all_areas += A
sortTim(all_areas, /proc/cmp_text_asc)

View File

@@ -148,6 +148,14 @@
out += "LT:{T:[processes_this_tick]|P:[powerusers_this_tick]}"
..(out.Join("\n\t"))
/datum/controller/subsystem/machinery/proc/setup_template_powernets(list/cables)
for(var/A in cables)
var/obj/structure/cable/PC = A
if(!PC.powernet)
var/datum/powernet/NewPN = new()
NewPN.add_cable(PC)
propagate_network(PC, PC.powernet)
/proc/add_machine(obj/machinery/M)
if (QDELETED(M))
crash_with("Attempted add of QDELETED machine [M ? M : "NULL"] to machines list, ignoring.")