Files
CHOMPStation2/code/modules/power/singularity/containment_field.dm
johnsonmt88@gmail.com 883b290064 Server crashing and exploit fixes
Added a cooldown to the containment field shocking players
- If a containment field was set up in a small room, it was possible to crash the server by jumping into the field with no way to escape it. This was likely due to the hundreds of spark effects being generated every second, on top of all the other calls it had to make.

Used the existing parent proc to check for proximity, canmove and death on:
- Atmos pumps
- Atmos mixers
- Canisters. (This should finish off issue 397.)
- Crew monitering computer (This one probably didn't need it but it shouldn't change the way it works.)

Added admin checks to:
- datum/mind
- tensioner
If either of these fail an admin check an admin log will be entered into the server logs and a message will be displayed to admins.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3818 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-14 19:31:15 +00:00

112 lines
2.6 KiB
Plaintext

//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
/obj/machinery/containment_field
name = "Containment Field"
desc = "An energy field."
icon = 'singularity.dmi'
icon_state = "Contain_F"
anchored = 1
density = 0
unacidable = 1
use_power = 0
var/obj/machinery/field_generator/FG1 = null
var/obj/machinery/field_generator/FG2 = null
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
New()
spawn(1)
src.sd_SetLuminosity(5)
Del()
if(FG1 && !FG1.clean_up)
FG1.cleanup()
if(FG2 && !FG2.clean_up)
FG2.cleanup()
..()
attack_hand(mob/user as mob)
if(get_dist(src, user) > 1)
return 0
else
shock(user)
return 1
blob_act()
return 0
ex_act(severity)
return 0
HasProximity(atom/movable/AM as mob|obj)
if(istype(AM,/mob/living/silicon) && prob(40))
shock(AM)
return 1
if(istype(AM,/mob/living/carbon) && prob(50))
shock(AM)
return 1
return 0
proc
shock(mob/living/user as mob)
if(hasShocked)
return 0
if(!FG1 || !FG2)
del(src)
return 0
if(iscarbon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
hasShocked = 1
var/shock_damage = min(rand(30,40),rand(30,40))
user.burn_skin(shock_damage)
user.updatehealth()
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>You feel a powerful shock course through your body sending you flying!</B>", \
"\red You hear a heavy electrical crack")
var/stun = min(shock_damage, 15)
user.Stun(stun)
user.Weaken(10)
user.updatehealth()
var/atom/target = get_edge_target_turf(user, get_dir(src, get_step_away(user, src)))
user.throw_at(target, 200, 4)
sleep(20)
hasShocked = 0
return
else if(issilicon(user))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(5, 1, user.loc)
s.start()
hasShocked = 1
var/shock_damage = rand(15,30)
user.take_overall_damage(0,shock_damage)
user.visible_message("\red [user.name] was shocked by the [src.name]!", \
"\red <B>Energy pulse detected, system damaged!</B>", \
"\red You hear an electrical crack")
if(prob(20))
user.Stun(2)
sleep(20)
hasShocked = 0
return
return
set_master(var/master1,var/master2)
if(!master1 || !master2)
return 0
FG1 = master1
FG2 = master2
return 1