[NO GBP] Fix minigames UI not removing inactive clients (#74391)

## About The Pull Request
Fixes #74260

The UI for the basketball menu was not properly updating when clients
would disconnect. This would allow someone to signup twice leading to
silly situations as detailed in the issue report. This issue also
affected the mafia minigame due to both UIs having similar code.

The fix is simple, just check the signups when the tgui menu has
interactions and also check to make sure the signups use a boolean
instead of a client for the value part of the key/value list. Why? After
a client would disconnect, the list would change and remove the client
object since it no longer exists. The solution is to keep the ckey as a
key, but use a boolean for the value.

## Why It's Good For The Game
Less bugs, more stability.

## Changelog
🆑
fix: Fix basketball and mafia minigame UI not removing inactive clients
/🆑

---------

Co-authored-by: Fikou <23585223+Fikou@users.noreply.github.com>
This commit is contained in:
Tim
2023-04-07 04:31:52 -05:00
committed by GitHub
parent 92f4b47656
commit c0c76c3f05
2 changed files with 13 additions and 12 deletions
+4 -6
View File
@@ -624,9 +624,7 @@
for(var/key in GLOB.mafia_signup + GLOB.mafia_bad_signup)
var/list/lobby_member = list()
lobby_member["name"] = key
lobby_member["status"] = "Ready"
if(key in GLOB.mafia_bad_signup)
lobby_member["status"] = "Disconnected"
lobby_member["status"] = (key in GLOB.mafia_bad_signup) ? "Disconnected" : "Ready"
lobby_member["spectating"] = "Ghost"
if(key in spectators)
lobby_member["spectating"] = "Spectator"
@@ -744,7 +742,7 @@
to_chat(usr, span_notice("You unregister from Mafia."))
return TRUE
else
GLOB.mafia_signup[C.ckey] = C
GLOB.mafia_signup[C.ckey] = TRUE
to_chat(usr, span_notice("You sign up for Mafia."))
if(phase == MAFIA_PHASE_SETUP)
check_signups()
@@ -1065,12 +1063,12 @@
for(var/bad_key in GLOB.mafia_bad_signup)
if(GLOB.directory[bad_key])//they have reconnected if we can search their key and get a client
GLOB.mafia_bad_signup -= bad_key
GLOB.mafia_signup += bad_key
GLOB.mafia_signup[bad_key] = TRUE
for(var/key in GLOB.mafia_signup)
var/client/C = GLOB.directory[key]
if(!C)//vice versa but in a variable we use later
GLOB.mafia_signup -= key
GLOB.mafia_bad_signup += key
GLOB.mafia_bad_signup[key] = TRUE
continue
if(!isobserver(C.mob))
//they are back to playing the game, remove them from the signups