Skip to content

Commit 26bd1e5

Browse files
fix: disconnection error when returning to main menu (AscensionGameDev#2257)
1 parent e840937 commit 26bd1e5

File tree

10 files changed

+20
-18
lines changed

10 files changed

+20
-18
lines changed

Intersect (Core)/Network/Packets/Client/LogoutPacket.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ public LogoutPacket()
1010
{
1111
}
1212

13-
public LogoutPacket(bool returnToCharSelect)
13+
public LogoutPacket(bool returnToCharSelect, bool returnToMainMenu)
1414
{
1515
ReturningToCharSelect = returnToCharSelect;
16+
ReturningToMainMenu = returnToMainMenu;
1617
}
1718

1819
[Key(0)]
1920
public bool ReturningToCharSelect { get; set; }
2021

22+
[Key(1)]
23+
public bool ReturningToMainMenu { get; set; }
24+
2125
}
2226

2327
}

Intersect.Client/Core/Main.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,8 @@ private static void ProcessGame()
194194
{
195195
if (Globals.ConnectionLost)
196196
{
197-
Main.Logout(false);
198-
Interface.Interface.ShowError(Strings.Errors.LostConnection);
199-
197+
Logout(false, true);
200198
Globals.ConnectionLost = false;
201-
202199
return;
203200
}
204201

@@ -328,7 +325,7 @@ public static void JoinGame()
328325
Audio.StopMusic(ClientConfiguration.Instance.MusicFadeTimer);
329326
}
330327

331-
public static void Logout(bool characterSelect, bool skipFade = false)
328+
public static void Logout(bool characterSelect, bool mainMenu, bool skipFade = false)
332329
{
333330
Audio.PlayMusic(ClientConfiguration.Instance.MenuMusic, ClientConfiguration.Instance.MusicFadeTimer, ClientConfiguration.Instance.MusicFadeTimer, true);
334331
if (skipFade)
@@ -342,7 +339,7 @@ public static void Logout(bool characterSelect, bool skipFade = false)
342339

343340
if (!ClientContext.IsSinglePlayer)
344341
{
345-
PacketSender.SendLogout(characterSelect);
342+
PacketSender.SendLogout(characterSelect, mainMenu);
346343
}
347344

348345
Globals.LoggedIn = false;

Intersect.Client/Interface/Game/EscapeMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private void LogoutToCharacterSelect(object sender, EventArgs e)
149149
Globals.Me.CombatTimer = 0;
150150
}
151151

152-
Main.Logout(true);
152+
Main.Logout(true, false);
153153
}
154154

155155
private void LogoutToMainMenu(object sender, EventArgs e)
@@ -159,7 +159,7 @@ private void LogoutToMainMenu(object sender, EventArgs e)
159159
Globals.Me.CombatTimer = 0;
160160
}
161161

162-
Main.Logout(false);
162+
Main.Logout(false, true);
163163
}
164164

165165
private void ExitToDesktop(object sender, EventArgs e)

Intersect.Client/Interface/Menu/CreateCharacterWindow.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ public void Update()
204204
{
205205
Hide();
206206
mMainMenu.Show();
207-
Interface.ShowError(Strings.Errors.LostConnection);
208-
209207
return;
210208
}
211209

Intersect.Client/Interface/Menu/ForgotPasswordWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public void Update()
102102
{
103103
Hide();
104104
mMainMenu.Show();
105-
Interface.ShowError(Strings.Errors.LostConnection);
106105
}
107106

108107
// Re-Enable our buttons if we're not waiting for the server anymore with it disabled.

Intersect.Client/Interface/Menu/RegisterWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ public void Update()
153153
{
154154
Hide();
155155
mMainMenu.Show();
156-
Interface.ShowError(Strings.Errors.LostConnection);
157156
}
158157

159158
// Re-Enable our buttons if we're not waiting for the server anymore with it disabled.

Intersect.Client/Interface/Menu/ResetPasswordWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public void Update()
144144
{
145145
Hide();
146146
mMainMenu.Show();
147-
Interface.ShowError(Strings.Errors.LostConnection);
148147
}
149148
}
150149

Intersect.Client/Interface/Menu/SelectCharacterWindow.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public void Update()
123123
{
124124
Hide();
125125
mMainMenu.Show();
126-
Interface.ShowError(Strings.Errors.LostConnection);
127126
}
128127

129128
// Re-Enable our buttons if we're not waiting for the server anymore with it disabled.
@@ -344,7 +343,7 @@ public void Hide()
344343

345344
private void mLogoutButton_Clicked(Base sender, ClickedEventArgs arguments)
346345
{
347-
Main.Logout(false, skipFade: true);
346+
Main.Logout(false, true, skipFade: true);
348347
mMainMenu.Reset();
349348
}
350349

Intersect.Client/Networking/PacketSender.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public static void SendLogin(string username, string password)
2828
Network.SendPacket(new LoginPacket(username, password));
2929
}
3030

31-
public static void SendLogout(bool characterSelect = false)
31+
public static void SendLogout(bool characterSelect = false, bool mainMenu = true)
3232
{
33-
Network.SendPacket(new LogoutPacket(characterSelect));
33+
Network.SendPacket(new LogoutPacket(characterSelect, mainMenu));
3434
}
3535

3636
public static void SendNeedMap(params ObjectCacheKey<MapBase>[] cacheKeys)

Intersect.Server.Core/Networking/PacketHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,13 @@ public void HandlePacket(Client client, LogoutPacket packet)
663663
client.Entity = default;
664664
PacketSender.SendPlayerCharacters(client, skipLoadingRelationships: true);
665665
}
666+
else if(packet.ReturningToMainMenu)
667+
{
668+
Log.Debug($"[{nameof(LogoutPacket)}] Returning to main menu from player {client.Entity?.Id} ({client.User?.Id})");
669+
client.Entity?.TryLogout(false, true);
670+
client.Entity = default;
671+
client.SetUser(null);
672+
}
666673
else
667674
{
668675
client.Logout();

0 commit comments

Comments
 (0)