DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerInventory.c File Reference

Go to the source code of this file.

Classes

class  DeferredEvent
 
class  DeferredSwapEntities
 
class  DeferredHandEvent
 

Functions

void DeferredTakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
 
override bool ReserveInventory (HumanInventory inventory)
 
override void ClearInventoryReservation (HumanInventory inventory)
 
void DeferredForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 
void DeferredHandEvent (InventoryMode mode, HandEventBase e)
 
void DayZPlayerInventory ()
 
DayZPlayer GetDayZPlayerOwner ()
 
bool IsAuthoritative ()
 
bool IsOwner ()
 
bool IsProxy ()
 
override void Init ()
 Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)
 
void CancelHandEvent ()
 cancels any handevents that will be executed this frame @NOTE: this is used in situations where the player performs an action that renders the event invalid exactly on the frame it will be executed
 
void CancelWeaponEvent ()
 
void AbortWeaponEvent ()
 
void PostWeaponEvent (WeaponEventBase e)
 
void DeferredWeaponFailed ()
 
void HandleWeaponEvents (float dt, out bool exitIronSights)
 
void HandleInventory (float dt)
 
void OnInputUserDataForRemote (ParamsReadContext ctx)
 
override void OnServerInventoryCommand (ParamsReadContext ctx)
 
bool ValidateSyncMove (inout Serializer ctx, InventoryValidation validation)
 
bool ValidateHandEvent (inout Serializer ctx, InventoryValidation validation)
 
bool ValidateSwap (inout Serializer ctx, InventoryValidation validation)
 
bool ValidateDestroy (inout Serializer ctx, InventoryValidation validation)
 
bool ProcessInputData (ParamsReadContext ctx, bool isJuncture, bool isRemote)
 
void RemoveMovableOverride (EntityAI item)
 
void EnableMovableOverride (EntityAI item)
 
void CheckForRope (InventoryLocation src, InventoryLocation dst)
 
bool IsServerOrLocalPlayer ()
 
bool StoreInputForRemotes (bool handling_juncture, bool remote, ParamsReadContext ctx)
 
override bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
 
void HandleTakeToDst (DeferredEvent deferred_event)
 
override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
 
void HandleSwapEntities (DeferredEvent deferred_event)
 
override bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
 
void HandleForceSwapEntities (DeferredEvent deferred_event)
 
static void SendServerHandEventViaJuncture (notnull DayZPlayer player, HandEventBase e)
 
override void NetSyncCurrentStateID (int id)
 
override void OnAfterStoreLoad ()
 engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase.OnAfterStoreLoad
 
bool OnEventForRemoteWeapon (ParamsReadContext ctx)
 
bool OnHandEventForRemote (ParamsReadContext ctx)
 
void SyncHandEventToRemote (HandEventBase e)
 
override void OnHandsExitedStableState (HandStateBase src, HandStateBase dst)
 
override void OnHandsEnteredStableState (HandStateBase src, HandStateBase dst)
 
override void OnHandsStateChanged (HandStateBase src, HandStateBase dst)
 
override bool HandEvent (InventoryMode mode, HandEventBase e)
 
void HandleHandEvent (DeferredEvent deferred_event)
 
override void HandleInventoryManipulation ()
 
bool IsProcessing ()
 
bool PlayerCheckRequestSrc (notnull InventoryLocation src, float radius)
 
bool PlayerCheckRequestDst (notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
 
bool PlayerCheckSwapItemsRequest (notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
 
bool PlayerCheckDropRequest (notnull InventoryLocation src, float radius)
 
override bool OnInventoryJunctureFromServer (ParamsReadContext ctx)
 
override bool OnInventoryJunctureRepairFromServer (ParamsReadContext ctx)
 
override void OnInventoryJunctureFailureFromServer (ParamsReadContext ctx)
 
override void OnInventoryFailure (InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
 
void OnHandleStoredJunctureData (ParamsReadContext ctx)
 
proto native void StoreJunctureData (ParamsReadContext ctx)
 
override bool OnInputUserDataProcess (ParamsReadContext ctx)
 
void OnHandleStoredInputUserData (ParamsReadContext ctx)
 
proto native void StoreInputUserData (ParamsReadContext ctx)
 

Variables

class DeferredEvent m_src
 
ref InventoryLocation m_dst
 
DeferredSwapEntities m_item1
 
EntityAI m_item2
 
ref InventoryLocation m_dst1
 
ref InventoryLocation m_dst2
 
ref HandEventBase m_event
 
 m_DeferredEvent = NULL
 
ref Timer m_DeferredWeaponTimer = new Timer
 
ref HandEventBase m_DeferredPostedHandEvent = NULL
 
ref WeaponEventBase m_DeferredWeaponEvent = NULL
 deferred hand event
 
ref HandAnimatedTakingFromAtt m_Taking
 deferred weapon event
 
ref HandAnimatedMovingToAtt m_MovingTo
 
ref HandAnimatedSwapping m_Swapping
 
ref HandAnimatedForceSwapping m_FSwapping
 
ref HandAnimatedForceSwapping_Inst m_FSwappingInst
 

Function Documentation

◆ AbortWeaponEvent()

void AbortWeaponEvent ( )
protected

Definition at line 255 of file DayZPlayerInventory.c.

256 {
257 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
258
260 Class.CastTo(weapon, GetEntityInHands());
261
262 if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
263 {
265 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
266
267 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
268 }
269 }
void wpnDebugPrint(string s)
Definition Debug.c:9
DayZPlayer GetDayZPlayerOwner()
Super root of all classes in Enforce script.
Definition EnScript.c:11
static bool IsWeaponLogEnable()
Definition Debug.c:799
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo(), GetDayZPlayerOwner(), LogManager::IsWeaponLogEnable(), and wpnDebugPrint().

Referenced by ManBase::OnCommandClimbStart(), ManBase::OnCommandDeathStart(), ManBase::OnCommandFallStart(), ManBase::OnCommandMelee2Start(), ManBase::OnCommandSwimStart(), ManBase::OnJumpStart(), and ManBase::OnStanceChange().

◆ CancelHandEvent()

CancelHandEvent ( )
protected

cancels any handevents that will be executed this frame @NOTE: this is used in situations where the player performs an action that renders the event invalid exactly on the frame it will be executed

Definition at line 243 of file DayZPlayerInventory.c.

244 {
246 //m_postedHandEvent = null;
247 }
ref HandEventBase m_DeferredPostedHandEvent

References m_DeferredPostedHandEvent.

◆ CancelWeaponEvent()

void CancelWeaponEvent ( )
protected

Definition at line 249 of file DayZPlayerInventory.c.

250 {
253 }
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
ref Timer m_DeferredWeaponTimer

References m_DeferredWeaponEvent, and m_DeferredWeaponTimer.

Referenced by DeferredWeaponFailed().

◆ CheckForRope()

void CheckForRope ( InventoryLocation src,
InventoryLocation dst )
protected

Definition at line 1392 of file DayZPlayerInventory.c.

1393 {
1394 Rope rope = Rope.Cast(src.GetItem());
1395 if (rope)
1396 rope.SetTargetLocation(dst);
1397 }

Referenced by ValidateHandEvent(), and ValidateSyncMove().

◆ ClearInventoryReservation()

override void ClearInventoryReservation ( HumanInventory inventory)

Definition at line 29 of file DayZPlayerInventory.c.

30 {
31 inventory.ClearInventoryReservationEx(m_dst.GetItem(), m_dst);
32 }
ref InventoryLocation m_dst

References m_dst.

◆ DayZPlayerInventory()

void DayZPlayerInventory ( )
protected

Definition at line 145 of file DayZPlayerInventory.c.

146 {
147 }

◆ DeferredForceSwapEntities()

void DeferredForceSwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2 )

Definition at line 77 of file DayZPlayerInventory.c.

78 {
79 m_mode = mode;
80 m_item1 = item1;
81 m_item2 = item2;
82 m_dst1 = dst1;
83 m_dst2 = dst2;
84 }
ref InventoryLocation m_dst1
ref InventoryLocation m_dst2
DeferredSwapEntities m_item1
EntityAI m_item2

References m_dst1, m_dst2, m_item1, and m_item2.

Referenced by ForceSwapEntities(), and HandleForceSwapEntities().

◆ DeferredHandEvent()

void DayZPlayerInventory::DeferredHandEvent ( InventoryMode mode,
HandEventBase e )

Definition at line 108 of file DayZPlayerInventory.c.

109 {
110 m_mode = mode;
111 m_event = e;
112 }
ref HandEventBase m_event

Referenced by HandEvent().

◆ DeferredTakeToDst()

void DeferredTakeToDst ( InventoryMode mode,
notnull InventoryLocation src,
notnull InventoryLocation dst )

Definition at line 15 of file DayZPlayerInventory.c.

16 {
17 m_mode = mode;
18 m_src = src;
19 m_dst = dst;
20 }
class DeferredEvent m_src

References m_dst, and m_src.

Referenced by HandleTakeToDst(), and TakeToDst().

◆ DeferredWeaponFailed()

void DeferredWeaponFailed ( )
protected

Definition at line 288 of file DayZPlayerInventory.c.

289 {
291 Class.CastTo(weapon, GetEntityInHands());
292
293 string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
294
295 string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
296 if (weapon)
297 {
298 secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
299 secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
300 for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
301 {
302 secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
303 secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
304 if (i < weapon.GetMuzzleCount() - 1)
305 secondPart += " | ";
306 }
307 }
308
311 }
void CancelWeaponEvent()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

References CancelWeaponEvent(), Class::CastTo(), Error(), and m_DeferredWeaponEvent.

◆ EnableMovableOverride()

void EnableMovableOverride ( EntityAI item)
protected

Definition at line 1384 of file DayZPlayerInventory.c.

1385 {
1386 ItemBase itemIB = ItemBase.Cast(item);
1387 if (itemIB)
1388 itemIB.SetCanBeMovedOverride(true);
1389 }

Referenced by HandleHandEvent(), HandleSwapEntities(), HandleTakeToDst(), ValidateHandEvent(), ValidateSwap(), and ValidateSyncMove().

◆ ForceSwapEntities()

override bool ForceSwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2,
notnull InventoryLocation item2_dst )
protected

Definition at line 1671 of file DayZPlayerInventory.c.

1672 {
1673#ifdef DEVELOPER
1675 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1676#endif
1677
1678 if (mode == InventoryMode.LOCAL)
1679 {
1682 {
1683 LocationSwap(src1, src2, dst1, item2_dst);
1684 return true;
1685 }
1686
1687 }
1688
1689 if (!super.ForceSwapEntities(mode, item1, item2, item2_dst))
1690 {
1691 if (!m_DeferredEvent)
1692 {
1694 {
1696 if (m_DeferredEvent.ReserveInventory(this))
1697 return true;
1698
1699 }
1700 }
1702 return false;
1703 }
1704
1705 return true;
1706 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
m_DeferredEvent
void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
proto string ToString()
Definition Debug.c:14
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:163
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool MakeSrcAndDstForForceSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
helper function for ForceSwap
Definition Inventory.c:1178
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
static bool IsInventoryMoveLogEnable()
Definition Debug.c:729

References DeferredForceSwapEntities(), InventoryLocation::DumpToStringNullSafe(), GetDayZPlayerOwner(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), m_DeferredEvent, GameInventory::MakeSrcAndDstForForceSwap(), and ToString().

◆ GetDayZPlayerOwner()

◆ HandEvent()

override bool HandEvent ( InventoryMode mode,
HandEventBase e )
protected

Let the client know a failure happened

If singleplayer or the client is executing this

Definition at line 1952 of file DayZPlayerInventory.c.

1953 {
1954 if (!IsProcessing())
1955 {
1956 EntityAI itemInHands = GetEntityInHands();
1957
1959 handInventoryLocation.SetHands(GetInventoryOwner(), itemInHands);
1960
1962 if (e.CanPerformEventEx(validation))
1963 {
1965 if (m_DeferredEvent.ReserveInventory(this))
1966 return true;
1967 }
1968
1970
1972 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
1973 {
1975 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
1976 }
1977 else
1978 {
1980
1982 serializer.Write(validation.m_Reason);
1983
1985 }
1986 }
1987
1988 return false;
1989 }
InventoryCommandType
Definition Inventory.c:3
bool IsProcessing()
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
proto native CGame GetGame()

References DeferredHandEvent(), GetDayZPlayerOwner(), GetGame(), IsProcessing(), m_DeferredEvent, OnInventoryFailure(), InventoryInputUserData::SerializeHandEvent(), and DayZPlayerSyncJunctures::SJ_INVENTORY_FAILURE.

◆ HandleForceSwapEntities()

void HandleForceSwapEntities ( DeferredEvent deferred_event)
protected

Definition at line 1708 of file DayZPlayerInventory.c.

1709 {
1712 {
1713 deferred_force_swap_entities.ClearInventoryReservation(this);
1716 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
1717 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
1718
1719 DayZPlayer player = GetGame().GetPlayer();
1720
1723
1724 switch (deferred_force_swap_entities.m_mode)
1725 {
1726 case InventoryMode.PREDICTIVE:
1727 if (CanForceSwapEntitiesEx(deferred_force_swap_entities.m_dst1.GetItem(), deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2.GetItem(), deferred_force_swap_entities.m_dst2))
1728 {
1731 }
1732 else
1733 {
1734#ifdef DEVELOPER
1736 Debug.InventoryMoveLog("Can not force swap (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_force_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_force_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_force_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1737#endif
1738 }
1739 break;
1740
1741 case InventoryMode.JUNCTURE:
1742 if (CanForceSwapEntitiesEx(deferred_force_swap_entities.m_dst1.GetItem(), deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2.GetItem(), deferred_force_swap_entities.m_dst2))
1743 {
1744 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1745 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1746
1748 }
1749 else
1750 {
1751#ifdef DEVELOPER
1753 Debug.InventoryMoveLog("Can not force swap (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_force_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_force_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_force_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1754#endif
1755 }
1756 break;
1757
1758 case InventoryMode.LOCAL:
1759 break;
1760
1761 default:
1762 Error("ForceSwapEntities - HandEvent - Invalid mode");
1763 }
1764 }
1765 }
void inventoryDebugPrint(string s)
Definition Debug.c:19
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:688
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)

References GameInventory::c_InventoryReservationTimeoutShortMS, DeferredForceSwapEntities(), InventoryLocation::DumpToStringNullSafe(), Error(), GetDayZPlayerOwner(), GetGame(), inventoryDebugPrint(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), InventoryInputUserData::SendInputUserDataSwap(), and ToString().

Referenced by HandleInventoryManipulation().

◆ HandleHandEvent()

void HandleHandEvent ( DeferredEvent deferred_event)
protected

Default structure suffices

Definition at line 1992 of file DayZPlayerInventory.c.

1993 {
1996
1999 {
2000#ifdef DEVELOPER
2002 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2003#endif
2004
2006 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2007
2008 switch (deferred_hand_event.m_mode)
2009 {
2010 case InventoryMode.PREDICTIVE:
2011#ifdef DEVELOPER
2013 Debug.InventoryHFSMLog("PREDICTIVE", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2014#endif
2015
2016 deferred_hand_event.ClearInventoryReservation(this);
2017 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2018 {
2020 ProcessHandEvent(deferred_hand_event.m_event);
2021 }
2022 break;
2023
2024 case InventoryMode.JUNCTURE:
2025#ifdef DEVELOPER
2027 Debug.InventoryHFSMLog("JUNCTURE", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2028#endif
2029
2030 deferred_hand_event.ClearInventoryReservation(this);
2031 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2032 {
2033 deferred_hand_event.ReserveInventory(this);
2035
2036 //Functionality to prevent desync when two players perform interfering action at the same time
2037 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2039 if (deferred_hand_event.m_event.GetDst())
2040 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2041 if (itemSrc)
2043 if (itemDst)
2045 }
2046 break;
2047
2048 case InventoryMode.LOCAL:
2049#ifdef DEVELOPER
2051 Debug.InventoryHFSMLog("LOCAL", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2052#endif
2053
2054 deferred_hand_event.ClearInventoryReservation(this);
2055 ProcessHandEvent(deferred_hand_event.m_event);
2056 //PostHandEvent(deferred_hand_event.m_event);
2057 break;
2058
2059 case InventoryMode.SERVER:
2060#ifdef DEVELOPER
2062 Debug.InventoryHFSMLog("SERVER", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2063#endif
2064
2066 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2067
2068 if (!deferred_hand_event.m_event.IsServerSideOnly())
2069 {
2070 if (GetDayZPlayerOwner().IsAlive())
2072 else
2074 }
2075 else
2076 ProcessHandEvent(deferred_hand_event.m_event);
2077 break;
2078
2079 default:
2080 Error("HumanInventory::HandEvent - Invalid mode");
2081 }
2082 }
2083 }
void EnableMovableOverride(EntityAI item)
static void SendServerHandEventViaJuncture(notnull DayZPlayer player, HandEventBase e)
void hndDebugPrint(string s)
Definition HandFSM.c:1
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:183
static void SendInputUserDataHandEvent(HandEventBase e)
static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749

References EnableMovableOverride(), Error(), GetDayZPlayerOwner(), hndDebugPrint(), Debug::InventoryHFSMLog(), LogManager::IsInventoryHFSMLogEnable(), InventoryInputUserData::SendInputUserDataHandEvent(), InventoryInputUserData::SendServerHandEventViaInventoryCommand(), SendServerHandEventViaJuncture(), and ToString().

Referenced by HandleInventoryManipulation().

◆ HandleInventory()

void HandleInventory ( float dt)
protected

Definition at line 387 of file DayZPlayerInventory.c.

388 {
389 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
390
391 EntityAI ih = GetEntityInHands();
394
395 if (hcw)
396 {
397 m_FSM.GetCurrentState().OnUpdate(dt);
398
399#ifdef DEVELOPER
401 hndDebugSpamALot("[hndfsm] HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
402#endif
403
404 if (!m_FSM.GetCurrentState().IsIdle() || !m_FSM.IsRunning())
405 {
406 while (true)
407 {
408 int weaponEventId = hcw.IsEvent();
409 if (weaponEventId == -1)
410 break;
411
413
414#ifdef DEVELOPER
416 hndDebugPrint("[hndfsm] HandleInventory: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
417#endif
418
419 if (anim_event != NULL)
420 {
422 ProcessHandEvent(anim_event);
423 }
424 }
425
426 if (hcw.IsActionFinished())
427 {
428 if (m_FSM.GetCurrentState().IsWaitingForActionFinish())
429 {
430#ifdef DEVELOPER
432 hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + m_FSM.GetCurrentState());
433#endif
434
435 HandEventBase fin_event = new HandEventHumanCommandActionFinished(GetManOwner());
437 ProcessHandEvent(fin_event);
438 }
439 else
440 {
441#ifdef DEVELOPER
443 hndDebugPrint("[hndfsm] Hand-Weapon event: ABORT! notifying running state=" + m_FSM.GetCurrentState());
444#endif
445
446 HandEventBase abt_event = new HandEventHumanCommandActionAborted(GetManOwner());
448 ProcessHandAbortEvent(abt_event);
449 //m_FSM.ProcessHandAbortEvent(new WeaponEventHumanCommandActionAborted(GetManOwner()));
450 }
451 }
452 }
453 }
454 }
void SyncHandEventToRemote(HandEventBase e)
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
void hndDebugSpamALot(string s)
Definition HandFSM.c:17
Abstracted event, not to be used, only inherited.
WeaponActions
actions
Definition human.c:796
WeaponEvents
events
Definition human.c:943
string WeaponActionTypeToString(int A, int AT)
Definition human.c:923

References Class::CastTo(), GetDayZPlayerOwner(), HandAnimEventFactory(), hndDebugPrint(), hndDebugSpamALot(), LogManager::IsInventoryHFSMLogEnable(), SyncHandEventToRemote(), and WeaponActionTypeToString().

◆ HandleInventoryManipulation()

override void HandleInventoryManipulation ( )
protected

Definition at line 2085 of file DayZPlayerInventory.c.

2086 {
2087 super.HandleInventoryManipulation();
2089 {
2094
2096 }
2097 }
void HandleHandEvent(DeferredEvent deferred_event)
void HandleTakeToDst(DeferredEvent deferred_event)
void HandleSwapEntities(DeferredEvent deferred_event)
void HandleForceSwapEntities(DeferredEvent deferred_event)
proto static native bool CanStoreInputUserData()

References ScriptInputUserData::CanStoreInputUserData(), HandleForceSwapEntities(), HandleHandEvent(), HandleSwapEntities(), HandleTakeToDst(), and m_DeferredEvent.

◆ HandleSwapEntities()

void HandleSwapEntities ( DeferredEvent deferred_event)
protected

Definition at line 1611 of file DayZPlayerInventory.c.

1612 {
1615 {
1616 deferred_swap_entities.ClearInventoryReservation(this);
1619 {
1622
1623 switch (deferred_swap_entities.m_mode)
1624 {
1625 case InventoryMode.PREDICTIVE:
1626 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst2.GetItem()))
1627 {
1629 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1630 }
1631 else
1632 {
1633#ifdef DEVELOPER
1635 Debug.InventoryMoveLog("Can not swap (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1636#endif
1637 }
1638 break;
1639
1640 case InventoryMode.JUNCTURE:
1641 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst2.GetItem()))
1642 {
1643 DayZPlayer player = GetGame().GetPlayer();
1644 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1645 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1649 }
1650 else
1651 {
1652#ifdef DEVELOPER
1654 Debug.InventoryMoveLog("Can not swap (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1655#endif
1656 }
1657 break;
1658
1659 case InventoryMode.LOCAL:
1660 break;
1661
1662 default:
1663 Error("SwapEntities - HandEvent - Invalid mode");
1664 }
1665 }
1666 else
1667 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1668 }
1669 }
static bool MakeSrcAndDstForSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
Definition Inventory.c:1166

References GameInventory::c_InventoryReservationTimeoutShortMS, InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), inventoryDebugPrint(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), GameInventory::MakeSrcAndDstForSwap(), InventoryInputUserData::SendInputUserDataSwap(), and ToString().

Referenced by HandleInventoryManipulation().

◆ HandleTakeToDst()

void HandleTakeToDst ( DeferredEvent deferred_event)
protected

Definition at line 1501 of file DayZPlayerInventory.c.

1502 {
1505 {
1506#ifdef DEVELOPER
1508 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1509#endif
1510
1511 deferred_take_to_dst.ClearInventoryReservation(this);
1512
1515
1516 switch (deferred_take_to_dst.m_mode)
1517 {
1518 case InventoryMode.PREDICTIVE:
1519#ifdef DEVELOPER
1521 Debug.InventoryHFSMLog("PREDICTIVE ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1522#endif
1523
1524 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
1525 {
1527 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1528 }
1529 else
1530 {
1531#ifdef DEVELOPER
1533 Debug.InventoryMoveLog("Can not move entity (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item = " + deferred_take_to_dst.m_dst.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_take_to_dst.m_dst), "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1534#endif
1535 }
1536 break;
1537 case InventoryMode.JUNCTURE:
1538#ifdef DEVELOPER
1540 Debug.InventoryHFSMLog("JUNCTURE ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1541#endif
1542
1543 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
1544 {
1545 DayZPlayer player = GetGame().GetPlayer();
1546 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1549 }
1550 else
1551 {
1552#ifdef DEVELOPER
1554 Debug.InventoryMoveLog("Can not move entity (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item = " + deferred_take_to_dst.m_dst.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_take_to_dst.m_dst), "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1555#endif
1556 }
1557 break;
1558 case InventoryMode.LOCAL:
1559#ifdef DEVELOPER
1561 Debug.InventoryHFSMLog("LOCAL ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1562#endif
1563 break;
1564 case InventoryMode.SERVER:
1565#ifdef DEVELOPER
1567 Debug.InventoryHFSMLog("SERVER ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1568#endif
1569 break;
1570 default:
1571 Error("HandEvent - Invalid mode");
1572 break;
1573 }
1574 }
1575 }
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)

References GameInventory::c_InventoryReservationTimeoutShortMS, DeferredTakeToDst(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), inventoryDebugPrint(), Debug::InventoryHFSMLog(), Debug::InventoryMoveLog(), LogManager::IsInventoryHFSMLogEnable(), LogManager::IsInventoryMoveLogEnable(), InventoryInputUserData::SendInputUserDataMove(), and ToString().

Referenced by HandleInventoryManipulation().

◆ HandleWeaponEvents()

void HandleWeaponEvents ( float dt,
out bool exitIronSights )
protected

Definition at line 313 of file DayZPlayerInventory.c.

314 {
315 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
316
318 Class.CastTo(weapon, GetEntityInHands());
319
320 if (hcw && weapon && weapon.CanProcessWeaponEvents())
321 {
322 weapon.GetCurrentState().OnUpdate(dt);
323
325 wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
326
327 if (!weapon.IsIdle())
328 {
329 while (true)
330 {
331 int weaponEventId = hcw.IsEvent();
332 if (weaponEventId == -1)
333 break;
334
335 if (weaponEventId == WeaponEvents.CHANGE_HIDE)
336 break;
337
339
341 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
342
343 if (anim_event != NULL)
344 weapon.ProcessWeaponEvent(anim_event);
345 }
346
347 if (hcw.IsActionFinished())
348 {
349 if (weapon.IsWaitingForActionFinish())
350 {
352 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
353
354 weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
355 }
356 else
357 {
359 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
360
361 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
362 }
363 }
364 }
365
367 {
369 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
370
371 if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
372 {
373 exitIronSights = true;
374
376 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
377
380 }
381 else if (!m_DeferredWeaponTimer.IsRunning())
382 m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
383 }
384 }
385 }
void wpnDebugSpamALot(string s)
Definition Debug.c:25
WeaponEventBase WeaponAnimEventFactory(WeaponEvents type, DayZPlayer p=NULL, Magazine m=NULL)
creates animation system events
Definition Events.c:251
void fsmDebugSpam(string s)
Definition HFSMBase.c:9
signalize mechanism manipulation
Definition Events.c:35

References Class::CastTo(), fsmDebugSpam(), GetDayZPlayerOwner(), LogManager::IsWeaponLogEnable(), m_DeferredWeaponEvent, m_DeferredWeaponTimer, WeaponActionTypeToString(), WeaponAnimEventFactory(), wpnDebugPrint(), and wpnDebugSpamALot().

◆ Init()

override void Init ( )
protected

Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside of a non-static system)

pre-init arrays

Definition at line 178 of file DayZPlayerInventory.c.

179 {
181 hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
182
183 CreateStableStates(); // stable states needs to be created first
184
185 m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
186 m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
187 m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
188 m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
189 m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
190
191 // events
192 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
193 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
194 HandEventBase __T__ = new HandEventTake;
195 HandEventBase __M__ = new HandEventMoveTo;
197 //HandEventBase __D__ = new HandEventDropping;
198 HandEventBase __Xd_ = new HandEventDestroyed;
199 HandEventBase __F__ = new HandEventForceSwap;
200
201 // setup transitions
202 m_FSM.AddTransition(new HandTransition(m_Empty, __T__, m_Taking, NULL, new HandSelectAnimationOfTakeToHandsEvent(GetManOwner())));
203 m_FSM.AddTransition(new HandTransition(m_Taking, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
204 m_FSM.AddTransition(new HandTransition(m_Taking, _fin_, m_Equipped, null, null));
205 m_FSM.AddTransition(new HandTransition(m_Taking, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
206 m_Taking.AddTransition(new HandTransition(m_Taking.m_Hide, _abt_, m_Empty));
207 m_Taking.AddTransition(new HandTransition(m_Taking.m_Show, _abt_, m_Equipped));
208
209 m_FSM.AddTransition(new HandTransition(m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
210 m_FSM.AddTransition(new HandTransition(m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
211 m_FSM.AddTransition(new HandTransition(m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
212 m_FSM.AddTransition(new HandTransition(m_MovingTo, _fin_, m_Empty, null, null));
213 m_MovingTo.AddTransition(new HandTransition(m_MovingTo.m_Hide, _abt_, m_Equipped));
214 m_MovingTo.AddTransition(new HandTransition(m_MovingTo.m_Show, _abt_, m_Empty));
215
216 m_FSM.AddTransition(new HandTransition(m_Equipped, __W__, m_Swapping, NULL, new HandSelectAnimationOfSwapInHandsEvent(GetManOwner())));
217 m_FSM.AddTransition(new HandTransition(m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
218 m_FSM.AddTransition(new HandTransition(m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
219 m_FSM.AddTransition(new HandTransition(m_Swapping, _fin_, m_Equipped, null, null));
220 m_FSM.AddTransition(new HandTransition(m_Swapping, _abt_, m_Equipped, null, null));
221
222 m_FSM.AddTransition(new HandTransition(m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd(new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()))));
223 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
224 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
225 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
226 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _abt_, m_Equipped, null, null));
227
228 m_FSM.AddTransition(new HandTransition(m_Equipped, __F__, m_FSwapping, NULL, new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner())));
229 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
230 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
231 m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
232 m_FSwapping.AddTransition(new HandTransition(m_FSwapping.m_Start, _abt_, m_Equipped));
233 m_FSwapping.AddTransition(new HandTransition(m_FSwapping.m_Hide, _abt_, m_Empty));
234 m_FSwapping.AddTransition(new HandTransition(m_FSwapping.m_Show, _abt_, m_Equipped));
235
236 super.Init(); // initialize ordinary human fsm (no anims)
237 }
ref HandAnimatedForceSwapping m_FSwapping
ref HandAnimatedForceSwapping_Inst m_FSwappingInst
ref HandAnimatedSwapping m_Swapping
ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
ref HandAnimatedMovingToAtt m_MovingTo
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:27

References hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), m_FSwapping, m_FSwappingInst, m_MovingTo, m_Swapping, and m_Taking.

◆ IsAuthoritative()

bool IsAuthoritative ( )
protected

Definition at line 151 of file DayZPlayerInventory.c.

152 {
154 if (!Class.CastTo(player, GetInventoryOwner()))
155 return false;
156
157 return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
158 }
DayZPlayerInstanceType
defined in C++

References Class::CastTo().

◆ IsOwner()

bool IsOwner ( )
protected

Definition at line 160 of file DayZPlayerInventory.c.

161 {
163 if (!Class.CastTo(player, GetInventoryOwner()))
164 return false;
165
166 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
167 }

References Class::CastTo().

◆ IsProcessing()

bool IsProcessing ( )
protected

Definition at line 2100 of file DayZPlayerInventory.c.

2101 {
2102 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2103 }

References m_DeferredEvent, and m_DeferredPostedHandEvent.

Referenced by HandEvent(), DayZPlayer::HandleADS(), and ManBase::OnQuickBarSingleUse().

◆ IsProxy()

bool IsProxy ( )
protected

Definition at line 169 of file DayZPlayerInventory.c.

170 {
172 if (!Class.CastTo(player, GetInventoryOwner()))
173 return false;
174
175 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
176 }

References Class::CastTo().

◆ IsServerOrLocalPlayer()

bool IsServerOrLocalPlayer ( )
protected

Definition at line 1399 of file DayZPlayerInventory.c.

1400 {
1401 return GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || GetDayZPlayerOwner() == GetGame().GetPlayer());
1402 }

References GetDayZPlayerOwner(), and GetGame().

◆ NetSyncCurrentStateID()

override void NetSyncCurrentStateID ( int id)
protected

Definition at line 1819 of file DayZPlayerInventory.c.

1820 {
1821 super.NetSyncCurrentStateID(id);
1822
1823 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
1824 }
override void OnItemInHandsChanged()

References GetDayZPlayerOwner(), and DayZPlayer::OnItemInHandsChanged().

◆ OnAfterStoreLoad()

OnAfterStoreLoad ( )
protected

engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase.OnAfterStoreLoad

Definition at line 1832 of file DayZPlayerInventory.c.

1833 {
1834 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
1835 }

References GetDayZPlayerOwner(), and DayZPlayer::OnItemInHandsChanged().

◆ OnEventForRemoteWeapon()

bool OnEventForRemoteWeapon ( ParamsReadContext ctx)
protected

Definition at line 1840 of file DayZPlayerInventory.c.

1841 {
1842 if (GetEntityInHands())
1843 {
1844 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
1845 if (wpn)
1846 {
1848
1850 if (pb && e)
1851 {
1852 pb.GetWeaponManager().SetRunning(true);
1853
1855 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
1856
1857 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
1858 wpn.ProcessWeaponAbortEvent(e);
1859 else
1860 wpn.ProcessWeaponEvent(e);
1861 pb.GetWeaponManager().SetRunning(false);
1862 }
1863 }
1864 else
1865 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
1866 }
1867 else
1868 Error("OnEventForRemoteWeapon - no entity in hands");
1869 return true;
1870 }
WeaponEventBase CreateWeaponEventFromContext(ParamsReadContext ctx)
Definition Events.c:281
WeaponEventID
identifier for events. mainly for rpc purposes
Definition Events.c:6

References CreateWeaponEventFromContext(), Error(), fsmDebugSpam(), GetDayZPlayerOwner(), and LogManager::IsWeaponLogEnable().

◆ OnHandEventForRemote()

bool OnHandEventForRemote ( ParamsReadContext ctx)
protected

Definition at line 1876 of file DayZPlayerInventory.c.

1877 {
1878 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1879 if (e)
1880 {
1882 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
1883
1884 //m_FSM.ProcessEvent(e);
1885
1886 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
1887 {
1889 m_FSM.ProcessAbortEvent(e, aa);
1890 }
1891 else
1892 m_FSM.ProcessEvent(e);
1893
1894 return true;
1895 }
1896 return false;
1897 }
ProcessEventResult
Definition FSMBase.c:41
HandEventID
events
Definition Hand_Events.c:7
void hndDebugSpam(string s)
Definition HandFSM.c:9

References hndDebugSpam(), and LogManager::IsInventoryHFSMLogEnable().

◆ OnHandleStoredInputUserData()

void OnHandleStoredInputUserData ( ParamsReadContext ctx)
protected

Definition at line 634 of file DayZPlayerInventory.c.

635 {
636 int tmp = -1;
637 ctx.Read(tmp);
638
640 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
641
642 ProcessInputData(ctx, false, false);
643 }
void syncDebugPrint(string s)
Definition Debug.c:1
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
static bool IsSyncLogEnable()
Definition Debug.c:759

References GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData(), and syncDebugPrint().

◆ OnHandleStoredJunctureData()

void OnHandleStoredJunctureData ( ParamsReadContext ctx)
protected

Juncture is only ever Server Req->Client Ack and Perform->Server Perform, never remote

Definition at line 594 of file DayZPlayerInventory.c.

595 {
596 int tmp = -1;
597 ctx.Read(tmp);
598
600 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
601
603 ProcessInputData(ctx, true, false);
604 }

References GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData(), and syncDebugPrint().

◆ OnHandsEnteredStableState()

override void OnHandsEnteredStableState ( HandStateBase src,
HandStateBase dst )
protected

Definition at line 1924 of file DayZPlayerInventory.c.

1925 {
1926 super.OnHandsEnteredStableState(src, dst);
1927
1929 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
1930 }

References hndDebugPrint(), and LogManager::IsInventoryHFSMLogEnable().

Referenced by OnHandsStateChanged().

◆ OnHandsExitedStableState()

override void OnHandsExitedStableState ( HandStateBase src,
HandStateBase dst )
protected

Definition at line 1916 of file DayZPlayerInventory.c.

1917 {
1918 super.OnHandsExitedStableState(src, dst);
1919
1921 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
1922 }

References hndDebugPrint(), and LogManager::IsInventoryHFSMLogEnable().

Referenced by OnHandsStateChanged().

◆ OnHandsStateChanged()

override void OnHandsStateChanged ( HandStateBase src,
HandStateBase dst )
protected

Definition at line 1932 of file DayZPlayerInventory.c.

1933 {
1934 super.OnHandsStateChanged(src, dst);
1935
1937 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
1938
1939 if (src.IsIdle())
1941
1942 if (dst.IsIdle())
1944
1945#ifdef BOT
1947 if (p && p.m_Bot)
1948 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
1949#endif
1950 }
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)

References GetDayZPlayerOwner(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), OnHandsEnteredStableState(), and OnHandsExitedStableState().

◆ OnInputUserDataForRemote()

void OnInputUserDataForRemote ( ParamsReadContext ctx)
protected

Definition at line 651 of file DayZPlayerInventory.c.

652 {
654 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
655
656 ProcessInputData(ctx, false, true);
657 }

References GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData(), and syncDebugPrint().

◆ OnInputUserDataProcess()

override bool OnInputUserDataProcess ( ParamsReadContext ctx)
protected

Definition at line 621 of file DayZPlayerInventory.c.

622 {
624 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
625
627 return true;
628 }
proto native void StoreInputUserData(ParamsReadContext ctx)

References GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), StoreInputUserData(), and syncDebugPrint().

◆ OnInventoryFailure()

override void OnInventoryFailure ( InventoryCommandType type,
InventoryValidationReason reason,
InventoryLocation src,
InventoryLocation dst )
protected

TODO(kumarjac): Notify player here

Definition at line 580 of file DayZPlayerInventory.c.

581 {
582 if (reason == InventoryValidationReason.DROP_PREVENTED)
583 {
585 return;
586 }
587
588 }
InventoryValidationReason
Definition Inventory.c:37

Referenced by HandEvent(), and OnInventoryJunctureFailureFromServer().

◆ OnInventoryJunctureFailureFromServer()

override void OnInventoryJunctureFailureFromServer ( ParamsReadContext ctx)
protected

Function and setup is still messy due to the switch statement and relation with reading.

It could be cleaner if we used classes to handle each inventory command type, but that comes at a performance cost and will also probably require making a fair amount of changes elsewhere.

The downsides with this system right now:

  1. It makes it hard to track what is written/read from the serializer
  2. It makes this file very very large

The new changes at least remove the massive switch block and allow for all inventory commands to respond back to the client if something goes wrong

Definition at line 509 of file DayZPlayerInventory.c.

510 {
524 if (GetGame().IsDedicatedServer())
525 return;
526
527 int udtIdentifier = -1;
529 return;
530
534
535 InventoryCommandType type = -1;
536 if (!ctx.Read(type))
537 return;
538
539 switch (type)
540 {
541 case InventoryCommandType.SYNC_MOVE:
542 {
543 src.ReadFromContext(ctx);
544 dst.ReadFromContext(ctx);
545 break;
546 }
547 case InventoryCommandType.HAND_EVENT:
548 {
549 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
550 src = e.GetSrc();
551 dst = e.GetDst();
552 break;
553 }
554 case InventoryCommandType.SWAP:
555 {
556 src.ReadFromContext(ctx);
557 temp.ReadFromContext(ctx);
558 dst.ReadFromContext(ctx);
559 temp.ReadFromContext(ctx);
560 break;
561 }
562 case InventoryCommandType.FORCESWAP:
563 {
564 break;
565 }
566 case InventoryCommandType.DESTROY:
567 {
568 src.ReadFromContext(ctx);
569 break;
570 }
571 }
572
574 if (!ctx.Read(reason))
576
578 }
const int INPUT_UDT_INVENTORY
Definition _constants.c:9

References GetGame(), INPUT_UDT_INVENTORY, and OnInventoryFailure().

◆ OnInventoryJunctureFromServer()

override bool OnInventoryJunctureFromServer ( ParamsReadContext ctx)
protected

Definition at line 464 of file DayZPlayerInventory.c.

465 {
466 int tmp = -1;
467 ctx.Read(tmp);
468
470 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store Juncture packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
471
473
474 return true;
475 }
proto native void StoreJunctureData(ParamsReadContext ctx)

References GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), StoreJunctureData(), and syncDebugPrint().

◆ OnInventoryJunctureRepairFromServer()

override bool OnInventoryJunctureRepairFromServer ( ParamsReadContext ctx)
protected

Definition at line 484 of file DayZPlayerInventory.c.

485 {
486 /* InventoryLocation il = new InventoryLocation;
487 if (!il.ReadFromContext(ctx) )
488 return false;
489
490 InventoryLocation il_current = new InventoryLocation;
491
492 EntityAI item = il.GetItem();
493 item.GetInventory().GetCurrentInventoryLocation(il_current);
494
495 if( !il_current.CompareLocationOnly(il))
496 {
497 LocationMoveEntity(il_current,il);
498 }*/
499 return true;
500 }

◆ OnServerInventoryCommand()

override void OnServerInventoryCommand ( ParamsReadContext ctx)
protected

Definition at line 659 of file DayZPlayerInventory.c.

660 {
662 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
663
664 ProcessInputData(ctx, true, true);
665 }

References GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData(), and syncDebugPrint().

◆ PlayerCheckDropRequest()

bool PlayerCheckDropRequest ( notnull InventoryLocation src,
float radius )
protected

Definition at line 2206 of file DayZPlayerInventory.c.

2207 {
2208 bool result = true;
2209
2210 EntityAI ent = src.GetParent();
2211 if (ent)
2212 {
2213 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2214 if (player)
2215 {
2216 if (GetDayZPlayerOwner() != player)
2217 {
2218 if (player.IsAlive())
2219 {
2220 if (!player.IsRestrained() && !player.IsUnconscious())
2221 return false;
2222 }
2223 }
2224 }
2225 }
2226
2227 if (result)
2228 result = CheckDropRequest(GetManOwner(), src, radius);
2229
2230 return result;
2231 }

References GetDayZPlayerOwner().

Referenced by ValidateDestroy().

◆ PlayerCheckRequestDst()

bool PlayerCheckRequestDst ( notnull InventoryLocation src,
notnull InventoryLocation dst,
float radius )
protected

Definition at line 2132 of file DayZPlayerInventory.c.

2133 {
2134 bool result = true;
2135
2136 EntityAI ent = dst.GetParent();
2137 if (ent)
2138 {
2139 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2140 if (player)
2141 {
2142 if (GetDayZPlayerOwner() != player)
2143 {
2144 if (player.IsAlive())
2145 {
2146 if (!player.IsRestrained() && !player.IsUnconscious())
2147 return false;
2148 }
2149 }
2150 }
2151 }
2152
2153 if (result)
2154 result = CheckMoveToDstRequest(GetManOwner(), src, dst, radius);
2155
2156 return result;
2157 }

References GetDayZPlayerOwner().

Referenced by ValidateSyncMove().

◆ PlayerCheckRequestSrc()

bool PlayerCheckRequestSrc ( notnull InventoryLocation src,
float radius )
protected

Definition at line 2105 of file DayZPlayerInventory.c.

2106 {
2107 bool result = true;
2108
2109 EntityAI ent = src.GetParent();
2110 if (ent)
2111 {
2112 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2113 if (player)
2114 {
2115 if (GetDayZPlayerOwner() != player)
2116 {
2117 if (player.IsAlive())
2118 {
2119 if (!player.IsRestrained() && !player.IsUnconscious())
2120 return false;
2121 }
2122 }
2123 }
2124 }
2125
2126 if (result)
2127 result = CheckRequestSrc(GetManOwner(), src, radius);
2128
2129 return result;
2130 }
bool CheckRequestSrc()

References CheckRequestSrc(), and GetDayZPlayerOwner().

Referenced by ValidateDestroy(), ValidateSwap(), and ValidateSyncMove().

◆ PlayerCheckSwapItemsRequest()

bool PlayerCheckSwapItemsRequest ( notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2,
float radius )
protected

Definition at line 2159 of file DayZPlayerInventory.c.

2160 {
2161 bool result = true;
2162
2163 EntityAI ent = dst1.GetParent();
2165 if (ent)
2166 {
2167 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2168 if (player)
2169 {
2170 if (GetDayZPlayerOwner() != player)
2171 {
2172 if (player.IsAlive())
2173 {
2174 if (!player.IsRestrained() && !player.IsUnconscious())
2175 return false;
2176 }
2177 }
2178 }
2179 }
2180
2181 ent = dst2.GetParent();
2182 if (ent)
2183 {
2184 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2185 if (player)
2186 {
2187 if (GetDayZPlayerOwner() != player)
2188 {
2189 if (player.IsAlive())
2190 {
2191 if (!player.IsRestrained() && !player.IsUnconscious())
2192 return false;
2193 }
2194 }
2195 }
2196 }
2197
2198
2199 if (result)
2200 result = CheckSwapItemsRequest(GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2201
2202 return result;
2203
2204 }
const float c_MaxItemDistanceRadius
anti-cheats
Definition Inventory.c:788

References GameInventory::c_MaxItemDistanceRadius, and GetDayZPlayerOwner().

Referenced by ValidateSwap().

◆ PostWeaponEvent()

void PostWeaponEvent ( WeaponEventBase e)
protected

Definition at line 275 of file DayZPlayerInventory.c.

276 {
278 {
280
282 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
283 }
284 else
285 Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
286 }

References Error(), LogManager::IsWeaponLogEnable(), m_DeferredWeaponEvent, and wpnDebugPrint().

◆ ProcessInputData()

bool ProcessInputData ( ParamsReadContext ctx,
bool isJuncture,
bool isRemote )
protected
Returns
false on malformed data, true on anything else, including cheats

It should be impossible for juncture to be ran on remote

Serializer can be updated and re-written to when we may want to only correct the client instead of denying the inventory command

Only inform client about failure

General purpose serializer change from read to write here if the validation doesn't update it

Only send juncture back to client

Definition at line 1295 of file DayZPlayerInventory.c.

1296 {
1297 if (isJuncture && isRemote)
1298 {
1300 return false;
1301 }
1302
1303 int type = -1;
1304 if (!ctx.Read(type))
1305 return false;
1306
1308 validation.m_IsJuncture = isJuncture;
1309 validation.m_IsRemote = isRemote;
1310
1313
1314 switch (type)
1315 {
1316 case InventoryCommandType.USER_RESERVATION_CANCEL:
1317 if (!ValidateUserReservationCancel(serializer, validation))
1318 return false;
1319 break;
1320 case InventoryCommandType.SYNC_MOVE:
1322 return false;
1323 break;
1324 case InventoryCommandType.HAND_EVENT:
1326 return false;
1327 break;
1328 case InventoryCommandType.SWAP:
1330 return false;
1331 break;
1332 case InventoryCommandType.DESTROY:
1334 return false;
1335 break;
1336 default:
1337 break;
1338 }
1339
1340 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1341
1342 switch (validation.m_Result)
1343 {
1344 case InventoryValidationResult.FAILED:
1345 if (canSendJuncture)
1346 {
1348 if (!serializer.CanWrite())
1349 {
1353 }
1354
1355 serializer.Write(validation.m_Reason);
1356
1358 }
1359 break;
1360 case InventoryValidationResult.JUNCTURE:
1361 if (canSendJuncture)
1362 {
1364 //StoreInputForRemotes(isJuncture, isRemote, serializer);
1365 }
1366 else
1367 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1368 break;
1369 case InventoryValidationResult.SUCCESS:
1371 break;
1372 }
1373
1374 return true;
1375 }
InventoryValidationResult
Definition Inventory.c:30
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
bool StoreInputForRemotes(bool handling_juncture, bool remote, ParamsReadContext ctx)
Serialization general interface. Serializer API works with:
Definition Serializer.c:56

References Error(), GetDayZPlayerOwner(), DayZPlayerSyncJunctures::SJ_INVENTORY, DayZPlayerSyncJunctures::SJ_INVENTORY_FAILURE, StoreInputForRemotes(), ValidateDestroy(), ValidateHandEvent(), ValidateSwap(), and ValidateSyncMove().

Referenced by OnHandleStoredInputUserData(), OnHandleStoredJunctureData(), OnInputUserDataForRemote(), and OnServerInventoryCommand().

◆ RemoveMovableOverride()

void RemoveMovableOverride ( EntityAI item)
protected

Definition at line 1377 of file DayZPlayerInventory.c.

1378 {
1379 ItemBase itemIB = ItemBase.Cast(item);
1380 if (itemIB)
1381 itemIB.SetCanBeMovedOverride(false);
1382 }

Referenced by ValidateHandEvent(), ValidateSwap(), and ValidateSyncMove().

◆ ReserveInventory()

override bool ReserveInventory ( HumanInventory inventory)

Definition at line 22 of file DayZPlayerInventory.c.

23 {
24 if (!inventory.AddInventoryReservationEx(m_dst.GetItem(), m_dst, GameInventory.c_InventoryReservationTimeoutShortMS))
25 return false;
26 return true;
27 }

References GameInventory::c_InventoryReservationTimeoutShortMS, and m_dst.

◆ SendServerHandEventViaJuncture()

static void SendServerHandEventViaJuncture ( notnull DayZPlayer player,
HandEventBase e )
staticprotected

Remote inputs are processed in sync juncture once performed on the server - this code below was executing the inventory command before the player simulation timeestamp for remotes which is illegal

Definition at line 1767 of file DayZPlayerInventory.c.

1768 {
1769 if (GetGame().IsServer())
1770 {
1771 if (e.IsServerSideOnly())
1772 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
1773
1774 if (player.IsAlive())
1775 {
1776 InventoryLocation dst = e.GetDst();
1777 InventoryLocation src = e.GetSrc();
1778 if (src.IsValid() && dst.IsValid())
1779 {
1780 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1781 {
1783 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1784
1785 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1786 {
1788 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
1789 }
1790 else
1791 {
1793 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
1794 }
1795 }
1796
1798 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + " server hand event src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1799
1803
1805 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " store input for remote - SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + " server hand event src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1806
1808 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1809 }
1810 }
1811 else
1812 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
1813 }
1814 }
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687

References GameInventory::c_InventoryReservationTimeoutMS, InventoryLocation::DumpToStringNullSafe(), Error(), GetGame(), LogManager::IsSyncLogEnable(), InventoryInputUserData::SerializeHandEvent(), DayZPlayerSyncJunctures::SJ_INVENTORY, and syncDebugPrint().

Referenced by HandleHandEvent().

◆ StoreInputForRemotes()

bool StoreInputForRemotes ( bool handling_juncture,
bool remote,
ParamsReadContext ctx )
protected

Definition at line 1404 of file DayZPlayerInventory.c.

1405 {
1406 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1407 {
1408#ifdef DEVELOPER
1410 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a", "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString());
1411#endif
1412
1413 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1414 return true;
1415 }
1416
1417 return false;
1418 }
proto native DayZPlayerInstanceType GetInstanceType()

References GetDayZPlayerOwner(), GetInstanceType(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), and ToString().

◆ StoreInputUserData()

proto native void StoreInputUserData ( ParamsReadContext ctx)
protected

Referenced by OnInputUserDataProcess().

◆ StoreJunctureData()

proto native void StoreJunctureData ( ParamsReadContext ctx)
protected

◆ SwapEntities()

override bool SwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2 )
protected

Definition at line 1577 of file DayZPlayerInventory.c.

1578 {
1579#ifdef DEVELOPER
1581 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a", "n/a", "SwapEntities", GetDayZPlayerOwner().ToString());
1582#endif
1583
1585 if (mode == InventoryMode.LOCAL)
1586 {
1588 {
1589 LocationSwap(src1, src2, dst1, dst2);
1590 return true;
1591 }
1592 }
1593
1594 if (!super.SwapEntities(mode, item1, item2))
1595 {
1596 if (!m_DeferredEvent)
1597 {
1599 {
1601 if (m_DeferredEvent.ReserveInventory(this))
1602 return true;
1603 }
1604 }
1606 return false;
1607 }
1608 return true;
1609 }

References GetDayZPlayerOwner(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), m_DeferredEvent, GameInventory::MakeSrcAndDstForSwap(), and ToString().

◆ SyncHandEventToRemote()

void SyncHandEventToRemote ( HandEventBase e)
protected

Definition at line 1899 of file DayZPlayerInventory.c.

1900 {
1902 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1903 {
1905
1907 e.WriteToContext(ctx);
1908
1910 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
1911
1912 p.StoreInputForRemotes(ctx);
1913 }
1914 }
const int INPUT_UDT_HAND_REMOTE_EVENT
Definition _constants.c:14

References GetDayZPlayerOwner(), hndDebugPrint(), INPUT_UDT_HAND_REMOTE_EVENT, and LogManager::IsInventoryHFSMLogEnable().

Referenced by HandleInventory().

◆ TakeToDst()

Remote inputs are processed in sync juncture once performed on the server - this code below was executing the inventory command before the player simulation timeestamp for remotes which is illegal

Definition at line 1420 of file DayZPlayerInventory.c.

1421 {
1422 if (GetManOwner().IsAlive() == false)
1423 return super.TakeToDst(mode, src, dst);
1424
1425#ifdef DEVELOPER
1427 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1428#endif
1429
1430 switch (mode)
1431 {
1432 case InventoryMode.SERVER:
1433 if (RedirectToHandEvent(mode, src, dst))
1434 {
1435#ifdef DEVELOPER
1437 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1438#endif
1439
1440 return true;
1441 }
1442
1443
1444 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1445 {
1446 if (GetGame().AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1447 {
1449 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1450 }
1451 else
1452 {
1453#ifdef DEVELOPER
1455 Debug.InventoryMoveLog("Juncture failed", "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1456#endif
1457
1459 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1460
1461 return false;
1462 }
1463
1464 }
1465
1468
1470
1472 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " store input for remote - DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + " server sync move src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1473
1475 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1476#ifdef DEVELOPER
1478 Debug.InventoryMoveLog("Success - store input for remote mode - " + typename.EnumToString(InventoryMode, mode) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1479#endif
1480 return true;
1481
1482 case InventoryMode.LOCAL:
1483 LocationSyncMoveEntity(src, dst);
1484 return true;
1485 }
1486 if (!super.TakeToDst(mode, src, dst))
1487 {
1488 if (!m_DeferredEvent)
1489 {
1491 if (m_DeferredEvent.ReserveInventory(this))
1492 return true;
1493 }
1494
1496 return false;
1497 }
1498 return true;
1499 }
static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
move

References GameInventory::c_InventoryReservationTimeoutMS, DeferredTakeToDst(), InventoryLocation::DumpToStringNullSafe(), GetDayZPlayerOwner(), GetGame(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), m_DeferredEvent, InventoryInputUserData::SerializeMove(), DayZPlayerSyncJunctures::SJ_INVENTORY, syncDebugPrint(), and ToString().

Referenced by EntityAI::PredictiveMoveItemFromHandsToInventory().

◆ ValidateDestroy()

bool ValidateDestroy ( inout Serializer ctx,
InventoryValidation validation )
protected

TODO(kumarjac): Probably should be called through inventory juncture, we shouldn't allow the client to delete until the server says it is okay as there can be more reasons than "cheater" for it to be rejected such as desync

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Definition at line 1219 of file DayZPlayerInventory.c.

1220 {
1222
1223 if (validation.m_IsJuncture)
1224 {
1232 return true;
1233 }
1234
1236 src.ReadFromContext(ctx);
1237
1238#ifdef DEVELOPER
1240 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1241#endif
1242
1243 if (validation.m_IsRemote && !src.GetItem())
1244 {
1245#ifdef DEVELOPER
1247 Debug.InventoryMoveLog("Failed item not exist", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1248#endif
1249
1250 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
1251 return true;
1252 }
1253
1258 {
1259#ifdef DEVELOPER
1261 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1262#endif
1263
1264 return true;
1265 }
1266
1271 {
1272#ifdef DEVELOPER
1274 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1275#endif
1276
1277 return true;
1278 }
1279
1280#ifdef DEVELOPER
1282 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1283#endif
1284
1285 GetGame().ObjectDelete(src.GetItem());
1286
1287 validation.m_Result = InventoryValidationResult.SUCCESS;
1288 return true;
1289 }
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)

References GameInventory::c_MaxItemDistanceRadius, InventoryLocation::DumpToStringNullSafe(), Error(), GetDayZPlayerOwner(), GetGame(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), PlayerCheckDropRequest(), PlayerCheckRequestSrc(), and ToString().

Referenced by ProcessInputData().

◆ ValidateHandEvent()

bool ValidateHandEvent ( inout Serializer ctx,
InventoryValidation validation )
protected

Pass partial information to guards so guards can do minimal checks if needed The guards can't prevent event so it would be incorrect to pass full InventoryValidation struct. We have to make sure guards don't inadvertantly produce different results in the FSM as that will create desync (two players attempting to put a rag into the same fireplace slot at the same time)

kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote

TODO(kumarjac): Is this one correct to be 'RemoveMovableOverride' or are the other Validate methdos wrong with 'EnableMovableOverride'?

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

'HandEventBase.CheckRequestEx' updates failure reason

if it already happened on server, remote just needs to comply TODO(kumarjac): Move m_IsRemote check to inside of HandEventBase.CanPerformEventEx

'HandEventBase.CanPerformEventEx' updates failure reason

Check if this this is being executed on the server and not by a juncture or AI

Continuing on with execution of rest of the function

Is called twice unfortunately... but it works so won't change

TODO(kumarjac): We should probably set the result to failure like so

Definition at line 833 of file DayZPlayerInventory.c.

834 {
836
837 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
838 e.ClearInventoryReservation();
839
843 e.m_IsRemote = validation.m_IsRemote;
844 e.m_IsJuncture = validation.m_IsJuncture;
845
846 EntityAI itemSrc = e.GetSrcEntity();
847 EntityAI itemDst = e.GetSecondSrcEntity();
848
849#ifdef DEVELOPER
851 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
852#endif
853
854 if (validation.m_IsRemote && !e.GetSrcEntity())
855 {
857
858#ifdef DEVELOPER
860 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
861#endif
862
863 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
864
865 return true;
866 }
867
869 if (itemSrc)
871 if (itemDst)
873
877 if (!validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
878 {
879#ifdef DEVELOPER
881 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
882#endif
883
884 if (!validation.m_IsRemote)
885 {
888 }
889
892
893 return true;
894 }
895
896 if (!e.CheckRequestEx(validation))
897 {
898#ifdef DEVELOPER
900 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
901#endif
902
904
907
909 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
910
913 return true;
914 }
915
918 if (!validation.m_IsRemote && !e.CanPerformEventEx(validation))
919 {
920#ifdef DEVELOPER
922 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
923#endif
924
926
929
931 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
932
935 return true;
936 }
937
940
942 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
943 {
944 JunctureRequestResult result_ev = e.AcquireInventoryJunctureFromServer(GetDayZPlayerOwner());
945 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
946 {
947#ifdef DEVELOPER
949 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
950#endif
951
953 }
954 else if (result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
955 {
956#ifdef DEVELOPER
958 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
959#endif
960
963
964 validation.m_Result = InventoryValidationResult.JUNCTURE;
965
966 if (itemSrc)
968 if (itemDst)
970 return true;
971 }
972 else if (result_ev == JunctureRequestResult.JUNCTURE_DENIED)
973 {
974#ifdef DEVELOPER
976 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
977#endif
978
979 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
980 return true;
981 }
982 else
983 {
984 Error("[syncinv] HandleInputData: unexpected return code from AcquireInventoryJunctureFromServer");
985
986 return true;
987 }
988 }
989
991 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
992 CheckForRope(e.GetSrc(), e.GetDst());
993
994#ifdef DEVELOPER
996 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
997#endif
998
999 validation.m_Result = InventoryValidationResult.SUCCESS;
1000 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1001 {
1003 //result = InventoryValidationResult.FAILURE;
1004 }
1005
1006 return true;
1007 }
void CheckForRope(InventoryLocation src, InventoryLocation dst)
void RemoveMovableOverride(EntityAI item)
JunctureRequestResult
Definition Hand_Events.c:28

References CheckForRope(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetInstanceType(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), RemoveMovableOverride(), InventoryInputUserData::SerializeHandEvent(), and syncDebugPrint().

Referenced by ProcessInputData().

◆ ValidateSwap()

bool ValidateSwap ( inout Serializer ctx,
InventoryValidation validation )
protected

kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Check if this this is being executed on the server and not by a juncture or AI

Continuing on with execution of rest of the function

Definition at line 1009 of file DayZPlayerInventory.c.

1010 {
1012
1015
1018
1019 bool skippedSwap = false;
1020
1021 src1.ReadFromContext(ctx);
1022 src2.ReadFromContext(ctx);
1023 dst1.ReadFromContext(ctx);
1024 dst2.ReadFromContext(ctx);
1025 ctx.Read(skippedSwap);
1026
1027#ifdef DEVELOPER
1029 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2), "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1030#endif
1031
1032 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1033 {
1034 if (skippedSwap)
1035 {
1036#ifdef DEVELOPER
1038 Debug.InventoryMoveLog("Remote - skipped", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1039#endif
1040 /*
1041 if (LogManager.IsSyncLogEnable())
1042 {
1043 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1044 }
1045 */
1046 }
1047 else
1048 {
1050
1051#ifdef DEVELOPER
1053 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1054#endif
1055
1056 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1057 }
1058
1059 return true;
1060 }
1061
1062 EnableMovableOverride(src1.GetItem());
1063 EnableMovableOverride(src2.GetItem());
1064
1069 {
1070#ifdef DEVELOPER
1072 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1073#endif
1074
1076 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1077
1078 RemoveMovableOverride(src1.GetItem());
1079 RemoveMovableOverride(src2.GetItem());
1080 return true;
1081 }
1082
1087 {
1088#ifdef DEVELOPER
1090 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1091#endif
1092
1094 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1095
1096 RemoveMovableOverride(src1.GetItem());
1097 RemoveMovableOverride(src2.GetItem());
1098 return true;
1099 }
1100
1105 {
1106#ifdef DEVELOPER
1108 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1109#endif
1110
1112 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1113
1114 RemoveMovableOverride(src1.GetItem());
1115 RemoveMovableOverride(src2.GetItem());
1116 return true;
1117 }
1118
1119 RemoveMovableOverride(src1.GetItem());
1120 RemoveMovableOverride(src2.GetItem());
1121
1122 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1123 {
1126 }
1127
1131 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1132 {
1133#ifdef DEVELOPER
1135
1137 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1138#endif
1139
1140 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT swap cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " | src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1141 return true;
1142 }
1143
1144 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1145 {
1146 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1147 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1148 }
1149
1150 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1151 {
1152 Error("HandleInputData: cmd=" + typename.EnumToString(InventoryCommandType, type) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1153 return true;
1154 }
1155
1157 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1158 {
1160 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1161 {
1162#ifdef DEVELOPER
1164 Debug.InventoryMoveLog("Juncture not required", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1165#endif
1166
1168 }
1169 else if (result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1170 {
1171#ifdef DEVELOPER
1173 Debug.InventoryMoveLog("Juncture sended", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1174#endif
1175
1176 validation.m_Result = InventoryValidationResult.JUNCTURE;
1177 EnableMovableOverride(src1.GetItem());
1178 EnableMovableOverride(src2.GetItem());
1179 return true;
1180 }
1181 else if (result_sw == JunctureRequestResult.JUNCTURE_DENIED)
1182 {
1183#ifdef DEVELOPER
1185 Debug.InventoryMoveLog("Juncture denied", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1186#endif
1187
1188 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1189 return true;
1190 }
1191 else
1192 {
1193 Error("[syncinv] HandleInputData: unexpected return code from TryAcquireTwoInventoryJuncturesFromServer"); return true;
1194
1195 return true;
1196 }
1197 }
1198
1199 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1200 {
1203 }
1204
1205#ifdef DEVELOPER
1207 Debug.InventoryMoveLog("Success - item swap", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1208#endif
1209
1210 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1211
1212 ctx = new ScriptInputUserData();
1214
1215 validation.m_Result = InventoryValidationResult.SUCCESS;
1216 return true;
1217 }
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition Junctures.c:27
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:645
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap

References GameInventory::c_InventoryReservationTimeoutShortMS, GameInventory::c_MaxItemDistanceRadius, GameInventory::CanForceSwapEntitiesEx(), ClearInventoryReservationEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetInstanceType(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), PlayerCheckRequestSrc(), PlayerCheckSwapItemsRequest(), RemoveMovableOverride(), InventoryInputUserData::SerializeSwap(), syncDebugPrint(), ToString(), and TryAcquireTwoInventoryJuncturesFromServer().

Referenced by ProcessInputData().

◆ ValidateSyncMove()

bool ValidateSyncMove ( inout Serializer ctx,
InventoryValidation validation )
protected

kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Check if this this is being executed on the server and not by a juncture or AI so we can lock the item and ensure replication relationships are setup

TODO(kumarjac): We should continue with the execution and not have this special block but making a change here now will require testing

Is called twice unfortunately...

Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync

Definition at line 667 of file DayZPlayerInventory.c.

668 {
670
673
674 src.ReadFromContext(ctx);
675 dst.ReadFromContext(ctx);
676
677#ifdef DEVELOPER
679 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
680#endif
681
682 if (validation.m_IsRemote && (!src.GetItem() || !dst.GetItem()))
683 {
685
686#ifdef DEVELOPER
688 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
689#endif
690
692 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
693
694 return true;
695 }
696
697 EnableMovableOverride(src.GetItem());
698
703 {
705
706#ifdef DEVELOPER
708 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
709#endif
710
712 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
713
714 RemoveMovableOverride(src.GetItem());
715 return true;
716 }
717
722 {
723#ifdef DEVELOPER
725 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
726#endif
727
729 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
730
731 RemoveMovableOverride(src.GetItem());
732 return true;
733 }
734
735 RemoveMovableOverride(src.GetItem());
736
738 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " HandleInputData t=" + GetGame().GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
739
741 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
742 {
744 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
745 {
746#ifdef DEVELOPER
748 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
749#endif
750
752
753 LocationSyncMoveEntity(src, dst);
754
755 validation.m_Result = InventoryValidationResult.SUCCESS;
756 return true;
757 }
758 else if (result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
759 {
760#ifdef DEVELOPER
762 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
763#endif
764
766 {
767#ifdef DEVELOPER
769
771 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
772#endif
773
774 return true;
775 }
776
777 validation.m_Result = InventoryValidationResult.JUNCTURE;
778 EnableMovableOverride(src.GetItem());
779 return true;
780 }
781 else if (result_mv == JunctureRequestResult.JUNCTURE_DENIED)
782 {
783#ifdef DEVELOPER
785 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
786#endif
787
788 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
789 return true;
790 }
791 else
792 {
793 Error("[syncinv] HandleInputData: unexpected return code from AcquireInventoryJunctureFromServer");
794
795 return true;
796 }
797 }
798
799 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
801
803 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
805
809 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
810 {
811#ifdef DEVELOPER
813
815 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
816#endif
817
818 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
819 return true;
820 }
821
822#ifdef DEVELOPER
824 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
825#endif
826
827 LocationSyncMoveEntity(src, dst);
828
829 validation.m_Result = InventoryValidationResult.SUCCESS;
830 return true;
831 }
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Junctures.c:2
float GetTime()
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Inventory.c:378
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...

References GameInventory::c_MaxItemDistanceRadius, CheckForRope(), ClearInventoryReservationEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), GetInstanceType(), GetTime(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), GameInventory::LocationCanMoveEntity(), GameInventory::LocationCanMoveEntitySyncCheck(), PlayerCheckRequestDst(), PlayerCheckRequestSrc(), RemoveMovableOverride(), syncDebugPrint(), ToString(), and TryAcquireInventoryJunctureFromServer().

Referenced by ProcessInputData().

Variable Documentation

◆ m_DeferredEvent

◆ m_DeferredPostedHandEvent

ref HandEventBase m_DeferredPostedHandEvent = NULL
protected

Definition at line 136 of file DayZPlayerInventory.c.

Referenced by CancelHandEvent(), and IsProcessing().

◆ m_DeferredWeaponEvent

ref WeaponEventBase m_DeferredWeaponEvent = NULL
protected

deferred hand event

Definition at line 137 of file DayZPlayerInventory.c.

Referenced by CancelWeaponEvent(), DeferredWeaponFailed(), HandleWeaponEvents(), and PostWeaponEvent().

◆ m_DeferredWeaponTimer

ref Timer m_DeferredWeaponTimer = new Timer

Definition at line 132 of file DayZPlayerInventory.c.

Referenced by CancelWeaponEvent(), and HandleWeaponEvents().

◆ m_dst

◆ m_dst1

Definition at line 74 of file DayZPlayerInventory.c.

Referenced by DeferredForceSwapEntities().

◆ m_dst2

Definition at line 75 of file DayZPlayerInventory.c.

Referenced by DeferredForceSwapEntities().

◆ m_event

◆ m_FSwapping

ref HandAnimatedForceSwapping m_FSwapping
protected

Definition at line 142 of file DayZPlayerInventory.c.

Referenced by Init().

◆ m_FSwappingInst

ref HandAnimatedForceSwapping_Inst m_FSwappingInst
protected

Definition at line 143 of file DayZPlayerInventory.c.

Referenced by Init().

◆ m_item1

◆ m_item2

EntityAI m_item2

Definition at line 73 of file DayZPlayerInventory.c.

Referenced by DeferredForceSwapEntities().

◆ m_MovingTo

ref HandAnimatedMovingToAtt m_MovingTo
protected

Definition at line 140 of file DayZPlayerInventory.c.

Referenced by Init().

◆ m_src

Referenced by DeferredTakeToDst().

◆ m_Swapping

ref HandAnimatedSwapping m_Swapping
protected

Definition at line 141 of file DayZPlayerInventory.c.

Referenced by Init().

◆ m_Taking

ref HandAnimatedTakingFromAtt m_Taking
protected

deferred weapon event

Definition at line 139 of file DayZPlayerInventory.c.

Referenced by Init().