Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
junctures.c
Go to the documentation of this file.
1 
2 bool TryAcquireInventoryJunctureFromServer (notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
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  {
8  return JunctureRequestResult.JUNCTURE_DENIED;
9  }
10  bool test_dst_occupancy = true;
11  if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, test_dst_occupancy, GameInventory.c_InventoryReservationTimeoutMS))
12  {
13  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture needed and acquired, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
14  return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok
15  }
16  else
17  {
18  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture request DENIED, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
19  return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
20  }
21  }
22  else
23  {
24  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture not required, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
25  return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
26  }
27 }
28 
29 bool TryAcquireTwoInventoryJuncturesFromServer (notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
30 {
31  #ifdef DEVELOPER
32  if ( LogManager.IsInventoryReservationLogEnable() )
33  {
34  Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp() + " src1:" + src1.DumpToString() + " dst1: " + dst1.DumpToString()+ " src2:" + src2.DumpToString() + " dst2: " + dst2.DumpToString(), "InventoryJuncture" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer",player.ToString() );
35  }
36  #endif
37 
38  //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));
39 
40  bool need_j1 = player.NeedInventoryJunctureFromServer(src1.GetItem(), src1.GetParent(), dst1.GetParent());
41  bool need_j2 = player.NeedInventoryJunctureFromServer(src2.GetItem(), src2.GetParent(), dst2.GetParent());
42  if (need_j1 || need_j2)
43  {
44  if (need_j1)
45  {
46  if ( ( src1.GetItem() && src1.GetItem().IsSetForDeletion() ) || ( src1.GetParent() && src1.GetParent().IsSetForDeletion() ) || ( dst1.GetParent() && dst1.GetParent().IsSetForDeletion() ) )
47  {
48  return JunctureRequestResult.JUNCTURE_DENIED;
49  }
50  if (!GetGame().AddInventoryJunctureEx(player, src1.GetItem(), dst1, false, GameInventory.c_InventoryReservationTimeoutMS))
51  {
52  /*#ifdef DEVELOPER
53  if ( LogManager.IsInventoryReservationLogEnable() )
54  {
55  Debug.InventoryMoveLog("", "SWAP" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer", player.ToString() );
56  }
57  #endif*/
58  return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
59  }
60  }
61 //Need add log and change chanel to print
62  if (need_j2)
63  {
64  if ( ( src2.GetItem() && src2.GetItem().IsSetForDeletion() ) || ( src2.GetParent() && src2.GetParent().IsSetForDeletion() ) || ( dst2.GetParent() && dst2.GetParent().IsSetForDeletion() ) )
65  {
66  if (need_j1)
67  {
68  GetGame().ClearJunctureEx(player, src1.GetItem()); // release already acquired juncture for item1
69  }
70  return JunctureRequestResult.JUNCTURE_DENIED;
71  }
72  if (!GetGame().AddInventoryJunctureEx(player, src2.GetItem(), dst2, false, GameInventory.c_InventoryReservationTimeoutMS))
73  {
74  //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));
75  if (need_j1)
76  {
77  GetGame().ClearJunctureEx(player, src1.GetItem()); // release already acquired juncture for item1
78  //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));
79  }
80  return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
81  }
82  }
83 
84  return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok, both junctures acquired
85  }
86  else
87  {
88  #ifdef DEVELOPER
89  if ( LogManager.IsInventoryReservationLogEnable() )
90  {
91  Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", player.ToString() );
92  }
93  #endif
94  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));
95  return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
96  }
97 }
98 
GetGame
proto native CGame GetGame()
LogManager
Definition: debug.c:734
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
TryAcquireTwoInventoryJuncturesFromServer
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition: junctures.c:29
JunctureRequestResult
JunctureRequestResult
Definition: hand_events.c:27
Object
Definition: objecttyped.c:1
Debug
Definition: debug.c:13
syncDebugPrint
void syncDebugPrint(string s)
Definition: debug.c:1
TryAcquireInventoryJunctureFromServer
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition: junctures.c:2
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78