DayZ 1.28
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
144
146 * @class DayZPlayerInventory
147 **/
149{
152 //protected ref HandEventBase m_PostedHandEvent = NULL; /// deferred hand event
153
154
157 // states with animations
158 protected ref HandAnimatedTakingFromAtt m_Taking;
159 protected ref HandAnimatedMovingToAtt m_MovingTo;
160 protected ref HandAnimatedSwapping m_Swapping;
161 protected ref HandAnimatedForceSwapping m_FSwapping;
162 protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst;
163
165 {
166 }
167
168 DayZPlayer GetDayZPlayerOwner () { return DayZPlayer.Cast(GetInventoryOwner()); }
169
171 {
172 DayZPlayer player;
173 if (!Class.CastTo(player, GetInventoryOwner()))
174 {
175 return false;
176 }
177
178 return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
179 }
180
181 bool IsOwner()
182 {
183 DayZPlayer player;
184 if (!Class.CastTo(player, GetInventoryOwner()))
185 {
186 return false;
187 }
188
189 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
190 }
191
192 bool IsProxy()
193 {
194 DayZPlayer player;
195 if (!Class.CastTo(player, GetInventoryOwner()))
196 {
197 return false;
198 }
199
200 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
201 }
202
203 override void Init ()
204 {
206 {
207 hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
208 }
209
210 CreateStableStates(); // stable states needs to be created first
211
212 m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
213 m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
214 m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
215 m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
216 m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
217
218 // events
219 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
220 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
221 HandEventBase __T__ = new HandEventTake;
222 HandEventBase __M__ = new HandEventMoveTo;
223 HandEventBase __W__ = new HandEventSwap;
224 //HandEventBase __D__ = new HandEventDropping;
225 HandEventBase __Xd_ = new HandEventDestroyed;
226 HandEventBase __F__ = new HandEventForceSwap;
227
228 // setup transitions
229 m_FSM.AddTransition(new HandTransition( m_Empty , __T__, m_Taking, NULL, new HandSelectAnimationOfTakeToHandsEvent(GetManOwner())));
230 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
231 m_FSM.AddTransition(new HandTransition( m_Taking , _fin_, m_Equipped, null, null));
232 m_FSM.AddTransition(new HandTransition( m_Taking , __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
233 m_Taking.AddTransition(new HandTransition( m_Taking.m_Hide, _abt_, m_Empty));
234 m_Taking.AddTransition(new HandTransition( m_Taking.m_Show, _abt_, m_Equipped));
235
236 m_FSM.AddTransition(new HandTransition( m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
237 m_FSM.AddTransition(new HandTransition( m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
238 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
239 m_FSM.AddTransition(new HandTransition( m_MovingTo, _fin_, m_Empty , null, null));
240 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Hide, _abt_, m_Equipped));
241 m_MovingTo.AddTransition(new HandTransition( m_MovingTo.m_Show, _abt_, m_Empty));
242
243 m_FSM.AddTransition(new HandTransition( m_Equipped, __W__, m_Swapping, NULL, new HandSelectAnimationOfSwapInHandsEvent(GetManOwner())));
244 m_FSM.AddTransition(new HandTransition( m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
245 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
246 m_FSM.AddTransition(new HandTransition( m_Swapping, _fin_, m_Equipped, null, null));
247 m_FSM.AddTransition(new HandTransition( m_Swapping, _abt_, m_Equipped, null, null));
248
249 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd( new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()) ) ));
250 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
251 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
252 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
253 m_FSM.AddTransition(new HandTransition( m_FSwappingInst, _abt_, m_Equipped, null, null));
254
255 m_FSM.AddTransition(new HandTransition( m_Equipped, __F__, m_FSwapping, NULL, new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner())));
256 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
257 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
258 m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
259 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Start, _abt_, m_Equipped));
260 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Hide, _abt_, m_Empty));
261 m_FSwapping.AddTransition(new HandTransition( m_FSwapping.m_Show, _abt_, m_Equipped));
262
263 super.Init(); // initialize ordinary human fsm (no anims)
264 }
265
271 {
273 //m_postedHandEvent = null;
274 }
275
277 {
280 }
281
283 {
284 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
285
286 Weapon_Base weapon;
287 Class.CastTo(weapon, GetEntityInHands());
288
289 if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
290 {
292 {
293 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
294 }
295
296 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
297 }
298 }
299
305 {
306 if (m_DeferredWeaponEvent == NULL)
307 {
309
311 {
312 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
313 }
314 }
315 else
316 {
317 Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
318 }
319 }
320
322 {
323 Weapon_Base weapon;
324 Class.CastTo(weapon, GetEntityInHands());
325
326 string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
327
328 string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
329 if (weapon)
330 {
331 secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
332 secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
333 for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
334 {
335 secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
336 secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
337 if (i < weapon.GetMuzzleCount() - 1)
338 secondPart += " | ";
339 }
340 }
341
342 Error(firstPart + secondPart);
344 }
345
346 void HandleWeaponEvents (float dt, out bool exitIronSights)
347 {
348 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
349
350 Weapon_Base weapon;
351 Class.CastTo(weapon, GetEntityInHands());
352
353 if (weapon)
354 {
355 weapon.UpdateCoolDown(dt);
356 if (hcw && weapon.CanProcessWeaponEvents())
357 {
358
359 weapon.GetCurrentState().OnUpdate(dt);
360
362 {
363 wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
364 }
365
366 if (!weapon.IsIdle())
367 {
368 while (true)
369 {
370 int weaponEventId = hcw.IsEvent();
371 if (weaponEventId == -1)
372 {
373 break;
374 }
375
376 if (weaponEventId == WeaponEvents.CHANGE_HIDE)
377 {
378 break;
379 }
380
381 WeaponEventBase anim_event = WeaponAnimEventFactory(weaponEventId, GetDayZPlayerOwner(), NULL);
382
384 {
385 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
386 }
387
388 if (anim_event != NULL)
389 {
390 weapon.ProcessWeaponEvent(anim_event);
391 }
392 }
393
394 if (hcw.IsActionFinished())
395 {
396 if (weapon.IsWaitingForActionFinish())
397 {
399 {
400 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
401 }
402
403 weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
404 }
405 else
406 {
408 {
409 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
410 }
411
412 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
413 }
414 }
415 }
416
418 {
420 {
421 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
422 }
423
424 if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
425 {
426 exitIronSights = true;
427
429 {
430 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
431 }
432
435 }
436 else if (!m_DeferredWeaponTimer.IsRunning())
437 {
438 m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
439 }
440 }
441 }
442 }
443 }
444
445 void HandleInventory(float dt)
446 {
447 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
448
449 EntityAI ih = GetEntityInHands();
450 Weapon_Base weapon;
451 Class.CastTo(weapon, ih);
452
453 if (hcw)
454 {
455 m_FSM.GetCurrentState().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 ( !m_FSM.GetCurrentState().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 (m_FSM.GetCurrentState().IsWaitingForActionFinish())
493 {
494 #ifdef ENABLE_LOGGING
496 {
497 hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + m_FSM.GetCurrentState());
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=" + m_FSM.GetCurrentState());
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 {
558/* InventoryLocation il = new InventoryLocation;
559 if (!il.ReadFromContext(ctx) )
560 return false;
561
562 InventoryLocation il_current = new InventoryLocation;
563
564 EntityAI item = il.GetItem();
565 item.GetInventory().GetCurrentInventoryLocation(il_current);
566
567 if( !il_current.CompareLocationOnly(il))
568 {
569 LocationMoveEntity(il_current,il);
570 }*/
571 return true;
572 }
573
575
582 {
595
596 if (GetGame().IsDedicatedServer())
597 {
598 return;
599 }
600
601 int udtIdentifier = -1;
602 if (!ctx.Read(udtIdentifier) || udtIdentifier != INPUT_UDT_INVENTORY)
603 {
604 return;
605 }
606
610
611 InventoryCommandType type = -1;
612 if (!ctx.Read(type))
613 {
614 return;
615 }
616
617 switch (type)
618 {
619 case InventoryCommandType.SYNC_MOVE:
620 {
621 src.ReadFromContext(ctx);
622 dst.ReadFromContext(ctx);
623 ClearInventoryReservationEx(dst.GetItem(), dst);
624 break;
625 }
626 case InventoryCommandType.HAND_EVENT:
627 {
628 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
629 src = e.GetSrc();
630 dst = e.GetDst();
632 break;
633 }
634 case InventoryCommandType.SWAP:
635 {
636 src.ReadFromContext(ctx);
637 temp.ReadFromContext(ctx);
638 dst.ReadFromContext(ctx);
639 temp.ReadFromContext(ctx);
640
641 ClearInventoryReservationEx(dst.GetItem(), dst);
642 ClearInventoryReservationEx(temp.GetItem(), temp);
643 break;
644 }
645 case InventoryCommandType.FORCESWAP:
646 {
647 break;
648 }
649 case InventoryCommandType.DESTROY:
650 {
651 src.ReadFromContext(ctx);
652 break;
653 }
654 }
655
657 if (!ctx.Read(reason))
658 {
659 reason = InventoryValidationReason.UNKNOWN;
660 }
661
662 OnInventoryFailure(type, reason, src, dst);
663 }
664
666 {
667 if (reason == InventoryValidationReason.DROP_PREVENTED)
668 {
670 return;
671 }
672
673 }
674
680 {
681 int tmp = -1;
682 ctx.Read(tmp);
683
684#ifdef ENABLE_LOGGING
686 {
687 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
688 }
689#endif
690
692 ProcessInputData(ctx, true, false);
693 }
694
699 proto native void StoreJunctureData(ParamsReadContext ctx);
701
702
704
711 {
712#ifdef ENABLE_LOGGING
714 {
715 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
716 }
717#endif
718
720 return true;
721 }
722
728 {
729 int tmp = -1;
730 ctx.Read(tmp);
731
732#ifdef ENABLE_LOGGING
734 {
735 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
736 }
737#endif
738
739 ProcessInputData(ctx, false, false);
740 }
741
745 proto native void StoreInputUserData(ParamsReadContext ctx);
747
749 {
750#ifdef ENABLE_LOGGING
752 {
753 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
754 }
755#endif
756
757 ProcessInputData(ctx, false, true);
758 }
759
761 {
762#ifdef ENABLE_LOGGING
764 {
765 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
766 }
767#endif
768
769 ProcessInputData(ctx, true, true);
770 }
771
773 {
775
778 bool success = true;
779
780 src.ReadFromContext(ctx);
781 dst.ReadFromContext(ctx);
782
783 #ifdef ENABLE_LOGGING
785 {
786 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
787 }
788 #endif
789
790 if (validation.m_IsRemote && (!src.GetItem() || !dst.GetItem()))
791 {
793
794#ifdef ENABLE_LOGGING
796 {
797 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
798 }
799
801 {
802 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
803 }
804#endif
805
806 return true;
807 }
808
810
814 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
815 {
817
818#ifdef ENABLE_LOGGING
820 {
821 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
822 }
823
825 {
826 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
827 }
828#endif
829
831
832 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
833 {
834 success = false;
835 }
836 else
837 {
838 return true;
839 }
840 }
841
845 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
846 {
847#ifdef ENABLE_LOGGING
849 {
850 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
851 }
852
854 {
855 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
856 }
857#endif
858
860
861 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
862 {
863 success = false;
864 }
865 else
866 {
867 return true;
868 }
869 }
870
872
873#ifdef ENABLE_LOGGING
875 {
876 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " HandleInputData t=" + GetGame().GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
877 }
878#endif
879
881 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
882 {
884 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
885 {
886 #ifdef ENABLE_LOGGING
888 {
889 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
890 }
891 #endif
892 if (success)
893 {
895
896 LocationSyncMoveEntity(src, dst);
897
898 validation.m_Result = InventoryValidationResult.SUCCESS;
899 }
900 return true;
901 }
902 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
903 {
904 #ifdef ENABLE_LOGGING
906 {
907 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
908 }
909 #endif
910
912 {
913 #ifdef ENABLE_LOGGING
914
915 #ifdef DEVELOPER
916 DumpInventoryDebug();
917 #endif
918
920 {
921 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
922 }
923 #endif
924 validation.m_Result = InventoryValidationResult.FAILED;
925 return true;
926 }
927
928 validation.m_Result = InventoryValidationResult.JUNCTURE;
930 return true;
931 }
932 else
933 {
934 #ifdef ENABLE_LOGGING
936 {
937 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
938 }
939 #endif
940
941 validation.m_Result = InventoryValidationResult.FAILED;
942 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
943 return true;
944 }
945 }
946
947 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
948 {
949 ClearInventoryReservationEx(dst.GetItem(), dst);
950 }
951
953 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
954 {
955 CheckForRope(src, dst);
956 }
957
961 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
962 {
963 #ifdef ENABLE_LOGGING
964
965 #ifdef DEVELOPER
966 DumpInventoryDebug();
967 #endif
968
970 {
971 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
972 }
973 #endif
974
975 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
976 return true;
977 }
978
979 //TODO: hotfix solution
980 if (!validation.m_IsRemote && validation.m_IsJuncture && !MoveCheckExclusionMaskLocal(src,dst))
981 {
982 #ifdef ENABLE_LOGGING
984 {
985 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
986 }
987 #endif
988 return false;
989 }
990
991 #ifdef ENABLE_LOGGING
993 {
994 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
995 }
996 #endif
997
998 LocationSyncMoveEntity(src, dst);
999
1000 validation.m_Result = InventoryValidationResult.SUCCESS;
1001 return true;
1002 }
1003
1005 {
1007 bool success = true;
1008
1009 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1011
1015 e.m_IsRemote = validation.m_IsRemote;
1016 e.m_IsJuncture = validation.m_IsJuncture;
1017
1018 EntityAI itemSrc = e.GetSrcEntity();
1019 EntityAI itemDst = e.GetSecondSrcEntity();
1020
1021 #ifdef ENABLE_LOGGING
1023 {
1024 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1025 }
1026 #endif
1027
1028 if (validation.m_IsRemote && !e.GetSrcEntity())
1029 {
1031 if (itemDst && (e.GetEventID() == HandEventID.SWAP || e.GetEventID() == HandEventID.FORCESWAP)) //presumed swap, replace with take
1032 {
1033 InventoryLocation srcNew = new InventoryLocation();
1034 srcNew.Copy(e.GetSrc());
1035 e = HandEventBase.HandEventFactory(HandEventID.TAKE, e.m_Player, srcNew);
1036
1037 Error("[syncinv] HandleInputData remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.DumpToString() + "), src item is null! Continuing.");
1038 }
1039 else
1040 {
1041 #ifdef ENABLE_LOGGING
1043 {
1044 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1045 }
1046 #endif
1047
1048 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1049
1050 return true;
1051 }
1052 }
1053
1055 if (itemSrc)
1056 RemoveMovableOverride(itemSrc);
1057 if (itemDst)
1058 RemoveMovableOverride(itemDst);
1059
1063 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1064 {
1065 #ifdef ENABLE_LOGGING
1067 {
1068 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1069 }
1070 #endif
1071
1072 if (!validation.m_IsRemote)
1073 {
1074 ctx = new ScriptInputUserData;
1076 }
1077
1078 RemoveMovableOverride(itemSrc);
1079 RemoveMovableOverride(itemDst);
1080
1081 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1082 {
1083 success = false;
1084 }
1085 else
1086 {
1087 return true;
1088 }
1089 }
1090
1091 if (success && !e.CheckRequestEx(validation))
1092 {
1093 #ifdef ENABLE_LOGGING
1095 {
1096 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1097 }
1098 #endif
1099
1101
1102 ctx = new ScriptInputUserData;
1104
1105#ifdef ENABLE_LOGGING
1107 {
1108 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1109 }
1110#endif
1111
1112 RemoveMovableOverride(itemSrc);
1113 RemoveMovableOverride(itemDst);
1114
1115 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1116 {
1117 success = false;
1118 }
1119 else
1120 {
1121 return true;
1122 }
1123 }
1124
1127 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1128 {
1129 #ifdef ENABLE_LOGGING
1131 {
1132 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1133 }
1134 #endif
1135
1137
1138 ctx = new ScriptInputUserData;
1140
1141#ifdef ENABLE_LOGGING
1143 {
1144 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1145 }
1146#endif
1147
1148 RemoveMovableOverride(itemSrc);
1149 RemoveMovableOverride(itemDst);
1150
1151 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1152 {
1153 success = false;
1154 }
1155 else
1156 {
1157 return true;
1158 }
1159 }
1160
1161 RemoveMovableOverride(itemSrc);
1162 RemoveMovableOverride(itemDst);
1163
1165 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1166 {
1168 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1169 {
1170 #ifdef ENABLE_LOGGING
1172 {
1173 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1174 }
1175 #endif
1176
1178 }
1179 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1180 {
1181 #ifdef ENABLE_LOGGING
1183 {
1184 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1185 }
1186 #endif
1187
1188 ctx = new ScriptInputUserData;
1190
1191 validation.m_Result = InventoryValidationResult.JUNCTURE;
1192
1193 if (itemSrc)
1194 EnableMovableOverride(itemSrc);
1195 if (itemDst)
1196 EnableMovableOverride(itemDst);
1197 return true;
1198 }
1199 else
1200 {
1201 #ifdef ENABLE_LOGGING
1203 {
1204 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1205 }
1206 #endif
1207
1208 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1209 return true;
1210 }
1211 }
1212
1214 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1215 {
1216 CheckForRope(e.GetSrc(), e.GetDst());
1217 }
1218
1219 #ifdef ENABLE_LOGGING
1221 {
1222 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1223 }
1224 #endif
1225
1226 if (success)
1227 {
1228 validation.m_Result = InventoryValidationResult.SUCCESS;
1229 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1230 {
1232 //result = InventoryValidationResult.FAILURE;
1233 }
1234 }
1235
1236 return true;
1237 }
1238
1239 bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
1240 {
1242
1245
1248
1249 bool skippedSwap = false;
1250 bool success = true;
1251
1252 src1.ReadFromContext(ctx);
1253 src2.ReadFromContext(ctx);
1254 dst1.ReadFromContext(ctx);
1255 dst2.ReadFromContext(ctx);
1256 ctx.Read(skippedSwap);
1257
1258 #ifdef ENABLE_LOGGING
1260 {
1261 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2), "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1262 }
1263 #endif
1264
1265 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1266 {
1267 if (skippedSwap)
1268 {
1269 #ifdef ENABLE_LOGGING
1271 {
1272 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1273 }
1274 #endif
1275/*
1276 if (LogManager.IsSyncLogEnable())
1277 {
1278 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1279 }
1280*/
1281 }
1282 else
1283 {
1285
1286 #ifdef ENABLE_LOGGING
1288 {
1289 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1290 }
1291 #endif
1292
1293 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1294 }
1295
1296 return true;
1297 }
1298
1301
1305 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src1, GameInventory.c_MaxItemDistanceRadius))
1306 {
1307#ifdef ENABLE_LOGGING
1309 {
1310 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1311 }
1312
1314 {
1315 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1316 }
1317#endif
1318
1321
1322 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1323 {
1324 success = false;
1325 }
1326 else
1327 {
1328 return true;
1329 }
1330 }
1331
1335 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src2, GameInventory.c_MaxItemDistanceRadius))
1336 {
1337#ifdef ENABLE_LOGGING
1339 {
1340 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1341 }
1342
1344 {
1345 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1346 }
1347#endif
1348
1351
1352 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1353 {
1354 success = false;
1355 }
1356 else
1357 {
1358 return true;
1359 }
1360 }
1361
1365 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckSwapItemsRequest(src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius))
1366 {
1367#ifdef ENABLE_LOGGING
1369 {
1370 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1371 }
1372
1374 {
1375 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1376 }
1377#endif
1378
1381
1382 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1383 {
1384 success = false;
1385 }
1386 else
1387 {
1388 return true;
1389 }
1390 }
1391
1394
1395 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1396 {
1397 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1398 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1399 }
1400
1404 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1405 {
1406 #ifdef ENABLE_LOGGING
1407
1408 #ifdef DEVELOPER
1409 DumpInventoryDebug();
1410 #endif
1411
1413 {
1414 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1415 }
1416 #endif
1417
1418 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1419 {
1420 success = false;
1421 }
1422 else
1423 {
1424 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT swap cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) +" | src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1425 return true;
1426 }
1427 }
1428
1429 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1430 {
1431 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1432 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1433 }
1434
1435 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1436 {
1437 Error("HandleInputData: cmd=" + typename.EnumToString(InventoryCommandType, type) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1438 return true;
1439 }
1440
1442 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1443 {
1445 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1446 {
1447 #ifdef ENABLE_LOGGING
1449 {
1450 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1451 }
1452 #endif
1453
1455 }
1456 else if (success && result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1457 {
1458 #ifdef ENABLE_LOGGING
1460 {
1461 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1462 }
1463 #endif
1464
1465 validation.m_Result = InventoryValidationResult.JUNCTURE;
1468 return true;
1469 }
1470 else
1471 {
1472 #ifdef ENABLE_LOGGING
1474 {
1475 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1476 }
1477 #endif
1478
1479 validation.m_Result = InventoryValidationResult.FAILED;
1480 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1481 return true;
1482 }
1483 }
1484
1485 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
1486 {
1487 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1488 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1489 }
1490 else
1491 {
1494 }
1495
1496 //TODO: hotfix solution
1497 if (!validation.m_IsRemote && validation.m_IsJuncture && !SwapCheckExclusionMaskLocal(src1,src2,dst1,dst2))
1498 {
1499 #ifdef ENABLE_LOGGING
1501 {
1502 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1503 }
1504 #endif
1505 return false;
1506 }
1507
1508 #ifdef ENABLE_LOGGING
1510 {
1511 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1512 }
1513 #endif
1514 if (success)
1515 {
1516 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1517
1518 ctx = new ScriptInputUserData();
1519 InventoryInputUserData.SerializeSwap(ctx, src1, src2, dst1, dst2, !isNotSkipped);
1520
1521 validation.m_Result = InventoryValidationResult.SUCCESS;
1522 }
1523 return true;
1524 }
1525
1530 bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
1531 {
1532 if (isJuncture && isRemote)
1533 {
1535 return false;
1536 }
1537
1538 int type = -1;
1539 if (!ctx.Read(type))
1540 {
1541 return false;
1542 }
1543
1544 InventoryValidation validation = new InventoryValidation();
1545 validation.m_IsJuncture = isJuncture;
1546 validation.m_IsRemote = isRemote;
1547
1549 Serializer serializer = ctx;
1550
1551 switch (type)
1552 {
1553 case InventoryCommandType.USER_RESERVATION_CANCEL:
1554 if (!ValidateUserReservationCancel(serializer, validation))
1555 {
1556 return false;
1557 }
1558 break;
1559 case InventoryCommandType.SYNC_MOVE:
1560 if (!ValidateSyncMove(serializer, validation))
1561 {
1562 return false;
1563 }
1564 break;
1565 case InventoryCommandType.HAND_EVENT:
1566 if (!ValidateHandEvent(serializer, validation))
1567 {
1568 return false;
1569 }
1570 break;
1571 case InventoryCommandType.SWAP:
1572 if (!ValidateSwap(serializer, validation))
1573 {
1574 return false;
1575 }
1576 break;
1577 default:
1578 break;
1579 }
1580
1581 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1582
1583 switch (validation.m_Result)
1584 {
1585 case InventoryValidationResult.FAILED:
1586 if (canSendJuncture)
1587 {
1589 if (!serializer.CanWrite())
1590 {
1591 ScriptInputUserData writeableSerializer();
1592 writeableSerializer.CopyFrom(serializer);
1593 serializer = writeableSerializer;
1594 }
1595
1596 serializer.Write(validation.m_Reason);
1597
1598 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
1599 }
1600 break;
1601 case InventoryValidationResult.JUNCTURE:
1602 if (canSendJuncture)
1603 {
1604 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, serializer);
1605 //StoreInputForRemotes(isJuncture, isRemote, serializer);
1606 }
1607 else
1608 {
1609 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1610 }
1611 break;
1612 case InventoryValidationResult.SUCCESS:
1613 StoreInputForRemotes(isJuncture, isRemote, serializer);
1614 break;
1615 }
1616
1617 return true;
1618 }
1619
1621 {
1622 ItemBase itemIB = ItemBase.Cast(item);
1623 if (itemIB)
1624 itemIB.SetCanBeMovedOverride(false);
1625 }
1626
1628 {
1629 ItemBase itemIB = ItemBase.Cast(item);
1630 if (itemIB)
1631 itemIB.SetCanBeMovedOverride(true);
1632 }
1633
1634 // Hacky solution for dealing with fencekit rope related issues, could be fixed by introducing some indicator that this item behaves differently or sth..
1636 {
1637 Rope rope = Rope.Cast(src.GetItem());
1638 if (rope)
1639 rope.SetTargetLocation(dst);
1640 }
1641
1643 {
1644 return (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER) || (GetDayZPlayerOwner() == GetGame().GetPlayer());
1645 }
1646
1647 bool StoreInputForRemotes (bool handling_juncture, bool remote, ParamsReadContext ctx)
1648 {
1649 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1650 {
1651 #ifdef ENABLE_LOGGING
1653 {
1654 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString() );
1655 }
1656 #endif
1657
1658 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1659 return true;
1660 }
1661
1662 return false;
1663 }
1664
1665 override bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
1666 {
1667 if (GetManOwner().IsAlive() == false)
1668 return super.TakeToDst(mode, src, dst);
1669
1670 #ifdef ENABLE_LOGGING
1672 {
1673 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1674 }
1675 #endif
1676
1677 switch (mode)
1678 {
1679 case InventoryMode.SERVER:
1680 if (RedirectToHandEvent(mode, src, dst))
1681 {
1682 #ifdef ENABLE_LOGGING
1684 {
1685 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1686 }
1687 #endif
1688
1689 return true;
1690 }
1691
1692
1693 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1694 {
1695 if (GetGame().AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1696 {
1697#ifdef ENABLE_LOGGING
1699 {
1700 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1701 }
1702#endif
1703 }
1704 else
1705 {
1706#ifdef ENABLE_LOGGING
1708 {
1709 Debug.InventoryMoveLog("Juncture failed", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1710 }
1711
1713 {
1714 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1715 }
1716#endif
1717
1718 return false;
1719 }
1720
1721 }
1722
1725
1727
1728#ifdef ENABLE_LOGGING
1730 {
1731 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));
1732 }
1733#endif
1734
1736 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1737 #ifdef ENABLE_LOGGING
1739 {
1740 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() );
1741 }
1742 #endif
1743 return true;
1744
1745 case InventoryMode.LOCAL:
1746 LocationSyncMoveEntity(src, dst);
1747 return true;
1748 }
1749 if (!super.TakeToDst(mode,src,dst))
1750 {
1751 return PostDeferredEventTakeToDst(mode,src,dst);
1752 }
1753 return true;
1754 }
1755
1757 {
1758 if (!super.PostDeferredEventTakeToDst(mode,src,dst))
1759 return false;
1760
1761 if (!m_DeferredEvent)
1762 {
1763 m_DeferredEvent = new DeferredTakeToDst(mode,src,dst);
1764 if (m_DeferredEvent.ReserveInventory(this))
1765 return true;
1766 }
1767
1768 m_DeferredEvent = null;
1769 return false;
1770 }
1771
1772 void HandleTakeToDst( DeferredEvent deferred_event )
1773 {
1774 DeferredTakeToDst deferred_take_to_dst = DeferredTakeToDst.Cast(deferred_event);
1775 if( deferred_take_to_dst )
1776 {
1777 #ifdef ENABLE_LOGGING
1779 {
1780 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1781 }
1782 #endif
1783
1784 deferred_take_to_dst.ClearInventoryReservation(this);
1785
1787 {
1788 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));
1789 }
1790
1791 switch (deferred_take_to_dst.m_mode)
1792 {
1793 case InventoryMode.PREDICTIVE:
1794 #ifdef ENABLE_LOGGING
1796 {
1797 Debug.InventoryHFSMLog("PREDICTIVE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1798 }
1799 #endif
1800
1801 if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
1802 {
1803 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1804 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1805 }
1806 else
1807 {
1808 #ifdef ENABLE_LOGGING
1810 {
1811 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() );
1812 }
1813 #endif
1814 }
1815 break;
1816 case InventoryMode.JUNCTURE:
1817 #ifdef ENABLE_LOGGING
1819 {
1820 Debug.InventoryHFSMLog("JUNCTURE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1821 }
1822 #endif
1823
1824 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
1825 {
1826 DayZPlayer player = GetGame().GetPlayer();
1827 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1828 EnableMovableOverride(deferred_take_to_dst.m_dst.GetItem());
1829 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1830 }
1831 else
1832 {
1833 #ifdef ENABLE_LOGGING
1835 {
1836 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());
1837 }
1838 #endif
1839 }
1840 break;
1841 case InventoryMode.LOCAL:
1842 #ifdef ENABLE_LOGGING
1844 {
1845 Debug.InventoryHFSMLog("LOCAL ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1846 }
1847 #endif
1848 break;
1849 case InventoryMode.SERVER:
1850 #ifdef ENABLE_LOGGING
1852 {
1853 Debug.InventoryHFSMLog("SERVER ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1854 }
1855 #endif
1856 break;
1857 default:
1858 Error("HandEvent - Invalid mode");
1859 break;
1860 }
1861 }
1862 }
1863
1864 override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
1865 {
1866 #ifdef ENABLE_LOGGING
1868 {
1869 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a" , "n/a", "SwapEntities", GetDayZPlayerOwner().ToString() );
1870 }
1871 #endif
1872
1873 InventoryLocation src1, src2, dst1, dst2;
1874 if( mode == InventoryMode.LOCAL )
1875 {
1876 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
1877 {
1878 LocationSwap(src1, src2, dst1, dst2);
1879 return true;
1880 }
1881 }
1882
1883 if(!super.SwapEntities(mode,item1,item2))
1884 {
1885 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
1886 {
1887 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
1888 }
1889 }
1890 return true;
1891 }
1892
1893 override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
1894 {
1895 if (!super.PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2))
1896 return false;
1897
1898 if (!m_DeferredEvent)
1899 {
1900 m_DeferredEvent = new DeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
1901 if (m_DeferredEvent.ReserveInventory(this))
1902 return true;
1903 }
1904
1905 m_DeferredEvent = null;
1906 return false;
1907 }
1908
1909 void HandleSwapEntities( DeferredEvent deferred_event )
1910 {
1911 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
1912 if( deferred_swap_entities )
1913 {
1914 deferred_swap_entities.ClearInventoryReservation(this);
1915 InventoryLocation src1, src2, dst1, dst2;
1916 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
1917 {
1919 {
1920 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));
1921 }
1922
1923 switch (deferred_swap_entities.m_mode)
1924 {
1925 case InventoryMode.PREDICTIVE:
1926 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1927 {
1928 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1929 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1930 }
1931 else
1932 {
1933 #ifdef ENABLE_LOGGING
1935 {
1936 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() );
1937 }
1938 #endif
1939 }
1940 break;
1941
1942 case InventoryMode.JUNCTURE:
1943 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1944 {
1945 DayZPlayer player = GetGame().GetPlayer();
1946 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1947 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1948 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
1949 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
1950 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1951 }
1952 else
1953 {
1954 #ifdef ENABLE_LOGGING
1956 {
1957 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() );
1958 }
1959 #endif
1960 }
1961 break;
1962
1963 case InventoryMode.LOCAL:
1964 break;
1965
1966 default:
1967 Error("SwapEntities - HandEvent - Invalid mode");
1968 }
1969 }
1970 else
1971 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1972 }
1973 }
1974
1975 override bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
1976 {
1977 #ifdef ENABLE_LOGGING
1979 {
1980 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
1981 }
1982 #endif
1983
1984 InventoryLocation src1, src2, dst1;
1985 if( mode == InventoryMode.LOCAL )
1986 {
1987 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
1988 {
1989 LocationSwap(src1, src2, dst1, item2_dst);
1990 return true;
1991 }
1992
1993 }
1994
1995 if(!super.ForceSwapEntities(mode,item1,item2,item2_dst))
1996 {
1997 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
1998 {
1999 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, item2_dst);
2000 }
2001 }
2002
2003 return true;
2004 }
2005
2007 {
2008 DeferredForceSwapEntities deferred_force_swap_entities = DeferredForceSwapEntities.Cast(deferred_event);
2009 if (deferred_force_swap_entities)
2010 {
2011 deferred_force_swap_entities.ClearInventoryReservation(this);
2014 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
2015 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
2016
2017 DayZPlayer player = GetGame().GetPlayer();
2018
2020 {
2021 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));
2022 }
2023
2024 switch (deferred_force_swap_entities.m_mode)
2025 {
2026 case InventoryMode.PREDICTIVE:
2027 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))
2028 {
2029 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2030 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2031 }
2032 else
2033 {
2034 #ifdef ENABLE_LOGGING
2036 {
2037 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());
2038 }
2039 #endif
2040 }
2041 break;
2042
2043 case InventoryMode.JUNCTURE:
2044 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))
2045 {
2046 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2047 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2048
2049 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2050 }
2051 else
2052 {
2053 #ifdef ENABLE_LOGGING
2055 {
2056 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());
2057 }
2058 #endif
2059 }
2060 break;
2061
2062 case InventoryMode.LOCAL:
2063 break;
2064
2065 default:
2066 Error("ForceSwapEntities - HandEvent - Invalid mode");
2067 }
2068 }
2069 }
2070
2072 {
2073 if (GetGame().IsServer())
2074 {
2075 if (e.IsServerSideOnly())
2076 {
2077 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
2078 }
2079
2080 if (player.IsAlive())
2081 {
2082 InventoryLocation dst = e.GetDst();
2083 InventoryLocation src = e.GetSrc();
2084 if (src.IsValid() && dst.IsValid())
2085 {
2086 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
2087 {
2088#ifdef ENABLE_LOGGING
2090 {
2091 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
2092 }
2093#endif
2094
2095 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
2096 {
2097#ifdef ENABLE_LOGGING
2099 {
2100 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
2101 }
2102#endif
2103 }
2104 else
2105 {
2106#ifdef ENABLE_LOGGING
2108 {
2109 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
2110 }
2111#endif
2112 }
2113 }
2114
2115#ifdef ENABLE_LOGGING
2117 {
2118 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));
2119 }
2120#endif
2121
2124 player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, ctx);
2125
2126#ifdef ENABLE_LOGGING
2128 {
2129 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));
2130 }
2131#endif
2132
2134 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
2135 }
2136 }
2137 else
2138 {
2139 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
2140 }
2141 }
2142 }
2143
2147 override void NetSyncCurrentStateID (int id)
2148 {
2149 super.NetSyncCurrentStateID(id);
2150
2151 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
2152 }
2153
2160 override void OnAfterStoreLoad ()
2161 {
2162 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
2163 }
2164
2169 {
2170 if (GetEntityInHands())
2171 {
2172 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
2173 if (wpn)
2174 {
2176
2178 if (pb && e)
2179 {
2180 pb.GetWeaponManager().SetRunning(true);
2181
2183 {
2184 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
2185 }
2186
2187 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
2188 {
2189 wpn.ProcessWeaponAbortEvent(e);
2190 }
2191 else
2192 {
2193 wpn.ProcessWeaponEvent(e);
2194 }
2195 pb.GetWeaponManager().SetRunning(false);
2196 }
2197 }
2198 else
2199 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
2200 }
2201 else
2202 Error("OnEventForRemoteWeapon - no entity in hands");
2203 return true;
2204 }
2205
2206
2211 {
2212 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2213 if (e)
2214 {
2216 {
2217 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
2218 }
2219
2220 //m_FSM.ProcessEvent(e);
2221
2222 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
2223 {
2225 m_FSM.ProcessAbortEvent(e, aa);
2226 }
2227 else
2228 {
2229 m_FSM.ProcessEvent(e);
2230 }
2231
2232 return true;
2233 }
2234 return false;
2235 }
2236
2238 {
2240 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2241 {
2243
2245 e.WriteToContext(ctx);
2246
2248 {
2249 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
2250 }
2251
2252 p.StoreInputForRemotes(ctx);
2253 }
2254 }
2255
2257 {
2258 super.OnHandsExitedStableState(src, dst);
2259
2261 {
2262 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
2263 }
2264 }
2265
2267 {
2268 super.OnHandsEnteredStableState(src, dst);
2269
2271 {
2272 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
2273 }
2274 }
2275
2277 {
2278 super.OnHandsStateChanged(src, dst);
2279
2281 {
2282 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
2283 }
2284
2285 if (src.IsIdle())
2286 OnHandsExitedStableState(src, dst);
2287
2288 if (dst.IsIdle())
2289 OnHandsEnteredStableState(src, dst);
2290
2291#ifdef DIAG_DEVELOPER
2293 if (p && p.m_Bot)
2294 {
2295 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
2296 }
2297#endif
2298 }
2299
2301 {
2302 if (!IsProcessing())
2303 {
2304 EntityAI itemInHands = GetEntityInHands();
2305
2307 il.SetHands(GetInventoryOwner(), itemInHands);
2308
2309 InventoryValidation validation = new InventoryValidation();
2310 if (e.CanPerformEventEx(validation))
2311 {
2312 m_DeferredEvent = new DeferredHandEvent(mode, e);
2313 if (m_DeferredEvent.ReserveInventory(this))
2314 {
2315 return true;
2316 }
2317 }
2318
2319 m_DeferredEvent = null;
2320
2322 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
2323 {
2325 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
2326 }
2327 else
2328 {
2329 ScriptInputUserData serializer();
2330
2332 serializer.Write(validation.m_Reason);
2333
2334 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
2335 }
2336 }
2337
2338 return false;
2339 }
2340
2341
2342 void HandleHandEvent(DeferredEvent deferred_event)
2343 {
2345 InventoryValidation validation = new InventoryValidation();
2346
2347 DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(deferred_event);
2348 if (deferred_hand_event)
2349 {
2350 #ifdef ENABLE_LOGGING
2352 {
2353 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2354 }
2355 #endif
2356
2358 {
2359 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2360 }
2361
2362 switch (deferred_hand_event.m_mode)
2363 {
2364 case InventoryMode.PREDICTIVE:
2365 #ifdef ENABLE_LOGGING
2367 {
2368 Debug.InventoryHFSMLog("PREDICTIVE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2369 }
2370 #endif
2371
2372 deferred_hand_event.ClearInventoryReservation(this);
2373 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2374 {
2376 ProcessHandEvent(deferred_hand_event.m_event);
2377 }
2378 break;
2379
2380 case InventoryMode.JUNCTURE:
2381 #ifdef ENABLE_LOGGING
2383 {
2384 Debug.InventoryHFSMLog("JUNCTURE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2385 }
2386 #endif
2387
2388 deferred_hand_event.ClearInventoryReservation(this);
2389 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2390 {
2391 deferred_hand_event.ReserveInventory(this);
2393
2394 //Functionality to prevent desync when two players perform interfering action at the same time
2395 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2396 EntityAI itemDst = null;
2397 if (deferred_hand_event.m_event.GetDst())
2398 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2399 if (itemSrc)
2400 EnableMovableOverride(itemSrc);
2401 if (itemDst)
2402 EnableMovableOverride(itemDst);
2403 }
2404 break;
2405
2406 case InventoryMode.LOCAL:
2407 #ifdef ENABLE_LOGGING
2409 {
2410 Debug.InventoryHFSMLog("LOCAL", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2411 }
2412 #endif
2413
2414 deferred_hand_event.ClearInventoryReservation(this);
2415 ProcessHandEvent(deferred_hand_event.m_event);
2416 //PostHandEvent(deferred_hand_event.m_event);
2417 break;
2418
2419 case InventoryMode.SERVER:
2420 #ifdef ENABLE_LOGGING
2422 {
2423 Debug.InventoryHFSMLog("SERVER", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2424 }
2425
2427 {
2428 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2429 }
2430 #endif
2431
2432 if (!deferred_hand_event.m_event.IsServerSideOnly())
2433 {
2434 if (GetDayZPlayerOwner().IsAlive())
2435 {
2437 }
2438 else
2439 {
2441 }
2442 }
2443 else
2444 {
2445 ProcessHandEvent(deferred_hand_event.m_event);
2446 }
2447 break;
2448
2449 default:
2450 Error("HumanInventory::HandEvent - Invalid mode");
2451 }
2452 }
2453 }
2454
2456 {
2457 super.HandleInventoryManipulation();
2459 {
2464
2465 m_DeferredEvent = null;
2466 }
2467 }
2468
2469
2470
2472 {
2473 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2474 }
2475
2476 bool PlayerCheckRequestSrc ( notnull InventoryLocation src, float radius )
2477 {
2478 bool result = true;
2479
2480 EntityAI ent = src.GetParent();
2481 if ( ent )
2482 {
2483 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2484 if (player)
2485 {
2486 if ( GetDayZPlayerOwner() != player )
2487 {
2488 if (player.IsAlive())
2489 {
2490 if (!player.IsRestrained() && !player.IsUnconscious())
2491 {
2492 return false;
2493 }
2494 }
2495 }
2496 }
2497 }
2498
2499 if ( result )
2500 {
2501 result = CheckRequestSrc( GetManOwner(), src, radius);
2502 }
2503
2504 return result;
2505 }
2506
2507 bool PlayerCheckRequestDst ( notnull InventoryLocation src, notnull InventoryLocation dst, float radius )
2508 {
2509 bool result = true;
2510
2511 EntityAI ent = dst.GetParent();
2512 if ( ent )
2513 {
2514 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2515 if (player)
2516 {
2517 if ( GetDayZPlayerOwner() != player )
2518 {
2519 if (player.IsAlive())
2520 {
2521 if (!player.IsRestrained() && !player.IsUnconscious())
2522 {
2523 return false;
2524 }
2525 }
2526 }
2527 }
2528 }
2529
2530 if ( result )
2531 {
2532 result = CheckMoveToDstRequest( GetManOwner(), src, dst, radius);
2533 }
2534
2535 return result;
2536 }
2537
2538 bool PlayerCheckSwapItemsRequest( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
2539 {
2540 bool result = true;
2541
2542 EntityAI ent = dst1.GetParent();
2543 PlayerBase player;
2544 if ( ent )
2545 {
2546 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2547 if (player)
2548 {
2549 if ( GetDayZPlayerOwner() != player )
2550 {
2551 if (player.IsAlive())
2552 {
2553 if (!player.IsRestrained() && !player.IsUnconscious())
2554 {
2555 return false;
2556 }
2557 }
2558 }
2559 }
2560 }
2561
2562 ent = dst2.GetParent();
2563 if ( ent )
2564 {
2565 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2566 if (player)
2567 {
2568 if ( GetDayZPlayerOwner() != player )
2569 {
2570 if (player.IsAlive())
2571 {
2572 if (!player.IsRestrained() && !player.IsUnconscious())
2573 {
2574 return false;
2575 }
2576 }
2577 }
2578 }
2579 }
2580
2581
2582 if ( result )
2583 {
2584 result = CheckSwapItemsRequest( GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2585 }
2586
2587 return result;
2588
2589 }
2590
2591 bool PlayerCheckDropRequest ( notnull InventoryLocation src, float radius )
2592 {
2593 bool result = true;
2594
2595 EntityAI ent = src.GetParent();
2596 if ( ent )
2597 {
2598 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2599 if (player)
2600 {
2601 if ( GetDayZPlayerOwner() != player )
2602 {
2603 if (player.IsAlive())
2604 {
2605 if (!player.IsRestrained() && !player.IsUnconscious())
2606 {
2607 return false;
2608 }
2609 }
2610 }
2611 }
2612 }
2613
2614 if ( result )
2615 {
2616 result = CheckDropRequest( GetManOwner(), src, radius);
2617 }
2618
2619 return result;
2620 }
2621
2624 {
2625 if (dst.GetType() == InventoryLocationType.ATTACHMENT)
2626 {
2627 return dst.GetParent().CheckAttachmentReceiveExclusion(src.GetItem(),dst.GetSlot());
2628 }
2629
2630 return true;
2631 }
2632
2634 bool SwapCheckExclusionMaskLocal ( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
2635 {
2636 bool failed = false;
2637
2638 if (dst1.GetType() == InventoryLocationType.ATTACHMENT)
2639 {
2640 failed |= !dst1.GetParent().CheckAttachmentReceiveExclusion(dst1.GetItem(),dst1.GetSlot());
2641 }
2642
2643 if (dst2.GetType() == InventoryLocationType.ATTACHMENT)
2644 {
2645 failed |= !dst2.GetParent().CheckAttachmentReceiveExclusion(dst2.GetItem(),dst2.GetSlot());
2646 }
2647 return !failed;
2648 }
2649
2652 {
2654
2655 if (validation.m_IsJuncture)
2656 {
2663
2664 return true;
2665 }
2666
2668 src.ReadFromContext(ctx);
2669
2670 #ifdef ENABLE_LOGGING
2672 {
2673 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2674 }
2675 #endif
2676
2677 if (validation.m_IsRemote && !src.GetItem())
2678 {
2679 #ifdef ENABLE_LOGGING
2681 {
2682 Debug.InventoryMoveLog("Failed item not exist", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2683 }
2684 #endif
2685
2686 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
2687 return true;
2688 }
2689
2694 {
2695 #ifdef ENABLE_LOGGING
2697 {
2698 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2699 }
2700 #endif
2701
2702 return true;
2703 }
2704
2709 {
2710 #ifdef ENABLE_LOGGING
2712 {
2713 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2714 }
2715 #endif
2716
2717 return true;
2718 }
2719
2720 #ifdef ENABLE_LOGGING
2722 {
2723 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2724 }
2725 #endif
2726
2727 GetGame().ObjectDelete(src.GetItem());
2728
2729 validation.m_Result = InventoryValidationResult.SUCCESS;
2730 return true;
2731 }
2732}
void syncDebugPrint(string s)
Определения 3_Game/Systems/Inventory/Debug.c:1
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_HAND_REMOTE_EVENT
void wpnDebugSpamALot(string s)
void wpnDebugPrint(string s)
override Widget Init()
Определения DayZGame.c:127
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2591
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:772
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1004
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1627
void OnHandleStoredInputUserData(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:727
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:2634
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
Определения DayZPlayerInventory.c:1530
ref HandAnimatedForceSwapping m_FSwapping
Определения DayZPlayerInventory.c:161
m_DeferredEvent
void HandleHandEvent(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2342
void HandleWeaponEvents(float dt, out bool exitIronSights)
Определения DayZPlayerInventory.c:346
proto native void StoreInputUserData(ParamsReadContext ctx)
void OnHandleStoredJunctureData(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:679
void SyncHandEventToRemote(HandEventBase e)
Определения DayZPlayerInventory.c:2237
void HandleTakeToDst(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:1772
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:162
ref HandAnimatedSwapping m_Swapping
Определения DayZPlayerInventory.c:160
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
DEPRECATED.
Определения DayZPlayerInventory.c:2651
bool MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:2623
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1635
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2476
void AbortWeaponEvent()
Определения DayZPlayerInventory.c:282
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:665
void PostWeaponEvent(WeaponEventBase e)
Определения DayZPlayerInventory.c:304
override void NetSyncCurrentStateID(int id)
Определения DayZPlayerInventory.c:2147
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2266
bool IsServerOrLocalPlayer()
Определения DayZPlayerInventory.c:1642
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:1665
override void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:581
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1620
ref HandEventBase m_DeferredPostedHandEvent
Определения DayZPlayerInventory.c:155
override void HandleInventoryManipulation()
Определения DayZPlayerInventory.c:2455
override bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:532
void DayZPlayerInventory()
Определения DayZPlayerInventory.c:164
ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
Определения DayZPlayerInventory.c:158
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
Определения DayZPlayerInventory.c:1864
ref HandAnimatedMovingToAtt m_MovingTo
Определения DayZPlayerInventory.c:159
override bool OnInventoryJunctureRepairFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:556
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:15
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2256
override void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2276
override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:1893
bool OnHandEventForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:2210
ref InventoryLocation m_dst1
Определения DayZPlayerInventory.c:86
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
Определения DayZPlayerInventory.c:156
void OnInputUserDataForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:748
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
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:1975
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1239
void HandleSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:1909
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:2538
void HandleInventory(float dt)
Определения DayZPlayerInventory.c:445
void DeferredWeaponFailed()
Определения DayZPlayerInventory.c:321
ref InventoryLocation m_dst
Определения DayZPlayerInventory.c:13
void HandleForceSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2006
ref Timer m_DeferredWeaponTimer
Определения DayZPlayerInventory.c:151
override bool PostDeferredEventTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:1756
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:2507
bool OnEventForRemoteWeapon(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:2168
override void OnServerInventoryCommand(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:760
void CancelHandEvent()
cancels any handevents that will be executed this frame @NOTE: this is used in situations where the p...
Определения DayZPlayerInventory.c:270
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:2300
void CancelWeaponEvent()
Определения DayZPlayerInventory.c:276
class DeferredEvent m_src
EntityAI m_item2
Определения DayZPlayerInventory.c:85
static void SendServerHandEventViaJuncture(notnull DayZPlayer player, HandEventBase e)
Определения DayZPlayerInventory.c:2071
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Определения EmoteManager.c:502
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:1645
void fsmDebugSpam(string s)
Определения HFSMBase.c:9
bool CheckRequestSrc()
Определения Hand_Events.c:104
bool IsAuthoritative()
Определения Hand_Events.c:55
bool ReserveInventory()
Определения Hand_Events.c:174
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
Определения Hand_Events.c:820
JunctureRequestResult
Определения Hand_Events.c:28
HandEventID
events
Определения Hand_Events.c:7
bool IsOwner()
Определения Hand_Events.c:60
void ClearInventoryReservation()
Определения Hand_Events.c:193
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
float GetTime()
Определения NotificationSystem.c:35
override void OnAfterStoreLoad()
engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase....
Определения PlayerStatBase.c:189
bool ClearJunctureEx(Man player, notnull EntityAI item)
Определения Global/game.c:762
proto native DayZPlayer GetPlayer()
proto native void ObjectDelete(Object obj)
Super root of all classes in Enforce script.
Определения EnScript.c:11
override void OnItemInHandsChanged()
Определения DayZPlayerImplement.c:963
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/tools/Debug.c:147
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/tools/Debug.c:137
Определения 3_Game/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 GetDst()
Определения Hand_Events.c:212
override bool AcquireInventoryJunctureFromServer(notnull Man player)
Определения Hand_Events.c:257
override EntityAI GetSecondSrcEntity()
Определения Hand_Events.c:600
override bool IsServerSideOnly()
Определения Hand_Events.c:744
override string DumpToString()
Определения Hand_Events.c:332
override void ClearInventoryReservation()
Определения Hand_Events.c:697
override void WriteToContext(ParamsWriteContext ctx)
Определения Hand_Events.c:282
override bool CheckRequestSrc()
Определения Hand_Events.c:219
override bool CanPerformEventEx(InventoryValidation validation)
Определения Hand_Events.c:235
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:209
Определения Hand_Events.c:705
override bool IsIdle()
idle state does not expect any animation events
Определения HandStableState.c:34
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:998
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:37
static void SendInputUserDataHandEvent(HandEventBase e)
Определения InventoryInputUserData.c:79
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:48
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
Определения InventoryInputUserData.c:72
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:90
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:226
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:296
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
InventoryValidationResult m_Result
InventoryValidationReason m_Reason
static bool IsWeaponLogEnable()
Определения 3_Game/tools/Debug.c:718
static bool IsSyncLogEnable()
Определения 3_Game/tools/Debug.c:678
static bool IsInventoryHFSMLogEnable()
Определения 3_Game/tools/Debug.c:668
static bool IsInventoryMoveLogEnable()
Определения 3_Game/tools/Debug.c:648
Определения 3_Game/tools/Debug.c:594
Определения 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:63
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
proto native void StoreInputForRemotes(ParamsWriteContext ctx)
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1068
proto native DayZPlayerInstanceType GetInstanceType()
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
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.
WeaponActions
actions
Определения human.c:816
WeaponEvents
events
Определения human.c:967
string WeaponActionTypeToString(int A, int AT)
Определения human.c:947