Pass partial information to guards so guards can do minimal checks if needed The guards can't prevent event so it would be incorrect to pass full InventoryValidation struct. We have to make sure guards don't inadvertantly produce different results in the FSM as that will create desync (two players attempting to put a rag into the same fireplace slot at the same time)
kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote
TODO(kumarjac): Is this one correct to be 'RemoveMovableOverride' or are the other Validate methdos wrong with 'EnableMovableOverride'?
Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync
if it already happened on server, remote just needs to comply TODO(kumarjac): Move m_IsRemote check to inside of HandEventBase.CanPerformEventEx
Is called twice unfortunately... but it works so won't change
1049 {
1051 bool success = true;
1052
1055
1061
1062 EntityAI itemSrc = e.GetSrcEntity();
1064
1065 #ifdef ENABLE_LOGGING
1067 {
1068 Debug.
InventoryMoveLog(
"STS = " + e.m_Player.GetSimulationTimeStamp() +
" event= " + e.
DumpToString(),
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1069 }
1070 #endif
1071
1072 if (validation.
m_IsRemote && !e.GetSrcEntity())
1073 {
1076 {
1078 srcNew.
Copy(e.GetSrc());
1080
1081 Error(
"[syncinv] HandleInputData remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.
DumpToString() +
"), src item is null! Continuing.");
1082 }
1083 else
1084 {
1085 #ifdef ENABLE_LOGGING
1087 {
1088 Debug.
InventoryMoveLog(
"Failed - CheckRequestSrc",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1089 }
1090 #endif
1091
1092 Error(
"[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.
DumpToString() +
") dropped, item not in bubble");
1093
1094 return true;
1095 }
1096 }
1097
1099 if (itemSrc)
1101 if (itemDst)
1103
1108 {
1109 #ifdef ENABLE_LOGGING
1111 {
1112 Debug.
InventoryMoveLog(
"Failed - CheckRequestSrc",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1113 }
1114 #endif
1115
1117 {
1120 }
1121
1124
1126 {
1127 success = false;
1128 #ifdef DIAG_DEVELOPER
1129 if (PluginInventoryDebug.Cast(
GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1130 {
1131 #endif
1134 itemSrc.GetInventory().GetCurrentInventoryLocation(repairIl);
1135
1136 if(e.GetSrc() != repairIl)
1137 {
1138 itemsToRepair.Insert(itemSrc);
1139 }
1140
1141 if(itemDst && itemSrc != itemDst )
1142 {
1143 itemDst.GetInventory().GetCurrentInventoryLocation(repairIl);
1145 {
1146 itemsToRepair.Insert(itemDst);
1147 }
1148 }
1149
1150 if (itemsToRepair.Count())
1151 {
1153 }
1154 #ifdef DIAG_DEVELOPER
1155 }
1156 #endif
1157 }
1158 else
1159 {
1160 return true;
1161 }
1162 }
1163
1164 if (success && !e.CheckRequestEx(validation))
1165 {
1166 #ifdef ENABLE_LOGGING
1168 {
1169 Debug.
InventoryMoveLog(
"Failed - CheckRequest",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1170 }
1171 #endif
1172
1174
1177
1178#ifdef ENABLE_LOGGING
1180 {
1182 }
1183#endif
1184
1187
1189 {
1190 success = false;
1191 }
1192 else
1193 {
1194 return true;
1195 }
1196 }
1197
1201 {
1202 #ifdef ENABLE_LOGGING
1204 {
1205 Debug.
InventoryMoveLog(
"Failed - CanPerformEvent",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1206 }
1207 #endif
1208
1210
1213
1214#ifdef ENABLE_LOGGING
1216 {
1218 }
1219#endif
1220
1223
1225 {
1227 if (ilDst)
1229
1231 if (ilDst)
1233
1234 success = false;
1235 }
1236 else
1237 {
1238 return true;
1239 }
1240 }
1241
1244
1247 {
1250 {
1251 #ifdef ENABLE_LOGGING
1253 {
1254 Debug.
InventoryMoveLog(
"Juncture not required",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1255 }
1256 #endif
1257
1259 }
1261 {
1262 #ifdef ENABLE_LOGGING
1264 {
1265 Debug.
InventoryMoveLog(
"Juncture sended",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1266 }
1267 #endif
1268
1271
1273
1274 if (itemSrc)
1276 if (itemDst)
1278 return true;
1279 }
1280 else
1281 {
1282 #ifdef ENABLE_LOGGING
1284 {
1285 Debug.
InventoryMoveLog(
"Juncture denied",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1286 }
1287 #endif
1288
1291 return true;
1292 }
1293 }
1294
1296 {
1297 bool hasJuncture = false;
1298
1299 if (itemSrc != null && itemDst != null)
1300 {
1302 }
1303 else if (itemSrc != null)
1304 {
1306 }
1307 else if (itemDst != null)
1308 {
1310 }
1311
1312 if (!hasJuncture)
1313 {
1314 success = false;
1315 }
1316 }
1317
1320 {
1322 }
1323
1324 #ifdef ENABLE_LOGGING
1326 {
1327 Debug.
InventoryMoveLog(
"Success - ProcessHandEvent",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1328 }
1329 #endif
1330
1331 if (success)
1332 {
1334 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1335 {
1337
1338 }
1339 }
1340
1341 return true;
1342 }
void syncDebugPrint(string s)
InventoryValidationResult
InventoryValidationReason
void EnableMovableOverride(EntityAI item)
void CheckForRope(InventoryLocation src, InventoryLocation dst)
void RemoveMovableOverride(EntityAI item)
void SendRepairToClientDst(notnull InventoryLocation dst)
DayZPlayer GetDayZPlayerOwner()
PluginBase GetPlugin(typename plugin_type)
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
override InventoryLocation GetSecondDst()
override InventoryLocation GetDst()
override bool AcquireInventoryJunctureFromServer(notnull Man player)
override EntityAI GetSecondSrcEntity()
override string DumpToString()
override void ClearInventoryReservation()
override bool CheckRequestSrc()
override bool CanPerformEventEx(InventoryValidation validation)
override InventoryLocation GetSecondSrc()
Abstracted event, not to be used, only inherited.
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
InventoryValidationResult m_Result
InventoryValidationReason m_Reason
static bool IsSyncLogEnable()
static bool IsInventoryMoveLogEnable()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerInstanceType
defined in C++
proto native DayZPlayerInstanceType GetInstanceType()
void Error(string err)
Messagebox with error message.