From 62e81a71ded70c0441cb80a4a4bbe7f588e40f5f Mon Sep 17 00:00:00 2001 From: Rob Nelson Date: Thu, 22 Aug 2013 01:37:10 -0700 Subject: [PATCH] Add method to track people breaking shit that would cause explosive decompression. --- code/game/objects/structures/false_walls.dm | 15 +++++++ code/game/objects/structures/girders.dm | 44 +++++++++++++++------ code/game/objects/structures/window.dm | 37 +++++++++++++++++ code/game/turfs/simulated/walls.dm | 37 +++++++++++++++++ code/game/turfs/simulated/walls_mineral.dm | 5 ++- code/modules/admin/admin.dm | 22 +++++++++++ 6 files changed, 146 insertions(+), 14 deletions(-) diff --git a/code/game/objects/structures/false_walls.dm b/code/game/objects/structures/false_walls.dm index a96d67344d8..a09cc0730cd 100644 --- a/code/game/objects/structures/false_walls.dm +++ b/code/game/objects/structures/false_walls.dm @@ -1,6 +1,21 @@ /* * False Walls */ + +#define FALSEDOOR_MAX_PRESSURE_DIFF 100.0 + +/proc/performFalseWallPressureCheck(var/turf/loc,var/mob/user) + var/datum/gas_mixture/myenv=loc.return_air() + var/pressure=myenv.return_pressure() + + for(var/dir in cardinal) + var/turf/T=get_turf(get_step(loc,dir)) + var/datum/gas_mixture/environment = T.return_air() + var/pdiff = abs(pressure - environment.return_pressure()) + if(pdiff > FALSEDOOR_MAX_PRESSURE_DIFF) + return pdiff + return 1 + /obj/structure/falsewall name = "wall" desc = "A huge chunk of metal used to seperate rooms." diff --git a/code/game/objects/structures/girders.dm b/code/game/objects/structures/girders.dm index b50225838e6..a97da1a47a7 100644 --- a/code/game/objects/structures/girders.dm +++ b/code/game/objects/structures/girders.dm @@ -70,10 +70,16 @@ if(/obj/item/stack/sheet/metal, /obj/item/stack/sheet/metal/cyborg) if(!anchored) if(S.amount < 2) return - S.use(2) - user << "\blue You create a false wall! Push on it to open or close the passage." - new /obj/structure/falsewall (src.loc) - del(src) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(!pdiff) + S.use(2) + user << "\blue You create a false wall! Push on it to open or close the passage." + new /obj/structure/falsewall (src.loc) + del(src) + else + user << "\red There is too much air moving through the gap! The door wouldn't stay closed if you built it." + message_admins("Attempted false wall made by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) at [formatJumpTo(loc)] had a pressure difference of [pdiff]!") + return else if(S.amount < 2) return ..() user << "\blue Now adding plating..." @@ -91,10 +97,16 @@ if(/obj/item/stack/sheet/plasteel) if(!anchored) if(S.amount < 2) return - S.use(2) - user << "\blue You create a false wall! Push on it to open or close the passage." - new /obj/structure/falserwall (src.loc) - del(src) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(!pdiff) + S.use(2) + user << "\blue You create a false wall! Push on it to open or close the passage." + new /obj/structure/falserwall (src.loc) + del(src) + else + user << "\red There is too much air moving through the gap! The door wouldn't stay closed if you built it." + message_admins("Attempted false rwall made by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) at [formatJumpTo(loc)] had a pressure difference of [pdiff]!") + return else if (src.icon_state == "reinforced") //I cant believe someone would actually write this line of code... if(S.amount < 1) return ..() @@ -124,11 +136,17 @@ var/M = S.sheettype if(!anchored) if(S.amount < 2) return - S.use(2) - user << "\blue You create a false wall! Push on it to open or close the passage." - var/F = text2path("/obj/structure/falsewall/[M]") - new F (src.loc) - del(src) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(!pdiff) + S.use(2) + user << "\blue You create a false wall! Push on it to open or close the passage." + var/F = text2path("/obj/structure/falsewall/[M]") + new F (src.loc) + del(src) + else + user << "\red There is too much air moving through the gap! The door wouldn't stay closed if you built it." + message_admins("Attempted false [M] wall made by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) at [formatJumpTo(loc)] had a pressure difference of [pdiff]!") + return else if(S.amount < 2) return ..() user << "\blue Now adding plating..." diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 28791229725..aa27d7cbc25 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -19,6 +19,9 @@ health -= Proj.damage ..() if(health <= 0) + var/pdiff=performFalseWallPressureCheck(src.loc,Proj.firer) + if(pdiff>0) + message_admins("Window destroyed by [Proj.firer.real_name] ([formatPlayerPanel(Proj.firer,Proj.firer.ckey)]) via \an [Proj]! pdiff = [pdiff] at [formatJumpTo(loc)]!") new /obj/item/weapon/shard(loc) new /obj/item/stack/rods(loc) del(src) @@ -79,8 +82,10 @@ ..() visible_message("[src] was hit by [AM].") var/tforce = 0 + var/mob/M=null if(ismob(AM)) tforce = 40 + M=AM else if(isobj(AM)) var/obj/item/I = AM tforce = I.throwforce @@ -91,10 +96,22 @@ anchored = 0 update_nearby_icons() step(src, get_dir(AM, src)) + var/pdiff=performFalseWallPressureCheck(src.loc,M) + if(pdiff>0) + if(M) + message_admins("Window with pdiff [pdiff] at [formatJumpTo(loc)] deanchored by [M.real_name] ([formatPlayerPanel(M,M.ckey)])!") + else + message_admins("Window with pdiff [pdiff] at [formatJumpTo(loc)] deanchored by [AM]!") if(health <= 0) new /obj/item/weapon/shard(loc) if(reinf) new /obj/item/stack/rods(loc) del(src) + var/pdiff=performFalseWallPressureCheck(src.loc,M) + if(pdiff>0) + if(M) + message_admins("Window with pdiff [pdiff] at [formatJumpTo(loc)] destroyed by [M.real_name] ([formatPlayerPanel(M,M.ckey)])!") + else + message_admins("Window with pdiff [pdiff] at [formatJumpTo(loc)] destroyed by [AM]!") /obj/structure/window/attack_hand(mob/user as mob) @@ -104,6 +121,9 @@ new /obj/item/weapon/shard(loc) if(reinf) new /obj/item/stack/rods(loc) del(src) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(pdiff>0) + message_admins("Window destroyed by hulk [user.real_name] ([formatPlayerPanel(user,user.ckey)]) with pdiff [pdiff] at [formatJumpTo(loc)]!") else if (usr.a_intent == "hurt") playsound(src.loc, 'glassknock.ogg', 80, 1) usr.visible_message("\red [usr.name] bangs against the [src.name]!", \ @@ -128,6 +148,9 @@ new /obj/item/weapon/shard(loc) if(reinf) new /obj/item/stack/rods(loc) del(src) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(pdiff>0) + message_admins("Window destroyed by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) with pdiff [pdiff] at [formatJumpTo(loc)]!") else //for nicer text~ user.visible_message("[user] smashes into [src]!") playsound(loc, 'sound/effects/Glasshit.ogg', 100, 1) @@ -185,11 +208,19 @@ update_nearby_icons() playsound(loc, 'sound/items/Screwdriver.ogg', 75, 1) user << (anchored ? "You have fastened the frame to the floor." : "You have unfastened the frame from the floor.") + if(!anchored) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(pdiff>0) + message_admins("Window with pdiff [pdiff] deanchored by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) at [formatJumpTo(loc)]!") else if(!reinf) anchored = !anchored update_nearby_icons() playsound(loc, 'sound/items/Screwdriver.ogg', 75, 1) user << (anchored ? "You have fastened the window to the floor." : "You have unfastened the window.") + if(!anchored) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(pdiff>0) + message_admins("Window with pdiff [pdiff] deanchored by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) at [formatJumpTo(loc)]!") else if(istype(W, /obj/item/weapon/crowbar) && reinf && state <= 1) state = 1 - state playsound(loc, 'sound/items/Crowbar.ogg', 75, 1) @@ -201,6 +232,9 @@ anchored = 0 update_nearby_icons() step(src, get_dir(user, src)) + var/pdiff=performFalseWallPressureCheck(src.loc,user) + if(pdiff>0) + message_admins("Window with pdiff [pdiff] deanchored by [user.real_name] ([formatPlayerPanel(user,user.ckey)]) at [formatJumpTo(loc)]!") else playsound(loc, 'sound/effects/Glasshit.ogg', 75, 1) ..() @@ -222,6 +256,9 @@ else new /obj/item/weapon/shard(loc) if(reinf) new /obj/item/stack/rods(loc) + var/pdiff=performFalseWallPressureCheck(src.loc,null) + if(pdiff>0) + message_admins("Window with pdiff [pdiff] broken at [formatJumpTo(loc)]!") del(src) return diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index 3b243741fc1..ad924f6d08a 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -1,3 +1,19 @@ + + +/proc/performWallPressureCheck(var/turf/loc,var/mob/user) + var/minp=16777216; + var/maxp=0; + for(var/dir in cardinal) + var/turf/T=get_turf(get_step(loc,dir)) + var/datum/gas_mixture/environment = T.return_air() + var/cp = environment.return_pressure() + if(cpmaxp)maxp=cp + var/pdiff = abs(minp-maxp) + if(pdiff > FALSEDOOR_MAX_PRESSURE_DIFF) + return pdiff + return 1 + /turf/simulated/wall name = "wall" desc = "A huge chunk of metal used to seperate rooms." @@ -164,6 +180,10 @@ else if(!is_sharp(W) && W.force >= 10 || W.force >= 20) user << "\The [src] crumbles away under the force of your [W.name]." src.dismantle_wall(1) + + var/pdiff=performWallPressureCheck(src.loc,user) + if(pdiff) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) broke a rotting wall with a pdiff of [pdiff] at [formatJumpTo(loc)]!") return //THERMITE related stuff. Calls src.thermitemelt() which handles melting simulated walls and the relevant effects @@ -203,6 +223,9 @@ if( user.loc == T && user.get_active_hand() == WT ) user << "You remove the outer plating." + var/pdiff=performWallPressureCheck(src.loc,user) + if(pdiff) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) dismanted a wall with a pdiff of [pdiff] at [formatJumpTo(loc)]!") dismantle_wall() else user << "You need more welding fuel to complete this task." @@ -221,6 +244,9 @@ if( user.loc == T && user.get_active_hand() == W ) user << "You remove the outer plating." dismantle_wall() + var/pdiff=performWallPressureCheck(src.loc,user) + if(pdiff) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) dismantled with a pdiff of [pdiff] at [formatJumpTo(loc)]!") for(var/mob/O in viewers(user, 5)) O.show_message("The wall was sliced apart by [user]!", 1, "You hear metal being sliced apart.", 2) return @@ -238,6 +264,9 @@ if( user.loc == T && user.get_active_hand() == W ) user << "Your drill tears though the last of the reinforced plating." dismantle_wall() + var/pdiff=performWallPressureCheck(src.loc,user) + if(pdiff) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) drilled a wall with a pdiff of [pdiff] at [formatJumpTo(loc)]!") for(var/mob/O in viewers(user, 5)) O.show_message("The wall was drilled through by [user]!", 1, "You hear the grinding of metal.", 2) return @@ -259,6 +288,9 @@ playsound(src.loc, "sparks", 50, 1) playsound(src.loc, 'sound/weapons/blade1.ogg', 50, 1) dismantle_wall(1) + var/pdiff=performWallPressureCheck(src.loc,user) + if(pdiff) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) sliced up a wall with a pdiff of [pdiff] at [formatJumpTo(loc)]!") for(var/mob/O in viewers(user, 5)) O.show_message("The wall was sliced apart by [user]!", 1, "You hear metal being sliced apart and sparks flying.", 2) return @@ -340,12 +372,17 @@ var/turf/simulated/floor/F = ChangeTurf(/turf/simulated/floor/plating) if(!F) if(O) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) thermited a wall into space at [formatJumpTo(loc)]!") del(O) user << "The thermite melts through the wall." F.burn_tile() F.icon_state = "wall_thermite" user << "The thermite melts through the wall." + var/pdiff=performWallPressureCheck(src.loc,user) + if(pdiff) + message_admins("[user.real_name] ([formatPlayerPanel(user,user.ckey)]) thermited a wall with a pdiff of [pdiff] at [formatJumpTo(loc)]!") + spawn(100) if(O) del(O) // F.sd_LumReset() //TODO: ~Carn diff --git a/code/game/turfs/simulated/walls_mineral.dm b/code/game/turfs/simulated/walls_mineral.dm index db92e15f4ae..74eddf52e09 100644 --- a/code/game/turfs/simulated/walls_mineral.dm +++ b/code/game/turfs/simulated/walls_mineral.dm @@ -90,6 +90,9 @@ ..() /turf/simulated/wall/mineral/plasma/proc/PlasmaBurn(temperature) + var/pdiff=performWallPressureCheck(src.loc,null) + if(pdiff>0) + message_admins("Plasma wall with pdiff [pdiff] at [formatJumpTo(loc)] just caught fire!") spawn(2) new /obj/structure/girder(src) src.ChangeTurf(/turf/simulated/floor) @@ -140,4 +143,4 @@ if((mineral == "gold") || (mineral == "silver")) if(shocked) shock() -*/ +*/ diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 6c9b9f9f81d..6595187ced4 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -1096,3 +1096,25 @@ proc/move_alien_ship() else alien_ship_location = 1 return + +proc/formatJumpTo(var/location,var/where="") + var/turf/loc + if(istype(location,/turf/)) + loc = location + else + loc = get_turf(location) + if(where=="") + where=formatLocation(loc) + return "[where]" + +proc/formatLocation(var/location) + var/turf/loc + if(istype(location,/turf/)) + loc = location + else + loc = get_turf(location) + var/area/A = get_area(location) + return "[A.name] - [loc.x],[loc.y],[loc.z]" + +proc/formatPlayerPanel(var/mob/U,var/text="PP") + return "[text]" \ No newline at end of file