Skip to content

Commit

Permalink
fix: three small mapmanip followup issues (#27200)
Browse files Browse the repository at this point in the history
* fix: two small mapmanip followup issues

* also qdel edge helper markers

* return init hints instead
  • Loading branch information
warriorstar-orion authored Oct 29, 2024
1 parent f38ccd7 commit a70062a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ $RECYCLE.BIN

# Rust output.
/rust/target/*
rustlibs_panic.txt

# mkdocs output.
site
12 changes: 10 additions & 2 deletions code/game/objects/effects/map_effects/mapmanip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/obj/effect/map_effect/marker/mapmanip/Initialize(mapload)
. = ..()
qdel(src)
return INITIALIZE_HINT_QDEL

/obj/effect/map_effect/marker/mapmanip/submap/extract
name = "mapmanip marker, extract submap"
Expand All @@ -20,7 +20,15 @@
pixel_x = -32
pixel_y = -32

/obj/effect/map_effect/marker_helper
name = "marker helper"
layer = POINT_LAYER

/obj/effect/map_effect/marker_helper/Initialize(mapload)
. = ..()
return INITIALIZE_HINT_QDEL

/obj/effect/map_effect/marker_helper/mapmanip/submap/edge
name = "mapmanip helper marker, edge of submap"
name = "mapmanip marker helper, submap edge"
icon = 'icons/effects/mapping_helpers.dmi'
icon_state = "mapmanip_submap_edge"
19 changes: 10 additions & 9 deletions code/modules/awaymissions/maploader/reader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,26 @@ GLOBAL_DATUM_INIT(_preloader, /datum/dmm_suite/preloader, new())
* allowed to romp unchecked.
*/
/datum/dmm_suite/proc/load_map(dmm_file, x_offset = 0, y_offset = 0, z_offset = 0, shouldCropMap = FALSE, measureOnly = FALSE)
var/tfile = dmm_file// the map file we're creating
var/map_data
var/fname = "Lambda"
if(isfile(tfile))
fname = "[tfile]"
if(isfile(dmm_file))
fname = "[dmm_file]"
// Make sure we dont load a dir up
var/lastchar = copytext(fname, -1)
if(lastchar == "/" || lastchar == "\\")
log_debug("Attempted to load map template without filename (Attempted [tfile])")
log_debug("Attempted to load map template without filename (Attempted [dmm_file])")
return

// use rustlib to read, parse, process, mapmanip etc
// this will "crash"/stacktrace on fail
tfile = mapmanip_read_dmm(fname)
// is not passed `dmm_file` because byondapi-rs doesn't support resource types yet
map_data = mapmanip_read_dmm(fname)
// if rustlib for whatever reason fails and returns null
// try to load it the old dm way instead
if(!tfile)
tfile = wrap_file2text(fname)
if(!map_data)
map_data = wrap_file2text(dmm_file)

if(!length(tfile))
if(!length(map_data))
throw EXCEPTION("Map path '[fname]' does not exist!")

if(!x_offset)
Expand All @@ -65,7 +66,7 @@ GLOBAL_DATUM_INIT(_preloader, /datum/dmm_suite/preloader, new())
log_debug("[measureOnly ? "Measuring" : "Loading"] map: [fname]")
try
LM.index = 1
while(dmmRegex.Find(tfile, LM.index))
while(dmmRegex.Find(map_data, LM.index))
LM.index = dmmRegex.next

// "aa" = (/type{vars=blah})
Expand Down

0 comments on commit a70062a

Please sign in to comment.