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

◆ ExecuteSwapCommandServer()

bool ExecuteSwapCommandServer ( inout Serializer ctx)
protected

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

3039 {
3040 DayZPlayer playerOwner = GetDayZPlayerOwner();
3042 if (!swapValidation)
3043 {
3044 return false;
3045 }
3046
3047#ifdef ENABLE_LOGGING
3049 {
3050 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", "ExecuteSwapCommandServer", playerOwner.ToString() );
3051 }
3052#endif
3053
3054 RemoveMovableOverride(swapValidation.m_SrcItem1);
3055 RemoveMovableOverride(swapValidation.m_SrcItem2);
3056
3057 if (!(swapValidation.m_Src1.IsValid() && swapValidation.m_Src2.IsValid() && swapValidation.m_Dst1.IsValid() && swapValidation.m_Dst2.IsValid()))
3058 {
3059 Error("ExecuteSwapCommandServer: 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));
3060 return true;
3061 }
3062
3063 bool hasJuncture = false;
3064 int nonNullCount = 0;
3065 bool failed = false;
3066
3067 if (swapValidation.m_SrcItem1 != null)
3068 {
3069 nonNullCount++;
3070 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem1))
3071 {
3072 failed = true;
3073 }
3074 }
3075
3076 if (!failed && swapValidation.m_SrcItem2 != null)
3077 {
3078 nonNullCount++;
3079 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_SrcItem2))
3080 {
3081 failed = true;
3082 }
3083 }
3084
3085 if (!failed && swapValidation.m_DstItem1 != null)
3086 {
3087 nonNullCount++;
3088 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem1))
3089 {
3090 failed = true;
3091 }
3092 }
3093
3094 if (!failed && swapValidation.m_DstItem2 != null)
3095 {
3096 nonNullCount++;
3097 if (!g_Game.HasInventoryJuncture(playerOwner, swapValidation.m_DstItem2))
3098 {
3099 failed = true;
3100 }
3101 }
3102
3103 hasJuncture = (nonNullCount > 0 && !failed);
3104
3105 if (!hasJuncture)
3106 {
3107#ifdef ENABLE_LOGGING
3109 {
3110 Debug.InventoryMoveLog("Failed - missing juncture", "SWAP", "n/a", "ExecuteSwapCommandServer", GetDayZPlayerOwner().ToString() );
3111 }
3112#endif
3113 swapValidation.m_Success = false;
3114 }
3115
3116 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem1);
3117 g_Game.ClearJunctureEx(playerOwner, swapValidation.m_DstItem2);
3118
3119 //TODO: hotfix solution
3120 if (!SwapCheckExclusionMaskLocal(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2))
3121 {
3122#ifdef ENABLE_LOGGING
3124 {
3125 Debug.InventoryMoveLog("Failed - !SwapCheckExclusionMaskLocal - condition failed locally", "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3126 }
3127#endif
3128 return false;
3129 }
3130
3131 if(!GameInventory.CanForceSwapEntitiesEx(swapValidation.m_SrcItem1, swapValidation.m_Dst1, swapValidation.m_SrcItem2, swapValidation.m_Dst2))
3132 {
3133#ifdef ENABLE_LOGGING
3135 {
3136 Debug.InventoryMoveLog("Failed - !CanForceSwapEntitiesEx", "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3137 }
3138#endif
3139 return false;
3140 }
3141
3142#ifdef ENABLE_LOGGING
3144 {
3145 Debug.InventoryMoveLog("Success - item swap", "SWAP" , "n/a", "ExecuteSwapCommandServer", playerOwner.ToString() );
3146 }
3147#endif
3148
3149 if (swapValidation.m_Success)
3150 {
3151 bool isNotSkipped = LocationSwap(swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2);
3152 ctx = new ScriptInputUserData();
3153 InventoryInputUserData.SerializeSwap(ctx, swapValidation.m_Src1, swapValidation.m_Src2, swapValidation.m_Dst1, swapValidation.m_Dst2, !isNotSkipped);
3154 return true;
3155 }
3156
3157 return false;
3158 }
InventoryCommandType
DayZGame g_Game
Определения DayZGame.c:4074
bool SwapCheckExclusionMaskLocal(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Local, checks only stuff that is in guaranteed sync.
Определения DayZPlayerInventory.c:4892
void RemoveMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3683
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:170
proto string ToString()
Определения 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)
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
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
static bool IsInventoryMoveLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:759
Определения gameplay.c:121
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::CanForceSwapEntitiesEx(), InventoryLocation::DumpToStringNullSafe(), Error(), g_Game, GetDayZPlayerOwner(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), InventoryLocation::IsValid(), InventoryJunctureSwapValidation::m_Dst1, InventoryJunctureSwapValidation::m_Dst2, InventoryJunctureSwapValidation::m_DstItem1, InventoryJunctureSwapValidation::m_DstItem2, InventoryJunctureSwapValidation::m_Src1, InventoryJunctureSwapValidation::m_Src2, InventoryJunctureSwapValidation::m_SrcItem1, InventoryJunctureSwapValidation::m_SrcItem2, InventoryJunctureSwapValidation::m_Success, RemoveMovableOverride(), InventoryInputUserData::SerializeSwap(), SwapCheckExclusionMaskLocal() и ToString().

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