Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzplayerinventory.c File Reference

Go to the source code of this file.

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) More...
 
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 More...
 
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)
 
override void NetSyncCurrentStateID (int id)
 
override void OnAfterStoreLoad ()
 engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase.OnAfterStoreLoad More...
 
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)
 
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 More...
 
protected ref HandAnimatedTakingFromAtt m_Taking
 deferred weapon event More...
 
protected ref HandAnimatedMovingToAtt m_MovingTo
 
protected ref HandAnimatedSwapping m_Swapping
 
protected ref HandAnimatedForceSwapping m_FSwapping
 
protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst
 

Function Documentation

◆ AbortWeaponEvent()

void AbortWeaponEvent ( )

Definition at line 269 of file dayzplayerinventory.c.

◆ 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

Definition at line 257 of file dayzplayerinventory.c.

◆ CancelWeaponEvent()

void CancelWeaponEvent ( )

Definition at line 263 of file dayzplayerinventory.c.

◆ CheckForRope()

void CheckForRope ( InventoryLocation  src,
InventoryLocation  dst 
)

Definition at line 1570 of file dayzplayerinventory.c.

◆ ClearInventoryReservation()

override void ClearInventoryReservation ( HumanInventory  inventory)

Definition at line 31 of file dayzplayerinventory.c.

◆ DayZPlayerInventory()

Definition at line 151 of file dayzplayerinventory.c.

◆ DeferredForceSwapEntities()

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

Definition at line 81 of file dayzplayerinventory.c.

◆ DeferredHandEvent()

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

Definition at line 134 of file dayzplayerinventory.c.

◆ DeferredTakeToDst()

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

Definition at line 15 of file dayzplayerinventory.c.

◆ DeferredWeaponFailed()

void DeferredWeaponFailed ( )

Definition at line 308 of file dayzplayerinventory.c.

◆ EnableMovableOverride()

void EnableMovableOverride ( EntityAI  item)

Definition at line 1562 of file dayzplayerinventory.c.

◆ ForceSwapEntities()

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

Definition at line 1889 of file dayzplayerinventory.c.

◆ GetDayZPlayerOwner()

DayZPlayer GetDayZPlayerOwner ( )

Definition at line 155 of file dayzplayerinventory.c.

◆ HandEvent()

override bool HandEvent ( InventoryMode  mode,
HandEventBase  e 
)

Let the client know a failure happened

If singleplayer or the client is executing this

Definition at line 2212 of file dayzplayerinventory.c.

◆ HandleForceSwapEntities()

void HandleForceSwapEntities ( DeferredEvent  deferred_event)

Definition at line 1928 of file dayzplayerinventory.c.

◆ HandleHandEvent()

void HandleHandEvent ( DeferredEvent  deferred_event)

Default structure suffices

Definition at line 2254 of file dayzplayerinventory.c.

◆ HandleInventory()

void HandleInventory ( float  dt)

Definition at line 427 of file dayzplayerinventory.c.

◆ HandleInventoryManipulation()

override void HandleInventoryManipulation ( )

Definition at line 2367 of file dayzplayerinventory.c.

◆ HandleSwapEntities()

void HandleSwapEntities ( DeferredEvent  deferred_event)

Definition at line 1823 of file dayzplayerinventory.c.

◆ HandleTakeToDst()

void HandleTakeToDst ( DeferredEvent  deferred_event)

Definition at line 1695 of file dayzplayerinventory.c.

◆ HandleWeaponEvents()

void HandleWeaponEvents ( float  dt,
out bool  exitIronSights 
)

Definition at line 333 of file dayzplayerinventory.c.

◆ Init()

override void Init ( )

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

pre-init arrays

Definition at line 190 of file dayzplayerinventory.c.

◆ IsAuthoritative()

bool IsAuthoritative ( )

Definition at line 157 of file dayzplayerinventory.c.

◆ IsOwner()

bool IsOwner ( )

Definition at line 168 of file dayzplayerinventory.c.

◆ IsProcessing()

bool IsProcessing ( )

Definition at line 2383 of file dayzplayerinventory.c.

◆ IsProxy()

bool IsProxy ( )

Definition at line 179 of file dayzplayerinventory.c.

◆ IsServerOrLocalPlayer()

bool IsServerOrLocalPlayer ( )

Definition at line 1577 of file dayzplayerinventory.c.

◆ NetSyncCurrentStateID()

override void NetSyncCurrentStateID ( int  id)

Definition at line 2059 of file dayzplayerinventory.c.

◆ OnAfterStoreLoad()

OnAfterStoreLoad ( )

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

Definition at line 2072 of file dayzplayerinventory.c.

◆ OnEventForRemoteWeapon()

bool OnEventForRemoteWeapon ( ParamsReadContext  ctx)

Definition at line 2080 of file dayzplayerinventory.c.

◆ OnHandEventForRemote()

bool OnHandEventForRemote ( ParamsReadContext  ctx)

Definition at line 2122 of file dayzplayerinventory.c.

◆ OnHandleStoredInputUserData()

protected void OnHandleStoredInputUserData ( ParamsReadContext  ctx)

Definition at line 698 of file dayzplayerinventory.c.

◆ OnHandleStoredJunctureData()

protected void OnHandleStoredJunctureData ( ParamsReadContext  ctx)

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

Definition at line 654 of file dayzplayerinventory.c.

◆ OnHandsEnteredStableState()

override void OnHandsEnteredStableState ( HandStateBase  src,
HandStateBase  dst 
)

Definition at line 2178 of file dayzplayerinventory.c.

◆ OnHandsExitedStableState()

override void OnHandsExitedStableState ( HandStateBase  src,
HandStateBase  dst 
)

Definition at line 2168 of file dayzplayerinventory.c.

◆ OnHandsStateChanged()

override void OnHandsStateChanged ( HandStateBase  src,
HandStateBase  dst 
)

Definition at line 2188 of file dayzplayerinventory.c.

◆ OnInputUserDataForRemote()

void OnInputUserDataForRemote ( ParamsReadContext  ctx)

Definition at line 717 of file dayzplayerinventory.c.

◆ OnInputUserDataProcess()

override bool OnInputUserDataProcess ( ParamsReadContext  ctx)

Definition at line 683 of file dayzplayerinventory.c.

◆ OnInventoryFailure()

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

TODO(kumarjac): Notify player here

Definition at line 640 of file dayzplayerinventory.c.

◆ 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

Definition at line 561 of file dayzplayerinventory.c.

◆ OnInventoryJunctureFromServer()

override bool OnInventoryJunctureFromServer ( ParamsReadContext  ctx)

Definition at line 514 of file dayzplayerinventory.c.

◆ OnInventoryJunctureRepairFromServer()

override bool OnInventoryJunctureRepairFromServer ( ParamsReadContext  ctx)

Definition at line 536 of file dayzplayerinventory.c.

◆ OnServerInventoryCommand()

override void OnServerInventoryCommand ( ParamsReadContext  ctx)

Definition at line 727 of file dayzplayerinventory.c.

◆ PlayerCheckDropRequest()

bool PlayerCheckDropRequest ( notnull InventoryLocation  src,
float  radius 
)

Definition at line 2503 of file dayzplayerinventory.c.

◆ PlayerCheckRequestDst()

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

Definition at line 2419 of file dayzplayerinventory.c.

◆ PlayerCheckRequestSrc()

bool PlayerCheckRequestSrc ( notnull InventoryLocation  src,
float  radius 
)

Definition at line 2388 of file dayzplayerinventory.c.

◆ PlayerCheckSwapItemsRequest()

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

Definition at line 2450 of file dayzplayerinventory.c.

◆ PostWeaponEvent()

void PostWeaponEvent ( WeaponEventBase  e)

Definition at line 291 of file dayzplayerinventory.c.

◆ 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

Definition at line 1459 of file dayzplayerinventory.c.

◆ RemoveMovableOverride()

void RemoveMovableOverride ( EntityAI  item)

Definition at line 1555 of file dayzplayerinventory.c.

◆ ReserveInventory()

override bool ReserveInventory ( HumanInventory  inventory)

Definition at line 22 of file dayzplayerinventory.c.

◆ StoreInputForRemotes()

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

Definition at line 1582 of file dayzplayerinventory.c.

◆ StoreInputUserData()

proto native void StoreInputUserData ( ParamsReadContext  ctx)

◆ StoreJunctureData()

proto native void StoreJunctureData ( ParamsReadContext  ctx)

◆ SwapEntities()

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

Definition at line 1787 of file dayzplayerinventory.c.

◆ SyncHandEventToRemote()

void SyncHandEventToRemote ( HandEventBase  e)

Definition at line 2149 of file dayzplayerinventory.c.

◆ TakeToDst()

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

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 1600 of file dayzplayerinventory.c.

◆ ValidateDestroy()

bool ValidateDestroy ( inout Serializer  ctx,
InventoryValidation  validation 
)

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 1373 of file dayzplayerinventory.c.

◆ 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

Definition at line 935 of file dayzplayerinventory.c.

◆ 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

Definition at line 1135 of file dayzplayerinventory.c.

◆ 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

Definition at line 737 of file dayzplayerinventory.c.

Variable Documentation

◆ m_DeferredEvent

m_DeferredEvent = NULL

◆ m_DeferredPostedHandEvent

protected ref HandEventBase m_DeferredPostedHandEvent = NULL

Definition at line 142 of file dayzplayerinventory.c.

◆ m_DeferredWeaponEvent

ref WeaponEventBase m_DeferredWeaponEvent = NULL

deferred hand event

Definition at line 143 of file dayzplayerinventory.c.

◆ m_DeferredWeaponTimer

ref Timer m_DeferredWeaponTimer = new Timer

Definition at line 138 of file dayzplayerinventory.c.

◆ m_dst

ref InventoryLocation m_dst

Definition at line 13 of file dayzplayerinventory.c.

◆ m_dst1

ref InventoryLocation m_dst1

Definition at line 78 of file dayzplayerinventory.c.

◆ m_dst2

ref InventoryLocation m_dst2

Definition at line 79 of file dayzplayerinventory.c.

◆ m_event

ref HandEventBase m_event

Definition at line 133 of file dayzplayerinventory.c.

◆ m_FSwapping

protected ref HandAnimatedForceSwapping m_FSwapping

Definition at line 148 of file dayzplayerinventory.c.

◆ m_FSwappingInst

protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst

Definition at line 149 of file dayzplayerinventory.c.

◆ m_item1

◆ m_item2

EntityAI m_item2

Definition at line 77 of file dayzplayerinventory.c.

◆ m_MovingTo

protected ref HandAnimatedMovingToAtt m_MovingTo

Definition at line 146 of file dayzplayerinventory.c.

◆ m_src

class DeferredEvent m_src

◆ m_Swapping

protected ref HandAnimatedSwapping m_Swapping

Definition at line 147 of file dayzplayerinventory.c.

◆ m_Taking

protected ref HandAnimatedTakingFromAtt m_Taking

deferred weapon event

Definition at line 145 of file dayzplayerinventory.c.