Skip to content

Commit

Permalink
Emitter stacks fix (vgstation-coders#13539)
Browse files Browse the repository at this point in the history
* Exploit fix for machine stacking.

* Fixes made during testing.

* Fix some minor indentation issues.

* honk
  • Loading branch information
N3X15 authored and ihadtoregisterforthis committed Jul 3, 2017
1 parent fc030fd commit 292f95c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
5 changes: 3 additions & 2 deletions code/game/machinery/machinery.dm
Expand Up @@ -564,7 +564,8 @@ Class Procs:
to_chat(user, "\The [src] has to be unwelded from the floor first.")
return -1 //state set to 2, can't do it
else
if(wrenchAnchor(user) && machine_flags && FIXED2WORK) //wrenches/unwrenches into place if possible, then updates the power and state if necessary
// wrenchAnchor returns -1 on check failures, for some reason.
if(wrenchAnchor(user) == 1 && machine_flags & FIXED2WORK) //wrenches/unwrenches into place if possible, then updates the power and state if necessary
state = anchored
power_change() //updates us to turn on or off as necessary
return 1
Expand All @@ -575,7 +576,7 @@ Class Procs:
if(isscrewdriver(O) && machine_flags & SCREWTOGGLE)
return togglePanelOpen(O, user)

if(iswelder(O) && machine_flags & WELD_FIXED)
if(iswelder(O) && machine_flags & WELD_FIXED && canAffixHere(user))
return weldToFloor(O, user)

if(iscrowbar(O) && machine_flags & CROWDESTROY)
Expand Down
27 changes: 25 additions & 2 deletions code/game/objects/objs.dm
Expand Up @@ -34,6 +34,9 @@ var/global/list/reagents_to_log = list(FUEL, PLASMA, PACID, SACID, AMUTATIONTOXI
var/datum/delay_controller/pAImove_delayer = new(1, ARBITRARILY_LARGE_NUMBER)
var/pAImovement_delay = 0

// Can we wrench/weld this to a turf with a dense /obj on it?
var/can_affix_to_dense_turf=0

/obj/New()
..()
if (auto_holomap && isturf(loc))
Expand Down Expand Up @@ -416,11 +419,29 @@ a {
machine._using += src
machine.in_use = 1

/obj/proc/wrenchAnchor(var/mob/user, var/time_to_wrench=30) //proc to wrench an object that can be secured
/** Returns 1 or 0 depending on whether the machine can be affixed to this position.
* Used to determine whether other density=1 things are on this tile.
* @param user Tool user
* @return bool Can affix here
*/
/obj/proc/canAffixHere(var/mob/user)
if(density==0 || can_affix_to_dense_turf)
return TRUE// Non-dense things just don't care. Same with can_affix_to_dense_turf=TRUE objects.
for(var/obj/other in loc) //ensure multiple things aren't anchored in one place
if(other.anchored == 1 && other.density == 1 && density && !anchored && !(other.flags & ON_BORDER))
to_chat(user, "\The [other] is already anchored in this location.")
return -1
return FALSE // NOPE
return TRUE

/** Anchors shit to the deck via wrench.
* NOTE: WHOEVER CODED THIS IS AN ABSOLUTE FUCKING RETARD AND USES -1 AS FAIL INSTEAD OF 0.
* @param user The mob doing the wrenching
* @param time_to_wrench The time to complete the wrenchening
* @returns 1 on success, -1 on fail
*/
/obj/proc/wrenchAnchor(var/mob/user, var/time_to_wrench=30) //proc to wrench an object that can be secured
if(!canAffixHere(user))
return -1
if(!anchored)
if(!istype(src.loc, /turf/simulated/floor)) //Prevent from anchoring shit to shuttles / space
if(istype(src.loc, /turf/simulated/shuttle) && !can_wrench_shuttle()) //If on the shuttle and not wrenchable to shuttle
Expand All @@ -433,6 +454,8 @@ a {
"You begin to [anchored ? "unbolt" : "bolt"] \the [src] [anchored ? "from" : "to" ] the floor.")
playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
if(do_after(user, src, time_to_wrench))
if(!canAffixHere(user))
return -1
anchored = !anchored
user.visible_message( "<span class='notice'>[user] [anchored ? "wrench" : "unwrench"]es \the [src] [anchored ? "in place" : "from its fixture"]</span>",
"<span class='notice'>[bicon(src)] You [anchored ? "wrench" : "unwrench"] \the [src] [anchored ? "in place" : "from its fixture"].</span>",
Expand Down

0 comments on commit 292f95c

Please sign in to comment.