DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Junctures.c
См. документацию.
1
2bool TryAcquireInventoryJunctureFromServer (notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
3{
4 #ifdef ENABLE_LOGGING
6 {
7 Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp() + " src:" + src.DumpToString() + " dst: " + dst.DumpToString(), "InventoryJuncture" , "n/a", "TryAcquireInventoryJunctureFromServer",player.ToString() );
8 }
9 #endif
10
11 if (!src.GetItem())
12 {
13 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] missing src item, junction cannot be tested, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src));
14 return JunctureRequestResult.ERROR;
15 }
16
17 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
18 {
19 if ( ( src.GetItem() && src.GetItem().IsSetForDeletion() ) || ( src.GetParent() && src.GetParent().IsSetForDeletion() ) || ( dst.GetParent() && dst.GetParent().IsSetForDeletion() ) )
20 {
21 return JunctureRequestResult.JUNCTURE_DENIED;
22 }
23
24 if (src.GetItem() && !src.GetItem().CanPutIntoHands(player))
25 {
26 return JunctureRequestResult.JUNCTURE_DENIED;
27 }
28
29 bool test_dst_occupancy = true;
30 if (g_Game.AddInventoryJunctureEx(player, src.GetItem(), dst, test_dst_occupancy, GameInventory.c_InventoryReservationTimeoutMS))
31 {
32 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture needed and acquired, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
33 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok
34 }
35 else
36 {
37 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture request DENIED, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
38 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
39 }
40 }
41 else
42 {
43 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] juncture not required, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
44 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
45 }
46}
47
48bool TryAcquireTwoInventoryJuncturesFromServer (notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
49{
50 #ifdef ENABLE_LOGGING
52 {
53 Debug.InventoryReservationLog("STS = " + player.GetSimulationTimeStamp() + " src1:" + src1.DumpToString() + " dst1: " + dst1.DumpToString()+ " src2:" + src2.DumpToString() + " dst2: " + dst2.DumpToString(), "InventoryJuncture" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer",player.ToString() );
54 }
55 #endif
56
57 //if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms TryAcquireTwoInventoryJuncturesFromServer src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
58
59 EntityAI srcItem1 = src1.GetItem();
60 EntityAI srcItem2 = src2.GetItem();
61 EntityAI srcParent1 = src1.GetParent();
62 EntityAI srcParent2 = src2.GetParent();
63 EntityAI dstParent1 = dst1.GetParent();
64 EntityAI dstParent2 = dst2.GetParent();
65
66 if (!srcItem1)
67 {
68 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] missing src1 item1, junction cannot be tested, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
69 return JunctureRequestResult.ERROR;
70 }
71
72 if (!srcItem2)
73 {
74 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] missing src1 item2, junction cannot be tested, player=" + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
75 return JunctureRequestResult.ERROR;
76 }
77
78
79 bool need_j1 = player.NeedInventoryJunctureFromServer(srcItem1, srcParent1, dstParent1);
80 bool need_j2 = player.NeedInventoryJunctureFromServer(srcItem2, srcParent2, dstParent2);
81 if (need_j1 || need_j2)
82 {
83 if (need_j1)
84 {
85 if ( ( srcItem1 && srcItem1.IsSetForDeletion() ) || ( srcParent1 && srcParent1.IsSetForDeletion() ) || ( dstParent1 && dstParent1.IsSetForDeletion() ) )
86 {
87 return JunctureRequestResult.JUNCTURE_DENIED;
88 }
89
90
91 if (srcItem1 && !srcItem1.CanPutIntoHands(player))
92 {
93 return JunctureRequestResult.JUNCTURE_DENIED;
94 }
95
96 if (!g_Game.AddInventoryJunctureEx(player, srcItem1, dst1, false, GameInventory.c_InventoryReservationTimeoutMS))
97 {
98 /*#ifdef ENABLE_LOGGING
99 if ( LogManager.IsInventoryReservationLogEnable() )
100 {
101 Debug.InventoryMoveLog("", "SWAP" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer", player.ToString() );
102 }
103 #endif*/
104 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
105 }
106 }
107//Need add log and change chanel to print
108 if (need_j2)
109 {
110 if ( ( srcItem2 && srcItem2.IsSetForDeletion() ) || ( srcParent2 && srcParent2.IsSetForDeletion() ) || ( dstParent2 && dstParent2.IsSetForDeletion() ) )
111 {
112 if (need_j1)
113 {
114 g_Game.ClearJunctureEx(player, srcItem1); // release already acquired juncture for item1
115 }
116 return JunctureRequestResult.JUNCTURE_DENIED;
117 }
118
119 if (srcItem2 && !srcItem2.CanPutIntoHands(player))
120 {
121 if (need_j1)
122 {
123 g_Game.ClearJunctureEx(player, srcItem1); // release already acquired juncture for item1
124 }
125 return JunctureRequestResult.JUNCTURE_DENIED;
126 }
127
128 if (!g_Game.AddInventoryJunctureEx(player, srcItem2, dst2, false, GameInventory.c_InventoryReservationTimeoutMS))
129 {
130 //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));
131 if (need_j1)
132 {
133 g_Game.ClearJunctureEx(player, srcItem1); // release already acquired juncture for item1
134 //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));
135 }
136 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
137 }
138 }
139
140 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok, both junctures acquired
141 }
142 else
143 {
144 /*#ifdef ENABLE_LOGGING
145 if ( LogManager.IsInventoryReservationLogEnable() )
146 {
147 Debug.InventoryReservationLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", player.ToString() );
148 }
149 #endif*/
150 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));
151 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
152 }
153}
154
void syncDebugPrint(string s)
DayZGame g_Game
Определения DayZGame.c:4074
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:48
static void InventoryReservationLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:203
Определения 3_Game/DayZ/tools/Debug.c:2
bool NeedInventoryJunctureFromServer(notnull EntityAI item, EntityAI currParent, EntityAI newParent)
Определения 3_Game/DayZ/Entities/Man.c:170
const int c_InventoryReservationTimeoutMS
reservations
script counterpart to engine's class Inventory
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:233
InventoryLocation.
Определения InventoryLocation.c:30
static bool IsInventoryReservationLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:769
static bool IsSyncLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:789
Определения ObjectTyped.c:2