Skip to content

Commit

Permalink
Fix crash when joining LAN game
Browse files Browse the repository at this point in the history
  • Loading branch information
Rampastring committed Mar 29, 2020
1 parent 651a656 commit 02e82ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/CnCNetGameLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ protected override void UpdateDiscordPresence(bool resetTimer = false)
if (discordHandler == null)
return;

PlayerInfo player = Players.Find(p => p.Name == ProgramConstants.PLAYERNAME);
PlayerInfo player = FindLocalPlayer();
if (player == null || Map == null || GameMode == null)
return;
string side = "";
Expand Down Expand Up @@ -1210,7 +1210,7 @@ protected override void WriteSpawnIniAdditions(IniFile iniFile)
iniFile.SetIntValue("Settings", "GameID", UniqueGameID);
iniFile.SetBooleanValue("Settings", "Host", IsHost);

PlayerInfo localPlayer = Players.Find(p => p.Name == ProgramConstants.PLAYERNAME);
PlayerInfo localPlayer = FindLocalPlayer();

if (localPlayer == null)
return;
Expand Down
2 changes: 2 additions & 0 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ protected Map Map
protected List<PlayerInfo> Players = new List<PlayerInfo>();
protected List<PlayerInfo> AIPlayers = new List<PlayerInfo>();

protected virtual PlayerInfo FindLocalPlayer() => Players.Find(p => p.Name == ProgramConstants.PLAYERNAME);

protected bool PlayerUpdatingInProgress { get; set; }

protected Texture2D[] RankTextures;
Expand Down
8 changes: 5 additions & 3 deletions DXMainClient/DXGUI/Multiplayer/GameLobby/LANGameLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ protected override void UpdateDiscordPresence(bool resetTimer = false)
if (discordHandler == null)
return;

PlayerInfo player = Players.Find(p => p.Name == ProgramConstants.PLAYERNAME);
PlayerInfo player = FindLocalPlayer();
if (player == null || Map == null || GameMode == null)
return;
string side = "";
Expand Down Expand Up @@ -847,7 +847,8 @@ private void HandlePlayerOptionsBroadcast(string data)
if (parts.Length != playerCount * 8)
return;

int oldSide = Players.Find(p => p.Name == ProgramConstants.PLAYERNAME).SideId;
PlayerInfo localPlayer = FindLocalPlayer();
int oldSideId = localPlayer == null ? -1 : localPlayer.SideId;

Players.Clear();
AIPlayers.Clear();
Expand Down Expand Up @@ -911,7 +912,8 @@ private void HandlePlayerOptionsBroadcast(string data)
}

CopyPlayerDataToUI();
if (oldSide != Players.Find(p => p.Name == ProgramConstants.PLAYERNAME).SideId)
localPlayer = FindLocalPlayer();
if (localPlayer != null && oldSideId != localPlayer.SideId)
UpdateDiscordPresence();
}

Expand Down
4 changes: 2 additions & 2 deletions DXMainClient/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.6.2.3")]
[assembly: AssemblyFileVersion("2.6.2.3")]
[assembly: AssemblyVersion("2.6.2.4")]
[assembly: AssemblyFileVersion("2.6.2.4")]

0 comments on commit 02e82ab

Please sign in to comment.