DayZ 1.26
DayZ Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл DayZPlayerInventory.c

См. исходные тексты.

Структуры данных

class  DeferredEvent
 
class  DeferredSwapEntities
 
class  DeferredHandEvent
 

Функции

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 ()
 
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)
 

Переменные

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
 

Функции

◆ AbortWeaponEvent()

void AbortWeaponEvent ( )
protected
283 {
284 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
285
287 Class.CastTo(weapon, GetEntityInHands());
288
289 if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
290 {
292 {
293 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
294 }
295
296 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
297 }
298 }
void wpnDebugPrint(string s)
Definition Debug.c:9
DayZPlayer GetDayZPlayerOwner()
Definition DayZPlayerInventory.c:168
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition human.c:994
Definition Debug.c:600
static bool IsWeaponLogEnable()
Definition Debug.c:724
Definition ObjectTyped.c:2
Definition EntityAI.c:95
shorthand
Definition BoltActionRifle_Base.c:6
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

Перекрестные ссылки Class::CastTo(), GetDayZPlayerOwner(), LogManager::IsWeaponLogEnable() и wpnDebugPrint().

Используется в ManBase::OnCommandClimbStart(), ManBase::OnCommandDeathStart(), ManBase::OnCommandFallStart(), ManBase::OnCommandMelee2Start(), ManBase::OnCommandSwimStart(), ManBase::OnJumpStart() и 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

271 {
273 //m_postedHandEvent = null;
274 }
ref HandEventBase m_DeferredPostedHandEvent
Definition DayZPlayerInventory.c:155

Перекрестные ссылки m_DeferredPostedHandEvent.

◆ CancelWeaponEvent()

void CancelWeaponEvent ( )
protected
277 {
280 }
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
Definition DayZPlayerInventory.c:156
ref Timer m_DeferredWeaponTimer
Definition DayZPlayerInventory.c:151

Перекрестные ссылки m_DeferredWeaponEvent и m_DeferredWeaponTimer.

Используется в DeferredWeaponFailed().

◆ CheckForRope()

void CheckForRope ( InventoryLocation src,
InventoryLocation dst )
protected
1675 {
1676 Rope rope = Rope.Cast(src.GetItem());
1677 if (rope)
1678 rope.SetTargetLocation(dst);
1679 }

Используется в ValidateHandEvent() и ValidateSyncMove().

◆ ClearInventoryReservation()

override void ClearInventoryReservation ( HumanInventory inventory)
35 {
36 inventory.ClearInventoryReservationEx(m_dst.GetItem(), m_dst);
37 }
ref InventoryLocation m_dst
Definition DayZPlayerInventory.c:13

Перекрестные ссылки m_dst.

◆ DayZPlayerInventory()

void DayZPlayerInventory ( )
protected
165 {
166 }

◆ DeferredForceSwapEntities()

void DeferredForceSwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2 )
90 {
91 m_mode = mode;
92 m_item1 = item1;
93 m_item2 = item2;
94 m_dst1 = dst1;
95 m_dst2 = dst2;
96 }
ref InventoryLocation m_dst1
Definition DayZPlayerInventory.c:86
ref InventoryLocation m_dst2
Definition DayZPlayerInventory.c:87
DeferredSwapEntities m_item1
EntityAI m_item2
Definition DayZPlayerInventory.c:85

Перекрестные ссылки m_dst1, m_dst2, m_item1 и m_item2.

Используется в ForceSwapEntities() и HandleForceSwapEntities().

◆ DeferredHandEvent()

void DeferredHandEvent ( InventoryMode mode,
HandEventBase e )
128 {
129 m_mode = mode;
130 m_event = e;
131 }
ref HandEventBase m_event
Definition DayZPlayerInventory.c:126

Используется в HandEvent().

◆ DeferredTakeToDst()

void DeferredTakeToDst ( InventoryMode mode,
notnull InventoryLocation src,
notnull InventoryLocation dst )
16 {
17 m_mode = mode;
18 m_src = src;
19 m_dst = dst;
20 }
class DeferredEvent m_src

Перекрестные ссылки m_dst и m_src.

Используется в HandleTakeToDst() и TakeToDst().

◆ DeferredWeaponFailed()

void DeferredWeaponFailed ( )
protected
322 {
324 Class.CastTo(weapon, GetEntityInHands());
325
326 string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
327
328 string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
329 if (weapon)
330 {
331 secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
332 secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
333 for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
334 {
335 secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
336 secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
337 if (i < weapon.GetMuzzleCount() - 1)
338 secondPart += " | ";
339 }
340 }
341
344 }
void CancelWeaponEvent()
Definition DayZPlayerInventory.c:276
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90

Перекрестные ссылки CancelWeaponEvent(), Class::CastTo(), Error() и m_DeferredWeaponEvent.

◆ EnableMovableOverride()

void EnableMovableOverride ( EntityAI item)
protected
1667 {
1668 ItemBase itemIB = ItemBase.Cast(item);
1669 if (itemIB)
1670 itemIB.SetCanBeMovedOverride(true);
1671 }
Definition InventoryItem.c:731

Используется в HandleHandEvent(), HandleSwapEntities(), HandleTakeToDst(), ValidateHandEvent(), ValidateSwap() и ValidateSyncMove().

◆ ForceSwapEntities()

override bool ForceSwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2,
notnull InventoryLocation item2_dst )
protected
1998 {
1999 #ifdef ENABLE_LOGGING
2001 {
2002 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
2003 }
2004 #endif
2005
2006 if( mode == InventoryMode.LOCAL )
2007 {
2010 {
2011 LocationSwap(src1, src2, dst1, item2_dst);
2012 return true;
2013 }
2014
2015 }
2016
2017 if(!super.ForceSwapEntities(mode,item1,item2,item2_dst))
2018 {
2019 if(!m_DeferredEvent)
2020 {
2022 {
2024 if( m_DeferredEvent.ReserveInventory(this))
2025 return true;
2026
2027 }
2028 }
2030 return false;
2031 }
2032
2033 return true;
2034 }
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)
Definition DayZPlayerInventory.c:89
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:151
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:1221
InventoryLocation.
Definition InventoryLocation.c:29
static string DumpToStringNullSafe(InventoryLocation loc)
Definition InventoryLocation.c:226
static bool IsInventoryMoveLogEnable()
Definition Debug.c:654

Перекрестные ссылки DeferredForceSwapEntities(), InventoryLocation::DumpToStringNullSafe(), GetDayZPlayerOwner(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), m_DeferredEvent, GameInventory::MakeSrcAndDstForForceSwap() и 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

2331 {
2332 if (!IsProcessing())
2333 {
2334 EntityAI itemInHands = GetEntityInHands();
2335
2337 handInventoryLocation.SetHands(GetInventoryOwner(), itemInHands);
2338
2340 if (e.CanPerformEventEx(validation))
2341 {
2343 if (m_DeferredEvent.ReserveInventory(this))
2344 {
2345 return true;
2346 }
2347 }
2348
2350
2352 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
2353 {
2355 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
2356 }
2357 else
2358 {
2360
2362 serializer.Write(validation.m_Reason);
2363
2365 }
2366 }
2367
2368 return false;
2369 }
InventoryCommandType
Definition Inventory.c:3
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
Definition DayZPlayerInventory.c:127
bool IsProcessing()
Definition DayZPlayerInventory.c:2501
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Definition DayZPlayerInventory.c:655
Definition DayZPlayerSyncJunctures.c:5
static const int SJ_INVENTORY_FAILURE
Definition DayZPlayerSyncJunctures.c:32
Definition Building.c:6
Definition InventoryInputUserData.c:3
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
Definition InventoryInputUserData.c:72
Definition Inventory.c:44
Definition gameplay.c:121
proto native CGame GetGame()

Перекрестные ссылки DeferredHandEvent(), GetDayZPlayerOwner(), GetGame(), IsProcessing(), m_DeferredEvent, OnInventoryFailure(), InventoryInputUserData::SerializeHandEvent() и DayZPlayerSyncJunctures::SJ_INVENTORY_FAILURE.

◆ HandleForceSwapEntities()

void HandleForceSwapEntities ( DeferredEvent deferred_event)
protected
2037 {
2040 {
2041 deferred_force_swap_entities.ClearInventoryReservation(this);
2044 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
2045 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
2046
2047 DayZPlayer player = GetGame().GetPlayer();
2048
2050 {
2052 }
2053
2054 switch (deferred_force_swap_entities.m_mode)
2055 {
2056 case InventoryMode.PREDICTIVE:
2057 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))
2058 {
2061 }
2062 else
2063 {
2064 #ifdef ENABLE_LOGGING
2066 {
2067 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());
2068 }
2069 #endif
2070 }
2071 break;
2072
2073 case InventoryMode.JUNCTURE:
2074 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))
2075 {
2076 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2077 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2078
2080 }
2081 else
2082 {
2083 #ifdef ENABLE_LOGGING
2085 {
2086 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());
2087 }
2088 #endif
2089 }
2090 break;
2091
2092 case InventoryMode.LOCAL:
2093 break;
2094
2095 default:
2096 Error("ForceSwapEntities - HandEvent - Invalid mode");
2097 }
2098 }
2099 }
void inventoryDebugPrint(string s)
Definition Debug.c:19
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:713
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
Definition InventoryInputUserData.c:48

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, DeferredForceSwapEntities(), InventoryLocation::DumpToStringNullSafe(), Error(), GetDayZPlayerOwner(), GetGame(), inventoryDebugPrint(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), InventoryInputUserData::SendInputUserDataSwap() и ToString().

Используется в HandleInventoryManipulation().

◆ HandleHandEvent()

void HandleHandEvent ( DeferredEvent deferred_event)
protected

Default structure suffices

2373 {
2376
2379 {
2380 #ifdef ENABLE_LOGGING
2382 {
2383 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2384 }
2385 #endif
2386
2388 {
2389 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2390 }
2391
2392 switch (deferred_hand_event.m_mode)
2393 {
2394 case InventoryMode.PREDICTIVE:
2395 #ifdef ENABLE_LOGGING
2397 {
2398 Debug.InventoryHFSMLog("PREDICTIVE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2399 }
2400 #endif
2401
2402 deferred_hand_event.ClearInventoryReservation(this);
2403 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2404 {
2406 ProcessHandEvent(deferred_hand_event.m_event);
2407 }
2408 break;
2409
2410 case InventoryMode.JUNCTURE:
2411 #ifdef ENABLE_LOGGING
2413 {
2414 Debug.InventoryHFSMLog("JUNCTURE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2415 }
2416 #endif
2417
2418 deferred_hand_event.ClearInventoryReservation(this);
2419 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2420 {
2421 deferred_hand_event.ReserveInventory(this);
2423
2424 //Functionality to prevent desync when two players perform interfering action at the same time
2425 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2427 if (deferred_hand_event.m_event.GetDst())
2428 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2429 if (itemSrc)
2431 if (itemDst)
2433 }
2434 break;
2435
2436 case InventoryMode.LOCAL:
2437 #ifdef ENABLE_LOGGING
2439 {
2440 Debug.InventoryHFSMLog("LOCAL", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2441 }
2442 #endif
2443
2444 deferred_hand_event.ClearInventoryReservation(this);
2445 ProcessHandEvent(deferred_hand_event.m_event);
2446 //PostHandEvent(deferred_hand_event.m_event);
2447 break;
2448
2449 case InventoryMode.SERVER:
2450 #ifdef ENABLE_LOGGING
2452 {
2453 Debug.InventoryHFSMLog("SERVER", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2454 }
2455
2457 {
2458 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2459 }
2460 #endif
2461
2462 if (!deferred_hand_event.m_event.IsServerSideOnly())
2463 {
2464 if (GetDayZPlayerOwner().IsAlive())
2465 {
2467 }
2468 else
2469 {
2471 }
2472 }
2473 else
2474 {
2475 ProcessHandEvent(deferred_hand_event.m_event);
2476 }
2477 break;
2478
2479 default:
2480 Error("HumanInventory::HandEvent - Invalid mode");
2481 }
2482 }
2483 }
void EnableMovableOverride(EntityAI item)
Definition DayZPlayerInventory.c:1666
static void SendServerHandEventViaJuncture(notnull DayZPlayer player, HandEventBase e)
Definition DayZPlayerInventory.c:2101
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:161
Definition DayZPlayerInventory.c:125
static void SendInputUserDataHandEvent(HandEventBase e)
Definition InventoryInputUserData.c:79
static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
Definition InventoryInputUserData.c:90
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:674

Перекрестные ссылки EnableMovableOverride(), Error(), GetDayZPlayerOwner(), hndDebugPrint(), Debug::InventoryHFSMLog(), LogManager::IsInventoryHFSMLogEnable(), InventoryInputUserData::SendInputUserDataHandEvent(), InventoryInputUserData::SendServerHandEventViaInventoryCommand(), SendServerHandEventViaJuncture() и ToString().

Используется в HandleInventoryManipulation().

◆ HandleInventory()

void HandleInventory ( float dt)
protected
441 {
442 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
443
444 EntityAI ih = GetEntityInHands();
447
448 if (hcw)
449 {
450 m_FSM.GetCurrentState().OnUpdate(dt);
451
452 #ifdef ENABLE_LOGGING
454 {
455 hndDebugSpamALot("[hndfsm] HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
456 }
457 #endif
458
459 if ( !m_FSM.GetCurrentState().IsIdle() || !m_FSM.IsRunning())
460 {
461 while (true)
462 {
463 int weaponEventId = hcw.IsEvent();
464 if (weaponEventId == -1)
465 {
466 break;
467 }
468
470
471 #ifdef ENABLE_LOGGING
473 {
474 hndDebugPrint("[hndfsm] HandleInventory: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
475 }
476 #endif
477
478 if (anim_event != NULL)
479 {
481 ProcessHandEvent(anim_event);
482 }
483 }
484
485 if (hcw.IsActionFinished())
486 {
487 if (m_FSM.GetCurrentState().IsWaitingForActionFinish())
488 {
489 #ifdef ENABLE_LOGGING
491 {
492 hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + m_FSM.GetCurrentState());
493 }
494 #endif
495
496 HandEventBase fin_event = new HandEventHumanCommandActionFinished(GetManOwner());
498 ProcessHandEvent(fin_event);
499 }
500 else
501 {
502 #ifdef ENABLE_LOGGING
504 {
505 hndDebugPrint("[hndfsm] Hand-Weapon event: ABORT! notifying running state=" + m_FSM.GetCurrentState());
506 }
507 #endif
508
509 HandEventBase abt_event = new HandEventHumanCommandActionAborted(GetManOwner());
511 ProcessHandAbortEvent(abt_event);
512 //m_FSM.ProcessHandAbortEvent(new WeaponEventHumanCommandActionAborted(GetManOwner()));
513 }
514 }
515 }
516 }
517 }
void SyncHandEventToRemote(HandEventBase e)
Definition DayZPlayerInventory.c:2267
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
Definition Hand_Events.c:794
void hndDebugSpamALot(string s)
Definition HandFSM.c:17
Abstracted event, not to be used, only inherited.
Definition Hand_Events.c:209
WeaponActions
actions
Definition human.c:816
WeaponEvents
events
Definition human.c:963
string WeaponActionTypeToString(int A, int AT)
Definition human.c:943

Перекрестные ссылки Class::CastTo(), GetDayZPlayerOwner(), HandAnimEventFactory(), hndDebugPrint(), hndDebugSpamALot(), LogManager::IsInventoryHFSMLogEnable(), SyncHandEventToRemote() и WeaponActionTypeToString().

◆ HandleInventoryManipulation()

override void HandleInventoryManipulation ( )
protected
2486 {
2487 super.HandleInventoryManipulation();
2489 {
2494
2496 }
2497 }
void HandleHandEvent(DeferredEvent deferred_event)
Definition DayZPlayerInventory.c:2372
void HandleTakeToDst(DeferredEvent deferred_event)
Definition DayZPlayerInventory.c:1803
void HandleSwapEntities(DeferredEvent deferred_event)
Definition DayZPlayerInventory.c:1931
void HandleForceSwapEntities(DeferredEvent deferred_event)
Definition DayZPlayerInventory.c:2036
proto static native bool CanStoreInputUserData()

Перекрестные ссылки ScriptInputUserData::CanStoreInputUserData(), HandleForceSwapEntities(), HandleHandEvent(), HandleSwapEntities(), HandleTakeToDst() и m_DeferredEvent.

◆ HandleSwapEntities()

void HandleSwapEntities ( DeferredEvent deferred_event)
protected
1932 {
1935 {
1936 deferred_swap_entities.ClearInventoryReservation(this);
1939 {
1941 {
1943 }
1944
1945 switch (deferred_swap_entities.m_mode)
1946 {
1947 case InventoryMode.PREDICTIVE:
1948 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1949 {
1951 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1952 }
1953 else
1954 {
1955 #ifdef ENABLE_LOGGING
1957 {
1958 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() );
1959 }
1960 #endif
1961 }
1962 break;
1963
1964 case InventoryMode.JUNCTURE:
1965 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1966 {
1967 DayZPlayer player = GetGame().GetPlayer();
1968 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1969 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1973 }
1974 else
1975 {
1976 #ifdef ENABLE_LOGGING
1978 {
1979 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() );
1980 }
1981 #endif
1982 }
1983 break;
1984
1985 case InventoryMode.LOCAL:
1986 break;
1987
1988 default:
1989 Error("SwapEntities - HandEvent - Invalid mode");
1990 }
1991 }
1992 else
1993 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1994 }
1995 }
Definition DayZPlayerInventory.c:41
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:1209

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), inventoryDebugPrint(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), GameInventory::MakeSrcAndDstForSwap(), InventoryInputUserData::SendInputUserDataSwap() и ToString().

Используется в HandleInventoryManipulation().

◆ HandleTakeToDst()

void HandleTakeToDst ( DeferredEvent deferred_event)
protected
1804 {
1807 {
1808 #ifdef ENABLE_LOGGING
1810 {
1811 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1812 }
1813 #endif
1814
1815 deferred_take_to_dst.ClearInventoryReservation(this);
1816
1818 {
1820 }
1821
1822 switch (deferred_take_to_dst.m_mode)
1823 {
1824 case InventoryMode.PREDICTIVE:
1825 #ifdef ENABLE_LOGGING
1827 {
1828 Debug.InventoryHFSMLog("PREDICTIVE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1829 }
1830 #endif
1831
1832 if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
1833 {
1835 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1836 }
1837 else
1838 {
1839 #ifdef ENABLE_LOGGING
1841 {
1842 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() );
1843 }
1844 #endif
1845 }
1846 break;
1847 case InventoryMode.JUNCTURE:
1848 #ifdef ENABLE_LOGGING
1850 {
1851 Debug.InventoryHFSMLog("JUNCTURE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1852 }
1853 #endif
1854
1855 if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
1856 {
1857 DayZPlayer player = GetGame().GetPlayer();
1858 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1861 }
1862 else
1863 {
1864 #ifdef ENABLE_LOGGING
1866 {
1867 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());
1868 }
1869 #endif
1870 }
1871 break;
1872 case InventoryMode.LOCAL:
1873 #ifdef ENABLE_LOGGING
1875 {
1876 Debug.InventoryHFSMLog("LOCAL ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1877 }
1878 #endif
1879 break;
1880 case InventoryMode.SERVER:
1881 #ifdef ENABLE_LOGGING
1883 {
1884 Debug.InventoryHFSMLog("SERVER ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1885 }
1886 #endif
1887 break;
1888 default:
1889 Error("HandEvent - Invalid mode");
1890 break;
1891 }
1892 }
1893 }
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition DayZPlayerInventory.c:15
static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition InventoryInputUserData.c:13

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, DeferredTakeToDst(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), inventoryDebugPrint(), Debug::InventoryHFSMLog(), Debug::InventoryMoveLog(), LogManager::IsInventoryHFSMLogEnable(), LogManager::IsInventoryMoveLogEnable(), InventoryInputUserData::SendInputUserDataMove() и ToString().

Используется в HandleInventoryManipulation().

◆ HandleWeaponEvents()

void HandleWeaponEvents ( float dt,
out bool exitIronSights )
protected
347 {
348 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
349
351 Class.CastTo(weapon, GetEntityInHands());
352
353 if (hcw && weapon && weapon.CanProcessWeaponEvents())
354 {
355 weapon.GetCurrentState().OnUpdate(dt);
356
358 {
359 wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
360 }
361
362 if (!weapon.IsIdle())
363 {
364 while (true)
365 {
366 int weaponEventId = hcw.IsEvent();
367 if (weaponEventId == -1)
368 {
369 break;
370 }
371
372 if (weaponEventId == WeaponEvents.CHANGE_HIDE)
373 {
374 break;
375 }
376
378
380 {
381 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
382 }
383
384 if (anim_event != NULL)
385 {
386 weapon.ProcessWeaponEvent(anim_event);
387 }
388 }
389
390 if (hcw.IsActionFinished())
391 {
392 if (weapon.IsWaitingForActionFinish())
393 {
395 {
396 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
397 }
398
399 weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
400 }
401 else
402 {
404 {
405 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
406 }
407
408 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
409 }
410 }
411 }
412
414 {
416 {
417 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
418 }
419
420 if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
421 {
422 exitIronSights = true;
423
425 {
426 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
427 }
428
431 }
432 else if (!m_DeferredWeaponTimer.IsRunning())
433 {
434 m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
435 }
436 }
437 }
438 }
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

Перекрестные ссылки Class::CastTo(), fsmDebugSpam(), GetDayZPlayerOwner(), LogManager::IsWeaponLogEnable(), m_DeferredWeaponEvent, m_DeferredWeaponTimer, WeaponActionTypeToString(), WeaponAnimEventFactory(), wpnDebugPrint() и 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

204 {
206 {
207 hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
208 }
209
210 CreateStableStates(); // stable states needs to be created first
211
212 m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
213 m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
214 m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
215 m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
216 m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
217
218 // events
219 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
220 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
221 HandEventBase __T__ = new HandEventTake;
222 HandEventBase __M__ = new HandEventMoveTo;
224 //HandEventBase __D__ = new HandEventDropping;
225 HandEventBase __Xd_ = new HandEventDestroyed;
226 HandEventBase __F__ = new HandEventForceSwap;
227
228 // setup transitions
229 m_FSM.AddTransition(new HandTransition( m_Empty , __T__, m_Taking, NULL, new HandSelectAnimationOfTakeToHandsEvent(GetManOwner())));
230 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
231 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Equipped, null, null));
232 m_FSM.AddTransition(new HandTransition( m_Taking , __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
233 m_Taking.AddTransition(new HandTransition( m_Taking.m_Hide, _abt_, m_Empty));
234 m_Taking.AddTransition(new HandTransition( m_Taking.m_Show, _abt_, m_Equipped));
235
236 m_FSM.AddTransition(new HandTransition( m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
237 m_FSM.AddTransition(new HandTransition( m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
238 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
239 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Empty , null, null));
240 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Hide, _abt_, m_Equipped));
241 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Show, _abt_, m_Empty));
242
243 m_FSM.AddTransition(new HandTransition( m_Equipped, __W__, m_Swapping, NULL, new HandSelectAnimationOfSwapInHandsEvent(GetManOwner())));
244 m_FSM.AddTransition(new HandTransition( m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
245 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
246 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Equipped, null, null));
247 m_FSM.AddTransition(new HandTransition( m_Swapping, _abt_, m_Equipped, null, null));
248
249 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd( new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()) ) ));
250 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
251 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
252 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
253 m_FSM.AddTransition(new HandTransition( m_FSwappingInst, _abt_, m_Equipped, null, null));
254
255 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwapping, NULL, new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner())));
256 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
257 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
258 m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
259 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Start, _abt_, m_Equipped));
260 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Hide, _abt_, m_Empty));
261 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Show, _abt_, m_Equipped));
262
263 super.Init(); // initialize ordinary human fsm (no anims)
264 }
ref HandAnimatedForceSwapping m_FSwapping
Definition DayZPlayerInventory.c:161
ref HandAnimatedForceSwapping_Inst m_FSwappingInst
Definition DayZPlayerInventory.c:162
ref HandAnimatedSwapping m_Swapping
Definition DayZPlayerInventory.c:160
ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
Definition DayZPlayerInventory.c:158
ref HandAnimatedMovingToAtt m_MovingTo
Definition DayZPlayerInventory.c:159
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:28
Definition Hand_Events.c:679
Definition HandAnimated_Guards.c:320

Перекрестные ссылки hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), m_FSwapping, m_FSwappingInst, m_MovingTo, m_Swapping и m_Taking.

◆ IsAuthoritative()

bool IsAuthoritative ( )
protected
171 {
173 if (!Class.CastTo(player, GetInventoryOwner()))
174 {
175 return false;
176 }
177
178 return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
179 }
DayZPlayerInstanceType
defined in C++
Definition dayzplayer.c:1068

Перекрестные ссылки Class::CastTo().

◆ IsOwner()

bool IsOwner ( )
protected
182 {
184 if (!Class.CastTo(player, GetInventoryOwner()))
185 {
186 return false;
187 }
188
189 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
190 }

Перекрестные ссылки Class::CastTo().

◆ IsProcessing()

bool IsProcessing ( )
protected
2502 {
2503 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2504 }

Перекрестные ссылки m_DeferredEvent и m_DeferredPostedHandEvent.

Используется в HandEvent(), DayZPlayer::HandleADS() и ManBase::OnQuickBarSingleUse().

◆ IsProxy()

bool IsProxy ( )
protected
193 {
195 if (!Class.CastTo(player, GetInventoryOwner()))
196 {
197 return false;
198 }
199
200 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
201 }

Перекрестные ссылки Class::CastTo().

◆ IsServerOrLocalPlayer()

bool IsServerOrLocalPlayer ( )
protected
1682 {
1683 return GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || GetDayZPlayerOwner() == GetGame().GetPlayer());
1684 }

Перекрестные ссылки GetDayZPlayerOwner() и GetGame().

◆ NetSyncCurrentStateID()

override void NetSyncCurrentStateID ( int id)
protected
2178 {
2179 super.NetSyncCurrentStateID(id);
2180
2181 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
2182 }
override void OnItemInHandsChanged()
Definition DayZPlayerImplement.c:954

Перекрестные ссылки GetDayZPlayerOwner() и DayZPlayer::OnItemInHandsChanged().

◆ OnAfterStoreLoad()

override void OnAfterStoreLoad ( )
protected
2191 {
2192 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
2193 }

Перекрестные ссылки GetDayZPlayerOwner() и DayZPlayer::OnItemInHandsChanged().

◆ OnEventForRemoteWeapon()

bool OnEventForRemoteWeapon ( ParamsReadContext ctx)
protected
2199 {
2200 if (GetEntityInHands())
2201 {
2202 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
2203 if (wpn)
2204 {
2206
2208 if (pb && e)
2209 {
2210 pb.GetWeaponManager().SetRunning(true);
2211
2213 {
2214 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
2215 }
2216
2217 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
2218 {
2219 wpn.ProcessWeaponAbortEvent(e);
2220 }
2221 else
2222 {
2223 wpn.ProcessWeaponEvent(e);
2224 }
2225 pb.GetWeaponManager().SetRunning(false);
2226 }
2227 }
2228 else
2229 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
2230 }
2231 else
2232 Error("OnEventForRemoteWeapon - no entity in hands");
2233 return true;
2234 }
WeaponEventBase CreateWeaponEventFromContext(ParamsReadContext ctx)
Definition Events.c:281
WeaponEventID
identifier for events. mainly for rpc purposes
Definition Events.c:6
Definition PlayerBaseClient.c:2

Перекрестные ссылки CreateWeaponEventFromContext(), Error(), fsmDebugSpam(), GetDayZPlayerOwner() и LogManager::IsWeaponLogEnable().

◆ OnHandEventForRemote()

bool OnHandEventForRemote ( ParamsReadContext ctx)
protected
2241 {
2242 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2243 if (e)
2244 {
2246 {
2247 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
2248 }
2249
2250 //m_FSM.ProcessEvent(e);
2251
2252 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
2253 {
2255 m_FSM.ProcessAbortEvent(e, aa);
2256 }
2257 else
2258 {
2259 m_FSM.ProcessEvent(e);
2260 }
2261
2262 return true;
2263 }
2264 return false;
2265 }
ProcessEventResult
Definition FSMBase.c:41
HandEventID
events
Definition Hand_Events.c:7
void hndDebugSpam(string s)
Definition HandFSM.c:9

Перекрестные ссылки hndDebugSpam() и LogManager::IsInventoryHFSMLogEnable().

◆ OnHandleStoredInputUserData()

void OnHandleStoredInputUserData ( ParamsReadContext ctx)
protected
718 {
719 int tmp = -1;
720 ctx.Read(tmp);
721
722#ifdef ENABLE_LOGGING
724 {
725 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
726 }
727#endif
728
729 ProcessInputData(ctx, false, false);
730 }
void syncDebugPrint(string s)
Definition Debug.c:1
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
Definition DayZPlayerInventory.c:1563
static bool IsSyncLogEnable()
Definition Debug.c:684

Перекрестные ссылки GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData() и syncDebugPrint().

◆ OnHandleStoredJunctureData()

void OnHandleStoredJunctureData ( ParamsReadContext ctx)
protected

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

670 {
671 int tmp = -1;
672 ctx.Read(tmp);
673
674#ifdef ENABLE_LOGGING
676 {
677 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
678 }
679#endif
680
682 ProcessInputData(ctx, true, false);
683 }

Перекрестные ссылки GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData() и syncDebugPrint().

◆ OnHandsEnteredStableState()

override void OnHandsEnteredStableState ( HandStateBase src,
HandStateBase dst )
protected
2297 {
2298 super.OnHandsEnteredStableState(src, dst);
2299
2301 {
2302 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
2303 }
2304 }

Перекрестные ссылки hndDebugPrint() и LogManager::IsInventoryHFSMLogEnable().

Используется в OnHandsStateChanged().

◆ OnHandsExitedStableState()

override void OnHandsExitedStableState ( HandStateBase src,
HandStateBase dst )
protected
2287 {
2288 super.OnHandsExitedStableState(src, dst);
2289
2291 {
2292 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
2293 }
2294 }

Перекрестные ссылки hndDebugPrint() и LogManager::IsInventoryHFSMLogEnable().

Используется в OnHandsStateChanged().

◆ OnHandsStateChanged()

override void OnHandsStateChanged ( HandStateBase src,
HandStateBase dst )
protected
2307 {
2308 super.OnHandsStateChanged(src, dst);
2309
2311 {
2312 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
2313 }
2314
2315 if (src.IsIdle())
2317
2318 if (dst.IsIdle())
2320
2321#ifdef DIAG_DEVELOPER
2323 if (p && p.m_Bot)
2324 {
2325 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
2326 }
2327#endif
2328 }
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
Definition DayZPlayerInventory.c:2296
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
Definition DayZPlayerInventory.c:2286
Definition BotEvents.c:22

Перекрестные ссылки GetDayZPlayerOwner(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), OnHandsEnteredStableState() и OnHandsExitedStableState().

◆ OnInputUserDataForRemote()

void OnInputUserDataForRemote ( ParamsReadContext ctx)
protected
739 {
740#ifdef ENABLE_LOGGING
742 {
743 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
744 }
745#endif
746
747 ProcessInputData(ctx, false, true);
748 }

Перекрестные ссылки GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData() и syncDebugPrint().

◆ OnInputUserDataProcess()

override bool OnInputUserDataProcess ( ParamsReadContext ctx)
protected
701 {
702#ifdef ENABLE_LOGGING
704 {
705 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
706 }
707#endif
708
710 return true;
711 }
proto native void StoreInputUserData(ParamsReadContext ctx)

Перекрестные ссылки GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), StoreInputUserData() и syncDebugPrint().

◆ OnInventoryFailure()

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

TODO(kumarjac): Notify player here

656 {
657 if (reason == InventoryValidationReason.DROP_PREVENTED)
658 {
660 return;
661 }
662
663 }
InventoryValidationReason
Definition Inventory.c:37

Используется в HandEvent() и 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

577 {
589
590
591 if (GetGame().IsDedicatedServer())
592 {
593 return;
594 }
595
596 int udtIdentifier = -1;
598 {
599 return;
600 }
601
605
606 InventoryCommandType type = -1;
607 if (!ctx.Read(type))
608 {
609 return;
610 }
611
612 switch (type)
613 {
614 case InventoryCommandType.SYNC_MOVE:
615 {
616 src.ReadFromContext(ctx);
617 dst.ReadFromContext(ctx);
618 break;
619 }
620 case InventoryCommandType.HAND_EVENT:
621 {
622 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
623 src = e.GetSrc();
624 dst = e.GetDst();
625 break;
626 }
627 case InventoryCommandType.SWAP:
628 {
629 src.ReadFromContext(ctx);
630 temp.ReadFromContext(ctx);
631 dst.ReadFromContext(ctx);
632 temp.ReadFromContext(ctx);
633 break;
634 }
635 case InventoryCommandType.FORCESWAP:
636 {
637 break;
638 }
639 case InventoryCommandType.DESTROY:
640 {
641 src.ReadFromContext(ctx);
642 break;
643 }
644 }
645
647 if (!ctx.Read(reason))
648 {
650 }
651
653 }
const int INPUT_UDT_INVENTORY
Definition _constants.c:9

Перекрестные ссылки GetGame(), INPUT_UDT_INVENTORY и OnInventoryFailure().

◆ OnInventoryJunctureFromServer()

override bool OnInventoryJunctureFromServer ( ParamsReadContext ctx)
protected
528 {
529 int tmp = -1;
530 ctx.Read(tmp);
531
532#ifdef ENABLE_LOGGING
534 {
535 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store Juncture packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
536 }
537#endif
538
540
541 return true;
542 }
proto native void StoreJunctureData(ParamsReadContext ctx)

Перекрестные ссылки GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), StoreJunctureData() и syncDebugPrint().

◆ OnInventoryJunctureRepairFromServer()

override bool OnInventoryJunctureRepairFromServer ( ParamsReadContext ctx)
protected
552 {
553/* InventoryLocation il = new InventoryLocation;
554 if (!il.ReadFromContext(ctx) )
555 return false;
556
557 InventoryLocation il_current = new InventoryLocation;
558
559 EntityAI item = il.GetItem();
560 item.GetInventory().GetCurrentInventoryLocation(il_current);
561
562 if( !il_current.CompareLocationOnly(il))
563 {
564 LocationMoveEntity(il_current,il);
565 }*/
566 return true;
567 }

◆ OnServerInventoryCommand()

override void OnServerInventoryCommand ( ParamsReadContext ctx)
protected
751 {
752#ifdef ENABLE_LOGGING
754 {
755 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
756 }
757#endif
758
759 ProcessInputData(ctx, true, true);
760 }

Перекрестные ссылки GetDayZPlayerOwner(), LogManager::IsSyncLogEnable(), ProcessInputData() и syncDebugPrint().

◆ PlayerCheckDropRequest()

bool PlayerCheckDropRequest ( notnull InventoryLocation src,
float radius )
protected
2622 {
2623 bool result = true;
2624
2625 EntityAI ent = src.GetParent();
2626 if ( ent )
2627 {
2628 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2629 if (player)
2630 {
2631 if ( GetDayZPlayerOwner() != player )
2632 {
2633 if (player.IsAlive())
2634 {
2635 if (!player.IsRestrained() && !player.IsUnconscious())
2636 {
2637 return false;
2638 }
2639 }
2640 }
2641 }
2642 }
2643
2644 if ( result )
2645 {
2646 result = CheckDropRequest( GetManOwner(), src, radius);
2647 }
2648
2649 return result;
2650 }

Перекрестные ссылки GetDayZPlayerOwner().

Используется в ValidateDestroy().

◆ PlayerCheckRequestDst()

bool PlayerCheckRequestDst ( notnull InventoryLocation src,
notnull InventoryLocation dst,
float radius )
protected
2538 {
2539 bool result = true;
2540
2541 EntityAI ent = dst.GetParent();
2542 if ( ent )
2543 {
2544 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2545 if (player)
2546 {
2547 if ( GetDayZPlayerOwner() != player )
2548 {
2549 if (player.IsAlive())
2550 {
2551 if (!player.IsRestrained() && !player.IsUnconscious())
2552 {
2553 return false;
2554 }
2555 }
2556 }
2557 }
2558 }
2559
2560 if ( result )
2561 {
2562 result = CheckMoveToDstRequest( GetManOwner(), src, dst, radius);
2563 }
2564
2565 return result;
2566 }

Перекрестные ссылки GetDayZPlayerOwner().

Используется в ValidateSyncMove().

◆ PlayerCheckRequestSrc()

bool PlayerCheckRequestSrc ( notnull InventoryLocation src,
float radius )
protected
2507 {
2508 bool result = true;
2509
2510 EntityAI ent = src.GetParent();
2511 if ( ent )
2512 {
2513 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2514 if (player)
2515 {
2516 if ( GetDayZPlayerOwner() != player )
2517 {
2518 if (player.IsAlive())
2519 {
2520 if (!player.IsRestrained() && !player.IsUnconscious())
2521 {
2522 return false;
2523 }
2524 }
2525 }
2526 }
2527 }
2528
2529 if ( result )
2530 {
2531 result = CheckRequestSrc( GetManOwner(), src, radius);
2532 }
2533
2534 return result;
2535 }
bool CheckRequestSrc()
Definition Hand_Events.c:104

Перекрестные ссылки CheckRequestSrc() и GetDayZPlayerOwner().

Используется в ValidateDestroy(), ValidateSwap() и ValidateSyncMove().

◆ PlayerCheckSwapItemsRequest()

bool PlayerCheckSwapItemsRequest ( notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2,
float radius )
protected
2569 {
2570 bool result = true;
2571
2572 EntityAI ent = dst1.GetParent();
2574 if ( ent )
2575 {
2576 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2577 if (player)
2578 {
2579 if ( GetDayZPlayerOwner() != player )
2580 {
2581 if (player.IsAlive())
2582 {
2583 if (!player.IsRestrained() && !player.IsUnconscious())
2584 {
2585 return false;
2586 }
2587 }
2588 }
2589 }
2590 }
2591
2592 ent = dst2.GetParent();
2593 if ( ent )
2594 {
2595 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2596 if (player)
2597 {
2598 if ( GetDayZPlayerOwner() != player )
2599 {
2600 if (player.IsAlive())
2601 {
2602 if (!player.IsRestrained() && !player.IsUnconscious())
2603 {
2604 return false;
2605 }
2606 }
2607 }
2608 }
2609 }
2610
2611
2612 if ( result )
2613 {
2614 result = CheckSwapItemsRequest( GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2615 }
2616
2617 return result;
2618
2619 }
const float c_MaxItemDistanceRadius
anti-cheats
Definition Inventory.c:813

Перекрестные ссылки GameInventory::c_MaxItemDistanceRadius и GetDayZPlayerOwner().

Используется в ValidateSwap().

◆ PostWeaponEvent()

void PostWeaponEvent ( WeaponEventBase e)
protected
305 {
307 {
309
311 {
312 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
313 }
314 }
315 else
316 {
317 Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
318 }
319 }

Перекрестные ссылки Error(), LogManager::IsWeaponLogEnable(), m_DeferredWeaponEvent и wpnDebugPrint().

◆ ProcessInputData()

bool ProcessInputData ( ParamsReadContext ctx,
bool isJuncture,
bool isRemote )
protected
Возвращает
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

1564 {
1565 if (isJuncture && isRemote)
1566 {
1568 return false;
1569 }
1570
1571 int type = -1;
1572 if (!ctx.Read(type))
1573 {
1574 return false;
1575 }
1576
1578 validation.m_IsJuncture = isJuncture;
1579 validation.m_IsRemote = isRemote;
1580
1583
1584 switch (type)
1585 {
1586 case InventoryCommandType.USER_RESERVATION_CANCEL:
1587 if (!ValidateUserReservationCancel(serializer, validation))
1588 {
1589 return false;
1590 }
1591 break;
1592 case InventoryCommandType.SYNC_MOVE:
1594 {
1595 return false;
1596 }
1597 break;
1598 case InventoryCommandType.HAND_EVENT:
1600 {
1601 return false;
1602 }
1603 break;
1604 case InventoryCommandType.SWAP:
1606 {
1607 return false;
1608 }
1609 break;
1610 case InventoryCommandType.DESTROY:
1612 {
1613 return false;
1614 }
1615 break;
1616 default:
1617 break;
1618 }
1619
1620 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1621
1622 switch (validation.m_Result)
1623 {
1624 case InventoryValidationResult.FAILED:
1625 if (canSendJuncture)
1626 {
1628 if (!serializer.CanWrite())
1629 {
1633 }
1634
1635 serializer.Write(validation.m_Reason);
1636
1638 }
1639 break;
1640 case InventoryValidationResult.JUNCTURE:
1641 if (canSendJuncture)
1642 {
1644 //StoreInputForRemotes(isJuncture, isRemote, serializer);
1645 }
1646 else
1647 {
1648 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1649 }
1650 break;
1651 case InventoryValidationResult.SUCCESS:
1653 break;
1654 }
1655
1656 return true;
1657 }
InventoryValidationResult
Definition Inventory.c:30
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
Definition DayZPlayerInventory.c:762
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
Definition DayZPlayerInventory.c:982
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
Definition DayZPlayerInventory.c:1477
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
Definition DayZPlayerInventory.c:1207
bool StoreInputForRemotes(bool handling_juncture, bool remote, ParamsReadContext ctx)
Definition DayZPlayerInventory.c:1686
static const int SJ_INVENTORY
Definition DayZPlayerSyncJunctures.c:11
Serialization general interface. Serializer API works with:
Definition Serializer.c:56

Перекрестные ссылки Error(), GetDayZPlayerOwner(), DayZPlayerSyncJunctures::SJ_INVENTORY, DayZPlayerSyncJunctures::SJ_INVENTORY_FAILURE, StoreInputForRemotes(), ValidateDestroy(), ValidateHandEvent(), ValidateSwap() и ValidateSyncMove().

Используется в OnHandleStoredInputUserData(), OnHandleStoredJunctureData(), OnInputUserDataForRemote() и OnServerInventoryCommand().

◆ RemoveMovableOverride()

void RemoveMovableOverride ( EntityAI item)
protected
1660 {
1661 ItemBase itemIB = ItemBase.Cast(item);
1662 if (itemIB)
1663 itemIB.SetCanBeMovedOverride(false);
1664 }

Используется в ValidateHandEvent(), ValidateSwap() и ValidateSyncMove().

◆ ReserveInventory()

override bool ReserveInventory ( HumanInventory inventory)
23 {
24 if (!inventory.HasInventoryReservation(m_dst.GetItem(), m_dst))
25 {
26 if ( inventory.AddInventoryReservationEx(m_dst.GetItem(), m_dst, GameInventory.c_InventoryReservationTimeoutShortMS) )
27 {
28 return true;
29 }
30 }
31 return false;
32 }

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS и 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

2102 {
2103 if (GetGame().IsServer())
2104 {
2105 if (e.IsServerSideOnly())
2106 {
2107 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
2108 }
2109
2110 if (player.IsAlive())
2111 {
2112 InventoryLocation dst = e.GetDst();
2113 InventoryLocation src = e.GetSrc();
2114 if (src.IsValid() && dst.IsValid())
2115 {
2116 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
2117 {
2118#ifdef ENABLE_LOGGING
2120 {
2121 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
2122 }
2123#endif
2124
2125 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
2126 {
2127#ifdef ENABLE_LOGGING
2129 {
2130 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
2131 }
2132#endif
2133 }
2134 else
2135 {
2136#ifdef ENABLE_LOGGING
2138 {
2139 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
2140 }
2141#endif
2142 }
2143 }
2144
2145#ifdef ENABLE_LOGGING
2147 {
2148 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));
2149 }
2150#endif
2151
2155
2156#ifdef ENABLE_LOGGING
2158 {
2159 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));
2160 }
2161#endif
2162
2164 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
2165 }
2166 }
2167 else
2168 {
2169 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
2170 }
2171 }
2172 }
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:712

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutMS, InventoryLocation::DumpToStringNullSafe(), Error(), GetGame(), LogManager::IsSyncLogEnable(), InventoryInputUserData::SerializeHandEvent(), DayZPlayerSyncJunctures::SJ_INVENTORY и syncDebugPrint().

Используется в HandleHandEvent().

◆ StoreInputForRemotes()

bool StoreInputForRemotes ( bool handling_juncture,
bool remote,
ParamsReadContext ctx )
protected
1687 {
1688 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1689 {
1690 #ifdef ENABLE_LOGGING
1692 {
1693 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString() );
1694 }
1695 #endif
1696
1697 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1698 return true;
1699 }
1700
1701 return false;
1702 }
proto native DayZPlayerInstanceType GetInstanceType()

Перекрестные ссылки GetDayZPlayerOwner(), GetInstanceType(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable() и ToString().

◆ StoreInputUserData()

proto native void StoreInputUserData ( ParamsReadContext ctx)
protected

Используется в OnInputUserDataProcess().

◆ StoreJunctureData()

proto native void StoreJunctureData ( ParamsReadContext ctx)
protected

Используется в OnInventoryJunctureFromServer().

◆ SwapEntities()

override bool SwapEntities ( InventoryMode mode,
notnull EntityAI item1,
notnull EntityAI item2 )
protected
1896 {
1897 #ifdef ENABLE_LOGGING
1899 {
1900 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a" , "n/a", "SwapEntities", GetDayZPlayerOwner().ToString() );
1901 }
1902 #endif
1903
1905 if( mode == InventoryMode.LOCAL )
1906 {
1908 {
1909 LocationSwap(src1, src2, dst1, dst2);
1910 return true;
1911 }
1912 }
1913
1914 if(!super.SwapEntities(mode,item1,item2))
1915 {
1916 if(!m_DeferredEvent)
1917 {
1919 {
1921 if( m_DeferredEvent.ReserveInventory(this) )
1922 return true;
1923 }
1924 }
1926 return false;
1927 }
1928 return true;
1929 }

Перекрестные ссылки GetDayZPlayerOwner(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), m_DeferredEvent, GameInventory::MakeSrcAndDstForSwap() и ToString().

◆ SyncHandEventToRemote()

void SyncHandEventToRemote ( HandEventBase e)
protected
2268 {
2270 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2271 {
2273
2275 e.WriteToContext(ctx);
2276
2278 {
2279 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
2280 }
2281
2282 p.StoreInputForRemotes(ctx);
2283 }
2284 }
const int INPUT_UDT_HAND_REMOTE_EVENT
Definition _constants.c:14
Definition gameplay.c:143

Перекрестные ссылки GetDayZPlayerOwner(), hndDebugPrint(), INPUT_UDT_HAND_REMOTE_EVENT и LogManager::IsInventoryHFSMLogEnable().

Используется в 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

1705 {
1706 if (GetManOwner().IsAlive() == false)
1707 return super.TakeToDst(mode, src, dst);
1708
1709 #ifdef ENABLE_LOGGING
1711 {
1712 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1713 }
1714 #endif
1715
1716 switch (mode)
1717 {
1718 case InventoryMode.SERVER:
1719 if (RedirectToHandEvent(mode, src, dst))
1720 {
1721 #ifdef ENABLE_LOGGING
1723 {
1724 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1725 }
1726 #endif
1727
1728 return true;
1729 }
1730
1731
1732 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1733 {
1734 if (GetGame().AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1735 {
1736#ifdef ENABLE_LOGGING
1738 {
1739 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1740 }
1741#endif
1742 }
1743 else
1744 {
1745#ifdef ENABLE_LOGGING
1747 {
1748 Debug.InventoryMoveLog("Juncture failed", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1749 }
1750
1752 {
1753 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1754 }
1755#endif
1756
1757 return false;
1758 }
1759
1760 }
1761
1764
1766
1767#ifdef ENABLE_LOGGING
1769 {
1770 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));
1771 }
1772#endif
1773
1775 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1776 #ifdef ENABLE_LOGGING
1778 {
1779 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() );
1780 }
1781 #endif
1782 return true;
1783
1784 case InventoryMode.LOCAL:
1785 LocationSyncMoveEntity(src, dst);
1786 return true;
1787 }
1788 if (!super.TakeToDst(mode,src,dst))
1789 {
1790 if (!m_DeferredEvent)
1791 {
1793 if (m_DeferredEvent.ReserveInventory(this))
1794 return true;
1795 }
1796
1798 return false;
1799 }
1800 return true;
1801 }
static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
move
Definition InventoryInputUserData.c:5

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutMS, DeferredTakeToDst(), InventoryLocation::DumpToStringNullSafe(), GetDayZPlayerOwner(), GetGame(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), m_DeferredEvent, InventoryInputUserData::SerializeMove(), DayZPlayerSyncJunctures::SJ_INVENTORY, syncDebugPrint() и ToString().

Используется в 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

1478 {
1480
1481 if (validation.m_IsJuncture)
1482 {
1488
1489
1490 return true;
1491 }
1492
1494 src.ReadFromContext(ctx);
1495
1496 #ifdef ENABLE_LOGGING
1498 {
1499 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1500 }
1501 #endif
1502
1503 if (validation.m_IsRemote && !src.GetItem())
1504 {
1505 #ifdef ENABLE_LOGGING
1507 {
1508 Debug.InventoryMoveLog("Failed item not exist", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1509 }
1510 #endif
1511
1512 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
1513 return true;
1514 }
1515
1520 {
1521 #ifdef ENABLE_LOGGING
1523 {
1524 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1525 }
1526 #endif
1527
1528 return true;
1529 }
1530
1535 {
1536 #ifdef ENABLE_LOGGING
1538 {
1539 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1540 }
1541 #endif
1542
1543 return true;
1544 }
1545
1546 #ifdef ENABLE_LOGGING
1548 {
1549 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1550 }
1551 #endif
1552
1553 GetGame().ObjectDelete(src.GetItem());
1554
1555 validation.m_Result = InventoryValidationResult.SUCCESS;
1556 return true;
1557 }
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
Definition DayZPlayerInventory.c:2621
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Definition DayZPlayerInventory.c:2506

Перекрестные ссылки GameInventory::c_MaxItemDistanceRadius, InventoryLocation::DumpToStringNullSafe(), Error(), GetDayZPlayerOwner(), GetGame(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), PlayerCheckDropRequest(), PlayerCheckRequestSrc() и ToString().

Используется в 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

983 {
985 bool success = true;
986
987 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
988 e.ClearInventoryReservation();
989
993 e.m_IsRemote = validation.m_IsRemote;
994 e.m_IsJuncture = validation.m_IsJuncture;
995
996 EntityAI itemSrc = e.GetSrcEntity();
997 EntityAI itemDst = e.GetSecondSrcEntity();
998
999 #ifdef ENABLE_LOGGING
1001 {
1002 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1003 }
1004 #endif
1005
1006 if (validation.m_IsRemote && !e.GetSrcEntity())
1007 {
1009
1010 #ifdef ENABLE_LOGGING
1012 {
1013 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1014 }
1015 #endif
1016
1017 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1018
1019 return true;
1020 }
1021
1023 if (itemSrc)
1025 if (itemDst)
1027
1031 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1032 {
1033 #ifdef ENABLE_LOGGING
1035 {
1036 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1037 }
1038 #endif
1039
1040 if (!validation.m_IsRemote)
1041 {
1044 }
1045
1048
1049 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1050 {
1051 success = false;
1052 }
1053 else
1054 {
1055 return true;
1056 }
1057 }
1058
1059 if (success && !e.CheckRequestEx(validation))
1060 {
1061 #ifdef ENABLE_LOGGING
1063 {
1064 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1065 }
1066 #endif
1067
1069
1072
1073#ifdef ENABLE_LOGGING
1075 {
1076 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1077 }
1078#endif
1079
1082
1083 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1084 {
1085 success = false;
1086 }
1087 else
1088 {
1089 return true;
1090 }
1091 }
1092
1095 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1096 {
1097 #ifdef ENABLE_LOGGING
1099 {
1100 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1101 }
1102 #endif
1103
1105
1108
1109#ifdef ENABLE_LOGGING
1111 {
1112 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1113 }
1114#endif
1115
1118
1119 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1120 {
1121 success = false;
1122 }
1123 else
1124 {
1125 return true;
1126 }
1127 }
1128
1131
1133 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1134 {
1135 JunctureRequestResult result_ev = e.AcquireInventoryJunctureFromServer(GetDayZPlayerOwner());
1136 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1137 {
1138 #ifdef ENABLE_LOGGING
1140 {
1141 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1142 }
1143 #endif
1144
1146 }
1147 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1148 {
1149 #ifdef ENABLE_LOGGING
1151 {
1152 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1153 }
1154 #endif
1155
1158
1159 validation.m_Result = InventoryValidationResult.JUNCTURE;
1160
1161 if (itemSrc)
1163 if (itemDst)
1165 return true;
1166 }
1167 else
1168 {
1169 #ifdef ENABLE_LOGGING
1171 {
1172 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1173 }
1174 #endif
1175
1176 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1177 return true;
1178 }
1179 }
1180
1182 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1183 {
1184 CheckForRope(e.GetSrc(), e.GetDst());
1185 }
1186
1187 #ifdef ENABLE_LOGGING
1189 {
1190 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1191 }
1192 #endif
1193
1194 if (success)
1195 {
1196 validation.m_Result = InventoryValidationResult.SUCCESS;
1197 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1198 {
1200 //result = InventoryValidationResult.FAILURE;
1201 }
1202 }
1203
1204 return true;
1205 }
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Definition DayZPlayerInventory.c:1674
void RemoveMovableOverride(EntityAI item)
Definition DayZPlayerInventory.c:1659
JunctureRequestResult
Definition Hand_Events.c:28

Перекрестные ссылки CheckForRope(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetInstanceType(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), RemoveMovableOverride(), InventoryInputUserData::SerializeHandEvent() и syncDebugPrint().

Используется в 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

1208 {
1210
1213
1216
1217 bool skippedSwap = false;
1218 bool success = true;
1219
1220 src1.ReadFromContext(ctx);
1221 src2.ReadFromContext(ctx);
1222 dst1.ReadFromContext(ctx);
1223 dst2.ReadFromContext(ctx);
1224 ctx.Read(skippedSwap);
1225
1226 #ifdef ENABLE_LOGGING
1228 {
1229 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() );
1230 }
1231 #endif
1232
1233 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1234 {
1235 if (skippedSwap)
1236 {
1237 #ifdef ENABLE_LOGGING
1239 {
1240 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1241 }
1242 #endif
1243/*
1244 if (LogManager.IsSyncLogEnable())
1245 {
1246 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1247 }
1248*/
1249 }
1250 else
1251 {
1253
1254 #ifdef ENABLE_LOGGING
1256 {
1257 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1258 }
1259 #endif
1260
1261 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1262 }
1263
1264 return true;
1265 }
1266
1267 EnableMovableOverride(src1.GetItem());
1268 EnableMovableOverride(src2.GetItem());
1269
1274 {
1275#ifdef ENABLE_LOGGING
1277 {
1278 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1279 }
1280
1282 {
1283 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1284 }
1285#endif
1286
1287 RemoveMovableOverride(src1.GetItem());
1288 RemoveMovableOverride(src2.GetItem());
1289
1290 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1291 {
1292 success = false;
1293 }
1294 else
1295 {
1296 return true;
1297 }
1298 }
1299
1304 {
1305#ifdef ENABLE_LOGGING
1307 {
1308 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1309 }
1310
1312 {
1313 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1314 }
1315#endif
1316
1317 RemoveMovableOverride(src1.GetItem());
1318 RemoveMovableOverride(src2.GetItem());
1319
1320 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1321 {
1322 success = false;
1323 }
1324 else
1325 {
1326 return true;
1327 }
1328 }
1329
1334 {
1335#ifdef ENABLE_LOGGING
1337 {
1338 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1339 }
1340
1342 {
1343 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));
1344 }
1345#endif
1346
1347 RemoveMovableOverride(src1.GetItem());
1348 RemoveMovableOverride(src2.GetItem());
1349
1350 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1351 {
1352 success = false;
1353 }
1354 else
1355 {
1356 return true;
1357 }
1358 }
1359
1360 RemoveMovableOverride(src1.GetItem());
1361 RemoveMovableOverride(src2.GetItem());
1362
1363 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1364 {
1365 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1366 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1367 }
1368
1372 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1373 {
1374 #ifdef ENABLE_LOGGING
1375
1376 #ifdef DEVELOPER
1378 #endif
1379
1381 {
1382 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1383 }
1384 #endif
1385
1386 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1387 {
1388 success = false;
1389 }
1390 else
1391 {
1392 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));
1393 return true;
1394 }
1395 }
1396
1397 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1398 {
1399 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1400 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1401 }
1402
1403 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1404 {
1405 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));
1406 return true;
1407 }
1408
1410 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1411 {
1413 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1414 {
1415 #ifdef ENABLE_LOGGING
1417 {
1418 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1419 }
1420 #endif
1421
1423 }
1424 else if (success && result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1425 {
1426 #ifdef ENABLE_LOGGING
1428 {
1429 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1430 }
1431 #endif
1432
1433 validation.m_Result = InventoryValidationResult.JUNCTURE;
1434 EnableMovableOverride(src1.GetItem());
1435 EnableMovableOverride(src2.GetItem());
1436 return true;
1437 }
1438 else
1439 {
1440 #ifdef ENABLE_LOGGING
1442 {
1443 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1444 }
1445 #endif
1446
1447 validation.m_Result = InventoryValidationResult.FAILED;
1448 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1449 return true;
1450 }
1451 }
1452
1453 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
1454 {
1455 ClearInventoryReservationEx(dst1.GetItem(),dst1);
1456 ClearInventoryReservationEx(dst2.GetItem(),dst2);
1457 }
1458
1459 #ifdef ENABLE_LOGGING
1461 {
1462 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1463 }
1464 #endif
1465 if (success)
1466 {
1467 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1468
1469 ctx = new ScriptInputUserData();
1471
1472 validation.m_Result = InventoryValidationResult.SUCCESS;
1473 }
1474 return true;
1475 }
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Definition DayZPlayerInventory.c:2568
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition Junctures.c:35
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:664
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap
Definition InventoryInputUserData.c:37

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, GameInventory::c_MaxItemDistanceRadius, GameInventory::CanForceSwapEntitiesEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetInstanceType(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), PlayerCheckRequestSrc(), PlayerCheckSwapItemsRequest(), RemoveMovableOverride(), InventoryInputUserData::SerializeSwap(), syncDebugPrint(), ToString() и TryAcquireTwoInventoryJuncturesFromServer().

Используется в 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

763 {
765
768 bool success = true;
769
770 src.ReadFromContext(ctx);
771 dst.ReadFromContext(ctx);
772
773 #ifdef ENABLE_LOGGING
775 {
776 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
777 }
778 #endif
779
780 if (validation.m_IsRemote && (!src.GetItem() || !dst.GetItem()))
781 {
783
784#ifdef ENABLE_LOGGING
786 {
787 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
788 }
789
791 {
792 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
793 }
794#endif
795
796 return true;
797 }
798
799 EnableMovableOverride(src.GetItem());
800
805 {
807
808#ifdef ENABLE_LOGGING
810 {
811 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
812 }
813
815 {
816 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
817 }
818#endif
819
820 RemoveMovableOverride(src.GetItem());
821
822 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
823 {
824 success = false;
825 }
826 else
827 {
828 return true;
829 }
830 }
831
836 {
837#ifdef ENABLE_LOGGING
839 {
840 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
841 }
842
844 {
845 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
846 }
847#endif
848
849 RemoveMovableOverride(src.GetItem());
850
851 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
852 {
853 success = false;
854 }
855 else
856 {
857 return true;
858 }
859 }
860
861 RemoveMovableOverride(src.GetItem());
862
863#ifdef ENABLE_LOGGING
865 {
866 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));
867 }
868#endif
869
871 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
872 {
874 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
875 {
876 #ifdef ENABLE_LOGGING
878 {
879 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
880 }
881 #endif
882 if (success)
883 {
885
886 LocationSyncMoveEntity(src, dst);
887
888 validation.m_Result = InventoryValidationResult.SUCCESS;
889 }
890 return true;
891 }
892 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
893 {
894 #ifdef ENABLE_LOGGING
896 {
897 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
898 }
899 #endif
900
902 {
903 #ifdef ENABLE_LOGGING
904
905 #ifdef DEVELOPER
907 #endif
908
910 {
911 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
912 }
913 #endif
914 validation.m_Result = InventoryValidationResult.FAILED;
915 return true;
916 }
917
918 validation.m_Result = InventoryValidationResult.JUNCTURE;
919 EnableMovableOverride(src.GetItem());
920 return true;
921 }
922 else
923 {
924 #ifdef ENABLE_LOGGING
926 {
927 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
928 }
929 #endif
930
931 validation.m_Result = InventoryValidationResult.FAILED;
932 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
933 return true;
934 }
935 }
936
937 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
938 {
939 ClearInventoryReservationEx(dst.GetItem(), dst);
940 }
941
943 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
944 {
946 }
947
951 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
952 {
953 #ifdef ENABLE_LOGGING
954
955 #ifdef DEVELOPER
957 #endif
958
960 {
961 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
962 }
963 #endif
964
965 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
966 return true;
967 }
968
969 #ifdef ENABLE_LOGGING
971 {
972 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
973 }
974 #endif
975
976 LocationSyncMoveEntity(src, dst);
977
978 validation.m_Result = InventoryValidationResult.SUCCESS;
979 return true;
980 }
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Definition DayZPlayerInventory.c:2537
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Junctures.c:2
float GetTime()
Definition NotificationSystem.c:35
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...
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Inventory.c:378

Перекрестные ссылки GameInventory::c_MaxItemDistanceRadius, CheckForRope(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), GetInstanceType(), GetTime(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), GameInventory::LocationCanMoveEntity(), GameInventory::LocationCanMoveEntitySyncCheck(), PlayerCheckRequestDst(), PlayerCheckRequestSrc(), RemoveMovableOverride(), syncDebugPrint(), ToString() и TryAcquireInventoryJunctureFromServer().

Используется в ProcessInputData().

Переменные

◆ m_DeferredEvent

◆ m_DeferredPostedHandEvent

ref HandEventBase m_DeferredPostedHandEvent = NULL
protected

Используется в CancelHandEvent() и IsProcessing().

◆ m_DeferredWeaponEvent

ref WeaponEventBase m_DeferredWeaponEvent = NULL
protected

deferred hand event

Используется в CancelWeaponEvent(), DeferredWeaponFailed(), HandleWeaponEvents() и PostWeaponEvent().

◆ m_DeferredWeaponTimer

ref Timer m_DeferredWeaponTimer = new Timer

Используется в CancelWeaponEvent() и HandleWeaponEvents().

◆ m_dst

◆ m_dst1

Используется в DeferredForceSwapEntities().

◆ m_dst2

Используется в DeferredForceSwapEntities().

◆ m_event

◆ m_FSwapping

ref HandAnimatedForceSwapping m_FSwapping
protected

Используется в Init().

◆ m_FSwappingInst

ref HandAnimatedForceSwapping_Inst m_FSwappingInst
protected

Используется в Init().

◆ m_item1

Используется в DeferredForceSwapEntities().

◆ m_item2

EntityAI m_item2

Используется в DeferredForceSwapEntities().

◆ m_MovingTo

ref HandAnimatedMovingToAtt m_MovingTo
protected

Используется в Init().

◆ m_src

Используется в DeferredTakeToDst().

◆ m_Swapping

ref HandAnimatedSwapping m_Swapping
protected

Используется в Init().

◆ m_Taking

ref HandAnimatedTakingFromAtt m_Taking
protected

deferred weapon event

Используется в Init().