Dayz 1.25
Dayz Code Explorer by KGB
Загрузка...
Поиск...
Не найдено
Файл Junctures.c

См. исходные тексты.

Функции

bool TryAcquireInventoryJunctureFromServer (notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
 
bool TryAcquireTwoInventoryJuncturesFromServer (notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
 

Функции

◆ TryAcquireInventoryJunctureFromServer()

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 (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}
void syncDebugPrint(string s)
Definition Debug.c:1
JunctureRequestResult
Definition Hand_Events.c:28
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:713
InventoryLocation.
Definition InventoryLocation.c:28
static string DumpToStringNullSafe(InventoryLocation loc)
Definition InventoryLocation.c:218
Definition Debug.c:735
static bool IsSyncLogEnable()
Definition Debug.c:819
Definition ObjectTyped.c:2
Definition EntityAI.c:95
proto native CGame GetGame()

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutMS, InventoryLocation::DumpToStringNullSafe(), GetGame(), LogManager::IsSyncLogEnable() и syncDebugPrint().

Используется в HandEventBase::AcquireInventoryJunctureFromServer() и ValidateSyncMove().

◆ TryAcquireTwoInventoryJuncturesFromServer()

bool TryAcquireTwoInventoryJuncturesFromServer ( notnull Man player,
notnull InventoryLocation src1,
notnull InventoryLocation src2,
notnull InventoryLocation dst1,
notnull InventoryLocation dst2 )
36{
37 #ifdef DEVELOPER
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 DEVELOPER
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 DEVELOPER
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}
Definition Debug.c:14
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:184
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:172
static bool IsInventoryReservationLogEnable()
Definition Debug.c:799

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutMS, InventoryLocation::DumpToStringNullSafe(), GetGame(), Debug::InventoryMoveLog(), Debug::InventoryReservationLog(), LogManager::IsInventoryReservationLogEnable(), LogManager::IsSyncLogEnable() и syncDebugPrint().

Используется в HandEventBase::AcquireInventoryJunctureFromServer() и ValidateSwap().