DayZ 1.29
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 (g_Game.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=" + g_Game.GetTime() + "ms TryAcquireTwoInventoryJuncturesFromServer src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
45
46 EntityAI srcItem1 = src1.GetItem();
47 EntityAI srcItem2 = src2.GetItem();
48 EntityAI srcParent1 = src1.GetParent();
49 EntityAI srcParent2 = src2.GetParent();
50 EntityAI dstParent1 = dst1.GetParent();
51 EntityAI dstParent2 = dst2.GetParent();
52
53
54 bool need_j1 = player.NeedInventoryJunctureFromServer(srcItem1, srcParent1, dstParent1);
55 bool need_j2 = player.NeedInventoryJunctureFromServer(srcItem2, srcParent2, dstParent2);
56 if (need_j1 || need_j2)
57 {
58 if (need_j1)
59 {
60 if ( ( srcItem1 && srcItem1.IsSetForDeletion() ) || ( srcParent1 && srcParent1.IsSetForDeletion() ) || ( dstParent1 && dstParent1.IsSetForDeletion() ) )
61 {
62 return JunctureRequestResult.JUNCTURE_DENIED;
63 }
64
65
66 if (srcItem1 && !srcItem1.CanPutIntoHands(player))
67 {
68 return JunctureRequestResult.JUNCTURE_DENIED;
69 }
70
71 if (!g_Game.AddInventoryJunctureEx(player, srcItem1, dst1, false, GameInventory.c_InventoryReservationTimeoutMS))
72 {
73 /*#ifdef ENABLE_LOGGING
74 if ( LogManager.IsInventoryReservationLogEnable() )
75 {
76 Debug.InventoryMoveLog("", "SWAP" , "n/a", "TryAcquireTwoInventoryJuncturesFromServer", player.ToString() );
77 }
78 #endif*/
79 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
80 }
81 }
82//Need add log and change chanel to print
83 if (need_j2)
84 {
85 if ( ( srcItem2 && srcItem2.IsSetForDeletion() ) || ( srcParent2 && srcParent2.IsSetForDeletion() ) || ( dstParent2 && dstParent2.IsSetForDeletion() ) )
86 {
87 if (need_j1)
88 {
89 g_Game.ClearJunctureEx(player, srcItem1); // release already acquired juncture for item1
90 }
91 return JunctureRequestResult.JUNCTURE_DENIED;
92 }
93
94 if (srcItem2 && !srcItem2.CanPutIntoHands(player))
95 {
96 return JunctureRequestResult.JUNCTURE_DENIED;
97 }
98
99 if (!g_Game.AddInventoryJunctureEx(player, srcItem2, dst2, false, GameInventory.c_InventoryReservationTimeoutMS))
100 {
101 //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));
102 if (need_j1)
103 {
104 g_Game.ClearJunctureEx(player, srcItem1); // release already acquired juncture for item1
105 //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));
106 }
107 return JunctureRequestResult.JUNCTURE_DENIED; // permission to perform juncture denied
108 }
109 }
110
111 return JunctureRequestResult.JUNCTURE_ACQUIRED; // ok, both junctures acquired
112 }
113 else
114 {
115 /*#ifdef ENABLE_LOGGING
116 if ( LogManager.IsInventoryReservationLogEnable() )
117 {
118 Debug.InventoryReservationLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", player.ToString() );
119 }
120 #endif*/
121 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));
122 return JunctureRequestResult.JUNCTURE_NOT_REQUIRED; // juncture not necessary
123 }
124}
125
void syncDebugPrint(string s)
DayZGame g_Game
Определения DayZGame.c:3942
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
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:202
Определения 3_Game/DayZ/tools/Debug.c:2
bool NeedInventoryJunctureFromServer(notnull EntityAI item, EntityAI currParent, EntityAI newParent)
Определения 3_Game/DayZ/Entities/Man.c:163
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:756
static bool IsSyncLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:776
Определения ObjectTyped.c:2