DayZ 1.27
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
1032 #ifdef ENABLE_LOGGING
1034 {
1035 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1036 }
1037 #endif
1038
1039 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
1040
1041 return true;
1042 }
1043
1045 if (itemSrc)
1046 RemoveMovableOverride(itemSrc);
1047 if (itemDst)
1048 RemoveMovableOverride(itemDst);
1049
1053 if (success && !validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
1054 {
1055 #ifdef ENABLE_LOGGING
1057 {
1058 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1059 }
1060 #endif
1061
1062 if (!validation.m_IsRemote)
1063 {
1064 ctx = new ScriptInputUserData;
1066 }
1067
1068 RemoveMovableOverride(itemSrc);
1069 RemoveMovableOverride(itemDst);
1070
1071 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1072 {
1073 success = false;
1074 }
1075 else
1076 {
1077 return true;
1078 }
1079 }
1080
1081 if (success && !e.CheckRequestEx(validation))
1082 {
1083 #ifdef ENABLE_LOGGING
1085 {
1086 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1087 }
1088 #endif
1089
1091
1092 ctx = new ScriptInputUserData;
1094
1095#ifdef ENABLE_LOGGING
1097 {
1098 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
1099 }
1100#endif
1101
1102 RemoveMovableOverride(itemSrc);
1103 RemoveMovableOverride(itemDst);
1104
1105 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1106 {
1107 success = false;
1108 }
1109 else
1110 {
1111 return true;
1112 }
1113 }
1114
1117 if (success && !validation.m_IsRemote && !e.CanPerformEventEx(validation))
1118 {
1119 #ifdef ENABLE_LOGGING
1121 {
1122 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1123 }
1124 #endif
1125
1127
1128 ctx = new ScriptInputUserData;
1130
1131#ifdef ENABLE_LOGGING
1133 {
1134 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
1135 }
1136#endif
1137
1138 RemoveMovableOverride(itemSrc);
1139 RemoveMovableOverride(itemDst);
1140
1141 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1142 {
1143 success = false;
1144 }
1145 else
1146 {
1147 return true;
1148 }
1149 }
1150
1151 RemoveMovableOverride(itemSrc);
1152 RemoveMovableOverride(itemDst);
1153
1155 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1156 {
1158 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1159 {
1160 #ifdef ENABLE_LOGGING
1162 {
1163 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1164 }
1165 #endif
1166
1168 }
1169 else if (success && result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
1170 {
1171 #ifdef ENABLE_LOGGING
1173 {
1174 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1175 }
1176 #endif
1177
1178 ctx = new ScriptInputUserData;
1180
1181 validation.m_Result = InventoryValidationResult.JUNCTURE;
1182
1183 if (itemSrc)
1184 EnableMovableOverride(itemSrc);
1185 if (itemDst)
1186 EnableMovableOverride(itemDst);
1187 return true;
1188 }
1189 else
1190 {
1191 #ifdef ENABLE_LOGGING
1193 {
1194 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1195 }
1196 #endif
1197
1198 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1199 return true;
1200 }
1201 }
1202
1204 if (success && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1205 {
1206 CheckForRope(e.GetSrc(), e.GetDst());
1207 }
1208
1209 #ifdef ENABLE_LOGGING
1211 {
1212 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT" , "n/a", "ProcessInputData", e.m_Player.ToString() );
1213 }
1214 #endif
1215
1216 if (success)
1217 {
1218 validation.m_Result = InventoryValidationResult.SUCCESS;
1219 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1220 {
1222 //result = InventoryValidationResult.FAILURE;
1223 }
1224 }
1225
1226 return true;
1227 }
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
void CheckForRope(InventoryLocation src, InventoryLocation dst)
Определения DayZPlayerInventory.c:1625
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1610
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
JunctureRequestResult
Определения Hand_Events.c:28
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
Определения Building.c:6
override InventoryLocation GetDst()
Определения Hand_Events.c:212
override bool AcquireInventoryJunctureFromServer(notnull Man player)
Определения Hand_Events.c:257
override EntityAI GetSecondSrcEntity()
Определения Hand_Events.c:574
override string DumpToString()
Определения Hand_Events.c:332
override void ClearInventoryReservation()
Определения Hand_Events.c:671
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
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
Определения 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(), 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().