Files
Bubberstation/code/datums/mocking/client.dm
san7890 35142811ee Fixes Mock Clients Leaking Into Production (#79640)
Basically, every time we made a new client interface, we would add it to
`GLOB.directory` (new behavior introduced in (#79348
(88bb3afcce)).
This would mean that we would pass in junk mock clients into the vote
processing feature instead of actual legitimate clients, as well as a
slew of unintended consequences elsewhere wherever we access
`GLOB.directory`.

We would create mock clients in stuff like
`randomize_human_appearance()`, which is legitimately used and called in
a slew of places where we want random humans, which allows junk to enter
in directory per the aforementioned point.

Anyways, let's just... not let's add it to the directory if we aren't
running unit tests. I also made the vote processing code a bit more
strict juuuuuuuust in case
2023-11-10 23:10:23 +00:00

51 lines
1.1 KiB
Plaintext

/// This should match the interface of /client wherever necessary.
/datum/client_interface
/// Player preferences datum for the client
var/datum/preferences/prefs
/// The view of the client, similar to /client/var/view.
var/view = "15x15"
/// View data of the client, similar to /client/var/view_size.
var/datum/view_data/view_size
/// Objects on the screen of the client
var/list/screen = list()
/// The mob the client controls
var/mob/mob
/// The ckey for this mock interface
var/ckey = "mockclient"
/// The key for this mock interface
var/key = "mockclient"
/// client prefs
var/fps
var/hotkeys
var/tgui_say
var/typing_indicators
/datum/client_interface/New()
..()
var/static/mock_client_uid = 0
mock_client_uid++
src.key = "[key]_[mock_client_uid]"
ckey = ckey(key)
#ifdef UNIT_TESTS // otherwise this shit can leak into production servers which is drather bad
GLOB.directory[ckey] = src
#endif
/datum/client_interface/Destroy(force, ...)
GLOB.directory -= ckey
return ..()
/datum/client_interface/proc/IsByondMember()
return FALSE
/datum/client_interface/proc/set_macros()
return