DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ TryAcquireTwoInventoryJuncturesFromServer()

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

См. определение в файле Junctures.c строка 35

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}
void syncDebugPrint(string s)
Определения Debug.c:1
JunctureRequestResult
Определения Hand_Events.c:28
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()

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

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