Skip to content

Commit

Permalink
Merge pull request SapphireServer#56 from Lotlab/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
SapphireMordred authored May 26, 2023
2 parents 432443e + 1bf8fe5 commit 1d855be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions FFXIVMonReborn/Importers/XmlCaptureImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public static Capture Load(string path)

public static void Save(Capture capture, string path)
{
//using (var fileStream = new FileStream(path, FileMode.Create))
using (var fileStream = new FileStream(path, FileMode.Create))
{
var fileStream = new FileStream(path, FileMode.Create);
if (capture != null)
{
foreach (var packet in capture.Packets)
Expand Down
19 changes: 12 additions & 7 deletions FFXIVMonReborn/Views/DataTypeView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ public void Apply(byte[] data, int offset)
thisItem.ValueCol = $"{DateTimeOffset.FromUnixTimeSeconds(BitConverter.ToUInt32(data, offset)).ToLocalTime()}";
else if (thisItem.DataTypeCol == "string (ascii)")
{
var str = Encoding.ASCII.GetString(data);
var terminatorOffset = str.IndexOf((char)0, offset);
thisItem.ValueCol = str.Substring(offset, terminatorOffset - offset);
var term = getTerminator(data, offset);
thisItem.ValueCol = Encoding.ASCII.GetString(data, offset, term - offset);
}
else if (thisItem.DataTypeCol == "string (utf8)")
{
var str = Encoding.UTF8.GetString(data);
var terminatorOffset = str.IndexOf((char)0, offset);
thisItem.ValueCol = str.Substring(offset, terminatorOffset - offset);
var term = getTerminator(data, offset);
thisItem.ValueCol = Encoding.UTF8.GetString(data, offset, term - offset);
}
else if (thisItem.DataTypeCol == "binary")
{
Expand Down Expand Up @@ -127,7 +125,14 @@ public void Apply(byte[] data, int offset)
DataTypeListView.Items.Add(thisItem);
}
}

int getTerminator(byte[] data, int offset)
{
for (int i = offset; i < data.Length; i++)
{
if (data[i] == 0) return i;
}
return data.Length;
}
private void DataTypeListView_KeyDown(object sender, KeyEventArgs e)
{
if (DataTypeListView.IsKeyboardFocusWithin)
Expand Down

0 comments on commit 1d855be

Please sign in to comment.