Skip to content

Commit

Permalink
Small auto-observe fixes (#5788)
Browse files Browse the repository at this point in the history
# About the pull request

Fixes/tweaks a couple of auto-observe things that I noticed after #5751.
Specifically:
- Fixes `runtime error: client_screen_add overridden. Use override =
TRUE to suppress this warning`/`runtime error: client_screen_remove
overridden. Use override = TRUE to suppress this warning`.
*This error was consistently thrown when a ghost who's body is being
observed re-enters their body. `observe_target_new_mind()` tries to
re-register the some signals on the body's new client, but didn't have
the `override` argument set.*

- Stops 'hidden' actions being added to the screen of observing players.
(e.g. the xeno tacmap action if the queen isn't ovied)

- Makes any observers transfer over to the new body when a xenomorph
evolves/de-evolves.
*(I also added `/mob/dead/observer` to the `observers` variable's
declaration since it wasn't particularly clear what the list held.)*

- Fixes the target player's action buttons disappearing for observers if
they reconnect or re-enter their body.
*(The actions were being shown to the player in
`Login()`>`show_hud()`>`update_action_buttons()` before the observer
could re-register signals in `observe_target_login()`.)
In order to fix this I renamed the existing `COMSIG_GLOB_MOB_LOGIN`,
`COMSIG_CLIENT_MOB_LOGIN`, `COMSIG_MOB_LOGIN` signals, and made
`COMSIG_MOB_LOGIN` send a bit earlier in the proc.*

# Explain why it's good for the game

Bugfixes :)


# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
fix: Fixed 'hidden' action buttons being shown to observing players.
qol: Made any observers transfer over when a Xenomorph
evolves/de-evolves.
/:cl:
  • Loading branch information
SabreML authored Feb 24, 2024
1 parent 031dff0 commit bab9f86
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 26 deletions.
8 changes: 6 additions & 2 deletions code/__DEFINES/dcs/signals/atom/mob/signals_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@
#define COMSIG_MOB_PRE_CLICK "mob_pre_click"
#define COMPONENT_INTERRUPT_CLICK (1<<0)

///from base of /mob/Login(): ()
/// From base of /mob/Login(), called when a client logs into this mob: ()
/// Not to be confused with [COMSIG_MOB_LOGGED_IN]
#define COMSIG_MOB_LOGIN "mob_login"
///from base of /mob/Logout(): ()
/// From base of /mob/Login(), called after a client logs into this mob: ()
/// Not to be confused with [COMSIG_MOB_LOGIN]
#define COMSIG_MOB_LOGGED_IN "mob_logged_in"
/// From base of /mob/Logout(): ()
#define COMSIG_MOB_LOGOUT "mob_logout"

/// From /mob/proc/change_real_name(): (old_name, new_name)
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/dcs/signals/signals_client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
/// Called after one or more verbs are added: (list of verbs added)
#define COMSIG_CLIENT_VERB_REMOVED "client_verb_removed"

/// Called after a client logs into a mob: (mob)
#define COMSIG_CLIENT_MOB_LOGIN "client_mob_changed"
/// Called from /mob/Login() after a client logs into a mob: (mob)
#define COMSIG_CLIENT_MOB_LOGGED_IN "client_mob_logged_in"

/// Called when something is added to a client's screen : /client/proc/add_to_screen(screen_add)
#define COMSIG_CLIENT_SCREEN_ADD "client_screen_add"
Expand Down
6 changes: 4 additions & 2 deletions code/__DEFINES/dcs/signals/signals_global.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@

#define COMSIG_GLOB_REMOVE_VOTE_BUTTON "!remove_vote_button"

#define COMSIG_GLOB_CLIENT_LOGIN "!client_login"
/// Called from /client/New() when a client logs in to the game: (client)
#define COMSIG_GLOB_CLIENT_LOGGED_IN "!client_logged_in"

#define COMSIG_GLOB_MOB_LOGIN "!mob_login"
/// Called from /mob/Login() when a client logs into a mob: (mob)
#define COMSIG_GLOB_MOB_LOGGED_IN "!mob_logged_in"

///from /datum/controller/subsystem/ticker/PostSetup
#define COMSIG_GLOB_POST_SETUP "!post_setup"
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ SUBSYSTEM_DEF(ticker)
CHECK_TICK
mode.announce()
if(mode.taskbar_icon)
RegisterSignal(SSdcs, COMSIG_GLOB_CLIENT_LOGIN, PROC_REF(handle_mode_icon))
RegisterSignal(SSdcs, COMSIG_GLOB_CLIENT_LOGGED_IN, PROC_REF(handle_mode_icon))
set_clients_taskbar_icon(mode.taskbar_icon)

if(GLOB.perf_flags & PERF_TOGGLE_LAZYSS)
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SUBSYSTEM_DEF(vote)
voting.Cut()
remove_action_buttons()

UnregisterSignal(SSdcs, COMSIG_GLOB_CLIENT_LOGIN)
UnregisterSignal(SSdcs, COMSIG_GLOB_CLIENT_LOGGED_IN)

for(var/c in GLOB.player_list)
update_static_data(c)
Expand Down Expand Up @@ -373,7 +373,7 @@ SUBSYSTEM_DEF(vote)
if(send_clients_vote)
C.mob.vote()

RegisterSignal(SSdcs, COMSIG_GLOB_CLIENT_LOGIN, PROC_REF(handle_client_joining))
RegisterSignal(SSdcs, COMSIG_GLOB_CLIENT_LOGGED_IN, PROC_REF(handle_client_joining))
SStgui.update_uis(src)
return TRUE
return FALSE
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/devices/radio/headset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
), PROC_REF(turn_on))
wearer = user
RegisterSignal(user, COMSIG_MOB_STAT_SET_ALIVE, PROC_REF(update_minimap_icon))
RegisterSignal(user, COMSIG_MOB_LOGIN, PROC_REF(add_hud_tracker))
RegisterSignal(user, COMSIG_MOB_LOGGED_IN, PROC_REF(add_hud_tracker))
RegisterSignal(user, COMSIG_MOB_DEATH, PROC_REF(update_minimap_icon))
RegisterSignal(user, COMSIG_HUMAN_SET_UNDEFIBBABLE, PROC_REF(update_minimap_icon))
if(headset_hud_on)
Expand All @@ -250,7 +250,7 @@
UnregisterSignal(user, list(
COMSIG_LIVING_REJUVENATED,
COMSIG_HUMAN_REVIVED,
COMSIG_MOB_LOGIN,
COMSIG_MOB_LOGGED_IN,
COMSIG_MOB_DEATH,
COMSIG_HUMAN_SET_UNDEFIBBABLE,
COMSIG_MOB_STAT_SET_ALIVE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ GLOBAL_LIST_INIT(whitelisted_client_procs, list(

view = GLOB.world_view_size

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CLIENT_LOGIN, src)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CLIENT_LOGGED_IN, src)

//////////////
//DISCONNECT//
Expand Down
2 changes: 1 addition & 1 deletion code/modules/escape_menu/escape_menu.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ GLOBAL_LIST_EMPTY(escape_menus)
show_page()

RegisterSignal(client, COMSIG_PARENT_QDELETING, PROC_REF(on_client_qdel))
RegisterSignal(client, COMSIG_CLIENT_MOB_LOGIN, PROC_REF(on_client_mob_login))
RegisterSignal(client, COMSIG_CLIENT_MOB_LOGGED_IN, PROC_REF(on_client_mob_login))

if (!isnull(ckey))
GLOB.escape_menus[ckey] = src
Expand Down
11 changes: 7 additions & 4 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@
if(observe_target_client != new_client)
observe_target_client = new_client

RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_ADD, PROC_REF(observe_target_screen_add))
RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_REMOVE, PROC_REF(observe_target_screen_remove))
// Override the signal from any previous targets.
RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_ADD, PROC_REF(observe_target_screen_add), TRUE)
RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_REMOVE, PROC_REF(observe_target_screen_remove), TRUE)

/// When the observe target logs in our observer connect to the new client
/mob/dead/observer/proc/observe_target_login(mob/living/new_character)
Expand All @@ -246,8 +247,9 @@
if(observe_target_client != new_character.client)
observe_target_client = new_character.client

RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_ADD, PROC_REF(observe_target_screen_add))
RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_REMOVE, PROC_REF(observe_target_screen_remove))
// Override the signal from any previous targets.
RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_ADD, PROC_REF(observe_target_screen_add), TRUE)
RegisterSignal(observe_target_client, COMSIG_CLIENT_SCREEN_REMOVE, PROC_REF(observe_target_screen_remove), TRUE)

///makes the ghost see the target hud and sets the eye at the target.
/mob/dead/observer/proc/do_observe(atom/movable/target)
Expand All @@ -266,6 +268,7 @@
client.clear_screen()
client.eye = carbon_target
observe_target_mob = carbon_target

carbon_target.auto_observed(src)

RegisterSignal(src, COMSIG_MOVABLE_MOVED, PROC_REF(observer_move_react))
Expand Down
6 changes: 5 additions & 1 deletion code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,12 @@
observers |= observer
hud_used.show_hud(hud_used.hud_version, observer)

// Add the player's action buttons (not the actions themselves) to the observer's screen.
for(var/datum/action/action as anything in actions)
// Add the action's button (not the action itself) to the observer's screen.
// Skip any hidden ones (of course).
if(action.hidden || action.player_hidden)
continue

observer.client.add_to_screen(action.button)

//generates realistic-ish pulse output based on preset levels
Expand Down
5 changes: 5 additions & 0 deletions code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@
var/datum/mob_hud/MH = GLOB.huds[MOB_HUD_XENO_INFECTION]
MH.add_hud_to(src, src)

// Transfer any observing players over to the xeno's new body (`target`) on evolve/de-evolve.
/mob/living/carbon/xenomorph/transfer_observers_to(atom/target)
for(var/mob/dead/observer/observer as anything in observers)
observer.clean_observe_target()
observer.do_observe(target)

/mob/living/carbon/xenomorph/check_improved_pointing()
//xeno leaders get a big arrow and less cooldown
Expand Down
8 changes: 5 additions & 3 deletions code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

update_Login_details()

SEND_SIGNAL(src, COMSIG_MOB_LOGIN)

client.images = null
client.screen = null //remove hud items just in case
if(!hud_used)
Expand Down Expand Up @@ -58,6 +60,6 @@

client.init_verbs()

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MOB_LOGIN, src)
SEND_SIGNAL(client, COMSIG_CLIENT_MOB_LOGIN, src)
SEND_SIGNAL(src, COMSIG_MOB_LOGIN)
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MOB_LOGGED_IN, src)
SEND_SIGNAL(client, COMSIG_CLIENT_MOB_LOGGED_IN, src)
SEND_SIGNAL(src, COMSIG_MOB_LOGGED_IN)
4 changes: 2 additions & 2 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
I'll make some notes on where certain variable defines should probably go.
Changing this around would probably require a good look-over the pre-existing code.
*/
var/list/observers //The list of people observing this mob.
/// The list of people observing this mob.
var/list/mob/dead/observer/observers
var/zone_selected = "chest"

var/use_me = 1 //Allows all mobs to use the me verb by default, will have to manually specify they cannot
Expand Down Expand Up @@ -429,4 +430,3 @@
return

src.regenerate_icons()

6 changes: 3 additions & 3 deletions code/modules/vehicles/van/van.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

icon_state = null

RegisterSignal(SSdcs, COMSIG_GLOB_MOB_LOGIN, PROC_REF(add_default_image))
RegisterSignal(SSdcs, COMSIG_GLOB_MOB_LOGGED_IN, PROC_REF(add_default_image))

for(var/I in GLOB.player_list)
add_default_image(SSdcs, I)
Expand Down Expand Up @@ -125,7 +125,7 @@

mobs_under += L
RegisterSignal(L, COMSIG_PARENT_QDELETING, PROC_REF(remove_under_van))
RegisterSignal(L, COMSIG_MOB_LOGIN, PROC_REF(add_client))
RegisterSignal(L, COMSIG_MOB_LOGGED_IN, PROC_REF(add_client))
RegisterSignal(L, COMSIG_MOVABLE_MOVED, PROC_REF(check_under_van))

if(L.client)
Expand All @@ -141,7 +141,7 @@

UnregisterSignal(L, list(
COMSIG_PARENT_QDELETING,
COMSIG_MOB_LOGIN,
COMSIG_MOB_LOGGED_IN,
COMSIG_MOVABLE_MOVED,
))

Expand Down

0 comments on commit bab9f86

Please sign in to comment.