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

◆ ValidateHandEvent()

bool ValidateHandEvent ( inout Serializer ctx,
InventoryValidation validation )
protected

Pass partial information to guards so guards can do minimal checks if needed The guards can't prevent event so it would be incorrect to pass full InventoryValidation struct. We have to make sure guards don't inadvertantly produce different results in the FSM as that will create desync (two players attempting to put a rag into the same fireplace slot at the same time)

kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote

TODO(kumarjac): Is this one correct to be 'RemoveMovableOverride' or are the other Validate methdos wrong with 'EnableMovableOverride'?

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

'HandEventBase.CheckRequestEx' updates failure reason

if it already happened on server, remote just needs to comply TODO(kumarjac): Move m_IsRemote check to inside of HandEventBase.CanPerformEventEx

'HandEventBase.CanPerformEventEx' updates failure reason

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

Is called twice unfortunately... but it works so won't change

TODO(kumarjac): We should probably set the result to failure like so

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

1005 {
1007 bool success = true;
1008
1009 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1011
1015 e.m_IsRemote = validation.m_IsRemote;
1016 e.m_IsJuncture = validation.m_IsJuncture;
1017
1018 EntityAI itemSrc = e.GetSrcEntity();
1019 EntityAI itemDst = e.GetSecondSrcEntity();
1020
1021 #ifdef ENABLE_LOGGING
1023 {
1024 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1025 }
1026 #endif
1027
1028 if (validation.m_IsRemote && !e.GetSrcEntity())
1029 {
1031 if (itemDst && (e.GetEventID() == HandEventID.SWAP || e.GetEventID() == HandEventID.FORCESWAP)) //presumed swap, replace with take
1032 {
1033 InventoryLocation srcNew = new InventoryLocation();
1034 srcNew.Copy(e.GetSrc());
1035 e = HandEventBase.HandEventFactory(HandEventID.TAKE, e.m_Player, srcNew);
1036
1037 Error("[syncinv] HandleInputData remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.DumpToString() + "), src item is null! Continuing.");
1038 }
1039 else
1040 {
1041 #ifdef ENABLE_LOGGING
1043 {
1044 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1045 }
1046 #endif
1047
1048 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1049
1050 return true;
1051 }
1052 }
1053
1055 if (itemSrc)
1056 RemoveMovableOverride(itemSrc);
1057 if (itemDst)
1058 RemoveMovableOverride(itemDst);
1059
1063 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1064 {
1065 #ifdef ENABLE_LOGGING
1067 {
1068 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1069 }
1070 #endif
1071
1072 if (!validation.m_IsRemote)
1073 {
1074 ctx = new ScriptInputUserData;
1076 }
1077
1078 RemoveMovableOverride(itemSrc);
1079 RemoveMovableOverride(itemDst);
1080
1081 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1082 {
1083 success = false;
1084 }
1085 else
1086 {
1087 return true;
1088 }
1089 }
1090
1091 if (success && !e.CheckRequestEx(validation))
1092 {
1093 #ifdef ENABLE_LOGGING
1095 {
1096 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1097 }
1098 #endif
1099
1101
1102 ctx = new ScriptInputUserData;
1104
1105#ifdef ENABLE_LOGGING
1107 {
1108 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1109 }
1110#endif
1111
1112 RemoveMovableOverride(itemSrc);
1113 RemoveMovableOverride(itemDst);
1114
1115 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1116 {
1117 success = false;
1118 }
1119 else
1120 {
1121 return true;
1122 }
1123 }
1124
1127 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1128 {
1129 #ifdef ENABLE_LOGGING
1131 {
1132 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1133 }
1134 #endif
1135
1137
1138 ctx = new ScriptInputUserData;
1140
1141#ifdef ENABLE_LOGGING
1143 {
1144 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1145 }
1146#endif
1147
1148 RemoveMovableOverride(itemSrc);
1149 RemoveMovableOverride(itemDst);
1150
1151 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1152 {
1153 success = false;
1154 }
1155 else
1156 {
1157 return true;
1158 }
1159 }
1160
1161 RemoveMovableOverride(itemSrc);
1162 RemoveMovableOverride(itemDst);
1163
1165 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1166 {
1168 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1169 {
1170 #ifdef ENABLE_LOGGING
1172 {
1173 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1174 }
1175 #endif
1176
1178 }
1179 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1180 {
1181 #ifdef ENABLE_LOGGING
1183 {
1184 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1185 }
1186 #endif
1187
1188 ctx = new ScriptInputUserData;
1190
1191 validation.m_Result = InventoryValidationResult.JUNCTURE;
1192
1193 if (itemSrc)
1194 EnableMovableOverride(itemSrc);
1195 if (itemDst)
1196 EnableMovableOverride(itemDst);
1197 return true;
1198 }
1199 else
1200 {
1201 #ifdef ENABLE_LOGGING
1203 {
1204 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1205 }
1206 #endif
1207
1208 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1209 return true;
1210 }
1211 }
1212
1214 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1215 {
1216 CheckForRope(e.GetSrc(), e.GetDst());
1217 }
1218
1219 #ifdef ENABLE_LOGGING
1221 {
1222 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1223 }
1224 #endif
1225
1226 if (success)
1227 {
1228 validation.m_Result = InventoryValidationResult.SUCCESS;
1229 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1230 {
1232 //result = InventoryValidationResult.FAILURE;
1233 }
1234 }
1235
1236 return true;
1237 }
void syncDebugPrint(string s)
Определения 3_Game/Systems/Inventory/Debug.c:1
InventoryCommandType
InventoryValidationResult
InventoryValidationReason
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1627
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1635
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1620
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
JunctureRequestResult
Определения Hand_Events.c:28
HandEventID
events
Определения Hand_Events.c:7
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
override InventoryLocation GetDst()
Определения Hand_Events.c:212
override bool AcquireInventoryJunctureFromServer(notnull Man player)
Определения Hand_Events.c:257
override EntityAI GetSecondSrcEntity()
Определения Hand_Events.c:600
override string DumpToString()
Определения Hand_Events.c:332
override void ClearInventoryReservation()
Определения Hand_Events.c:697
override bool CheckRequestSrc()
Определения Hand_Events.c:219
override bool CanPerformEventEx(InventoryValidation validation)
Определения Hand_Events.c:235
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:209
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
Определения InventoryInputUserData.c:72
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another 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()
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки HandEventBase::AcquireInventoryJunctureFromServer(), HandEventBase::CanPerformEventEx(), CheckForRope(), HandEventBase::CheckRequestSrc(), HandEventBase::ClearInventoryReservation(), InventoryLocation::Copy(), HandEventBase::DumpToString(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), HandEventBase::GetDst(), GetInstanceType(), HandEventBase::GetSecondSrcEntity(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), LogManager::IsSyncLogEnable(), InventoryValidation::m_IsJuncture, InventoryValidation::m_IsRemote, InventoryValidation::m_Reason, InventoryValidation::m_Result, RemoveMovableOverride(), InventoryInputUserData::SerializeHandEvent() и syncDebugPrint().

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