Skip to content

Commit cafd22a

Browse files
committed
fix: save battalion edits to the selected slot
Use the barracks selection and preserve the empty owner and battalion values. Adapted from imouto1994's battalion fix: imouto1994/fe3h-editor@80bb3b8
1 parent b4aaea5 commit cafd22a

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎SaveEditor/frmMain.cs‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,26 +1109,27 @@ private void LoadBattalions(int index = 0)
11091109

11101110
private void SaveBattalion()
11111111
{
1112-
int x = lstCharacter.SelectedIndex;
1113-
1114-
if(x == -1 || save == null)
1112+
int slot = lstBattalion.SelectedIndex;
1113+
1114+
if(save == null || slot < 0 || slot >= save.SaveData.Player.Battalions.Length)
11151115
return;
11161116

1117-
short id = (short) Util.GetSortedKey<string>(cboBattalionCharacter);
1118-
if (id == -1) id = Database.BATTALION_COUNT;
1117+
short characterId = cboBattalionCharacter.SelectedItem == null
1118+
? (short)-1 : (short)Util.GetSortedKey<string>(cboBattalionCharacter);
1119+
int type = cboBattalionType.SelectedItem == null
1120+
? -1 : Util.GetSortedKey<string>(cboBattalionType);
11191121

11201122
Battalion battalion = new Battalion
11211123
{
1122-
CharacterId = id,
1123-
Type = (byte)Util.GetSortedKey<string>(cboBattalionType),
1124+
CharacterId = characterId,
1125+
Type = (byte)(type == -1 ? Database.BATTALION_COUNT : type),
11241126
Exp = (ushort)numBattalionExp.Value,
11251127
Stamina = (ushort)numBattalionStamina.Value,
11261128
Skill = (byte)Util.GetSortedKey<string>(cboBattalionSkill)
11271129
};
1128-
1129-
save.SaveData.Player.Battalions[x] = battalion;
11301130

1131-
LoadBattalions(x);
1131+
save.SaveData.Player.Battalions[slot] = battalion;
1132+
LoadBattalions(slot);
11321133
}
11331134

11341135
private void LoadDatabaseViewer()

‎bin/FETH_SaveEditor.exe‎

0 Bytes
Binary file not shown.

‎bin/FETH_SaveEditor.pdb‎

24 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)