Files
Bubberstation/code/modules/unit_tests/emoting.dm
Timberpoes a56270cb05 Fixes issue where role banned players can still play roles they're banned from. (#77738)
## About The Pull Request

`is_banned_from(...)` expects a ckey.

`/obj/effect/mob_spawn/ghost_role/attack_ghost(...)` checks for role
bans by using key instead.

This can lead to players whose keys and ckeys are different being able
to evade certain ghost role bans; by accident or otherwise.

This PR takes a two-pronged approach. The first fixes ghost roles
passing in the key instead of the ckey to is_banned_from. This fixes the
bug, and makes it consistent with all other cases of
`is_banned_from(...)` being called.

The second is to redefine the behaviour of `is_banned_from(...)` to
accept either a ckey OR a key, since converting from key to canonical
key should be a fairly trivial operation. This prevents this specific
bug from ever occuring again, by making it intended functionality to
pass either key or ckey similar to how the roles param accepts either a
string role or a list of roles.

### ***Please review the code carefully, my changes to
`is_banned_from(...)` have not been tested. No logical flow should have
been changed.***
## Why It's Good For The Game

Ban systems working good.
## Changelog
🆑
fix: Fixes an issue where role banned players would be able to accept
certain ghost roles they're meant to be banned from.
/🆑
2023-08-29 16:42:50 +02:00

30 lines
880 B
Plaintext

/datum/unit_test/emoting
var/emotes_used = 0
/datum/unit_test/emoting/Run()
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human/consistent)
human.key = "EmoteTestKey"
RegisterSignal(human, COMSIG_MOB_EMOTE, PROC_REF(on_emote_used))
human.say("*shrug")
TEST_ASSERT_EQUAL(emotes_used, 1, "Human did not shrug")
human.say("*beep")
TEST_ASSERT_EQUAL(emotes_used, 1, "Human beeped, when that should be restricted to silicons")
human.setOxyLoss(140)
TEST_ASSERT(human.stat != CONSCIOUS, "Human is somehow conscious after receiving suffocation damage")
human.say("*shrug")
TEST_ASSERT_EQUAL(emotes_used, 1, "Human shrugged while unconscious")
human.say("*deathgasp")
TEST_ASSERT_EQUAL(emotes_used, 2, "Human could not deathgasp while unconscious")
human.key = null
/datum/unit_test/emoting/proc/on_emote_used()
SIGNAL_HANDLER
emotes_used += 1