ekolis / ekolis/FrEee

Error when loading battle that ends in defeat

Open
#631 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
86
Forks
14
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Opening the battle results for a battle that ends in defeat causes a null reference exception.

**Steps to reproduce**
1. Open attached savegame
2. Double click the "Defeat at Wanduk I" battle in the log

**Expected behavior**
The battle results load.

**Actual behavior**
Error:
```
NullReferenceException occurred at 3/2/2026 2:13:20 PM:
System.NullReferenceException: Object reference not set to an instance of an object.
at FrEee.Extensions.CommonExtensions.<>c__DisplayClass54_0.b__2(ICombatant c) in /var/mnt/data/Repos/FrEee/FrEee.Core.Domain/Extensions/CommonExtensions.cs:line 1029
at System.Linq.Enumerable.IEnumerableWhereIterator`1.TryGetFirst(Boolean& found)
at System.Linq.Enumerable.Concat2Iterator`1.TryGetFirst(Boolean& found)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at FrEee.Extensions.CommonExtensions.ResultFor(IBattle b, Empire emp) in /var/mnt/data/Repos/FrEee/FrEee.Core.Domain/Extensions/CommonExtensions.cs:line 1032
at FrEee.Extensions.CommonExtensions.NameFor(IBattle b, Empire emp) in /var/mnt/data/Repos/FrEee/FrEee.Core.Domain/Extensions/CommonExtensions.cs:line 698
at FrEee.UI.WinForms.Forms.BattleResultsForm.Bind() in /var/mnt/data/Repos/FrEee/FrEee.UI.WinForms/Forms/BattleResultsForm.cs:line 97
at FrEee.UI.WinForms.Forms.BattleResultsForm.Bind(IBattle data) in /var/mnt/data/Repos/FrEee/FrEee.UI.WinForms/Forms/BattleResultsForm.cs:line 45
at FrEee.UI.WinForms.Forms.BattleResultsForm..ctor(IBattle battle) in /var/mnt/data/Repos/FrEee/FrEee.UI.WinForms/Forms/BattleResultsForm.cs:line 34
at FrEee.UI.WinForms.Forms.LogForm.lstLog_MouseDoubleClick(Object sender, MouseEventArgs e) in /var/mnt/data/Repos/FrEee/FrEee.UI.WinForms/Forms/LogForm.cs:line 120
at System.Windows.Forms.ListView.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, UInt32 msg, WPARAM wparam, LPARAM lparam)
```

**Screenshots**
N/A

**Related issues**
N/A

**Testing plan**
???

**Additional context**
[fc2_44_0001.gam.zip](https://github.com/user-attachments/files/25692635/fc2_44_0001.gam.zip)

Contributor guide

No contributing guide indexed for this repository

Research direction

Open the attached fc2_44_0001.gam save and reproduce the crash by opening “Defeat at Wanduk I.” Start at FrEee.Core.Domain/Extensions/CommonExtensions.cs lines 1029-1032, then follow the call through FrEee.UI.WinForms/Forms/BattleResultsForm.cs line 97. Done means the defeat battle results open without a NullReferenceException; add or run a regression test if the existing test structure supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.