Skip to content

Commit

Permalink
Fixes APC icon weirdness (#2568)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Replaces APC update_icon() calls with update_appearance()

## Why It's Good For The Game

fixes #2538

## Changelog

🆑 
fix: APCs now update their icon more correctly
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Signed-off-by: Theos <[email protected]>
  • Loading branch information
SomeguyManperson authored Dec 11, 2023
1 parent a3c9dad commit 3a655cf
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions code/modules/power/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
if(auto_name)
name = "\improper [get_area_name(area, TRUE)] APC"

update_icon()
update_appearance()

make_terminal()

Expand Down Expand Up @@ -342,12 +342,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
if(!cell) //it always peeved me that abandoned ships always had the apc lights on. this should fix it
icon_update_needed = FALSE
set_light(0)
return

if(cell.charge <= 0)
else if(cell.charge <= 0)
icon_update_needed = FALSE
set_light(0)
return
//this may need to be moved up!!
. = ..()
// And now, separately for cleanness, the lighting changing
Expand All @@ -360,12 +358,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
if(APC_FULLY_CHARGED)
set_light_color(LIGHT_COLOR_GREEN)
set_light(lon_range)
return

if(update_state & UPSTATE_BLUESCREEN)
else if(update_state & UPSTATE_BLUESCREEN)
set_light_color(LIGHT_COLOR_BLUE)
set_light(lon_range)
return

/obj/machinery/power/apc/update_icon_state()
if(!update_state)
Expand Down Expand Up @@ -501,7 +497,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
else if (opened!=APC_COVER_REMOVED)
opened = APC_COVER_CLOSED
coverlocked = TRUE //closing cover relocks it
update_icon()
update_appearance()
return
else if (!(machine_stat & BROKEN))
if(coverlocked && !(machine_stat & MAINT)) // locked...
Expand All @@ -512,7 +508,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
return
else
opened = APC_COVER_OPENED
update_icon()
update_appearance()
return

/obj/machinery/power/apc/screwdriver_act(mob/living/user, obj/item/W)
Expand All @@ -524,10 +520,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
user.visible_message("<span class='notice'>[user] removes \the [cell] from [src]!</span>", "<span class='notice'>You remove \the [cell].</span>")
var/turf/T = get_turf(user)
cell.forceMove(T)
cell.update_icon()
cell.update_appearance()
cell = null
charging = APC_NOT_CHARGING
update_icon()
update_appearance()
return
else
switch (has_electronics)
Expand All @@ -544,14 +540,14 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
else
to_chat(user, "<span class='warning'>There is nothing to secure!</span>")
return
update_icon()
update_appearance()
else if(obj_flags & EMAGGED)
to_chat(user, "<span class='warning'>The interface is broken!</span>")
return
else
panel_open = !panel_open
to_chat(user, "<span class='notice'>The wires have been [panel_open ? "exposed" : "unexposed"].</span>")
update_icon()
update_appearance()

/obj/machinery/power/apc/wirecutter_act(mob/living/user, obj/item/W)
. = ..()
Expand Down Expand Up @@ -599,7 +595,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
user.visible_message("<span class='notice'>[user.name] inserts the power cell to [src.name]!</span>",\
"<span class='notice'>You insert the power cell.</span>")
chargecount = 0
update_icon()
update_appearance()
else if (W.GetID())
togglelock(user)
else if (istype(W, /obj/item/stack/cable_coil) && opened)
Expand Down Expand Up @@ -677,7 +673,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
chargecount = 0
user.visible_message("<span class='notice'>[user] fabricates a weak power cell and places it into [src].</span>", \
"<span class='warning'>Your [P.name] whirrs with strain as you create a weak power cell and place it into [src]!</span>")
update_icon()
update_appearance()
else
to_chat(user, "<span class='warning'>[src] has both electronics and a cell.</span>")
return
Expand All @@ -692,7 +688,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
to_chat(user, "<span class='notice'>You replace missing APC's cover.</span>")
qdel(W)
opened = APC_COVER_OPENED
update_icon()
update_appearance()
return
if (has_electronics)
to_chat(user, "<span class='warning'>You cannot repair this APC until you remove the electronics still inside!</span>")
Expand All @@ -706,7 +702,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
obj_integrity = max_integrity
if (opened==APC_COVER_REMOVED)
opened = APC_COVER_OPENED
update_icon()
update_appearance()
else if(istype(W, /obj/item/apc_powercord))
return //because we put our fancy code in the right places, and this is all in the powercord's afterattack()

Expand Down Expand Up @@ -754,7 +750,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
chargecount = 0
user.visible_message("<span class='notice'>[user] fabricates a weak power cell and places it into [src].</span>", \
"<span class='warning'>Your [the_rcd.name] whirrs with strain as you create a weak power cell and place it into [src]!</span>")
update_icon()
update_appearance()
return TRUE
else
to_chat(user, "<span class='warning'>[src] has both electronics and a cell.</span>")
Expand All @@ -781,7 +777,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
if(allowed(usr) && !wires.is_cut(WIRE_IDSCAN) && !malfhack)
locked = !locked
to_chat(user, "<span class='notice'>You [ locked ? "lock" : "unlock"] the APC interface.</span>")
update_icon()
update_appearance()
updateUsrDialog()
else
to_chat(user, "<span class='warning'>Access denied.</span>")
Expand Down Expand Up @@ -811,7 +807,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
opened = APC_COVER_REMOVED
coverlocked = FALSE
visible_message("<span class='warning'>The APC cover is knocked down!</span>")
update_icon()
update_appearance()

/obj/machinery/power/apc/emag_act(mob/user)
if(!(obj_flags & EMAGGED) && !malfhack)
Expand All @@ -827,7 +823,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
obj_flags |= EMAGGED
locked = FALSE
to_chat(user, "<span class='notice'>You emag the APC interface.</span>")
update_icon()
update_appearance()


// attack with hand - remove cell (if cover open) or interact with the APC
Expand Down Expand Up @@ -890,10 +886,10 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
if(cell)
user.visible_message("<span class='notice'>[user] removes \the [cell] from [src]!</span>", "<span class='notice'>You remove \the [cell].</span>")
user.put_in_hands(cell)
cell.update_icon()
cell.update_appearance()
src.cell = null
charging = APC_NOT_CHARGING
src.update_icon()
src.update_appearance()
return
if((machine_stat & MAINT) && !opened) //no board; no interface
return
Expand Down Expand Up @@ -1027,7 +1023,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
to_chat(usr, "<span class='warning'>The APC does not respond to the command!</span>")
else
locked = !locked
update_icon()
update_appearance()
. = TRUE
if("cover")
coverlocked = !coverlocked
Expand All @@ -1042,20 +1038,20 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
chargemode = !chargemode
if(!chargemode)
charging = APC_NOT_CHARGING
update_icon()
update_appearance()
. = TRUE
if("channel")
if(params["eqp"])
equipment = setsubsystem(text2num(params["eqp"]))
update_icon()
update_appearance()
update()
else if(params["lgt"])
lighting = setsubsystem(text2num(params["lgt"]))
update_icon()
update_appearance()
update()
else if(params["env"])
environ = setsubsystem(text2num(params["env"]))
update_icon()
update_appearance()
update()
. = TRUE
if("overload")
Expand All @@ -1076,7 +1072,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
malfhidehack(usr) //EndWS Edit - Malf AI Rework
if("reboot")
failure_timer = 0
update_icon()
update_appearance()
update()
if("emergency_lighting")
emergency_lights = !emergency_lights
Expand All @@ -1094,7 +1090,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
add_hiddenprint(user)
log_game("[key_name(user)] turned [operating ? "on" : "off"] the [src] in [AREACOORD(src)]")
update()
update_icon()
update_appearance()

/obj/machinery/power/apc/proc/malfhack(mob/living/silicon/ai/malf)
if(!istype(malf))
Expand Down Expand Up @@ -1136,7 +1132,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25)
A.target = src

malfhackhide = 1
update_icon()
update_appearance()

/obj/machinery/power/apc/proc/malfunhidehack(mob/living/silicon/ai/malf)
if(src.machine_stat & BROKEN)
Expand Down

0 comments on commit 3a655cf

Please sign in to comment.