Skip to content

Commit

Permalink
fix replayviewer crash when first replay data item does not contain p…
Browse files Browse the repository at this point in the history
…layer entity
  • Loading branch information
epix37 committed May 5, 2015
1 parent 01fd0cc commit 0012166
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Hearthstone Deck Tracker/Replay/ReplayViewer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,12 @@ public void Load(List<ReplayKeyPoint> replay)
var selectedKeypoint = DataGridKeyPoints.SelectedItem as TurnViewItem;
DataGridKeyPoints.Items.Clear();
Replay = replay;
_currentGameState = Replay[0];
_currentGameState = Replay.FirstOrDefault(r => r.Data.Any(x => x.HasTag(GAME_TAG.PLAYER_ID)));
if(_currentGameState == null)
{
Logger.WriteLine("Error loading replay. No player entity found.");
return;
}
_playerController = PlayerEntity.GetTag(GAME_TAG.CONTROLLER);
_opponentController = OpponentEntity.GetTag(GAME_TAG.CONTROLLER);
var currentTurn = -1;
Expand Down

0 comments on commit 0012166

Please sign in to comment.