Skip to content

Commit

Permalink
[MIRROR] Splits placeontop proc [MDB IGNORE] (#25103)
Browse files Browse the repository at this point in the history
* Splits placeontop proc (#79702)

## About The Pull Request
I find the proc hard to read honestly. There's no reason we can't split
this into two functions - the secondary functionality is used only once,
in reader.dmm.
## Why It's Good For The Game
Code improvement
Glorious snake case
## Changelog
N/A nothing player facing

---------

Co-authored-by: san7890 <34697715+san7890@ users.noreply.github.com>

* Splits placeontop proc

* Update brass_spreader.dm

---------

Co-authored-by: Jeremiah <[email protected]>
Co-authored-by: san7890 <34697715+san7890@ users.noreply.github.com>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
4 people authored and FFMirrorBot committed Nov 19, 2023
1 parent 8bc6cad commit a7c125f
Show file tree
Hide file tree
Showing 32 changed files with 85 additions and 97 deletions.
2 changes: 1 addition & 1 deletion code/datums/components/trapdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
in_use = FALSE
if(!isopenspaceturf(target_turf)) // second check to make sure nothing changed during constructions
return
var/turf/new_turf = target_turf.PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
var/turf/new_turf = target_turf.place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
new_turf.AddComponent(/datum/component/trapdoor, starts_open = FALSE, conspicuous = TRUE)
balloon_alert(user, "trapdoor constructed")
qdel(src)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/elements/movement_turf_changer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
if(!isturf(destination) || istype(destination, turf_type) || isgroundlessturf(destination))
return

destination.PlaceOnTop(turf_type)
destination.place_on_top(turf_type)
2 changes: 1 addition & 1 deletion code/game/machinery/computer/arcade/orion_event.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
game.say("A new floor suddenly appears around [game]. What the hell?")
playsound(game, 'sound/weapons/genhit.ogg', 100, TRUE)
for(var/turf/open/space/fixed in orange(1, game))
fixed.PlaceOnTop(/turf/open/floor/plating)
fixed.place_on_top(/turf/open/floor/plating)

#define BUTTON_EXPLORE_SHIP "Explore Ship"
#define BUTTON_LEAVE_THE_DERELICT "Leave the Derelict"
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
if(do_after(user, 50, target=src))
W.use(5)
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall/mineral/wood/nonmetal)
T.place_on_top(/turf/closed/wall/mineral/wood/nonmetal)
qdel(src)
return
return ..()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
return
to_chat(user, span_notice("You add the plating."))
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall/metal_foam_base)
T.place_on_top(/turf/closed/wall/metal_foam_base)
transfer_fingerprints_to(T)
qdel(src)
return
Expand Down Expand Up @@ -393,7 +393,7 @@
/obj/effect/particle_effect/fluid/foam/metal/smart/make_result() //Smart foam adheres to area borders for walls
var/turf/open/location = loc
if(isspaceturf(location))
location.PlaceOnTop(/turf/open/floor/plating/foam)
location.place_on_top(/turf/open/floor/plating/foam)

for(var/cardinal in GLOB.cardinals)
var/turf/cardinal_turf = get_step(location, cardinal)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/stacks/stack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
var/turf/covered_turf = builder.drop_location()
if(!isturf(covered_turf))
return
var/turf/created_turf = covered_turf.PlaceOnTop(recipe.result_type, flags = CHANGETURF_INHERIT_AIR)
var/turf/created_turf = covered_turf.place_on_top(recipe.result_type, flags = CHANGETURF_INHERIT_AIR)
builder.balloon_alert(builder, "placed [ispath(recipe.result_type, /turf/open) ? "floor" : "wall"]")
if(recipe.applies_mats && LAZYLEN(mats_per_unit))
created_turf.set_custom_materials(mats_per_unit, recipe.req_amount / recipe.res_amount)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/stacks/tiles/tile_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
if(!replace_plating)
if(!use(1))
return
target_plating = target_plating.PlaceOnTop(placed_turf_path, flags = CHANGETURF_INHERIT_AIR)
target_plating = target_plating.place_on_top(placed_turf_path, flags = CHANGETURF_INHERIT_AIR)
target_plating.setDir(turf_dir)
playsound(target_plating, 'sound/weapons/genhit.ogg', 50, TRUE)
return target_plating // Most executions should end here.
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/false_walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

/obj/structure/falsewall/proc/ChangeToWall(delete = 1)
var/turf/T = get_turf(src)
T.PlaceOnTop(walltype)
T.place_on_top(walltype)
if(delete)
qdel(src)
return T
Expand Down Expand Up @@ -406,7 +406,7 @@

/obj/structure/falsewall/material/ChangeToWall(delete = 1)
var/turf/current_turf = get_turf(src)
var/turf/closed/wall/material/new_wall = current_turf.PlaceOnTop(/turf/closed/wall/material)
var/turf/closed/wall/material/new_wall = current_turf.place_on_top(/turf/closed/wall/material)
new_wall.set_custom_materials(custom_materials)
if(delete)
qdel(src)
Expand Down
16 changes: 8 additions & 8 deletions code/game/objects/structures/girders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
return
rod.use(amount)
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall/mineral/iron)
T.place_on_top(/turf/closed/wall/mineral/iron)
transfer_fingerprints_to(T)
qdel(src)
return
Expand Down Expand Up @@ -149,7 +149,7 @@
return
sheets.use(amount)
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall)
T.place_on_top(/turf/closed/wall)
transfer_fingerprints_to(T)
qdel(src)
return
Expand Down Expand Up @@ -194,7 +194,7 @@
return
sheets.use(amount)
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall/r_wall)
T.place_on_top(/turf/closed/wall/r_wall)
transfer_fingerprints_to(T)
qdel(src)
return
Expand Down Expand Up @@ -270,9 +270,9 @@
sheets.use(amount)
var/turf/T = get_turf(src)
if(sheets.walltype)
T.PlaceOnTop(sheets.walltype)
T.place_on_top(sheets.walltype)
else
var/turf/newturf = T.PlaceOnTop(/turf/closed/wall/material)
var/turf/newturf = T.place_on_top(/turf/closed/wall/material)
var/list/material_list = list()
material_list[GET_MATERIAL_REF(sheets.material_type)] = SHEET_MATERIAL_AMOUNT * 2
if(material_list)
Expand Down Expand Up @@ -452,7 +452,7 @@
return
R.use(amount)
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall/mineral/cult)
T.place_on_top(/turf/closed/wall/mineral/cult)
qdel(src)

else
Expand Down Expand Up @@ -487,7 +487,7 @@
return FALSE

var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall)
T.place_on_top(/turf/closed/wall)
qdel(src)
return TRUE
if(RCD_DECONSTRUCT)
Expand Down Expand Up @@ -524,7 +524,7 @@
return
B.use(amount)
var/turf/T = get_turf(src)
T.PlaceOnTop(/turf/closed/wall/mineral/bronze)
T.place_on_top(/turf/closed/wall/mineral/bronze)
qdel(src)

else
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/lattice.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
if(design_structure == /turf/open/floor/plating)
var/turf/T = src.loc
if(isgroundlessturf(T))
T.PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
T.place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
qdel(src)
return TRUE
if(design_structure == /obj/structure/lattice/catwalk)
Expand Down
68 changes: 28 additions & 40 deletions code/game/turfs/baseturfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,54 +27,42 @@
src
)

// Make a new turf and put it on top
// The args behave identical to PlaceOnBottom except they go on top
// Things placed on top of closed turfs will ignore the topmost closed turf
// Returns the new turf
/turf/proc/PlaceOnTop(list/new_baseturfs, turf/fake_turf_type, flags)
var/area/turf_area = loc
if(new_baseturfs && !length(new_baseturfs))
new_baseturfs = list(new_baseturfs)
flags = turf_area.PlaceOnTopReact(new_baseturfs, fake_turf_type, flags) // A hook so areas can modify the incoming args
/// Places a turf at the top of the stack
/turf/proc/place_on_top(turf/added_layer, flags)
var/list/turf/new_baseturfs = list()

new_baseturfs.Add(baseturfs)
if(isopenturf(src))
new_baseturfs.Add(type)

return ChangeTurf(added_layer, new_baseturfs, flags)

/// Places a turf on top - for map loading
/turf/proc/load_on_top(turf/added_layer, flags)
var/area/our_area = get_area(src)
flags = our_area.PlaceOnTopReact(list(baseturfs), added_layer, flags)

var/turf/newT
if(flags & CHANGETURF_SKIP) // We haven't been initialized
if(flags_1 & INITIALIZED_1)
stack_trace("CHANGETURF_SKIP was used in a PlaceOnTop call for a turf that's initialized. This is a mistake. [src]([type])")
assemble_baseturfs()
if(fake_turf_type)
if(!new_baseturfs) // If no baseturfs list then we want to create one from the turf type
if(!length(baseturfs))
baseturfs = list(baseturfs)
var/list/old_baseturfs = baseturfs.Copy()
if(!isclosedturf(src))
old_baseturfs += type
newT = ChangeTurf(fake_turf_type, null, flags)
newT.assemble_baseturfs(initial(fake_turf_type.baseturfs)) // The baseturfs list is created like roundstart
if(!length(newT.baseturfs))
newT.baseturfs = list(baseturfs)
// The old baseturfs are put underneath, and we sort out the unwanted ones
newT.baseturfs = baseturfs_string_list(old_baseturfs + (newT.baseturfs - GLOB.blacklisted_automated_baseturfs), newT)
return newT
if(!length(baseturfs))
baseturfs = list(baseturfs)
if(!isclosedturf(src))
new_baseturfs = list(type) + new_baseturfs
baseturfs = baseturfs_string_list(baseturfs + new_baseturfs, src)
return ChangeTurf(fake_turf_type, null, flags)

var/turf/new_turf
if(!length(baseturfs))
baseturfs = list(baseturfs)

var/list/old_baseturfs = baseturfs.Copy()
if(!isclosedturf(src))
baseturfs = baseturfs_string_list(baseturfs + type, src)
var/turf/change_type
if(length(new_baseturfs))
change_type = new_baseturfs[new_baseturfs.len]
new_baseturfs.len--
if(new_baseturfs.len)
baseturfs = baseturfs_string_list(baseturfs + new_baseturfs, src)
else
change_type = new_baseturfs
return ChangeTurf(change_type, null, flags)
old_baseturfs += type

new_turf = ChangeTurf(added_layer, null, flags)
new_turf.assemble_baseturfs(initial(added_layer.baseturfs)) // The baseturfs list is created like roundstart
if(!length(new_turf.baseturfs))
new_turf.baseturfs = list(baseturfs)

// The old baseturfs are put underneath, and we sort out the unwanted ones
new_turf.baseturfs = baseturfs_string_list(old_baseturfs + (new_turf.baseturfs - GLOB.blacklisted_automated_baseturfs), new_turf)
return new_turf

// Copy an existing turf and put it on top
// Returns the new turf
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/open/_open.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
*/
/turf/open/proc/replace_floor(turf/open/new_floor_path, flags)
if (!overfloor_placed && initial(new_floor_path.overfloor_placed))
PlaceOnTop(new_floor_path, flags = flags)
place_on_top(new_floor_path, flags = flags)
return
ChangeTurf(new_floor_path, flags = flags)

Expand Down Expand Up @@ -408,7 +408,7 @@
return

playsound(src, 'sound/weapons/genhit.ogg', 50, TRUE)
var/turf/open/floor/plating/new_plating = PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
var/turf/open/floor/plating/new_plating = place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
if(lattice)
qdel(lattice)
else
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/open/chasm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

/turf/open/chasm/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, list/rcd_data)
if(rcd_data["[RCD_DESIGN_MODE]"] == RCD_TURF && rcd_data["[RCD_DESIGN_PATH]"] == /turf/open/floor/plating/rcd)
PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
return FALSE

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/open/floor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
if(girder)
return girder.rcd_act(user, the_rcd, rcd_data)

PlaceOnTop(/turf/closed/wall)
place_on_top(/turf/closed/wall)
return TRUE
if(RCD_WINDOWGRILLE)
//check if we are building a window
Expand Down
4 changes: 2 additions & 2 deletions code/game/turfs/open/floor/plating.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
to_chat(user, span_notice("You begin reinforcing the floor..."))
if(do_after(user, 30, target = src))
if (R.get_amount() >= 2 && !istype(src, /turf/open/floor/engine))
PlaceOnTop(/turf/open/floor/engine, flags = CHANGETURF_INHERIT_AIR)
place_on_top(/turf/open/floor/engine, flags = CHANGETURF_INHERIT_AIR)
playsound(src, 'sound/items/deconstruct.ogg', 80, TRUE)
R.use(2)
to_chat(user, span_notice("You reinforce the floor."))
Expand Down Expand Up @@ -100,7 +100,7 @@
return
sheets.use(PLATE_REINFORCE_COST)
playsound(src, 'sound/machines/creak.ogg', 100, vary = TRUE)
PlaceOnTop(/turf/open/floor/plating/reinforced)
place_on_top(/turf/open/floor/plating/reinforced)
else
if(!iscyborg(user))
balloon_alert(user, "too damaged, use a welding tool!")
Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/open/lava.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

/turf/open/lava/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, list/rcd_data)
if(rcd_data["[RCD_DESIGN_MODE]"] == RCD_TURF && rcd_data["[RCD_DESIGN_PATH]"] == /turf/open/floor/plating/rcd)
PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
return FALSE

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/open/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
if(girder)
return girder.rcd_act(user, the_rcd, rcd_data)

PlaceOnTop(/turf/closed/wall)
place_on_top(/turf/closed/wall)
return TRUE
if(RCD_WINDOWGRILLE)
//check if we are building a window
Expand Down
6 changes: 3 additions & 3 deletions code/game/turfs/open/openspace.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

/turf/open/openspace/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, list/rcd_data)
if(rcd_data["[RCD_DESIGN_MODE]"] == RCD_TURF && rcd_data["[RCD_DESIGN_PATH]"] == /turf/open/floor/plating/rcd)
PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
return FALSE

Expand All @@ -163,8 +163,8 @@
ChangeTurf(new_floor_path, flags = flags)
return
// Create plating under tiled floor we try to create directly onto the air
PlaceOnTop(/turf/open/floor/plating, flags = flags)
PlaceOnTop(new_floor_path, flags = flags)
place_on_top(/turf/open/floor/plating, flags = flags)
place_on_top(new_floor_path, flags = flags)

/turf/open/openspace/can_cross_safely(atom/movable/crossing)
return HAS_TRAIT(crossing, TRAIT_MOVE_FLYING)
Expand Down
6 changes: 3 additions & 3 deletions code/game/turfs/open/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ GLOBAL_LIST_EMPTY(starlight)
/turf/open/space/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, list/rcd_data)
if(the_rcd.mode == RCD_TURF)
if(rcd_data["[RCD_DESIGN_PATH]"] == /turf/open/floor/plating/rcd)
PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR)
return TRUE
else if(rcd_data["[RCD_DESIGN_PATH]"] == /obj/structure/lattice/catwalk)
var/obj/structure/lattice/lattice = locate(/obj/structure/lattice, src)
Expand Down Expand Up @@ -346,5 +346,5 @@ GLOBAL_LIST_EMPTY(starlight)
ChangeTurf(new_floor_path, flags = flags)
return
// Create plating under tiled floor we try to create directly onto space
PlaceOnTop(/turf/open/floor/plating, flags = flags)
PlaceOnTop(new_floor_path, flags = flags)
place_on_top(/turf/open/floor/plating, flags = flags)
place_on_top(new_floor_path, flags = flags)
2 changes: 1 addition & 1 deletion code/modules/antagonists/cult/cult_structure_pylon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
if(length(validturfs))
var/turf/converted_turf = pick(validturfs)
if(isplatingturf(converted_turf))
converted_turf.PlaceOnTop(/turf/open/floor/engine/cult, flags = CHANGETURF_INHERIT_AIR)
converted_turf.place_on_top(/turf/open/floor/engine/cult, flags = CHANGETURF_INHERIT_AIR)
else
converted_turf.ChangeTurf(/turf/open/floor/engine/cult, flags = CHANGETURF_INHERIT_AIR)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/datum/action/cooldown/spell/pointed/rust_construction/cast(turf/open/cast_on)
. = ..()
var/rises_message = "rises out of [cast_on]"
var/turf/closed/wall/new_wall = cast_on.PlaceOnTop(/turf/closed/wall)
var/turf/closed/wall/new_wall = cast_on.place_on_top(/turf/closed/wall)
if(!istype(new_wall))
return

Expand Down
8 changes: 4 additions & 4 deletions code/modules/buildmode/submodes/basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
if(istype(object,/turf) && left_click && !alt_click && !ctrl_click)
var/turf/clicked_turf = object
if(isplatingturf(object))
clicked_turf.PlaceOnTop(/turf/open/floor/iron, flags = CHANGETURF_INHERIT_AIR)
clicked_turf.place_on_top(/turf/open/floor/iron, flags = CHANGETURF_INHERIT_AIR)
else if(isfloorturf(object))
clicked_turf.PlaceOnTop(/turf/closed/wall)
clicked_turf.place_on_top(/turf/closed/wall)
else if(iswallturf(object))
clicked_turf.PlaceOnTop(/turf/closed/wall/r_wall)
clicked_turf.place_on_top(/turf/closed/wall/r_wall)
else
clicked_turf.PlaceOnTop(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR) // Gotta do something
clicked_turf.place_on_top(/turf/open/floor/plating, flags = CHANGETURF_INHERIT_AIR) // Gotta do something
log_admin("Build Mode: [key_name(c)] built [clicked_turf] at [AREACOORD(clicked_turf)]")
return
else if(right_click)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/cargo/supplypod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
if (openingSound)
playsound(get_turf(holder), openingSound, soundVolume, FALSE, FALSE) //Special admin sound to play
for (var/turf_type in turfs_in_cargo)
turf_underneath.PlaceOnTop(turf_type)
turf_underneath.place_on_top(turf_type)
for (var/cargo in holder.contents)
var/atom/movable/movable_cargo = cargo
movable_cargo.forceMove(turf_underneath)
Expand Down
Loading

0 comments on commit a7c125f

Please sign in to comment.