Skip to content

Commit

Permalink
Merge pull request #3 from jasonycw/feature/MHW_5.1_update
Browse files Browse the repository at this point in the history
MHW 5.1 Update
  • Loading branch information
jasonycw authored Jan 24, 2019
2 parents 4f82990 + cf1337c commit 0369012
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Binary file modified Decode.docx
Binary file not shown.
15 changes: 8 additions & 7 deletions MHW-KT-Droprate-Editor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,20 @@ private void OpenFile(object sender, RoutedEventArgs e)
var filename = dlg.FileName;
var input = File.ReadAllBytes(filename);
var buffer = new byte[1];
for (var i = 6; i < input.Length - 1; i += 24)
for (var i = 6; i < input.Length - 1; i += 28)
{
buffer[0] = input[i + 8];
var r6Pre = (decimal) (BitConverter.ToInt32(input, i + 8) / 100.0);
var r6Post = (decimal)(BitConverter.ToInt32(input, i + 12) / 100.0);
var r7 = (decimal)(BitConverter.ToInt32(input, i + 16) / 100.0);
var r8 = (decimal)(BitConverter.ToInt32(input, i + 20) / 100.0);
var r9 = (decimal)(BitConverter.ToInt32(input, i + 24) / 100.0);
if (i == 6)
BrownDroprate = new Droprate(WeaponType.Dissolved, r6Pre, r6Post, r7, r8);
else if (i == 30)
SilverDroprate = new Droprate(WeaponType.Melded, r6Pre, r6Post, r7, r8);
else if (i == 54)
GoldDroprate = new Droprate(WeaponType.Sublimated, r6Pre, r6Post, r7, r8);
BrownDroprate = new Droprate(WeaponType.Dissolved, r6Pre, r6Post, r7, r8, r9);
else if (i == 34)
SilverDroprate = new Droprate(WeaponType.Melded, r6Pre, r6Post, r7, r8, r9);
else if (i == 62)
GoldDroprate = new Droprate(WeaponType.Sublimated, r6Pre, r6Post, r7, r8, r9);
}

Render();
Expand Down Expand Up @@ -172,7 +173,7 @@ private async void SaveFile(object sender, RoutedEventArgs e)
{
using (var fs = dlg.OpenFile())
{
var buffer = new List<byte> { 0x1F, 0x00, 0x03, 0x00, 0x00, 0x00 };
var buffer = new List<byte> { 0x3B, 0x00, 0x03, 0x00, 0x00, 0x00 };
var brownHeader = new List<byte> { 0x00, 0x00, 0x00, 0x00, 0xA8, 0x03, 0x00, 0x00 };
var silverHeader = new List<byte> { 0x01, 0x00, 0x00, 0x00, 0xA9, 0x03, 0x00, 0x00 };
var goldHeader = new List<byte> { 0x02, 0x00, 0x00, 0x00, 0xAA, 0x03, 0x00, 0x00 };
Expand Down
7 changes: 5 additions & 2 deletions MHW-KT-Droprate-Editor/Models/Droprate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ public class Droprate
public decimal R6GoldPostfix { get; set; }
public decimal R7 { get; set; }
public decimal R8 { get; set; }
public decimal R9 { get; set; }

public int TotalPercentage => (int)((R6GoldPrefix + R6GoldPostfix + R7 + R8) * 100);
public int TotalPercentage => (int)((R6GoldPrefix + R6GoldPostfix + R7 + R8 + R9) * 100);
public bool Valid => TotalPercentage == 100;

public byte[] ToByte
Expand All @@ -20,20 +21,22 @@ public byte[] ToByte
(byte) (R6GoldPostfix * 100), 0x00, 0x00, 0x00,
(byte) (R7 * 100), 0x00, 0x00, 0x00,
(byte) (R8 * 100), 0x00, 0x00, 0x00,
(byte) (R9 * 100), 0x00, 0x00, 0x00,
}.ToArray();

// JsonConvert need this
public Droprate() { }

public Droprate(WeaponType type) => Type = type;

public Droprate(WeaponType type, decimal r6Pre, decimal r6Post, decimal r7, decimal r8)
public Droprate(WeaponType type, decimal r6Pre, decimal r6Post, decimal r7, decimal r8, decimal r9)
{
Type = type;
R6GoldPrefix = r6Pre;
R6GoldPostfix = r6Post;
R7 = r7;
R8 = r8;
R9 = r9;
}
}
}

0 comments on commit 0369012

Please sign in to comment.