DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
DayZPlayerInventory.c
См. документацию.
1//Post event containers
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.HasInventoryReservation(m_dst.GetItem(), m_dst))
25 {
27 {
28 return true;
29 }
30 }
31 return false;
32 }
33
35 {
36 inventory.ClearInventoryReservationEx(m_dst.GetItem(), m_dst);
37 }
38}
39
41{
46
47 void DeferredSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
48 {
49 m_mode = mode;
50 m_item1 = item1;
51 m_item2 = item2;
52 m_dst1 = dst1;
53 m_dst2 = dst2;
54 }
55
56 override bool ReserveInventory(HumanInventory inventory)
57 {
59 {
61 {
63 {
64 return true;
65 }
66 else
67 {
69 }
70 }
71 }
72 return false;
73 }
74
80}
81
83{
88
89 void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
90 {
91 m_mode = mode;
92 m_item1 = item1;
93 m_item2 = item2;
94 m_dst1 = dst1;
95 m_dst2 = dst2;
96 }
97
98 override bool ReserveInventory(HumanInventory inventory)
99 {
101 {
102 if (inventory.AddInventoryReservationEx(m_item1, m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS))
103 {
104 if (inventory.AddInventoryReservationEx(m_item2, m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS))
105 {
106 return true;
107 }
108 else
109 {
111 }
112 }
113 }
114 return false;
115 }
116
117 override void ClearInventoryReservation(HumanInventory inventory)
118 {
121 }
122}
123
125{
128 {
129 m_mode = mode;
130 m_event = e;
131 }
132
133 override bool ReserveInventory(HumanInventory inventory)
134 {
135 return m_event.ReserveInventory();
136 }
137
139 {
140 m_event.ClearInventoryReservation();
141 }
142}
143
145 * @class DayZPlayerInventory
146 **/
148{
151 //protected ref HandEventBase m_PostedHandEvent = NULL; /// deferred hand event
152
153
156 // states with animations
157 protected ref HandAnimatedTakingFromAtt m_Taking;
158 protected ref HandAnimatedMovingToAtt m_MovingTo;
159 protected ref HandAnimatedSwapping m_Swapping;
160 protected ref HandAnimatedForceSwapping m_FSwapping;
161 protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst;
162
163 static const float INVENTORY_REPAIR_MAX_DISTANCE = 500.0;
164 static const int INVENTORY_REPAIR_MAX_ITEMS = 5;
165
167 {
168 }
169
170 DayZPlayer GetDayZPlayerOwner () { return DayZPlayer.Cast(GetInventoryOwner()); }
171
173 {
174 DayZPlayer player;
175 if (!Class.CastTo(player, GetInventoryOwner()))
176 {
177 return false;
178 }
179
180 return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
181 }
182
183 bool IsOwner()
184 {
185 DayZPlayer player;
186 if (!Class.CastTo(player, GetInventoryOwner()))
187 {
188 return false;
189 }
190
191 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
192 }
193
194 bool IsProxy()
195 {
196 DayZPlayer player;
197 if (!Class.CastTo(player, GetInventoryOwner()))
198 {
199 return false;
200 }
201
202 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
203 }
204
205 override void Init ()
206 {
208 {
209 hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
210 }
211
212 CreateStableStates(); // stable states needs to be created first
213
214 m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
215 m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
216 m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
217 m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
218 m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
219
220 // events
221 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
222 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
223 HandEventBase __T__ = new HandEventTake;
224 HandEventBase __M__ = new HandEventMoveTo;
225 HandEventBase __W__ = new HandEventSwap;
226 //HandEventBase __D__ = new HandEventDropping;
227 HandEventBase __Xd_ = new HandEventDestroyed;
228 HandEventBase __F__ = new HandEventForceSwap;
229
230 // setup transitions
231 m_FSM.AddTransition(new HandTransition( m_Empty , __T__, m_Taking, NULL, new HandGuardAnd(new HandSelectAnimationOfTakeToHandsEvent(GetManOwner()), new HandGuardIsNotSurrendered(GetManOwner()))));
232 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
233 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Equipped, null, null));
234 m_FSM.AddTransition(new HandTransition( m_Taking , __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
235 m_Taking.AddTransition(new HandTransition( m_Taking.m_Hide, _abt_, m_Empty));
236 m_Taking.AddTransition(new HandTransition( m_Taking.m_Show, _abt_, m_Equipped));
237
238 m_FSM.AddTransition(new HandTransition( m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
239 m_FSM.AddTransition(new HandTransition( m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
240 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
241 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Empty , null, null));
242 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Hide, _abt_, m_Equipped));
243 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Show, _abt_, m_Empty));
244
245 m_FSM.AddTransition(new HandTransition( m_Equipped, __W__, m_Swapping, NULL, new HandGuardAnd(new HandSelectAnimationOfSwapInHandsEvent(GetManOwner()), new HandGuardIsNotSurrendered(GetManOwner()))));
246 m_FSM.AddTransition(new HandTransition( m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
247 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
248 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Equipped, null, null));
249 m_FSM.AddTransition(new HandTransition( m_Swapping, _abt_, m_Equipped, null, null));
250
251 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd(new HandGuardAnd( new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()) ), new HandGuardIsNotSurrendered(GetManOwner())) ));
252 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
253 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
254 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
255 m_FSM.AddTransition(new HandTransition( m_FSwappingInst, _abt_, m_Equipped, null, null));
256
257 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwapping, NULL, new HandGuardAnd(new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardIsNotSurrendered(GetManOwner()))));
258 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
259 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
260 m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
261 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Start, _abt_, m_Equipped));
262 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Hide, _abt_, m_Empty));
263 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Show, _abt_, m_Equipped));
264
265 super.Init(); // initialize ordinary human fsm (no anims)
266 }
267
273 {
275 //m_postedHandEvent = null;
276 }
277
279 {
282 }
283
285 {
286 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
287
288 Weapon_Base weapon;
289 Class.CastTo(weapon, GetEntityInHands());
290
291 if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
292 {
294 {
295 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
296 }
297
298 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
299 }
300 }
301
307 {
308 if (m_DeferredWeaponEvent == NULL)
309 {
311
313 {
314 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
315 }
316 }
317 else
318 {
319 Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
320 }
321 }
322
324 {
325 Weapon_Base weapon;
326 Class.CastTo(weapon, GetEntityInHands());
327
328 string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
329
330 string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
331 if (weapon)
332 {
333 secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
334 secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
335 for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
336 {
337 secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
338 secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
339 if (i < weapon.GetMuzzleCount() - 1)
340 secondPart += " | ";
341 }
342 }
343
344 Error(firstPart + secondPart);
346 }
347
348 void HandleWeaponEvents (float dt, out bool exitIronSights)
349 {
350 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
351
352 Weapon_Base weapon;
353 Class.CastTo(weapon, GetEntityInHands());
354
355 if (weapon)
356 {
357 weapon.UpdateCoolDown(dt);
358 if (hcw && weapon.CanProcessWeaponEvents())
359 {
360
361 weapon.GetCurrentState().OnUpdate(dt);
362
364 {
365 wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
366 }
367
368 if (!weapon.IsIdle())
369 {
370 while (true)
371 {
372 int weaponEventId = hcw.IsEvent();
373 if (weaponEventId == -1)
374 {
375 break;
376 }
377
378 if (weaponEventId == WeaponEvents.CHANGE_HIDE)
379 {
380 break;
381 }
382
383 WeaponEventBase anim_event = WeaponAnimEventFactory(weaponEventId, GetDayZPlayerOwner(), NULL);
384
386 {
387 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
388 }
389
390 if (anim_event != NULL)
391 {
392 weapon.ProcessWeaponEvent(anim_event);
393 }
394 }
395
396 if (hcw.IsActionFinished())
397 {
398 if (weapon.IsWaitingForActionFinish())
399 {
401 {
402 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
403 }
404
405 weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
406 }
407 else
408 {
410 {
411 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
412 }
413
414 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
415 }
416 }
417 }
418
420 {
422 {
423 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
424 }
425
426 if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
427 {
428 exitIronSights = true;
429
431 {
432 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
433 }
434
437 }
438 else if (!m_DeferredWeaponTimer.IsRunning())
439 {
440 m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
441 }
442 }
443 }
444 }
445 }
446
447 void HandleInventory(float dt)
448 {
449 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
450
451 EntityAI ih = GetEntityInHands();
452 Weapon_Base weapon;
453 Class.CastTo(weapon, ih);
454
455 if (hcw)
456 {
457 HandStateBase fsmState = m_FSM.GetCurrentState();
458 fsmState.OnUpdate(dt);
459
460 #ifdef ENABLE_LOGGING
462 {
463 hndDebugSpamALot("[hndfsm] HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
464 }
465 #endif
466
467 if ( !fsmState.IsIdle() || !m_FSM.IsRunning())
468 {
469 while (true)
470 {
471 int weaponEventId = hcw.IsEvent();
472 if (weaponEventId == -1)
473 {
474 break;
475 }
476
477 HandEventBase anim_event = HandAnimEventFactory(weaponEventId, GetManOwner(), NULL);
478
479 #ifdef ENABLE_LOGGING
481 {
482 hndDebugPrint("[hndfsm] HandleInventory: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
483 }
484 #endif
485
486 if (anim_event != NULL)
487 {
488 SyncHandEventToRemote(anim_event);
489 ProcessHandEvent(anim_event);
490 }
491 }
492
493 if (hcw.IsActionFinished())
494 {
495 if (fsmState.IsWaitingForActionFinish())
496 {
497 #ifdef ENABLE_LOGGING
499 {
500 hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + fsmState);
501 }
502 #endif
503
504 HandEventBase fin_event = new HandEventHumanCommandActionFinished(GetManOwner());
505 SyncHandEventToRemote(fin_event);
506 ProcessHandEvent(fin_event);
507 }
508 else
509 {
510 #ifdef ENABLE_LOGGING
512 {
513 hndDebugPrint("[hndfsm] Hand-Weapon event: ABORT! notifying running state=" + fsmState);
514 }
515 #endif
516
517 HandEventBase abt_event = new HandEventHumanCommandActionAborted(GetManOwner());
518 SyncHandEventToRemote(abt_event);
519 ProcessHandAbortEvent(abt_event);
520 //m_FSM.ProcessHandAbortEvent(new WeaponEventHumanCommandActionAborted(GetManOwner()));
521 }
522 }
523 }
524 }
525 }
526
527
529
536 {
537 int tmp = -1;
538 ctx.Read(tmp);
539
540#ifdef ENABLE_LOGGING
542 {
543 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store Juncture packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
544 }
545#endif
546
548
549 return true;
550 }
551
553
560 {
573
574 if (g_Game.IsDedicatedServer())
575 {
576 return;
577 }
578
579 int udtIdentifier = -1;
580 if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
581 {
582 return;
583 }
584
588
589 InventoryCommandType type = -1;
590 if (!ctx.Read(type))
591 {
592 return;
593 }
594
595 switch (type)
596 {
597 case InventoryCommandType.SYNC_MOVE:
598 {
599 src.ReadFromContext(ctx);
600 dst.ReadFromContext(ctx);
602 break;
603 }
604 case InventoryCommandType.HAND_EVENT:
605 {
606 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
607 src = e.GetSrc();
608 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
621 break;
622 }
623 case InventoryCommandType.FORCESWAP:
624 {
625 break;
626 }
627 case InventoryCommandType.DESTROY:
628 {
629 src.ReadFromContext(ctx);
630 break;
631 }
632 }
633
635 if (!ctx.Read(reason))
636 {
637 reason = InventoryValidationReason.UNKNOWN;
638 }
639
640 OnInventoryFailure(type, reason, src, dst);
641 }
642
644 {
645 if (reason == InventoryValidationReason.DROP_PREVENTED)
646 {
648 return;
649 }
650
651 }
652
658 {
659 int tmp = -1;
660 ctx.Read(tmp);
661
662#ifdef ENABLE_LOGGING
664 {
665 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
666 }
667#endif
669#ifdef DIAG_DEVELOPER
670 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsOldProcessInputDataEnable())
671 {
672 ProcessInputData(ctx, true, false);
673 }
674 else
675 {
676#endif
677 if(g_Game.IsServer())
678 {
680 }
681 else
682 {
684 }
685#ifdef DIAG_DEVELOPER
686 }
687#endif
688 }
689
694 proto native void StoreJunctureData(ParamsReadContext ctx);
696
697
699
706 {
707#ifdef ENABLE_LOGGING
709 {
710 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
711 }
712#endif
713
715 return true;
716 }
717
723 {
724 int tmp = -1;
725 ctx.Read(tmp);
726
727#ifdef ENABLE_LOGGING
729 {
730 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
731 }
732#endif
734#ifdef DIAG_DEVELOPER
735 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsOldProcessInputDataEnable())
736 {
737 ProcessInputData(ctx, false, false);
738 }
739 else
740 {
741#endif
742 if(g_Game.IsServer())
743 {
745 }
746 else
747 {
748 Error("OnHandleStoredInputUserData - Client");
749 }
750#ifdef DIAG_DEVELOPER
751 }
752#endif
753 }
754
758 proto native void StoreInputUserData(ParamsReadContext ctx);
760
762 {
763#ifdef ENABLE_LOGGING
765 {
766 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
767 }
768#endif
770#ifdef DIAG_DEVELOPER
771 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsOldProcessInputDataEnable())
772 {
773 ProcessInputData(ctx, false, true);
774 }
775 else
776 {
777#endif
779#ifdef DIAG_DEVELOPER
780 }
781#endif
782 }
783
785 {
786#ifdef ENABLE_LOGGING
788 {
789 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
790 }
791#endif
793#ifdef DIAG_DEVELOPER
794 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsOldProcessInputDataEnable())
795 {
796 ProcessInputData(ctx, true, true);
797 }
798 else
799 {
800#endif
801 Error("OnServerInventoryCommand Should not happen");
802#ifdef DIAG_DEVELOPER
803 }
804#endif
805 }
806
808 {
810
813 bool success = true;
814
815 src.ReadFromContext(ctx);
816 dst.ReadFromContext(ctx);
817
818 #ifdef ENABLE_LOGGING
820 {
821 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
822 }
823 #endif
824
825 EntityAI itemSrc = src.GetItem();
826 EntityAI itemDst = dst.GetItem();
827
828 if (validation.m_IsRemote && (!itemSrc || !itemDst))
829 {
831
832#ifdef ENABLE_LOGGING
834 {
835 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
836 }
837
839 {
840 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
841 }
842#endif
843
844 return true;
845 }
846
847 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && itemSrc != itemDst)
848 {
849 #ifdef ENABLE_LOGGING
851 {
852 Debug.InventoryMoveLog("Failed - src and dst are for different items", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
853 }
854
856 {
857 syncDebugPrint("[syncinv] HandleInputData Failed - src and dst are for different items src item =" + itemSrc + " dst item =" + itemDst);
858 }
859 #endif
860
861 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
862 {
863 success = false;
864 }
865 else
866 {
867 return true;
868 }
869 }
870
871 EnableMovableOverride(itemSrc);
872
876 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
877 {
879
880#ifdef ENABLE_LOGGING
882 {
883 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
884 }
885
887 {
888 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
889 }
890#endif
891
892 RemoveMovableOverride(itemSrc);
893
894 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
895 {
896 success = false;
897 #ifdef DIAG_DEVELOPER
898 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
899 {
900 #endif
901 array<EntityAI> itemsToRepair = new array<EntityAI>;
903 src.GetItem().GetInventory().GetCurrentInventoryLocation(realIl);
904
905 if(src != realIl)
906 {
907 itemsToRepair.Insert(src.GetItem());
909 }
910 #ifdef DIAG_DEVELOPER
911 }
912 #endif
913 }
914 else
915 {
916 return true;
917 }
918 }
919
923 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
924 {
925#ifdef ENABLE_LOGGING
927 {
928 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
929 }
930
932 {
933 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
934 }
935#endif
936
937 RemoveMovableOverride(itemSrc);
938
939 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
940 {
942 success = false;
943 }
944 else
945 {
946 return true;
947 }
948 }
949
950 RemoveMovableOverride(itemSrc);
951
952#ifdef ENABLE_LOGGING
954 {
955 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " HandleInputData t=" + g_Game.GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
956 }
957#endif
958
960 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
961 {
963 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
964 {
965 #ifdef ENABLE_LOGGING
967 {
968 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
969 }
970 #endif
971 if (success)
972 {
974
975 LocationSyncMoveEntity(src, dst);
976
977 validation.m_Result = InventoryValidationResult.SUCCESS;
978 }
979 return true;
980 }
981 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
982 {
983 #ifdef ENABLE_LOGGING
985 {
986 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
987 }
988 #endif
989
991 {
992 #ifdef ENABLE_LOGGING
993
994 #ifdef DEVELOPER
995 DumpInventoryDebug();
996 #endif
997
999 {
1000 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1001 }
1002 #endif
1003 validation.m_Result = InventoryValidationResult.FAILED;
1004 return true;
1005 }
1006
1007 validation.m_Result = InventoryValidationResult.JUNCTURE;
1008 EnableMovableOverride(itemSrc);
1009 return true;
1010 }
1011 else
1012 {
1013 #ifdef ENABLE_LOGGING
1015 {
1016 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1017 }
1018 #endif
1019
1020 validation.m_Result = InventoryValidationResult.FAILED;
1021 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1022 return true;
1023 }
1024 }
1025 // Check whether the juncture for the related player and items has been acquired.
1026 else if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1027 {
1028 bool hasJuncture = false;
1029 if (itemSrc != null && itemDst != null)
1030 {
1031 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1032 }
1033 else if (itemSrc != null)
1034 {
1035 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
1036 }
1037 else if (itemDst != null)
1038 {
1039 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1040 }
1041
1042 if (!hasJuncture)
1043 {
1044#ifdef ENABLE_LOGGING
1046 {
1047 Debug.InventoryMoveLog("Failed - missing juncture", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1048 }
1049#endif
1050 success = false;
1051 }
1052 }
1053
1054 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1055 {
1056 ClearInventoryReservationEx(itemDst, dst);
1057 }
1058
1060 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1061 {
1062 CheckForRope(src, dst);
1063 }
1064
1069 if (!validation.m_IsRemote)
1070 {
1072 {
1073 #ifdef ENABLE_LOGGING
1074
1075 #ifdef DEVELOPER
1076 DumpInventoryDebug();
1077 #endif
1078
1080 {
1081 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1082 }
1083 #endif
1084
1085 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1086 return true;
1087 }
1088 else if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && !GameInventory.LocationTestAddEntity(dst, false, true, true, true, false, false))
1089 {
1090 #ifdef ENABLE_LOGGING
1091
1092 #ifdef DEVELOPER
1093 DumpInventoryDebug();
1094 #endif
1095
1097 {
1098 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1099 }
1100 #endif
1101
1102 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1103 return true;
1104 }
1105 }
1106
1107
1108 //TODO: hotfix solution
1109 if (!validation.m_IsRemote && validation.m_IsJuncture && !MoveCheckExclusionMaskLocal(src,dst))
1110 {
1111 #ifdef ENABLE_LOGGING
1113 {
1114 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1115 }
1116 #endif
1117 return false;
1118 }
1119
1120 #ifdef ENABLE_LOGGING
1122 {
1123 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1124 }
1125 #endif
1126
1127 if (success)
1128 {
1129 LocationSyncMoveEntity(src, dst);
1130 validation.m_Result = InventoryValidationResult.SUCCESS;
1131 }
1132
1133 return true;
1134 }
1135
1137 {
1140 bool success = true;
1141
1142 if (!src.ReadFromContext(ctx))
1143 return false;
1144 if (!dst.ReadFromContext(ctx))
1145 return false;
1146
1147#ifdef ENABLE_LOGGING
1149 {
1150 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1151 }
1152#endif
1153
1154 EntityAI itemSrc = src.GetItem();
1155 EntityAI itemDst = dst.GetItem();
1156
1157 if (success && itemSrc != itemDst)
1158 {
1159#ifdef ENABLE_LOGGING
1161 {
1162 Debug.InventoryMoveLog("Failed - src and dst are for different items", "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1163 }
1164
1166 {
1167 syncDebugPrint("[syncinv] ValidateSyncMoveServer Failed - src and dst are for different items src item =" + itemSrc + " dst item =" + itemDst);
1168 }
1169#endif
1170
1171 success = false;
1172 }
1173
1174 EnableMovableOverride(itemSrc);
1175
1177 {
1178#ifdef ENABLE_LOGGING
1180 {
1181 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1182 }
1183
1185 {
1186 syncDebugPrint("[cheat] ValidateSyncMoveServer man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SYNC_MOVE) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
1187 }
1188#endif
1189
1190 RemoveMovableOverride(itemSrc);
1191
1192 success = false;
1193#ifdef DIAG_DEVELOPER
1194 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1195 {
1196#endif
1197 array<EntityAI> itemsToRepair = new array<EntityAI>();
1198 InventoryLocation realIl = new InventoryLocation();
1199 src.GetItem().GetInventory().GetCurrentInventoryLocation(realIl);
1200
1201 if(src != realIl)
1202 {
1203 itemsToRepair.Insert(src.GetItem());
1205 }
1206#ifdef DIAG_DEVELOPER
1207 }
1208#endif
1209 }
1210
1212 {
1213#ifdef ENABLE_LOGGING
1215 {
1216 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1217 }
1218
1220 {
1221 syncDebugPrint("[cheat] ValidateSyncMoveServer man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SYNC_MOVE) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1222 }
1223#endif
1224
1225 RemoveMovableOverride(itemSrc);
1226
1228 success = false;
1229 }
1230
1231 RemoveMovableOverride(itemSrc);
1232
1233#ifdef ENABLE_LOGGING
1235 {
1236 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " ValidateSyncMoveServer t=" + g_Game.GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SYNC_MOVE) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1237 }
1238#endif
1239
1241 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1242 {
1243#ifdef ENABLE_LOGGING
1245 {
1246 Debug.InventoryMoveLog("Juncture not required STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1247 }
1248#endif
1249 if (success)
1250 {
1252 LocationSyncMoveEntity(src, dst);
1253
1254 validation.m_Result = InventoryValidationResult.SUCCESS;
1255 }
1256
1257 }
1258 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
1259 {
1260#ifdef ENABLE_LOGGING
1262 {
1263 Debug.InventoryMoveLog("Juncture needed STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1264 }
1265#endif
1266
1267 if (!GameInventory.LocationCanMoveEntity(src, dst))
1268 {
1269#ifdef ENABLE_LOGGING
1270
1271 #ifdef DEVELOPER
1272 DumpInventoryDebug();
1273 #endif
1274
1276 {
1277 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1278 }
1279#endif
1280 validation.m_Result = InventoryValidationResult.FAILED;
1281 success = false;
1282 }
1283 else
1284 {
1285 validation.m_Result = InventoryValidationResult.JUNCTURE;
1286 EnableMovableOverride(itemSrc);
1287 }
1288 }
1289 else
1290 {
1291#ifdef ENABLE_LOGGING
1293 {
1294 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ValidateSyncMoveServer", GetDayZPlayerOwner().ToString() );
1295 }
1296#endif
1297
1298 validation.m_Result = InventoryValidationResult.FAILED;
1299 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1300
1301 success = false;
1302
1303 }
1304 return true;
1305 }
1306
1308 {
1311
1312 if (!src.ReadFromContext(ctx))
1313 return false;
1314 if (!dst.ReadFromContext(ctx))
1315 return false;
1316
1317#ifdef ENABLE_LOGGING
1319 {
1320 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandServer", GetDayZPlayerOwner().ToString() );
1321 }
1322#endif
1323
1324 EntityAI itemSrc = src.GetItem();
1325 EntityAI itemDst = dst.GetItem();
1326
1327RemoveMovableOverride(itemSrc);
1328 #ifdef ENABLE_LOGGING
1330 {
1331 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " ExecuteSyncMoveCommandServer t=" + g_Game.GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SYNC_MOVE) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1332 }
1333#endif
1334
1335 //MW Should always exist an be same, better add check and after that just one check
1336 bool hasJuncture = false;
1337 if (itemSrc != null && itemDst != null)
1338 {
1339 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1340 }
1341 else if (itemSrc != null)
1342 {
1343 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
1344 }
1345 else if (itemDst != null)
1346 {
1347 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1348 }
1349
1350 if (!hasJuncture)
1351 {
1352#ifdef ENABLE_LOGGING
1354 {
1355 Debug.InventoryMoveLog("Failed - missing juncture", "SYNC_MOVE", "n/a", "ExecuteSyncMoveCommandServer", GetDayZPlayerOwner().ToString() );
1356 }
1357#endif
1358 return false;
1359 }
1360
1361 //???
1362 CheckForRope(src, dst);
1363
1364 //TODO: hotfix solution
1365 //???
1366 if (!MoveCheckExclusionMaskLocal(src,dst))
1367 {
1368#ifdef ENABLE_LOGGING
1370 {
1371 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE", "n/a", "ExecuteSyncMoveCommandServer", GetDayZPlayerOwner().ToString() );
1372 }
1373#endif
1374 return false;
1375 }
1376
1377 if (!GameInventory.LocationCanMoveEntity(src, dst))
1378 {
1379#ifdef ENABLE_LOGGING
1381 {
1382 Debug.InventoryMoveLog("Failed - LocationSyncMoveEntity Can not move entity STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandServer", GetDayZPlayerOwner().ToString() );
1383 }
1384#endif
1385 return false;
1386 }
1387
1388
1389#ifdef ENABLE_LOGGING
1391 {
1392 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandServer", GetDayZPlayerOwner().ToString() );
1393 }
1394#endif
1395 return LocationSyncMoveEntity(src, dst);
1396 }
1397
1399 {
1402
1403 if (!src.ReadFromContext(ctx))
1404 {
1405 return false;
1406 }
1407 if (!dst.ReadFromContext(ctx))
1408 {
1409 return false;
1410 }
1411
1412#ifdef ENABLE_LOGGING
1414 {
1415 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandClient", GetDayZPlayerOwner().ToString() );
1416 }
1417#endif
1418
1419 EntityAI itemSrc = src.GetItem();
1420 EntityAI itemDst = dst.GetItem();
1421
1422 RemoveMovableOverride(itemSrc);
1423 #ifdef ENABLE_LOGGING
1425 {
1426 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " ExecuteSyncMoveCommandClient t=" + g_Game.GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SYNC_MOVE) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1427 }
1428 #endif
1429
1430 ClearInventoryReservationEx(itemDst, dst);
1431
1432 //TODO: hotfix solution
1433 if (!MoveCheckExclusionMaskLocal(src,dst))
1434 {
1435#ifdef ENABLE_LOGGING
1437 {
1438 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandClient", GetDayZPlayerOwner().ToString() );
1439 }
1440#endif
1441 return false;
1442 }
1443
1444 if (!GameInventory.LocationTestAddEntity(dst, false, true, true, true, false, false))
1445 {
1446#ifdef ENABLE_LOGGING
1448 {
1449 Debug.InventoryMoveLog("Fail - LocationSyncMoveEntity Can not move entity STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandClient", GetDayZPlayerOwner().ToString() );
1450 }
1451#endif
1452 return false;
1453 }
1454
1455#ifdef ENABLE_LOGGING
1457 {
1458 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandClient", GetDayZPlayerOwner().ToString() );
1459 }
1460#endif
1461 return LocationSyncMoveEntity(src, dst);
1462 }
1463
1465 {
1468
1469 if (!src.ReadFromContext(ctx))
1470 return false;
1471 if (!dst.ReadFromContext(ctx))
1472 return false;
1473
1474#ifdef ENABLE_LOGGING
1476 {
1477 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandRemote", GetDayZPlayerOwner().ToString() );
1478 }
1479#endif
1480
1481 EntityAI itemSrc = src.GetItem();
1482 EntityAI itemDst = dst.GetItem();
1483
1484 if (!itemSrc || !itemDst)
1485 {
1486#ifdef ENABLE_LOGGING
1488 {
1489 Debug.InventoryMoveLog("Failed - item not exist on remote client", "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandRemote", GetDayZPlayerOwner().ToString() );
1490 }
1491
1493 {
1494 syncDebugPrint("[syncinv] ExecuteSyncMoveCommandRemote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1495 }
1496#endif
1497 return false;
1498 }
1499
1500 RemoveMovableOverride(itemSrc);
1501
1502#ifdef ENABLE_LOGGING
1504 {
1505 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " ExecuteSyncMoveCommandRemote t=" + g_Game.GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SYNC_MOVE) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1506 }
1507#endif
1508
1509#ifdef ENABLE_LOGGING
1511 {
1512 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ExecuteSyncMoveCommandRemote", GetDayZPlayerOwner().ToString() );
1513 }
1514#endif
1515
1516 return LocationSyncMoveEntity(src, dst);
1517 }
1518
1520 {
1522 bool success = true;
1523
1524 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1525
1526 //client only
1528
1532 e.m_IsRemote = validation.m_IsRemote;
1533 e.m_IsJuncture = validation.m_IsJuncture;
1534
1535 EntityAI itemSrc = e.GetSrcEntity();
1536 EntityAI itemDst = e.GetSecondSrcEntity();
1537
1538 #ifdef ENABLE_LOGGING
1540 {
1541 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1542 }
1543 #endif
1544
1545 if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER && e.m_Player != GetManOwner())
1546 {
1547 Error("[syncinv] Inventory owner " + GetManOwner() + " and event sender " + e.m_Player + " do not match.");
1548 return true;
1549 }
1550
1551 if (e.IsServerSideOnly())
1552 {
1553 Error("[syncinv] ValidateHandEvent This event " + e.GetDebugName() + " should not be use for synchronization.");
1554 return true;
1555 }
1556
1557 if (validation.m_IsRemote && !itemSrc)
1558 {
1560 if (itemDst && (e.GetEventID() == HandEventID.SWAP || e.GetEventID() == HandEventID.FORCESWAP)) //presumed swap, replace with take
1561 {
1562 InventoryLocation srcNew = new InventoryLocation();
1563 srcNew.Copy(e.GetSrc());
1564 e = HandEventBase.HandEventFactory(HandEventID.TAKE, e.m_Player, srcNew);
1565
1566 Error("[syncinv] HandleInputData remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.DumpToString() + "), src item is null! Continuing.");
1567 }
1568 else
1569 {
1570 #ifdef ENABLE_LOGGING
1572 {
1573 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1574 }
1575 #endif
1576
1577 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1578
1579 return true;
1580 }
1581 }
1582
1584 if (itemSrc)
1585 RemoveMovableOverride(itemSrc);
1586 if (itemDst)
1587 RemoveMovableOverride(itemDst);
1588
1592 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1593 {
1594 #ifdef ENABLE_LOGGING
1596 {
1597 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1598 }
1599 #endif
1600
1601 if (!validation.m_IsRemote)
1602 {
1603 ctx = new ScriptInputUserData;
1605 }
1606
1607 RemoveMovableOverride(itemSrc);
1608 RemoveMovableOverride(itemDst);
1609
1610 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1611 {
1612 success = false;
1613 #ifdef DIAG_DEVELOPER
1614 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1615 {
1616 #endif
1617 array<EntityAI> itemsToRepair = new array<EntityAI>;
1618 InventoryLocation repairIl = new InventoryLocation();
1619 if(!itemSrc)
1620 {
1621 return false;
1622 }
1623
1624 itemSrc.GetInventory().GetCurrentInventoryLocation(repairIl);
1625
1626 if(e.GetSrc() != repairIl)
1627 {
1628 itemsToRepair.Insert(itemSrc);
1629 }
1630
1631 if(itemDst && itemSrc != itemDst )
1632 {
1633 itemDst.GetInventory().GetCurrentInventoryLocation(repairIl);
1634 if(e.GetSecondSrc() != repairIl)
1635 {
1636 itemsToRepair.Insert(itemDst);
1637 }
1638 }
1639
1640 if (itemsToRepair.Count())
1641 {
1643 }
1644 #ifdef DIAG_DEVELOPER
1645 }
1646 #endif
1647 }
1648 else
1649 {
1650 return true;
1651 }
1652 }
1653
1654 if (success && !e.CheckRequestEx(validation))
1655 {
1656 #ifdef ENABLE_LOGGING
1658 {
1659 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1660 }
1661 #endif
1662
1664
1665 ctx = new ScriptInputUserData;
1667
1668#ifdef ENABLE_LOGGING
1670 {
1671 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1672 }
1673#endif
1674
1675 RemoveMovableOverride(itemSrc);
1676 RemoveMovableOverride(itemDst);
1677
1678 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1679 {
1680 success = false;
1681 }
1682 else
1683 {
1684 return true;
1685 }
1686 }
1687
1690 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1691 {
1692 #ifdef ENABLE_LOGGING
1694 {
1695 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1696 }
1697 #endif
1698
1700
1701 ctx = new ScriptInputUserData;
1703
1704#ifdef ENABLE_LOGGING
1706 {
1707 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1708 }
1709#endif
1710
1711 RemoveMovableOverride(itemSrc);
1712 RemoveMovableOverride(itemDst);
1713
1714 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1715 {
1716 InventoryLocation ilDst = e.GetDst();
1717 if (ilDst)
1718 SendRepairToClientDst(ilDst);
1719
1720 ilDst = e.GetSecondDst();
1721 if (ilDst)
1722 SendRepairToClientDst(ilDst);
1723
1724 success = false;
1725 }
1726 else
1727 {
1728 return true;
1729 }
1730 }
1731
1732 RemoveMovableOverride(itemSrc);
1733 RemoveMovableOverride(itemDst);
1734
1736 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1737 {
1739 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1740 {
1741 #ifdef ENABLE_LOGGING
1743 {
1744 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1745 }
1746 #endif
1747
1749 }
1750 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1751 {
1752 #ifdef ENABLE_LOGGING
1754 {
1755 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1756 }
1757 #endif
1758
1759 ctx = new ScriptInputUserData;
1761
1762 validation.m_Result = InventoryValidationResult.JUNCTURE;
1763
1764 if (itemSrc)
1765 EnableMovableOverride(itemSrc);
1766 if (itemDst)
1767 EnableMovableOverride(itemDst);
1768 return true;
1769 }
1770 else
1771 {
1772 #ifdef ENABLE_LOGGING
1774 {
1775 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1776 }
1777 #endif
1778
1779 validation.m_Result = InventoryValidationResult.FAILED;
1780 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1781 return true;
1782 }
1783 }
1784 // Check whether the juncture for the related player and items has been acquired.
1785 else if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1786 {
1787 bool hasJuncture = false;
1788
1789 if (itemSrc != null && itemDst != null)
1790 {
1791 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1792 }
1793 else if (itemSrc != null)
1794 {
1795 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
1796 }
1797 else if (itemDst != null)
1798 {
1799 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1800 }
1801
1802 if (!hasJuncture)
1803 {
1804#ifdef ENABLE_LOGGING
1806 {
1807 Debug.InventoryMoveLog("Failed - missing juncture", "HAND_EVENT", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1808 }
1809#endif
1810 success = false;
1811 }
1812 }
1813
1815 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1816 {
1817 CheckForRope(e.GetSrc(), e.GetDst());
1818 }
1819
1820 #ifdef ENABLE_LOGGING
1822 {
1823 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1824 }
1825 #endif
1826
1827 if (success)
1828 {
1829 validation.m_Result = InventoryValidationResult.SUCCESS;
1830 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1831 {
1833 //result = InventoryValidationResult.FAILURE;
1834 }
1835 }
1836
1837 return true;
1838 }
1839
1841 {
1842 bool success = true;
1843
1844 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1845 if (e.m_Player != GetManOwner())
1846 {
1847 Error("[syncinv] Inventory owner " + GetManOwner() + " and event sender " + e.m_Player + " not match.");
1848 return true;
1849 }
1850
1851 e.m_IsJuncture = false;
1852 e.m_IsRemote = false;
1853
1854 EntityAI itemSrc = e.GetSrcEntity();
1855 EntityAI itemDst = e.GetSecondSrcEntity();
1856
1857#ifdef ENABLE_LOGGING
1859 {
1860 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
1861 }
1862#endif
1863
1864 if (e.IsServerSideOnly())
1865 {
1866 Error("[syncinv] ValidateHandEvent This event " + e.GetDebugName() + " should not be use for synchronization.");
1867 return true;
1868 }
1869
1871 if (itemSrc)
1872 {
1873 RemoveMovableOverride(itemSrc);
1874 }
1875 if (itemDst)
1876 {
1877 RemoveMovableOverride(itemDst);
1878 }
1879
1881 if (success && !e.CheckRequestSrc())
1882 {
1883#ifdef ENABLE_LOGGING
1885 {
1886 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
1887 }
1888#endif
1889
1890 ctx = new ScriptInputUserData();
1892
1893 success = false;
1894#ifdef DIAG_DEVELOPER
1895 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1896 {
1897#endif
1898 array<EntityAI> itemsToRepair = new array<EntityAI>();
1899 InventoryLocation repairIl = new InventoryLocation();
1900 if(itemSrc)
1901 {
1902 itemSrc.GetInventory().GetCurrentInventoryLocation(repairIl);
1903
1904 if(e.GetSrc() != repairIl)
1905 {
1906 itemsToRepair.Insert(itemSrc);
1907 }
1908
1909 if(itemDst && itemSrc != itemDst )
1910 {
1911 itemDst.GetInventory().GetCurrentInventoryLocation(repairIl);
1912 if(e.GetSecondSrc() != repairIl)
1913 {
1914 itemsToRepair.Insert(itemDst);
1915 }
1916 }
1917
1918 if (itemsToRepair.Count())
1919 {
1921 }
1922 }
1923#ifdef DIAG_DEVELOPER
1924 }
1925#endif
1926 }
1927
1928 if (success && !e.CheckRequestEx(validation))
1929 {
1930#ifdef ENABLE_LOGGING
1932 {
1933 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
1934 }
1935#endif
1936
1938
1939 ctx = new ScriptInputUserData();
1941
1942#ifdef ENABLE_LOGGING
1944 {
1945 syncDebugPrint("[cheat] ValidateHandEventServer man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.HAND_EVENT) + " event=" + e.DumpToString());
1946 }
1947#endif
1948
1949 success = false;
1950 }
1951
1952 if (success && !e.CanPerformEventEx(validation))
1953 {
1954#ifdef ENABLE_LOGGING
1956 {
1957 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
1958 }
1959#endif
1960
1962
1963 ctx = new ScriptInputUserData();
1965
1966#ifdef ENABLE_LOGGING
1968 {
1969 syncDebugPrint("[desync] ValidateHandEventServer man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1970 }
1971#endif
1972
1973 InventoryLocation ilDst = e.GetDst();
1974 if (ilDst)
1975 {
1976 SendRepairToClientDst(ilDst);
1977 }
1978
1979 ilDst = e.GetSecondDst();
1980 if (ilDst)
1981 {
1982 SendRepairToClientDst(ilDst);
1983 }
1984
1985 success = false;
1986 }
1987
1989 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1990 {
1991#ifdef ENABLE_LOGGING
1993 {
1994 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
1995 }
1996#endif
1997 CheckForRope(e.GetSrc(), e.GetDst());
1998#ifdef ENABLE_LOGGING
2000 {
2001 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
2002 }
2003#endif
2004 validation.m_Result = InventoryValidationResult.SUCCESS;
2005 return e.m_Player.GetHumanInventory().ProcessHandEvent(e);
2007 }
2008 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
2009 {
2010#ifdef ENABLE_LOGGING
2012 {
2013 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
2014 }
2015#endif
2016
2017 ctx = new ScriptInputUserData();
2019
2020 validation.m_Result = InventoryValidationResult.JUNCTURE;
2021
2022 if (itemSrc)
2023 {
2024 EnableMovableOverride(itemSrc);
2025 }
2026 if (itemDst)
2027 {
2028 EnableMovableOverride(itemDst);
2029 }
2030 return true;
2031 }
2032 else
2033 {
2034#ifdef ENABLE_LOGGING
2036 {
2037 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ValidateHandEventServer", e.m_Player.ToString() );
2038 }
2039#endif
2040
2041 validation.m_Result = InventoryValidationResult.FAILED;
2042 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
2043 return true;
2044 }
2045 }
2046
2048 {
2049 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2050
2051 e.m_IsJuncture = true;
2052 e.m_IsRemote = false;
2053
2054 EntityAI itemSrc = e.GetSrcEntity();
2055 EntityAI itemDst = e.GetSecondSrcEntity();
2056
2057#ifdef ENABLE_LOGGING
2059 {
2060 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ExecuteHandEventCommandServer", e.m_Player.ToString() );
2061 }
2062#endif
2063
2064
2065 if (itemSrc)
2066 {
2067 //???
2068 RemoveMovableOverride(itemSrc);
2069 }
2070 if (itemDst)
2071 {
2072 //???
2073 RemoveMovableOverride(itemDst);
2074 }
2075
2076 InventoryValidation validation = new InventoryValidation();
2077 validation.m_IsJuncture = true;
2078 validation.m_IsRemote = false;
2079 validation.m_Mode = InventoryMode.JUNCTURE;
2080
2081 if (!e.CheckRequestEx(validation))//??? This should be remove in refactor, but for drop it has some functionality
2082 {
2083#ifdef ENABLE_LOGGING
2085 {
2086 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandServer", e.m_Player.ToString() );
2087 }
2088#endif
2089
2091
2092 ctx = new ScriptInputUserData();
2094
2095#ifdef ENABLE_LOGGING
2097 {
2098 syncDebugPrint("[cheat] ExecuteHandEventCommandServer man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.HAND_EVENT) + " event=" + e.DumpToString());
2099 }
2100#endif
2101
2102 return true;
2103 }
2104
2106 if (!e.CanPerformEventEx(validation))//??? This should be remove in refactor, but for drop it has some functionality
2107 {
2108#ifdef ENABLE_LOGGING
2110 {
2111 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandServer", e.m_Player.ToString() );
2112 }
2113#endif
2114
2116
2117 ctx = new ScriptInputUserData();
2119
2120#ifdef ENABLE_LOGGING
2122 {
2123 syncDebugPrint("[desync] ExecuteHandEventCommandServer man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
2124 }
2125#endif
2126
2127 return true;
2128 }
2129
2130 bool hasJuncture = false;
2131
2132 if (itemSrc != null && itemDst != null)
2133 {
2134 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
2135 }
2136 else if (itemSrc != null)
2137 {
2138 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
2139 }
2140 else if (itemDst != null)
2141 {
2142 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
2143 }
2144
2145 if (!hasJuncture)
2146 {
2147#ifdef ENABLE_LOGGING
2149 {
2150 Debug.InventoryMoveLog("Failed - missing juncture", "HAND_EVENT", "n/a", "ExecuteHandEventCommandServer", GetDayZPlayerOwner().ToString() );
2151 }
2152#endif
2153 return false;
2154 }
2155
2156 //???
2157 CheckForRope(e.GetSrc(), e.GetDst());
2158
2159
2160#ifdef ENABLE_LOGGING
2162 {
2163 Debug.InventoryMoveLog("Success", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandServer", e.m_Player.ToString() );
2164 }
2165#endif
2166
2167 return e.m_Player.GetHumanInventory().ProcessHandEvent(e);
2168 }
2169
2171 {
2172 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2174
2175 e.m_IsJuncture = true;
2176 e.m_IsRemote = false;
2177
2178 EntityAI itemSrc = e.GetSrcEntity();
2179 EntityAI itemDst = e.GetSecondSrcEntity();
2180
2181#ifdef ENABLE_LOGGING
2183 {
2184 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ExecuteHandEventCommandClient", e.m_Player.ToString() );
2185 }
2186#endif
2187
2188
2189 if (itemSrc)
2190 {
2191 //???
2192 RemoveMovableOverride(itemSrc);
2193 }
2194 if (itemDst)
2195 {
2196 //???
2197 RemoveMovableOverride(itemDst);
2198 }
2199
2200 InventoryValidation validation = new InventoryValidation();
2201 validation.m_IsJuncture = true;
2202 validation.m_IsRemote = false;
2203 validation.m_Mode = InventoryMode.JUNCTURE;
2204
2205 if (!e.CheckRequestEx(validation))//??? This should be remove in refactor, but for drop it has some functionality
2206 {
2207#ifdef ENABLE_LOGGING
2209 {
2210 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandClient", e.m_Player.ToString() );
2211 }
2212#endif
2213
2215
2216 ctx = new ScriptInputUserData();
2218
2219#ifdef ENABLE_LOGGING
2221 {
2222 syncDebugPrint("[cheat] ExecuteHandEventCommandClient man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.HAND_EVENT) + " event=" + e.DumpToString());
2223 }
2224#endif
2225
2226 return true;
2227 }
2228
2230 if (!e.CanPerformEventEx(validation))//??? This should be remove in refactor, but for drop it has some functionality
2231 {
2232#ifdef ENABLE_LOGGING
2234 {
2235 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandClient", e.m_Player.ToString() );
2236 }
2237#endif
2238
2240
2241 ctx = new ScriptInputUserData();
2243
2244#ifdef ENABLE_LOGGING
2246 {
2247 syncDebugPrint("[desync] ExecuteHandEventCommandClient man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
2248 }
2249#endif
2250
2251 return true;
2252 }
2253
2254#ifdef ENABLE_LOGGING
2256 {
2257 Debug.InventoryMoveLog("Success", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandClient", e.m_Player.ToString() );
2258 }
2259#endif
2260
2261 return e.m_Player.GetHumanInventory().ProcessHandEvent(e);
2262 }
2263
2265 {
2266 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2267
2268 e.m_IsJuncture = true;
2269 e.m_IsRemote = true;
2270
2271 EntityAI itemSrc = e.GetSrcEntity();
2272 EntityAI itemDst = e.GetSecondSrcEntity();
2273
2274#ifdef ENABLE_LOGGING
2276 {
2277 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ExecuteHandEventCommandRemote", e.m_Player.ToString() );
2278 }
2279#endif
2280
2281 if (!itemSrc)
2282 {
2284 if (itemDst && (e.GetEventID() == HandEventID.SWAP || e.GetEventID() == HandEventID.FORCESWAP)) //presumed swap, replace with take
2285 {
2286 InventoryLocation srcNew = new InventoryLocation();
2287 srcNew.Copy(e.GetSrc());
2288 e = HandEventBase.HandEventFactory(HandEventID.TAKE, e.m_Player, srcNew);
2289
2290 Error("[syncinv] ExecuteHandEventCommandRemote remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.DumpToString() + "), src item is null! Continuing.");
2291 }
2292 else
2293 {
2294#ifdef ENABLE_LOGGING
2296 {
2297 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandRemote", e.m_Player.ToString() );
2298 }
2299#endif
2300
2301 Error("[syncinv] ExecuteHandEventCommandRemote remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
2302
2303 return true;
2304 }
2305 }
2306
2307 if (itemSrc)
2308 {
2309 //???
2310 RemoveMovableOverride(itemSrc);
2311 }
2312 if (itemDst)
2313 {
2314 //???
2315 RemoveMovableOverride(itemDst);
2316 }
2317
2318 InventoryValidation validation = new InventoryValidation();
2319 validation.m_IsJuncture = true;
2320 validation.m_IsRemote = false;
2321 validation.m_Mode = InventoryMode.JUNCTURE;
2322
2323 if (!e.CheckRequestEx(validation))//??? This should be remove in refactor, but for drop it has some functionality
2324 {
2325#ifdef ENABLE_LOGGING
2327 {
2328 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandRemote", e.m_Player.ToString() );
2329 }
2330#endif
2331
2333
2334 ctx = new ScriptInputUserData();
2336
2337#ifdef ENABLE_LOGGING
2339 {
2340 syncDebugPrint("[cheat] ExecuteHandEventCommandRemote man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.HAND_EVENT) + " event=" + e.DumpToString());
2341 }
2342#endif
2343
2344 return true;
2345 }
2346
2347#ifdef ENABLE_LOGGING
2349 {
2350 Debug.InventoryMoveLog("Success", "HAND_EVENT" , "n/a", "ExecuteHandEventCommandRemote", e.m_Player.ToString() );
2351 }
2352#endif
2353
2354 return e.m_Player.GetHumanInventory().ProcessHandEvent(e);
2355 }
2356
2357 bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
2358 {
2359 DayZPlayer playerOwner = GetDayZPlayerOwner();
2361 if (!swapValidation)
2362 return false;
2363
2364 array<EntityAI> itemsToRepair;
2365 InventoryLocation repairIl;
2366
2367 #ifdef ENABLE_LOGGING
2369 {
2370 Debug.InventoryMoveLog("STS = " + playerOwner.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2), "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2371 }
2372 #endif
2373
2374 if (validation.m_IsRemote && (!swapValidation.m_SrcItem1 || !swapValidation.m_SrcItem2))
2375 {
2376 if (!swapValidation.m_SrcItem2 && swapValidation.m_SrcItem1)
2377 {
2378 // Treat as a simple move of srcItem1 to dst1 on remote clients
2379 LocationSyncMoveEntity(swapValidation.m_Src1, swapValidation.m_Dst1);
2380 validation.m_Result = InventoryValidationResult.SUCCESS;
2381 return true;
2382 }
2383 else if (!swapValidation.m_SrcItem1 && swapValidation.m_SrcItem2)
2384 {
2385 // Treat as a simple move of srcItem2 to dst2 on remote clients
2386 LocationSyncMoveEntity(swapValidation.m_Src2, swapValidation.m_Dst2);
2387 validation.m_Result = InventoryValidationResult.SUCCESS;
2388 return true;
2389 }
2390 else
2391 {
2392 if (swapValidation.m_SkippedSwap)
2393 {
2394 #ifdef ENABLE_LOGGING
2396 {
2397 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2398 }
2399 #endif
2400 }
2401 else
2402 {
2404 #ifdef ENABLE_LOGGING
2406 {
2407 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2408 }
2409 #endif
2410
2411 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
2412 }
2413 }
2414
2415 return true;
2416 }
2417
2418 EnableMovableOverride(swapValidation.m_SrcItem1);
2419 EnableMovableOverride(swapValidation.m_SrcItem2);
2420
2421 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && (swapValidation.m_SrcItem1 != swapValidation.m_DstItem1 || swapValidation.m_SrcItem2 != swapValidation.m_DstItem2) )
2422 {
2423 #ifdef ENABLE_LOGGING
2425 {
2426 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
2427 Debug.InventoryMoveLog("Failed - src and dst are for different for first item", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2428 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
2429 Debug.InventoryMoveLog("Failed - src and dst are for different for second item", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2430 }
2431
2433 {
2434 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
2435 syncDebugPrint("[syncinv] HandleInputData Failed - first src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
2436 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
2437 syncDebugPrint("[syncinv] HandleInputData Failed - second src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
2438 }
2439 #endif
2440
2441 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2442 {
2443 swapValidation.m_Success = false;
2444 }
2445 else
2446 {
2447 return true;
2448 }
2449 }
2450
2454 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(swapValidation.m_Src1, GameInventory.c_MaxItemDistanceRadius))
2455 {
2456 #ifdef ENABLE_LOGGING
2458 {
2459 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2460 }
2461
2463 {
2464 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1));
2465 }
2466 #endif
2467
2468 RemoveMovableOverride(swapValidation.m_SrcItem1);
2469 RemoveMovableOverride(swapValidation.m_SrcItem2);
2470
2471 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2472 {
2473 swapValidation.m_Success = false;
2474 #ifdef DIAG_DEVELOPER
2475 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2476 {
2477 #endif
2478 itemsToRepair = new array<EntityAI>;
2479 repairIl = new InventoryLocation;
2480
2481 swapValidation.m_SrcItem1.GetInventory().GetCurrentInventoryLocation(repairIl);
2482
2483 if(swapValidation.m_Src1 != repairIl)
2484 {
2485 itemsToRepair.Insert(swapValidation.m_SrcItem1);
2486 }
2487
2488 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
2489 if(swapValidation.m_Src2 != repairIl)
2490 {
2491 itemsToRepair.Insert(swapValidation.m_SrcItem2);
2492 }
2493
2494 if (itemsToRepair.Count())
2495 {
2497 }
2498 #ifdef DIAG_DEVELOPER
2499 }
2500 #endif
2501 }
2502 else
2503 {
2504 return true;
2505 }
2506 }
2507
2511 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(swapValidation.m_Src2, GameInventory.c_MaxItemDistanceRadius))
2512 {
2513 #ifdef ENABLE_LOGGING
2515 {
2516 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2517 }
2518
2520 {
2521 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2));
2522 }
2523 #endif
2524
2525 RemoveMovableOverride(swapValidation.m_SrcItem1);
2526 RemoveMovableOverride(swapValidation.m_SrcItem2);
2527
2528 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2529 {
2530 swapValidation.m_Success = false;
2531 #ifdef DIAG_DEVELOPER
2532 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2533 {
2534 #endif
2535 itemsToRepair = new array<EntityAI>;
2536 repairIl = new InventoryLocation;
2537
2538 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
2539 if(swapValidation.m_Src2 != repairIl)
2540 {
2541 itemsToRepair.Insert(swapValidation.m_SrcItem2);
2542 }
2543
2544 if (itemsToRepair.Count())
2545 {
2547 }
2548 #ifdef DIAG_DEVELOPER
2549 }
2550 #endif
2551 }
2552 else
2553 {
2554 return true;
2555 }
2556 }
2557
2561 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckSwapItemsRequest(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, GameInventory.c_MaxItemDistanceRadius))
2562 {
2563 #ifdef ENABLE_LOGGING
2565 {
2566 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString());
2567 }
2568
2570 {
2571 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2572 }
2573 #endif
2574
2575 RemoveMovableOverride(swapValidation.m_SrcItem1);
2576 RemoveMovableOverride(swapValidation.m_SrcItem2);
2577
2578 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2579 {
2580 swapValidation.m_Success = false;
2581 }
2582 else
2583 {
2584 return true;
2585 }
2586 }
2587
2588 RemoveMovableOverride(swapValidation.m_SrcItem1);
2589 RemoveMovableOverride(swapValidation.m_SrcItem2);
2590
2591 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2592 {
2593 ClearInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1);
2594 ClearInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2);
2595 }
2596
2600 if (swapValidation.m_Success && !validation.m_IsRemote && !GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
2601 {
2602 #ifdef ENABLE_LOGGING
2603 #ifdef DEVELOPER
2604 DumpInventoryDebug();
2605 #endif
2606
2608 {
2609 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString());
2610 }
2611 #endif
2612
2613 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2614 {
2615 if (swapValidation.m_Dst1)
2616 SendRepairToClientDst(swapValidation.m_Dst1);
2617
2618 if (swapValidation.m_Dst2)
2619 SendRepairToClientDst(swapValidation.m_Dst2);
2620 swapValidation.m_Success = false;
2621 }
2622 else
2623 {
2624 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT swap cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) +" | src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2625 return true;
2626 }
2627 }
2628
2629 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2630 {
2631 AddInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2632 AddInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2633 }
2634
2635 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
2636 {
2637 Error("HandleInputData: cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2638 return true;
2639 }
2640
2641 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2642 {
2644 if (!validation.m_IsJuncture)
2645 {
2646 JunctureRequestResult resultSwap = TryAcquireTwoInventoryJuncturesFromServer(playerOwner, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
2647 if (resultSwap == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
2648 {
2649 #ifdef ENABLE_LOGGING
2651 {
2652 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
2653 }
2654 #endif
2655
2657 }
2658 else if (swapValidation.m_Success && resultSwap == JunctureRequestResult.JUNCTURE_ACQUIRED)
2659 {
2660 #ifdef ENABLE_LOGGING
2662 {
2663 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2664 }
2665 #endif
2666
2667 validation.m_Result = InventoryValidationResult.JUNCTURE;
2668 EnableMovableOverride(swapValidation.m_SrcItem1);
2669 EnableMovableOverride(swapValidation.m_SrcItem2);
2670 return true;
2671 }
2672 else
2673 {
2674 #ifdef ENABLE_LOGGING
2676 {
2677 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2678 }
2679 #endif
2680
2681 validation.m_Result = InventoryValidationResult.FAILED;
2682 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
2683 return true;
2684 }
2685 }
2687 else if (validation.m_IsJuncture)
2688 {
2689 bool hasJuncture = false;
2690 int nonNullCount = 0;
2691 bool failed = false;
2692
2693 if (swapValidation.m_SrcItem1 != null)
2694 {
2695 nonNullCount++;
2696 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem1))
2697 failed = true;
2698 }
2699
2700 if (!failed && swapValidation.m_SrcItem2 != null)
2701 {
2702 nonNullCount++;
2703 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem2))
2704 failed = true;
2705 }
2706
2707 if (!failed && swapValidation.m_DstItem1 != null)
2708 {
2709 nonNullCount++;
2710 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem1))
2711 failed = true;
2712 }
2713
2714 if (!failed && swapValidation.m_DstItem2 != null)
2715 {
2716 nonNullCount++;
2717 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem2))
2718 failed = true;
2719 }
2720
2721 hasJuncture = (nonNullCount > 0 && !failed);
2722
2723 if (!hasJuncture)
2724 {
2725#ifdef ENABLE_LOGGING
2727 {
2728 Debug.InventoryMoveLog("Failed - missing juncture", "SWAP", "n/a", "ValidateSwap", GetDayZPlayerOwner().ToString() );
2729 }
2730#endif
2731 swapValidation.m_Success = false;
2732 }
2733 }
2734 }
2735
2736 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
2737 {
2738 ClearInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1);
2739 ClearInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2);
2740 }
2741 else
2742 {
2743 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem1);
2744 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem2);
2745 }
2746
2747 //TODO: hotfix solution
2748 if (!validation.m_IsRemote && validation.m_IsJuncture && !SwapCheckExclusionMaskLocal(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2))
2749 {
2750 #ifdef ENABLE_LOGGING
2752 {
2753 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2754 }
2755 #endif
2756 return false;
2757 }
2758
2759 #ifdef ENABLE_LOGGING
2761 {
2762 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
2763 }
2764 #endif
2765
2766 if (swapValidation.m_Success)
2767 {
2768 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
2769 ctx = new ScriptInputUserData();
2770 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
2771 validation.m_Result = InventoryValidationResult.SUCCESS;
2772 }
2773
2774 return true;
2775 }
2776
2778 {
2779 DayZPlayer playerOwner = GetDayZPlayerOwner();
2781 if (!swapValidation)
2782 {
2783 return false;
2784 }
2785
2786 array<EntityAI> itemsToRepair;
2787 InventoryLocation repairIl;
2788
2789#ifdef ENABLE_LOGGING
2791 {
2792 Debug.InventoryMoveLog("STS = " + playerOwner.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2), "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2793 }
2794#endif
2795
2796 EnableMovableOverride(swapValidation.m_SrcItem1);
2797 EnableMovableOverride(swapValidation.m_SrcItem2);
2798
2799 if (swapValidation.m_Success && swapValidation.m_SrcItem1 != swapValidation.m_DstItem1 || swapValidation.m_SrcItem2 != swapValidation.m_DstItem2 )
2800 {
2801 #ifdef ENABLE_LOGGING
2803 {
2804 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
2805 {
2806 Debug.InventoryMoveLog("Failed - src and dst are for different for first item", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
2807 }
2808 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
2809 {
2810 Debug.InventoryMoveLog("Failed - src and dst are for different for second item", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
2811 }
2812 }
2813
2815 {
2816 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
2817 {
2818 syncDebugPrint("[syncinv] ValidateSwapServer Failed - first src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
2819 }
2820 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
2821 {
2822 syncDebugPrint("[syncinv] ValidateSwapServer Failed - second src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
2823 }
2824 }
2825#endif
2826
2827 swapValidation.m_Success = false;
2828 }
2829
2833 if (swapValidation.m_Success && !PlayerCheckRequestSrc(swapValidation.m_Src1, GameInventory.c_MaxItemDistanceRadius))
2834 {
2835#ifdef ENABLE_LOGGING
2837 {
2838 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2839 }
2840
2842 {
2843 syncDebugPrint("[cheat] ValidateSwapServer man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1));
2844 }
2845#endif
2846
2847 RemoveMovableOverride(swapValidation.m_SrcItem1);
2848 RemoveMovableOverride(swapValidation.m_SrcItem2);
2849
2850 swapValidation.m_Success = false;
2851#ifdef DIAG_DEVELOPER
2852 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2853 {
2854#endif
2855 itemsToRepair = new array<EntityAI>();
2856 repairIl = new InventoryLocation();
2857
2858 swapValidation.m_SrcItem1.GetInventory().GetCurrentInventoryLocation(repairIl);
2859
2860 if(swapValidation.m_Src1 != repairIl)
2861 {
2862 itemsToRepair.Insert(swapValidation.m_SrcItem1);
2863 }
2864
2865 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
2866 if(swapValidation.m_Src2 != repairIl)
2867 {
2868 itemsToRepair.Insert(swapValidation.m_SrcItem2);
2869 }
2870
2871 if (itemsToRepair.Count())
2872 {
2874 }
2875#ifdef DIAG_DEVELOPER
2876 }
2877#endif
2878 }
2879
2883 if (swapValidation.m_Success && !PlayerCheckRequestSrc(swapValidation.m_Src2, GameInventory.c_MaxItemDistanceRadius))
2884 {
2885 #ifdef ENABLE_LOGGING
2887 {
2888 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2889 }
2890
2892 {
2893 syncDebugPrint("[cheat] ValidateSwapServer man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2));
2894 }
2895 #endif
2896
2897 RemoveMovableOverride(swapValidation.m_SrcItem1);
2898 RemoveMovableOverride(swapValidation.m_SrcItem2);
2899
2900 swapValidation.m_Success = false;
2901#ifdef DIAG_DEVELOPER
2902 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2903 {
2904#endif
2905 itemsToRepair = new array<EntityAI>();
2906 repairIl = new InventoryLocation();
2907
2908 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
2909 if(swapValidation.m_Src2 != repairIl)
2910 {
2911 itemsToRepair.Insert(swapValidation.m_SrcItem2);
2912 }
2913
2914 if (itemsToRepair.Count())
2915 {
2917 }
2918#ifdef DIAG_DEVELOPER
2919 }
2920#endif
2921 }
2922
2926 if (swapValidation.m_Success && !PlayerCheckSwapItemsRequest(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, GameInventory.c_MaxItemDistanceRadius))
2927 {
2928#ifdef ENABLE_LOGGING
2930 {
2931 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString());
2932 }
2933
2935 {
2936 syncDebugPrint("[cheat] ValidateSwapServer man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2937 }
2938#endif
2939
2940 RemoveMovableOverride(swapValidation.m_SrcItem1);
2941 RemoveMovableOverride(swapValidation.m_SrcItem2);
2942
2943 swapValidation.m_Success = false;
2944 }
2945
2946 RemoveMovableOverride(swapValidation.m_SrcItem1);
2947 RemoveMovableOverride(swapValidation.m_SrcItem2);
2948
2952 if (swapValidation.m_Success && !GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
2953 {
2954#ifdef ENABLE_LOGGING
2955 #ifdef DEVELOPER
2956 DumpInventoryDebug();
2957 #endif
2958
2960 {
2961 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString());
2962 }
2963#endif
2964
2965 if (swapValidation.m_Dst1)
2966 {
2967 SendRepairToClientDst(swapValidation.m_Dst1);
2968 }
2969
2970 if (swapValidation.m_Dst2)
2971 {
2972 SendRepairToClientDst(swapValidation.m_Dst2);
2973 }
2974 swapValidation.m_Success = false;
2975 }
2976
2977 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
2978 {
2979 Error("ValidateSwapServer: cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2980 return true;
2981 }
2982
2983 JunctureRequestResult resultSwap = TryAcquireTwoInventoryJuncturesFromServer(playerOwner, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
2984 if (resultSwap == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
2985 {
2986 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem1);
2987 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem2);
2988
2989#ifdef ENABLE_LOGGING
2991 {
2992 Debug.InventoryMoveLog("Success - item swap without juncture", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2993 }
2994#endif
2995
2996 if (swapValidation.m_Success)
2997 {
2998 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
2999 ctx = new ScriptInputUserData();
3000 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
3001 validation.m_Result = InventoryValidationResult.SUCCESS;
3002 }
3003
3004 return true;
3005 }
3006 else if (swapValidation.m_Success && resultSwap == JunctureRequestResult.JUNCTURE_ACQUIRED)
3007 {
3008#ifdef ENABLE_LOGGING
3010 {
3011 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
3012 }
3013#endif
3014
3015 validation.m_Result = InventoryValidationResult.JUNCTURE;
3016 EnableMovableOverride(swapValidation.m_SrcItem1);
3017 EnableMovableOverride(swapValidation.m_SrcItem2);
3018 return true;
3019 }
3020 else
3021 {
3022#ifdef ENABLE_LOGGING
3024 {
3025 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
3026 }
3027#endif
3028
3029 validation.m_Result = InventoryValidationResult.FAILED;
3030 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
3031 return true;
3032 }
3033
3034 //Not end here
3035 return true;
3036 }
3037
3039 {
3040 DayZPlayer playerOwner = GetDayZPlayerOwner();
3042 if (!swapValidation)
3043 {
3044 return false;
3045 }
3046
3047#ifdef ENABLE_LOGGING
3049 {
3050 Debug.InventoryMoveLog("STS = " + playerOwner.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2), "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3051 }
3052#endif
3053
3054 RemoveMovableOverride(swapValidation.m_SrcItem1);
3055 RemoveMovableOverride(swapValidation.m_SrcItem2);
3056
3057 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
3058 {
3059 Error("ExecuteSwapCommandServer: cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
3060 return true;
3061 }
3062
3063 bool hasJuncture = false;
3064 int nonNullCount = 0;
3065 bool failed = false;
3066
3067 if (swapValidation.m_SrcItem1 != null)
3068 {
3069 nonNullCount++;
3070 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem1))
3071 {
3072 failed = true;
3073 }
3074 }
3075
3076 if (!failed && swapValidation.m_SrcItem2 != null)
3077 {
3078 nonNullCount++;
3079 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem2))
3080 {
3081 failed = true;
3082 }
3083 }
3084
3085 if (!failed && swapValidation.m_DstItem1 != null)
3086 {
3087 nonNullCount++;
3088 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem1))
3089 {
3090 failed = true;
3091 }
3092 }
3093
3094 if (!failed && swapValidation.m_DstItem2 != null)
3095 {
3096 nonNullCount++;
3097 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem2))
3098 {
3099 failed = true;
3100 }
3101 }
3102
3103 hasJuncture = (nonNullCount > 0 && !failed);
3104
3105 if (!hasJuncture)
3106 {
3107#ifdef ENABLE_LOGGING
3109 {
3110 Debug.InventoryMoveLog("Failed - missing juncture", "SWAP", "n/a", "ExecuteSwapCommandServer", GetDayZPlayerOwner().ToString() );
3111 }
3112#endif
3113 swapValidation.m_Success = false;
3114 }
3115
3116 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem1);
3117 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem2);
3118
3119 //TODO: hotfix solution
3120 if (!SwapCheckExclusionMaskLocal(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2))
3121 {
3122#ifdef ENABLE_LOGGING
3124 {
3125 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3126 }
3127#endif
3128 return false;
3129 }
3130
3131 if(!GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
3132 {
3133#ifdef ENABLE_LOGGING
3135 {
3136 Debug.InventoryMoveLog("Failed - !CanForceSwapEntitiesEx", "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3137 }
3138#endif
3139 return false;
3140 }
3141
3142#ifdef ENABLE_LOGGING
3144 {
3145 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3146 }
3147#endif
3148
3149 if (swapValidation.m_Success)
3150 {
3151 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
3152 ctx = new ScriptInputUserData();
3153 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
3154 return true;
3155 }
3156
3157 return false;
3158 }
3159
3161 {
3162 DayZPlayer playerOwner = GetDayZPlayerOwner();
3164 if (!swapValidation)
3165 {
3166 return false;
3167 }
3168
3169#ifdef ENABLE_LOGGING
3171 {
3172 Debug.InventoryMoveLog("STS = " + playerOwner.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2), "SWAP" , "n/a", "ExecuteSwapCommandClient", playerOwner.ToString() );
3173 }
3174#endif
3175 RemoveMovableOverride(swapValidation.m_SrcItem1);
3176 RemoveMovableOverride(swapValidation.m_SrcItem2);
3177
3178 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
3179 {
3180 Error("ExecuteSwapCommandClient: cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
3181 return true;
3182 }
3183
3184 ClearInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1);
3185 ClearInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2);
3186
3187 //TODO: hotfix solution
3188 if (!SwapCheckExclusionMaskLocal(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2))
3189 {
3190#ifdef ENABLE_LOGGING
3192 {
3193 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SWAP" , "n/a", "ExecuteSwapCommandClient", playerOwner.ToString() );
3194 }
3195#endif
3196 return false;
3197 }
3198
3199 if(!GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
3200 {
3201#ifdef ENABLE_LOGGING
3203 {
3204 Debug.InventoryMoveLog("Failed - !CanForceSwapEntitiesEx", "SWAP" , "n/a", "ExecuteSwapCommandClient", playerOwner.ToString() );
3205 }
3206#endif
3207 return false;
3208 }
3209
3210#ifdef ENABLE_LOGGING
3212 {
3213 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ExecuteSwapCommandClient", playerOwner.ToString() );
3214 }
3215#endif
3216
3217 if (swapValidation.m_Success)
3218 {
3219 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
3220 ctx = new ScriptInputUserData();
3221 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
3222 }
3223
3224 return true;
3225 }
3226
3228 {
3229 DayZPlayer playerOwner = GetDayZPlayerOwner();
3231 if (!swapValidation)
3232 {
3233 return false;
3234 }
3235
3236#ifdef ENABLE_LOGGING
3238 {
3239 Debug.InventoryMoveLog("STS = " + playerOwner.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2), "SWAP" , "n/a", "ExecuteSwapCommandRemote", playerOwner.ToString() );
3240 }
3241#endif
3242
3243 if (!swapValidation.m_SrcItem1 || !swapValidation.m_SrcItem2)
3244 {
3245 if (!swapValidation.m_SrcItem2 && swapValidation.m_SrcItem1)
3246 {
3247 // Treat as a simple move of srcItem1 to dst1 on remote clients
3248 LocationSyncMoveEntity(swapValidation.m_Src1, swapValidation.m_Dst1);
3249 return true;
3250 }
3251 else if (!swapValidation.m_SrcItem1 && swapValidation.m_SrcItem2)
3252 {
3253 // Treat as a simple move of srcItem2 to dst2 on remote clients
3254 LocationSyncMoveEntity(swapValidation.m_Src2, swapValidation.m_Dst2);
3255 return true;
3256 }
3257 else
3258 {
3259 if (swapValidation.m_SkippedSwap)
3260 {
3261#ifdef ENABLE_LOGGING
3263 {
3264 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ExecuteSwapCommandRemote", playerOwner.ToString() );
3265 }
3266#endif
3267 }
3268 else
3269 {
3271#ifdef ENABLE_LOGGING
3273 {
3274 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ExecuteSwapCommandRemote", playerOwner.ToString() );
3275 }
3276#endif
3277
3278 Error("[syncinv] ExecuteSwapCommandRemote remote input (cmd=SWAP) dropped, item not in bubble");
3279 }
3280 }
3281
3282 return false;
3283 }
3284
3285 RemoveMovableOverride(swapValidation.m_SrcItem1);
3286 RemoveMovableOverride(swapValidation.m_SrcItem2);
3287
3288 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
3289 {
3290 Error("ExecuteSwapCommandRemote: cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
3291 return false;
3292 }
3293
3294 ClearInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1);
3295 ClearInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2);
3296
3297#ifdef ENABLE_LOGGING
3299 {
3300 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ExecuteSwapCommandRemote", playerOwner.ToString() );
3301 }
3302#endif
3303
3304 if (swapValidation.m_Success)
3305 {
3306 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
3307 ctx = new ScriptInputUserData();
3308 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
3309 return true;
3310 }
3311
3312 return false;
3313 }
3314
3319 bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
3320 {
3321 if (isJuncture && isRemote)
3322 {
3324 return false;
3325 }
3326
3327 int type = -1;
3328 if (!ctx.Read(type))
3329 {
3330 return false;
3331 }
3332
3333 InventoryValidation validation = new InventoryValidation();
3334 validation.m_IsJuncture = isJuncture;
3335 validation.m_IsRemote = isRemote;
3336 validation.m_Mode = InventoryMode.JUNCTURE;
3337
3339 Serializer serializer = ctx;
3340
3341 switch (type)
3342 {
3343 case InventoryCommandType.USER_RESERVATION_CANCEL:
3344 if (!ValidateUserReservationCancel(serializer, validation))
3345 {
3346 return false;
3347 }
3348 break;
3349 case InventoryCommandType.SYNC_MOVE:
3350 if (!ValidateSyncMove(serializer, validation))
3351 {
3352 return false;
3353 }
3354 break;
3355 case InventoryCommandType.HAND_EVENT:
3356 if (!ValidateHandEvent(serializer, validation))
3357 {
3358 return false;
3359 }
3360 break;
3361 case InventoryCommandType.SWAP:
3362 if (!ValidateSwap(serializer, validation))
3363 {
3364 return false;
3365 }
3366 break;
3367 default:
3368 break;
3369 }
3370
3371 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
3372
3373 switch (validation.m_Result)
3374 {
3375 case InventoryValidationResult.FAILED:
3376 if (canSendJuncture)
3377 {
3379 if (!serializer.CanWrite())
3380 {
3381 ScriptInputUserData writeableSerializer();
3382 writeableSerializer.CopyFrom(serializer);
3383 serializer = writeableSerializer;
3384 }
3385
3386 serializer.Write(validation.m_Reason);
3387
3388 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
3389 }
3390 break;
3391 case InventoryValidationResult.JUNCTURE:
3392 if (canSendJuncture)
3393 {
3394 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, serializer);
3395 //StoreInputForRemotes(isJuncture, isRemote, serializer);
3396 }
3397 else
3398 {
3399 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
3400 }
3401 break;
3402 case InventoryValidationResult.SUCCESS:
3403 StoreInputForRemotes(isJuncture, isRemote, serializer);
3404 break;
3405 }
3406
3407 return true;
3408 }
3409
3410 bool ValidateInventoryCommandServer(ParamsReadContext ctx) // Send juncture Server
3411 {
3412 int type = -1;
3413 if (!ctx.Read(type))
3414 {
3415 return false;
3416 }
3417
3418 InventoryValidation validation = new InventoryValidation();
3419 validation.m_IsJuncture = false;
3420 validation.m_IsRemote = false;
3421 validation.m_Mode = InventoryMode.JUNCTURE;
3422
3424 Serializer serializer = ctx;
3425
3426 switch (type)
3427 {
3428 case InventoryCommandType.USER_RESERVATION_CANCEL:
3429 if (!ValidateUserReservationCancel(serializer, validation))
3430 {
3431 return false;
3432 }
3433 break;
3434 case InventoryCommandType.SYNC_MOVE:
3435 if (!ValidateSyncMoveServer(serializer, validation))
3436 {
3437 return false;
3438 }
3439 break;
3440 case InventoryCommandType.HAND_EVENT:
3441 if (!ValidateHandEventServer(serializer, validation))
3442 {
3443 return false;
3444 }
3445 break;
3446 case InventoryCommandType.SWAP:
3447 if (!ValidateSwapServer(serializer, validation))
3448 {
3449 return false;
3450 }
3451 break;
3452 default:
3453 break;
3454 }
3455
3456
3457 switch (validation.m_Result)
3458 {
3459 case InventoryValidationResult.FAILED:
3460#ifdef ENABLE_LOGGING
3462 {
3463 Debug.InventoryMoveLog("InventoryValidationResult.FAILED STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ValidateInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3464 }
3465#endif
3467 if (!serializer.CanWrite())
3468 {
3469 ScriptInputUserData writeableSerializer();
3470 writeableSerializer.CopyFrom(serializer);
3471 serializer = writeableSerializer;
3472 }
3473 serializer.Write(validation.m_Reason);
3474
3475 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
3476 break;
3477 case InventoryValidationResult.JUNCTURE:
3478#ifdef ENABLE_LOGGING
3480 {
3481 Debug.InventoryMoveLog("InventoryValidationResult.JUNCTURE sended STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ValidateInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3482 }
3483#endif
3484 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, serializer);
3485 break;
3486 case InventoryValidationResult.SUCCESS:
3487#ifdef ENABLE_LOGGING
3489 {
3490 Debug.InventoryMoveLog("InventoryValidationResult.SUCCESS executed STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ValidateInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3491 }
3492#endif
3493 StoreInputForRemotes(false, false, serializer);
3494 break;
3495 }
3496
3497 return true;
3498
3499
3500 }
3502 {
3503 int type = -1;
3504 if (!ctx.Read(type))
3505 {
3506 return false;
3507 }
3508
3510 Serializer serializer = ctx;
3511
3512 switch (type)
3513 {
3514 case InventoryCommandType.USER_RESERVATION_CANCEL:
3515 Error("JunctureServer - InventoryCommandType.USER_RESERVATION_CANCEL");
3516 return false;
3517 case InventoryCommandType.SYNC_MOVE:
3518 if (!ExecuteSyncMoveCommandServer(serializer))
3519 {
3520#ifdef ENABLE_LOGGING
3522 {
3523 Debug.InventoryMoveLog("Failed - ExecuteSyncMoveCommandServer STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3524 }
3525#endif
3526 return false;
3527 }
3528 break;
3529 case InventoryCommandType.HAND_EVENT:
3530 if (!ExecuteHandEventCommandServer(serializer))
3531 {
3532#ifdef ENABLE_LOGGING
3534 {
3535 Debug.InventoryMoveLog("Failed - ExecuteHandEventCommandServer STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3536 }
3537#endif
3538 return false;
3539 }
3540 break;
3541 case InventoryCommandType.SWAP:
3542 if (!ExecuteSwapCommandServer(serializer))
3543 {
3544#ifdef ENABLE_LOGGING
3546 {
3547 Debug.InventoryMoveLog("Failed - ExecuteSwapCommandServer STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3548 }
3549#endif
3550 return false;
3551 }
3552 break;
3553 default:
3554 break;
3555 }
3556
3557#ifdef ENABLE_LOGGING
3559 {
3560 Debug.InventoryMoveLog("Executed STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandServer", GetDayZPlayerOwner().ToString() );
3561 }
3562#endif
3563
3564 StoreInputForRemotes(true, false, serializer);
3565 return true;
3566
3567 }
3568
3569 bool ExecuteInventoryCommandClient(ParamsReadContext ctx) // React to juncture Client
3570 {
3571 int type = -1;
3572 if (!ctx.Read(type))
3573 {
3574 return false;
3575 }
3576
3578 Serializer serializer = ctx;
3579
3580 switch (type)
3581 {
3582 case InventoryCommandType.USER_RESERVATION_CANCEL:
3583 Error("JunctureClient - InventoryCommandType.USER_RESERVATION_CANCEL");
3584 break;
3585 case InventoryCommandType.SYNC_MOVE:
3586 if (!ExecuteSyncMoveCommandClient(serializer))
3587 {
3588#ifdef ENABLE_LOGGING
3590 {
3591 Debug.InventoryMoveLog("Failed - ExecuteSyncMoveCommandClient STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandClient", GetDayZPlayerOwner().ToString() );
3592 }
3593#endif
3594 return false;
3595 }
3596 break;
3597 case InventoryCommandType.HAND_EVENT:
3598 if (!ExecuteHandEventCommandClient(serializer))
3599 {
3600#ifdef ENABLE_LOGGING
3602 {
3603 Debug.InventoryMoveLog("Failed - ExecuteHandEventCommandClient STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandClient", GetDayZPlayerOwner().ToString() );
3604 }
3605#endif
3606 return false;
3607 }
3608 break;
3609 case InventoryCommandType.SWAP:
3610 if (!ExecuteSwapCommandClient(serializer))
3611 {
3612#ifdef ENABLE_LOGGING
3614 {
3615 Debug.InventoryMoveLog("Failed - ExecuteSwapCommandClient STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandClient", GetDayZPlayerOwner().ToString() );
3616 }
3617#endif
3618 return false;
3619 }
3620 break;
3621 default:
3622 break;
3623 }
3624
3625#ifdef ENABLE_LOGGING
3627 {
3628 Debug.InventoryMoveLog("Executed STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandClient", GetDayZPlayerOwner().ToString() );
3629 }
3630#endif
3631 return true;
3632 }
3634 {
3635 int type = -1;
3636 if (!ctx.Read(type))
3637 {
3638 return false;
3639 }
3640
3642 Serializer serializer = ctx;
3643
3644 switch (type)
3645 {
3646 case InventoryCommandType.USER_RESERVATION_CANCEL:
3647 if (!ExecuteUserReservationCancelRemote(serializer))
3648 {
3649 return false;
3650 }
3651 break;
3652 case InventoryCommandType.SYNC_MOVE:
3653 if (!ExecuteSyncMoveCommandRemote(serializer))
3654 {
3655 return false;
3656 }
3657 break;
3658 case InventoryCommandType.HAND_EVENT:
3659 if (!ExecuteHandEventCommandRemote(serializer))
3660 {
3661 return false;
3662 }
3663 break;
3664 case InventoryCommandType.SWAP:
3665 if (!ExecuteSwapCommandRemote(serializer))
3666 {
3667 return false;
3668 }
3669 break;
3670 default:
3671 break;
3672 }
3673
3674#ifdef ENABLE_LOGGING
3676 {
3677 Debug.InventoryMoveLog("Executed STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "SYNC_MOVE" , "n/a", "ExecuteInventoryCommandRemote", GetDayZPlayerOwner().ToString() );
3678 }
3679#endif
3680 return true;
3681 }
3682
3684 {
3685 ItemBase itemIB = ItemBase.Cast(item);
3686 if (itemIB)
3687 itemIB.SetCanBeMovedOverride(false);
3688 }
3689
3691 {
3692 ItemBase itemIB = ItemBase.Cast(item);
3693 if (itemIB)
3694 itemIB.SetCanBeMovedOverride(true);
3695 }
3696
3697 // Hacky solution for dealing with fencekit rope related issues, could be fixed by introducing some indicator that this item behaves differently or sth..
3699 {
3700 Rope rope = Rope.Cast(src.GetItem());
3701 if (rope)
3702 rope.SetTargetLocation(dst);
3703 }
3704
3706 {
3707 return (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER) || (GetDayZPlayerOwner() == g_Game.GetPlayer());
3708 }
3709
3710 bool StoreInputForRemotes (bool handling_juncture, bool remote, ParamsReadContext ctx)
3711 {
3712 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
3713 {
3714 #ifdef ENABLE_LOGGING
3716 {
3717 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString() );
3718 }
3719 #endif
3720
3721 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
3722 return true;
3723 }
3724
3725 return false;
3726 }
3727
3728 override bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
3729 {
3730 if (GetManOwner().IsAlive() == false)
3731 return super.TakeToDst(mode, src, dst);
3732
3733 #ifdef ENABLE_LOGGING
3735 {
3736 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
3737 }
3738 #endif
3739
3740 switch (mode)
3741 {
3742 case InventoryMode.SERVER:
3743 if (RedirectToHandEvent(mode, src, dst))
3744 {
3745 #ifdef ENABLE_LOGGING
3747 {
3748 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
3749 }
3750 #endif
3751
3752 return true;
3753 }
3754
3755
3756 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
3757 {
3758 if (g_Game.AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
3759 {
3760#ifdef ENABLE_LOGGING
3762 {
3763 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
3764 }
3765#endif
3766 }
3767 else
3768 {
3769#ifdef ENABLE_LOGGING
3771 {
3772 Debug.InventoryMoveLog("Juncture failed", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
3773 }
3774
3776 {
3777 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
3778 }
3779#endif
3780
3781 return false;
3782 }
3783
3784 }
3785
3788
3790
3791#ifdef ENABLE_LOGGING
3793 {
3794 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));
3795 }
3796#endif
3797
3799 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
3800 #ifdef ENABLE_LOGGING
3802 {
3803 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() );
3804 }
3805 #endif
3806 return true;
3807
3808 case InventoryMode.LOCAL:
3809 LocationSyncMoveEntity(src, dst);
3810 return true;
3811 }
3812 if (!super.TakeToDst(mode,src,dst))
3813 {
3814 return PostDeferredEventTakeToDst(mode,src,dst);
3815 }
3816 return true;
3817 }
3818
3820 {
3821 if (!super.PostDeferredEventTakeToDst(mode,src,dst))
3822 return false;
3823
3824 if (!m_DeferredEvent)
3825 {
3826 m_DeferredEvent = new DeferredTakeToDst(mode,src,dst);
3827 if (m_DeferredEvent.ReserveInventory(this))
3828 return true;
3829 }
3830
3831 m_DeferredEvent = null;
3832 return false;
3833 }
3834
3835 void HandleTakeToDst( DeferredEvent deferred_event )
3836 {
3837 DeferredTakeToDst deferred_take_to_dst = DeferredTakeToDst.Cast(deferred_event);
3838 if( deferred_take_to_dst )
3839 {
3840 #ifdef ENABLE_LOGGING
3842 {
3843 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
3844 }
3845 #endif
3846
3847 deferred_take_to_dst.ClearInventoryReservation(this);
3848
3850 {
3851 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));
3852 }
3853
3854 switch (deferred_take_to_dst.m_mode)
3855 {
3856 case InventoryMode.PREDICTIVE:
3857 #ifdef ENABLE_LOGGING
3859 {
3860 Debug.InventoryHFSMLog("PREDICTIVE STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
3861 }
3862 #endif
3863
3864 if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
3865 {
3866 #ifdef DIAG_DEVELOPER
3867 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
3868 {
3869 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
3870 }
3871 else
3872 {
3873 #endif
3874 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
3875 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
3876 #ifdef DIAG_DEVELOPER
3877 }
3878 #endif
3879 }
3880 else
3881 {
3882 #ifdef ENABLE_LOGGING
3884 {
3885 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() );
3886 }
3887 #endif
3888 }
3889 break;
3890 case InventoryMode.JUNCTURE:
3891 #ifdef ENABLE_LOGGING
3893 {
3894 Debug.InventoryHFSMLog("JUNCTURE STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
3895 }
3896 #endif
3897
3898 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
3899 {
3900 #ifdef DIAG_DEVELOPER
3901 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
3902 {
3903 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
3904 }
3905 else
3906 {
3907 #endif
3908 DayZPlayer player = g_Game.GetPlayer();
3909 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
3910 EnableMovableOverride(deferred_take_to_dst.m_dst.GetItem());
3911 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
3912 #ifdef DIAG_DEVELOPER
3913 }
3914 #endif
3915 }
3916 else
3917 {
3918 #ifdef ENABLE_LOGGING
3920 {
3921 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());
3922 }
3923 #endif
3924 }
3925 break;
3926 case InventoryMode.LOCAL:
3927 #ifdef ENABLE_LOGGING
3929 {
3930 Debug.InventoryHFSMLog("LOCAL ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
3931 }
3932 #endif
3933 break;
3934 case InventoryMode.SERVER:
3935 #ifdef ENABLE_LOGGING
3937 {
3938 Debug.InventoryHFSMLog("SERVER ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
3939 }
3940 #endif
3941 break;
3942 default:
3943 Error("HandEvent - Invalid mode");
3944 break;
3945 }
3946 }
3947 }
3948
3949 override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
3950 {
3951 #ifdef ENABLE_LOGGING
3953 {
3954 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a" , "n/a", "SwapEntities", GetDayZPlayerOwner().ToString() );
3955 }
3956 #endif
3957
3958 InventoryLocation src1, src2, dst1, dst2;
3959 if( mode == InventoryMode.LOCAL )
3960 {
3961 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
3962 {
3963 LocationSwap(src1, src2, dst1, dst2);
3964 return true;
3965 }
3966 }
3967
3968 if(!super.SwapEntities(mode,item1,item2))
3969 {
3970 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
3971 {
3972 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
3973 }
3974 }
3975 return true;
3976 }
3977
3978 override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
3979 {
3980 if (!super.PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2))
3981 return false;
3982
3983 if (!m_DeferredEvent)
3984 {
3985 m_DeferredEvent = new DeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
3986 if (m_DeferredEvent.ReserveInventory(this))
3987 return true;
3988 }
3989
3990 m_DeferredEvent = null;
3991 return false;
3992 }
3993
3994 void HandleSwapEntities( DeferredEvent deferred_event )
3995 {
3996 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
3997 if( deferred_swap_entities )
3998 {
3999 deferred_swap_entities.ClearInventoryReservation(this);
4000 InventoryLocation src1, src2, dst1, dst2;
4001 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
4002 {
4004 {
4005 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));
4006 }
4007
4008 switch (deferred_swap_entities.m_mode)
4009 {
4010 case InventoryMode.PREDICTIVE:
4011 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
4012 {
4013 #ifdef DIAG_DEVELOPER
4014 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4015 {
4016 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4017 }
4018 else
4019 {
4020 #endif
4021
4022 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4023 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4024
4025 #ifdef DIAG_DEVELOPER
4026 }
4027 #endif
4028 }
4029 else
4030 {
4031 #ifdef ENABLE_LOGGING
4033 {
4034 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() );
4035 }
4036 #endif
4037 }
4038 break;
4039
4040 case InventoryMode.JUNCTURE:
4041 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
4042 {
4043 #ifdef DIAG_DEVELOPER
4044 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4045 {
4046 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4047 }
4048 else
4049 {
4050 #endif
4051
4052 DayZPlayer player = g_Game.GetPlayer();
4053 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
4054 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
4055 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
4056 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
4057 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4058
4059 #ifdef DIAG_DEVELOPER
4060 }
4061 #endif
4062 }
4063 else
4064 {
4065 #ifdef ENABLE_LOGGING
4067 {
4068 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() );
4069 }
4070 #endif
4071 }
4072 break;
4073
4074 case InventoryMode.LOCAL:
4075 break;
4076
4077 default:
4078 Error("SwapEntities - HandEvent - Invalid mode");
4079 }
4080 }
4081 else
4082 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
4083 }
4084 }
4085
4086 override bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
4087 {
4088 #ifdef ENABLE_LOGGING
4090 {
4091 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
4092 }
4093 #endif
4094
4095 InventoryLocation src1, src2, dst1;
4096 if( mode == InventoryMode.LOCAL )
4097 {
4098 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
4099 {
4100 LocationSwap(src1, src2, dst1, item2_dst);
4101 return true;
4102 }
4103
4104 }
4105
4106 if(!super.ForceSwapEntities(mode,item1,item2,item2_dst))
4107 {
4108 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
4109 {
4110 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, item2_dst);
4111 }
4112 }
4113
4114 return true;
4115 }
4116
4118 {
4119 DeferredForceSwapEntities deferred_force_swap_entities = DeferredForceSwapEntities.Cast(deferred_event);
4120 if (deferred_force_swap_entities)
4121 {
4122 deferred_force_swap_entities.ClearInventoryReservation(this);
4125 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
4126 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
4127
4128 DayZPlayer player = g_Game.GetPlayer();
4129
4131 {
4132 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));
4133 }
4134
4135 switch (deferred_force_swap_entities.m_mode)
4136 {
4137 case InventoryMode.PREDICTIVE:
4138 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))
4139 {
4140 #ifdef DIAG_DEVELOPER
4141 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4142 {
4143 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
4144 }
4145 else
4146 {
4147 #endif
4148 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
4149 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
4150 #ifdef DIAG_DEVELOPER
4151 }
4152 #endif
4153 }
4154 else
4155 {
4156 #ifdef ENABLE_LOGGING
4158 {
4159 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());
4160 }
4161 #endif
4162 }
4163 break;
4164
4165 case InventoryMode.JUNCTURE:
4166 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))
4167 {
4168 #ifdef DIAG_DEVELOPER
4169 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4170 {
4171 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
4172 }
4173 else
4174 {
4175 #endif
4176
4177
4178 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
4179 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
4180
4181 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
4182 #ifdef DIAG_DEVELOPER
4183 }
4184 #endif
4185 }
4186 else
4187 {
4188 #ifdef ENABLE_LOGGING
4190 {
4191 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());
4192 }
4193 #endif
4194 }
4195 break;
4196
4197 case InventoryMode.LOCAL:
4198 break;
4199
4200 default:
4201 Error("ForceSwapEntities - HandEvent - Invalid mode");
4202 }
4203 }
4204 }
4205
4207 {
4208 if (g_Game.IsServer())
4209 {
4210 if (e.IsServerSideOnly())
4211 {
4212 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
4213 }
4214
4215 if (player.IsAlive())
4216 {
4217 InventoryLocation dst = e.GetDst();
4218 InventoryLocation src = e.GetSrc();
4219 if (src.IsValid() && dst.IsValid())
4220 {
4221 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
4222 {
4223#ifdef ENABLE_LOGGING
4225 {
4226 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
4227 }
4228#endif
4229
4230 if (g_Game.AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
4231 {
4232#ifdef ENABLE_LOGGING
4234 {
4235 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
4236 }
4237#endif
4238 }
4239 else
4240 {
4241#ifdef ENABLE_LOGGING
4243 {
4244 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
4245 }
4246#endif
4247 }
4248 }
4249
4250#ifdef ENABLE_LOGGING
4252 {
4253 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));
4254 }
4255#endif
4256
4259 player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, ctx);
4260
4261#ifdef ENABLE_LOGGING
4263 {
4264 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));
4265 }
4266#endif
4267
4269 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
4270 }
4271 }
4272 else
4273 {
4274 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
4275 }
4276 }
4277 }
4278
4282 override void NetSyncCurrentStateID (int id)
4283 {
4284 super.NetSyncCurrentStateID(id);
4285
4286 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
4287 }
4288
4295 override void OnAfterStoreLoad ()
4296 {
4297 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
4298 }
4299
4304 {
4305 if (GetEntityInHands())
4306 {
4307 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
4308 if (wpn)
4309 {
4311
4313 if (pb && e)
4314 {
4315 pb.GetWeaponManager().SetRunning(true);
4316
4318 {
4319 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
4320 }
4321
4322 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
4323 {
4324 wpn.ProcessWeaponAbortEvent(e);
4325 }
4326 else
4327 {
4328 wpn.ProcessWeaponEvent(e);
4329 }
4330 pb.GetWeaponManager().SetRunning(false);
4331 }
4332 }
4333 else
4334 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
4335 }
4336 else
4337 Error("OnEventForRemoteWeapon - no entity in hands");
4338 return true;
4339 }
4340
4341
4346 {
4347 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
4348 if (e)
4349 {
4351 {
4352 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
4353 }
4354
4355 //m_FSM.ProcessEvent(e);
4356
4357 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
4358 {
4360 m_FSM.ProcessAbortEvent(e, aa);
4361 }
4362 else
4363 {
4364 m_FSM.ProcessEvent(e);
4365 }
4366
4367 return true;
4368 }
4369 return false;
4370 }
4371
4373 {
4375 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
4376 {
4378
4380 e.WriteToContext(ctx);
4381
4383 {
4384 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
4385 }
4386
4387 p.StoreInputForRemotes(ctx);
4388 }
4389 }
4390
4392 {
4393 super.OnHandsExitedStableState(src, dst);
4394
4396 {
4397 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
4398 }
4399 }
4400
4402 {
4403 super.OnHandsEnteredStableState(src, dst);
4404
4406 {
4407 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
4408 }
4409 }
4410
4412 {
4413 super.OnHandsStateChanged(src, dst);
4414
4416 {
4417 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
4418 }
4419
4420 if (src.IsIdle())
4421 OnHandsExitedStableState(src, dst);
4422
4423 if (dst.IsIdle())
4424 OnHandsEnteredStableState(src, dst);
4425
4426#ifdef ROBOCLIENT
4428 if (p && p.m_Bot)
4429 {
4430 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
4431 }
4432#endif
4433 }
4434
4436 {
4437 if (!IsProcessing())
4438 {
4439 EntityAI itemInHands = GetEntityInHands();
4440
4442 il.SetHands(GetInventoryOwner(), itemInHands);
4443
4444 InventoryValidation validation = new InventoryValidation();
4445 validation.m_Mode = mode;
4446 if (e.CanPerformEventEx(validation))
4447 {
4448 m_DeferredEvent = new DeferredHandEvent(mode, e);
4449 if (m_DeferredEvent.ReserveInventory(this))
4450 {
4451 return true;
4452 }
4453 }
4454
4455 m_DeferredEvent = null;
4456
4458 if (!g_Game.IsMultiplayer() || g_Game.IsClient())
4459 {
4461 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
4462 }
4463 else
4464 {
4465 ScriptInputUserData serializer();
4466
4468 serializer.Write(validation.m_Reason);
4469
4470 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
4471 }
4472 }
4473
4474 return false;
4475 }
4476
4478 {
4479 DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(m_DeferredEvent);
4480 if (!deferred_hand_event)
4481 return;
4482
4483 SyncHandEventToRemote(deferred_hand_event.m_event);
4484 }
4485
4486 void HandleHandEvent(DeferredEvent deferred_event)
4487 {
4489 InventoryValidation validation = new InventoryValidation();
4490
4491 DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(deferred_event);
4492 if (deferred_hand_event)
4493 {
4494 #ifdef ENABLE_LOGGING
4496 {
4497 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
4498 }
4499 #endif
4500
4502 {
4503 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
4504 }
4505
4506 validation.m_Mode = deferred_hand_event.m_mode;
4507
4508 switch (deferred_hand_event.m_mode)
4509 {
4510 case InventoryMode.PREDICTIVE:
4511 #ifdef ENABLE_LOGGING
4513 {
4514 Debug.InventoryHFSMLog("PREDICTIVE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
4515 }
4516 #endif
4517
4518 deferred_hand_event.ClearInventoryReservation(this);
4519 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
4520 {
4521 #ifdef DIAG_DEVELOPER
4522 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4523 {
4524 ProcessHandEvent(deferred_hand_event.m_event);
4525 }
4526 else
4527 {
4528 #endif
4530 ProcessHandEvent(deferred_hand_event.m_event);
4531 #ifdef DIAG_DEVELOPER
4532 }
4533 #endif
4534 }
4535 break;
4536
4537 case InventoryMode.JUNCTURE:
4538 #ifdef ENABLE_LOGGING
4540 {
4541 Debug.InventoryHFSMLog("JUNCTURE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
4542 }
4543 #endif
4544
4545 deferred_hand_event.ClearInventoryReservation(this);
4546 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
4547 {
4548 #ifdef DIAG_DEVELOPER
4549 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4550 {
4551 ProcessHandEvent(deferred_hand_event.m_event);
4552 }
4553 else
4554 {
4555 #endif
4556 deferred_hand_event.ReserveInventory(this);
4558
4559 //Functionality to prevent desync when two players perform interfering action at the same time
4560 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
4561 EntityAI itemDst = null;
4562 if (deferred_hand_event.m_event.GetDst())
4563 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
4564 if (itemSrc)
4565 EnableMovableOverride(itemSrc);
4566 if (itemDst)
4567 EnableMovableOverride(itemDst);
4568 #ifdef DIAG_DEVELOPER
4569 }
4570 #endif
4571 }
4572 break;
4573
4574 case InventoryMode.LOCAL:
4575 #ifdef ENABLE_LOGGING
4577 {
4578 Debug.InventoryHFSMLog("LOCAL", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
4579 }
4580 #endif
4581
4582 deferred_hand_event.ClearInventoryReservation(this);
4583 ProcessHandEvent(deferred_hand_event.m_event);
4584 //PostHandEvent(deferred_hand_event.m_event);
4585 break;
4586
4587 case InventoryMode.SERVER:
4588 #ifdef ENABLE_LOGGING
4590 {
4591 Debug.InventoryHFSMLog("SERVER", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
4592 }
4593
4595 {
4596 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
4597 }
4598 #endif
4599
4600 if (!deferred_hand_event.m_event.IsServerSideOnly())
4601 {
4602 if (GetDayZPlayerOwner().IsAlive())
4603 {
4605 }
4606 else
4607 {
4609 }
4610 }
4611 else
4612 {
4613 ProcessHandEvent(deferred_hand_event.m_event);
4614 }
4615 break;
4616
4617 default:
4618 Error("HumanInventory::HandEvent - Invalid mode");
4619 }
4620 }
4621 }
4622
4624 {
4625 super.HandleInventoryManipulation();
4627 {
4632
4633 m_DeferredEvent = null;
4634 }
4635 }
4636
4637
4638
4640 {
4641 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
4642 }
4643
4644 bool PlayerCheckRequestSrc ( notnull InventoryLocation src, float radius )
4645 {
4646 bool result = true;
4647
4648 EntityAI ent = src.GetParent();
4649 if ( ent )
4650 {
4651 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
4652 if (player)
4653 {
4654 if ( GetDayZPlayerOwner() != player )
4655 {
4656 if (player.IsAlive())
4657 {
4658 if (!player.IsRestrained() && !player.IsUnconscious())
4659 {
4660 return false;
4661 }
4662 }
4663 }
4664 }
4665 }
4666
4667 if ( result )
4668 {
4669 result = CheckRequestSrc( GetManOwner(), src, radius);
4670 }
4671
4672 if (result)
4673 {
4674 EntityAI item = src.GetItem().GetHierarchyRoot();
4675 EntityAI root = item.GetHierarchyRoot();
4676 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
4677 }
4678
4679 return result;
4680 }
4681
4682 bool PlayerCheckRequestDst ( notnull InventoryLocation src, notnull InventoryLocation dst, float radius )
4683 {
4684 bool result = true;
4685
4686 EntityAI ent = dst.GetParent();
4687 if ( ent )
4688 {
4689 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
4690 if (player)
4691 {
4692 if ( GetDayZPlayerOwner() != player )
4693 {
4694 if (player.IsAlive())
4695 {
4696 if (!player.IsRestrained() && !player.IsUnconscious())
4697 {
4698 result = false;
4699 }
4700 }
4701 }
4702 }
4703 }
4704
4705 if (!LocationCanMoveEntity(src, dst))
4706 {
4707 result = false;
4708 }
4709
4710
4711 if ( result )
4712 {
4713 result = CheckMoveToDstRequest( GetManOwner(), src, dst, radius);
4714 }
4715
4716 if (result)
4717 {
4718 EntityAI item = dst.GetItem().GetHierarchyRoot();
4719 EntityAI root = item.GetHierarchyRoot();
4720 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
4721 }
4722
4723 return result;
4724 }
4725
4727 {
4728 #ifdef DIAG_DEVELOPER
4729 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
4730 {
4731 #endif
4732 array<EntityAI> itemsToRepair = new array<EntityAI>;
4733 switch(dst.GetType())
4734 {
4735 case InventoryLocationType.CARGO:
4736 InventoryLocation ilCargoItem = new InventoryLocation;
4737 CargoBase cargo = dst.GetParent().GetInventory().GetCargo();
4738 for(int i = cargo.GetItemCount() - 1; i >= 0 ; --i)
4739 {
4740 EntityAI itemInCargo = cargo.GetItem(i);
4741 itemInCargo.GetInventory().GetCurrentInventoryLocation(ilCargoItem);
4742 if (dst.CollidesWith(ilCargoItem))
4743 {
4744 itemsToRepair.Insert(itemInCargo);
4745 }
4746 }
4747 break;
4748 case InventoryLocationType.ATTACHMENT:
4749 EntityAI entityInAttachment = dst.GetParent().GetInventory().FindAttachment(dst.GetSlot());
4750
4751 if(entityInAttachment)
4752 {
4753 itemsToRepair.Insert(entityInAttachment);
4754 }
4755 break;
4756 case InventoryLocationType.HANDS:
4757 EntityAI entityInHands = GetEntityInHands();
4758 if(entityInHands)
4759 {
4760 itemsToRepair.Insert(entityInHands);
4761 }
4762
4763 break;
4764 default:
4765 break;
4766 }
4767
4768 if(itemsToRepair.Count() > 0)
4769 {
4771 }
4772 #ifdef DIAG_DEVELOPER
4773 }
4774 #endif
4775 }
4776
4777 bool PlayerCheckSwapItemsRequest( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
4778 {
4779 bool result = true;
4780
4781 EntityAI ent = dst1.GetParent();
4782 PlayerBase player;
4783 if ( ent )
4784 {
4785 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
4786 if (player)
4787 {
4788 if ( GetDayZPlayerOwner() != player )
4789 {
4790 if (player.IsAlive())
4791 {
4792 if (!player.IsRestrained() && !player.IsUnconscious())
4793 {
4794 return false;
4795 }
4796 }
4797 }
4798 }
4799 }
4800
4801 ent = dst2.GetParent();
4802 if ( ent )
4803 {
4804 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
4805 if (player)
4806 {
4807 if ( GetDayZPlayerOwner() != player )
4808 {
4809 if (player.IsAlive())
4810 {
4811 if (!player.IsRestrained() && !player.IsUnconscious())
4812 {
4813 return false;
4814 }
4815 }
4816 }
4817 }
4818 }
4819
4820
4821 if ( result )
4822 {
4823 result = CheckSwapItemsRequest( GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
4824 }
4825
4826 EntityAI item;
4827 EntityAI root;
4828
4829 if (result)
4830 {
4831 item = dst1.GetItem().GetHierarchyRoot();
4832 root = item.GetHierarchyRoot();
4833
4834 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
4835 }
4836
4837 if (result)
4838 {
4839 item = dst2.GetItem().GetHierarchyRoot();
4840 root = item.GetHierarchyRoot();
4841
4842 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
4843 }
4844
4845 return result;
4846
4847 }
4848
4849 bool PlayerCheckDropRequest ( notnull InventoryLocation src, float radius )
4850 {
4851 bool result = true;
4852
4853 EntityAI ent = src.GetParent();
4854 if ( ent )
4855 {
4856 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
4857 if (player)
4858 {
4859 if ( GetDayZPlayerOwner() != player )
4860 {
4861 if (player.IsAlive())
4862 {
4863 if (!player.IsRestrained() && !player.IsUnconscious())
4864 {
4865 return false;
4866 }
4867 }
4868 }
4869 }
4870 }
4871
4872 if ( result )
4873 {
4874 result = CheckDropRequest( GetManOwner(), src, radius);
4875 }
4876
4877 return result;
4878 }
4879
4882 {
4883 if (dst.GetType() == InventoryLocationType.ATTACHMENT)
4884 {
4885 return dst.GetParent().CheckAttachmentReceiveExclusion(src.GetItem(),dst.GetSlot());
4886 }
4887
4888 return true;
4889 }
4890
4892 bool SwapCheckExclusionMaskLocal ( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
4893 {
4894 bool failed = false;
4895
4896 if (dst1.GetType() == InventoryLocationType.ATTACHMENT)
4897 {
4898 failed |= !dst1.GetParent().CheckAttachmentReceiveExclusion(dst1.GetItem(),dst1.GetSlot());
4899 }
4900
4901 if (dst2.GetType() == InventoryLocationType.ATTACHMENT)
4902 {
4903 failed |= !dst2.GetParent().CheckAttachmentReceiveExclusion(dst2.GetItem(),dst2.GetSlot());
4904 }
4905 return !failed;
4906 }
4907
4908 [Obsolete("No replacement")]
4910 {
4912
4913 if (validation.m_IsJuncture)
4914 {
4921
4922 return true;
4923 }
4924
4926 src.ReadFromContext(ctx);
4927
4928 #ifdef ENABLE_LOGGING
4930 {
4931 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
4932 }
4933 #endif
4934
4935 if (validation.m_IsRemote && !src.GetItem())
4936 {
4937 #ifdef ENABLE_LOGGING
4939 {
4940 Debug.InventoryMoveLog("Failed item not exist", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
4941 }
4942 #endif
4943
4944 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
4945 return true;
4946 }
4947
4952 {
4953 #ifdef ENABLE_LOGGING
4955 {
4956 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
4957 }
4958 #endif
4959
4960 return true;
4961 }
4962
4967 {
4968 #ifdef ENABLE_LOGGING
4970 {
4971 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
4972 }
4973 #endif
4974
4975 return true;
4976 }
4977
4978 if (GetInventoryOwner() != src.GetParent())
4979 {
4980 #ifdef ENABLE_LOGGING
4982 {
4983 Debug.InventoryMoveLog("Failed PlayerDoesNotOwnItem", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
4984 }
4985 #endif
4986
4987 return true;
4988 }
4989
4990 #ifdef ENABLE_LOGGING
4992 {
4993 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
4994 }
4995 #endif
4996
4997 g_Game.ObjectDelete(src.GetItem());
4998
4999 validation.m_Result = InventoryValidationResult.SUCCESS;
5000 return true;
5001 }
5002
5003 override bool OnInventoryCheck(int userDataType, ParamsReadContext ctx)
5004 {
5005 if (userDataType == INPUT_UDT_INVENTORY_CHECK)
5006 {
5007 bool correct = true;
5008
5009 int count;
5010 array<EntityAI> itemsToRepair = new array<EntityAI>;
5011 InventoryLocation clientIl = new InventoryLocation;
5013 DayZPlayer player = GetDayZPlayerOwner();
5014
5015
5016 if(!ctx.Read(count))
5017 return false;
5018
5019 if (count > INVENTORY_REPAIR_MAX_ITEMS)
5020 return false;
5021
5022 for (int i = 0; i < count; i++)
5023 {
5024 if(!clientIl.ReadFromContext(ctx))
5025 {
5026 return false;
5027 }
5028
5029 EntityAI item = clientIl.GetItem();
5030 if (!item)
5031 continue;
5032
5033 Man itemOwner = item.GetHierarchyRootPlayer();
5034 if (itemOwner != player && vector.Distance(player.GetPosition(), item.GetPosition()) > INVENTORY_REPAIR_MAX_DISTANCE)
5035 continue;
5036
5037 item.GetInventory().GetCurrentInventoryLocation(realIl);
5038
5039 if(clientIl != realIl)
5040 {
5041 itemsToRepair.Insert(item);
5042 correct = false;
5043 }
5044 }
5045
5046 if (itemsToRepair.Count())
5047 {
5048 #ifdef DIAG_DEVELOPER
5049 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
5050 {
5051 #endif
5053 #ifdef DIAG_DEVELOPER
5054 }
5055 #endif
5056 }
5057
5058 return correct;
5059 }
5060 return false;
5061 }
5062}
void syncDebugPrint(string s)
void inventoryDebugPrint(string s)
InventoryCommandType
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
InventoryValidationResult
InventoryValidationReason
const int INPUT_UDT_INVENTORY
const int INPUT_UDT_INVENTORY_CHECK
const int INPUT_UDT_HAND_REMOTE_EVENT
void wpnDebugSpamALot(string s)
void wpnDebugPrint(string s)
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1120
DayZGame g_Game
Определения DayZGame.c:4074
override Widget Init()
Определения DayZGame.c:127
bool ExecuteHandEventCommandServer(inout Serializer ctx)
Определения DayZPlayerInventory.c:2047
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:4849
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:807
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1519
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3690
void OnHandleStoredInputUserData(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:722
bool SwapCheckExclusionMaskLocal(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:4892
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
Определения DayZPlayerInventory.c:3319
ref HandAnimatedForceSwapping m_FSwapping
Определения DayZPlayerInventory.c:160
m_DeferredEvent
void HandleHandEvent(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:4486
bool ExecuteInventoryCommandRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:3633
void HandleWeaponEvents(float dt, out bool exitIronSights)
Определения DayZPlayerInventory.c:348
proto native void StoreInputUserData(ParamsReadContext ctx)
void OnHandleStoredJunctureData(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:657
void SyncHandEventToRemote(HandEventBase e)
Определения DayZPlayerInventory.c:4372
void HandleTakeToDst(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:3835
bool ExecuteSyncMoveCommandClient(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:1398
void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:89
bool ExecuteHandEventCommandClient(inout Serializer ctx)
Определения DayZPlayerInventory.c:2170
ref HandAnimatedForceSwapping_Inst m_FSwappingInst
Определения DayZPlayerInventory.c:161
ref HandAnimatedSwapping m_Swapping
Определения DayZPlayerInventory.c:159
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:4909
bool MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:4881
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:3698
bool ExecuteSyncMoveCommandRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:1464
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:4644
void AbortWeaponEvent()
Определения DayZPlayerInventory.c:284
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:643
bool ExecuteHandEventCommandRemote(inout Serializer ctx)
Определения DayZPlayerInventory.c:2264
bool ValidateSyncMoveServer(ParamsReadContext ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1136
void PostWeaponEvent(WeaponEventBase e)
Определения DayZPlayerInventory.c:306
override void NetSyncCurrentStateID(int id)
Определения DayZPlayerInventory.c:4282
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:4401
bool IsServerOrLocalPlayer()
Определения DayZPlayerInventory.c:3705
bool ValidateSwapServer(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:2777
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:3728
override void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:559
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3683
static const int INVENTORY_REPAIR_MAX_ITEMS
MAx distance for itme to be repair (without it it can be use for getting position from server)
Определения DayZPlayerInventory.c:164
bool ExecuteSwapCommandClient(inout Serializer ctx)
Определения DayZPlayerInventory.c:3160
ref HandEventBase m_DeferredPostedHandEvent
Определения DayZPlayerInventory.c:154
void SyncDeferredEventToRemotes()
Определения DayZPlayerInventory.c:4477
bool ValidateHandEventServer(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1840
override void HandleInventoryManipulation()
Определения DayZPlayerInventory.c:4623
override bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:535
void DayZPlayerInventory()
limmit number of items transfere duting repair.
Определения DayZPlayerInventory.c:166
ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
Определения DayZPlayerInventory.c:157
override bool OnInventoryCheck(int userDataType, ParamsReadContext ctx)
Определения DayZPlayerInventory.c:5003
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
Определения DayZPlayerInventory.c:3949
ref HandAnimatedMovingToAtt m_MovingTo
Определения DayZPlayerInventory.c:158
void SendRepairToClientDst(notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:4726
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:15
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:4391
bool ValidateInventoryCommandServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:3410
override void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:4411
override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:3978
bool ExecuteSwapCommandServer(inout Serializer ctx)
Определения DayZPlayerInventory.c:3038
bool OnHandEventForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:4345
ref InventoryLocation m_dst1
Определения DayZPlayerInventory.c:86
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
Определения DayZPlayerInventory.c:155
void OnInputUserDataForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:761
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:170
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
Определения DayZPlayerInventory.c:127
override bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
Определения DayZPlayerInventory.c:4086
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:2357
void HandleSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:3994
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:4777
void HandleInventory(float dt)
Определения DayZPlayerInventory.c:447
static const float INVENTORY_REPAIR_MAX_DISTANCE
Определения DayZPlayerInventory.c:163
void DeferredWeaponFailed()
Определения DayZPlayerInventory.c:323
bool ExecuteSyncMoveCommandServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:1307
ref InventoryLocation m_dst
Определения DayZPlayerInventory.c:13
void HandleForceSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:4117
bool ExecuteInventoryCommandClient(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:3569
ref Timer m_DeferredWeaponTimer
Определения DayZPlayerInventory.c:150
override bool PostDeferredEventTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:3819
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:4682
bool OnEventForRemoteWeapon(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:4303
override void OnServerInventoryCommand(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:784
void CancelHandEvent()
cancels any handevents that will be executed this frame @NOTE: this is used in situations where the p...
Определения DayZPlayerInventory.c:272
bool ExecuteSwapCommandRemote(inout Serializer ctx)
Определения DayZPlayerInventory.c:3227
bool ExecuteInventoryCommandServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:3501
proto native void StoreJunctureData(ParamsReadContext ctx)
ref InventoryLocation m_dst2
Определения DayZPlayerInventory.c:87
DeferredSwapEntities m_item1
override bool HandEvent(InventoryMode mode, HandEventBase e)
Определения DayZPlayerInventory.c:4435
void CancelWeaponEvent()
Определения DayZPlayerInventory.c:278
class DeferredEvent m_src
EntityAI m_item2
Определения DayZPlayerInventory.c:85
static void SendServerHandEventViaJuncture(notnull DayZPlayer player, HandEventBase e)
Определения DayZPlayerInventory.c:4206
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Определения EmoteManager.c:517
proto string ToString()
WeaponEventBase WeaponAnimEventFactory(WeaponEvents type, DayZPlayer p=NULL, Magazine m=NULL)
creates animation system events
Определения Events.c:251
WeaponEventBase CreateWeaponEventFromContext(ParamsReadContext ctx)
Определения Events.c:281
WeaponEventID
identifier for events. mainly for rpc purposes
Определения Events.c:6
ProcessEventResult
Определения FSMBase.c:41
bool IsProcessing()
returns true when FP is heating or cooling
Определения FireplaceBase.c:1663
void fsmDebugSpam(string s)
Определения HFSMBase.c:9
bool CheckRequestSrc()
Определения Hand_Events.c:107
bool IsAuthoritative()
Определения Hand_Events.c:55
bool ReserveInventory()
Определения Hand_Events.c:177
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
Определения Hand_Events.c:853
JunctureRequestResult
Определения Hand_Events.c:28
HandEventID
events
Определения Hand_Events.c:7
bool IsOwner()
Определения Hand_Events.c:60
void ClearInventoryReservation()
Определения Hand_Events.c:196
bool IsProxy()
Определения Hand_Events.c:65
void hndDebugSpam(string s)
Определения HandFSM.c:9
void hndDebugSpamALot(string s)
Определения HandFSM.c:17
void hndDebugPrint(string s)
Определения HandFSM.c:1
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Определения HandFSM.c:28
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Junctures.c:2
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения Junctures.c:48
override void OnAfterStoreLoad()
engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase....
Определения PlayerStatBase.c:189
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
represents base for cargo storage for entities
Определения Cargo.c:7
Super root of all classes in Enforce script.
Определения EnScript.c:11
override void OnItemInHandsChanged()
Определения DayZPlayerImplement.c:997
Определения DayZPlayerImplement.c:87
static const int SJ_INVENTORY_FAILURE
Определения DayZPlayerSyncJunctures.c:32
static const int SJ_INVENTORY
Определения DayZPlayerSyncJunctures.c:11
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:208
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:198
Определения 3_Game/DayZ/tools/Debug.c:2
bool ReserveInventory(HumanInventory inventory)
Определения DayZPlayerInventory.c:5
void ClearInventoryReservation(HumanInventory inventory)
Определения DayZPlayerInventory.c:6
InventoryMode m_mode
Определения DayZPlayerInventory.c:4
override bool ReserveInventory(HumanInventory inventory)
Определения DayZPlayerInventory.c:133
ref HandEventBase m_event
Определения DayZPlayerInventory.c:126
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
Определения DayZPlayerInventory.c:127
override void ClearInventoryReservation(HumanInventory inventory)
Определения DayZPlayerInventory.c:138
EntityAI m_item1
Определения DayZPlayerInventory.c:42
ref InventoryLocation m_dst1
Определения DayZPlayerInventory.c:44
EntityAI m_item2
Определения DayZPlayerInventory.c:43
void DeferredSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:47
override void ClearInventoryReservation(HumanInventory inventory)
Определения DayZPlayerInventory.c:75
override bool ReserveInventory(HumanInventory inventory)
Определения DayZPlayerInventory.c:56
ref InventoryLocation m_dst2
Определения DayZPlayerInventory.c:45
static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
bool ClearInventoryReservationEx(EntityAI item, InventoryLocation dst)
const int c_InventoryReservationTimeoutShortMS
static bool MakeSrcAndDstForSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
static bool MakeSrcAndDstForForceSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
helper function for ForceSwap
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
const int c_InventoryReservationTimeoutMS
reservations
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst)
Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY,...
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
const float c_MaxItemDistanceRadius
anti-cheats
bool AddInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
script counterpart to engine's class Inventory
override InventoryLocation GetSecondDst()
Определения Hand_Events.c:605
override InventoryLocation GetDst()
Определения Hand_Events.c:215
override bool AcquireInventoryJunctureFromServer(notnull Man player)
Определения Hand_Events.c:255
override EntityAI GetSecondSrcEntity()
Определения Hand_Events.c:610
override bool IsServerSideOnly()
Определения Hand_Events.c:777
override string DumpToString()
Определения Hand_Events.c:333
override void ClearInventoryReservation()
Определения Hand_Events.c:724
override void WriteToContext(ParamsWriteContext ctx)
Определения Hand_Events.c:280
override bool CheckRequestSrc()
Определения Hand_Events.c:222
override bool CanPerformEventEx(InventoryValidation validation)
Определения Hand_Events.c:238
override InventoryLocation GetSecondSrc()
Определения Hand_Events.c:600
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:212
Определения Hand_Events.c:732
override bool IsIdle()
idle state does not expect any animation events
Определения HandStableState.c:34
override void OnUpdate(float dt)
Определения HandStableState.c:19
override bool IsWaitingForActionFinish()
waiting for active animation action/actionType finish
Определения HandAnimatedForceSwapping.c:73
represent hand state base
Определения HandAnimatedForceSwapping.c:4
proto native bool IsActionFinished()
proto native int GetRunningAction()
returns -1 when no action is running or RELOAD,MECHANISM, ....
proto native int IsEvent()
return -1 when there is no event, otherwise it returns pId of event from animation
proto native int GetRunningActionType()
returns -1 when no action is running or appropriate action type
Определения human.c:1027
inventory for plain man/human
Определения HumanInventory.c:10
HumanInventory... with FSM (synchronous, no anims)
Определения HumanInventoryWithFSM.c:6
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap
Определения InventoryInputUserData.c:70
static void SendInputUserDataHandEvent(HandEventBase e)
Определения InventoryInputUserData.c:112
static void SendServerInventoryCheck(array< EntityAI > items, DayZPlayer player)
Определения InventoryInputUserData.c:44
static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения InventoryInputUserData.c:13
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
Определения InventoryInputUserData.c:81
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
Определения InventoryInputUserData.c:105
static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
move
Определения InventoryInputUserData.c:5
static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
Определения InventoryInputUserData.c:123
ref InventoryLocation m_Src2
ref InventoryLocation m_Src1
ref InventoryLocation m_Dst1
ref InventoryLocation m_Dst2
proto native bool IsValid()
verify current set inventory location
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native EntityAI GetParent()
returns parent of current inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:233
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:310
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
InventoryValidationResult m_Result
InventoryValidationReason m_Reason
static bool IsWeaponLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:829
static bool IsSyncLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:789
static bool IsInventoryHFSMLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:779
static bool IsInventoryMoveLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:759
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
proto native bool CopyFrom(ParamsReadContext other)
proto static native bool CanStoreInputUserData()
Returns true when the channel is free, AND the InputBuffer is NOT full (same as '!...
Определения gameplay.c:121
proto bool Write(void value_out)
proto bool Read(void value_in)
proto native bool CanWrite()
Serialization general interface. Serializer API works with:
Определения Serializer.c:56
Определения DayZPlayerImplement.c:39
shorthand
Определения BoltActionRifle_Base.c:6
string DumpToString()
Определения Events.c:62
WeaponEventID GetEventID()
returns id from enum WeaponEventID
Определения Events.c:42
signalize mechanism manipulation
Определения Events.c:35
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:119
proto native void StoreInputForRemotes(ParamsWriteContext ctx)
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1084
proto native DayZPlayerInstanceType GetInstanceType()
Serializer ParamsReadContext
Определения gameplay.c:15
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
void Obsolete(string msg="")
Определения EnScript.c:371
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
WeaponActions
actions
Определения human.c:843
WeaponEvents
events
Определения human.c:996
string WeaponActionTypeToString(int A, int AT)
Определения human.c:976