Skip to content

Commit 1e8ddf7

Browse files
authored
Fix loading screen hanging on map parsing errors (#782)
1 parent d93d1d1 commit 1e8ddf7

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

DXMainClient/DXGUI/GameClass.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,6 @@ protected override void Initialize()
148148

149149
wm.ControlINIAttributeParsers.Add(new TranslationINIParser());
150150

151-
MainClientConstants.DisplayErrorAction = (title, error, exit) =>
152-
{
153-
new XNAMessageBox(wm, title, error, XNAMessageBoxButtons.OK)
154-
{
155-
OKClickedAction = _ =>
156-
{
157-
if (exit)
158-
Environment.Exit(1);
159-
}
160-
}.Show();
161-
};
162-
163151
SetGraphicsMode(wm);
164152

165153
#if WINFORMS

DXMainClient/DXGUI/Generic/MainMenu.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,19 @@ public void PostInit()
652652
CheckRequiredFiles();
653653
CheckForbiddenFiles();
654654
CheckIfFirstRun();
655+
656+
MainClientConstants.DisplayErrorAction = (title, error, exit) =>
657+
{
658+
new XNAMessageBox(WindowManager, title, error, XNAMessageBoxButtons.OK)
659+
{
660+
OKClickedAction = _ =>
661+
{
662+
if (exit)
663+
Environment.Exit(1);
664+
},
665+
666+
}.Show();
667+
};
655668
}
656669

657670
private void LoadThemeSong()

DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ private void RefreshPlayerList(object sender, EventArgs e)
14001400
lbPlayerList.Clear();
14011401

14021402
// Note: IUserCollection.GetFirst() is not guaranteed to be implemented, unless it is a SortedUserCollection
1403-
Debug.Assert(currentChatChannel.Users is SortedUserCollection<ChannelUser>);
1403+
Debug.Assert(currentChatChannel.Users is SortedUserCollection<ChannelUser>, "Channel 'users' is supposed to be a SortedUserCollection");
14041404
var current = currentChatChannel.Users.GetFirst();
14051405
while (current != null)
14061406
{

DXMainClient/Online/Channel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ public void OnUserListReceived(List<ChannelUser> userList)
147147
existingUser.IsAdmin = user.IsAdmin;
148148
existingUser.IsFriend = user.IsFriend;
149149

150-
// Note: IUserCollection.GetFirst() is not guaranteed to be implemented, unless it is a SortedUserCollection
151-
Debug.Assert(users is SortedUserCollection<ChannelUser>);
150+
// Note: IUserCollection.Reinsert() is not guaranteed to be implemented, unless it is a SortedUserCollection
151+
Debug.Assert(users is SortedUserCollection<ChannelUser>, "Channel 'users' is supposed to be a SortedUserCollection");
152152
users.Reinsert(user.IRCUser.Name);
153153
}
154154
}

DXMainClient/PreStartup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ public static void LogException(Exception ex, bool innerException = false)
234234
Logger.Log("Type: " + ex.GetType());
235235
Logger.Log("Message: " + ex.Message);
236236
Logger.Log("Source: " + ex.Source);
237-
Logger.Log("TargetSite.Name: " + ex.TargetSite.Name);
237+
Logger.Log("TargetSite.Name: " + ex.TargetSite?.Name);
238238
Logger.Log("Stacktrace: " + ex.StackTrace);
239239

240240
if (ex.InnerException is not null)
241241
LogException(ex.InnerException, true);
242242
}
243243

244-
static void HandleException(object sender, Exception ex)
244+
public static void HandleException(object sender, Exception ex)
245245
{
246-
LogException(ex);
246+
LogException(ex, innerException: false);
247247

248248
string errorLogPath = SafePath.CombineFilePath(ProgramConstants.ClientUserFilesPath, "ClientCrashLogs", FormattableString.Invariant($"ClientCrashLog{DateTime.Now.ToString("_yyyy_MM_dd_HH_mm")}.txt"));
249249
bool crashLogCopied = false;

0 commit comments

Comments
 (0)