Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
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
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
35
bool
TryAcquireTwoInventoryJuncturesFromServer
(notnull Man player, notnull
InventoryLocation
src1, notnull
InventoryLocation
src2, notnull
InventoryLocation
dst1, notnull
InventoryLocation
dst2)
36
{
37
#ifdef ENABLE_LOGGING
38
if
(
LogManager
.
IsInventoryReservationLogEnable
() )
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
syncDebugPrint
void syncDebugPrint(string s)
Definition
debug.c:1
Debug
Definition
debug.c:2
Debug::InventoryReservationLog
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:202
EntityAI
Definition
inventoryitem.c:2
EntityAI::NeedInventoryJunctureFromServer
bool NeedInventoryJunctureFromServer(notnull EntityAI item, EntityAI currParent, EntityAI newParent)
Definition
man.c:163
GameInventory
script counterpart to engine's class Inventory
Definition
inventory.c:81
GameInventory::c_InventoryReservationTimeoutMS
const int c_InventoryReservationTimeoutMS
reservations
Definition
inventory.c:714
InventoryLocation
InventoryLocation.
Definition
inventorylocation.c:30
InventoryLocation::DumpToStringNullSafe
static string DumpToStringNullSafe(InventoryLocation loc)
Definition
inventorylocation.c:233
LogManager
Definition
debug.c:692
LogManager::IsInventoryReservationLogEnable
static bool IsInventoryReservationLogEnable()
Definition
debug.c:756
LogManager::IsSyncLogEnable
static bool IsSyncLogEnable()
Definition
debug.c:776
Object
Definition
objecttyped.c:2
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
JunctureRequestResult
JunctureRequestResult
Definition
hand_events.c:28
TryAcquireInventoryJunctureFromServer
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition
junctures.c:2
TryAcquireTwoInventoryJuncturesFromServer
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition
junctures.c:35
Games
Dayz
scripts
3_game
systems
inventory
junctures.c
Generated by
1.17.0