8000 Refactor some stuff related to quirk processing by Absolucy · Pull Request #89075 · tgstation/tgstation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor some stuff related to quirk processing #89075

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 26, 2025

Conversation

Absolucy
Copy link
Member
@Absolucy Absolucy commented Jan 14, 2025

About The Pull Request

Several quirks that process have some common checks and patterns: only processing if the mob's stat is conscious or not dead, or not processing if they have certain traits.

This refactors quirk processing so those checks are a part of /datum/quirk itself, and the quirk will automatically be start/stop being processed by SSquirks based on those conditions, by registering signals to re-check if the quirk should be processing or not.

This ports said refactor from my downstream PR, Monkestation/Monkestation2.0#4642 (and is unaffected by the bug that Monkestation/Monkestation2.0#4836 fixes, due to additional refactors regarding trait handling)

Why It's Good For The Game

Less repetitive code is always better, and leaves less room for errors. Also, completely stopping the quirk from being processed by SSquirks can save a minuscule amount of CPU time.

Changelog

🆑
refactor: Refactored how quirks handle starting/stopping processing.
/:cl:

@tgstation-server tgstation-server added the Refactor Makes the code harder to read label Jan 14, 2025
@@ -7,17 +7,13 @@
hardcore_value = 5
quirk_flags = QUIRK_HUMAN_ONLY|QUIRK_PROCESSES
mail_goodies = list(/obj/item/reagent_containers/syringe/convermol) // to help breathing
minimum_process_stat = CONSCIOUS
no_process_traits = list(TRAIT_MIND_TEMPORARILY_GONE, TRAIT_FEARLESS, TRAIT_KNOCKEDOUT)
Copy link
Member Author

Choose a reason for hiding this comment

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

technically, minimum_process_stat = CONSCIOUS should handle this just fine, but I added TRAIT_KNOCKEDOUT here just to be 1:1 with the original code.

Comment on lines 47 to 50
if(no_process_traits)
LAZYINITLIST(process_update_signals)
for(var/trait in no_process_traits)
process_update_signals += list(SIGNAL_ADDTRAIT(trait), SIGNAL_REMOVETRAIT(trait))
Copy link
Contributor

Choose a reason for hiding this comment

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

you only need the for loop.
for(_ in null) is a noop

Copy link
Member Author

Choose a reason for hiding this comment

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

fair, it was mostly to avoid the unneeded LAZYINITLIST - but I can just do LAZYADD, looking back

@Jacquerel Jacquerel merged commit 8eaa934 into tgstation:master Jan 26, 2025
22 checks passed
tgstation-ci bot added a commit that referenced this pull request Jan 26, 2025
github-actions bot added a commit that referenced this pull request Jan 26, 2025
@Absolucy Absolucy deleted the quirk-refactors branch January 26, 2025 23:04
Absolucy added a commit to Absolucy/tgstation that referenced this pull request Jan 28, 2025
Absolucy added a commit to Absolucy/Monkestation that referenced this pull request Feb 1, 2025
Ports my additional refactors from tgstation/tgstation#89075, and the fix from tgstation/tgstation#89265
Absolucy added a commit to Absolucy/Monkestation that referenced this pull request Feb 1, 2025
Ports my additional refactors from tgstation/tgstation#89075, and the fix from tgstation/tgstation#89265
Absolucy added a commit to Absolucy/Monkestation that referenced this pull request Feb 1, 2025
Ports my additional refactors from tgstation/tgstation#89075, and the fix from tgstation/tgstation#89265
Absolucy added a commit to Monkestation/Monkestation2.0 that referenced this pull request Feb 1, 2025
Ports my additional refactors from tgstation/tgstation#89075, and the fix from tgstation/tgstation#89265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor Makes the code harder to read
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0