ignore hat/weapon state changes

This commit is contained in:
rootdarkarchon
2023-02-26 14:47:59 +01:00
parent 242b6650ef
commit b42e7e236c
3 changed files with 6 additions and 30 deletions

View File

@@ -165,11 +165,11 @@ public class GameObjectHandler : MediatorSubscriberBase
}
}
var customizeDiff = CompareAndUpdateCustomizeData(chara->CustomizeData, out bool doNotSendUpdate);
var customizeDiff = CompareAndUpdateCustomizeData(chara->CustomizeData);
if (addrDiff || equipDiff || customizeDiff || drawObjDiff || nameChange)
{
if (_isOwnedObject && !doNotSendUpdate)
if (_isOwnedObject)
{
_logger.LogTrace("[{this}] Changed", this);
@@ -203,11 +203,10 @@ public class GameObjectHandler : MediatorSubscriberBase
_clearCts = null;
}
private unsafe bool CompareAndUpdateCustomizeData(byte* customizeData, out bool doNotSendUpdate)
private unsafe bool CompareAndUpdateCustomizeData(byte* customizeData)
{
bool hasChanges = false;
doNotSendUpdate = false;
for (int i = 0; i < CustomizeData.Length; i++)
{
var data = Marshal.ReadByte((IntPtr)customizeData, i);
@@ -218,30 +217,6 @@ public class GameObjectHandler : MediatorSubscriberBase
}
}
var newHatState = Marshal.ReadByte((IntPtr)customizeData + 30, 0);
var newWeaponOrVisorState = Marshal.ReadByte((IntPtr)customizeData + 31, 0);
if (newHatState != HatState)
{
if (HatState != null && !hasChanges)
{
_logger.LogDebug("[{this}] Not Sending Update, only Hat changed", this);
doNotSendUpdate = true;
}
HatState = newHatState;
}
newWeaponOrVisorState &= 0b1101; // ignore drawing weapon
if (newWeaponOrVisorState != VisorWeaponState)
{
if (VisorWeaponState != null && !hasChanges)
{
_logger.LogDebug("[{this}] Not Sending Update, only Visor/Weapon changed", this);
doNotSendUpdate = true;
}
VisorWeaponState = newWeaponOrVisorState;
}
return hasChanges;
}