Skip to content

Commit

Permalink
refactor: user check in emag_act to prevent runtimes (#4055)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimach authored Dec 13, 2023
1 parent 26c6246 commit 2bb5b06
Show file tree
Hide file tree
Showing 76 changed files with 193 additions and 132 deletions.
4 changes: 2 additions & 2 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@
/atom/proc/welder_act(mob/living/user, obj/item/I)
return

/atom/proc/emag_act()
/atom/proc/emag_act(mob/user)
return

/atom/proc/cmag_act()
/atom/proc/cmag_act(mob/user)
return


Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/cloning.dm
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ GLOBAL_LIST_INIT(cloner_biomass_items, list(\
WRENCH_ANCHOR_MESSAGE
anchored = TRUE

/obj/machinery/clonepod/emag_act(user)
/obj/machinery/clonepod/emag_act(mob/user)
if(isnull(occupant))
return
go_out()
Expand Down
7 changes: 4 additions & 3 deletions code/game/machinery/computer/HolodeckControl.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@
/obj/machinery/computer/HolodeckControl/attackby(var/obj/item/D as obj, var/mob/user as mob, params)
return

/obj/machinery/computer/HolodeckControl/emag_act(user as mob)
/obj/machinery/computer/HolodeckControl/emag_act(mob/user)
if(!emagged)
add_attack_logs(user, src, "emagged")
playsound(src.loc, 'sound/effects/sparks4.ogg', 75, 1)
emagged = 1
to_chat(user, span_notice("You vastly increase projector power and override the safety and security protocols."))
to_chat(user, "Warning. Automatic shutoff and derezing protocols have been corrupted. Please call Nanotrasen maintenance and do not use the simulator.")
if(user)
to_chat(user, span_notice("You vastly increase projector power and override the safety and security protocols."))
to_chat(user, "Warning. Automatic shutoff and derezing protocols have been corrupted. Please call Nanotrasen maintenance and do not use the simulator.")
src.updateUsrDialog()

/obj/machinery/computer/HolodeckControl/New()
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/computer/arcade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
return


/obj/machinery/computer/arcade/battle/emag_act(user as mob)
/obj/machinery/computer/arcade/battle/emag_act(mob/user)
if(!emagged)
add_attack_logs(user, src, "emagged")
temp = "If you die in the game, you die for real!"
Expand Down Expand Up @@ -963,7 +963,8 @@
/obj/machinery/computer/arcade/orion_trail/emag_act(mob/user)
if(!emagged)
add_attack_logs(user, src, "emagged")
to_chat(user, span_notice("You override the cheat code menu and skip to Cheat #[rand(1, 50)]: Realism Mode."))
if(user)
to_chat(user, span_notice("You override the cheat code menu and skip to Cheat #[rand(1, 50)]: Realism Mode."))
name = "The Orion Trail: Realism Edition"
desc = "Learn how our ancestors got to Orion, and try not to die in the process!"
newgame()
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/computer/communications.dm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@
if(!emagged)
add_attack_logs(user, src, "emagged")
src.emagged = 1
to_chat(user, span_notice("You scramble the communication routing circuits!"))
if(user)
to_chat(user, span_notice("You scramble the communication routing circuits!"))
SStgui.update_uis(src)

/obj/machinery/computer/communications/attack_ai(var/mob/user as mob)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/depot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
return

/obj/machinery/computer/syndicate_depot/emag_act(mob/user)
to_chat(user, span_notice("The electronic systems in this console are far too advanced for your primitive hacking peripherals."))
return
if(user)
to_chat(user, span_notice("The electronic systems in this console are far too advanced for your primitive hacking peripherals."))

/obj/machinery/computer/syndicate_depot/allowed(mob/user)
if(user.can_advanced_admin_interact())
Expand Down
9 changes: 5 additions & 4 deletions code/game/machinery/computer/honkputer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@

src.updateUsrDialog()

/obj/machinery/computer/HONKputer/emag_act(user as mob)
/obj/machinery/computer/HONKputer/emag_act(mob/user)
if(!emagged)
src.emagged = 1
to_chat(user, "You scramble the login circuits, allowing anyone to use the console!")
emagged = 1
if(user)
to_chat(user, "You scramble the login circuits, allowing anyone to use the console!")

/obj/machinery/computer/HONKputer/attack_hand(var/mob/user as mob)
/obj/machinery/computer/HONKputer/attack_hand(mob/user)
if(..())
return
if(is_away_level(src.z))
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/computer/message.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
return
return ..()

/obj/machinery/computer/message_monitor/emag_act(user as mob)
/obj/machinery/computer/message_monitor/emag_act(mob/user)
// Will create sparks and print out the console's password. You will then have to wait a while for the console to be back online.
// It'll take more time if there's more characters in the password..
if(!emag)
Expand All @@ -60,7 +60,7 @@
UnmagConsole()
update_icon()
message = rebootmsg
else
else if(user)
to_chat(user, span_notice("A no server error appears on the screen."))

/obj/machinery/computer/message_monitor/update_icon()
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/computer/syndie_cargo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ GLOBAL_LIST_INIT(data_storages, list()) //list of all cargo console data storage
is_public = TRUE

/obj/machinery/computer/syndie_supplycomp/emag_act(mob/user)
to_chat(user, span_notice("The electronic systems in this console are far too advanced for your primitive hacking peripherals."))
if(user)
to_chat(user, span_notice("The electronic systems in this console are far too advanced for your primitive hacking peripherals."))
return


Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/door_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
return
return ..()

/obj/machinery/door_control/emag_act(user as mob)
/obj/machinery/door_control/emag_act(mob/user)
if(!emagged)
emagged = TRUE
req_access = list()
Expand Down Expand Up @@ -128,5 +128,5 @@
ai_control = FALSE

/obj/machinery/door_control/secure/emag_act(user)
to_chat(user, span_notice("The electronic systems in this device are far too advanced for your primitive hacking peripherals."))
return
if(user)
to_chat(user, span_notice("The electronic systems in this device are far too advanced for your primitive hacking peripherals."))
3 changes: 2 additions & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,8 @@ About the new airlock wires panel:

/obj/machinery/door/airlock/emag_act(mob/user)
if(!hackable)
to_chat(user, span_notice("The electronic systems in this door are far too advanced for your primitive hacking peripherals."))
if(user)
to_chat(user, span_notice("The electronic systems in this door are far too advanced for your primitive hacking peripherals."))
return
if(!operating && density && arePowerSystemsOn() && !emagged)
add_attack_logs(user, src, "emagged ([locked ? "bolted" : "not bolted"])")
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@

/obj/machinery/door/emag_act(mob/user)
if(!hackable)
to_chat(user, span_notice("The electronic systems in this door are far too advanced for your primitive hacking peripherals."))
if(user)
to_chat(user, span_notice("The electronic systems in this door are far too advanced for your primitive hacking peripherals."))
return
if(density)
add_attack_logs(user, src, "emagged ([locked ? "bolted" : "not bolted"])")
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
return
return try_to_activate_door(user)

/obj/machinery/door/window/emag_act(mob/user, obj/weapon)
/obj/machinery/door/window/emag_act(mob/user)
if(!operating && density && !emagged)
add_attack_logs(user, src, "emagged")
emagged = TRUE
Expand All @@ -264,7 +264,7 @@
open(2)
return 1

/obj/machinery/door/window/cmag_act(mob/user, obj/weapon)
/obj/machinery/door/window/cmag_act(mob/user)
if(operating || !density || HAS_TRAIT(src, TRAIT_CMAGGED) || emagged)
return
ADD_TRAIT(src, TRAIT_CMAGGED, CMAGGED)
Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ FIRE ALARM
if(!emagged)
emagged = TRUE
if(user)
user.visible_message(span_warning("Sparks fly out of the [src]!"),
span_notice("You emag [src], disabling its thermal sensors."))
user.visible_message(span_warning("Sparks fly out of the [src]!"), span_notice("You emag [src], disabling its thermal sensors."))
playsound(loc, 'sound/effects/sparks4.ogg', 50, 1)

/obj/machinery/firealarm/temperature_expose(datum/gas_mixture/air, temperature, volume)
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/mass_driver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
/obj/machinery/mass_driver/emag_act(mob/user)
if(!emagged)
emagged = 1
to_chat(user, "You hack the Mass Driver, radically increasing the force at which it'll throw things. Better not stand in its way.")
if(user)
to_chat(user, "You hack the Mass Driver, radically increasing the force at which it'll throw things. Better not stand in its way.")
return 1
return -1

Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/poolcontroller.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@

/obj/machinery/poolcontroller/emag_act(user as mob) //Emag_act, this is called when it is hit with a cryptographic sequencer.
if(!emagged) //If it is not already emagged, emag it.
to_chat(user, span_warning("You disable \the [src]'s temperature safeguards."))//Inform the mob of what emagging does.
if(user)
to_chat(user, span_warning("You disable \the [src]'s temperature safeguards."))//Inform the mob of what emagging does.

emagged = 1 //Set the emag var to true.

Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ GLOBAL_LIST_EMPTY(turret_icons)
to_chat(M, span_noticealien("That object is useless to you."))
return

/obj/machinery/porta_turret/emag_act(user as mob)
/obj/machinery/porta_turret/emag_act(mob/user)
if(!emagged)
//Emagging the turret makes it go bonkers and stun everyone. It also makes
//the turret shoot much, much faster.
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/recycler.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
emergency_mode = FALSE
update_icon()
playsound(src, "sparks", 75, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
to_chat(user, span_notice("You use the cryptographic sequencer on the [name]."))
if(user)
to_chat(user, span_notice("You use the cryptographic sequencer on the [name]."))
add_attack_logs(user, src, "emagged")

/obj/machinery/recycler/update_icon()
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/suit_storage_unit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,8 @@
emagged = TRUE
update_icon()
SStgui.update_uis(src)
to_chat(user, span_warning("You burn the locking mechanism, unlocking it forever."))
if(user)
to_chat(user, span_warning("You burn the locking mechanism, unlocking it forever."))
do_sparks(5, 0, loc)
playsound(loc, "sparks", 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)

Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/teleporter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
/obj/machinery/computer/teleporter/emag_act(mob/user)
if(!emagged)
emagged = TRUE
to_chat(user, span_notice("The teleporter can now lock on to Syndicate beacons!"))
if(user)
to_chat(user, span_notice("The teleporter can now lock on to Syndicate beacons!"))
else
ui_interact(user)

Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/turret_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@
return
return ..()

/obj/machinery/turretid/emag_act(user as mob)
/obj/machinery/turretid/emag_act(mob/user)
if(!emagged)
to_chat(user, span_danger("You short out the turret controls' access analysis module."))
if(user)
to_chat(user, span_danger("You short out the turret controls' access analysis module."))
emagged = TRUE
locked = FALSE
ailock = FALSE
return

/obj/machinery/turretid/attack_ai(mob/user as mob)
ui_interact(user)
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,10 @@
inserted_item = null
SStgui.update_uis(src)

/obj/machinery/vending/emag_act(user as mob)
/obj/machinery/vending/emag_act(mob/user)
emagged = TRUE
to_chat(user, "You short out the product lock on [src]")
if(user)
to_chat(user, "You short out the product lock on [src]")

/obj/machinery/vending/attack_ai(mob/user)
return attack_hand(user)
Expand Down
4 changes: 2 additions & 2 deletions code/game/mecha/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,8 @@
. = ..()

/obj/mecha/emag_act(mob/user)
to_chat(user, "<span class='warning'>[src]'s ID slot rejects the card.</span>")
return
if(user)
to_chat(user, "<span class='warning'>[src]'s ID slot rejects the card.</span>")


/////////////////////////////////////
Expand Down
5 changes: 3 additions & 2 deletions code/game/mecha/working/ripley.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@
if(!emagged)
add_attack_logs(user, src, "emagged")
emagged = TRUE
to_chat(user, "<span class='notice'>You slide the card through [src]'s ID slot.</span>")
if(user)
to_chat(user, "<span class='notice'>You slide the card through [src]'s ID slot.</span>")
playsound(loc, "sparks", 100, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
desc += "</br><span class='danger'>The mech's equipment slots spark dangerously!</span>"
else
else if(user)
to_chat(user, "<span class='warning'>[src]'s ID slot rejects the card.</span>")

/obj/mecha/working/ripley/full_load
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/lightreplacer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
return
return ..()

/obj/item/lightreplacer/emag_act(user as mob)
/obj/item/lightreplacer/emag_act(mob/user)
if(!emagged)
add_attack_logs(user, src, "emagged")
Emag()
Expand Down
7 changes: 4 additions & 3 deletions code/game/objects/items/devices/megaphone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
spawn(20)
spamcheck = 0

/obj/item/megaphone/proc/saymsg(mob/living/user as mob, message)
/obj/item/megaphone/proc/saymsg(mob/living/user, message)
add_say_logs(user, message, language = "Megaphone")
var/message_tts = message
message = replace_characters(message, list("+"))
Expand All @@ -82,8 +82,9 @@
INVOKE_ASYNC(GLOBAL_PROC, /proc/tts_cast, user, M, message_tts, user.tts_seed, FALSE, effect)
log_debug("megaphone.saymsg(): [message]")

/obj/item/megaphone/emag_act(user as mob)
/obj/item/megaphone/emag_act(mob/user)
if(!emagged)
to_chat(user, "<span class='warning'>You overload \the [src]'s voice synthesizer.</span>")
if(user)
to_chat(user, "<span class='warning'>You overload \the [src]'s voice synthesizer.</span>")
emagged = 1
insults = rand(1, 3)//to prevent dickflooding
5 changes: 3 additions & 2 deletions code/game/objects/items/devices/radio/beacon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
GLOB.beacons -= src
return ..()

/obj/item/radio/beacon/emag_act(user as mob)
/obj/item/radio/beacon/emag_act(mob/user)
if(!emagged)
emagged = 1
syndicate = 1
to_chat(user, "<span class='notice'>The This beacon now only be locked on to by emagged teleporters!</span>")
if(user)
to_chat(user, "<span class='notice'>The This beacon now only be locked on to by emagged teleporters!</span>")

/obj/item/radio/beacon/hear_talk()
return
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/devices/signmaker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
/obj/item/signmaker/emag_act(mob/user)
add_attack_logs(user, src, "emagged")
clear_holosign()
to_chat(user, "You broke the pointer, oh no")
if(user)
to_chat(user, "You broke the pointer, oh no")
holosign_type = /obj/structure/holosoap/holosoap_emagged

/obj/item/signmaker/attack_self(mob/user)
Expand Down
5 changes: 3 additions & 2 deletions code/game/objects/items/devices/whistle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
spawn(20)
spamcheck = 0

/obj/item/hailer/emag_act(user as mob)
/obj/item/hailer/emag_act(mob/user)
if(!emagged)
to_chat(user, "<span class='warning'>You overload \the [src]'s voice synthesizer.</span>")
if(user)
to_chat(user, "<span class='warning'>You overload \the [src]'s voice synthesizer.</span>")
emagged = 1
8 changes: 5 additions & 3 deletions code/game/objects/items/robot/robot_parts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,12 @@
qdel(W)
qdel(src)

/obj/item/robot_parts/emag_act(user)
/obj/item/robot_parts/emag_act(mob/user)
if(sabotaged)
to_chat(user, "<span class='warning'>[src] is already sabotaged!</span>")
if(user)
to_chat(user, "<span class='warning'>[src] is already sabotaged!</span>")
else
add_attack_logs(user, src, "emagged")
to_chat(user, "<span class='warning'>You slide the emag into the dataport on [src] and short out the safeties.</span>")
if(user)
to_chat(user, "<span class='warning'>You slide the emag into the dataport on [src] and short out the safeties.</span>")
sabotaged = 1
Loading

0 comments on commit 2bb5b06

Please sign in to comment.