mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-19 03:55:11 +01:00
Runtime Dynamic Station Loading (#24171)
* Dynamic map loading prototype * Get the title screen working * Fixes the random pod bugs * map configs * Add back the asteroid * Ignore the rotate file * Fix some shit * More shit fixes * Babby's first json * Cyberboss confirmed shitcoder * Makes map rotation great again * Moves the map defines * Delete tgstation2.dm * Convert runtimestation * Convert PubbyStation * Convert OmegaStation * Convert Metastation * Convert Delta Station * Lol file extensions * Reee line endings * Take out the trash * Fix loadallmaps.dm * Deltaassssssstation? * Fix travis * Did I ASK you to change the line endings? * Remove votable maps * Cleanup * Previous config. Load configs in New. Fix splash * Fix this * More generic minetype * STOP TOUCHING THE LINE ENDINGS!!! * Add some flexibility to /obj/screen/splash * Fix the shit * Update gitignore * Smooth transition from last map * Better check * Missed this map rotate check * Remove these checks too * Prep for a future request by @kevinz000 * Fix z2 line endings * Solution for custom .dms * Rename some things, trim some fat * Fixes default map_config * Remove stale comment * Delete the previous config after loading * Don't try to open a non-existent file * Delete the old rotator script * And references to it * Line endings * More line endings * Del checks from when m-config may have not existed * LINE ENDINGS * Update the default map config * Map load error checking for what it's worth * Small cleanup * For case sensitive * File systems * Strip maprotate stuff from build script * Spruce up the _maps tree. Compile some empty space * Make travis simpler * LINEARU ENDARU!!! * tgstation TWO!!! * Lowercase mine type * Dummy dm's for testmerging * Fixes job ordering * If ghosts wanna watch the map load so be it * Let them know what's going on * Fixes z-transitions * Optimize z expansion further * Remove this old var * Fix wiznerd teleportation * Rmove butt * Does the thing * Moved temp configs to the data dir * Un-touch gitignore * Forgot templates.dm * Forgot to include the includer * Fair enough * SILENCE IMBECILE! * @Cyberboss still a fuckboi * Speed things up a bit * Fix a potential bug with the error message * Whatever
This commit is contained in:
@@ -25,13 +25,13 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
* 2) Read the map line by line, parsing the result (using parse_grid)
|
||||
*
|
||||
*/
|
||||
/dmm_suite/load_map(dmm_file as file, x_offset as num, y_offset as num, z_offset as num, cropMap as num, measureOnly as num)
|
||||
/dmm_suite/load_map(dmm_file as file, x_offset as num, y_offset as num, z_offset as num, cropMap as num, measureOnly as num, no_changeturf as num)
|
||||
//How I wish for RAII
|
||||
Master.StartLoadingMap()
|
||||
. = load_map_impl(dmm_file, x_offset, y_offset, z_offset, cropMap, measureOnly)
|
||||
. = load_map_impl(dmm_file, x_offset, y_offset, z_offset, cropMap, measureOnly, no_changeturf)
|
||||
Master.StopLoadingMap()
|
||||
|
||||
/dmm_suite/proc/load_map_impl(dmm_file, x_offset, y_offset, z_offset, cropMap, measureOnly)
|
||||
/dmm_suite/proc/load_map_impl(dmm_file, x_offset, y_offset, z_offset, cropMap, measureOnly, no_changeturf)
|
||||
var/tfile = dmm_file//the map file we're creating
|
||||
if(isfile(tfile))
|
||||
tfile = file2text(tfile)
|
||||
@@ -75,7 +75,8 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
var/ycrd = text2num(dmmRegex.group[4]) + y_offset - 1
|
||||
var/zcrd = text2num(dmmRegex.group[5]) + z_offset - 1
|
||||
|
||||
if(zcrd > world.maxz)
|
||||
var/zexpansion = zcrd > world.maxz
|
||||
if(zexpansion)
|
||||
if(cropMap)
|
||||
continue
|
||||
else
|
||||
@@ -127,7 +128,7 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
var/model_key = copytext(line, tpos, tpos + key_len)
|
||||
if(!grid_models[model_key])
|
||||
throw EXCEPTION("Undefined model key in DMM.")
|
||||
parse_grid(grid_models[model_key], xcrd, ycrd, zcrd)
|
||||
parse_grid(grid_models[model_key], xcrd, ycrd, zcrd, no_changeturf || zexpansion)
|
||||
CHECK_TICK
|
||||
|
||||
maxx = max(maxx, xcrd)
|
||||
@@ -142,10 +143,11 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
return null
|
||||
else
|
||||
if(!measureOnly)
|
||||
for(var/t in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]), locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
|
||||
var/turf/T = t
|
||||
//we do this after we load everything in. if we don't; we'll have weird atmos bugs regarding atmos adjacent turfs
|
||||
T.AfterChange(TRUE)
|
||||
if(!no_changeturf)
|
||||
for(var/t in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]), locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
|
||||
var/turf/T = t
|
||||
//we do this after we load everything in. if we don't; we'll have weird atmos bugs regarding atmos adjacent turfs
|
||||
T.AfterChange(TRUE)
|
||||
return bounds
|
||||
|
||||
/**
|
||||
@@ -165,7 +167,7 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
* 4) Instanciates the atom with its variables
|
||||
*
|
||||
*/
|
||||
/dmm_suite/proc/parse_grid(model as text,xcrd as num,ycrd as num,zcrd as num)
|
||||
/dmm_suite/proc/parse_grid(model as text,xcrd as num,ycrd as num,zcrd as num, no_changeturf as num)
|
||||
/*Method parse_grid()
|
||||
- Accepts a text string containing a comma separated list of type paths of the
|
||||
same construction as those contained in a .dmm file, and instantiates them.
|
||||
@@ -253,20 +255,20 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
//instanciate the first /turf
|
||||
var/turf/T
|
||||
if(members[first_turf_index] != /turf/template_noop)
|
||||
T = instance_atom(members[first_turf_index],members_attributes[first_turf_index],xcrd,ycrd,zcrd)
|
||||
T = instance_atom(members[first_turf_index],members_attributes[first_turf_index],xcrd,ycrd,zcrd,no_changeturf)
|
||||
|
||||
if(T)
|
||||
//if others /turf are presents, simulates the underlays piling effect
|
||||
index = first_turf_index + 1
|
||||
while(index <= members.len - 1) // Last item is an /area
|
||||
var/underlay = T.appearance
|
||||
T = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)//instance new turf
|
||||
T = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd,no_changeturf)//instance new turf
|
||||
T.underlays += underlay
|
||||
index++
|
||||
|
||||
//finally instance all remainings objects/mobs
|
||||
for(index in 1 to first_turf_index-1)
|
||||
instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd)
|
||||
instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd,no_changeturf)
|
||||
|
||||
//custom CHECK_TICK here because we don't want things created while we're sleeping to not initialize
|
||||
if(world.tick_usage > CURRENT_TICKLIMIT)
|
||||
@@ -281,13 +283,13 @@ var/global/dmm_suite/preloader/_preloader = new
|
||||
////////////////
|
||||
|
||||
//Instance an atom at (x,y,z) and gives it the variables in attributes
|
||||
/dmm_suite/proc/instance_atom(path,list/attributes, x, y, z)
|
||||
/dmm_suite/proc/instance_atom(path,list/attributes, x, y, z, no_changeturf)
|
||||
var/atom/instance
|
||||
_preloader.setup(attributes, path)
|
||||
|
||||
var/turf/T = locate(x,y,z)
|
||||
if(T)
|
||||
if(ispath(path, /turf))
|
||||
if(!no_changeturf && ispath(path, /turf))
|
||||
T.ChangeTurf(path, TRUE)
|
||||
instance = T
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user