Files
Bubberstation/code/modules/mapping/modular_map_loader/modular_map_loader.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

78 lines
2.0 KiB
Plaintext

/obj/modular_map_root
invisibility = INVISIBILITY_ABSTRACT
icon = 'icons/obj/device.dmi'
icon_state = "pinonclose"
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
anchored = TRUE
/// Points to a .toml file storing configuration data about the modules associated with this root
var/config_file = null
/// Key used to look up the appropriate map paths in the associated .toml file
var/key = null
INITIALIZE_IMMEDIATE(/obj/modular_map_root)
/obj/modular_map_root/Initialize(mapload)
. = ..()
INVOKE_ASYNC(src, PROC_REF(load_map))
/// Randonly selects a map file from the TOML config specified in config_file, loads it, then deletes itself.
/obj/modular_map_root/proc/load_map()
var/turf/spawn_area = get_turf(src)
var/datum/map_template/map_module/map = new()
if(!config_file)
return
if(!key)
return
var/config = rustg_read_toml_file(config_file)
var/mapfile = config["directory"] + pick(config["rooms"][key]["modules"])
map.load(spawn_area, FALSE, mapfile)
qdel(src, force=TRUE)
/datum/map_template/map_module
name = "Base Map Module Template"
var/x_offset = 0
var/y_offset = 0
/datum/map_template/map_module/load(turf/T, centered = FALSE, mapfile = null)
if(!mapfile)
return
mappath = mapfile
preload_size(mappath) // We need to run this here as the map path has been null until now
T = locate(T.x - x_offset, T.y - y_offset, T.z)
. = ..()
/datum/map_template/map_module/preload_size(path, cache)
. = ..(path, TRUE) // Done this way because we still want to know if someone actualy wanted to cache the map
if(!cached_map)
return
var/list/offset = discover_offset(/obj/modular_map_connector)
x_offset = offset[1] - 1
y_offset = offset[2] - 1
if(!cache)
cached_map = null
/obj/modular_map_connector
invisibility = INVISIBILITY_ABSTRACT
icon = 'icons/obj/device.dmi'
icon_state = "pinonclose"
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
anchored = TRUE