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

◆ ValidateSwap()

bool ValidateSwap ( inout Serializer ctx,
InventoryValidation validation )
protected

kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote

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

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

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

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

Check if this this is being executed on the server and not by a juncture or AI

Continuing on with execution of rest of the function

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

1230 {
1232
1235
1238
1239 bool skippedSwap = false;
1240 bool success = true;
1241
1242 src1.ReadFromContext(ctx);
1243 src2.ReadFromContext(ctx);
1244 dst1.ReadFromContext(ctx);
1245 dst2.ReadFromContext(ctx);
1246 ctx.Read(skippedSwap);
1247
1248 #ifdef ENABLE_LOGGING
1250 {
1251 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2), "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1252 }
1253 #endif
1254
1255 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1256 {
1257 if (skippedSwap)
1258 {
1259 #ifdef ENABLE_LOGGING
1261 {
1262 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1263 }
1264 #endif
1265/*
1266 if (LogManager.IsSyncLogEnable())
1267 {
1268 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1269 }
1270*/
1271 }
1272 else
1273 {
1275
1276 #ifdef ENABLE_LOGGING
1278 {
1279 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1280 }
1281 #endif
1282
1283 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1284 }
1285
1286 return true;
1287 }
1288
1291
1295 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src1, GameInventory.c_MaxItemDistanceRadius))
1296 {
1297#ifdef ENABLE_LOGGING
1299 {
1300 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1301 }
1302
1304 {
1305 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1306 }
1307#endif
1308
1311
1312 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1313 {
1314 success = false;
1315 }
1316 else
1317 {
1318 return true;
1319 }
1320 }
1321
1325 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src2, GameInventory.c_MaxItemDistanceRadius))
1326 {
1327#ifdef ENABLE_LOGGING
1329 {
1330 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1331 }
1332
1334 {
1335 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1336 }
1337#endif
1338
1341
1342 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1343 {
1344 success = false;
1345 }
1346 else
1347 {
1348 return true;
1349 }
1350 }
1351
1355 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckSwapItemsRequest(src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius))
1356 {
1357#ifdef ENABLE_LOGGING
1359 {
1360 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1361 }
1362
1364 {
1365 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1366 }
1367#endif
1368
1371
1372 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1373 {
1374 success = false;
1375 }
1376 else
1377 {
1378 return true;
1379 }
1380 }
1381
1384
1385 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1386 {
1387 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1388 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1389 }
1390
1394 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1395 {
1396 #ifdef ENABLE_LOGGING
1397
1398 #ifdef DEVELOPER
1399 DumpInventoryDebug();
1400 #endif
1401
1403 {
1404 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1405 }
1406 #endif
1407
1408 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1409 {
1410 success = false;
1411 }
1412 else
1413 {
1414 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT swap cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) +" | src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1415 return true;
1416 }
1417 }
1418
1419 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1420 {
1421 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1422 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1423 }
1424
1425 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1426 {
1427 Error("HandleInputData: cmd=" + typename.EnumToString(InventoryCommandType, type) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1428 return true;
1429 }
1430
1432 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1433 {
1435 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1436 {
1437 #ifdef ENABLE_LOGGING
1439 {
1440 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1441 }
1442 #endif
1443
1445 }
1446 else if (success && result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1447 {
1448 #ifdef ENABLE_LOGGING
1450 {
1451 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1452 }
1453 #endif
1454
1455 validation.m_Result = InventoryValidationResult.JUNCTURE;
1458 return true;
1459 }
1460 else
1461 {
1462 #ifdef ENABLE_LOGGING
1464 {
1465 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1466 }
1467 #endif
1468
1469 validation.m_Result = InventoryValidationResult.FAILED;
1470 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1471 return true;
1472 }
1473 }
1474
1475 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
1476 {
1477 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1478 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1479 }
1480 else
1481 {
1484 }
1485
1486 //TODO: hotfix solution
1487 if (!validation.m_IsRemote && validation.m_IsJuncture && !SwapCheckExclusionMaskLocal(src1,src2,dst1,dst2))
1488 {
1489 #ifdef ENABLE_LOGGING
1491 {
1492 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1493 }
1494 #endif
1495 return false;
1496 }
1497
1498 #ifdef ENABLE_LOGGING
1500 {
1501 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1502 }
1503 #endif
1504 if (success)
1505 {
1506 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1507
1508 ctx = new ScriptInputUserData();
1509 InventoryInputUserData.SerializeSwap(ctx, src1, src2, dst1, dst2, !isNotSkipped);
1510
1511 validation.m_Result = InventoryValidationResult.SUCCESS;
1512 }
1513 return true;
1514 }
void syncDebugPrint(string s)
Определения Debug.c:1
InventoryCommandType
Определения Inventory.c:3
InventoryValidationResult
Определения Inventory.c:30
InventoryValidationReason
Определения Inventory.c:37
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1617
bool SwapCheckExclusionMaskLocal(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:2624
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2466
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1610
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:2528
proto string ToString()
JunctureRequestResult
Определения Hand_Events.c:28
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Определения Junctures.c:35
bool ClearJunctureEx(Man player, notnull EntityAI item)
Определения Game.c:762
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_InventoryReservationTimeoutShortMS
Определения Inventory.c:713
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Определения Inventory.c:664
const float c_MaxItemDistanceRadius
anti-cheats
Определения Inventory.c:813
script counterpart to engine's class Inventory
Определения Inventory.c:79
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap
Определения InventoryInputUserData.c:37
proto native bool IsValid()
verify current set inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:296
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
bool m_IsJuncture
Определения Inventory.c:45
InventoryValidationResult m_Result
Определения Inventory.c:48
InventoryValidationReason m_Reason
Определения Inventory.c:49
bool m_IsRemote
Определения Inventory.c:46
static bool IsSyncLogEnable()
Определения Debug.c:678
static bool IsInventoryMoveLogEnable()
Определения Debug.c:648
Определения Debug.c:594
Определения ObjectTyped.c:2
Определения gameplay.c:121
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1068
proto native DayZPlayerInstanceType GetInstanceType()
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, GameInventory::c_MaxItemDistanceRadius, GameInventory::CanForceSwapEntitiesEx(), CGame::ClearJunctureEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), GetInstanceType(), InventoryLocation::GetItem(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), InventoryLocation::IsValid(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, PlayerCheckRequestSrc(), PlayerCheckSwapItemsRequest(), InventoryLocation::ReadFromContext(), RemoveMovableOverride(), InventoryInputUserData::SerializeSwap(), SwapCheckExclusionMaskLocal(), syncDebugPrint(), ToString() и TryAcquireTwoInventoryJuncturesFromServer().

Используется в ProcessInputData().