PC Stable Documentation
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
DayZPlayerInventory.c File Reference

Data Structures

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 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)
 
override bool PostDeferredEventTakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
 
void HandleTakeToDst (DeferredEvent deferred_event)
 
override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
 
override bool PostDeferredForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 
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 ()
 
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)
 
bool MoveCheckExclusionMaskLocal (notnull InventoryLocation src, notnull InventoryLocation dst)
 Local, checks only stuff that is in guaranteed sync.
 
bool SwapCheckExclusionMaskLocal (notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 Local, checks only stuff that is in guaranteed sync.
 
bool ValidateDestroy (inout Serializer ctx, InventoryValidation validation)
 DEPRECATED.
 
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)
 
protected void OnHandleStoredJunctureData (ParamsReadContext ctx)
 
proto native void StoreJunctureData (ParamsReadContext ctx)
 
override bool OnInputUserDataProcess (ParamsReadContext ctx)
 
protected 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
 
protected ref HandEventBase m_DeferredPostedHandEvent = NULL
 
ref WeaponEventBase m_DeferredWeaponEvent = NULL
 deferred hand event
 
protected ref HandAnimatedTakingFromAtt m_Taking
 deferred weapon event
 
protected ref HandAnimatedMovingToAtt m_MovingTo
 
protected ref HandAnimatedSwapping m_Swapping
 
protected ref HandAnimatedForceSwapping m_FSwapping
 
protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst
 

Function Documentation

◆ AbortWeaponEvent()

◆ CancelHandEvent()

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

References m_DeferredPostedHandEvent.

◆ CancelWeaponEvent()

void CancelWeaponEvent ( )

◆ CheckForRope()

void CheckForRope ( InventoryLocation  src,
InventoryLocation  dst 
)

◆ ClearInventoryReservation()

override void ClearInventoryReservation ( HumanInventory  inventory)

◆ DayZPlayerInventory()

◆ DeferredForceSwapEntities()

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

◆ DeferredHandEvent()

◆ DeferredTakeToDst()

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

References m_dst, and m_src.

Referenced by HandleTakeToDst(), and PostDeferredEventTakeToDst().

◆ DeferredWeaponFailed()

◆ EnableMovableOverride()

◆ ForceSwapEntities()

◆ GetDayZPlayerOwner()

◆ HandEvent()

◆ HandleForceSwapEntities()

◆ HandleHandEvent()

◆ HandleInventory()

◆ HandleInventoryManipulation()

◆ HandleSwapEntities()

◆ HandleTakeToDst()

◆ HandleWeaponEvents()

◆ Init()

override void Init ( )

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

whole body slots

upper body part slots

bottom body part slots

lower body part slots


heat comfort related slots

pre-init arrays

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

◆ IsAuthoritative()

bool IsAuthoritative ( )

References Class::CastTo().

◆ IsOwner()

bool IsOwner ( )

References Class::CastTo().

◆ IsProcessing()

bool IsProcessing ( )

◆ IsProxy()

bool IsProxy ( )

References Class::CastTo().

◆ IsServerOrLocalPlayer()

bool IsServerOrLocalPlayer ( )

◆ MoveCheckExclusionMaskLocal()

bool MoveCheckExclusionMaskLocal ( notnull InventoryLocation  src,
notnull InventoryLocation  dst 
)

Local, checks only stuff that is in guaranteed sync.

Referenced by ValidateSyncMove().

◆ NetSyncCurrentStateID()

override void NetSyncCurrentStateID ( int  id)

◆ OnAfterStoreLoad()

override void OnAfterStoreLoad ( )

◆ OnEventForRemoteWeapon()

◆ OnHandEventForRemote()

bool OnHandEventForRemote ( ParamsReadContext  ctx)

◆ OnHandleStoredInputUserData()

protected void OnHandleStoredInputUserData ( ParamsReadContext  ctx)

◆ OnHandleStoredJunctureData()

protected void OnHandleStoredJunctureData ( ParamsReadContext  ctx)

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

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

◆ OnHandsEnteredStableState()

override void OnHandsEnteredStableState ( HandStateBase  src,
HandStateBase  dst 
)

◆ OnHandsExitedStableState()

override void OnHandsExitedStableState ( HandStateBase  src,
HandStateBase  dst 
)

◆ OnHandsStateChanged()

◆ OnInputUserDataForRemote()

◆ OnInputUserDataProcess()

◆ OnInventoryFailure()

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

TODO(kumarjac): Notify player here

Referenced by HandEvent(), and OnInventoryJunctureFailureFromServer().

◆ OnInventoryJunctureFailureFromServer()

override void OnInventoryJunctureFailureFromServer ( ParamsReadContext  ctx)

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

References HandEventBase::ClearInventoryReservation(), HandEventBase::GetDst(), GetGame(), InventoryLocation::GetItem(), INPUT_UDT_INVENTORY, OnInventoryFailure(), Serializer::Read(), and InventoryLocation::ReadFromContext().

◆ OnInventoryJunctureFromServer()

◆ OnInventoryJunctureRepairFromServer()

override bool OnInventoryJunctureRepairFromServer ( ParamsReadContext  ctx)

◆ OnServerInventoryCommand()

override void OnServerInventoryCommand ( ParamsReadContext  ctx)

◆ PlayerCheckDropRequest()

bool PlayerCheckDropRequest ( notnull InventoryLocation  src,
float  radius 
)

References GetDayZPlayerOwner().

Referenced by ValidateDestroy().

◆ PlayerCheckRequestDst()

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

References GetDayZPlayerOwner().

Referenced by ValidateSyncMove().

◆ PlayerCheckRequestSrc()

bool PlayerCheckRequestSrc ( notnull InventoryLocation  src,
float  radius 
)

◆ PlayerCheckSwapItemsRequest()

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

◆ PostDeferredEventTakeToDst()

override bool PostDeferredEventTakeToDst ( InventoryMode  mode,
notnull InventoryLocation  src,
notnull InventoryLocation  dst 
)

References DeferredTakeToDst(), and m_DeferredEvent.

Referenced by TakeToDst().

◆ PostDeferredForceSwapEntities()

override bool PostDeferredForceSwapEntities ( InventoryMode  mode,
notnull EntityAI  item1,
notnull EntityAI  item2,
notnull InventoryLocation  dst1,
notnull InventoryLocation  dst2 
)

◆ PostWeaponEvent()

◆ ProcessInputData()

bool ProcessInputData ( ParamsReadContext  ctx,
bool  isJuncture,
bool  isRemote 
)
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

References Serializer::CanWrite(), ScriptInputUserData::CopyFrom(), Error(), GetDayZPlayerOwner(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, Serializer::Read(), DayZPlayerSyncJunctures::SJ_INVENTORY, DayZPlayerSyncJunctures::SJ_INVENTORY_FAILURE, StoreInputForRemotes(), ValidateHandEvent(), ValidateSwap(), ValidateSyncMove(), and Serializer::Write().

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

◆ RemoveMovableOverride()

void RemoveMovableOverride ( EntityAI  item)

◆ ReserveInventory()

◆ SendServerHandEventViaJuncture()

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

◆ StoreInputForRemotes()

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

◆ StoreInputUserData()

proto native void StoreInputUserData ( ParamsReadContext  ctx)

Referenced by OnInputUserDataProcess().

◆ StoreJunctureData()

proto native void StoreJunctureData ( ParamsReadContext  ctx)

◆ SwapCheckExclusionMaskLocal()

bool SwapCheckExclusionMaskLocal ( notnull InventoryLocation  src1,
notnull InventoryLocation  src2,
notnull InventoryLocation  dst1,
notnull InventoryLocation  dst2 
)

Local, checks only stuff that is in guaranteed sync.

Referenced by ValidateSwap().

◆ SwapEntities()

◆ SyncHandEventToRemote()

◆ TakeToDst()

override bool TakeToDst ( InventoryMode  mode,
notnull InventoryLocation  src,
notnull InventoryLocation  dst 
)

◆ ValidateDestroy()

bool ValidateDestroy ( inout Serializer  ctx,
InventoryValidation  validation 
)

DEPRECATED.

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

References GameInventory::c_MaxItemDistanceRadius, InventoryLocation::DumpToStringNullSafe(), Error(), GetDayZPlayerOwner(), GetGame(), InventoryLocation::GetItem(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Result, CGame::ObjectDelete(), PlayerCheckDropRequest(), PlayerCheckRequestSrc(), InventoryLocation::ReadFromContext(), and ToString().

◆ ValidateHandEvent()

bool ValidateHandEvent ( inout Serializer  ctx,
InventoryValidation  validation 
)

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

References HandEventBase::AcquireInventoryJunctureFromServer(), HandEventBase::CanPerformEventEx(), CheckForRope(), HandEventBase::CheckRequestSrc(), HandEventBase::ClearInventoryReservation(), InventoryLocation::Copy(), HandEventBase::DumpToString(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), HandEventBase::GetDst(), GetInstanceType(), HandEventBase::GetSecondSrcEntity(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, RemoveMovableOverride(), InventoryInputUserData::SerializeHandEvent(), and syncDebugPrint().

Referenced by ProcessInputData().

◆ ValidateSwap()

bool ValidateSwap ( inout Serializer  ctx,
InventoryValidation  validation 
)

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

References GameInventory::c_InventoryReservationTimeoutShortMS, GameInventory::c_MaxItemDistanceRadius, GameInventory::CanForceSwapEntitiesEx(), CGame::ClearJunctureEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), GetInstanceType(), InventoryLocation::GetItem(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), InventoryLocation::IsValid(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, PlayerCheckRequestSrc(), PlayerCheckSwapItemsRequest(), InventoryLocation::ReadFromContext(), RemoveMovableOverride(), InventoryInputUserData::SerializeSwap(), SwapCheckExclusionMaskLocal(), syncDebugPrint(), ToString(), and TryAcquireTwoInventoryJuncturesFromServer().

Referenced by ProcessInputData().

◆ ValidateSyncMove()

bool ValidateSyncMove ( inout Serializer  ctx,
InventoryValidation  validation 
)

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

References GameInventory::c_MaxItemDistanceRadius, CheckForRope(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), GetInstanceType(), InventoryLocation::GetItem(), GetTime(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), GameInventory::LocationCanMoveEntity(), GameInventory::LocationCanMoveEntitySyncCheck(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, MoveCheckExclusionMaskLocal(), PlayerCheckRequestDst(), PlayerCheckRequestSrc(), InventoryLocation::ReadFromContext(), RemoveMovableOverride(), syncDebugPrint(), ToString(), and TryAcquireInventoryJunctureFromServer().

Referenced by ProcessInputData().

Variable Documentation

◆ m_DeferredEvent

◆ m_DeferredPostedHandEvent

protected ref HandEventBase m_DeferredPostedHandEvent = NULL

Referenced by CancelHandEvent(), and IsProcessing().

◆ m_DeferredWeaponEvent

ref WeaponEventBase m_DeferredWeaponEvent = NULL

◆ m_DeferredWeaponTimer

ref Timer m_DeferredWeaponTimer = new Timer

◆ m_dst

◆ m_dst1

◆ m_dst2

◆ m_event

◆ m_FSwapping

protected ref HandAnimatedForceSwapping m_FSwapping

Referenced by Init().

◆ m_FSwappingInst

protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst

Referenced by Init().

◆ m_item1

◆ m_item2

EntityAI m_item2

◆ m_MovingTo

protected ref HandAnimatedMovingToAtt m_MovingTo

Referenced by Init().

◆ m_src

class DeferredEvent m_src

Referenced by DeferredTakeToDst().

◆ m_Swapping

protected ref HandAnimatedSwapping m_Swapping

Referenced by Init().

◆ m_Taking

protected ref HandAnimatedTakingFromAtt m_Taking

deferred weapon event

Referenced by Init().