DayZ 1.27
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
1032 #ifdef ENABLE_LOGGING
1034 {
1035 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1036 }
1037 #endif
1038
1039 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1040
1041 return true;
1042 }
1043
1045 if (itemSrc)
1046 RemoveMovableOverride(itemSrc);
1047 if (itemDst)
1048 RemoveMovableOverride(itemDst);
1049
1053 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1054 {
1055 #ifdef ENABLE_LOGGING
1057 {
1058 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1059 }
1060 #endif
1061
1062 if (!validation.m_IsRemote)
1063 {
1064 ctx = new ScriptInputUserData;
1066 }
1067
1068 RemoveMovableOverride(itemSrc);
1069 RemoveMovableOverride(itemDst);
1070
1071 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1072 {
1073 success = false;
1074 }
1075 else
1076 {
1077 return true;
1078 }
1079 }
1080
1081 if (success && !e.CheckRequestEx(validation))
1082 {
1083 #ifdef ENABLE_LOGGING
1085 {
1086 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1087 }
1088 #endif
1089
1091
1092 ctx = new ScriptInputUserData;
1094
1095#ifdef ENABLE_LOGGING
1097 {
1098 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1099 }
1100#endif
1101
1102 RemoveMovableOverride(itemSrc);
1103 RemoveMovableOverride(itemDst);
1104
1105 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1106 {
1107 success = false;
1108 }
1109 else
1110 {
1111 return true;
1112 }
1113 }
1114
1117 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1118 {
1119 #ifdef ENABLE_LOGGING
1121 {
1122 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1123 }
1124 #endif
1125
1127
1128 ctx = new ScriptInputUserData;
1130
1131#ifdef ENABLE_LOGGING
1133 {
1134 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1135 }
1136#endif
1137
1138 RemoveMovableOverride(itemSrc);
1139 RemoveMovableOverride(itemDst);
1140
1141 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1142 {
1143 success = false;
1144 }
1145 else
1146 {
1147 return true;
1148 }
1149 }
1150
1151 RemoveMovableOverride(itemSrc);
1152 RemoveMovableOverride(itemDst);
1153
1155 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1156 {
1158 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1159 {
1160 #ifdef ENABLE_LOGGING
1162 {
1163 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1164 }
1165 #endif
1166
1168 }
1169 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1170 {
1171 #ifdef ENABLE_LOGGING
1173 {
1174 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1175 }
1176 #endif
1177
1178 ctx = new ScriptInputUserData;
1180
1181 validation.m_Result = InventoryValidationResult.JUNCTURE;
1182
1183 if (itemSrc)
1184 EnableMovableOverride(itemSrc);
1185 if (itemDst)
1186 EnableMovableOverride(itemDst);
1187 return true;
1188 }
1189 else
1190 {
1191 #ifdef ENABLE_LOGGING
1193 {
1194 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1195 }
1196 #endif
1197
1198 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1199 return true;
1200 }
1201 }
1202
1204 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1205 {
1206 CheckForRope(e.GetSrc(), e.GetDst());
1207 }
1208
1209 #ifdef ENABLE_LOGGING
1211 {
1212 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1213 }
1214 #endif
1215
1216 if (success)
1217 {
1218 validation.m_Result = InventoryValidationResult.SUCCESS;
1219 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1220 {
1222 //result = InventoryValidationResult.FAILURE;
1223 }
1224 }
1225
1226 return true;
1227 }
1228
1229 bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
1230 {
1232
1235
1238
1239 bool skippedSwap = false;
1240 bool success = true;
1241
1242 src1.ReadFromContext(ctx);
1243 src2.ReadFromContext(ctx);
1244 dst1.ReadFromContext(ctx);
1245 dst2.ReadFromContext(ctx);
1246 ctx.Read(skippedSwap);
1247
1248 #ifdef ENABLE_LOGGING
1250 {
1251 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() );
1252 }
1253 #endif
1254
1255 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1256 {
1257 if (skippedSwap)
1258 {
1259 #ifdef ENABLE_LOGGING
1261 {
1262 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1263 }
1264 #endif
1265/*
1266 if (LogManager.IsSyncLogEnable())
1267 {
1268 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1269 }
1270*/
1271 }
1272 else
1273 {
1275
1276 #ifdef ENABLE_LOGGING
1278 {
1279 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1280 }
1281 #endif
1282
1283 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1284 }
1285
1286 return true;
1287 }
1288
1291
1295 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src1, GameInventory.c_MaxItemDistanceRadius))
1296 {
1297#ifdef ENABLE_LOGGING
1299 {
1300 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1301 }
1302
1304 {
1305 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1306 }
1307#endif
1308
1311
1312 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1313 {
1314 success = false;
1315 }
1316 else
1317 {
1318 return true;
1319 }
1320 }
1321
1325 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src2, GameInventory.c_MaxItemDistanceRadius))
1326 {
1327#ifdef ENABLE_LOGGING
1329 {
1330 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1331 }
1332
1334 {
1335 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1336 }
1337#endif
1338
1341
1342 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1343 {
1344 success = false;
1345 }
1346 else
1347 {
1348 return true;
1349 }
1350 }
1351
1355 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckSwapItemsRequest(src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius))
1356 {
1357#ifdef ENABLE_LOGGING
1359 {
1360 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1361 }
1362
1364 {
1365 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));
1366 }
1367#endif
1368
1371
1372 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1373 {
1374 success = false;
1375 }
1376 else
1377 {
1378 return true;
1379 }
1380 }
1381
1384
1385 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1386 {
1387 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1388 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1389 }
1390
1394 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1395 {
1396 #ifdef ENABLE_LOGGING
1397
1398 #ifdef DEVELOPER
1399 DumpInventoryDebug();
1400 #endif
1401
1403 {
1404 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1405 }
1406 #endif
1407
1408 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1409 {
1410 success = false;
1411 }
1412 else
1413 {
1414 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));
1415 return true;
1416 }
1417 }
1418
1419 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1420 {
1421 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1422 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1423 }
1424
1425 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1426 {
1427 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));
1428 return true;
1429 }
1430
1432 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1433 {
1435 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1436 {
1437 #ifdef ENABLE_LOGGING
1439 {
1440 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1441 }
1442 #endif
1443
1445 }
1446 else if (success && result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1447 {
1448 #ifdef ENABLE_LOGGING
1450 {
1451 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1452 }
1453 #endif
1454
1455 validation.m_Result = InventoryValidationResult.JUNCTURE;
1458 return true;
1459 }
1460 else
1461 {
1462 #ifdef ENABLE_LOGGING
1464 {
1465 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1466 }
1467 #endif
1468
1469 validation.m_Result = InventoryValidationResult.FAILED;
1470 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1471 return true;
1472 }
1473 }
1474
1475 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
1476 {
1477 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1478 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1479 }
1480 else
1481 {
1484 }
1485
1486 //TODO: hotfix solution
1487 if (!validation.m_IsRemote && validation.m_IsJuncture && !SwapCheckExclusionMaskLocal(src1,src2,dst1,dst2))
1488 {
1489 #ifdef ENABLE_LOGGING
1491 {
1492 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1493 }
1494 #endif
1495 return false;
1496 }
1497
1498 #ifdef ENABLE_LOGGING
1500 {
1501 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1502 }
1503 #endif
1504 if (success)
1505 {
1506 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1507
1508 ctx = new ScriptInputUserData();
1509 InventoryInputUserData.SerializeSwap(ctx, src1, src2, dst1, dst2, !isNotSkipped);
1510
1511 validation.m_Result = InventoryValidationResult.SUCCESS;
1512 }
1513 return true;
1514 }
1515
1520 bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
1521 {
1522 if (isJuncture && isRemote)
1523 {
1525 return false;
1526 }
1527
1528 int type = -1;
1529 if (!ctx.Read(type))
1530 {
1531 return false;
1532 }
1533
1534 InventoryValidation validation();
1535 validation.m_IsJuncture = isJuncture;
1536 validation.m_IsRemote = isRemote;
1537
1539 Serializer serializer = ctx;
1540
1541 switch (type)
1542 {
1543 case InventoryCommandType.USER_RESERVATION_CANCEL:
1544 if (!ValidateUserReservationCancel(serializer, validation))
1545 {
1546 return false;
1547 }
1548 break;
1549 case InventoryCommandType.SYNC_MOVE:
1550 if (!ValidateSyncMove(serializer, validation))
1551 {
1552 return false;
1553 }
1554 break;
1555 case InventoryCommandType.HAND_EVENT:
1556 if (!ValidateHandEvent(serializer, validation))
1557 {
1558 return false;
1559 }
1560 break;
1561 case InventoryCommandType.SWAP:
1562 if (!ValidateSwap(serializer, validation))
1563 {
1564 return false;
1565 }
1566 break;
1567 default:
1568 break;
1569 }
1570
1571 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1572
1573 switch (validation.m_Result)
1574 {
1575 case InventoryValidationResult.FAILED:
1576 if (canSendJuncture)
1577 {
1579 if (!serializer.CanWrite())
1580 {
1581 ScriptInputUserData writeableSerializer();
1582 writeableSerializer.CopyFrom(serializer);
1583 serializer = writeableSerializer;
1584 }
1585
1586 serializer.Write(validation.m_Reason);
1587
1588 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
1589 }
1590 break;
1591 case InventoryValidationResult.JUNCTURE:
1592 if (canSendJuncture)
1593 {
1594 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, serializer);
1595 //StoreInputForRemotes(isJuncture, isRemote, serializer);
1596 }
1597 else
1598 {
1599 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1600 }
1601 break;
1602 case InventoryValidationResult.SUCCESS:
1603 StoreInputForRemotes(isJuncture, isRemote, serializer);
1604 break;
1605 }
1606
1607 return true;
1608 }
1609
1611 {
1612 ItemBase itemIB = ItemBase.Cast(item);
1613 if (itemIB)
1614 itemIB.SetCanBeMovedOverride(false);
1615 }
1616
1618 {
1619 ItemBase itemIB = ItemBase.Cast(item);
1620 if (itemIB)
1621 itemIB.SetCanBeMovedOverride(true);
1622 }
1623
1624 // Hacky solution for dealing with fencekit rope related issues, could be fixed by introducing some indicator that this item behaves differently or sth..
1626 {
1627 Rope rope = Rope.Cast(src.GetItem());
1628 if (rope)
1629 rope.SetTargetLocation(dst);
1630 }
1631
1633 {
1634 return GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || GetDayZPlayerOwner() == GetGame().GetPlayer());
1635 }
1636
1637 bool StoreInputForRemotes (bool handling_juncture, bool remote, ParamsReadContext ctx)
1638 {
1639 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1640 {
1641 #ifdef ENABLE_LOGGING
1643 {
1644 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString() );
1645 }
1646 #endif
1647
1648 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1649 return true;
1650 }
1651
1652 return false;
1653 }
1654
1655 override bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
1656 {
1657 if (GetManOwner().IsAlive() == false)
1658 return super.TakeToDst(mode, src, dst);
1659
1660 #ifdef ENABLE_LOGGING
1662 {
1663 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1664 }
1665 #endif
1666
1667 switch (mode)
1668 {
1669 case InventoryMode.SERVER:
1670 if (RedirectToHandEvent(mode, src, dst))
1671 {
1672 #ifdef ENABLE_LOGGING
1674 {
1675 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1676 }
1677 #endif
1678
1679 return true;
1680 }
1681
1682
1683 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1684 {
1685 if (GetGame().AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1686 {
1687#ifdef ENABLE_LOGGING
1689 {
1690 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1691 }
1692#endif
1693 }
1694 else
1695 {
1696#ifdef ENABLE_LOGGING
1698 {
1699 Debug.InventoryMoveLog("Juncture failed", "n/a" , "n/a", "TakeToDst", GetDayZPlayerOwner().ToString() );
1700 }
1701
1703 {
1704 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1705 }
1706#endif
1707
1708 return false;
1709 }
1710
1711 }
1712
1715
1717
1718#ifdef ENABLE_LOGGING
1720 {
1721 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));
1722 }
1723#endif
1724
1726 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1727 #ifdef ENABLE_LOGGING
1729 {
1730 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() );
1731 }
1732 #endif
1733 return true;
1734
1735 case InventoryMode.LOCAL:
1736 LocationSyncMoveEntity(src, dst);
1737 return true;
1738 }
1739 if (!super.TakeToDst(mode,src,dst))
1740 {
1741 return PostDeferredEventTakeToDst(mode,src,dst);
1742 }
1743 return true;
1744 }
1745
1747 {
1748 if (!super.PostDeferredEventTakeToDst(mode,src,dst))
1749 return false;
1750
1751 if (!m_DeferredEvent)
1752 {
1753 m_DeferredEvent = new DeferredTakeToDst(mode,src,dst);
1754 if (m_DeferredEvent.ReserveInventory(this))
1755 return true;
1756 }
1757
1758 m_DeferredEvent = null;
1759 return false;
1760 }
1761
1762 void HandleTakeToDst( DeferredEvent deferred_event )
1763 {
1764 DeferredTakeToDst deferred_take_to_dst = DeferredTakeToDst.Cast(deferred_event);
1765 if( deferred_take_to_dst )
1766 {
1767 #ifdef ENABLE_LOGGING
1769 {
1770 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1771 }
1772 #endif
1773
1774 deferred_take_to_dst.ClearInventoryReservation(this);
1775
1777 {
1778 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));
1779 }
1780
1781 switch (deferred_take_to_dst.m_mode)
1782 {
1783 case InventoryMode.PREDICTIVE:
1784 #ifdef ENABLE_LOGGING
1786 {
1787 Debug.InventoryHFSMLog("PREDICTIVE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString() );
1788 }
1789 #endif
1790
1791 if (LocationCanMoveEntity(deferred_take_to_dst.m_src,deferred_take_to_dst.m_dst))
1792 {
1793 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1794 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1795 }
1796 else
1797 {
1798 #ifdef ENABLE_LOGGING
1800 {
1801 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() );
1802 }
1803 #endif
1804 }
1805 break;
1806 case InventoryMode.JUNCTURE:
1807 #ifdef ENABLE_LOGGING
1809 {
1810 Debug.InventoryHFSMLog("JUNCTURE ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1811 }
1812 #endif
1813
1814 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
1815 {
1816 DayZPlayer player = GetGame().GetPlayer();
1817 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1818 EnableMovableOverride(deferred_take_to_dst.m_dst.GetItem());
1819 InventoryInputUserData.SendInputUserDataMove(InventoryCommandType.SYNC_MOVE, deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1820 }
1821 else
1822 {
1823 #ifdef ENABLE_LOGGING
1825 {
1826 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());
1827 }
1828 #endif
1829 }
1830 break;
1831 case InventoryMode.LOCAL:
1832 #ifdef ENABLE_LOGGING
1834 {
1835 Debug.InventoryHFSMLog("LOCAL ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1836 }
1837 #endif
1838 break;
1839 case InventoryMode.SERVER:
1840 #ifdef ENABLE_LOGGING
1842 {
1843 Debug.InventoryHFSMLog("SERVER ", "n/a" , "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1844 }
1845 #endif
1846 break;
1847 default:
1848 Error("HandEvent - Invalid mode");
1849 break;
1850 }
1851 }
1852 }
1853
1854 override bool SwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
1855 {
1856 #ifdef ENABLE_LOGGING
1858 {
1859 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a" , "n/a", "SwapEntities", GetDayZPlayerOwner().ToString() );
1860 }
1861 #endif
1862
1863 InventoryLocation src1, src2, dst1, dst2;
1864 if( mode == InventoryMode.LOCAL )
1865 {
1866 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
1867 {
1868 LocationSwap(src1, src2, dst1, dst2);
1869 return true;
1870 }
1871 }
1872
1873 if(!super.SwapEntities(mode,item1,item2))
1874 {
1875 if (GameInventory.MakeSrcAndDstForSwap(item1, item2, src1, src2, dst1, dst2))
1876 {
1877 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
1878 }
1879 }
1880 return true;
1881 }
1882
1883 override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
1884 {
1885 if (!super.PostDeferredForceSwapEntities(mode, item1, item2, dst1, dst2))
1886 return false;
1887
1888 if (!m_DeferredEvent)
1889 {
1890 m_DeferredEvent = new DeferredForceSwapEntities(mode, item1, item2, dst1, dst2);
1891 if (m_DeferredEvent.ReserveInventory(this))
1892 return true;
1893 }
1894
1895 m_DeferredEvent = null;
1896 return false;
1897 }
1898
1899 void HandleSwapEntities( DeferredEvent deferred_event )
1900 {
1901 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
1902 if( deferred_swap_entities )
1903 {
1904 deferred_swap_entities.ClearInventoryReservation(this);
1905 InventoryLocation src1, src2, dst1, dst2;
1906 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
1907 {
1909 {
1910 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));
1911 }
1912
1913 switch (deferred_swap_entities.m_mode)
1914 {
1915 case InventoryMode.PREDICTIVE:
1916 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1917 {
1918 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1919 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1920 }
1921 else
1922 {
1923 #ifdef ENABLE_LOGGING
1925 {
1926 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() );
1927 }
1928 #endif
1929 }
1930 break;
1931
1932 case InventoryMode.JUNCTURE:
1933 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1934 {
1935 DayZPlayer player = GetGame().GetPlayer();
1936 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1937 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1938 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
1939 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
1940 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1941 }
1942 else
1943 {
1944 #ifdef ENABLE_LOGGING
1946 {
1947 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() );
1948 }
1949 #endif
1950 }
1951 break;
1952
1953 case InventoryMode.LOCAL:
1954 break;
1955
1956 default:
1957 Error("SwapEntities - HandEvent - Invalid mode");
1958 }
1959 }
1960 else
1961 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1962 }
1963 }
1964
1965 override bool ForceSwapEntities (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
1966 {
1967 #ifdef ENABLE_LOGGING
1969 {
1970 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
1971 }
1972 #endif
1973
1974 InventoryLocation src1, src2, dst1;
1975 if( mode == InventoryMode.LOCAL )
1976 {
1977 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
1978 {
1979 LocationSwap(src1, src2, dst1, item2_dst);
1980 return true;
1981 }
1982
1983 }
1984
1985 if(!super.ForceSwapEntities(mode,item1,item2,item2_dst))
1986 {
1987 if (GameInventory.MakeSrcAndDstForForceSwap(item1, item2, src1, src2, dst1, item2_dst))
1988 {
1989 return PostDeferredForceSwapEntities(mode, item1, item2, dst1, item2_dst);
1990 }
1991 }
1992
1993 return true;
1994 }
1995
1997 {
1998 DeferredForceSwapEntities deferred_force_swap_entities = DeferredForceSwapEntities.Cast(deferred_event);
1999 if (deferred_force_swap_entities)
2000 {
2001 deferred_force_swap_entities.ClearInventoryReservation(this);
2004 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
2005 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
2006
2007 DayZPlayer player = GetGame().GetPlayer();
2008
2010 {
2011 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));
2012 }
2013
2014 switch (deferred_force_swap_entities.m_mode)
2015 {
2016 case InventoryMode.PREDICTIVE:
2017 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))
2018 {
2019 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2020 LocationSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2021 }
2022 else
2023 {
2024 #ifdef ENABLE_LOGGING
2026 {
2027 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());
2028 }
2029 #endif
2030 }
2031 break;
2032
2033 case InventoryMode.JUNCTURE:
2034 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))
2035 {
2036 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2037 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2038
2039 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2);
2040 }
2041 else
2042 {
2043 #ifdef ENABLE_LOGGING
2045 {
2046 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());
2047 }
2048 #endif
2049 }
2050 break;
2051
2052 case InventoryMode.LOCAL:
2053 break;
2054
2055 default:
2056 Error("ForceSwapEntities - HandEvent - Invalid mode");
2057 }
2058 }
2059 }
2060
2062 {
2063 if (GetGame().IsServer())
2064 {
2065 if (e.IsServerSideOnly())
2066 {
2067 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
2068 }
2069
2070 if (player.IsAlive())
2071 {
2072 InventoryLocation dst = e.GetDst();
2073 InventoryLocation src = e.GetSrc();
2074 if (src.IsValid() && dst.IsValid())
2075 {
2076 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
2077 {
2078#ifdef ENABLE_LOGGING
2080 {
2081 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
2082 }
2083#endif
2084
2085 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
2086 {
2087#ifdef ENABLE_LOGGING
2089 {
2090 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
2091 }
2092#endif
2093 }
2094 else
2095 {
2096#ifdef ENABLE_LOGGING
2098 {
2099 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
2100 }
2101#endif
2102 }
2103 }
2104
2105#ifdef ENABLE_LOGGING
2107 {
2108 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));
2109 }
2110#endif
2111
2114 player.SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY, ctx);
2115
2116#ifdef ENABLE_LOGGING
2118 {
2119 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));
2120 }
2121#endif
2122
2124 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
2125 }
2126 }
2127 else
2128 {
2129 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
2130 }
2131 }
2132 }
2133
2137 override void NetSyncCurrentStateID (int id)
2138 {
2139 super.NetSyncCurrentStateID(id);
2140
2141 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
2142 }
2143
2150 override void OnAfterStoreLoad ()
2151 {
2152 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
2153 }
2154
2159 {
2160 if (GetEntityInHands())
2161 {
2162 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
2163 if (wpn)
2164 {
2166
2168 if (pb && e)
2169 {
2170 pb.GetWeaponManager().SetRunning(true);
2171
2173 {
2174 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
2175 }
2176
2177 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
2178 {
2179 wpn.ProcessWeaponAbortEvent(e);
2180 }
2181 else
2182 {
2183 wpn.ProcessWeaponEvent(e);
2184 }
2185 pb.GetWeaponManager().SetRunning(false);
2186 }
2187 }
2188 else
2189 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
2190 }
2191 else
2192 Error("OnEventForRemoteWeapon - no entity in hands");
2193 return true;
2194 }
2195
2196
2201 {
2202 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
2203 if (e)
2204 {
2206 {
2207 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
2208 }
2209
2210 //m_FSM.ProcessEvent(e);
2211
2212 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
2213 {
2215 m_FSM.ProcessAbortEvent(e, aa);
2216 }
2217 else
2218 {
2219 m_FSM.ProcessEvent(e);
2220 }
2221
2222 return true;
2223 }
2224 return false;
2225 }
2226
2228 {
2230 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
2231 {
2233
2235 e.WriteToContext(ctx);
2236
2238 {
2239 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
2240 }
2241
2242 p.StoreInputForRemotes(ctx);
2243 }
2244 }
2245
2247 {
2248 super.OnHandsExitedStableState(src, dst);
2249
2251 {
2252 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
2253 }
2254 }
2255
2257 {
2258 super.OnHandsEnteredStableState(src, dst);
2259
2261 {
2262 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
2263 }
2264 }
2265
2267 {
2268 super.OnHandsStateChanged(src, dst);
2269
2271 {
2272 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
2273 }
2274
2275 if (src.IsIdle())
2276 OnHandsExitedStableState(src, dst);
2277
2278 if (dst.IsIdle())
2279 OnHandsEnteredStableState(src, dst);
2280
2281#ifdef DIAG_DEVELOPER
2283 if (p && p.m_Bot)
2284 {
2285 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
2286 }
2287#endif
2288 }
2289
2291 {
2292 if (!IsProcessing())
2293 {
2294 EntityAI itemInHands = GetEntityInHands();
2295
2296 InventoryLocation handInventoryLocation();
2297 handInventoryLocation.SetHands(GetInventoryOwner(), itemInHands);
2298
2299 InventoryValidation validation();
2300 if (e.CanPerformEventEx(validation))
2301 {
2302 m_DeferredEvent = new DeferredHandEvent(mode, e);
2303 if (m_DeferredEvent.ReserveInventory(this))
2304 {
2305 return true;
2306 }
2307 }
2308
2309 m_DeferredEvent = null;
2310
2312 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
2313 {
2315 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
2316 }
2317 else
2318 {
2319 ScriptInputUserData serializer();
2320
2322 serializer.Write(validation.m_Reason);
2323
2324 GetDayZPlayerOwner().SendSyncJuncture(DayZPlayerSyncJunctures.SJ_INVENTORY_FAILURE, serializer);
2325 }
2326 }
2327
2328 return false;
2329 }
2330
2331
2332 void HandleHandEvent(DeferredEvent deferred_event)
2333 {
2335 InventoryValidation validation();
2336
2337 DeferredHandEvent deferred_hand_event = DeferredHandEvent.Cast(deferred_event);
2338 if (deferred_hand_event)
2339 {
2340 #ifdef ENABLE_LOGGING
2342 {
2343 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2344 }
2345 #endif
2346
2348 {
2349 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2350 }
2351
2352 switch (deferred_hand_event.m_mode)
2353 {
2354 case InventoryMode.PREDICTIVE:
2355 #ifdef ENABLE_LOGGING
2357 {
2358 Debug.InventoryHFSMLog("PREDICTIVE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2359 }
2360 #endif
2361
2362 deferred_hand_event.ClearInventoryReservation(this);
2363 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2364 {
2366 ProcessHandEvent(deferred_hand_event.m_event);
2367 }
2368 break;
2369
2370 case InventoryMode.JUNCTURE:
2371 #ifdef ENABLE_LOGGING
2373 {
2374 Debug.InventoryHFSMLog("JUNCTURE", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2375 }
2376 #endif
2377
2378 deferred_hand_event.ClearInventoryReservation(this);
2379 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2380 {
2381 deferred_hand_event.ReserveInventory(this);
2383
2384 //Functionality to prevent desync when two players perform interfering action at the same time
2385 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2386 EntityAI itemDst = null;
2387 if (deferred_hand_event.m_event.GetDst())
2388 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2389 if (itemSrc)
2390 EnableMovableOverride(itemSrc);
2391 if (itemDst)
2392 EnableMovableOverride(itemDst);
2393 }
2394 break;
2395
2396 case InventoryMode.LOCAL:
2397 #ifdef ENABLE_LOGGING
2399 {
2400 Debug.InventoryHFSMLog("LOCAL", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2401 }
2402 #endif
2403
2404 deferred_hand_event.ClearInventoryReservation(this);
2405 ProcessHandEvent(deferred_hand_event.m_event);
2406 //PostHandEvent(deferred_hand_event.m_event);
2407 break;
2408
2409 case InventoryMode.SERVER:
2410 #ifdef ENABLE_LOGGING
2412 {
2413 Debug.InventoryHFSMLog("SERVER", "n/a" , "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2414 }
2415
2417 {
2418 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2419 }
2420 #endif
2421
2422 if (!deferred_hand_event.m_event.IsServerSideOnly())
2423 {
2424 if (GetDayZPlayerOwner().IsAlive())
2425 {
2427 }
2428 else
2429 {
2431 }
2432 }
2433 else
2434 {
2435 ProcessHandEvent(deferred_hand_event.m_event);
2436 }
2437 break;
2438
2439 default:
2440 Error("HumanInventory::HandEvent - Invalid mode");
2441 }
2442 }
2443 }
2444
2446 {
2447 super.HandleInventoryManipulation();
2449 {
2454
2455 m_DeferredEvent = null;
2456 }
2457 }
2458
2459
2460
2462 {
2463 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2464 }
2465
2466 bool PlayerCheckRequestSrc ( notnull InventoryLocation src, float radius )
2467 {
2468 bool result = true;
2469
2470 EntityAI ent = src.GetParent();
2471 if ( ent )
2472 {
2473 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2474 if (player)
2475 {
2476 if ( GetDayZPlayerOwner() != player )
2477 {
2478 if (player.IsAlive())
2479 {
2480 if (!player.IsRestrained() && !player.IsUnconscious())
2481 {
2482 return false;
2483 }
2484 }
2485 }
2486 }
2487 }
2488
2489 if ( result )
2490 {
2491 result = CheckRequestSrc( GetManOwner(), src, radius);
2492 }
2493
2494 return result;
2495 }
2496
2497 bool PlayerCheckRequestDst ( notnull InventoryLocation src, notnull InventoryLocation dst, float radius )
2498 {
2499 bool result = true;
2500
2501 EntityAI ent = dst.GetParent();
2502 if ( ent )
2503 {
2504 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2505 if (player)
2506 {
2507 if ( GetDayZPlayerOwner() != player )
2508 {
2509 if (player.IsAlive())
2510 {
2511 if (!player.IsRestrained() && !player.IsUnconscious())
2512 {
2513 return false;
2514 }
2515 }
2516 }
2517 }
2518 }
2519
2520 if ( result )
2521 {
2522 result = CheckMoveToDstRequest( GetManOwner(), src, dst, radius);
2523 }
2524
2525 return result;
2526 }
2527
2528 bool PlayerCheckSwapItemsRequest( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
2529 {
2530 bool result = true;
2531
2532 EntityAI ent = dst1.GetParent();
2533 PlayerBase player;
2534 if ( ent )
2535 {
2536 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2537 if (player)
2538 {
2539 if ( GetDayZPlayerOwner() != player )
2540 {
2541 if (player.IsAlive())
2542 {
2543 if (!player.IsRestrained() && !player.IsUnconscious())
2544 {
2545 return false;
2546 }
2547 }
2548 }
2549 }
2550 }
2551
2552 ent = dst2.GetParent();
2553 if ( ent )
2554 {
2555 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2556 if (player)
2557 {
2558 if ( GetDayZPlayerOwner() != player )
2559 {
2560 if (player.IsAlive())
2561 {
2562 if (!player.IsRestrained() && !player.IsUnconscious())
2563 {
2564 return false;
2565 }
2566 }
2567 }
2568 }
2569 }
2570
2571
2572 if ( result )
2573 {
2574 result = CheckSwapItemsRequest( GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2575 }
2576
2577 return result;
2578
2579 }
2580
2581 bool PlayerCheckDropRequest ( notnull InventoryLocation src, float radius )
2582 {
2583 bool result = true;
2584
2585 EntityAI ent = src.GetParent();
2586 if ( ent )
2587 {
2588 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2589 if (player)
2590 {
2591 if ( GetDayZPlayerOwner() != player )
2592 {
2593 if (player.IsAlive())
2594 {
2595 if (!player.IsRestrained() && !player.IsUnconscious())
2596 {
2597 return false;
2598 }
2599 }
2600 }
2601 }
2602 }
2603
2604 if ( result )
2605 {
2606 result = CheckDropRequest( GetManOwner(), src, radius);
2607 }
2608
2609 return result;
2610 }
2611
2614 {
2615 if (dst.GetType() == InventoryLocationType.ATTACHMENT)
2616 {
2617 return dst.GetParent().CheckAttachmentReceiveExclusion(src.GetItem(),dst.GetSlot());
2618 }
2619
2620 return true;
2621 }
2622
2624 bool SwapCheckExclusionMaskLocal ( notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
2625 {
2626 bool failed = false;
2627
2628 if (dst1.GetType() == InventoryLocationType.ATTACHMENT)
2629 {
2630 failed |= !dst1.GetParent().CheckAttachmentReceiveExclusion(dst1.GetItem(),dst1.GetSlot());
2631 }
2632
2633 if (dst2.GetType() == InventoryLocationType.ATTACHMENT)
2634 {
2635 failed |= !dst2.GetParent().CheckAttachmentReceiveExclusion(dst2.GetItem(),dst2.GetSlot());
2636 }
2637 return !failed;
2638 }
2639
2642 {
2644
2645 if (validation.m_IsJuncture)
2646 {
2653
2654 return true;
2655 }
2656
2658 src.ReadFromContext(ctx);
2659
2660 #ifdef ENABLE_LOGGING
2662 {
2663 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2664 }
2665 #endif
2666
2667 if (validation.m_IsRemote && !src.GetItem())
2668 {
2669 #ifdef ENABLE_LOGGING
2671 {
2672 Debug.InventoryMoveLog("Failed item not exist", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2673 }
2674 #endif
2675
2676 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
2677 return true;
2678 }
2679
2684 {
2685 #ifdef ENABLE_LOGGING
2687 {
2688 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2689 }
2690 #endif
2691
2692 return true;
2693 }
2694
2699 {
2700 #ifdef ENABLE_LOGGING
2702 {
2703 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2704 }
2705 #endif
2706
2707 return true;
2708 }
2709
2710 #ifdef ENABLE_LOGGING
2712 {
2713 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
2714 }
2715 #endif
2716
2717 GetGame().ObjectDelete(src.GetItem());
2718
2719 validation.m_Result = InventoryValidationResult.SUCCESS;
2720 return true;
2721 }
2722}
void syncDebugPrint(string s)
Определения Debug.c:1
void inventoryDebugPrint(string s)
Определения Debug.c:19
InventoryCommandType
Определения Inventory.c:3
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
InventoryValidationResult
Определения Inventory.c:30
InventoryValidationReason
Определения Inventory.c:37
const int INPUT_UDT_INVENTORY
Определения _constants.c:9
const int INPUT_UDT_HAND_REMOTE_EVENT
Определения _constants.c:14
void wpnDebugSpamALot(string s)
Определения Debug.c:25
void wpnDebugPrint(string s)
Определения Debug.c:9
override Widget Init()
Определения DayZGame.c:127
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2581
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:1617
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:2624
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
Определения DayZPlayerInventory.c:1520
ref HandAnimatedForceSwapping m_FSwapping
Определения DayZPlayerInventory.c:161
m_DeferredEvent
void HandleHandEvent(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:2332
bool IsProcessing()
Определения DayZPlayerInventory.c:2461
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:2227
void HandleTakeToDst(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:1762
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:2641
bool MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:2613
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1625
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2466
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:2137
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2256
bool IsServerOrLocalPlayer()
Определения DayZPlayerInventory.c:1632
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:1655
override void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:581
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1610
ref HandEventBase m_DeferredPostedHandEvent
Определения DayZPlayerInventory.c:155
override void HandleInventoryManipulation()
Определения DayZPlayerInventory.c:2445
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:1854
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:2246
override void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
Определения DayZPlayerInventory.c:2266
override bool PostDeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения DayZPlayerInventory.c:1883
bool OnHandEventForRemote(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:2200
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:1965
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
Определения DayZPlayerInventory.c:1229
void HandleSwapEntities(DeferredEvent deferred_event)
Определения DayZPlayerInventory.c:1899
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:2528
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:1996
ref Timer m_DeferredWeaponTimer
Определения DayZPlayerInventory.c:151
override bool PostDeferredEventTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:1746
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:2497
bool OnEventForRemoteWeapon(ParamsReadContext ctx)
Определения DayZPlayerInventory.c:2158
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:2290
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:2061
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Определения EmoteManager.c:500
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
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:794
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)
Определения 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:955
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)
Определения 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)
Определения Debug.c:137
Определения 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
Определения Building.c:6
bool ClearInventoryReservationEx(EntityAI item, InventoryLocation dst)
Определения Inventory.c:762
const int c_InventoryReservationTimeoutShortMS
Определения Inventory.c:713
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
Определения Inventory.c:1209
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
Определения Inventory.c:1221
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
Определения Inventory.c:712
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Inventory.c:378
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)
Определения Inventory.c:664
const float c_MaxItemDistanceRadius
anti-cheats
Определения Inventory.c:813
bool AddInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
Определения Inventory.c:716
script counterpart to engine's class Inventory
Определения Inventory.c:79
override InventoryLocation GetDst()
Определения Hand_Events.c:212
override bool AcquireInventoryJunctureFromServer(notnull Man player)
Определения Hand_Events.c:257
override EntityAI GetSecondSrcEntity()
Определения Hand_Events.c:574
override bool IsServerSideOnly()
Определения Hand_Events.c:718
override string DumpToString()
Определения Hand_Events.c:332
override void ClearInventoryReservation()
Определения Hand_Events.c:671
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:679
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:994
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
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:296
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
bool m_IsJuncture
Определения Inventory.c:45
InventoryValidationResult m_Result
Определения Inventory.c:48
InventoryValidationReason m_Reason
Определения Inventory.c:49
bool m_IsRemote
Определения Inventory.c:46
Определения Inventory.c:44
Определения InventoryItem.c:731
static bool IsWeaponLogEnable()
Определения Debug.c:718
static bool IsSyncLogEnable()
Определения Debug.c:678
static bool IsInventoryHFSMLogEnable()
Определения Debug.c:668
static bool IsInventoryMoveLogEnable()
Определения Debug.c:648
Определения 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:963
string WeaponActionTypeToString(int A, int AT)
Определения human.c:943