Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
dayzplayerinventory.c
Go to the documentation of this file.
1 //Post event containers
3 {
4  InventoryMode m_mode;
5  bool ReserveInventory(HumanInventory inventory){return true;}
6  void ClearInventoryReservation(HumanInventory inventory){}
7 }
8 
9 
11 {
14 
16  {
17  m_mode = mode;
18  m_src = src;
19  m_dst = dst;
20  }
21 
22  override bool ReserveInventory(HumanInventory inventory)
23  {
24  if( !inventory.AddInventoryReservationEx(m_dst.GetItem(), m_dst, GameInventory.c_InventoryReservationTimeoutShortMS) )
25  {
26  return false;
27  }
28  return true;
29  }
30 
31  override void ClearInventoryReservation(HumanInventory inventory)
32  {
33  inventory.ClearInventoryReservationEx(m_dst.GetItem(), m_dst);
34  }
35 }
36 
38 {
39  EntityAI m_item1;
40  EntityAI m_item2;
41  ref InventoryLocation m_dst1;
42  ref InventoryLocation m_dst2;
43 
44  void DeferredSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
45  {
46  m_mode = mode;
47  m_item1 = item1;
48  m_item2 = item2;
49  m_dst1 = dst1;
50  m_dst2 = dst2;
51  }
52 
53  override bool ReserveInventory(HumanInventory inventory)
54  {
55  if( !inventory.AddInventoryReservationEx(m_item1, m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS) )
56  {
57  return false;
58  }
59  if( !inventory.AddInventoryReservationEx(m_item2, m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS) )
60  {
61  inventory.ClearInventoryReservationEx(m_item1, m_dst1);
62  return false;
63  }
64  return true;
65  }
66 
67  override void ClearInventoryReservation(HumanInventory inventory)
68  {
69  inventory.ClearInventoryReservationEx(m_item1, m_dst1);
70  inventory.ClearInventoryReservationEx(m_item2, m_dst2);
71  }
72 }
73 
75 {
80 
81  void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
82  {
83  m_mode = mode;
84  m_item1 = item1;
85  m_item2 = item2;
86  m_dst1 = dst1;
87  m_dst2 = dst2;
88  }
89 
90  override bool ReserveInventory(HumanInventory inventory)
91  {
92  if( !inventory.AddInventoryReservationEx(m_item1, m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS) )
93  {
94  return false;
95  }
96  if( !inventory.AddInventoryReservationEx(m_item2, m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS) )
97  {
98  inventory.ClearInventoryReservationEx(m_item1, m_dst1);
99  return false;
100  }
101  return true;
102  }
103 
104  override void ClearInventoryReservation(HumanInventory inventory)
105  {
106  inventory.ClearInventoryReservationEx(m_item1, m_dst1);
107  inventory.ClearInventoryReservationEx(m_item2, m_dst2);
108  }
109 }
110 
112 {
113  ref HandEventBase m_event;
115  {
116  m_mode = mode;
117  m_event = e;
118  }
119 
120  override bool ReserveInventory(HumanInventory inventory)
121  {
122  return m_event.ReserveInventory();
123  }
124 
125  override void ClearInventoryReservation(HumanInventory inventory)
126  {
127  m_event.ClearInventoryReservation();
128  }
129 }
130 
131 
136 {
137  ref DeferredEvent m_DeferredEvent = NULL;
139  //protected ref HandEventBase m_PostedHandEvent = NULL; /// deferred hand event
140 
141 
144  // states with animations
145  protected ref HandAnimatedTakingFromAtt m_Taking;
146  protected ref HandAnimatedMovingToAtt m_MovingTo;
147  protected ref HandAnimatedSwapping m_Swapping;
148  protected ref HandAnimatedForceSwapping m_FSwapping;
149  protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst;
150 
152  {
153  }
154 
155  DayZPlayer GetDayZPlayerOwner () { return DayZPlayer.Cast(GetInventoryOwner()); }
156 
158  {
159  DayZPlayer player;
160  if (!Class.CastTo(player, GetInventoryOwner()))
161  {
162  return false;
163  }
164 
165  return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
166  }
167 
168  bool IsOwner()
169  {
170  DayZPlayer player;
171  if (!Class.CastTo(player, GetInventoryOwner()))
172  {
173  return false;
174  }
175 
176  return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
177  }
178 
179  bool IsProxy()
180  {
181  DayZPlayer player;
182  if (!Class.CastTo(player, GetInventoryOwner()))
183  {
184  return false;
185  }
186 
187  return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
188  }
189 
190  override void Init ()
191  {
192  if (LogManager.IsInventoryHFSMLogEnable())
193  {
194  hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
195  }
196 
197  CreateStableStates(); // stable states needs to be created first
198 
199  m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
200  m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
201  m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
202  m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
203  m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
204 
205  // events
206  HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
207  HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
208  HandEventBase __T__ = new HandEventTake;
209  HandEventBase __M__ = new HandEventMoveTo;
210  HandEventBase __W__ = new HandEventSwap;
211  //HandEventBase __D__ = new HandEventDropping;
212  HandEventBase __Xd_ = new HandEventDestroyed;
213  HandEventBase __F__ = new HandEventForceSwap;
214 
215  // setup transitions
216  m_FSM.AddTransition(new HandTransition( m_Empty , __T__, m_Taking, NULL, new HandSelectAnimationOfTakeToHandsEvent(GetManOwner())));
217  m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
218  m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Equipped, null, null));
219  m_FSM.AddTransition(new HandTransition( m_Taking , __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
220  m_Taking.AddTransition(new HandTransition( m_Taking.m_Hide, _abt_, m_Empty));
221  m_Taking.AddTransition(new HandTransition( m_Taking.m_Show, _abt_, m_Equipped));
222 
223  m_FSM.AddTransition(new HandTransition( m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
224  m_FSM.AddTransition(new HandTransition( m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
225  m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
226  m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Empty , null, null));
227  m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Hide, _abt_, m_Equipped));
228  m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Show, _abt_, m_Empty));
229 
230  m_FSM.AddTransition(new HandTransition( m_Equipped, __W__, m_Swapping, NULL, new HandSelectAnimationOfSwapInHandsEvent(GetManOwner())));
231  m_FSM.AddTransition(new HandTransition( m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
232  m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
233  m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Equipped, null, null));
234  m_FSM.AddTransition(new HandTransition( m_Swapping, _abt_, m_Equipped, null, null));
235 
236  m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd( new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()) ) ));
237  m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
238  m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
239  m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
240  m_FSM.AddTransition(new HandTransition( m_FSwappingInst, _abt_, m_Equipped, null, null));
241 
242  m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwapping, NULL, new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner())));
243  m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
244  m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
245  m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
246  m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Start, _abt_, m_Equipped));
247  m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Hide, _abt_, m_Empty));
248  m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Show, _abt_, m_Equipped));
249 
250  super.Init(); // initialize ordinary human fsm (no anims)
251  }
252 
258  {
260  //m_postedHandEvent = null;
261  }
262 
264  {
265  m_DeferredWeaponEvent = null;
266  m_DeferredWeaponTimer.Stop();
267  }
268 
270  {
271  HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
272 
273  Weapon_Base weapon;
274  Class.CastTo(weapon, GetEntityInHands());
275 
276  if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
277  {
278  if (LogManager.IsWeaponLogEnable())
279  {
280  wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
281  }
282 
283  weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
284  }
285  }
286 
292  {
293  if (m_DeferredWeaponEvent == NULL)
294  {
296 
297  if (LogManager.IsWeaponLogEnable())
298  {
299  wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
300  }
301  }
302  else
303  {
304  Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
305  }
306  }
307 
309  {
310  Weapon_Base weapon;
311  Class.CastTo(weapon, GetEntityInHands());
312 
313  string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
314 
315  string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
316  if (weapon)
317  {
318  secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
319  secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
320  for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
321  {
322  secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
323  secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
324  if (i < weapon.GetMuzzleCount() - 1)
325  secondPart += " | ";
326  }
327  }
328 
329  Error(firstPart + secondPart);
331  }
332 
333  void HandleWeaponEvents (float dt, out bool exitIronSights)
334  {
335  HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
336 
337  Weapon_Base weapon;
338  Class.CastTo(weapon, GetEntityInHands());
339 
340  if (hcw && weapon && weapon.CanProcessWeaponEvents())
341  {
342  weapon.GetCurrentState().OnUpdate(dt);
343 
344  if (LogManager.IsWeaponLogEnable())
345  {
346  wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
347  }
348 
349  if (!weapon.IsIdle())
350  {
351  while (true)
352  {
353  int weaponEventId = hcw.IsEvent();
354  if (weaponEventId == -1)
355  {
356  break;
357  }
358 
359  if (weaponEventId == WeaponEvents.CHANGE_HIDE)
360  {
361  break;
362  }
363 
364  WeaponEventBase anim_event = WeaponAnimEventFactory(weaponEventId, GetDayZPlayerOwner(), NULL);
365 
366  if (LogManager.IsWeaponLogEnable())
367  {
368  wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
369  }
370 
371  if (anim_event != NULL)
372  {
373  weapon.ProcessWeaponEvent(anim_event);
374  }
375  }
376 
377  if (hcw.IsActionFinished())
378  {
379  if (weapon.IsWaitingForActionFinish())
380  {
381  if (LogManager.IsWeaponLogEnable())
382  {
383  wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
384  }
385 
386  weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
387  }
388  else
389  {
390  if (LogManager.IsWeaponLogEnable())
391  {
392  wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
393  }
394 
395  weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
396  }
397  }
398  }
399 
401  {
402  if (LogManager.IsWeaponLogEnable())
403  {
404  wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
405  }
406 
407  if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
408  {
409  exitIronSights = true;
410 
411  if (LogManager.IsWeaponLogEnable())
412  {
413  fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
414  }
415 
416  m_DeferredWeaponEvent = NULL;
417  m_DeferredWeaponTimer.Stop();
418  }
419  else if (!m_DeferredWeaponTimer.IsRunning())
420  {
421  m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
422  }
423  }
424  }
425  }
426 
427  void HandleInventory(float dt)
428  {
429  HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
430 
431  EntityAI ih = GetEntityInHands();
432  Weapon_Base weapon;
433  Class.CastTo(weapon, ih);
434 
435  if (hcw)
436  {
437  m_FSM.GetCurrentState().OnUpdate(dt);
438 
439  #ifdef DEVELOPER
440  if (LogManager.IsInventoryHFSMLogEnable())
441  {
442  hndDebugSpamALot("[hndfsm] HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
443  }
444  #endif
445 
446  if ( !m_FSM.GetCurrentState().IsIdle() || !m_FSM.IsRunning())
447  {
448  while (true)
449  {
450  int weaponEventId = hcw.IsEvent();
451  if (weaponEventId == -1)
452  {
453  break;
454  }
455 
456  HandEventBase anim_event = HandAnimEventFactory(weaponEventId, GetManOwner(), NULL);
457 
458  #ifdef DEVELOPER
459  if (LogManager.IsInventoryHFSMLogEnable())
460  {
461  hndDebugPrint("[hndfsm] HandleInventory: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
462  }
463  #endif
464 
465  if (anim_event != NULL)
466  {
467  SyncHandEventToRemote(anim_event);
468  ProcessHandEvent(anim_event);
469  }
470  }
471 
472  if (hcw.IsActionFinished())
473  {
474  if (m_FSM.GetCurrentState().IsWaitingForActionFinish())
475  {
476  #ifdef DEVELOPER
477  if (LogManager.IsInventoryHFSMLogEnable())
478  {
479  hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + m_FSM.GetCurrentState());
480  }
481  #endif
482 
483  HandEventBase fin_event = new HandEventHumanCommandActionFinished(GetManOwner());
484  SyncHandEventToRemote(fin_event);
485  ProcessHandEvent(fin_event);
486  }
487  else
488  {
489  #ifdef DEVELOPER
490  if (LogManager.IsInventoryHFSMLogEnable())
491  {
492  hndDebugPrint("[hndfsm] Hand-Weapon event: ABORT! notifying running state=" + m_FSM.GetCurrentState());
493  }
494  #endif
495 
496  HandEventBase abt_event = new HandEventHumanCommandActionAborted(GetManOwner());
497  SyncHandEventToRemote(abt_event);
498  ProcessHandAbortEvent(abt_event);
499  //m_FSM.ProcessHandAbortEvent(new WeaponEventHumanCommandActionAborted(GetManOwner()));
500  }
501  }
502  }
503  }
504  }
505 
506 
508 
515  {
516  int tmp = -1;
517  ctx.Read(tmp);
518 
519  if (LogManager.IsSyncLogEnable())
520  {
521  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store Juncture packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
522  }
523 
524  StoreJunctureData(ctx);
525 
526  return true;
527  }
528 
530 
537  {
538 /* InventoryLocation il = new InventoryLocation;
539  if (!il.ReadFromContext(ctx) )
540  return false;
541 
542  InventoryLocation il_current = new InventoryLocation;
543 
544  EntityAI item = il.GetItem();
545  item.GetInventory().GetCurrentInventoryLocation(il_current);
546 
547  if( !il_current.CompareLocationOnly(il))
548  {
549  LocationMoveEntity(il_current,il);
550  }*/
551  return true;
552  }
553 
555 
562  {
576  if (GetGame().IsDedicatedServer())
577  {
578  return;
579  }
580 
581  int udtIdentifier = -1;
582  if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
583  {
584  return;
585  }
586 
590 
591  InventoryCommandType type = -1;
592  if (!ctx.Read(type))
593  {
594  return;
595  }
596 
597  switch (type)
598  {
599  case InventoryCommandType.SYNC_MOVE:
600  {
601  src.ReadFromContext(ctx);
602  dst.ReadFromContext(ctx);
603  break;
604  }
605  case InventoryCommandType.HAND_EVENT:
606  {
607  HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
608  src = e.GetSrc();
609  dst = e.GetDst();
610  break;
611  }
612  case InventoryCommandType.SWAP:
613  {
614  src.ReadFromContext(ctx);
615  temp.ReadFromContext(ctx);
616  dst.ReadFromContext(ctx);
617  temp.ReadFromContext(ctx);
618  break;
619  }
620  case InventoryCommandType.FORCESWAP:
621  {
622  break;
623  }
624  case InventoryCommandType.DESTROY:
625  {
626  src.ReadFromContext(ctx);
627  break;
628  }
629  }
630 
632  if (!ctx.Read(reason))
633  {
634  reason = InventoryValidationReason.UNKNOWN;
635  }
636 
637  OnInventoryFailure(type, reason, src, dst);
638  }
639 
641  {
642  if (reason == InventoryValidationReason.DROP_PREVENTED)
643  {
645  return;
646  }
647 
648  }
649 
655  {
656  int tmp = -1;
657  ctx.Read(tmp);
658 
659  if (LogManager.IsSyncLogEnable())
660  {
661  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
662  }
663 
665  ProcessInputData(ctx, true, false);
666  }
667 
672  proto native void StoreJunctureData(ParamsReadContext ctx);
674 
675 
677 
684  {
685  if (LogManager.IsSyncLogEnable())
686  {
687  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
688  }
689 
690  StoreInputUserData(ctx);
691  return true;
692  }
693 
699  {
700  int tmp = -1;
701  ctx.Read(tmp);
702 
703  if (LogManager.IsSyncLogEnable())
704  {
705  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
706  }
707 
708  ProcessInputData(ctx, false, false);
709  }
710 
714  proto native void StoreInputUserData(ParamsReadContext ctx);
716 
718  {
719  if (LogManager.IsSyncLogEnable())
720  {
721  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
722  }
723 
724  ProcessInputData(ctx, false, true);
725  }
726 
728  {
729  if (LogManager.IsSyncLogEnable())
730  {
731  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
732  }
733 
734  ProcessInputData(ctx, true, true);
735  }
736 
737  bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
738  {
740 
743 
744  src.ReadFromContext(ctx);
745  dst.ReadFromContext(ctx);
746 
747  #ifdef DEVELOPER
748  if (LogManager.IsInventoryMoveLogEnable())
749  {
750  Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
751  }
752  #endif
753 
754  if (validation.m_IsRemote && (!src.GetItem() || !dst.GetItem()))
755  {
757 
758  #ifdef DEVELOPER
759  if (LogManager.IsInventoryMoveLogEnable())
760  {
761  Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
762  }
763  #endif
764 
765  if (LogManager.IsSyncLogEnable())
766  {
767  syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
768  }
769 
770  return true;
771  }
772 
773  EnableMovableOverride(src.GetItem());
774 
778  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
779  {
781 
782  #ifdef DEVELOPER
783  if (LogManager.IsInventoryMoveLogEnable())
784  {
785  Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
786  }
787  #endif
788 
789  if (LogManager.IsSyncLogEnable())
790  {
791  syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
792  }
793 
794  RemoveMovableOverride(src.GetItem());
795  return true;
796  }
797 
801  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
802  {
803  #ifdef DEVELOPER
804  if (LogManager.IsInventoryMoveLogEnable())
805  {
806  Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
807  }
808  #endif
809 
810  if (LogManager.IsSyncLogEnable())
811  {
812  syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
813  }
814 
815  RemoveMovableOverride(src.GetItem());
816  return true;
817  }
818 
819  RemoveMovableOverride(src.GetItem());
820 
821  if (LogManager.IsSyncLogEnable())
822  {
823  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));
824  }
825 
827  if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
828  {
830  if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
831  {
832  #ifdef DEVELOPER
833  if (LogManager.IsInventoryMoveLogEnable())
834  {
835  Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
836  }
837  #endif
838 
840 
841  LocationSyncMoveEntity(src, dst);
842 
843  validation.m_Result = InventoryValidationResult.SUCCESS;
844  return true;
845  }
846  else if (result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
847  {
848  #ifdef DEVELOPER
849  if (LogManager.IsInventoryMoveLogEnable())
850  {
851  Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
852  }
853  #endif
854 
855  if (!GameInventory.LocationCanMoveEntity(src, dst))
856  {
857  #ifdef DEVELOPER
858  DumpInventoryDebug();
859 
860  if (LogManager.IsInventoryMoveLogEnable())
861  {
862  Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
863  }
864  #endif
865 
866  return true;
867  }
868 
869  validation.m_Result = InventoryValidationResult.JUNCTURE;
870  EnableMovableOverride(src.GetItem());
871  return true;
872  }
873  else if (result_mv == JunctureRequestResult.JUNCTURE_DENIED)
874  {
875  #ifdef DEVELOPER
876  if ( LogManager.IsInventoryMoveLogEnable() )
877  {
878  Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
879  }
880  #endif
881 
882  validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
883  return true;
884  }
885  else
886  {
887  Error("[syncinv] HandleInputData: unexpected return code from AcquireInventoryJunctureFromServer");
888 
889  return true;
890  }
891  }
892 
893  if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
894  {
895  ClearInventoryReservationEx(dst.GetItem(), dst);
896  }
897 
899  if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
900  {
901  CheckForRope(src, dst);
902  }
903 
907  if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
908  {
909  #ifdef DEVELOPER
910  DumpInventoryDebug();
911 
912  if (LogManager.IsInventoryMoveLogEnable())
913  {
914  Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
915  }
916  #endif
917 
918  Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
919  return true;
920  }
921 
922  #ifdef DEVELOPER
923  if (LogManager.IsInventoryMoveLogEnable())
924  {
925  Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
926  }
927  #endif
928 
929  LocationSyncMoveEntity(src, dst);
930 
931  validation.m_Result = InventoryValidationResult.SUCCESS;
932  return true;
933  }
934 
936  {
937  InventoryCommandType type = InventoryCommandType.HAND_EVENT;
938 
939  HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
940  e.ClearInventoryReservation();
941 
945  e.m_IsRemote = validation.m_IsRemote;
946  e.m_IsJuncture = validation.m_IsJuncture;
947 
948  EntityAI itemSrc = e.GetSrcEntity();
949  EntityAI itemDst = e.GetSecondSrcEntity();
950 
951  #ifdef DEVELOPER
952  if (LogManager.IsInventoryMoveLogEnable())
953  {
954  Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
955  }
956  #endif
957 
958  if (validation.m_IsRemote && !e.GetSrcEntity())
959  {
961 
962  #ifdef DEVELOPER
963  if (LogManager.IsInventoryMoveLogEnable())
964  {
965  Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
966  }
967  #endif
968 
969  Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
970 
971  return true;
972  }
973 
975  if (itemSrc)
976  RemoveMovableOverride(itemSrc);
977  if (itemDst)
978  RemoveMovableOverride(itemDst);
979 
983  if (!validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
984  {
985  #ifdef DEVELOPER
986  if (LogManager.IsInventoryMoveLogEnable())
987  {
988  Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
989  }
990  #endif
991 
992  if (!validation.m_IsRemote)
993  {
994  ctx = new ScriptInputUserData;
995  InventoryInputUserData.SerializeHandEvent(ctx, e);
996  }
997 
998  RemoveMovableOverride(itemSrc);
999  RemoveMovableOverride(itemDst);
1000 
1001  return true;
1002  }
1003 
1004  if (!e.CheckRequestEx(validation))
1005  {
1006  #ifdef DEVELOPER
1007  if (LogManager.IsInventoryMoveLogEnable())
1008  {
1009  Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1010  }
1011  #endif
1012 
1014 
1015  ctx = new ScriptInputUserData;
1016  InventoryInputUserData.SerializeHandEvent(ctx, e);
1017 
1018  if (LogManager.IsSyncLogEnable())
1019  {
1020  syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1021  }
1022 
1023  RemoveMovableOverride(itemSrc);
1024  RemoveMovableOverride(itemDst);
1025  return true;
1026  }
1027 
1030  if (!validation.m_IsRemote && !e.CanPerformEventEx(validation))
1031  {
1032  #ifdef DEVELOPER
1033  if (LogManager.IsInventoryMoveLogEnable())
1034  {
1035  Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1036  }
1037  #endif
1038 
1040 
1041  ctx = new ScriptInputUserData;
1042  InventoryInputUserData.SerializeHandEvent(ctx, e);
1043 
1044  if (LogManager.IsSyncLogEnable())
1045  {
1046  syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1047  }
1048 
1049  RemoveMovableOverride(itemSrc);
1050  RemoveMovableOverride(itemDst);
1051  return true;
1052  }
1053 
1054  RemoveMovableOverride(itemSrc);
1055  RemoveMovableOverride(itemDst);
1056 
1058  if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1059  {
1060  JunctureRequestResult result_ev = e.AcquireInventoryJunctureFromServer(GetDayZPlayerOwner());
1061  if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1062  {
1063  #ifdef DEVELOPER
1064  if (LogManager.IsInventoryMoveLogEnable())
1065  {
1066  Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1067  }
1068  #endif
1069 
1071  }
1072  else if (result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1073  {
1074  #ifdef DEVELOPER
1075  if (LogManager.IsInventoryMoveLogEnable())
1076  {
1077  Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1078  }
1079  #endif
1080 
1081  ctx = new ScriptInputUserData;
1082  InventoryInputUserData.SerializeHandEvent(ctx, e);
1083 
1084  validation.m_Result = InventoryValidationResult.JUNCTURE;
1085 
1086  if (itemSrc)
1087  EnableMovableOverride(itemSrc);
1088  if (itemDst)
1089  EnableMovableOverride(itemDst);
1090  return true;
1091  }
1092  else if (result_ev == JunctureRequestResult.JUNCTURE_DENIED)
1093  {
1094  #ifdef DEVELOPER
1095  if (LogManager.IsInventoryMoveLogEnable())
1096  {
1097  Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1098  }
1099  #endif
1100 
1101  validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1102  return true;
1103  }
1104  else
1105  {
1106  Error("[syncinv] HandleInputData: unexpected return code from AcquireInventoryJunctureFromServer");
1107 
1108  return true;
1109  }
1110  }
1111 
1113  if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1114  {
1115  CheckForRope(e.GetSrc(), e.GetDst());
1116  }
1117 
1118  #ifdef DEVELOPER
1119  if (LogManager.IsInventoryMoveLogEnable())
1120  {
1121  Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1122  }
1123  #endif
1124 
1125  validation.m_Result = InventoryValidationResult.SUCCESS;
1126  if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1127  {
1129  //result = InventoryValidationResult.FAILURE;
1130  }
1131 
1132  return true;
1133  }
1134 
1135  bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
1136  {
1138 
1141 
1144 
1145  bool skippedSwap = false;
1146 
1147  src1.ReadFromContext(ctx);
1148  src2.ReadFromContext(ctx);
1149  dst1.ReadFromContext(ctx);
1150  dst2.ReadFromContext(ctx);
1151  ctx.Read(skippedSwap);
1152 
1153  #ifdef DEVELOPER
1154  if (LogManager.IsInventoryMoveLogEnable())
1155  {
1156  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() );
1157  }
1158  #endif
1159 
1160  if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1161  {
1162  if (skippedSwap)
1163  {
1164  #ifdef DEVELOPER
1165  if (LogManager.IsInventoryMoveLogEnable())
1166  {
1167  Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1168  }
1169  #endif
1170 /*
1171  if (LogManager.IsSyncLogEnable())
1172  {
1173  syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1174  }
1175 */
1176  }
1177  else
1178  {
1180 
1181  #ifdef DEVELOPER
1182  if (LogManager.IsInventoryMoveLogEnable())
1183  {
1184  Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1185  }
1186  #endif
1187 
1188  Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1189  }
1190 
1191  return true;
1192  }
1193 
1194  EnableMovableOverride(src1.GetItem());
1195  EnableMovableOverride(src2.GetItem());
1196 
1200  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src1, GameInventory.c_MaxItemDistanceRadius))
1201  {
1202  #ifdef DEVELOPER
1203  if (LogManager.IsInventoryMoveLogEnable())
1204  {
1205  Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1206  }
1207  #endif
1208 
1209  if (LogManager.IsSyncLogEnable())
1210  {
1211  syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1212  }
1213 
1214  RemoveMovableOverride(src1.GetItem());
1215  RemoveMovableOverride(src2.GetItem());
1216  return true;
1217  }
1218 
1222  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src2, GameInventory.c_MaxItemDistanceRadius))
1223  {
1224  #ifdef DEVELOPER
1225  if (LogManager.IsInventoryMoveLogEnable())
1226  {
1227  Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1228  }
1229  #endif
1230 
1231  if (LogManager.IsSyncLogEnable())
1232  {
1233  syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1234  }
1235 
1236  RemoveMovableOverride(src1.GetItem());
1237  RemoveMovableOverride(src2.GetItem());
1238  return true;
1239  }
1240 
1244  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckSwapItemsRequest(src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius))
1245  {
1246  #ifdef DEVELOPER
1247  if (LogManager.IsInventoryMoveLogEnable())
1248  {
1249  Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1250  }
1251  #endif
1252 
1253  if (LogManager.IsSyncLogEnable())
1254  {
1255  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));
1256  }
1257 
1258  RemoveMovableOverride(src1.GetItem());
1259  RemoveMovableOverride(src2.GetItem());
1260  return true;
1261  }
1262 
1263  RemoveMovableOverride(src1.GetItem());
1264  RemoveMovableOverride(src2.GetItem());
1265 
1266  if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1267  {
1268  ClearInventoryReservationEx(dst1.GetItem(), dst1);
1269  ClearInventoryReservationEx(dst2.GetItem(), dst2);
1270  }
1271 
1275  if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1276  {
1277  #ifdef DEVELOPER
1278  DumpInventoryDebug();
1279 
1280  if (LogManager.IsInventoryMoveLogEnable())
1281  {
1282  Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1283  }
1284  #endif
1285 
1286  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));
1287  return true;
1288  }
1289 
1290  if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1291  {
1292  AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1293  AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1294  }
1295 
1296  if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1297  {
1298  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));
1299  return true;
1300  }
1301 
1303  if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1304  {
1306  if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1307  {
1308  #ifdef DEVELOPER
1309  if (LogManager.IsInventoryMoveLogEnable())
1310  {
1311  Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1312  }
1313  #endif
1314 
1316  }
1317  else if (result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1318  {
1319  #ifdef DEVELOPER
1320  if (LogManager.IsInventoryMoveLogEnable())
1321  {
1322  Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1323  }
1324  #endif
1325 
1326  validation.m_Result = InventoryValidationResult.JUNCTURE;
1327  EnableMovableOverride(src1.GetItem());
1328  EnableMovableOverride(src2.GetItem());
1329  return true;
1330  }
1331  else if (result_sw == JunctureRequestResult.JUNCTURE_DENIED)
1332  {
1333  #ifdef DEVELOPER
1334  if (LogManager.IsInventoryMoveLogEnable())
1335  {
1336  Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1337  }
1338  #endif
1339 
1340  validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1341  return true;
1342  }
1343  else
1344  {
1345  Error("[syncinv] HandleInputData: unexpected return code from TryAcquireTwoInventoryJuncturesFromServer"); return true;
1346 
1347  return true;
1348  }
1349  }
1350 
1351  if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
1352  {
1353  ClearInventoryReservationEx(dst1.GetItem(),dst1);
1354  ClearInventoryReservationEx(dst2.GetItem(),dst2);
1355  }
1356 
1357  #ifdef DEVELOPER
1358  if (LogManager.IsInventoryMoveLogEnable())
1359  {
1360  Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1361  }
1362  #endif
1363 
1364  bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1365 
1366  ctx = new ScriptInputUserData();
1367  InventoryInputUserData.SerializeSwap(ctx, src1, src2, dst1, dst2, !isNotSkipped);
1368 
1369  validation.m_Result = InventoryValidationResult.SUCCESS;
1370  return true;
1371  }
1372 
1373  bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
1374  {
1376 
1377  if (validation.m_IsJuncture)
1378  {
1386  return true;
1387  }
1388 
1390  src.ReadFromContext(ctx);
1391 
1392  #ifdef DEVELOPER
1393  if (LogManager.IsInventoryMoveLogEnable())
1394  {
1395  Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1396  }
1397  #endif
1398 
1399  if (validation.m_IsRemote && !src.GetItem())
1400  {
1401  #ifdef DEVELOPER
1402  if (LogManager.IsInventoryMoveLogEnable())
1403  {
1404  Debug.InventoryMoveLog("Failed item not exist", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1405  }
1406  #endif
1407 
1408  Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
1409  return true;
1410  }
1411 
1415  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
1416  {
1417  #ifdef DEVELOPER
1418  if (LogManager.IsInventoryMoveLogEnable())
1419  {
1420  Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1421  }
1422  #endif
1423 
1424  return true;
1425  }
1426 
1430  if (!validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckDropRequest(src, GameInventory.c_MaxItemDistanceRadius))
1431  {
1432  #ifdef DEVELOPER
1433  if (LogManager.IsInventoryMoveLogEnable())
1434  {
1435  Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1436  }
1437  #endif
1438 
1439  return true;
1440  }
1441 
1442  #ifdef DEVELOPER
1443  if (LogManager.IsInventoryMoveLogEnable())
1444  {
1445  Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1446  }
1447  #endif
1448 
1449  GetGame().ObjectDelete(src.GetItem());
1450 
1451  validation.m_Result = InventoryValidationResult.SUCCESS;
1452  return true;
1453  }
1454 
1459  bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
1460  {
1461  if (isJuncture && isRemote)
1462  {
1464  return false;
1465  }
1466 
1467  int type = -1;
1468  if (!ctx.Read(type))
1469  {
1470  return false;
1471  }
1472 
1473  InventoryValidation validation();
1474  validation.m_IsJuncture = isJuncture;
1475  validation.m_IsRemote = isRemote;
1476 
1478  Serializer serializer = ctx;
1479 
1480  switch (type)
1481  {
1482  case InventoryCommandType.USER_RESERVATION_CANCEL:
1483  if (!ValidateUserReservationCancel(serializer, validation))
1484  {
1485  return false;
1486  }
1487  break;
1488  case InventoryCommandType.SYNC_MOVE:
1489  if (!ValidateSyncMove(serializer, validation))
1490  {
1491  return false;
1492  }
1493  break;
1494  case InventoryCommandType.HAND_EVENT:
1495  if (!ValidateHandEvent(serializer, validation))
1496  {
1497  return false;
1498  }
1499  break;
1500  case InventoryCommandType.SWAP:
1501  if (!ValidateSwap(serializer, validation))
1502  {
1503  return false;
1504  }
1505  break;
1506  case InventoryCommandType.DESTROY:
1507  if (!ValidateDestroy(serializer, validation))
1508  {
1509  return false;
1510  }
1511  break;
1512  default:
1513  break;
1514  }
1515 
1516  bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1517 
1518  switch (validation.m_Result)
1519  {
1520  case InventoryValidationResult.FAILED:
1521  if (canSendJuncture)
1522  {
1524  if (!serializer.CanWrite())
1525  {
1526  ScriptInputUserData writeableSerializer();
1527  writeableSerializer.CopyFrom(serializer);
1528  serializer = writeableSerializer;
1529  }
1530 
1531  serializer.Write(validation.m_Reason);
1532 
1533  GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
1534  }
1535  break;
1536  case InventoryValidationResult.JUNCTURE:
1537  if (canSendJuncture)
1538  {
1539  GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, serializer);
1540  //StoreInputForRemotes(isJuncture, isRemote, serializer);
1541  }
1542  else
1543  {
1544  Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1545  }
1546  break;
1547  case InventoryValidationResult.SUCCESS:
1548  StoreInputForRemotes(isJuncture, isRemote, serializer);
1549  break;
1550  }
1551 
1552  return true;
1553  }
1554 
1556  {
1557  ItemBase itemIB = ItemBase.Cast(item);
1558  if (itemIB)
1559  itemIB.SetCanBeMovedOverride(false);
1560  }
1561 
1563  {
1564  ItemBase itemIB = ItemBase.Cast(item);
1565  if (itemIB)
1566  itemIB.SetCanBeMovedOverride(true);
1567  }
1568 
1569  // Hacky solution for dealing with fencekit rope related issues, could be fixed by introducing some indicator that this item behaves differently or sth..
1571  {
1572  Rope rope = Rope.Cast(src.GetItem());
1573  if (rope)
1574  rope.SetTargetLocation(dst);
1575  }
1576 
1578  {
1579  return GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || GetDayZPlayerOwner() == GetGame().GetPlayer());
1580  }
1581 
1582  bool StoreInputForRemotes (bool handling_juncture, bool remote, ParamsReadContext ctx)
1583  {
1584  if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1585  {
1586  #ifdef DEVELOPER
1587  if (LogManager.IsInventoryMoveLogEnable())
1588  {
1589  Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString() );
1590  }
1591  #endif
1592 
1593  GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1594  return true;
1595  }
1596 
1597  return false;
1598  }
1599 
1600  override bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
1601  {
1602  if (GetManOwner().IsAlive() == false)
1603  return super.TakeToDst(mode, src, dst);
1604 
1605  #ifdef DEVELOPER
1606  if (LogManager.IsInventoryMoveLogEnable())
1607  {
1608  Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1609  }
1610  #endif
1611 
1612  switch (mode)
1613  {
1614  case InventoryMode.SERVER:
1615  if (RedirectToHandEvent(mode, src, dst))
1616  {
1617  #ifdef DEVELOPER
1618  if (LogManager.IsInventoryMoveLogEnable())
1619  {
1620  Debug.InventoryMoveLog("RedirectToHandEvent", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1621  }
1622  #endif
1623 
1624  return true;
1625  }
1626 
1627 
1628  if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1629  {
1630  if (GetGame().AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1631  {
1632  if (LogManager.IsSyncLogEnable())
1633  {
1634  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1635  }
1636  }
1637  else
1638  {
1639  #ifdef DEVELOPER
1640  if (LogManager.IsInventoryMoveLogEnable())
1641  {
1642  Debug.InventoryMoveLog("Juncture failed", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1643  }
1644  #endif
1645 
1646  if (LogManager.IsSyncLogEnable())
1647  {
1648  syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1649  }
1650 
1651  return false;
1652  }
1653 
1654  }
1655 
1657  InventoryInputUserData.SerializeMove(ctx, InventoryCommandType.SYNC_MOVE, src, dst);
1658 
1659  GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, ctx);
1660 
1661  if (LogManager.IsSyncLogEnable())
1662  {
1663  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));
1664  }
1665 
1667  //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1668  #ifdef DEVELOPER
1669  if ( LogManager.IsInventoryMoveLogEnable() )
1670  {
1671  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() );
1672  }
1673  #endif
1674  return true;
1675 
1676  case InventoryMode.LOCAL:
1677  LocationSyncMoveEntity(src, dst);
1678  return true;
1679  }
1680  if(!super.TakeToDst(mode,src,dst))
1681  {
1682  if (!m_DeferredEvent)
1683  {
1684  m_DeferredEvent = new DeferredTakeToDst(mode,src,dst);
1685  if( m_DeferredEvent.ReserveInventory(this) )
1686  return true;
1687  }
1688 
1689  m_DeferredEvent = null;
1690  return false;
1691  }
1692  return true;
1693  }
1694 
1695  void HandleTakeToDst( DeferredEvent deferred_event )
1696  {
1697  DeferredTakeToDst deferred_take_to_dst = DeferredTakeToDst.Cast(deferred_event);
1698  if( deferred_take_to_dst )
1699  {
1700  #ifdef DEVELOPER
1701  if ( LogManager.IsInventoryHFSMLogEnable() )
1702  {
1703  Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1704  }
1705  #endif
1706 
1707  deferred_take_to_dst.ClearInventoryReservation(this);
1708 
1709  if (LogManager.IsInventoryMoveLogEnable())
1710  {
1711  inventoryDebugPrint("[inv] I::Take2Dst(" + typename.EnumToString(InventoryMode, deferred_take_to_dst.m_mode) + ") src=" + InventoryLocation.DumpToStringNullSafe(deferred_take_to_dst.m_src) + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_take_to_dst.m_dst));
1712  }
1713 
1714  switch (deferred_take_to_dst.m_mode)
1715  {
1716  case InventoryMode.PREDICTIVE:
1717  #ifdef DEVELOPER
1718  if (LogManager.IsInventoryHFSMLogEnable())
1719  {
1720  Debug.InventoryHFSMLog("PREDICTIVE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1721  }
1722  #endif
1723 
1724  if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
1725  {
1726  InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1727  LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1728  }
1729  else
1730  {
1731  #ifdef DEVELOPER
1732  if (LogManager.IsInventoryMoveLogEnable())
1733  {
1734  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() );
1735  }
1736  #endif
1737  }
1738  break;
1739  case InventoryMode.JUNCTURE:
1740  #ifdef DEVELOPER
1741  if (LogManager.IsInventoryHFSMLogEnable())
1742  {
1743  Debug.InventoryHFSMLog("JUNCTURE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1744  }
1745  #endif
1746 
1747  if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
1748  {
1749  DayZPlayer player = GetGame().GetPlayer();
1750  player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1751  EnableMovableOverride(deferred_take_to_dst.m_dst.GetItem());
1752  InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1753  }
1754  else
1755  {
1756  #ifdef DEVELOPER
1757  if (LogManager.IsInventoryMoveLogEnable())
1758  {
1759  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());
1760  }
1761  #endif
1762  }
1763  break;
1764  case InventoryMode.LOCAL:
1765  #ifdef DEVELOPER
1766  if (LogManager.IsInventoryHFSMLogEnable())
1767  {
1768  Debug.InventoryHFSMLog("LOCAL ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1769  }
1770  #endif
1771  break;
1772  case InventoryMode.SERVER:
1773  #ifdef DEVELOPER
1774  if (LogManager.IsInventoryHFSMLogEnable())
1775  {
1776  Debug.InventoryHFSMLog("SERVER ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1777  }
1778  #endif
1779  break;
1780  default:
1781  Error("HandEvent - Invalid mode");
1782  break;
1783  }
1784  }
1785  }
1786 
1787  override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
1788  {
1789  #ifdef DEVELOPER
1790  if (LogManager.IsInventoryMoveLogEnable())
1791  {
1792  Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a" , "n/a", "SwapEntities", GetDayZPlayerOwner().ToString() );
1793  }
1794  #endif
1795 
1796  InventoryLocation src1, src2, dst1, dst2;
1797  if( mode == InventoryMode.LOCAL )
1798  {
1799  if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
1800  {
1801  LocationSwap(src1, src2, dst1, dst2);
1802  return true;
1803  }
1804  }
1805 
1806  if(!super.SwapEntities(mode,item1,item2))
1807  {
1808  if(!m_DeferredEvent)
1809  {
1810  if( GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2) );
1811  {
1812  m_DeferredEvent = new DeferredSwapEntities(mode, item1, item2, dst1, dst2);
1813  if( m_DeferredEvent.ReserveInventory(this) )
1814  return true;
1815  }
1816  }
1817  m_DeferredEvent = null;
1818  return false;
1819  }
1820  return true;
1821  }
1822 
1823  void HandleSwapEntities( DeferredEvent deferred_event )
1824  {
1825  DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
1826  if( deferred_swap_entities )
1827  {
1828  deferred_swap_entities.ClearInventoryReservation(this);
1829  InventoryLocation src1, src2, dst1, dst2;
1830  if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
1831  {
1832  if (LogManager.IsInventoryMoveLogEnable())
1833  {
1834  inventoryDebugPrint("[inv] I::Swap(" + typename.EnumToString(InventoryMode, deferred_swap_entities.m_mode) + ") src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2));
1835  }
1836 
1837  switch (deferred_swap_entities.m_mode)
1838  {
1839  case InventoryMode.PREDICTIVE:
1840  if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1841  {
1842  InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1843  LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1844  }
1845  else
1846  {
1847  #ifdef DEVELOPER
1848  if (LogManager.IsInventoryMoveLogEnable())
1849  {
1850  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() );
1851  }
1852  #endif
1853  }
1854  break;
1855 
1856  case InventoryMode.JUNCTURE:
1857  if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1858  {
1859  DayZPlayer player = GetGame().GetPlayer();
1860  player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1861  player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1862  EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
1863  EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
1864  InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1865  }
1866  else
1867  {
1868  #ifdef DEVELOPER
1869  if (LogManager.IsInventoryMoveLogEnable())
1870  {
1871  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() );
1872  }
1873  #endif
1874  }
1875  break;
1876 
1877  case InventoryMode.LOCAL:
1878  break;
1879 
1880  default:
1881  Error("SwapEntities - HandEvent - Invalid mode");
1882  }
1883  }
1884  else
1885  Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1886  }
1887  }
1888 
1889  override bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
1890  {
1891  #ifdef DEVELOPER
1892  if (LogManager.IsInventoryMoveLogEnable())
1893  {
1894  Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
1895  }
1896  #endif
1897 
1898  if( mode == InventoryMode.LOCAL )
1899  {
1900  InventoryLocation src1, src2, dst1;
1901  if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
1902  {
1903  LocationSwap(src1, src2, dst1, item2_dst);
1904  return true;
1905  }
1906 
1907  }
1908 
1909  if(!super.ForceSwapEntities(mode,item1,item2,item2_dst))
1910  {
1911  if(!m_DeferredEvent)
1912  {
1913  if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
1914  {
1915  m_DeferredEvent = new DeferredForceSwapEntities(mode,item1,item2, dst1, item2_dst);
1916  if( m_DeferredEvent.ReserveInventory(this))
1917  return true;
1918 
1919  }
1920  }
1921  m_DeferredEvent = null;
1922  return false;
1923  }
1924 
1925  return true;
1926  }
1927 
1929  {
1930  DeferredForceSwapEntities deferred_force_swap_entities = DeferredForceSwapEntities.Cast(deferred_event);
1931  if (deferred_force_swap_entities)
1932  {
1933  deferred_force_swap_entities.ClearInventoryReservation(this);
1936  deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
1937  deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
1938 
1939  DayZPlayer player = GetGame().GetPlayer();
1940 
1941  if (LogManager.IsInventoryMoveLogEnable())
1942  {
1943  inventoryDebugPrint("[inv] I::FSwap(" + typename.EnumToString(InventoryMode, deferred_force_swap_entities.m_mode) + ") src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(deferred_force_swap_entities.m_dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(deferred_force_swap_entities.m_dst2));
1944  }
1945 
1946  switch (deferred_force_swap_entities.m_mode)
1947  {
1948  case InventoryMode.PREDICTIVE:
1949  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))
1950  {
1951  InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
1952  LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
1953  }
1954  else
1955  {
1956  #ifdef DEVELOPER
1957  if (LogManager.IsInventoryMoveLogEnable())
1958  {
1959  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());
1960  }
1961  #endif
1962  }
1963  break;
1964 
1965  case InventoryMode.JUNCTURE:
1966  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))
1967  {
1968  player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1969  player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1970 
1971  InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
1972  }
1973  else
1974  {
1975  #ifdef DEVELOPER
1976  if (LogManager.IsInventoryMoveLogEnable())
1977  {
1978  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());
1979  }
1980  #endif
1981  }
1982  break;
1983 
1984  case InventoryMode.LOCAL:
1985  break;
1986 
1987  default:
1988  Error("ForceSwapEntities - HandEvent - Invalid mode");
1989  }
1990  }
1991  }
1992 
1993  static void SendServerHandEventViaJuncture (notnull DayZPlayer player, HandEventBase e)
1994  {
1995  if (GetGame().IsServer())
1996  {
1997  if (e.IsServerSideOnly())
1998  {
1999  Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
2000  }
2001 
2002  if (player.IsAlive())
2003  {
2004  InventoryLocation dst = e.GetDst();
2005  InventoryLocation src = e.GetSrc();
2006  if (src.IsValid() && dst.IsValid())
2007  {
2008  if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
2009  {
2010  if (LogManager.IsSyncLogEnable())
2011  {
2012  syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
2013  }
2014 
2015  if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
2016  {
2017  if (LogManager.IsSyncLogEnable())
2018  {
2019  syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
2020  }
2021  }
2022  else
2023  {
2024  if (LogManager.IsSyncLogEnable())
2025  {
2026  syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
2027  }
2028  }
2029  }
2030 
2031  if (LogManager.IsSyncLogEnable())
2032  {
2033  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));
2034  }
2035 
2037  InventoryInputUserData.SerializeHandEvent(ctx, e);
2038  player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, ctx);
2039 
2040  if (LogManager.IsSyncLogEnable())
2041  {
2042  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));
2043  }
2044 
2046  //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
2047  }
2048  }
2049  else
2050  {
2051  Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
2052  }
2053  }
2054  }
2055 
2059  override void NetSyncCurrentStateID (int id)
2060  {
2061  super.NetSyncCurrentStateID(id);
2062 
2063  GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
2064  }
2065 
2072  override void OnAfterStoreLoad ()
2073  {
2074  GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
2075  }
2076 
2081  {
2082  if (GetEntityInHands())
2083  {
2084  Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
2085  if (wpn)
2086  {
2088 
2090  if (pb && e)
2091  {
2092  pb.GetWeaponManager().SetRunning(true);
2093 
2094  if (LogManager.IsWeaponLogEnable())
2095  {
2096  fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
2097  }
2098 
2099  if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
2100  {
2101  wpn.ProcessWeaponAbortEvent(e);
2102  }
2103  else
2104  {
2105  wpn.ProcessWeaponEvent(e);
2106  }
2107  pb.GetWeaponManager().SetRunning(false);
2108  }
2109  }
2110  else
2111  Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
2112  }
2113  else
2114  Error("OnEventForRemoteWeapon - no entity in hands");
2115  return true;
2116  }
2117 
2118 
2123  {
2124  HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2125  if (e)
2126  {
2127  if (LogManager.IsInventoryHFSMLogEnable())
2128  {
2129  hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
2130  }
2131 
2132  //m_FSM.ProcessEvent(e);
2133 
2134  if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
2135  {
2136  ProcessEventResult aa;
2137  m_FSM.ProcessAbortEvent(e, aa);
2138  }
2139  else
2140  {
2141  m_FSM.ProcessEvent(e);
2142  }
2143 
2144  return true;
2145  }
2146  return false;
2147  }
2148 
2150  {
2152  if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2153  {
2155 
2156  ctx.Write(INPUT_UDT_HAND_REMOTE_EVENT);
2157  e.WriteToContext(ctx);
2158 
2159  if (LogManager.IsInventoryHFSMLogEnable())
2160  {
2161  hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
2162  }
2163 
2164  p.StoreInputForRemotes(ctx);
2165  }
2166  }
2167 
2169  {
2170  super.OnHandsExitedStableState(src, dst);
2171 
2172  if (LogManager.IsInventoryHFSMLogEnable())
2173  {
2174  hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
2175  }
2176  }
2177 
2179  {
2180  super.OnHandsEnteredStableState(src, dst);
2181 
2182  if (LogManager.IsInventoryHFSMLogEnable())
2183  {
2184  hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
2185  }
2186  }
2187 
2189  {
2190  super.OnHandsStateChanged(src, dst);
2191 
2192  if (LogManager.IsInventoryHFSMLogEnable())
2193  {
2194  hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
2195  }
2196 
2197  if (src.IsIdle())
2198  OnHandsExitedStableState(src, dst);
2199 
2200  if (dst.IsIdle())
2201  OnHandsEnteredStableState(src, dst);
2202 
2203 #ifdef BOT
2205  if (p && p.m_Bot)
2206  {
2207  p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
2208  }
2209 #endif
2210  }
2211 
2212  override bool HandEvent(InventoryMode mode, HandEventBase e)
2213  {
2214  if (!IsProcessing())
2215  {
2216  EntityAI itemInHands = GetEntityInHands();
2217 
2218  InventoryLocation handInventoryLocation();
2219  handInventoryLocation.SetHands(GetInventoryOwner(), itemInHands);
2220 
2221  InventoryValidation validation();
2222  if (e.CanPerformEventEx(validation))
2223  {
2224  m_DeferredEvent = new DeferredHandEvent(mode, e);
2225  if (m_DeferredEvent.ReserveInventory(this))
2226  {
2227  return true;
2228  }
2229  }
2230 
2231  m_DeferredEvent = null;
2232 
2234  if (!GetGame().IsMultiplayer() || GetGame().IsClient())
2235  {
2237  OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
2238  }
2239  else
2240  {
2241  ScriptInputUserData serializer();
2242 
2243  InventoryInputUserData.SerializeHandEvent(serializer, e);
2244  serializer.Write(validation.m_Reason);
2245 
2246  GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
2247  }
2248  }
2249 
2250  return false;
2251  }
2252 
2253 
2254  void HandleHandEvent(DeferredEvent deferred_event)
2255  {
2257  InventoryValidation validation();
2258 
2259  DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(deferred_event);
2260  if (deferred_hand_event)
2261  {
2262  #ifdef DEVELOPER
2263  if (LogManager.IsInventoryHFSMLogEnable())
2264  {
2265  Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2266  }
2267  #endif
2268 
2269  if (LogManager.IsInventoryHFSMLogEnable())
2270  {
2271  hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2272  }
2273 
2274  switch (deferred_hand_event.m_mode)
2275  {
2276  case InventoryMode.PREDICTIVE:
2277  #ifdef DEVELOPER
2278  if (LogManager.IsInventoryHFSMLogEnable())
2279  {
2280  Debug.InventoryHFSMLog("PREDICTIVE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2281  }
2282  #endif
2283 
2284  deferred_hand_event.ClearInventoryReservation(this);
2285  if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2286  {
2287  InventoryInputUserData.SendInputUserDataHandEvent(deferred_hand_event.m_event);
2288  ProcessHandEvent(deferred_hand_event.m_event);
2289  }
2290  break;
2291 
2292  case InventoryMode.JUNCTURE:
2293  #ifdef DEVELOPER
2294  if (LogManager.IsInventoryHFSMLogEnable())
2295  {
2296  Debug.InventoryHFSMLog("JUNCTURE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2297  }
2298  #endif
2299 
2300  deferred_hand_event.ClearInventoryReservation(this);
2301  if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2302  {
2303  deferred_hand_event.ReserveInventory(this);
2304  InventoryInputUserData.SendInputUserDataHandEvent(deferred_hand_event.m_event);
2305 
2306  //Functionality to prevent desync when two players perform interfering action at the same time
2307  EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2308  EntityAI itemDst = null;
2309  if (deferred_hand_event.m_event.GetDst())
2310  itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2311  if (itemSrc)
2312  EnableMovableOverride(itemSrc);
2313  if (itemDst)
2314  EnableMovableOverride(itemDst);
2315  }
2316  break;
2317 
2318  case InventoryMode.LOCAL:
2319  #ifdef DEVELOPER
2320  if (LogManager.IsInventoryHFSMLogEnable())
2321  {
2322  Debug.InventoryHFSMLog("LOCAL", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2323  }
2324  #endif
2325 
2326  deferred_hand_event.ClearInventoryReservation(this);
2327  ProcessHandEvent(deferred_hand_event.m_event);
2328  //PostHandEvent(deferred_hand_event.m_event);
2329  break;
2330 
2331  case InventoryMode.SERVER:
2332  #ifdef DEVELOPER
2333  if (LogManager.IsInventoryHFSMLogEnable())
2334  {
2335  Debug.InventoryHFSMLog("SERVER", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2336  }
2337  #endif
2338 
2339  if (LogManager.IsInventoryHFSMLogEnable())
2340  {
2341  hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2342  }
2343 
2344  if (!deferred_hand_event.m_event.IsServerSideOnly())
2345  {
2346  if (GetDayZPlayerOwner().IsAlive())
2347  {
2348  SendServerHandEventViaJuncture(GetDayZPlayerOwner(), deferred_hand_event.m_event);
2349  }
2350  else
2351  {
2352  InventoryInputUserData.SendServerHandEventViaInventoryCommand(GetDayZPlayerOwner(), deferred_hand_event.m_event);
2353  }
2354  }
2355  else
2356  {
2357  ProcessHandEvent(deferred_hand_event.m_event);
2358  }
2359  break;
2360 
2361  default:
2362  Error("HumanInventory::HandEvent - Invalid mode");
2363  }
2364  }
2365  }
2366 
2368  {
2369  super.HandleInventoryManipulation();
2370  if(m_DeferredEvent && ScriptInputUserData.CanStoreInputUserData() )
2371  {
2376 
2377  m_DeferredEvent = null;
2378  }
2379  }
2380 
2381 
2382 
2384  {
2385  return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2386  }
2387 
2388  bool PlayerCheckRequestSrc ( notnull InventoryLocation src, float radius )
2389  {
2390  bool result = true;
2391 
2392  EntityAI ent = src.GetParent();
2393  if ( ent )
2394  {
2395  PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2396  if (player)
2397  {
2398  if ( GetDayZPlayerOwner() != player )
2399  {
2400  if (player.IsAlive())
2401  {
2402  if (!player.IsRestrained() && !player.IsUnconscious())
2403  {
2404  return false;
2405  }
2406  }
2407  }
2408  }
2409  }
2410 
2411  if ( result )
2412  {
2413  result = CheckRequestSrc( GetManOwner(), src, radius);
2414  }
2415 
2416  return result;
2417  }
2418 
2419  bool PlayerCheckRequestDst ( notnull InventoryLocation src, notnull InventoryLocation dst, float radius )
2420  {
2421  bool result = true;
2422 
2423  EntityAI ent = dst.GetParent();
2424  if ( ent )
2425  {
2426  PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2427  if (player)
2428  {
2429  if ( GetDayZPlayerOwner() != player )
2430  {
2431  if (player.IsAlive())
2432  {
2433  if (!player.IsRestrained() && !player.IsUnconscious())
2434  {
2435  return false;
2436  }
2437  }
2438  }
2439  }
2440  }
2441 
2442  if ( result )
2443  {
2444  result = CheckMoveToDstRequest( GetManOwner(), src, dst, radius);
2445  }
2446 
2447  return result;
2448  }
2449 
2450  bool PlayerCheckSwapItemsRequest( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
2451  {
2452  bool result = true;
2453 
2454  EntityAI ent = dst1.GetParent();
2455  PlayerBase player;
2456  if ( ent )
2457  {
2458  player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2459  if (player)
2460  {
2461  if ( GetDayZPlayerOwner() != player )
2462  {
2463  if (player.IsAlive())
2464  {
2465  if (!player.IsRestrained() && !player.IsUnconscious())
2466  {
2467  return false;
2468  }
2469  }
2470  }
2471  }
2472  }
2473 
2474  ent = dst2.GetParent();
2475  if ( ent )
2476  {
2477  player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2478  if (player)
2479  {
2480  if ( GetDayZPlayerOwner() != player )
2481  {
2482  if (player.IsAlive())
2483  {
2484  if (!player.IsRestrained() && !player.IsUnconscious())
2485  {
2486  return false;
2487  }
2488  }
2489  }
2490  }
2491  }
2492 
2493 
2494  if ( result )
2495  {
2496  result = CheckSwapItemsRequest( GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2497  }
2498 
2499  return result;
2500 
2501  }
2502 
2503  bool PlayerCheckDropRequest ( notnull InventoryLocation src, float radius )
2504  {
2505  bool result = true;
2506 
2507  EntityAI ent = src.GetParent();
2508  if ( ent )
2509  {
2510  PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2511  if (player)
2512  {
2513  if ( GetDayZPlayerOwner() != player )
2514  {
2515  if (player.IsAlive())
2516  {
2517  if (!player.IsRestrained() && !player.IsUnconscious())
2518  {
2519  return false;
2520  }
2521  }
2522  }
2523  }
2524  }
2525 
2526  if ( result )
2527  {
2528  result = CheckDropRequest( GetManOwner(), src, radius);
2529  }
2530 
2531  return result;
2532  }
2533 };
2534 
ItemBase
Definition: inventoryitem.c:730
OnHandsExitedStableState
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
Definition: dayzplayerinventory.c:2168
DeferredEvent
Definition: dayzplayerinventory.c:2
OnAfterStoreLoad
override void OnAfterStoreLoad()
engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase....
Definition: dayzplayerinventory.c:2072
GetGame
proto native CGame GetGame()
HandleInventoryManipulation
override void HandleInventoryManipulation()
Definition: dayzplayerinventory.c:2367
InventoryValidationReason
InventoryValidationReason
Definition: inventory.c:36
HandStateBase
represent hand state base
Definition: handanimatedforceswapping.c:3
CheckForRope
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Definition: dayzplayerinventory.c:1570
m_MovingTo
protected ref HandAnimatedMovingToAtt m_MovingTo
Definition: dayzplayerinventory.c:146
CancelHandEvent
void CancelHandEvent()
cancels any handevents that will be executed this frame @NOTE: this is used in situations where the p...
Definition: dayzplayerinventory.c:257
OnEventForRemoteWeapon
bool OnEventForRemoteWeapon(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:2080
HandTransition
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition: handfsm.c:28
m_dst
ref InventoryLocation m_dst
Definition: dayzplayerinventory.c:13
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
OnHandsEnteredStableState
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
Definition: dayzplayerinventory.c:2178
LogManager
Definition: debug.c:734
OnHandleStoredJunctureData
protected void OnHandleStoredJunctureData(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:654
RemoveMovableOverride
void RemoveMovableOverride(EntityAI item)
Definition: dayzplayerinventory.c:1555
HandEventSwap
Definition: hand_events.c:659
m_Swapping
protected ref HandAnimatedSwapping m_Swapping
Definition: dayzplayerinventory.c:147
SyncHandEventToRemote
void SyncHandEventToRemote(HandEventBase e)
Definition: dayzplayerinventory.c:2149
WeaponActionTypeToString
string WeaponActionTypeToString(int A, int AT)
Definition: human.c:936
DayZPlayerInventory
Definition: dayzplayerinventory.c:111
HandEventID
HandEventID
events
Definition: hand_events.c:6
HandSelectAnimationOfForceSwapInHandsEvent
Definition: handanimated_guards.c:319
ClearInventoryReservation
override void ClearInventoryReservation(HumanInventory inventory)
Definition: dayzplayerinventory.c:31
OnInputUserDataProcess
override bool OnInputUserDataProcess(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:683
EnableMovableOverride
void EnableMovableOverride(EntityAI item)
Definition: dayzplayerinventory.c:1562
WeaponEventID
WeaponEventID
identifier for events. mainly for rpc purposes
Definition: events.c:5
CancelWeaponEvent
void CancelWeaponEvent()
Definition: dayzplayerinventory.c:263
ScriptRemoteInputUserData
Definition: gameplay.c:142
ScriptInputUserData
Definition: gameplay.c:120
m_item1
DeferredSwapEntities m_item1
OnServerInventoryCommand
override void OnServerInventoryCommand(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:727
wpnDebugPrint
void wpnDebugPrint(string s)
Definition: debug.c:9
hndDebugSpamALot
void hndDebugSpamALot(string s)
Definition: handfsm.c:17
m_DeferredEvent
m_DeferredEvent
OnInventoryJunctureRepairFromServer
override bool OnInventoryJunctureRepairFromServer(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:536
BotEventOnItemInHandsChanged
Definition: botevents.c:22
CreateWeaponEventFromContext
WeaponEventBase CreateWeaponEventFromContext(ParamsReadContext ctx)
Definition: events.c:281
GetInstanceType
proto native DayZPlayerInstanceType GetInstanceType()
IsProcessing
bool IsProcessing()
Definition: dayzplayerinventory.c:2383
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
WeaponEvents
WeaponEvents
events
Definition: human.c:955
DayZPlayerInventory
void DayZPlayerInventory()
Definition: dayzplayerinventory.c:151
WeaponAnimEventFactory
WeaponEventBase WeaponAnimEventFactory(WeaponEvents type, DayZPlayer p=NULL, Magazine m=NULL)
creates animation system events
Definition: events.c:251
ValidateDestroy
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
Definition: dayzplayerinventory.c:1373
InventoryValidationResult
InventoryValidationResult
Definition: inventory.c:29
IsServerOrLocalPlayer
bool IsServerOrLocalPlayer()
Definition: dayzplayerinventory.c:1577
InventoryCommandType
InventoryCommandType
Definition: inventory.c:2
CheckRequestSrc
bool CheckRequestSrc()
Definition: hand_events.c:104
TryAcquireTwoInventoryJuncturesFromServer
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition: junctures.c:29
InventoryValidation
Definition: inventory.c:43
OnInventoryJunctureFailureFromServer
override void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:561
ForceSwapEntities
override bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
Definition: dayzplayerinventory.c:1889
HandEventBase
Abstracted event, not to be used, only inherited.
Definition: hand_events.c:194
PlayerCheckRequestDst
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Definition: dayzplayerinventory.c:2419
ToString
proto string ToString()
DayZPlayer
Definition: dayzplayerimplement.c:72
ClearInventoryReservationEx
void ClearInventoryReservationEx(ActionData action_data)
Definition: actionbase.c:862
m_FSwapping
protected ref HandAnimatedForceSwapping m_FSwapping
Definition: dayzplayerinventory.c:148
NetSyncCurrentStateID
override void NetSyncCurrentStateID(int id)
Definition: dayzplayerinventory.c:2059
ReserveInventory
override bool ReserveInventory(HumanInventory inventory)
Definition: dayzplayerinventory.c:22
HumanInventoryWithFSM
HumanInventory... with FSM (synchronous, no anims)
Definition: humaninventorywithfsm.c:5
AbortWeaponEvent
void AbortWeaponEvent()
Definition: dayzplayerinventory.c:269
OnHandleStoredInputUserData
protected void OnHandleStoredInputUserData(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:698
WeaponActions
WeaponActions
actions
Definition: human.c:808
DeferredHandEvent
Definition: dayzplayerinventory.c:111
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
m_DeferredWeaponTimer
ref Timer m_DeferredWeaponTimer
Definition: dayzplayerinventory.c:138
DeferredSwapEntities
Definition: dayzplayerinventory.c:37
DeferredTakeToDst
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition: dayzplayerinventory.c:15
HandleHandEvent
void HandleHandEvent(DeferredEvent deferred_event)
Definition: dayzplayerinventory.c:2254
ValidateSwap
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
Definition: dayzplayerinventory.c:1135
HandEvent
override bool HandEvent(InventoryMode mode, HandEventBase e)
Definition: dayzplayerinventory.c:2212
PlayerBase
Definition: playerbaseclient.c:1
DeferredWeaponFailed
void DeferredWeaponFailed()
Definition: dayzplayerinventory.c:308
m_item2
EntityAI m_item2
Definition: dayzplayerinventory.c:77
JunctureRequestResult
JunctureRequestResult
Definition: hand_events.c:27
hndDebugSpam
void hndDebugSpam(string s)
Definition: handfsm.c:9
INPUT_UDT_INVENTORY
const int INPUT_UDT_INVENTORY
Definition: _constants.c:9
inventoryDebugPrint
void inventoryDebugPrint(string s)
Definition: debug.c:19
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
m_src
class DeferredEvent m_src
fsmDebugSpam
void fsmDebugSpam(string s)
Definition: hfsmbase.c:9
DeferredForceSwapEntities
void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition: dayzplayerinventory.c:81
wpnDebugSpamALot
void wpnDebugSpamALot(string s)
Definition: debug.c:25
m_dst2
ref InventoryLocation m_dst2
Definition: dayzplayerinventory.c:79
hndDebugPrint
void hndDebugPrint(string s)
Definition: handfsm.c:1
HandleWeaponEvents
void HandleWeaponEvents(float dt, out bool exitIronSights)
Definition: dayzplayerinventory.c:333
Object
Definition: objecttyped.c:1
InventoryInputUserData
Definition: inventoryinputuserdata.c:2
StoreInputForRemotes
bool StoreInputForRemotes(bool handling_juncture, bool remote, ParamsReadContext ctx)
Definition: dayzplayerinventory.c:1582
GetDayZPlayerOwner
DayZPlayer GetDayZPlayerOwner()
Definition: dayzplayerinventory.c:155
HandleTakeToDst
void HandleTakeToDst(DeferredEvent deferred_event)
Definition: dayzplayerinventory.c:1695
DayZPlayerSyncJunctures
Definition: dayzplayersyncjunctures.c:4
OnInventoryFailure
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Definition: dayzplayerinventory.c:640
m_DeferredWeaponEvent
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
Definition: dayzplayerinventory.c:143
m_DeferredPostedHandEvent
protected ref HandEventBase m_DeferredPostedHandEvent
Definition: dayzplayerinventory.c:142
m_FSwappingInst
protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst
Definition: dayzplayerinventory.c:149
IsAuthoritative
bool IsAuthoritative()
Definition: dayzplayerinventory.c:157
DeferredHandEvent
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
Definition: dayzplayerinventory.c:134
ValidateHandEvent
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
Definition: dayzplayerinventory.c:935
m_event
ref HandEventBase m_event
Definition: dayzplayerinventory.c:133
HandAnimEventFactory
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
Definition: hand_events.c:775
OnInputUserDataForRemote
void OnInputUserDataForRemote(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:717
HandleInventory
void HandleInventory(float dt)
Definition: dayzplayerinventory.c:427
INPUT_UDT_HAND_REMOTE_EVENT
const int INPUT_UDT_HAND_REMOTE_EVENT
Definition: _constants.c:14
HumanCommandWeapons
Definition: human.c:986
Init
override void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: dayzplayerinventory.c:190
PostWeaponEvent
void PostWeaponEvent(WeaponEventBase e)
Definition: dayzplayerinventory.c:291
WeaponEventBase
signalize mechanism manipulation
Definition: events.c:34
Debug
Definition: debug.c:13
ProcessInputData
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
Definition: dayzplayerinventory.c:1459
m_Taking
protected ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
Definition: dayzplayerinventory.c:145
Weapon_Base
shorthand
Definition: boltactionrifle_base.c:5
StoreInputUserData
proto native void StoreInputUserData(ParamsReadContext ctx)
HumanInventory
inventory for plain man/human
Definition: humaninventory.c:9
ProcessEventResult
ProcessEventResult
Definition: fsmbase.c:40
m_dst1
ref InventoryLocation m_dst1
Definition: dayzplayerinventory.c:78
Timer
Definition: dayzplayerimplement.c:62
OnInventoryJunctureFromServer
override bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:514
GetTime
float GetTime()
Definition: notificationsystem.c:35
syncDebugPrint
void syncDebugPrint(string s)
Definition: debug.c:1
SwapEntities
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
Definition: dayzplayerinventory.c:1787
TakeToDst
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition: dayzplayerinventory.c:1600
TryAcquireInventoryJunctureFromServer
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition: junctures.c:2
PlayerCheckRequestSrc
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Definition: dayzplayerinventory.c:2388
StoreJunctureData
proto native void StoreJunctureData(ParamsReadContext ctx)
OnHandsStateChanged
override void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
Definition: dayzplayerinventory.c:2188
IsOwner
bool IsOwner()
Definition: dayzplayerinventory.c:168
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
HandleForceSwapEntities
void HandleForceSwapEntities(DeferredEvent deferred_event)
Definition: dayzplayerinventory.c:1928
PlayerCheckSwapItemsRequest
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Definition: dayzplayerinventory.c:2450
EntityAI
Definition: building.c:5
OnHandEventForRemote
bool OnHandEventForRemote(ParamsReadContext ctx)
Definition: dayzplayerinventory.c:2122
ValidateSyncMove
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
Definition: dayzplayerinventory.c:737
HandleSwapEntities
void HandleSwapEntities(DeferredEvent deferred_event)
Definition: dayzplayerinventory.c:1823
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
IsProxy
bool IsProxy()
Definition: dayzplayerinventory.c:179
PlayerCheckDropRequest
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
Definition: dayzplayerinventory.c:2503
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058