mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-25 07:37:02 -05:00
Finalize the verification logic for inventory
Move the ValidateEnabled check to the top to completely disable validation -- it is recommended to actually use the validation. This should work perfectly for everyone, assuming you haven't corrupted the region we're validating. Game data structure stores as follows: Item[20] bag; u32 bagCount; sbyte[20] binds; Item[20] pocket; u32 pocketCount; sbyte[20] binds; count is 0,10,20 depending on unlocked, and binding is -1 or 0-7 depending on where the item is bound (item quick use wheel)
This commit is contained in:
parent
de6190ed79
commit
f28a544604
|
|
@ -87,17 +87,27 @@ public InjectionResult Write()
|
|||
|
||||
public bool Validate(byte[] data)
|
||||
{
|
||||
if (BitConverter.ToUInt32(data, pocket) > 20) // pouch21-39 count
|
||||
return false;
|
||||
|
||||
if (!ValidateEnabled)
|
||||
return true;
|
||||
|
||||
for (int i = 4; i < 0x18; i += 4)
|
||||
// Check the unlocked slot count -- expect 0,10,20
|
||||
var bagCount = BitConverter.ToUInt32(data, pocket);
|
||||
if (bagCount > 20 || bagCount % 10 != 0) // pouch21-39 count
|
||||
return false;
|
||||
|
||||
// Check the item wheel binding -- expect -1 or [0,7]
|
||||
// Disallow duplicate binds!
|
||||
var bound = new List<byte>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var val = BitConverter.ToInt32(data, pocket + i);
|
||||
if (val != -1)
|
||||
var bind = data[pocket + 4 + i];
|
||||
if (bind == 0xFF)
|
||||
continue;
|
||||
if (bind > 7)
|
||||
return false;
|
||||
if (bound.Contains(bind))
|
||||
return false;
|
||||
bound.Add(bind);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user