DayZ 1.27
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 строка 772

773 {
775
778 bool success = true;
779
780 src.ReadFromContext(ctx);
781 dst.ReadFromContext(ctx);
782
783 #ifdef ENABLE_LOGGING
785 {
786 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
787 }
788 #endif
789
790 if (validation.m_IsRemote && (!src.GetItem() || !dst.GetItem()))
791 {
793
794#ifdef ENABLE_LOGGING
796 {
797 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
798 }
799
801 {
802 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
803 }
804#endif
805
806 return true;
807 }
808
810
814 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestSrc(src, GameInventory.c_MaxItemDistanceRadius))
815 {
817
818#ifdef ENABLE_LOGGING
820 {
821 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
822 }
823
825 {
826 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
827 }
828#endif
829
831
832 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
833 {
834 success = false;
835 }
836 else
837 {
838 return true;
839 }
840 }
841
845 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !PlayerCheckRequestDst(src, dst, GameInventory.c_MaxItemDistanceRadius))
846 {
847#ifdef ENABLE_LOGGING
849 {
850 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
851 }
852
854 {
855 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
856 }
857#endif
858
860
861 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
862 {
863 success = false;
864 }
865 else
866 {
867 return true;
868 }
869 }
870
872
873#ifdef ENABLE_LOGGING
875 {
876 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " HandleInputData t=" + GetGame().GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
877 }
878#endif
879
881 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
882 {
884 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
885 {
886 #ifdef ENABLE_LOGGING
888 {
889 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
890 }
891 #endif
892 if (success)
893 {
895
896 LocationSyncMoveEntity(src, dst);
897
898 validation.m_Result = InventoryValidationResult.SUCCESS;
899 }
900 return true;
901 }
902 else if (success && result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
903 {
904 #ifdef ENABLE_LOGGING
906 {
907 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
908 }
909 #endif
910
912 {
913 #ifdef ENABLE_LOGGING
914
915 #ifdef DEVELOPER
916 DumpInventoryDebug();
917 #endif
918
920 {
921 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
922 }
923 #endif
924 validation.m_Result = InventoryValidationResult.FAILED;
925 return true;
926 }
927
928 validation.m_Result = InventoryValidationResult.JUNCTURE;
930 return true;
931 }
932 else
933 {
934 #ifdef ENABLE_LOGGING
936 {
937 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
938 }
939 #endif
940
941 validation.m_Result = InventoryValidationResult.FAILED;
942 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
943 return true;
944 }
945 }
946
947 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
948 {
949 ClearInventoryReservationEx(dst.GetItem(), dst);
950 }
951
953 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
954 {
955 CheckForRope(src, dst);
956 }
957
961 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
962 {
963 #ifdef ENABLE_LOGGING
964
965 #ifdef DEVELOPER
966 DumpInventoryDebug();
967 #endif
968
970 {
971 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
972 }
973 #endif
974
975 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
976 return true;
977 }
978
979 //TODO: hotfix solution
980 if (!validation.m_IsRemote && validation.m_IsJuncture && !MoveCheckExclusionMaskLocal(src,dst))
981 {
982 #ifdef ENABLE_LOGGING
984 {
985 Debug.InventoryMoveLog("Failed - MoveCheckExclusionMaskLocal - condition failed locally", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
986 }
987 #endif
988 return false;
989 }
990
991 #ifdef ENABLE_LOGGING
993 {
994 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE" , "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString() );
995 }
996 #endif
997
998 LocationSyncMoveEntity(src, dst);
999
1000 validation.m_Result = InventoryValidationResult.SUCCESS;
1001 return true;
1002 }
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 MoveCheckExclusionMaskLocal(notnull InventoryLocation src, notnull InventoryLocation dst)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:2613
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1625
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
Определения DayZPlayerInventory.c:2466
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1610
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
Определения DayZPlayerInventory.c:2497
proto string ToString()
JunctureRequestResult
Определения Hand_Events.c:28
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Junctures.c:2
float GetTime()
Определения NotificationSystem.c:35
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
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)
Определения Inventory.c:378
const float c_MaxItemDistanceRadius
anti-cheats
Определения Inventory.c:813
script counterpart to engine's class Inventory
Определения Inventory.c:79
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
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_MaxItemDistanceRadius, CheckForRope(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), GetInstanceType(), InventoryLocation::GetItem(), GetTime(), 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(), syncDebugPrint(), ToString() и TryAcquireInventoryJunctureFromServer().

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