Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emitter stacks fix #13539

Merged
merged 4 commits into from Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long has this check even been like this - that should be a bitwise &.

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 @@ -412,11 +415,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 @@ -429,6 +450,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