mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Fixes map element overwriting option (#31978)
* Fixes vault overwriting option * Saner method of looping * Actually works nice now * Makes this static for performance * Some debug logging for how long a vault takes to load * Here too * Removing logging, for future PR * Changing this to handle qdels better * Fixes how vending machines do it too * Requested changes * Forgot this too * And this * APC cells * Set this to null too Co-authored-by: kanef <kanef9x@protonmail.com>
This commit is contained in:
@@ -106,14 +106,14 @@
|
||||
L[T] = MAX_VALUE //Set them equal to the max value which is unlikely to collide with any other pregenerated value
|
||||
|
||||
//Removes returns a new list which only contains elements from the original list of a certain type
|
||||
/proc/prune_list_to_type(list/L, datum/A)
|
||||
/proc/prune_list_to_type(list/L, datum/A, var/exclude_type = FALSE)
|
||||
if(!L || !L.len || !A)
|
||||
return 0
|
||||
return list()
|
||||
if(!ispath(A))
|
||||
A = A.type
|
||||
var/list/nu = L.Copy()
|
||||
for(var/element in nu)
|
||||
if(!istype(element,A))
|
||||
if(istype(element,A) == exclude_type)
|
||||
nu -= element
|
||||
return nu
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ var/list/datum/map_element/map_elements = list()
|
||||
for(var/atom/A in objects)
|
||||
A.spawned_by_map_element(src, objects)
|
||||
|
||||
/datum/map_element/proc/load(x, y, z, rotate=0, override_can_rotate = FALSE)
|
||||
/datum/map_element/proc/load(x, y, z, rotate=0, overwrite = FALSE, override_can_rotate = FALSE)
|
||||
//Location is always lower left corner.
|
||||
//In some cases, location is set to null (when creating a new z-level, for example)
|
||||
//To account for that, location is set again in maploader's load_map() proc
|
||||
@@ -53,7 +53,7 @@ var/list/datum/map_element/map_elements = list()
|
||||
if(file_path)
|
||||
var/file = file(file_path)
|
||||
if(isfile(file))
|
||||
var/list/L = maploader.load_map(file, z, x, y, src, rotation)
|
||||
var/list/L = maploader.load_map(file, z, x, y, src, rotation, overwrite)
|
||||
initialize(L)
|
||||
return L
|
||||
else //No file specified - empty map element
|
||||
|
||||
@@ -187,7 +187,12 @@ var/global/num_vending_terminals = 1
|
||||
if(wires)
|
||||
qdel(wires)
|
||||
wires = null
|
||||
if(coinbox)
|
||||
qdel(coinbox)
|
||||
coinbox = null
|
||||
..()
|
||||
|
||||
/obj/machinery/vending/proc/dump_vendpack_and_coinbox()
|
||||
if(product_records.len && cardboard) //Only spit out if we have slotted cardboard
|
||||
if(is_custom_machine)
|
||||
var/obj/structure/vendomatpack/custom/newpack = new(src.loc)
|
||||
@@ -207,7 +212,6 @@ var/global/num_vending_terminals = 1
|
||||
|
||||
if(coinbox)
|
||||
coinbox.forceMove(get_turf(src))
|
||||
..()
|
||||
|
||||
/obj/machinery/vending/examine(var/mob/user)
|
||||
..()
|
||||
@@ -322,10 +326,12 @@ var/global/num_vending_terminals = 1
|
||||
/obj/machinery/vending/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1.0)
|
||||
dump_vendpack_and_coinbox()
|
||||
qdel(src)
|
||||
return
|
||||
if(2.0)
|
||||
if (prob(50))
|
||||
dump_vendpack_and_coinbox()
|
||||
qdel(src)
|
||||
return
|
||||
if(3.0)
|
||||
@@ -337,6 +343,7 @@ var/global/num_vending_terminals = 1
|
||||
if(prob(75))
|
||||
malfunction()
|
||||
else
|
||||
dump_vendpack_and_coinbox()
|
||||
qdel(src)
|
||||
|
||||
/obj/machinery/vending/emp_act(severity)
|
||||
|
||||
@@ -86,11 +86,6 @@
|
||||
..()
|
||||
take_contents()
|
||||
|
||||
// Fix for #383 - C4 deleting fridges with corpses
|
||||
/obj/structure/closet/Destroy()
|
||||
dump_contents()
|
||||
..()
|
||||
|
||||
/obj/structure/closet/alter_health()
|
||||
return get_turf(src)
|
||||
|
||||
@@ -340,6 +335,7 @@
|
||||
for(var/atom/movable/A in src)//pulls everything else out of the locker and hits it with an explosion
|
||||
A.forceMove(src.loc)
|
||||
A.ex_act(severity++)
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
if(2)
|
||||
if(prob(50))
|
||||
@@ -350,6 +346,7 @@
|
||||
for (var/atom/movable/A as mob|obj in src)
|
||||
A.forceMove(src.loc)
|
||||
A.ex_act(severity++)
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
if(3)
|
||||
if(prob(5))
|
||||
@@ -360,6 +357,7 @@
|
||||
for(var/atom/movable/A as mob|obj in src)
|
||||
A.forceMove(src.loc)
|
||||
A.ex_act(severity++)
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/closet/shuttle_act()
|
||||
@@ -376,8 +374,7 @@
|
||||
broken = 1
|
||||
if(has_electronics)
|
||||
dump_electronics()
|
||||
for(var/atom/movable/A as mob|obj in src)
|
||||
A.forceMove(src.loc)
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
|
||||
return
|
||||
@@ -428,8 +425,7 @@
|
||||
broken = 1
|
||||
if(has_electronics)
|
||||
dump_electronics()
|
||||
for(var/atom/movable/A as mob|obj in src)
|
||||
A.forceMove(src.loc)
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
|
||||
// this should probably use dump_contents()
|
||||
@@ -439,8 +435,7 @@
|
||||
broken = 1
|
||||
if(has_electronics)
|
||||
dump_electronics()
|
||||
for(var/atom/movable/A as mob|obj in src)
|
||||
A.forceMove(src.loc)
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/closet/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
@@ -463,6 +458,7 @@
|
||||
M.show_message("<span class='notice'>\The [src] has been cut apart by [user] with \the [WT].</span>", 1, "You hear welding.", 2)
|
||||
if(has_electronics)
|
||||
dump_electronics()
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
@@ -473,6 +469,7 @@
|
||||
M.show_message("<span class='notice'>\The [src] has been dismantled by [user] with \the [WT].</span>", 1)
|
||||
if(has_electronics)
|
||||
dump_electronics()
|
||||
dump_contents()
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
|
||||
@@ -1211,10 +1211,11 @@ var/list/admin_verbs_mod = list(
|
||||
if(rotate == null)
|
||||
return
|
||||
|
||||
log_admin("[key_name(src)] is loading [ME.file_path] at z-level 2 (location chosen automatically) rotated by [rotate] degrees.")
|
||||
message_admins("[key_name_admin(src)] is loading [ME.file_path] at z-level 2 (location chosen automatically) rotated by [rotate] degrees")
|
||||
var/rotatetext = rotate ? " rotated by [rotate] degrees" : ""
|
||||
log_admin("[key_name(src)] is loading [ME.file_path] at z-level 2 (location chosen automatically)[rotatetext].")
|
||||
message_admins("[key_name_admin(src)] is loading [ME.file_path] at z-level 2 (location chosen automatically)[rotatetext].")
|
||||
load_dungeon(ME, rotate, TRUE)
|
||||
message_admins("[ME.file_path] loaded at [ME.location ? formatJumpTo(ME.location) : "[x_coord], [y_coord], [z_coord]"] rotated by [rotate] degrees")
|
||||
message_admins("[ME.file_path] loaded at [ME.location ? formatJumpTo(ME.location) : "[x_coord], [y_coord], [z_coord]"][rotatetext].")
|
||||
return
|
||||
|
||||
|
||||
@@ -1223,10 +1224,12 @@ var/list/admin_verbs_mod = list(
|
||||
return
|
||||
var/overwrite = alert("Overwrite original objects in area?","Map element loading","Yes","No") == "Yes"
|
||||
|
||||
log_admin("[key_name(src)] is loading [ME.file_path] at [x_coord], [y_coord], [z_coord] rotated by [rotate] degrees")
|
||||
message_admins("[key_name_admin(src)] is loading [ME.file_path] at [x_coord], [y_coord], [z_coord] rotated by [rotate] degrees")
|
||||
ME.load(x_coord - 1, y_coord - 1, z_coord, rotate, overwrite, TRUE) //Reduce X and Y by 1 because these arguments are actually offsets, and they're added to 1;1 in the map loader. Without this, spawning something at 1;1 would result in it getting spawned at 2;2
|
||||
message_admins("[ME.file_path] loaded at [ME.location ? formatJumpTo(ME.location) : "[x_coord], [y_coord], [z_coord]"] rotated by [rotate] degrees")
|
||||
var/rotatetext = rotate ? " rotated by [rotate] degrees" : ""
|
||||
log_admin("[key_name(src)] is loading [ME.file_path] at [x_coord], [y_coord], [z_coord][rotatetext].")
|
||||
message_admins("[key_name_admin(src)] is loading [ME.file_path] at [x_coord], [y_coord], [z_coord][rotatetext].")
|
||||
//Reduce X and Y by 1 because these arguments are actually offsets, and they're added to 1;1 in the map loader. Without this, spawning something at 1;1 would result in it getting spawned at 2;2
|
||||
ME.load(x_coord - 1, y_coord - 1, z_coord, rotate, overwrite, TRUE)
|
||||
message_admins("[ME.file_path] loaded at [ME.location ? formatJumpTo(ME.location) : "[x_coord], [y_coord], [z_coord]"][rotatetext].")
|
||||
|
||||
/client/proc/create_awaymission()
|
||||
set category = "Admin"
|
||||
|
||||
@@ -55,6 +55,7 @@ var/list/map_dimension_cache = list()
|
||||
*
|
||||
*/
|
||||
/dmm_suite/load_map(var/dmm_file as file, var/z_offset as num, var/x_offset as num, var/y_offset as num, var/datum/map_element/map_element as null, var/rotate as num, var/overwrite as num)
|
||||
|
||||
if((rotate % 90) != 0) //If not divisible by 90, make it
|
||||
rotate += (rotate % 90)
|
||||
|
||||
@@ -303,8 +304,14 @@ var/list/map_dimension_cache = list()
|
||||
|
||||
members.Remove(members[index])
|
||||
|
||||
//then instance the /turf and, if multiple tiles are presents, simulates the DMM underlays piling effect (only the last turf is spawned, other ones are drawn as underlays)
|
||||
if(overwrite) //make this come first so lighting overlays don't die
|
||||
var/turf/T_old = locate(xcrd,ycrd,zcrd)
|
||||
var/static/list/blacklisted_types = list(/mob/dead/observer,/mob/dview,/atom/movable/lighting_overlay)
|
||||
for(var/atom/thing as anything in T_old.contents)
|
||||
if(!is_type_in_list(thing.type,blacklisted_types))
|
||||
qdel(thing)
|
||||
|
||||
//then instance the /turf and, if multiple tiles are presents, simulates the DMM underlays piling effect (only the last turf is spawned, other ones are drawn as underlays)
|
||||
var/first_turf_index = 1
|
||||
while(!ispath(members[first_turf_index],/turf)) //find first /turf object in members
|
||||
first_turf_index++
|
||||
@@ -329,10 +336,6 @@ var/list/map_dimension_cache = list()
|
||||
spawned_atoms.Add(T)
|
||||
|
||||
//finally instance all remainings objects/mobs
|
||||
if(overwrite)
|
||||
var/turf/T_old = locate(xcrd,ycrd,zcrd)
|
||||
for(var/atom/thing in T_old)
|
||||
qdel(T_old)
|
||||
for(index=1,index < first_turf_index,index++)
|
||||
var/atom/new_atom = instance_atom(members[index],members_attributes[index],xcrd,ycrd,zcrd,rotate)
|
||||
spawned_atoms.Add(new_atom)
|
||||
|
||||
@@ -584,6 +584,9 @@
|
||||
"<span class='warning'>[src] has been cut from the wall by [user.name] with the weldingtool.</span>",\
|
||||
"You cut the APC frame from the wall.",\
|
||||
"<span class='warning'>You hear welding.</span>")
|
||||
if(cell)
|
||||
cell.forceMove(loc)
|
||||
cell = null
|
||||
qdel(src)
|
||||
return
|
||||
else if (istype(W, /obj/item/mounted/frame/apc_frame) && opened && emagged)
|
||||
@@ -1275,9 +1278,6 @@
|
||||
/obj/machinery/power/apc/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
if(cell)
|
||||
qdel(cell)
|
||||
cell = null
|
||||
qdel(src)
|
||||
if(2)
|
||||
if(prob(50))
|
||||
@@ -1342,7 +1342,7 @@
|
||||
malfvacate(1)
|
||||
|
||||
if(cell)
|
||||
cell.forceMove(loc)
|
||||
qdel(cell)
|
||||
cell = null
|
||||
|
||||
if(wires)
|
||||
|
||||
Reference in New Issue
Block a user