-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactors Get_Angle() and related procs (#5212)
# About the pull request To begin, fixes #5206. `Get_Compass_Dir()` needed atoms with valid coordinates, but didn't test for them. Adding some checks and `get_turf`s resolved that issue. But then if `Get_Compass_Dir()` needed those checks, `Get_Angle()` did too. And `get_angle()` (lowercase!). And `get_angle_raw()`. And half of `Get_Compass_Dir()` was just duplicated code from `Get_Angle()`. And-- So I took inspiration from how TG and TGMC did it and refactored the lot. https://github.com/tgstation/tgstation/blob/32fb42d19e0c763f7e5e3dafb9844d0f05e86630/code/__HELPERS/maths.dm#L1-L17 https://github.com/tgstation/TerraGov-Marine-Corps/blob/3963b2d5b89dd60b88a7a1534ee77bd654abe953/code/__HELPERS/unsorted.dm#L99-L159 REMOVED: - `get_angle_raw()` - never used - `get_angle()` - used 3 places, identical use case to `Get_Angle()` - `get_pixel_angle()` - used once, replaced by `delta_to_angle()` ADDED: - `angle_to_dir()` - pulls out the only unique thing `Get_Compass_Dir()` actually did - only difference from TGMC is it retains our angle breakpoints instead of theirs - `delta_to_angle()` - the only thing that actually calculates an angle, uses the 2-argument version of `arctan()` CHANGED: - `Get_Angle()` - removed the `tile_bound` branch (never used), added checks and `get_turf`s, position deltas passed to `delta_to_angle()` - only difference from TGMC is it retains `return 0`s instead of `CRASH`es, retains `get_pixel_position_x`/`y`, and passing to `delta_to_angle()` - `Get_Compass_Dir()` - gutted, now just a convenience function of `Get_Angle()` piped into `angle_to_dir()` <!-- Remove this text and explain what the purpose of your PR is. Mention if you have tested your changes. If you changed a map, make sure you used the mapmerge tool. If this is an Issue Correction, you can type "Fixes Issue #169420" to link the PR to the corresponding Issue number #169420. Remember: something that is self-evident to you might not be to others. Explain your rationale fully, even if you feel it goes without saying. --> # Explain why it's good for the game Having multiple unused or barely used functions trying to do the same thing makes code maintenance harder. # Testing Photographs and Procedure - [x] doesn't crash - [x] security tuner APC detection works - [x] SL/queen tracker works - [x] bullets face the right way # Changelog :cl: fix: Fixed security tuner not dispalying direction to room's APC refactor: Refactored code handling angles /:cl:
- Loading branch information
Showing
6 changed files
with
31 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters