DayZ 1.29
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...

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 строка 747

748 {
750
753 bool success = true;
754
755 src.ReadFromContext(ctx);
756 dst.ReadFromContext(ctx);
757
758 #ifdef ENABLE_LOGGING
760 {
761 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
762 }
763 #endif
764
765 EntityAI itemSrc = src.GetItem();
766 EntityAI itemDst = dst.GetItem();
767
768 if (validation.m_IsRemote && (!itemSrc || !itemDst))
769 {
771
772#ifdef ENABLE_LOGGING
774 {
775 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
776 }
777
779 {
780 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
781 }
782#endif
783
784 return true;
785 }
786
787 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && itemSrc != itemDst)
788 {
789 #ifdef ENABLE_LOGGING
791 {
792 Debug.InventoryMoveLog("Failed - src and dst are for different items", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
793 }
794
796 {
797 syncDebugPrint("[syncinv] HandleInputData Failed - src and dst are for different items src item =" + itemSrc + " dst item =" + itemDst);
798 }
799 #endif
800
801 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
802 {
803 success = false;
804 }
805 else
806 {
807 return true;
808 }
809 }
810
811 EnableMovableOverride(itemSrc);
812
816 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
817 {
819
820#ifdef ENABLE_LOGGING
822 {
823 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
824 }
825
827 {
828 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
829 }
830#endif
831
832 RemoveMovableOverride(itemSrc);
833
834 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
835 {
836 success = false;
837 #ifdef DIAG_DEVELOPER
838 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
839 {
840 #endif
841 array<EntityAI> itemsToRepair = new array<EntityAI>;
843 src.GetItem().GetInventory().GetCurrentInventoryLocation(realIl);
844
845 if(src != realIl)
846 {
847 itemsToRepair.Insert(src.GetItem());
849 }
850 #ifdef DIAG_DEVELOPER
851 }
852 #endif
853 }
854 else
855 {
856 return true;
857 }
858 }
859
863 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
864 {
865#ifdef ENABLE_LOGGING
867 {
868 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
869 }
870
872 {
873 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
874 }
875#endif
876
877 RemoveMovableOverride(itemSrc);
878
879 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
880 {
882 success = false;
883 }
884 else
885 {
886 return true;
887 }
888 }
889
890 RemoveMovableOverride(itemSrc);
891
892#ifdef ENABLE_LOGGING
894 {
895 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));
896 }
897#endif
898
900 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
901 {
903 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
904 {
905 #ifdef ENABLE_LOGGING
907 {
908 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
909 }
910 #endif
911 if (success)
912 {
914
915 LocationSyncMoveEntity(src, dst);
916
917 validation.m_Result = InventoryValidationResult.SUCCESS;
918 }
919 return true;
920 }
921 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
922 {
923 #ifdef ENABLE_LOGGING
925 {
926 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
927 }
928 #endif
929
931 {
932 #ifdef ENABLE_LOGGING
933
934 #ifdef DEVELOPER
935 DumpInventoryDebug();
936 #endif
937
939 {
940 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
941 }
942 #endif
943 validation.m_Result = InventoryValidationResult.FAILED;
944 return true;
945 }
946
947 validation.m_Result = InventoryValidationResult.JUNCTURE;
948 EnableMovableOverride(itemSrc);
949 return true;
950 }
951 else
952 {
953 #ifdef ENABLE_LOGGING
955 {
956 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
957 }
958 #endif
959
960 validation.m_Result = InventoryValidationResult.FAILED;
961 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
962 return true;
963 }
964 }
965 // Check whether the juncture for the related player and items has been acquired.
966 else if (validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
967 {
968 bool hasJuncture = false;
969 if (itemSrc != null && itemDst != null)
970 {
971 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc) && g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
972 }
973 else if (itemSrc != null)
974 {
975 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemSrc);
976 }
977 else if (itemDst != null)
978 {
979 hasJuncture = g_Game.HasInventoryJuncture(GetDayZPlayerOwner(), itemDst);
980 }
981
982 if (!hasJuncture)
983 {
984 success = false;
985 }
986 }
987
988 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
989 {
990 ClearInventoryReservationEx(itemDst, dst);
991 }
992
994 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
995 {
996 CheckForRope(src, dst);
997 }
998
1002 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
1003 {
1004 #ifdef ENABLE_LOGGING
1005
1006 #ifdef DEVELOPER
1007 DumpInventoryDebug();
1008 #endif
1009
1011 {
1012 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1013 }
1014 #endif
1015
1016 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1017 return true;
1018 }
1019
1020 //TODO: hotfix solution
1021 if (!validation.m_IsRemote && validation.m_IsJuncture && !MoveCheckExclusionMaskLocal(src,dst))
1022 {
1023 #ifdef ENABLE_LOGGING
1025 {
1026 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1027 }
1028 #endif
1029 return false;
1030 }
1031
1032 #ifdef ENABLE_LOGGING
1034 {
1035 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
1036 }
1037 #endif
1038
1039 if (success)
1040 {
1041 LocationSyncMoveEntity(src, dst);
1042 validation.m_Result = InventoryValidationResult.SUCCESS;
1043 }
1044
1045 return true;
1046 }
void syncDebugPrint(string s)
InventoryCommandType
InventoryValidationResult
InventoryValidationReason
DayZGame g_Game
Определения DayZGame.c:3942
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1860
bool MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:3051
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1868
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2814
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1853
void SendRepairToClientDst(notnull InventoryLocation dst)
Определения DayZPlayerInventory.c:2896
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:167
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:2852
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:325
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:197
Определения 3_Game/DayZ/tools/Debug.c:2
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:776
static bool IsInventoryMoveLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:746
Определения ObjectTyped.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerInstanceType
defined in C++
Определения dayzplayer.c:1071
proto native DayZPlayerInstanceType GetInstanceType()
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::c_MaxItemDistanceRadius, CheckForRope(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), g_Game, GetDayZPlayerOwner(), GetInstanceType(), InventoryLocation::GetItem(), GetPlugin(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), GameInventory::LocationCanMoveEntity(), GameInventory::LocationCanMoveEntitySyncCheck(), 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().