Skip to content

Commit

Permalink
Character data is now correctly saved
Browse files Browse the repository at this point in the history
  • Loading branch information
hozuki committed Mar 2, 2020
1 parent 78a65eb commit 00c2538
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ internal sealed class KkCharacter {
throw new InvalidOperationException("Cannot set value to a placeholder.");
}

var a = k.SubArray(2);

var mapped = PercentageKeyMap[value];

KkBinaryIo.WriteUInt16LE(a, mapped);
KkBinaryIo.WriteUInt16LE(k, mapped, 2);
}

[CanBeNull]
Expand Down
6 changes: 3 additions & 3 deletions KoikatuGameSaveEditor.Entities/IO/KkBinaryIo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ internal sealed class KkBinaryIo {
return u;
}

public static void WriteUInt16LE([NotNull] byte[] span, ushort value) {
Trace.Assert(span.Length >= 2);
public static void WriteUInt16LE([NotNull] byte[] span, ushort value, int offset) {
Trace.Assert(span.Length >= 2 + offset);

if (!BitConverter.IsLittleEndian) {
value = SwapEndian(value);
}

var bytes = BitConverter.GetBytes(value);

Array.Copy(bytes, span, bytes.Length);
Array.Copy(bytes, 0, span, offset, bytes.Length);
}

public string ReadUtf8String([NotNull] Stream stream) {
Expand Down
8 changes: 8 additions & 0 deletions KoikatuGameSaveEditor/UI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ public partial class Form1 : Form, ITranslateable {
}

private void SaveCurrentSaveGameTo([NotNull] string path) {
foreach (var o in mainPanel.Tiles) {
var control = o as ICharacterControl;

Trace.Assert(control != null);

control.SaveToCharacter();
}

Trace.Assert(_saveData != null, nameof(_saveData) + " != null");

try {
Expand Down

0 comments on commit 00c2538

Please sign in to comment.