fix: g_dm_auto_join / g_dm_force_join never fire for human players#234
Open
KarmicP wants to merge 1 commit into
Open
fix: g_dm_auto_join / g_dm_force_join never fire for human players#234KarmicP wants to merge 1 commit into
KarmicP wants to merge 1 commit into
Conversation
ClientConnect pre-sets fresh deathmatch clients to TEAM_SPECTATOR before first spawn (its InitPlayerTeam call is commented out upstream), so InitPlayerTeam's 'already initialised' early-return (team != TEAM_NONE) fired for every human before the g_dm_force_join / g_dm_auto_join block could run - the cvars were dead for humans (upstream bug; bots join via the bot manager instead). An uninitialised spectator (sess.initialised only becomes true at the end of a successful SetTeam, including deliberate spectator picks) is really a brand-new client awaiting first join, so let them fall through to the auto-join gate. Recursion via SetTeam -> ClientSpawn is safe: team + initialised are set before the nested spawn, so the inner InitPlayerTeam early-returns. With g_dm_auto_join 0 (default) behavior is unchanged. Motivation: hard map rotation (g_hard_map_rotation) wipes sessions each rotation, dumping players at the join menu every map change; g_dm_auto_join 1 now actually rejoins them.
10f1820 to
494c155
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
g_dm_auto_joinandg_dm_force_joinare dead cvars for human players.ClientConnectpre-sets every fresh deathmatch client toTEAM_SPECTATORbefore first spawn (itsInitPlayerTeam(ent)call there is commented out):https://github.com/DarkMatter-Productions/MuffMode/blob/45e4c9a/src/sgame/client/lifecycle.cpp#L1511-L1516
so by the time
InitPlayerTeamruns at first spawn, the "already initialised" early-return (sess.team != TEAM_NONE) fires for every human and theg_dm_force_join / g_dm_auto_joinblock right below it is unreachable. Bots aren't affected because the bot manager assigns their team directly — which masks the bug in testing.Fix
Treat an uninitialised spectator as a brand-new client and let them fall through to the auto-join gate.
sess.initialisedonly becomestrueat the end of a successfulSetTeam(including a deliberate spectator pick), so:initialised == false) → falls through → auto-join applies as documentedinitialised == true) → early-returns as before, never force-joinedg_dm_auto_join 0/g_dm_force_join 0(defaults) → behavior unchangedRecursion via
SetTeam → ClientSpawnis safe:sess.teamandsess.initialisedare both set before the nested spawn, so the innerInitPlayerTeamearly-returns.Testing
45e4c9a: 0 warnings / 0 errorsg_dm_auto_join 1, humans spawn straight into the match on connect and after map changes; with it unset, the join menu appears exactly as before;team spectatorstill works and spectators are not force-joined