DayZ 1.24
Loading...
Searching...
No Matches
Junctures.c File Reference

Go to the source code of this file.

Functions

bool TryAcquireInventoryJunctureFromServer (notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
 
bool TryAcquireTwoInventoryJuncturesFromServer (notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 

Function Documentation

◆ TryAcquireInventoryJunctureFromServer()

bool TryAcquireInventoryJunctureFromServer ( notnull Man player,
notnull InventoryLocation src,
notnull InventoryLocation dst )

Definition at line 2 of file Junctures.c.

3{
4 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
5 {
6 if ((src.GetItem() && src.GetItem().IsSetForDeletion()) || (src.GetParent() && src.GetParent().IsSetForDeletion()) || (dst.GetParent() && dst.GetParent().IsSetForDeletion()))
7 return JunctureRequestResult.JUNCTURE_DENIED;
8 bool test_dst_occupancy = true;
9 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, test_dst_occupancy, GameInventory.c_InventoryReservationTimeoutMS))
10 {
11 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture needed and acquired, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
12 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok
13 }
14 else
15 {
16 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture request DENIED, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
17 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
18 }
19 }
20 else
21 {
22 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture not required, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
23 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
24 }
25}
void syncDebugPrint(string s)
Definition Debug.c:1
JunctureRequestResult
Definition Hand_Events.c:28
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
static bool IsSyncLogEnable()
Definition Debug.c:759
proto native CGame GetGame()

References GameInventory::c_InventoryReservationTimeoutMS, InventoryLocation::DumpToStringNullSafe(), GetGame(), LogManager::IsSyncLogEnable(), and syncDebugPrint().

Referenced by HandEventBase::AcquireInventoryJunctureFromServer(), and ValidateSyncMove().

◆ TryAcquireTwoInventoryJuncturesFromServer()

bool TryAcquireTwoInventoryJuncturesFromServer ( notnull Man player,
notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2 )

Definition at line 27 of file Junctures.c.

28{
29#ifdef DEVELOPER
31 Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp() + " src1:" + src1.DumpToString() + " dst1: " + dst1.DumpToString() + " src2:" + src2.DumpToString() + " dst2: " + dst2.DumpToString(), "InventoryJuncture", "n/a", "TryAcquireTwoInventoryJuncturesFromServer", player.ToString());
32#endif
33
34 //if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms TryAcquireTwoInventoryJuncturesFromServer src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
35
36 bool need_j1 = player.NeedInventoryJunctureFromServer(src1.GetItem(), src1.GetParent(), dst1.GetParent());
37 bool need_j2 = player.NeedInventoryJunctureFromServer(src2.GetItem(), src2.GetParent(), dst2.GetParent());
38 if (need_j1 || need_j2)
39 {
40 if (need_j1)
41 {
42 if ((src1.GetItem() && src1.GetItem().IsSetForDeletion()) || (src1.GetParent() && src1.GetParent().IsSetForDeletion()) || (dst1.GetParent() && dst1.GetParent().IsSetForDeletion()))
43 return JunctureRequestResult.JUNCTURE_DENIED;
44 if (!GetGame().AddInventoryJunctureEx(player, src1.GetItem(), dst1, false, GameInventory.c_InventoryReservationTimeoutMS))
45 {
46 /*#ifdef DEVELOPER
47 if ( LogManager.IsInventoryReservationLogEnable() )
48 {
49 Debug.InventoryMoveLog("", "SWAP" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer", player.ToString() );
50 }
51 #endif*/
52 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
53 }
54 }
55 //Need add log and change chanel to print
56 if (need_j2)
57 {
58 if ((src2.GetItem() && src2.GetItem().IsSetForDeletion()) || (src2.GetParent() && src2.GetParent().IsSetForDeletion()) || (dst2.GetParent() && dst2.GetParent().IsSetForDeletion()))
59 {
60 if (need_j1)
61 {
62 GetGame().ClearJunctureEx(player, src1.GetItem()); // release already acquired juncture for item1
63 }
64 return JunctureRequestResult.JUNCTURE_DENIED;
65 }
66 if (!GetGame().AddInventoryJunctureEx(player, src2.GetItem(), dst2, false, GameInventory.c_InventoryReservationTimeoutMS))
67 {
68 //if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] item2 juncture request DENIED, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
69 if (need_j1)
70 {
71 GetGame().ClearJunctureEx(player, src1.GetItem()); // release already acquired juncture for item1
72 //if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] item2 juncture request DENIED, cleaning acquired juncture for item1, , player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
73 }
74 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
75 }
76 }
77
78 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok, both junctures acquired
79 }
80 else
81 {
82#ifdef DEVELOPER
84 Debug.InventoryMoveLog("Remote - skipped", "SWAP", "n/a", "ProcessInputData", player.ToString());
85#endif
86 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] junctures not required, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
87 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
88 }
89}
Definition Debug.c:14
static void InventoryReservationLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:173
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:163
static bool IsInventoryReservationLogEnable()
Definition Debug.c:739

References GameInventory::c_InventoryReservationTimeoutMS, InventoryLocation::DumpToStringNullSafe(), GetGame(), Debug::InventoryMoveLog(), Debug::InventoryReservationLog(), LogManager::IsInventoryReservationLogEnable(), LogManager::IsSyncLogEnable(), and syncDebugPrint().

Referenced by HandEventBase::AcquireInventoryJunctureFromServer(), and ValidateSwap().