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

◆ ValidateSyncMove()

bool ValidateSyncMove ( 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

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

Check if this this is being executed on the server and not by a juncture or AI so we can lock the item and ensure replication relationships are setup

TODO(kumarjac): We should continue with the execution and not have this special block but making a change here now will require testing

Is called twice unfortunately...

Never end here, always return in send junture part MW 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

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

808 {
810
813 bool success = true;
814
815 src.ReadFromContext(ctx);
816 dst.ReadFromContext(ctx);
817
818 #ifdef ENABLE_LOGGING
820 {
821 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
822 }
823 #endif
824
825 EntityAI itemSrc = src.GetItem();
826 EntityAI itemDst = dst.GetItem();
827
828 if (validation.m_IsRemote && (!itemSrc || !itemDst))
829 {
831
832#ifdef ENABLE_LOGGING
834 {
835 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
836 }
837
839 {
840 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
841 }
842#endif
843
844 return true;
845 }
846
847 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && itemSrc != itemDst)
848 {
849 #ifdef ENABLE_LOGGING
851 {
852 Debug.InventoryMoveLog("Failed - src and dst are for different items", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
853 }
854
856 {
857 syncDebugPrint("[syncinv] HandleInputData Failed - src and dst are for different items src item =" + itemSrc + " dst item =" + itemDst);
858 }
859 #endif
860
861 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
862 {
863 success = false;
864 }
865 else
866 {
867 return true;
868 }
869 }
870
871 EnableMovableOverride(itemSrc);
872
876 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
877 {
879
880#ifdef ENABLE_LOGGING
882 {
883 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
884 }
885
887 {
888 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
889 }
890#endif
891
892 RemoveMovableOverride(itemSrc);
893
894 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
895 {
896 success = false;
897 #ifdef DIAG_DEVELOPER
898 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
899 {
900 #endif
901 array<EntityAI> itemsToRepair = new array<EntityAI>;
903 src.GetItem().GetInventory().GetCurrentInventoryLocation(realIl);
904
905 if(src != realIl)
906 {
907 itemsToRepair.Insert(src.GetItem());
909 }
910 #ifdef DIAG_DEVELOPER
911 }
912 #endif
913 }
914 else
915 {
916 return true;
917 }
918 }
919
923 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
924 {
925#ifdef ENABLE_LOGGING
927 {
928 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
929 }
930
932 {
933 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
934 }
935#endif
936
937 RemoveMovableOverride(itemSrc);
938
939 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
940 {
942 success = false;
943 }
944 else
945 {
946 return true;
947 }
948 }
949
950 RemoveMovableOverride(itemSrc);
951
952#ifdef ENABLE_LOGGING
954 {
955 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " HandleInputData t=" + g_Game.GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
956 }
957#endif
958
960 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
961 {
963 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
964 {
965 #ifdef ENABLE_LOGGING
967 {
968 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
969 }
970 #endif
971 if (success)
972 {
974
975 LocationSyncMoveEntity(src, dst);
976
977 validation.m_Result = InventoryValidationResult.SUCCESS;
978 }
979 return true;
980 }
981 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
982 {
983 #ifdef ENABLE_LOGGING
985 {
986 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
987 }
988 #endif
989
991 {
992 #ifdef ENABLE_LOGGING
993
994 #ifdef DEVELOPER
995 DumpInventoryDebug();
996 #endif
997
999 {
1000 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1001 }
1002 #endif
1003 validation.m_Result = InventoryValidationResult.FAILED;
1004 return true;
1005 }
1006
1007 validation.m_Result = InventoryValidationResult.JUNCTURE;
1008 EnableMovableOverride(itemSrc);
1009 return true;
1010 }
1011 else
1012 {
1013 #ifdef ENABLE_LOGGING
1015 {
1016 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1017 }
1018 #endif
1019
1020 validation.m_Result = InventoryValidationResult.FAILED;
1021 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1022 return true;
1023 }
1024 }
1025 // Check whether the juncture for the related player and items has been acquired.
1026 else if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1027 {
1028 bool hasJuncture = false;
1029 if (itemSrc != null && itemDst != null)
1030 {
1031 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1032 }
1033 else if (itemSrc != null)
1034 {
1035 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
1036 }
1037 else if (itemDst != null)
1038 {
1039 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
1040 }
1041
1042 if (!hasJuncture)
1043 {
1044#ifdef ENABLE_LOGGING
1046 {
1047 Debug.InventoryMoveLog("Failed - missing juncture", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1048 }
1049#endif
1050 success = false;
1051 }
1052 }
1053
1054 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1055 {
1056 ClearInventoryReservationEx(itemDst, dst);
1057 }
1058
1060 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1061 {
1062 CheckForRope(src, dst);
1063 }
1064
1069 if (!validation.m_IsRemote)
1070 {
1072 {
1073 #ifdef ENABLE_LOGGING
1074
1075 #ifdef DEVELOPER
1076 DumpInventoryDebug();
1077 #endif
1078
1080 {
1081 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1082 }
1083 #endif
1084
1085 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1086 return true;
1087 }
1088 else if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT && !GameInventory.LocationTestAddEntity(dst, false, true, true, true, false, false))
1089 {
1090 #ifdef ENABLE_LOGGING
1091
1092 #ifdef DEVELOPER
1093 DumpInventoryDebug();
1094 #endif
1095
1097 {
1098 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1099 }
1100 #endif
1101
1102 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1103 return true;
1104 }
1105 }
1106
1107
1108 //TODO: hotfix solution
1109 if (!validation.m_IsRemote && validation.m_IsJuncture && !MoveCheckExclusionMaskLocal(src,dst))
1110 {
1111 #ifdef ENABLE_LOGGING
1113 {
1114 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1115 }
1116 #endif
1117 return false;
1118 }
1119
1120 #ifdef ENABLE_LOGGING
1122 {
1123 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1124 }
1125 #endif
1126
1127 if (success)
1128 {
1129 LocationSyncMoveEntity(src, dst);
1130 validation.m_Result = InventoryValidationResult.SUCCESS;
1131 }
1132
1133 return true;
1134 }
void syncDebugPrint(string s)
InventoryCommandType
InventoryValidationResult
InventoryValidationReason
void ClearInventoryReservationEx(ActionData action_data)
Определения ActionBase.c:1120
DayZGame g_Game
Определения DayZGame.c:4074
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3690
bool MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:4881
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:3698
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:4644
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3683
void SendRepairToClientDst(notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:4726
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:170
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:4682
proto string ToString()
JunctureRequestResult
Определения Hand_Events.c:28
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Junctures.c:2
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
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/DayZ/tools/Debug.c:198
Определения 3_Game/DayZ/tools/Debug.c:2
static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
const float c_MaxItemDistanceRadius
anti-cheats
script counterpart to engine's class Inventory
static void SendServerInventoryCheck(array< EntityAI > items, DayZPlayer player)
Определения InventoryInputUserData.c:44
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:233
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:310
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
InventoryValidationResult m_Result
InventoryValidationReason m_Reason
static bool IsSyncLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:789
static bool IsInventoryMoveLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:759
Определения ObjectTyped.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1084
proto native DayZPlayerInstanceType GetInstanceType()
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::c_MaxItemDistanceRadius, CheckForRope(), ClearInventoryReservationEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), g_Game, GetDayZPlayerOwner(), GetInstanceType(), InventoryLocation::GetItem(), GetPlugin(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), GameInventory::LocationCanMoveEntity(), GameInventory::LocationCanMoveEntitySyncCheck(), GameInventory::LocationTestAddEntity(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, MoveCheckExclusionMaskLocal(), PlayerCheckRequestDst(), PlayerCheckRequestSrc(), InventoryLocation::ReadFromContext(), RemoveMovableOverride(), SendRepairToClientDst(), InventoryInputUserData::SendServerInventoryCheck(), syncDebugPrint(), ToString() и TryAcquireInventoryJunctureFromServer().

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