DayZ 1.28
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 строка 1239

1240 {
1242
1245
1248
1249 bool skippedSwap = false;
1250 bool success = true;
1251
1252 src1.ReadFromContext(ctx);
1253 src2.ReadFromContext(ctx);
1254 dst1.ReadFromContext(ctx);
1255 dst2.ReadFromContext(ctx);
1256 ctx.Read(skippedSwap);
1257
1258 #ifdef ENABLE_LOGGING
1260 {
1261 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() );
1262 }
1263 #endif
1264
1265 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1266 {
1267 if (skippedSwap)
1268 {
1269 #ifdef ENABLE_LOGGING
1271 {
1272 Debug.InventoryMoveLog("Remote - skipped", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1273 }
1274 #endif
1275/*
1276 if (LogManager.IsSyncLogEnable())
1277 {
1278 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1279 }
1280*/
1281 }
1282 else
1283 {
1285
1286 #ifdef ENABLE_LOGGING
1288 {
1289 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1290 }
1291 #endif
1292
1293 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1294 }
1295
1296 return true;
1297 }
1298
1301
1305 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src1, GameInventory.c_MaxItemDistanceRadius))
1306 {
1307#ifdef ENABLE_LOGGING
1309 {
1310 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1311 }
1312
1314 {
1315 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1316 }
1317#endif
1318
1321
1322 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1323 {
1324 success = false;
1325 }
1326 else
1327 {
1328 return true;
1329 }
1330 }
1331
1335 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src2, GameInventory.c_MaxItemDistanceRadius))
1336 {
1337#ifdef ENABLE_LOGGING
1339 {
1340 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1341 }
1342
1344 {
1345 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1346 }
1347#endif
1348
1351
1352 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1353 {
1354 success = false;
1355 }
1356 else
1357 {
1358 return true;
1359 }
1360 }
1361
1365 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckSwapItemsRequest(src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius))
1366 {
1367#ifdef ENABLE_LOGGING
1369 {
1370 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1371 }
1372
1374 {
1375 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));
1376 }
1377#endif
1378
1381
1382 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1383 {
1384 success = false;
1385 }
1386 else
1387 {
1388 return true;
1389 }
1390 }
1391
1394
1395 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1396 {
1397 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1398 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1399 }
1400
1404 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1405 {
1406 #ifdef ENABLE_LOGGING
1407
1408 #ifdef DEVELOPER
1409 DumpInventoryDebug();
1410 #endif
1411
1413 {
1414 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1415 }
1416 #endif
1417
1418 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1419 {
1420 success = false;
1421 }
1422 else
1423 {
1424 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));
1425 return true;
1426 }
1427 }
1428
1429 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1430 {
1431 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1432 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1433 }
1434
1435 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1436 {
1437 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));
1438 return true;
1439 }
1440
1442 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1443 {
1445 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1446 {
1447 #ifdef ENABLE_LOGGING
1449 {
1450 Debug.InventoryMoveLog("Juncture not required", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1451 }
1452 #endif
1453
1455 }
1456 else if (success && result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1457 {
1458 #ifdef ENABLE_LOGGING
1460 {
1461 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1462 }
1463 #endif
1464
1465 validation.m_Result = InventoryValidationResult.JUNCTURE;
1468 return true;
1469 }
1470 else
1471 {
1472 #ifdef ENABLE_LOGGING
1474 {
1475 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1476 }
1477 #endif
1478
1479 validation.m_Result = InventoryValidationResult.FAILED;
1480 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1481 return true;
1482 }
1483 }
1484
1485 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT )
1486 {
1487 ClearInventoryReservationEx(dst1.GetItem(), dst1);
1488 ClearInventoryReservationEx(dst2.GetItem(), dst2);
1489 }
1490 else
1491 {
1494 }
1495
1496 //TODO: hotfix solution
1497 if (!validation.m_IsRemote && validation.m_IsJuncture && !SwapCheckExclusionMaskLocal(src1,src2,dst1,dst2))
1498 {
1499 #ifdef ENABLE_LOGGING
1501 {
1502 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1503 }
1504 #endif
1505 return false;
1506 }
1507
1508 #ifdef ENABLE_LOGGING
1510 {
1511 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1512 }
1513 #endif
1514 if (success)
1515 {
1516 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1517
1518 ctx = new ScriptInputUserData();
1519 InventoryInputUserData.SerializeSwap(ctx, src1, src2, dst1, dst2, !isNotSkipped);
1520
1521 validation.m_Result = InventoryValidationResult.SUCCESS;
1522 }
1523 return true;
1524 }
void syncDebugPrint(string s)
Определения 3_Game/Systems/Inventory/Debug.c:1
InventoryCommandType
InventoryValidationResult
InventoryValidationReason
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1627
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:2634
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2476
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1620
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:2538
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)
Определения Global/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)
Определения 3_Game/tools/Debug.c:137
Определения 3_Game/tools/Debug.c:2
const int c_InventoryReservationTimeoutShortMS
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
const float c_MaxItemDistanceRadius
anti-cheats
script counterpart to engine's class Inventory
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
InventoryValidationResult m_Result
InventoryValidationReason m_Reason
static bool IsSyncLogEnable()
Определения 3_Game/tools/Debug.c:678
static bool IsInventoryMoveLogEnable()
Определения 3_Game/tools/Debug.c:648
Определения 3_Game/tools/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().