DayZ 1.29
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
164 {
165 }
166
167 DayZPlayer GetDayZPlayerOwner () { return DayZPlayer.Cast(GetInventoryOwner()); }
168
170 {
171 DayZPlayer player;
172 if (!Class.CastTo(player, GetInventoryOwner()))
173 {
174 return false;
175 }
176
177 return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
178 }
179
180 bool IsOwner()
181 {
182 DayZPlayer player;
183 if (!Class.CastTo(player, GetInventoryOwner()))
184 {
185 return false;
186 }
187
188 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
189 }
190
191 bool IsProxy()
192 {
193 DayZPlayer player;
194 if (!Class.CastTo(player, GetInventoryOwner()))
195 {
196 return false;
197 }
198
199 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
200 }
201
202 override void Init ()
203 {
205 {
206 hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
207 }
208
209 CreateStableStates(); // stable states needs to be created first
210
211 m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
212 m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
213 m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
214 m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
215 m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
216
217 // events
218 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
219 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
220 HandEventBase __T__ = new HandEventTake;
221 HandEventBase __M__ = new HandEventMoveTo;
222 HandEventBase __W__ = new HandEventSwap;
223 //HandEventBase __D__ = new HandEventDropping;
224 HandEventBase __Xd_ = new HandEventDestroyed;
225 HandEventBase __F__ = new HandEventForceSwap;
226
227 // setup transitions
228 m_FSM.AddTransition(new HandTransition( m_Empty , __T__, m_Taking, NULL, new HandSelectAnimationOfTakeToHandsEvent(GetManOwner())));
229 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
230 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Equipped, null, null));
231 m_FSM.AddTransition(new HandTransition( m_Taking , __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
232 m_Taking.AddTransition(new HandTransition( m_Taking.m_Hide, _abt_, m_Empty));
233 m_Taking.AddTransition(new HandTransition( m_Taking.m_Show, _abt_, m_Equipped));
234
235 m_FSM.AddTransition(new HandTransition( m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
236 m_FSM.AddTransition(new HandTransition( m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
237 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
238 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Empty , null, null));
239 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Hide, _abt_, m_Equipped));
240 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Show, _abt_, m_Empty));
241
242 m_FSM.AddTransition(new HandTransition( m_Equipped, __W__, m_Swapping, NULL, new HandSelectAnimationOfSwapInHandsEvent(GetManOwner())));
243 m_FSM.AddTransition(new HandTransition( m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
244 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
245 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Equipped, null, null));
246 m_FSM.AddTransition(new HandTransition( m_Swapping, _abt_, m_Equipped, null, null));
247
248 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd( new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()) ) ));
249 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
250 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
251 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
252 m_FSM.AddTransition(new HandTransition( m_FSwappingInst, _abt_, m_Equipped, null, null));
253
254 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwapping, NULL, new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner())));
255 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
256 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
257 m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
258 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Start, _abt_, m_Equipped));
259 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Hide, _abt_, m_Empty));
260 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Show, _abt_, m_Equipped));
261
262 super.Init(); // initialize ordinary human fsm (no anims)
263 }
264
270 {
272 //m_postedHandEvent = null;
273 }
274
276 {
279 }
280
282 {
283 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
284
285 Weapon_Base weapon;
286 Class.CastTo(weapon, GetEntityInHands());
287
288 if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
289 {
291 {
292 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
293 }
294
295 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
296 }
297 }
298
304 {
305 if (m_DeferredWeaponEvent == NULL)
306 {
308
310 {
311 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
312 }
313 }
314 else
315 {
316 Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
317 }
318 }
319
321 {
322 Weapon_Base weapon;
323 Class.CastTo(weapon, GetEntityInHands());
324
325 string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
326
327 string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
328 if (weapon)
329 {
330 secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
331 secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
332 for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
333 {
334 secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
335 secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
336 if (i < weapon.GetMuzzleCount() - 1)
337 secondPart += " | ";
338 }
339 }
340
341 Error(firstPart + secondPart);
343 }
344
345 void HandleWeaponEvents (float dt, out bool exitIronSights)
346 {
347 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
348
349 Weapon_Base weapon;
350 Class.CastTo(weapon, GetEntityInHands());
351
352 if (weapon)
353 {
354 weapon.UpdateCoolDown(dt);
355 if (hcw && weapon.CanProcessWeaponEvents())
356 {
357
358 weapon.GetCurrentState().OnUpdate(dt);
359
361 {
362 wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
363 }
364
365 if (!weapon.IsIdle())
366 {
367 while (true)
368 {
369 int weaponEventId = hcw.IsEvent();
370 if (weaponEventId == -1)
371 {
372 break;
373 }
374
375 if (weaponEventId == WeaponEvents.CHANGE_HIDE)
376 {
377 break;
378 }
379
380 WeaponEventBase anim_event = WeaponAnimEventFactory(weaponEventId, GetDayZPlayerOwner(), NULL);
381
383 {
384 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
385 }
386
387 if (anim_event != NULL)
388 {
389 weapon.ProcessWeaponEvent(anim_event);
390 }
391 }
392
393 if (hcw.IsActionFinished())
394 {
395 if (weapon.IsWaitingForActionFinish())
396 {
398 {
399 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
400 }
401
402 weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
403 }
404 else
405 {
407 {
408 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
409 }
410
411 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
412 }
413 }
414 }
415
417 {
419 {
420 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
421 }
422
423 if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
424 {
425 exitIronSights = true;
426
428 {
429 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
430 }
431
434 }
435 else if (!m_DeferredWeaponTimer.IsRunning())
436 {
437 m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
438 }
439 }
440 }
441 }
442 }
443
444 void HandleInventory(float dt)
445 {
446 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
447
448 EntityAI ih = GetEntityInHands();
449 Weapon_Base weapon;
450 Class.CastTo(weapon, ih);
451
452 if (hcw)
453 {
454 HandStateBase fsmState = m_FSM.GetCurrentState();
455 fsmState.OnUpdate(dt);
456
457 #ifdef ENABLE_LOGGING
459 {
460 hndDebugSpamALot("[hndfsm] HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
461 }
462 #endif
463
464 if ( !fsmState.IsIdle() || !m_FSM.IsRunning())
465 {
466 while (true)
467 {
468 int weaponEventId = hcw.IsEvent();
469 if (weaponEventId == -1)
470 {
471 break;
472 }
473
474 HandEventBase anim_event = HandAnimEventFactory(weaponEventId, GetManOwner(), NULL);
475
476 #ifdef ENABLE_LOGGING
478 {
479 hndDebugPrint("[hndfsm] HandleInventory: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
480 }
481 #endif
482
483 if (anim_event != NULL)
484 {
485 SyncHandEventToRemote(anim_event);
486 ProcessHandEvent(anim_event);
487 }
488 }
489
490 if (hcw.IsActionFinished())
491 {
492 if (fsmState.IsWaitingForActionFinish())
493 {
494 #ifdef ENABLE_LOGGING
496 {
497 hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + fsmState);
498 }
499 #endif
500
501 HandEventBase fin_event = new HandEventHumanCommandActionFinished(GetManOwner());
502 SyncHandEventToRemote(fin_event);
503 ProcessHandEvent(fin_event);
504 }
505 else
506 {
507 #ifdef ENABLE_LOGGING
509 {
510 hndDebugPrint("[hndfsm] Hand-Weapon event: ABORT! notifying running state=" + fsmState);
511 }
512 #endif
513
514 HandEventBase abt_event = new HandEventHumanCommandActionAborted(GetManOwner());
515 SyncHandEventToRemote(abt_event);
516 ProcessHandAbortEvent(abt_event);
517 //m_FSM.ProcessHandAbortEvent(new WeaponEventHumanCommandActionAborted(GetManOwner()));
518 }
519 }
520 }
521 }
522 }
523
524
526
533 {
534 int tmp = -1;
535 ctx.Read(tmp);
536
537#ifdef ENABLE_LOGGING
539 {
540 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store Juncture packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
541 }
542#endif
543
545
546 return true;
547 }
548
550
557 {
570
571 if (g_Game.IsDedicatedServer())
572 {
573 return;
574 }
575
576 int udtIdentifier = -1;
577 if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
578 {
579 return;
580 }
581
585
586 InventoryCommandType type = -1;
587 if (!ctx.Read(type))
588 {
589 return;
590 }
591
592 switch (type)
593 {
594 case InventoryCommandType.SYNC_MOVE:
595 {
596 src.ReadFromContext(ctx);
597 dst.ReadFromContext(ctx);
598 ClearInventoryReservationEx(dst.GetItem(), dst);
599 break;
600 }
601 case InventoryCommandType.HAND_EVENT:
602 {
603 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
604 src = e.GetSrc();
605 dst = e.GetDst();
607 break;
608 }
609 case InventoryCommandType.SWAP:
610 {
611 src.ReadFromContext(ctx);
612 temp.ReadFromContext(ctx);
613 dst.ReadFromContext(ctx);
614 temp.ReadFromContext(ctx);
615
616 ClearInventoryReservationEx(dst.GetItem(), dst);
617 ClearInventoryReservationEx(temp.GetItem(), temp);
618 break;
619 }
620 case InventoryCommandType.FORCESWAP:
621 {
622 break;
623 }
624 case InventoryCommandType.DESTROY:
625 {
626 src.ReadFromContext(ctx);
627 break;
628 }
629 }
630
632 if (!ctx.Read(reason))
633 {
634 reason = InventoryValidationReason.UNKNOWN;
635 }
636
637 OnInventoryFailure(type, reason, src, dst);
638 }
639
641 {
642 if (reason == InventoryValidationReason.DROP_PREVENTED)
643 {
645 return;
646 }
647
648 }
649
655 {
656 int tmp = -1;
657 ctx.Read(tmp);
658
659#ifdef ENABLE_LOGGING
661 {
662 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
663 }
664#endif
665
667 ProcessInputData(ctx, true, false);
668 }
669
674 proto native void StoreJunctureData(ParamsReadContext ctx);
676
677
679
686 {
687#ifdef ENABLE_LOGGING
689 {
690 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
691 }
692#endif
693
695 return true;
696 }
697
703 {
704 int tmp = -1;
705 ctx.Read(tmp);
706
707#ifdef ENABLE_LOGGING
709 {
710 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
711 }
712#endif
713
714 ProcessInputData(ctx, false, false);
715 }
716
720 proto native void StoreInputUserData(ParamsReadContext ctx);
722
724 {
725#ifdef ENABLE_LOGGING
727 {
728 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
729 }
730#endif
731
732 ProcessInputData(ctx, false, true);
733 }
734
736 {
737#ifdef ENABLE_LOGGING
739 {
740 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
741 }
742#endif
743
744 ProcessInputData(ctx, true, true);
745 }
746
748 {
750
753 bool success = true;
754
755 src.ReadFromContext(ctx);
756 dst.ReadFromContext(ctx);
757
758 #ifdef ENABLE_LOGGING
760 {
761 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
762 }
763 #endif
764
765 EntityAI itemSrc = src.GetItem();
766 EntityAI itemDst = dst.GetItem();
767
768 if (validation.m_IsRemote && (!itemSrc || !itemDst))
769 {
771
772#ifdef ENABLE_LOGGING
774 {
775 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
776 }
777
779 {
780 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
781 }
782#endif
783
784 return true;
785 }
786
787 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && itemSrc != itemDst)
788 {
789 #ifdef ENABLE_LOGGING
791 {
792 Debug.InventoryMoveLog("Failed - src and dst are for different items", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
793 }
794
796 {
797 syncDebugPrint("[syncinv] HandleInputData Failed - src and dst are for different items src item =" + itemSrc + " dst item =" + itemDst);
798 }
799 #endif
800
801 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
802 {
803 success = false;
804 }
805 else
806 {
807 return true;
808 }
809 }
810
811 EnableMovableOverride(itemSrc);
812
816 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
817 {
819
820#ifdef ENABLE_LOGGING
822 {
823 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
824 }
825
827 {
828 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
829 }
830#endif
831
832 RemoveMovableOverride(itemSrc);
833
834 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
835 {
836 success = false;
837 #ifdef DIAG_DEVELOPER
838 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
839 {
840 #endif
841 array<EntityAI> itemsToRepair = new array<EntityAI>;
843 src.GetItem().GetInventory().GetCurrentInventoryLocation(realIl);
844
845 if(src != realIl)
846 {
847 itemsToRepair.Insert(src.GetItem());
849 }
850 #ifdef DIAG_DEVELOPER
851 }
852 #endif
853 }
854 else
855 {
856 return true;
857 }
858 }
859
863 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
864 {
865#ifdef ENABLE_LOGGING
867 {
868 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
869 }
870
872 {
873 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
874 }
875#endif
876
877 RemoveMovableOverride(itemSrc);
878
879 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
880 {
882 success = false;
883 }
884 else
885 {
886 return true;
887 }
888 }
889
890 RemoveMovableOverride(itemSrc);
891
892#ifdef ENABLE_LOGGING
894 {
895 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));
896 }
897#endif
898
900 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
901 {
903 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
904 {
905 #ifdef ENABLE_LOGGING
907 {
908 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
909 }
910 #endif
911 if (success)
912 {
914
915 LocationSyncMoveEntity(src, dst);
916
917 validation.m_Result = InventoryValidationResult.SUCCESS;
918 }
919 return true;
920 }
921 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
922 {
923 #ifdef ENABLE_LOGGING
925 {
926 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
927 }
928 #endif
929
931 {
932 #ifdef ENABLE_LOGGING
933
934 #ifdef DEVELOPER
935 DumpInventoryDebug();
936 #endif
937
939 {
940 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
941 }
942 #endif
943 validation.m_Result = InventoryValidationResult.FAILED;
944 return true;
945 }
946
947 validation.m_Result = InventoryValidationResult.JUNCTURE;
948 EnableMovableOverride(itemSrc);
949 return true;
950 }
951 else
952 {
953 #ifdef ENABLE_LOGGING
955 {
956 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
957 }
958 #endif
959
960 validation.m_Result = InventoryValidationResult.FAILED;
961 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
962 return true;
963 }
964 }
965 // Check whether the juncture for the related player and items has been acquired.
966 else if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
967 {
968 bool hasJuncture = false;
969 if (itemSrc != null && itemDst != null)
970 {
971 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
972 }
973 else if (itemSrc != null)
974 {
975 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
976 }
977 else if (itemDst != null)
978 {
979 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
980 }
981
982 if (!hasJuncture)
983 {
984 success = false;
985 }
986 }
987
988 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
989 {
990 ClearInventoryReservationEx(itemDst, dst);
991 }
992
994 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
995 {
996 CheckForRope(src, dst);
997 }
998
1002 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
1003 {
1004 #ifdef ENABLE_LOGGING
1005
1006 #ifdef DEVELOPER
1007 DumpInventoryDebug();
1008 #endif
1009
1011 {
1012 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1013 }
1014 #endif
1015
1016 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1017 return true;
1018 }
1019
1020 //TODO: hotfix solution
1021 if (!validation.m_IsRemote && validation.m_IsJuncture && !MoveCheckExclusionMaskLocal(src,dst))
1022 {
1023 #ifdef ENABLE_LOGGING
1025 {
1026 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1027 }
1028 #endif
1029 return false;
1030 }
1031
1032 #ifdef ENABLE_LOGGING
1034 {
1035 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1036 }
1037 #endif
1038
1039 if (success)
1040 {
1041 LocationSyncMoveEntity(src, dst);
1042 validation.m_Result = InventoryValidationResult.SUCCESS;
1043 }
1044
1045 return true;
1046 }
1047
1049 {
1051 bool success = true;
1052
1053 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1055
1059 e.m_IsRemote = validation.m_IsRemote;
1060 e.m_IsJuncture = validation.m_IsJuncture;
1061
1062 EntityAI itemSrc = e.GetSrcEntity();
1063 EntityAI itemDst = e.GetSecondSrcEntity();
1064
1065 #ifdef ENABLE_LOGGING
1067 {
1068 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1069 }
1070 #endif
1071
1072 if (validation.m_IsRemote && !e.GetSrcEntity())
1073 {
1075 if (itemDst && (e.GetEventID() == HandEventID.SWAP || e.GetEventID() == HandEventID.FORCESWAP)) //presumed swap, replace with take
1076 {
1077 InventoryLocation srcNew = new InventoryLocation();
1078 srcNew.Copy(e.GetSrc());
1079 e = HandEventBase.HandEventFactory(HandEventID.TAKE, e.m_Player, srcNew);
1080
1081 Error("[syncinv] HandleInputData remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.DumpToString() + "), src item is null! Continuing.");
1082 }
1083 else
1084 {
1085 #ifdef ENABLE_LOGGING
1087 {
1088 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1089 }
1090 #endif
1091
1092 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1093
1094 return true;
1095 }
1096 }
1097
1099 if (itemSrc)
1100 RemoveMovableOverride(itemSrc);
1101 if (itemDst)
1102 RemoveMovableOverride(itemDst);
1103
1107 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1108 {
1109 #ifdef ENABLE_LOGGING
1111 {
1112 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1113 }
1114 #endif
1115
1116 if (!validation.m_IsRemote)
1117 {
1118 ctx = new ScriptInputUserData;
1120 }
1121
1122 RemoveMovableOverride(itemSrc);
1123 RemoveMovableOverride(itemDst);
1124
1125 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1126 {
1127 success = false;
1128 #ifdef DIAG_DEVELOPER
1129 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1130 {
1131 #endif
1132 array<EntityAI> itemsToRepair = new array<EntityAI>;
1133 InventoryLocation repairIl = new InventoryLocation();
1134 itemSrc.GetInventory().GetCurrentInventoryLocation(repairIl);
1135
1136 if(e.GetSrc() != repairIl)
1137 {
1138 itemsToRepair.Insert(itemSrc);
1139 }
1140
1141 if(itemDst && itemSrc != itemDst )
1142 {
1143 itemDst.GetInventory().GetCurrentInventoryLocation(repairIl);
1144 if(e.GetSecondSrc() != repairIl)
1145 {
1146 itemsToRepair.Insert(itemDst);
1147 }
1148 }
1149
1150 if (itemsToRepair.Count())
1151 {
1153 }
1154 #ifdef DIAG_DEVELOPER
1155 }
1156 #endif
1157 }
1158 else
1159 {
1160 return true;
1161 }
1162 }
1163
1164 if (success && !e.CheckRequestEx(validation))
1165 {
1166 #ifdef ENABLE_LOGGING
1168 {
1169 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1170 }
1171 #endif
1172
1174
1175 ctx = new ScriptInputUserData;
1177
1178#ifdef ENABLE_LOGGING
1180 {
1181 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1182 }
1183#endif
1184
1185 RemoveMovableOverride(itemSrc);
1186 RemoveMovableOverride(itemDst);
1187
1188 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1189 {
1190 success = false;
1191 }
1192 else
1193 {
1194 return true;
1195 }
1196 }
1197
1200 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1201 {
1202 #ifdef ENABLE_LOGGING
1204 {
1205 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1206 }
1207 #endif
1208
1210
1211 ctx = new ScriptInputUserData;
1213
1214#ifdef ENABLE_LOGGING
1216 {
1217 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1218 }
1219#endif
1220
1221 RemoveMovableOverride(itemSrc);
1222 RemoveMovableOverride(itemDst);
1223
1224 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1225 {
1226 InventoryLocation ilDst = e.GetDst();
1227 if (ilDst)
1228 SendRepairToClientDst(ilDst);
1229
1230 ilDst = e.GetSecondDst();
1231 if (ilDst)
1232 SendRepairToClientDst(ilDst);
1233
1234 success = false;
1235 }
1236 else
1237 {
1238 return true;
1239 }
1240 }
1241
1242 RemoveMovableOverride(itemSrc);
1243 RemoveMovableOverride(itemDst);
1244
1246 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1247 {
1249 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1250 {
1251 #ifdef ENABLE_LOGGING
1253 {
1254 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1255 }
1256 #endif
1257
1259 }
1260 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1261 {
1262 #ifdef ENABLE_LOGGING
1264 {
1265 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1266 }
1267 #endif
1268
1269 ctx = new ScriptInputUserData;
1271
1272 validation.m_Result = InventoryValidationResult.JUNCTURE;
1273
1274 if (itemSrc)
1275 EnableMovableOverride(itemSrc);
1276 if (itemDst)
1277 EnableMovableOverride(itemDst);
1278 return true;
1279 }
1280 else
1281 {
1282 #ifdef ENABLE_LOGGING
1284 {
1285 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1286 }
1287 #endif
1288
1289 validation.m_Result = InventoryValidationResult.FAILED;
1290 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1291 return true;
1292 }
1293 }
1294 // Check whether the juncture for the related player and items has been acquired.
1295 else if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1296 {
1297 bool hasJuncture = false;
1298
1299 if (itemSrc != null && itemDst != null)
1300 {
1301 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1302 }
1303 else if (itemSrc != null)
1304 {
1305 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
1306 }
1307 else if (itemDst != null)
1308 {
1309 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1310 }
1311
1312 if (!hasJuncture)
1313 {
1314 success = false;
1315 }
1316 }
1317
1319 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1320 {
1321 CheckForRope(e.GetSrc(), e.GetDst());
1322 }
1323
1324 #ifdef ENABLE_LOGGING
1326 {
1327 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1328 }
1329 #endif
1330
1331 if (success)
1332 {
1333 validation.m_Result = InventoryValidationResult.SUCCESS;
1334 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1335 {
1337 //result = InventoryValidationResult.FAILURE;
1338 }
1339 }
1340
1341 return true;
1342 }
1343
1344 bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
1345 {
1346 DayZPlayer playerOwner = GetDayZPlayerOwner();
1348 if (!swapValidation)
1349 return false;
1350
1351 array<EntityAI> itemsToRepair;
1352 InventoryLocation repairIl;
1353
1354 #ifdef ENABLE_LOGGING
1356 {
1357 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() );
1358 }
1359 #endif
1360
1361 if (validation.m_IsRemote && (!swapValidation.m_SrcItem1 || !swapValidation.m_SrcItem2))
1362 {
1363 if (!swapValidation.m_SrcItem2 && swapValidation.m_SrcItem1)
1364 {
1365 // Treat as a simple move of srcItem1 to dst1 on remote clients
1366 LocationSyncMoveEntity(swapValidation.m_Src1, swapValidation.m_Dst1);
1367 validation.m_Result = InventoryValidationResult.SUCCESS;
1368 return true;
1369 }
1370 else if (!swapValidation.m_SrcItem1 && swapValidation.m_SrcItem2)
1371 {
1372 // Treat as a simple move of srcItem2 to dst2 on remote clients
1373 LocationSyncMoveEntity(swapValidation.m_Src2, swapValidation.m_Dst2);
1374 validation.m_Result = InventoryValidationResult.SUCCESS;
1375 return true;
1376 }
1377 else
1378 {
1379 if (swapValidation.m_SkippedSwap)
1380 {
1381 #ifdef ENABLE_LOGGING
1383 {
1384 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
1385 }
1386 #endif
1387 }
1388 else
1389 {
1391 #ifdef ENABLE_LOGGING
1393 {
1394 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
1395 }
1396 #endif
1397
1398 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1399 }
1400 }
1401
1402 return true;
1403 }
1404
1405 EnableMovableOverride(swapValidation.m_SrcItem1);
1406 EnableMovableOverride(swapValidation.m_SrcItem2);
1407
1408 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && (swapValidation.m_SrcItem1 != swapValidation.m_DstItem1 || swapValidation.m_SrcItem2 != swapValidation.m_DstItem2) )
1409 {
1410 #ifdef ENABLE_LOGGING
1412 {
1413 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
1414 Debug.InventoryMoveLog("Failed - src and dst are for different for first item", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1415 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
1416 Debug.InventoryMoveLog("Failed - src and dst are for different for second item", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1417 }
1418
1420 {
1421 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
1422 syncDebugPrint("[syncinv] HandleInputData Failed - first src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
1423 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
1424 syncDebugPrint("[syncinv] HandleInputData Failed - second src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
1425 }
1426 #endif
1427
1428 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1429 {
1430 swapValidation.m_Success = false;
1431 }
1432 else
1433 {
1434 return true;
1435 }
1436 }
1437
1441 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(swapValidation.m_Src1, GameInventory.c_MaxItemDistanceRadius))
1442 {
1443 #ifdef ENABLE_LOGGING
1445 {
1446 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
1447 }
1448
1450 {
1451 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1));
1452 }
1453 #endif
1454
1455 RemoveMovableOverride(swapValidation.m_SrcItem1);
1456 RemoveMovableOverride(swapValidation.m_SrcItem2);
1457
1458 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1459 {
1460 swapValidation.m_Success = false;
1461 #ifdef DIAG_DEVELOPER
1462 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1463 {
1464 #endif
1465 itemsToRepair = new array<EntityAI>;
1466 repairIl = new InventoryLocation;
1467
1468 swapValidation.m_SrcItem1.GetInventory().GetCurrentInventoryLocation(repairIl);
1469
1470 if(swapValidation.m_Src1 != repairIl)
1471 {
1472 itemsToRepair.Insert(swapValidation.m_SrcItem1);
1473 }
1474
1475 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
1476 if(swapValidation.m_Src2 != repairIl)
1477 {
1478 itemsToRepair.Insert(swapValidation.m_SrcItem2);
1479 }
1480
1481 if (itemsToRepair.Count())
1482 {
1484 }
1485 #ifdef DIAG_DEVELOPER
1486 }
1487 #endif
1488 }
1489 else
1490 {
1491 return true;
1492 }
1493 }
1494
1498 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(swapValidation.m_Src2, GameInventory.c_MaxItemDistanceRadius))
1499 {
1500 #ifdef ENABLE_LOGGING
1502 {
1503 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
1504 }
1505
1507 {
1508 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2));
1509 }
1510 #endif
1511
1512 RemoveMovableOverride(swapValidation.m_SrcItem1);
1513 RemoveMovableOverride(swapValidation.m_SrcItem2);
1514
1515 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1516 {
1517 swapValidation.m_Success = false;
1518 #ifdef DIAG_DEVELOPER
1519 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1520 {
1521 #endif
1522 itemsToRepair = new array<EntityAI>;
1523 repairIl = new InventoryLocation;
1524
1525 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
1526 if(swapValidation.m_Src2 != repairIl)
1527 {
1528 itemsToRepair.Insert(swapValidation.m_SrcItem2);
1529 }
1530
1531 if (itemsToRepair.Count())
1532 {
1534 }
1535 #ifdef DIAG_DEVELOPER
1536 }
1537 #endif
1538 }
1539 else
1540 {
1541 return true;
1542 }
1543 }
1544
1548 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))
1549 {
1550 #ifdef ENABLE_LOGGING
1552 {
1553 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString());
1554 }
1555
1557 {
1558 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));
1559 }
1560 #endif
1561
1562 RemoveMovableOverride(swapValidation.m_SrcItem1);
1563 RemoveMovableOverride(swapValidation.m_SrcItem2);
1564
1565 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1566 {
1567 swapValidation.m_Success = false;
1568 }
1569 else
1570 {
1571 return true;
1572 }
1573 }
1574
1575 RemoveMovableOverride(swapValidation.m_SrcItem1);
1576 RemoveMovableOverride(swapValidation.m_SrcItem2);
1577
1578 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1579 {
1580 ClearInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1);
1581 ClearInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2);
1582 }
1583
1587 if (swapValidation.m_Success && !validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
1588 {
1589 #ifdef ENABLE_LOGGING
1590 #ifdef DEVELOPER
1591 DumpInventoryDebug();
1592 #endif
1593
1595 {
1596 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString());
1597 }
1598 #endif
1599
1600 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1601 {
1602 if (swapValidation.m_Dst1)
1603 SendRepairToClientDst(swapValidation.m_Dst1);
1604
1605 if (swapValidation.m_Dst2)
1606 SendRepairToClientDst(swapValidation.m_Dst2);
1607 swapValidation.m_Success = false;
1608 }
1609 else
1610 {
1611 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));
1612 return true;
1613 }
1614 }
1615
1616 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1617 {
1618 AddInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1619 AddInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1620 }
1621
1622 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
1623 {
1624 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));
1625 return true;
1626 }
1627
1628 if (playerOwner.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1629 {
1631 if (!validation.m_IsJuncture)
1632 {
1633 JunctureRequestResult resultSwap = TryAcquireTwoInventoryJuncturesFromServer(playerOwner, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
1634 if (resultSwap == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1635 {
1636 #ifdef ENABLE_LOGGING
1638 {
1639 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1640 }
1641 #endif
1642
1644 }
1645 else if (swapValidation.m_Success && resultSwap == JunctureRequestResult.JUNCTURE_ACQUIRED)
1646 {
1647 #ifdef ENABLE_LOGGING
1649 {
1650 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1651 }
1652 #endif
1653
1654 validation.m_Result = InventoryValidationResult.JUNCTURE;
1655 EnableMovableOverride(swapValidation.m_SrcItem1);
1656 EnableMovableOverride(swapValidation.m_SrcItem2);
1657 return true;
1658 }
1659 else
1660 {
1661 #ifdef ENABLE_LOGGING
1663 {
1664 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1665 }
1666 #endif
1667
1668 validation.m_Result = InventoryValidationResult.FAILED;
1669 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1670 return true;
1671 }
1672 }
1674 else if (validation.m_IsJuncture)
1675 {
1676 bool hasJuncture = false;
1677 int nonNullCount = 0;
1678 bool failed = false;
1679
1680 if (swapValidation.m_SrcItem1 != null)
1681 {
1682 nonNullCount++;
1683 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem1))
1684 failed = true;
1685 }
1686
1687 if (!failed && swapValidation.m_SrcItem2 != null)
1688 {
1689 nonNullCount++;
1690 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem2))
1691 failed = true;
1692 }
1693
1694 if (!failed && swapValidation.m_DstItem1 != null)
1695 {
1696 nonNullCount++;
1697 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem1))
1698 failed = true;
1699 }
1700
1701 if (!failed && swapValidation.m_DstItem2 != null)
1702 {
1703 nonNullCount++;
1704 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem2))
1705 failed = true;
1706 }
1707
1708 hasJuncture = (nonNullCount > 0 && !failed);
1709
1710 if (!hasJuncture)
1711 {
1712 swapValidation.m_Success = false;
1713 }
1714 }
1715 }
1716
1717 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1718 {
1719 ClearInventoryReservationEx(swapValidation.m_DstItem1, swapValidation.m_Dst1);
1720 ClearInventoryReservationEx(swapValidation.m_DstItem2, swapValidation.m_Dst2);
1721 }
1722 else
1723 {
1724 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem1);
1725 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem2);
1726 }
1727
1728 //TODO: hotfix solution
1729 if (!validation.m_IsRemote && validation.m_IsJuncture && !SwapCheckExclusionMaskLocal(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2))
1730 {
1731 #ifdef ENABLE_LOGGING
1733 {
1734 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", playerOwner.ToString() );
1735 }
1736 #endif
1737 return false;
1738 }
1739
1740 #ifdef ENABLE_LOGGING
1742 {
1743 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", playerOwner.ToString() );
1744 }
1745 #endif
1746
1747 if (swapValidation.m_Success)
1748 {
1749 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
1750 ctx = new ScriptInputUserData();
1751 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
1752 validation.m_Result = InventoryValidationResult.SUCCESS;
1753 }
1754
1755 return true;
1756 }
1757
1762 bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
1763 {
1764 if (isJuncture && isRemote)
1765 {
1767 return false;
1768 }
1769
1770 int type = -1;
1771 if (!ctx.Read(type))
1772 {
1773 return false;
1774 }
1775
1776 InventoryValidation validation = new InventoryValidation();
1777 validation.m_IsJuncture = isJuncture;
1778 validation.m_IsRemote = isRemote;
1779 validation.m_Mode = InventoryMode.JUNCTURE;
1780
1782 Serializer serializer = ctx;
1783
1784 switch (type)
1785 {
1786 case InventoryCommandType.USER_RESERVATION_CANCEL:
1787 if (!ValidateUserReservationCancel(serializer, validation))
1788 {
1789 return false;
1790 }
1791 break;
1792 case InventoryCommandType.SYNC_MOVE:
1793 if (!ValidateSyncMove(serializer, validation))
1794 {
1795 return false;
1796 }
1797 break;
1798 case InventoryCommandType.HAND_EVENT:
1799 if (!ValidateHandEvent(serializer, validation))
1800 {
1801 return false;
1802 }
1803 break;
1804 case InventoryCommandType.SWAP:
1805 if (!ValidateSwap(serializer, validation))
1806 {
1807 return false;
1808 }
1809 break;
1810 default:
1811 break;
1812 }
1813
1814 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1815
1816 switch (validation.m_Result)
1817 {
1818 case InventoryValidationResult.FAILED:
1819 if (canSendJuncture)
1820 {
1822 if (!serializer.CanWrite())
1823 {
1824 ScriptInputUserData writeableSerializer();
1825 writeableSerializer.CopyFrom(serializer);
1826 serializer = writeableSerializer;
1827 }
1828
1829 serializer.Write(validation.m_Reason);
1830
1831 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
1832 }
1833 break;
1834 case InventoryValidationResult.JUNCTURE:
1835 if (canSendJuncture)
1836 {
1837 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, serializer);
1838 //StoreInputForRemotes(isJuncture, isRemote, serializer);
1839 }
1840 else
1841 {
1842 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1843 }
1844 break;
1845 case InventoryValidationResult.SUCCESS:
1846 StoreInputForRemotes(isJuncture, isRemote, serializer);
1847 break;
1848 }
1849
1850 return true;
1851 }
1852
1854 {
1855 ItemBase itemIB = ItemBase.Cast(item);
1856 if (itemIB)
1857 itemIB.SetCanBeMovedOverride(false);
1858 }
1859
1861 {
1862 ItemBase itemIB = ItemBase.Cast(item);
1863 if (itemIB)
1864 itemIB.SetCanBeMovedOverride(true);
1865 }
1866
1867 // Hacky solution for dealing with fencekit rope related issues, could be fixed by introducing some indicator that this item behaves differently or sth..
1869 {
1870 Rope rope = Rope.Cast(src.GetItem());
1871 if (rope)
1872 rope.SetTargetLocation(dst);
1873 }
1874
1876 {
1877 return (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER) || (GetDayZPlayerOwner() == g_Game.GetPlayer());
1878 }
1879
1880 bool StoreInputForRemotes (bool handling_juncture, bool remote, ParamsReadContext ctx)
1881 {
1882 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1883 {
1884 #ifdef ENABLE_LOGGING
1886 {
1887 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString() );
1888 }
1889 #endif
1890
1891 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1892 return true;
1893 }
1894
1895 return false;
1896 }
1897
1898 override bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
1899 {
1900 if (GetManOwner().IsAlive() == false)
1901 return super.TakeToDst(mode, src, dst);
1902
1903 #ifdef ENABLE_LOGGING
1905 {
1906 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1907 }
1908 #endif
1909
1910 switch (mode)
1911 {
1912 case InventoryMode.SERVER:
1913 if (RedirectToHandEvent(mode, src, dst))
1914 {
1915 #ifdef ENABLE_LOGGING
1917 {
1918 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1919 }
1920 #endif
1921
1922 return true;
1923 }
1924
1925
1926 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1927 {
1928 if (g_Game.AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1929 {
1930#ifdef ENABLE_LOGGING
1932 {
1933 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1934 }
1935#endif
1936 }
1937 else
1938 {
1939#ifdef ENABLE_LOGGING
1941 {
1942 Debug.InventoryMoveLog("Juncture failed", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1943 }
1944
1946 {
1947 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1948 }
1949#endif
1950
1951 return false;
1952 }
1953
1954 }
1955
1958
1960
1961#ifdef ENABLE_LOGGING
1963 {
1964 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));
1965 }
1966#endif
1967
1969 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1970 #ifdef ENABLE_LOGGING
1972 {
1973 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() );
1974 }
1975 #endif
1976 return true;
1977
1978 case InventoryMode.LOCAL:
1979 LocationSyncMoveEntity(src, dst);
1980 return true;
1981 }
1982 if (!super.TakeToDst(mode,src,dst))
1983 {
1984 return PostDeferredEventTakeToDst(mode,src,dst);
1985 }
1986 return true;
1987 }
1988
1990 {
1991 if (!super.PostDeferredEventTakeToDst(mode,src,dst))
1992 return false;
1993
1994 if (!m_DeferredEvent)
1995 {
1996 m_DeferredEvent = new DeferredTakeToDst(mode,src,dst);
1997 if (m_DeferredEvent.ReserveInventory(this))
1998 return true;
1999 }
2000
2001 m_DeferredEvent = null;
2002 return false;
2003 }
2004
2005 void HandleTakeToDst( DeferredEvent deferred_event )
2006 {
2007 DeferredTakeToDst deferred_take_to_dst = DeferredTakeToDst.Cast(deferred_event);
2008 if( deferred_take_to_dst )
2009 {
2010 #ifdef ENABLE_LOGGING
2012 {
2013 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
2014 }
2015 #endif
2016
2017 deferred_take_to_dst.ClearInventoryReservation(this);
2018
2020 {
2021 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));
2022 }
2023
2024 switch (deferred_take_to_dst.m_mode)
2025 {
2026 case InventoryMode.PREDICTIVE:
2027 #ifdef ENABLE_LOGGING
2029 {
2030 Debug.InventoryHFSMLog("PREDICTIVE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
2031 }
2032 #endif
2033
2034 if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
2035 {
2036 #ifdef DIAG_DEVELOPER
2037 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2038 {
2039 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
2040 }
2041 else
2042 {
2043 #endif
2044 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
2045 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
2046 #ifdef DIAG_DEVELOPER
2047 }
2048 #endif
2049 }
2050 else
2051 {
2052 #ifdef ENABLE_LOGGING
2054 {
2055 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() );
2056 }
2057 #endif
2058 }
2059 break;
2060 case InventoryMode.JUNCTURE:
2061 #ifdef ENABLE_LOGGING
2063 {
2064 Debug.InventoryHFSMLog("JUNCTURE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
2065 }
2066 #endif
2067
2068 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
2069 {
2070 #ifdef DIAG_DEVELOPER
2071 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2072 {
2073 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
2074 }
2075 else
2076 {
2077 #endif
2078 DayZPlayer player = g_Game.GetPlayer();
2079 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
2080 EnableMovableOverride(deferred_take_to_dst.m_dst.GetItem());
2081 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
2082 #ifdef DIAG_DEVELOPER
2083 }
2084 #endif
2085 }
2086 else
2087 {
2088 #ifdef ENABLE_LOGGING
2090 {
2091 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());
2092 }
2093 #endif
2094 }
2095 break;
2096 case InventoryMode.LOCAL:
2097 #ifdef ENABLE_LOGGING
2099 {
2100 Debug.InventoryHFSMLog("LOCAL ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
2101 }
2102 #endif
2103 break;
2104 case InventoryMode.SERVER:
2105 #ifdef ENABLE_LOGGING
2107 {
2108 Debug.InventoryHFSMLog("SERVER ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
2109 }
2110 #endif
2111 break;
2112 default:
2113 Error("HandEvent - Invalid mode");
2114 break;
2115 }
2116 }
2117 }
2118
2119 override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
2120 {
2121 #ifdef ENABLE_LOGGING
2123 {
2124 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a" , "n/a", "SwapEntities", GetDayZPlayerOwner().ToString() );
2125 }
2126 #endif
2127
2128 InventoryLocation src1, src2, dst1, dst2;
2129 if( mode == InventoryMode.LOCAL )
2130 {
2131 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
2132 {
2133 LocationSwap(src1, src2, dst1, dst2);
2134 return true;
2135 }
2136 }
2137
2138 if(!super.SwapEntities(mode,item1,item2))
2139 {
2140 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
2141 {
2142 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
2143 }
2144 }
2145 return true;
2146 }
2147
2148 override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
2149 {
2150 if (!super.PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2))
2151 return false;
2152
2153 if (!m_DeferredEvent)
2154 {
2155 m_DeferredEvent = new DeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
2156 if (m_DeferredEvent.ReserveInventory(this))
2157 return true;
2158 }
2159
2160 m_DeferredEvent = null;
2161 return false;
2162 }
2163
2164 void HandleSwapEntities( DeferredEvent deferred_event )
2165 {
2166 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
2167 if( deferred_swap_entities )
2168 {
2169 deferred_swap_entities.ClearInventoryReservation(this);
2170 InventoryLocation src1, src2, dst1, dst2;
2171 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
2172 {
2174 {
2175 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));
2176 }
2177
2178 switch (deferred_swap_entities.m_mode)
2179 {
2180 case InventoryMode.PREDICTIVE:
2181 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
2182 {
2183 #ifdef DIAG_DEVELOPER
2184 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2185 {
2186 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2187 }
2188 else
2189 {
2190 #endif
2191
2192 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2193 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2194
2195 #ifdef DIAG_DEVELOPER
2196 }
2197 #endif
2198 }
2199 else
2200 {
2201 #ifdef ENABLE_LOGGING
2203 {
2204 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() );
2205 }
2206 #endif
2207 }
2208 break;
2209
2210 case InventoryMode.JUNCTURE:
2211 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
2212 {
2213 #ifdef DIAG_DEVELOPER
2214 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2215 {
2216 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2217 }
2218 else
2219 {
2220 #endif
2221
2222 DayZPlayer player = g_Game.GetPlayer();
2223 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2224 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2225 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
2226 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
2227 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2228
2229 #ifdef DIAG_DEVELOPER
2230 }
2231 #endif
2232 }
2233 else
2234 {
2235 #ifdef ENABLE_LOGGING
2237 {
2238 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() );
2239 }
2240 #endif
2241 }
2242 break;
2243
2244 case InventoryMode.LOCAL:
2245 break;
2246
2247 default:
2248 Error("SwapEntities - HandEvent - Invalid mode");
2249 }
2250 }
2251 else
2252 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
2253 }
2254 }
2255
2256 override bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
2257 {
2258 #ifdef ENABLE_LOGGING
2260 {
2261 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
2262 }
2263 #endif
2264
2265 InventoryLocation src1, src2, dst1;
2266 if( mode == InventoryMode.LOCAL )
2267 {
2268 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
2269 {
2270 LocationSwap(src1, src2, dst1, item2_dst);
2271 return true;
2272 }
2273
2274 }
2275
2276 if(!super.ForceSwapEntities(mode,item1,item2,item2_dst))
2277 {
2278 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
2279 {
2280 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, item2_dst);
2281 }
2282 }
2283
2284 return true;
2285 }
2286
2288 {
2289 DeferredForceSwapEntities deferred_force_swap_entities = DeferredForceSwapEntities.Cast(deferred_event);
2290 if (deferred_force_swap_entities)
2291 {
2292 deferred_force_swap_entities.ClearInventoryReservation(this);
2295 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
2296 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
2297
2298 DayZPlayer player = g_Game.GetPlayer();
2299
2301 {
2302 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));
2303 }
2304
2305 switch (deferred_force_swap_entities.m_mode)
2306 {
2307 case InventoryMode.PREDICTIVE:
2308 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))
2309 {
2310 #ifdef DIAG_DEVELOPER
2311 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2312 {
2313 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2314 }
2315 else
2316 {
2317 #endif
2318 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2319 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2320 #ifdef DIAG_DEVELOPER
2321 }
2322 #endif
2323 }
2324 else
2325 {
2326 #ifdef ENABLE_LOGGING
2328 {
2329 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());
2330 }
2331 #endif
2332 }
2333 break;
2334
2335 case InventoryMode.JUNCTURE:
2336 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))
2337 {
2338 #ifdef DIAG_DEVELOPER
2339 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2340 {
2341 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2342 }
2343 else
2344 {
2345 #endif
2346
2347
2348 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2349 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2350
2351 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2352 #ifdef DIAG_DEVELOPER
2353 }
2354 #endif
2355 }
2356 else
2357 {
2358 #ifdef ENABLE_LOGGING
2360 {
2361 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());
2362 }
2363 #endif
2364 }
2365 break;
2366
2367 case InventoryMode.LOCAL:
2368 break;
2369
2370 default:
2371 Error("ForceSwapEntities - HandEvent - Invalid mode");
2372 }
2373 }
2374 }
2375
2377 {
2378 if (g_Game.IsServer())
2379 {
2380 if (e.IsServerSideOnly())
2381 {
2382 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
2383 }
2384
2385 if (player.IsAlive())
2386 {
2387 InventoryLocation dst = e.GetDst();
2388 InventoryLocation src = e.GetSrc();
2389 if (src.IsValid() && dst.IsValid())
2390 {
2391 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
2392 {
2393#ifdef ENABLE_LOGGING
2395 {
2396 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
2397 }
2398#endif
2399
2400 if (g_Game.AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
2401 {
2402#ifdef ENABLE_LOGGING
2404 {
2405 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
2406 }
2407#endif
2408 }
2409 else
2410 {
2411#ifdef ENABLE_LOGGING
2413 {
2414 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
2415 }
2416#endif
2417 }
2418 }
2419
2420#ifdef ENABLE_LOGGING
2422 {
2423 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));
2424 }
2425#endif
2426
2429 player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, ctx);
2430
2431#ifdef ENABLE_LOGGING
2433 {
2434 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));
2435 }
2436#endif
2437
2439 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
2440 }
2441 }
2442 else
2443 {
2444 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
2445 }
2446 }
2447 }
2448
2452 override void NetSyncCurrentStateID (int id)
2453 {
2454 super.NetSyncCurrentStateID(id);
2455
2456 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
2457 }
2458
2465 override void OnAfterStoreLoad ()
2466 {
2467 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
2468 }
2469
2474 {
2475 if (GetEntityInHands())
2476 {
2477 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
2478 if (wpn)
2479 {
2481
2483 if (pb && e)
2484 {
2485 pb.GetWeaponManager().SetRunning(true);
2486
2488 {
2489 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
2490 }
2491
2492 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
2493 {
2494 wpn.ProcessWeaponAbortEvent(e);
2495 }
2496 else
2497 {
2498 wpn.ProcessWeaponEvent(e);
2499 }
2500 pb.GetWeaponManager().SetRunning(false);
2501 }
2502 }
2503 else
2504 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
2505 }
2506 else
2507 Error("OnEventForRemoteWeapon - no entity in hands");
2508 return true;
2509 }
2510
2511
2516 {
2517 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2518 if (e)
2519 {
2521 {
2522 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
2523 }
2524
2525 //m_FSM.ProcessEvent(e);
2526
2527 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
2528 {
2530 m_FSM.ProcessAbortEvent(e, aa);
2531 }
2532 else
2533 {
2534 m_FSM.ProcessEvent(e);
2535 }
2536
2537 return true;
2538 }
2539 return false;
2540 }
2541
2543 {
2545 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2546 {
2548
2550 e.WriteToContext(ctx);
2551
2553 {
2554 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
2555 }
2556
2557 p.StoreInputForRemotes(ctx);
2558 }
2559 }
2560
2562 {
2563 super.OnHandsExitedStableState(src, dst);
2564
2566 {
2567 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
2568 }
2569 }
2570
2572 {
2573 super.OnHandsEnteredStableState(src, dst);
2574
2576 {
2577 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
2578 }
2579 }
2580
2582 {
2583 super.OnHandsStateChanged(src, dst);
2584
2586 {
2587 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
2588 }
2589
2590 if (src.IsIdle())
2591 OnHandsExitedStableState(src, dst);
2592
2593 if (dst.IsIdle())
2594 OnHandsEnteredStableState(src, dst);
2595
2596#ifdef DIAG_DEVELOPER
2598 if (p && p.m_Bot)
2599 {
2600 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
2601 }
2602#endif
2603 }
2604
2606 {
2607 if (!IsProcessing())
2608 {
2609 EntityAI itemInHands = GetEntityInHands();
2610
2612 il.SetHands(GetInventoryOwner(), itemInHands);
2613
2614 InventoryValidation validation = new InventoryValidation();
2615 validation.m_Mode = mode;
2616 if (e.CanPerformEventEx(validation))
2617 {
2618 m_DeferredEvent = new DeferredHandEvent(mode, e);
2619 if (m_DeferredEvent.ReserveInventory(this))
2620 {
2621 return true;
2622 }
2623 }
2624
2625 m_DeferredEvent = null;
2626
2628 if (!g_Game.IsMultiplayer() || g_Game.IsClient())
2629 {
2631 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
2632 }
2633 else
2634 {
2635 ScriptInputUserData serializer();
2636
2638 serializer.Write(validation.m_Reason);
2639
2640 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
2641 }
2642 }
2643
2644 return false;
2645 }
2646
2648 {
2649 DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(m_DeferredEvent);
2650 if (!deferred_hand_event)
2651 return;
2652
2653 SyncHandEventToRemote(deferred_hand_event.m_event);
2654 }
2655
2656 void HandleHandEvent(DeferredEvent deferred_event)
2657 {
2659 InventoryValidation validation = new InventoryValidation();
2660
2661 DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(deferred_event);
2662 if (deferred_hand_event)
2663 {
2664 #ifdef ENABLE_LOGGING
2666 {
2667 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2668 }
2669 #endif
2670
2672 {
2673 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2674 }
2675
2676 validation.m_Mode = deferred_hand_event.m_mode;
2677
2678 switch (deferred_hand_event.m_mode)
2679 {
2680 case InventoryMode.PREDICTIVE:
2681 #ifdef ENABLE_LOGGING
2683 {
2684 Debug.InventoryHFSMLog("PREDICTIVE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2685 }
2686 #endif
2687
2688 deferred_hand_event.ClearInventoryReservation(this);
2689 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2690 {
2691 #ifdef DIAG_DEVELOPER
2692 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2693 {
2694 ProcessHandEvent(deferred_hand_event.m_event);
2695 }
2696 else
2697 {
2698 #endif
2700 ProcessHandEvent(deferred_hand_event.m_event);
2701 #ifdef DIAG_DEVELOPER
2702 }
2703 #endif
2704 }
2705 break;
2706
2707 case InventoryMode.JUNCTURE:
2708 #ifdef ENABLE_LOGGING
2710 {
2711 Debug.InventoryHFSMLog("JUNCTURE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2712 }
2713 #endif
2714
2715 deferred_hand_event.ClearInventoryReservation(this);
2716 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2717 {
2718 #ifdef DIAG_DEVELOPER
2719 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2720 {
2721 ProcessHandEvent(deferred_hand_event.m_event);
2722 }
2723 else
2724 {
2725 #endif
2726 deferred_hand_event.ReserveInventory(this);
2728
2729 //Functionality to prevent desync when two players perform interfering action at the same time
2730 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2731 EntityAI itemDst = null;
2732 if (deferred_hand_event.m_event.GetDst())
2733 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2734 if (itemSrc)
2735 EnableMovableOverride(itemSrc);
2736 if (itemDst)
2737 EnableMovableOverride(itemDst);
2738 #ifdef DIAG_DEVELOPER
2739 }
2740 #endif
2741 }
2742 break;
2743
2744 case InventoryMode.LOCAL:
2745 #ifdef ENABLE_LOGGING
2747 {
2748 Debug.InventoryHFSMLog("LOCAL", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2749 }
2750 #endif
2751
2752 deferred_hand_event.ClearInventoryReservation(this);
2753 ProcessHandEvent(deferred_hand_event.m_event);
2754 //PostHandEvent(deferred_hand_event.m_event);
2755 break;
2756
2757 case InventoryMode.SERVER:
2758 #ifdef ENABLE_LOGGING
2760 {
2761 Debug.InventoryHFSMLog("SERVER", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2762 }
2763
2765 {
2766 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2767 }
2768 #endif
2769
2770 if (!deferred_hand_event.m_event.IsServerSideOnly())
2771 {
2772 if (GetDayZPlayerOwner().IsAlive())
2773 {
2775 }
2776 else
2777 {
2779 }
2780 }
2781 else
2782 {
2783 ProcessHandEvent(deferred_hand_event.m_event);
2784 }
2785 break;
2786
2787 default:
2788 Error("HumanInventory::HandEvent - Invalid mode");
2789 }
2790 }
2791 }
2792
2794 {
2795 super.HandleInventoryManipulation();
2797 {
2802
2803 m_DeferredEvent = null;
2804 }
2805 }
2806
2807
2808
2810 {
2811 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2812 }
2813
2814 bool PlayerCheckRequestSrc ( notnull InventoryLocation src, float radius )
2815 {
2816 bool result = true;
2817
2818 EntityAI ent = src.GetParent();
2819 if ( ent )
2820 {
2821 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2822 if (player)
2823 {
2824 if ( GetDayZPlayerOwner() != player )
2825 {
2826 if (player.IsAlive())
2827 {
2828 if (!player.IsRestrained() && !player.IsUnconscious())
2829 {
2830 return false;
2831 }
2832 }
2833 }
2834 }
2835 }
2836
2837 if ( result )
2838 {
2839 result = CheckRequestSrc( GetManOwner(), src, radius);
2840 }
2841
2842 if (result)
2843 {
2844 EntityAI item = src.GetItem().GetHierarchyRoot();
2845 EntityAI root = item.GetHierarchyRoot();
2846 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
2847 }
2848
2849 return result;
2850 }
2851
2852 bool PlayerCheckRequestDst ( notnull InventoryLocation src, notnull InventoryLocation dst, float radius )
2853 {
2854 bool result = true;
2855
2856 EntityAI ent = dst.GetParent();
2857 if ( ent )
2858 {
2859 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2860 if (player)
2861 {
2862 if ( GetDayZPlayerOwner() != player )
2863 {
2864 if (player.IsAlive())
2865 {
2866 if (!player.IsRestrained() && !player.IsUnconscious())
2867 {
2868 result = false;
2869 }
2870 }
2871 }
2872 }
2873 }
2874
2875 if (!LocationCanMoveEntity(src, dst))
2876 {
2877 result = false;
2878 }
2879
2880
2881 if ( result )
2882 {
2883 result = CheckMoveToDstRequest( GetManOwner(), src, dst, radius);
2884 }
2885
2886 if (result)
2887 {
2888 EntityAI item = dst.GetItem().GetHierarchyRoot();
2889 EntityAI root = item.GetHierarchyRoot();
2890 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
2891 }
2892
2893 return result;
2894 }
2895
2897 {
2898 #ifdef DIAG_DEVELOPER
2899 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2900 {
2901 #endif
2902 array<EntityAI> itemsToRepair = new array<EntityAI>;
2903 switch(dst.GetType())
2904 {
2905 case InventoryLocationType.CARGO:
2906 InventoryLocation ilCargoItem = new InventoryLocation;
2907 CargoBase cargo = dst.GetParent().GetInventory().GetCargo();
2908 for(int i = cargo.GetItemCount() - 1; i >= 0 ; --i)
2909 {
2910 EntityAI itemInCargo = cargo.GetItem(i);
2911 itemInCargo.GetInventory().GetCurrentInventoryLocation(ilCargoItem);
2912 if (dst.CollidesWith(ilCargoItem))
2913 {
2914 itemsToRepair.Insert(itemInCargo);
2915 }
2916 }
2917 break;
2918 case InventoryLocationType.ATTACHMENT:
2919 EntityAI entityInAttachment = dst.GetParent().GetInventory().FindAttachment(dst.GetSlot());
2920
2921 if(entityInAttachment)
2922 {
2923 itemsToRepair.Insert(entityInAttachment);
2924 }
2925 break;
2926 case InventoryLocationType.HANDS:
2927 EntityAI entityInHands = GetEntityInHands();
2928 if(entityInHands)
2929 {
2930 itemsToRepair.Insert(entityInHands);
2931 }
2932
2933 break;
2934 default:
2935 break;
2936 }
2937
2938 if(itemsToRepair.Count() > 0)
2939 {
2941 }
2942 #ifdef DIAG_DEVELOPER
2943 }
2944 #endif
2945 }
2946
2947 bool PlayerCheckSwapItemsRequest( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
2948 {
2949 bool result = true;
2950
2951 EntityAI ent = dst1.GetParent();
2952 PlayerBase player;
2953 if ( ent )
2954 {
2955 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2956 if (player)
2957 {
2958 if ( GetDayZPlayerOwner() != player )
2959 {
2960 if (player.IsAlive())
2961 {
2962 if (!player.IsRestrained() && !player.IsUnconscious())
2963 {
2964 return false;
2965 }
2966 }
2967 }
2968 }
2969 }
2970
2971 ent = dst2.GetParent();
2972 if ( ent )
2973 {
2974 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2975 if (player)
2976 {
2977 if ( GetDayZPlayerOwner() != player )
2978 {
2979 if (player.IsAlive())
2980 {
2981 if (!player.IsRestrained() && !player.IsUnconscious())
2982 {
2983 return false;
2984 }
2985 }
2986 }
2987 }
2988 }
2989
2990
2991 if ( result )
2992 {
2993 result = CheckSwapItemsRequest( GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2994 }
2995
2996 EntityAI item;
2997 EntityAI root;
2998
2999 if (result)
3000 {
3001 item = dst1.GetItem().GetHierarchyRoot();
3002 root = item.GetHierarchyRoot();
3003
3004 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
3005 }
3006
3007 if (result)
3008 {
3009 item = dst2.GetItem().GetHierarchyRoot();
3010 root = item.GetHierarchyRoot();
3011
3012 result = vector.Distance(GetManOwner().GetPosition(), item.GetPosition()) < (radius + root.GetCollisionRadius());
3013 }
3014
3015 return result;
3016
3017 }
3018
3019 bool PlayerCheckDropRequest ( notnull InventoryLocation src, float radius )
3020 {
3021 bool result = true;
3022
3023 EntityAI ent = src.GetParent();
3024 if ( ent )
3025 {
3026 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
3027 if (player)
3028 {
3029 if ( GetDayZPlayerOwner() != player )
3030 {
3031 if (player.IsAlive())
3032 {
3033 if (!player.IsRestrained() && !player.IsUnconscious())
3034 {
3035 return false;
3036 }
3037 }
3038 }
3039 }
3040 }
3041
3042 if ( result )
3043 {
3044 result = CheckDropRequest( GetManOwner(), src, radius);
3045 }
3046
3047 return result;
3048 }
3049
3052 {
3053 if (dst.GetType() == InventoryLocationType.ATTACHMENT)
3054 {
3055 return dst.GetParent().CheckAttachmentReceiveExclusion(src.GetItem(),dst.GetSlot());
3056 }
3057
3058 return true;
3059 }
3060
3062 bool SwapCheckExclusionMaskLocal ( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
3063 {
3064 bool failed = false;
3065
3066 if (dst1.GetType() == InventoryLocationType.ATTACHMENT)
3067 {
3068 failed |= !dst1.GetParent().CheckAttachmentReceiveExclusion(dst1.GetItem(),dst1.GetSlot());
3069 }
3070
3071 if (dst2.GetType() == InventoryLocationType.ATTACHMENT)
3072 {
3073 failed |= !dst2.GetParent().CheckAttachmentReceiveExclusion(dst2.GetItem(),dst2.GetSlot());
3074 }
3075 return !failed;
3076 }
3077
3078 [Obsolete("No replacement")]
3080 {
3082
3083 if (validation.m_IsJuncture)
3084 {
3091
3092 return true;
3093 }
3094
3096 src.ReadFromContext(ctx);
3097
3098 #ifdef ENABLE_LOGGING
3100 {
3101 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
3102 }
3103 #endif
3104
3105 if (validation.m_IsRemote && !src.GetItem())
3106 {
3107 #ifdef ENABLE_LOGGING
3109 {
3110 Debug.InventoryMoveLog("Failed item not exist", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
3111 }
3112 #endif
3113
3114 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
3115 return true;
3116 }
3117
3122 {
3123 #ifdef ENABLE_LOGGING
3125 {
3126 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
3127 }
3128 #endif
3129
3130 return true;
3131 }
3132
3137 {
3138 #ifdef ENABLE_LOGGING
3140 {
3141 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
3142 }
3143 #endif
3144
3145 return true;
3146 }
3147
3148 if (GetInventoryOwner() != src.GetParent())
3149 {
3150 #ifdef ENABLE_LOGGING
3152 {
3153 Debug.InventoryMoveLog("Failed PlayerDoesNotOwnItem", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
3154 }
3155 #endif
3156
3157 return true;
3158 }
3159
3160 #ifdef ENABLE_LOGGING
3162 {
3163 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
3164 }
3165 #endif
3166
3167 g_Game.ObjectDelete(src.GetItem());
3168
3169 validation.m_Result = InventoryValidationResult.SUCCESS;
3170 return true;
3171 }
3172
3173 override bool OnInventoryCheck(int userDataType, ParamsReadContext ctx)
3174 {
3175 if (userDataType == INPUT_UDT_INVENTORY_CHECK)
3176 {
3177 bool correct = true;
3178
3179 int count;
3180 array<EntityAI> itemsToRepair = new array<EntityAI>;
3181 InventoryLocation clientIl = new InventoryLocation;
3183
3184
3185 if(!ctx.Read(count))
3186 return false;
3187
3188 for (int i = 0; i < count; i++)
3189 {
3190 if(!clientIl.ReadFromContext(ctx))
3191 {
3192 return false;
3193 }
3194
3195 clientIl.GetItem().GetInventory().GetCurrentInventoryLocation(realIl);
3196
3197 if(clientIl != realIl)
3198 {
3199 itemsToRepair.Insert(clientIl.GetItem());
3200 correct = false;
3201 }
3202 }
3203
3204 if (itemsToRepair.Count())
3205 {
3206 #ifdef DIAG_DEVELOPER
3207 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
3208 {
3209 #endif
3211 #ifdef DIAG_DEVELOPER
3212 }
3213 #endif
3214 }
3215
3216 return correct;
3217 }
3218 return false;
3219 }
3220}
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)
DayZGame g_Game
Определения DayZGame.c:3942
override Widget Init()
Определения DayZGame.c:127
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:3019
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:747
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1048
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1860
void OnHandleStoredInputUserData(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:702
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:3062
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
Определения DayZPlayerInventory.c:1762
ref HandAnimatedForceSwapping m_FSwapping
Определения DayZPlayerInventory.c:160
m_DeferredEvent
void HandleHandEvent(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2656
void HandleWeaponEvents(float dt, out bool exitIronSights)
Определения DayZPlayerInventory.c:345
proto native void StoreInputUserData(ParamsReadContext ctx)
void OnHandleStoredJunctureData(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:654
void SyncHandEventToRemote(HandEventBase e)
Определения DayZPlayerInventory.c:2542
void HandleTakeToDst(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2005
void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:89
ref HandAnimatedForceSwapping_Inst m_FSwappingInst
Определения DayZPlayerInventory.c:161
ref HandAnimatedSwapping m_Swapping
Определения DayZPlayerInventory.c:159
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:3079
bool MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:3051
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1868
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2814
void AbortWeaponEvent()
Определения DayZPlayerInventory.c:281
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:640
void PostWeaponEvent(WeaponEventBase e)
Определения DayZPlayerInventory.c:303
override void NetSyncCurrentStateID(int id)
Определения DayZPlayerInventory.c:2452
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2571
bool IsServerOrLocalPlayer()
Определения DayZPlayerInventory.c:1875
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:1898
override void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:556
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1853
ref HandEventBase m_DeferredPostedHandEvent
Определения DayZPlayerInventory.c:154
void SyncDeferredEventToRemotes()
Определения DayZPlayerInventory.c:2647
override void HandleInventoryManipulation()
Определения DayZPlayerInventory.c:2793
override bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:532
void DayZPlayerInventory()
Определения DayZPlayerInventory.c:163
ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
Определения DayZPlayerInventory.c:157
override bool OnInventoryCheck(int userDataType, ParamsReadContext ctx)
Определения DayZPlayerInventory.c:3173
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
Определения DayZPlayerInventory.c:2119
ref HandAnimatedMovingToAtt m_MovingTo
Определения DayZPlayerInventory.c:158
void SendRepairToClientDst(notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:2896
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:15
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2561
override void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2581
override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:2148
bool OnHandEventForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:2515
ref InventoryLocation m_dst1
Определения DayZPlayerInventory.c:86
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
Определения DayZPlayerInventory.c:155
void OnInputUserDataForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:723
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:167
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:2256
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1344
void HandleSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2164
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:2947
void HandleInventory(float dt)
Определения DayZPlayerInventory.c:444
void DeferredWeaponFailed()
Определения DayZPlayerInventory.c:320
ref InventoryLocation m_dst
Определения DayZPlayerInventory.c:13
void HandleForceSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2287
ref Timer m_DeferredWeaponTimer
Определения DayZPlayerInventory.c:150
override bool PostDeferredEventTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:1989
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:2852
bool OnEventForRemoteWeapon(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:2473
override void OnServerInventoryCommand(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:735
void CancelHandEvent()
cancels any handevents that will be executed this frame @NOTE: this is used in situations where the p...
Определения DayZPlayerInventory.c:269
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:2605
void CancelWeaponEvent()
Определения DayZPlayerInventory.c:275
class DeferredEvent m_src
EntityAI m_item2
Определения DayZPlayerInventory.c:85
static void SendServerHandEventViaJuncture(notnull DayZPlayer player, HandEventBase e)
Определения DayZPlayerInventory.c:2376
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Определения EmoteManager.c:549
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:1647
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:847
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:35
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:325
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:988
Определения 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:207
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:197
Определения 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
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:610
override InventoryLocation GetDst()
Определения Hand_Events.c:215
override bool AcquireInventoryJunctureFromServer(notnull Man player)
Определения Hand_Events.c:260
override EntityAI GetSecondSrcEntity()
Определения Hand_Events.c:615
override bool IsServerSideOnly()
Определения Hand_Events.c:771
override string DumpToString()
Определения Hand_Events.c:338
override void ClearInventoryReservation()
Определения Hand_Events.c:718
override void WriteToContext(ParamsWriteContext ctx)
Определения Hand_Events.c:285
override bool CheckRequestSrc()
Определения Hand_Events.c:222
override bool CanPerformEventEx(InventoryValidation validation)
Определения Hand_Events.c:238
override InventoryLocation GetSecondSrc()
Определения Hand_Events.c:605
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:212
Определения Hand_Events.c:726
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:1000
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:816
static bool IsSyncLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:776
static bool IsInventoryHFSMLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:766
static bool IsInventoryMoveLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:746
Определения 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:1071
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:816
WeaponEvents
events
Определения human.c:969
string WeaponActionTypeToString(int A, int AT)
Определения human.c:949