@@ -167,21 +167,6 @@ public string GenerateClientScriptPassword(string name)
167167 return Hash . HashString ( battleInstanceGuid + name ) . ToString ( ) ;
168168 }
169169
170- /// <summary>
171- /// Tries to claim a preallocated team slot for a mid-game joiner on the given ally team.
172- /// Returns the team number if a slot is available, null otherwise.
173- /// </summary>
174- private int ? TryClaimMidGameTeamSlot ( int allyTeamId )
175- {
176- if ( spring ? . Context ? . MidGameTeamSlots != null &&
177- spring . Context . MidGameTeamSlots . TryGetValue ( allyTeamId , out var queue ) &&
178- queue . TryDequeue ( out var teamNum ) )
179- {
180- return teamNum ;
181- }
182- return null ;
183- }
184-
185170 public void Dispose ( )
186171 {
187172 spring . UnsubscribeEvents ( this ) ;
@@ -364,28 +349,11 @@ public virtual async Task ProcessPlayerJoin(ConnectedUser user, string joinPassw
364349
365350 if ( spring . IsRunning )
366351 {
367- // Try to assign a preallocated mid-game team slot if available
368- int ? midGameTeam = null ;
369- if ( ! ubs . IsSpectator )
370- {
371- midGameTeam = TryClaimMidGameTeamSlot ( ubs . AllyNumber ) ;
372- if ( midGameTeam == null )
373- ubs . IsSpectator = true ; // no slot available, force spectator
374- }
375-
376- spring . AddUser ( ubs . Name , ubs . ScriptPassword , ubs . LobbyUser , ubs . IsSpectator , midGameTeam ) ;
377-
378- if ( midGameTeam . HasValue )
379- {
380- await SayBattle ( $ "Game is in progress — { ubs . Name } is joining as a player on team { midGameTeam . Value } .") ;
381- }
382- else
383- {
384- var started = DateTime . UtcNow . Subtract ( spring . IngameStartTime ?? RunningSince ?? DateTime . UtcNow ) ;
385- started = new TimeSpan ( ( int ) started . TotalHours , started . Minutes , started . Seconds ) ;
386- await SayBattle ( $ "THIS GAME IS CURRENTLY IN PROGRESS, PLEASE WAIT UNTIL IT ENDS! Running for { started } ", ubs . Name ) ;
387- await SayBattle ( "If you say !notify, I will message you when the current game ends." , ubs . Name ) ;
388- }
352+ spring . AddUser ( ubs . Name , ubs . ScriptPassword , ubs . LobbyUser ) ;
353+ var started = DateTime . UtcNow . Subtract ( spring . IngameStartTime ?? RunningSince ?? DateTime . UtcNow ) ;
354+ started = new TimeSpan ( ( int ) started . TotalHours , started . Minutes , started . Seconds ) ;
355+ await SayBattle ( $ "THIS GAME IS CURRENTLY IN PROGRESS, PLEASE WAIT UNTIL IT ENDS! Running for { started } ", ubs . Name ) ;
356+ await SayBattle ( "If you say !notify, I will message you when the current game ends." , ubs . Name ) ;
389357 }
390358
391359 try
@@ -438,34 +406,22 @@ public async Task RequestConnectSpring(ConnectedUser conus, string joinPassword)
438406 UserBattleStatus ubs ;
439407
440408 startGameStatus = spring . LobbyStartContext . Players . FirstOrDefault ( x => x . Name == conus . Name ) ;
441-
409+
442410 if ( ! Users . TryGetValue ( conus . Name , out ubs ) && ! ( IsInGame && startGameStatus != null ) )
443411 if ( IsPassworded && ( Password != joinPassword ) )
444412 {
445413 await conus . Respond ( "Invalid password" ) ;
446414 return ;
447415 }
448-
449- var isSpectator = startGameStatus ? . IsSpectator != false ;
450-
451- // For mid-game joins of users not in the original player list, try to assign a team slot
452- int ? midGameTeam = null ;
453- if ( isSpectator && startGameStatus == null && Users . TryGetValue ( conus . Name , out ubs ) && ! ubs . IsSpectator )
454- {
455- midGameTeam = TryClaimMidGameTeamSlot ( ubs . AllyNumber ) ;
456- if ( midGameTeam . HasValue )
457- isSpectator = false ;
458- }
459-
460416 var pwd = GenerateClientScriptPassword ( conus . Name ) ;
461- spring . AddUser ( conus . Name , pwd , conus . User , isSpectator , midGameTeam ) ;
417+ spring . AddUser ( conus . Name , pwd , conus . User ) ;
462418
463419 if ( spring . Context . LobbyStartContext . Players . Any ( x => x . Name == conus . Name ) && conus . MyBattle != this )
464420 {
465421 await ProcessPlayerJoin ( conus , joinPassword ) ;
466422 }
467423
468- await conus . SendCommand ( GetConnectSpringStructure ( pwd , isSpectator ) ) ;
424+ await conus . SendCommand ( GetConnectSpringStructure ( pwd , startGameStatus ? . IsSpectator != false ) ) ;
469425 }
470426
471427
0 commit comments