DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Junctures.c
См. документацию.
1
2bool 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
11 if (src.GetItem() && !src.GetItem().CanPutIntoHands(player))
12 {
13 return JunctureRequestResult.JUNCTURE_DENIED;
14 }
15
16 bool test_dst_occupancy = true;
17 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, test_dst_occupancy, GameInventory.c_InventoryReservationTimeoutMS))
18 {
19 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture needed and acquired, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
20 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok
21 }
22 else
23 {
24 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture request DENIED, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
25 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
26 }
27 }
28 else
29 {
30 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture not required, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
31 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
32 }
33}
34
35bool TryAcquireTwoInventoryJuncturesFromServer (notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
36{
37 #ifdef ENABLE_LOGGING
39 {
40 Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp() + " src1:" + src1.DumpToString() + " dst1: " + dst1.DumpToString()+ " src2:" + src2.DumpToString() + " dst2: " + dst2.DumpToString(), "InventoryJuncture" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer",player.ToString() );
41 }
42 #endif
43
44 //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));
45
46 bool need_j1 = player.NeedInventoryJunctureFromServer(src1.GetItem(), src1.GetParent(), dst1.GetParent());
47 bool need_j2 = player.NeedInventoryJunctureFromServer(src2.GetItem(), src2.GetParent(), dst2.GetParent());
48 if (need_j1 || need_j2)
49 {
50 if (need_j1)
51 {
52 if ( ( src1.GetItem() && src1.GetItem().IsSetForDeletion() ) || ( src1.GetParent() && src1.GetParent().IsSetForDeletion() ) || ( dst1.GetParent() && dst1.GetParent().IsSetForDeletion() ) )
53 {
54 return JunctureRequestResult.JUNCTURE_DENIED;
55 }
56
57
58 if (src1.GetItem() && !src1.GetItem().CanPutIntoHands(player))
59 {
60 return JunctureRequestResult.JUNCTURE_DENIED;
61 }
62
63 if (!GetGame().AddInventoryJunctureEx(player, src1.GetItem(), dst1, false, GameInventory.c_InventoryReservationTimeoutMS))
64 {
65 /*#ifdef ENABLE_LOGGING
66 if ( LogManager.IsInventoryReservationLogEnable() )
67 {
68 Debug.InventoryMoveLog("", "SWAP" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer", player.ToString() );
69 }
70 #endif*/
71 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
72 }
73 }
74//Need add log and change chanel to print
75 if (need_j2)
76 {
77 if ( ( src2.GetItem() && src2.GetItem().IsSetForDeletion() ) || ( src2.GetParent() && src2.GetParent().IsSetForDeletion() ) || ( dst2.GetParent() && dst2.GetParent().IsSetForDeletion() ) )
78 {
79 if (need_j1)
80 {
81 GetGame().ClearJunctureEx(player, src1.GetItem()); // release already acquired juncture for item1
82 }
83 return JunctureRequestResult.JUNCTURE_DENIED;
84 }
85
86 if (src2.GetItem() && !src2.GetItem().CanPutIntoHands(player))
87 {
88 return JunctureRequestResult.JUNCTURE_DENIED;
89 }
90
91 if (!GetGame().AddInventoryJunctureEx(player, src2.GetItem(), dst2, false, GameInventory.c_InventoryReservationTimeoutMS))
92 {
93 //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));
94 if (need_j1)
95 {
96 GetGame().ClearJunctureEx(player, src1.GetItem()); // release already acquired juncture for item1
97 //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));
98 }
99 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
100 }
101 }
102
103 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok, both junctures acquired
104 }
105 else
106 {
107 #ifdef ENABLE_LOGGING
109 {
110 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", player.ToString() );
111 }
112 #endif
113 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));
114 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
115 }
116}
117
void syncDebugPrint(string s)
Определения Debug.c:1
JunctureRequestResult
Определения Hand_Events.c:28
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
bool ClearJunctureEx(Man player, notnull EntityAI item)
Определения Game.c:762
static void InventoryReservationLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения Debug.c:142
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
const int c_InventoryReservationTimeoutMS
reservations
Определения Inventory.c:712
script counterpart to engine's class Inventory
Определения Inventory.c:79
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
InventoryLocation.
Определения InventoryLocation.c:29
static bool IsInventoryReservationLogEnable()
Определения Debug.c:658
static bool IsSyncLogEnable()
Определения Debug.c:678
Определения Debug.c:594
Определения ObjectTyped.c:2
proto native CGame GetGame()