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

◆ ValidateSwapServer()

bool ValidateSwapServer ( inout Serializer ctx,
InventoryValidation validation )
protected

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

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

2778 {
2779 DayZPlayer playerOwner = GetDayZPlayerOwner();
2781 if (!swapValidation)
2782 {
2783 return false;
2784 }
2785
2786 array<EntityAI> itemsToRepair;
2787 InventoryLocation repairIl;
2788
2789#ifdef ENABLE_LOGGING
2791 {
2792 Debug.InventoryMoveLog("STS = " + playerOwner.GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2), "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2793 }
2794#endif
2795
2796 EnableMovableOverride(swapValidation.m_SrcItem1);
2797 EnableMovableOverride(swapValidation.m_SrcItem2);
2798
2799 if (swapValidation.m_Success && swapValidation.m_SrcItem1 != swapValidation.m_DstItem1 || swapValidation.m_SrcItem2 != swapValidation.m_DstItem2 )
2800 {
2801 #ifdef ENABLE_LOGGING
2803 {
2804 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
2805 {
2806 Debug.InventoryMoveLog("Failed - src and dst are for different for first item", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
2807 }
2808 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
2809 {
2810 Debug.InventoryMoveLog("Failed - src and dst are for different for second item", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
2811 }
2812 }
2813
2815 {
2816 if(swapValidation.m_SrcItem1 != swapValidation.m_DstItem1)
2817 {
2818 syncDebugPrint("[syncinv] ValidateSwapServer Failed - first src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
2819 }
2820 if(swapValidation.m_SrcItem2 != swapValidation.m_DstItem2)
2821 {
2822 syncDebugPrint("[syncinv] ValidateSwapServer Failed - second src and dst are for different items src item =" + swapValidation.m_SrcItem1 + " dst item =" + swapValidation.m_DstItem1);
2823 }
2824 }
2825#endif
2826
2827 swapValidation.m_Success = false;
2828 }
2829
2833 if (swapValidation.m_Success && !PlayerCheckRequestSrc(swapValidation.m_Src1, GameInventory.c_MaxItemDistanceRadius))
2834 {
2835#ifdef ENABLE_LOGGING
2837 {
2838 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2839 }
2840
2842 {
2843 syncDebugPrint("[cheat] ValidateSwapServer man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1));
2844 }
2845#endif
2846
2847 RemoveMovableOverride(swapValidation.m_SrcItem1);
2848 RemoveMovableOverride(swapValidation.m_SrcItem2);
2849
2850 swapValidation.m_Success = false;
2851#ifdef DIAG_DEVELOPER
2852 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2853 {
2854#endif
2855 itemsToRepair = new array<EntityAI>();
2856 repairIl = new InventoryLocation();
2857
2858 swapValidation.m_SrcItem1.GetInventory().GetCurrentInventoryLocation(repairIl);
2859
2860 if(swapValidation.m_Src1 != repairIl)
2861 {
2862 itemsToRepair.Insert(swapValidation.m_SrcItem1);
2863 }
2864
2865 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
2866 if(swapValidation.m_Src2 != repairIl)
2867 {
2868 itemsToRepair.Insert(swapValidation.m_SrcItem2);
2869 }
2870
2871 if (itemsToRepair.Count())
2872 {
2874 }
2875#ifdef DIAG_DEVELOPER
2876 }
2877#endif
2878 }
2879
2883 if (swapValidation.m_Success && !PlayerCheckRequestSrc(swapValidation.m_Src2, GameInventory.c_MaxItemDistanceRadius))
2884 {
2885 #ifdef ENABLE_LOGGING
2887 {
2888 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2889 }
2890
2892 {
2893 syncDebugPrint("[cheat] ValidateSwapServer man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2));
2894 }
2895 #endif
2896
2897 RemoveMovableOverride(swapValidation.m_SrcItem1);
2898 RemoveMovableOverride(swapValidation.m_SrcItem2);
2899
2900 swapValidation.m_Success = false;
2901#ifdef DIAG_DEVELOPER
2902 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
2903 {
2904#endif
2905 itemsToRepair = new array<EntityAI>();
2906 repairIl = new InventoryLocation();
2907
2908 swapValidation.m_SrcItem2.GetInventory().GetCurrentInventoryLocation(repairIl);
2909 if(swapValidation.m_Src2 != repairIl)
2910 {
2911 itemsToRepair.Insert(swapValidation.m_SrcItem2);
2912 }
2913
2914 if (itemsToRepair.Count())
2915 {
2917 }
2918#ifdef DIAG_DEVELOPER
2919 }
2920#endif
2921 }
2922
2926 if (swapValidation.m_Success && !PlayerCheckSwapItemsRequest(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, GameInventory.c_MaxItemDistanceRadius))
2927 {
2928#ifdef ENABLE_LOGGING
2930 {
2931 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString());
2932 }
2933
2935 {
2936 syncDebugPrint("[cheat] ValidateSwapServer man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2937 }
2938#endif
2939
2940 RemoveMovableOverride(swapValidation.m_SrcItem1);
2941 RemoveMovableOverride(swapValidation.m_SrcItem2);
2942
2943 swapValidation.m_Success = false;
2944 }
2945
2946 RemoveMovableOverride(swapValidation.m_SrcItem1);
2947 RemoveMovableOverride(swapValidation.m_SrcItem2);
2948
2952 if (swapValidation.m_Success && !GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
2953 {
2954#ifdef ENABLE_LOGGING
2955 #ifdef DEVELOPER
2956 DumpInventoryDebug();
2957 #endif
2958
2960 {
2961 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString());
2962 }
2963#endif
2964
2965 if (swapValidation.m_Dst1)
2966 {
2967 SendRepairToClientDst(swapValidation.m_Dst1);
2968 }
2969
2970 if (swapValidation.m_Dst2)
2971 {
2972 SendRepairToClientDst(swapValidation.m_Dst2);
2973 }
2974 swapValidation.m_Success = false;
2975 }
2976
2977 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
2978 {
2979 Error("ValidateSwapServer: cmd=" + typename.EnumToString(InventoryCommandType, InventoryCommandType.SWAP) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(swapValidation.m_Dst2));
2980 return true;
2981 }
2982
2983 JunctureRequestResult resultSwap = TryAcquireTwoInventoryJuncturesFromServer(playerOwner, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
2984 if (resultSwap == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
2985 {
2986 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem1);
2987 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem2);
2988
2989#ifdef ENABLE_LOGGING
2991 {
2992 Debug.InventoryMoveLog("Success - item swap without juncture", "SWAP" , "n/a", "ValidateSwapServer", playerOwner.ToString() );
2993 }
2994#endif
2995
2996 if (swapValidation.m_Success)
2997 {
2998 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
2999 ctx = new ScriptInputUserData();
3000 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
3001 validation.m_Result = InventoryValidationResult.SUCCESS;
3002 }
3003
3004 return true;
3005 }
3006 else if (swapValidation.m_Success && resultSwap == JunctureRequestResult.JUNCTURE_ACQUIRED)
3007 {
3008#ifdef ENABLE_LOGGING
3010 {
3011 Debug.InventoryMoveLog("Juncture sended", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
3012 }
3013#endif
3014
3015 validation.m_Result = InventoryValidationResult.JUNCTURE;
3016 EnableMovableOverride(swapValidation.m_SrcItem1);
3017 EnableMovableOverride(swapValidation.m_SrcItem2);
3018 return true;
3019 }
3020 else
3021 {
3022#ifdef ENABLE_LOGGING
3024 {
3025 Debug.InventoryMoveLog("Juncture denied", "SWAP" , "n/a", "ValidateSwapServer", GetDayZPlayerOwner().ToString() );
3026 }
3027#endif
3028
3029 validation.m_Result = InventoryValidationResult.FAILED;
3030 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
3031 return true;
3032 }
3033
3034 //Not end here
3035 return true;
3036 }
void syncDebugPrint(string s)
InventoryCommandType
InventoryValidationResult
InventoryValidationReason
DayZGame g_Game
Определения DayZGame.c:4074
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3690
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 PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
Определения DayZPlayerInventory.c:4777
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:48
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
Определения DayZPlayerImplement.c:87
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 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:70
static void SendServerInventoryCheck(array< EntityAI > items, DayZPlayer player)
Определения InventoryInputUserData.c:44
ref InventoryLocation m_Src2
ref InventoryLocation m_Src1
ref InventoryLocation m_Dst1
ref InventoryLocation m_Dst2
proto native bool IsValid()
verify current set inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:233
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
Определения gameplay.c:121
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::c_MaxItemDistanceRadius, GameInventory::CanForceSwapEntitiesEx(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), g_Game, GetDayZPlayerOwner(), GetPlugin(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), InventoryLocation::IsValid(), InventoryJunctureSwapValidation::m_Dst1, InventoryJunctureSwapValidation::m_Dst2, InventoryJunctureSwapValidation::m_DstItem1, InventoryJunctureSwapValidation::m_DstItem2, InventoryValidation::m_Reason, InventoryValidation::m_Result, InventoryJunctureSwapValidation::m_Src1, InventoryJunctureSwapValidation::m_Src2, InventoryJunctureSwapValidation::m_SrcItem1, InventoryJunctureSwapValidation::m_SrcItem2, InventoryJunctureSwapValidation::m_Success, PlayerCheckRequestSrc(), PlayerCheckSwapItemsRequest(), RemoveMovableOverride(), SendRepairToClientDst(), InventoryInputUserData::SendServerInventoryCheck(), InventoryInputUserData::SerializeSwap(), syncDebugPrint(), ToString() и TryAcquireTwoInventoryJuncturesFromServer().

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