mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 04:57:57 +01:00
[MIRROR] Implements usage of the REVERSE_DIR macro throughout the code. [MDB IGNORE] (#22743)
* Implements usage of the REVERSE_DIR macro throughout the code. (#77122) ## About The Pull Request Replaces a ton of `turn(dir, 180)` calls with the aforementioned macro. ## Why It's Good For The Game Afaik, `REVERSE_DIR` was coded to be faster than the classic `turn(dir, 180)` call, being a simple set of binary operations. To sum it up, micro optimization. ## Changelog N/A * Implements usage of the REVERSE_DIR macro throughout the code. --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
@@ -205,10 +205,10 @@
|
||||
|
||||
if(user.buckled && isobj(user.buckled) && !user.buckled.anchored)
|
||||
var/obj/B = user.buckled
|
||||
var/movementdirection = turn(direction,180)
|
||||
var/movementdirection = REVERSE_DIR(direction)
|
||||
addtimer(CALLBACK(src, TYPE_PROC_REF(/obj/item/extinguisher, move_chair), B, movementdirection), 1)
|
||||
else
|
||||
user.newtonian_move(turn(direction, 180))
|
||||
user.newtonian_move(REVERSE_DIR(direction))
|
||||
|
||||
//Get all the turfs that can be shot at
|
||||
var/turf/T = get_turf(target)
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
return //If we've run out, display message and exit
|
||||
else
|
||||
last = null
|
||||
last = loaded.place_turf(get_turf(src), user, turn(user.dir, 180))
|
||||
last = loaded.place_turf(get_turf(src), user, REVERSE_DIR(user.dir))
|
||||
is_empty(user) //If we've run out, display message
|
||||
update_appearance()
|
||||
|
||||
|
||||
@@ -785,7 +785,7 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301
|
||||
angle = 270
|
||||
if(target.dir & turn(target_to_user, 270))
|
||||
angle = 90
|
||||
if(target.dir & turn(target_to_user, 180))
|
||||
if(target.dir & REVERSE_DIR(target_to_user))
|
||||
angle = 180
|
||||
if(target.dir & target_to_user)
|
||||
angle = 360
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
playsound(src, P.hitsound, 50, TRUE)
|
||||
var/damage
|
||||
if(!QDELETED(src)) //Bullet on_hit effect might have already destroyed this object
|
||||
damage = take_damage(P.damage * P.demolition_mod, P.damage_type, P.armor_flag, 0, turn(P.dir, 180), P.armour_penetration)
|
||||
damage = take_damage(P.damage * P.demolition_mod, P.damage_type, P.armor_flag, 0, REVERSE_DIR(P.dir), P.armour_penetration)
|
||||
if(P.suppressed != SUPPRESSED_VERY)
|
||||
visible_message(span_danger("[src] is hit by \a [P][damage ? "" : ", without leaving a mark"]!"), null, null, COMBAT_MESSAGE_RANGE)
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ GLOBAL_LIST_EMPTY(objects_by_id_tag)
|
||||
/obj/handle_ricochet(obj/projectile/P)
|
||||
. = ..()
|
||||
if(. && receive_ricochet_damage_coeff)
|
||||
take_damage(P.damage * receive_ricochet_damage_coeff, P.damage_type, P.armor_flag, 0, turn(P.dir, 180), P.armour_penetration) // pass along receive_ricochet_damage_coeff damage to the structure for the ricochet
|
||||
take_damage(P.damage * receive_ricochet_damage_coeff, P.damage_type, P.armor_flag, 0, REVERSE_DIR(P.dir), P.armour_penetration) // pass along receive_ricochet_damage_coeff damage to the structure for the ricochet
|
||||
|
||||
/// Handles exposing an object to reagents.
|
||||
/obj/expose_reagents(list/reagents, datum/reagents/source, methods=TOUCH, volume_modifier=1, show_message=TRUE)
|
||||
|
||||
@@ -140,7 +140,7 @@ LINEN BINS
|
||||
// double check the canUseTopic args to make sure it's correct
|
||||
if(!istype(user) || !user.can_perform_action(src, NEED_DEXTERITY))
|
||||
return
|
||||
dir = turn(dir, 180)
|
||||
dir = REVERSE_DIR(dir)
|
||||
|
||||
/obj/item/bedsheet/blue
|
||||
icon_state = "sheetblue"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
/// We're offset back into the wall, account for that
|
||||
/obj/structure/fireplace/get_light_offset()
|
||||
var/list/hand_back = ..()
|
||||
var/list/dir_offset = dir2offset(turn(dir, 180))
|
||||
var/list/dir_offset = dir2offset(REVERSE_DIR(dir))
|
||||
hand_back[1] += dir_offset[1] * 0.5
|
||||
hand_back[2] += dir_offset[2] * 0.5
|
||||
return hand_back
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
tube_dirs = list(NORTH, SOUTH)
|
||||
if(WEST)
|
||||
tube_dirs = list(NORTH, SOUTH)
|
||||
boarding_dir = turn(dir, 180)
|
||||
boarding_dir = REVERSE_DIR(dir)
|
||||
|
||||
|
||||
/obj/structure/transit_tube/station/flipped
|
||||
@@ -212,7 +212,7 @@
|
||||
tube_dirs = list(SOUTH)
|
||||
if(WEST)
|
||||
tube_dirs = list(NORTH)
|
||||
boarding_dir = turn(dir, 180)
|
||||
boarding_dir = REVERSE_DIR(dir)
|
||||
|
||||
/obj/structure/transit_tube/station/reverse/flipped
|
||||
icon_state = "closed_terminus1"
|
||||
@@ -291,7 +291,7 @@
|
||||
tube_dirs = list(SOUTH)
|
||||
if(WEST)
|
||||
tube_dirs = list(NORTH)
|
||||
boarding_dir = turn(dir, 180)
|
||||
boarding_dir = REVERSE_DIR(dir)
|
||||
|
||||
/obj/structure/transit_tube/station/dispenser/reverse/flipped
|
||||
icon_state = "open_terminusdispenser1"
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
|
||||
/obj/structure/transit_tube/proc/has_entrance(from_dir)
|
||||
from_dir = turn(from_dir, 180)
|
||||
from_dir = REVERSE_DIR(from_dir)
|
||||
|
||||
for(var/direction in tube_dirs)
|
||||
if(direction == from_dir)
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
|
||||
var/obj/structure/transit_tube/TT = locate(/obj/structure/transit_tube) in loc
|
||||
//landed on a turf without transit tube or not in our direction
|
||||
if(!TT || (!(dir in TT.tube_dirs) && !(turn(dir,180) in TT.tube_dirs)))
|
||||
if(!TT || (!(dir in TT.tube_dirs) && !(REVERSE_DIR(dir) in TT.tube_dirs)))
|
||||
outside_tube()
|
||||
|
||||
/obj/structure/transit_tube_pod/proc/outside_tube()
|
||||
@@ -187,7 +187,7 @@
|
||||
for(var/obj/structure/transit_tube/station/station in loc)
|
||||
if(station.pod_moving)
|
||||
return
|
||||
if(direction == turn(station.boarding_dir,180))
|
||||
if(direction == REVERSE_DIR(station.boarding_dir))
|
||||
if(station.open_status == STATION_TUBE_OPEN)
|
||||
user.forceMove(loc)
|
||||
update_appearance()
|
||||
|
||||
Reference in New Issue
Block a user