Skip to content

Commit

Permalink
Reset player state to be not in game when leaving PlayingTheGame state.
Browse files Browse the repository at this point in the history
Fixes bug where trying to log in again after logging out without relaunching the client would drop the connection.
  • Loading branch information
ethanmoffat committed Nov 18, 2022
1 parent c8223d4 commit f2db780
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions EndlessClient/GameExecution/GameStateActions.cs
Expand Up @@ -6,6 +6,7 @@
using EndlessClient.ControlSets;
using EndlessClient.Network;
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using Microsoft.Xna.Framework;

namespace EndlessClient.GameExecution
Expand All @@ -17,20 +18,23 @@ public class GameStateActions : IGameStateActions
private readonly IControlSetRepository _controlSetRepository;
private readonly IControlSetFactory _controlSetFactory;
private readonly IEndlessGameProvider _endlessGameProvider;
private readonly IPlayerInfoRepository _playerInfoRepository;
private readonly ISfxPlayer _sfxPlayer;
private readonly IMfxPlayer _mfxPlayer;

public GameStateActions(IGameStateRepository gameStateRepository,
IControlSetRepository controlSetRepository,
IControlSetFactory controlSetFactory,
IEndlessGameProvider endlessGameProvider,
IPlayerInfoRepository playerInfoRepository,
ISfxPlayer sfxPlayer,
IMfxPlayer mfxPlayer)
{
_gameStateRepository = gameStateRepository;
_controlSetRepository = controlSetRepository;
_controlSetFactory = controlSetFactory;
_endlessGameProvider = endlessGameProvider;
_playerInfoRepository = playerInfoRepository;
_sfxPlayer = sfxPlayer;
_mfxPlayer = mfxPlayer;
}
Expand All @@ -40,6 +44,9 @@ public void ChangeToState(GameStates newState)
if (newState == _gameStateRepository.CurrentState)
return;

if (_gameStateRepository.CurrentState == GameStates.PlayingTheGame)
_playerInfoRepository.PlayerIsInGame = false;

var currentSet = _controlSetRepository.CurrentControlSet;
var nextSet = _controlSetFactory.CreateControlsForState(newState, currentSet);

Expand Down

0 comments on commit f2db780

Please sign in to comment.