Skip to content

Commit

Permalink
[MIRROR] Removes weird arg in machinery get_room_area [MDB IGNORE] …
Browse files Browse the repository at this point in the history
…(#24993)

* Removes weird arg in machinery `get_room_area`

* Update light.dm

---------

Co-authored-by: MrMelbert <[email protected]>
Co-authored-by: Giz <[email protected]>
  • Loading branch information
3 people authored and FFMirrorBot committed Nov 14, 2023
1 parent 3e18472 commit 175876d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
27 changes: 16 additions & 11 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -512,19 +512,24 @@
return TRUE

///Get a valid powered area to reference for power use, mainly for wall-mounted machinery that isn't always mapped directly in a powered location.
/obj/machinery/proc/get_room_area(area/machine_room)
/obj/machinery/proc/get_room_area()
var/area/machine_area = get_area(src)
if(!machine_area.always_unpowered) ///check our loc first to see if its a powered area
machine_room = machine_area
return machine_room
var/turf/mounted_wall = get_step(src,dir)
if (mounted_wall && istype(mounted_wall, /turf/closed))
if(isnull(machine_area))
return null // ??

// check our own loc first to see if its a powered area
if(!machine_area.always_unpowered)
return machine_area

// loc area wasn't good, checking adjacent wall for a good area to use
var/turf/mounted_wall = get_step(src, dir)
if(isclosedturf(mounted_wall))
var/area/wall_area = get_area(mounted_wall)
if(!wall_area.always_unpowered) //loc area wasn't good, checking adjacent wall for a good area to use
machine_room = wall_area
return machine_room
machine_room = machine_area ///couldn't find a proper powered area on loc or adjacent wall, defaulting back to loc and blaming mappers
return machine_room
if(!wall_area.always_unpowered)
return wall_area

// couldn't find a proper powered area on loc or adjacent wall, defaulting back to loc and blaming mappers
return machine_area

///makes this machine draw power from its area according to which use_power mode it is set to
/obj/machinery/proc/update_current_power_usage()
Expand Down
22 changes: 11 additions & 11 deletions code/modules/power/lighting/light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
qdel(on_turf)

if(!mapload) //sync up nightshift lighting for player made lights
var/area/our_area = get_room_area(src)
var/area/our_area = get_room_area()
var/obj/machinery/power/apc/temp_apc = our_area.apc
nightshift_enabled = temp_apc?.nightshift_lights

Expand Down Expand Up @@ -131,7 +131,7 @@
update(trigger = FALSE)

/obj/machinery/light/Destroy()
var/area/local_area = get_room_area(src)
var/area/local_area = get_room_area()
if(local_area)
on = FALSE
QDEL_NULL(cell)
Expand All @@ -154,7 +154,7 @@
/obj/machinery/light/update_icon_state()
switch(status) // set icon_states
if(LIGHT_OK)
var/area/local_area = get_area(src)
var/area/local_area = get_room_area()
if(low_power_mode || major_emergency || (local_area?.fire))
icon_state = "[base_state]_emergency"
else
Expand All @@ -174,7 +174,7 @@

. += emissive_appearance(overlay_icon, "[base_state]", src, alpha = src.alpha)

var/area/local_area = get_room_area(src)
var/area/local_area = get_room_area()

if(low_power_mode || major_emergency || (local_area?.fire))
. += mutable_appearance(overlay_icon, "[base_state]_emergency")
Expand All @@ -196,7 +196,7 @@
. = ..()
if(!.)
return
var/area/our_area = get_room_area(src)
var/area/our_area = get_room_area()
RegisterSignal(our_area, COMSIG_AREA_FIRE_CHANGED, PROC_REF(handle_fire))

/obj/machinery/light/on_enter_area(datum/source, area/area_to_register)
Expand Down Expand Up @@ -227,7 +227,7 @@
color_set = color
if(reagents)
START_PROCESSING(SSmachines, src)
var/area/local_area =get_room_area(src)
var/area/local_area = get_room_area()
if (local_area?.fire)
color_set = fire_colour
brightness_set = fire_brightness
Expand Down Expand Up @@ -286,7 +286,7 @@
static_power_used = 0
else if(on) //Light is on, just recalculate usage
var/static_power_used_new = 0
var/area/local_area = get_room_area(src)
var/area/local_area = get_room_area()
if (nightshift_enabled && !local_area?.fire)
static_power_used_new = nightshift_brightness * nightshift_light_power * power_consumption_rate
else
Expand Down Expand Up @@ -475,13 +475,13 @@
// returns if the light has power /but/ is manually turned off
// if a light is turned off, it won't activate emergency power
/obj/machinery/light/proc/turned_off()
var/area/local_area = get_room_area(src)
return !local_area.lightswitch && local_area.power_light || flickering || constant_flickering //SKYRAT EDIT CHANGE
var/area/local_area = get_room_area()
return !local_area.lightswitch && local_area.power_light || flickering || constant_flickering //SKYRAT EDIT CHANGE - ORIGINAL : return !local_area.lightswitch && local_area.power_light || flickering

// returns whether this light has power
// true if area has power and lightswitch is on
/obj/machinery/light/proc/has_power()
var/area/local_area =get_room_area(src)
var/area/local_area = get_room_area()
//SKYRAT EDIT ADDITION BEGIN
if(isnull(local_area))
return FALSE
Expand Down Expand Up @@ -687,7 +687,7 @@
// called when area power state changes
/obj/machinery/light/power_change()
SHOULD_CALL_PARENT(FALSE)
var/area/local_area =get_room_area(src)
var/area/local_area = get_room_area()
set_on(local_area.lightswitch && local_area.power_light)

// called when heated
Expand Down

0 comments on commit 175876d

Please sign in to comment.