Skip to content

Commit dd688e9

Browse files
authored
Merge pull request #313 from ethanmoffat/beta_bugfix
Miscellaneous bugfixes for beta 1
2 parents 48f7ad9 + fb00c47 commit dd688e9

File tree

6 files changed

+42
-23
lines changed

6 files changed

+42
-23
lines changed

EOLib/Domain/Map/MapCellStateProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public IMapCellState GetCellStateAt(int x, int y)
4545

4646
Option<NPC.NPC> npc = Option.None<NPC.NPC>();
4747
if (_mapStateProvider.NPCs.TryGetValues(new MapCoordinate(x, y), out var npcs))
48+
{
4849
npc = npcs.FirstOrNone();
50+
if (npc.Map(x => x.IsActing(NPCActionState.Walking)).ValueOr(false))
51+
npc = Option.None<NPC.NPC>();
52+
}
4953

5054
var items = _mapStateProvider.MapItems.TryGetValues(new MapCoordinate(x, y), out var mapItems)
5155
? mapItems.OrderByDescending(i => i.UniqueID)

EndlessClient/Controllers/LoginController.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ public async Task LoginToAccount(ILoginParameters loginParameters)
101101
var reply = loginToServerOperation.Result;
102102

103103
if (reply == LoginReply.Ok)
104-
_gameStateActions.ChangeToState(GameStates.LoggedIn);
104+
{
105+
await DispatcherGameComponent.Invoke(() => _gameStateActions.ChangeToState(GameStates.LoggedIn));
106+
}
105107
else
106108
{
107109
_errorDisplayAction.ShowLoginError(reply);
@@ -227,12 +229,15 @@ await DispatcherGameComponent.Invoke(() =>
227229
_clientWindowSizeRepository.Resizable = true;
228230
}
229231

230-
_gameStateActions.ChangeToState(GameStates.PlayingTheGame);
231-
_chatTextBoxActions.FocusChatTextBox();
232-
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING,
233-
EOResourceID.LOADING_GAME_HINT_FIRST);
234-
_firstTimePlayerActions.WarnFirstTimePlayers();
235-
_mapChangedActions.ActiveCharacterEnterMapForLogin();
232+
await DispatcherGameComponent.Invoke(() =>
233+
{
234+
_gameStateActions.ChangeToState(GameStates.PlayingTheGame);
235+
_chatTextBoxActions.FocusChatTextBox();
236+
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING,
237+
EOResourceID.LOADING_GAME_HINT_FIRST);
238+
_firstTimePlayerActions.WarnFirstTimePlayers();
239+
_mapChangedActions.ActiveCharacterEnterMapForLogin();
240+
});
236241
}
237242

238243
private void SetInitialStateAndShowError(NoDataSentException ex)

EndlessClient/Controllers/MainButtonController.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using AutomaticTypeMapper;
22
using EndlessClient.Dialogs.Actions;
33
using EndlessClient.GameExecution;
4+
using EndlessClient.Rendering;
45
using EOLib.Domain;
56
using EOLib.Domain.Protocol;
67
using EOLib.Net.Communication;
@@ -49,12 +50,15 @@ public void GoToInitialState()
4950
_gameStateActions.ChangeToState(GameStates.Initial);
5051
}
5152

52-
public void GoToInitialStateAndDisconnect()
53+
public void GoToInitialStateAndDisconnect(bool showLostConnection = false)
5354
{
5455
GoToInitialState();
5556
StopReceivingAndDisconnect();
5657

5758
_resetStateAction.ResetState();
59+
60+
if (showLostConnection)
61+
_errorDialogDisplayAction.ShowConnectionLost(false);
5862
}
5963

6064
public async Task ClickCreateAccount()
@@ -63,8 +67,11 @@ public async Task ClickCreateAccount()
6367

6468
if (result)
6569
{
66-
_gameStateActions.ChangeToState(GameStates.CreateAccount);
67-
_accountDialogDisplayActions.ShowInitialCreateWarningDialog();
70+
await DispatcherGameComponent.Invoke(() =>
71+
{
72+
_gameStateActions.ChangeToState(GameStates.CreateAccount);
73+
_accountDialogDisplayActions.ShowInitialCreateWarningDialog();
74+
});
6875
}
6976
}
7077

@@ -73,7 +80,9 @@ public async Task ClickLogin()
7380
var result = await StartNetworkConnection().ConfigureAwait(false);
7481

7582
if (result)
76-
_gameStateActions.ChangeToState(GameStates.Login);
83+
{
84+
await DispatcherGameComponent.Invoke(() => _gameStateActions.ChangeToState(GameStates.Login));
85+
}
7786
}
7887

7988
public void ClickViewCredits()
@@ -150,7 +159,7 @@ public interface IMainButtonController
150159
{
151160
void GoToInitialState();
152161

153-
void GoToInitialStateAndDisconnect();
162+
void GoToInitialStateAndDisconnect(bool showLostConnection = false);
154163

155164
Task ClickCreateAccount();
156165

EndlessClient/GameExecution/EndlessGame.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using AutomaticTypeMapper;
22
using EndlessClient.Audio;
33
using EndlessClient.Content;
4+
using EndlessClient.Controllers;
45
using EndlessClient.ControlSets;
56
using EndlessClient.Rendering;
67
using EndlessClient.Rendering.Chat;
@@ -43,6 +44,8 @@ public class EndlessGame : Game, IEndlessGame
4344
private readonly IMfxPlayer _mfxPlayer;
4445
private readonly IXnaControlSoundMapper _soundMapper;
4546
private readonly IFixedTimeStepRepository _fixedTimeStepRepository;
47+
private readonly IMainButtonController _mainButtonController;
48+
4649
private GraphicsDeviceManager _graphicsDeviceManager;
4750

4851
private KeyboardState _previousKeyState;
@@ -69,7 +72,8 @@ public EndlessGame(IClientWindowSizeRepository windowSizeRepository,
6972
IConfigurationProvider configurationProvider,
7073
IMfxPlayer mfxPlayer,
7174
IXnaControlSoundMapper soundMapper,
72-
IFixedTimeStepRepository fixedTimeStepRepository)
75+
IFixedTimeStepRepository fixedTimeStepRepository,
76+
IMainButtonController mainButtonController)
7377
{
7478
_windowSizeRepository = windowSizeRepository;
7579
_contentProvider = contentProvider;
@@ -86,6 +90,8 @@ public EndlessGame(IClientWindowSizeRepository windowSizeRepository,
8690
_mfxPlayer = mfxPlayer;
8791
_soundMapper = soundMapper;
8892
_fixedTimeStepRepository = fixedTimeStepRepository;
93+
_mainButtonController = mainButtonController;
94+
8995
_graphicsDeviceManager = new GraphicsDeviceManager(this)
9096
{
9197
PreferredBackBufferWidth = ClientWindowSizeRepository.DEFAULT_BACKBUFFER_WIDTH,
@@ -203,9 +209,9 @@ protected override void Update(GameTime gameTime)
203209
{
204210
base.Update(gameTime);
205211
}
206-
catch (InvalidOperationException ioe) when (ioe.InnerException is NullReferenceException)
212+
catch
207213
{
208-
// hide "failed to compare two elements in the array" error from Monogame
214+
_mainButtonController.GoToInitialStateAndDisconnect(showLostConnection: true);
209215
}
210216

211217
_lastFrameUpdate = gameTime.TotalGameTime;
@@ -287,7 +293,7 @@ private void SetUpInitialControlSet()
287293
_controlSetRepository.CurrentControlSet);
288294
_controlSetRepository.CurrentControlSet = controls;
289295

290-
//since the controls are being created in Initialize(), adding them to the default game
296+
//since the controls are being created in LoadContent(), adding them to the default game
291297
// doesn't call the Initialize() method on any controls, so it must be done here
292298
foreach (var xnaControl in _controlSetRepository.CurrentControlSet.AllComponents)
293299
xnaControl.Initialize();

EndlessClient/Network/PacketHandlerGameComponent.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using AutomaticTypeMapper;
22
using EndlessClient.Controllers;
3-
using EndlessClient.Dialogs.Actions;
43
using EndlessClient.GameExecution;
54
using EOLib.Net.Communication;
65
using EOLib.Net.Handlers;
@@ -14,21 +13,18 @@ public class PacketHandlerGameComponent : GameComponent
1413
private readonly IOutOfBandPacketHandler _packetHandler;
1514
private readonly INetworkClientProvider _networkClientProvider;
1615
private readonly IGameStateProvider _gameStateProvider;
17-
private readonly IErrorDialogDisplayAction _errorDialogDisplayAction;
1816
private readonly IMainButtonController _mainButtonController;
1917

2018
public PacketHandlerGameComponent(IEndlessGame game,
2119
IOutOfBandPacketHandler packetHandler,
2220
INetworkClientProvider networkClientProvider,
2321
IGameStateProvider gameStateProvider,
24-
IErrorDialogDisplayAction errorDialogDisplayAction,
2522
IMainButtonController mainButtonController)
2623
: base((Game) game)
2724
{
2825
_packetHandler = packetHandler;
2926
_networkClientProvider = networkClientProvider;
3027
_gameStateProvider = gameStateProvider;
31-
_errorDialogDisplayAction = errorDialogDisplayAction;
3228
_mainButtonController = mainButtonController;
3329

3430
UpdateOrder = int.MinValue;
@@ -41,8 +37,7 @@ public override void Update(GameTime gameTime)
4137
!_networkClientProvider.NetworkClient.Connected)
4238
{
4339
var isInGame = _gameStateProvider.CurrentState == GameStates.PlayingTheGame;
44-
_mainButtonController.GoToInitialStateAndDisconnect();
45-
_errorDialogDisplayAction.ShowConnectionLost(isInGame);
40+
_mainButtonController.GoToInitialStateAndDisconnect(showLostConnection: true);
4641
}
4742

4843
_packetHandler.PollForPacketsAndHandle();

EndlessClient/Rendering/Character/PeriodicEmoteHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public override void Update(GameTime gameTime)
109109
{
110110
if ((now - _userInputTimeProvider.LastInputTime).TotalMilliseconds >= AFK_TIME_MS + AFK_TIME_ALERT_MS)
111111
{
112-
_mainButtonController.GoToInitialStateAndDisconnect();
112+
_mainButtonController.GoToInitialStateAndDisconnect(showLostConnection: true);
113113
}
114114
else
115115
{

0 commit comments

Comments
 (0)