Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
actionmanagerserver.c
Go to the documentation of this file.
1class ActionManagerServer: ActionManagerBase
2{
4 ref ActionReciveData m_PendingActionReciveData;
5
11
12 //------------------------------------------
13 //EVENTS
14 //------------------------------------------
15 override void OnJumpStart()
16 {
18 }
19
21 {
23 {
25 {
28 }
29 else
30 {
31 m_CurrentActionData.m_Action.Interrupt(m_CurrentActionData);
32 }
33 }
34 }
35
36 override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
37 {
38 switch (userDataType)
39 {
41 {
42 bool success = true;
43
44 int actionID = 0;
45 if (!ctx.Read(actionID))
46 return false;
47
48 ActionBase recvAction = GetAction(actionID);
49 if (!recvAction)
50 return false;
51
52 if (!recvAction.ReadFromContext(ctx, m_PendingActionReciveData))
53 success = false;
54
55 m_PendingAction = recvAction;
56
57 if (recvAction.UseAcknowledgment())
58 {
59 int ackID;
60 if (!ctx.Read(ackID))
61 success = false;
62
64 }
65
66 break;
67
68 }
69
71 {
72 //Debug.Log("Action want end request, STS = " + m_Player.GetSimulationTimeStamp());
73 int commandID = -10;
74 ctx.Read(commandID);
75
76 if (commandID == DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT)
77 {
78 //Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | CMD_ACTIONINT_INTERRUPT");
80 }
81 else
82 {
83 //Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | m_ActionWantEndRequest");
85 }
86 }
87
89 {
90 //Debug.Log("Action input ended, STS = " + m_Player.GetSimulationTimeStamp());
92 }
93 default:
94 return false;
95 }
96
97 if (!success)
98 {
99 //Debug.Log("[AM] OnInputUserDataProcess INPUT_UDT_STANDARD_ACTION_START Error");
100 if (recvAction.UseAcknowledgment())
101 {
102 DayZPlayerSyncJunctures.SendActionAcknowledgment(m_Player, m_PendingActionAcknowledgmentID, false);
103 }
104 else
105 {
107 }
108
109 return false;
110 }
111 return true;
112
113 }
114
115 override void StartDeliveredAction()
116 {
118 {
120 return;
121 }
122
123 m_Interrupted = false;
124
125 bool accepted = false;
126 ActionBase pickedAction = m_CurrentActionData.m_Action;
127 ActionTarget target = m_CurrentActionData.m_Target;
128 ItemBase item = m_CurrentActionData.m_MainItem;
129
130 if (LogManager.IsActionLogEnable())
131 {
132 if (target)
133 {
134 Debug.ActionLog("Item = " + item + ", " + target.DumpToString(), pickedAction.ToString() , "n/a", "DeliveredAction", m_Player.ToString());
135 }
136 else
137 {
138 Debug.ActionLog("Item = " + item + ", NULL", pickedAction.ToString() , "n/a", "DeliveredAction", m_Player.ToString());
139 }
140 }
141
142 if (!m_Player.GetCommandModifier_Action() && !m_Player.GetCommand_Action() && !m_Player.IsSprinting() && pickedAction && pickedAction.Can(m_Player,target,item))
143 {
144 if (pickedAction.AddActionJuncture(m_CurrentActionData))
145 accepted = true;
146 }
147
148 if (accepted)
149 {
150 if (LogManager.IsActionLogEnable())
151 {
152 Debug.ActionLog("Action accepted", pickedAction.ToString() , "n/a", "CheckDeliveredAction", m_Player.ToString() );
153 }
154 //Debug.Log("[AM] Action acccepted");
155 if (pickedAction.UseAcknowledgment())
156 {
157 //Unlock target
160 }
161 else
162 {
164 }
165 }
166 else
167 {
168 if (LogManager.IsActionLogEnable())
169 {
170 Debug.ActionLog("Action rejected", pickedAction.ToString() , "n/a", "CheckDeliveredAction", m_Player.ToString() );
171 }
172
173 if (pickedAction.UseAcknowledgment())
174 {
175 DayZPlayerSyncJunctures.SendActionAcknowledgment(m_Player, m_PendingActionAcknowledgmentID, false);
176 }
177 else
178 {
180 }
181 }
182 }
183
184 override void OnActionEnd()
185 {
186 //Debug.Log("Action ended - hard, STS = " + m_Player.GetSimulationTimeStamp());
188 {
189 m_CurrentActionData.m_Action.ClearActionJuncture(m_CurrentActionData);
190
191 super.OnActionEnd();
192 }
193 }
194
195 //pCurrentCommandID is command ID at time of call command handler, some called methods can change actual true value (need call m_Player.GetCurrentCommandID() for actual command ID)
196 override void Update(int pCurrentCommandID)
197 {
198 super.Update(pCurrentCommandID);
199 int currentCommandID = m_Player.GetCurrentCommandID();
200
201 //Debug.Log("m_ActionWantEnd " + m_ActionInputWantEnd);
202
203 if (m_PendingAction)
204 {
206 {
207 DayZPlayerSyncJunctures.SendActionAcknowledgment(m_Player, m_PendingActionAcknowledgmentID, false);
208 }
209 else
210 {
212 m_ActionInputWantEnd = false;
213
214 bool success = true;
215 ActionTarget target = new ActionTarget(null, null, -1, vector.Zero, 0);
216
217 if ( LogManager.IsActionLogEnable() )
218 {
219 Debug.ActionLog("n/a", m_PendingAction.ToString() , "n/a", "HandlePendingAction", m_Player.ToString() );
220 }
221
223 {
224 success = false;
225 }
226 //Debug.Log("[AM] Action data synced (" + m_Player + ") success: " + success);
227
228 if (success)
229 {
231 }
232 else
233 {
235 {
236 DayZPlayerSyncJunctures.SendActionAcknowledgment(m_Player, m_PendingActionAcknowledgmentID, false);
237 }
238 else
239 {
241 }
242 }
243 }
244
245 m_PendingAction = null;
247 }
248
250 {
252 {
253 m_CurrentActionData.m_Action.OnUpdateServer(m_CurrentActionData);
254 }
255
256 //Debug.Log("m_CurrentActionData.m_State: " + m_CurrentActionData.m_State +" m_ActionWantEnd: " + m_ActionWantEndRequest );
257 switch (m_CurrentActionData.m_State)
258 {
259 case UA_AM_PENDING:
260 break;
261
262 case UA_AM_ACCEPTED:
263 // check currentCommandID before start or reject
264
265 int condition_mask = ActionBase.ComputeConditionMask(m_Player, m_CurrentActionData.m_Target, m_CurrentActionData.m_MainItem);
266 bool canActionPerform = ((condition_mask & m_CurrentActionData.m_Action.m_ConditionMask) == condition_mask);
267 if (canActionPerform && ActionPossibilityCheck(currentCommandID))
268 {
271
272 if (m_CurrentActionData.m_Action && m_CurrentActionData.m_Action.IsInstant())
273 OnActionEnd();
274 }
275 else
276 {
278 }
280 break;
281
282 case UA_AM_REJECTED:
283 OnActionEnd();
285 break;
286
287 default:
289 {
290 m_ActionInputWantEnd = false;
291 m_CurrentActionData.m_Action.EndInput(m_CurrentActionData);
292 }
293
295 {
297 m_CurrentActionData.m_Action.EndRequest(m_CurrentActionData);
298 }
299 break;
300 }
301 }
302 }
303
306 {
308 DayZPlayerSyncJunctures.SendActionInterrupt(m_Player);
309 }
310
311 override ActionReciveData GetReciveData()
312 {
314 }
315}
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Definition _constants.c:3
const int INPUT_UDT_STANDARD_ACTION_START
Definition _constants.c:2
const int INPUT_UDT_STANDARD_ACTION_INPUT_END
Definition _constants.c:4
override ActionBase GetAction()
bool m_Interrupted
ref ActionData m_CurrentActionData
bool m_ActionInputWantEnd
bool ActionPossibilityCheck(int pCurrentCommandID)
int m_PendingActionAcknowledgmentID
bool m_ActionWantEndRequest
bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
Definition actionbase.c:897
bool SetupAction(PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data=NULL)
Definition actionbase.c:156
bool UseAcknowledgment()
bool AddActionJuncture(ActionData action_data)
bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
Definition actionbase.c:493
static int ComputeConditionMask(PlayerBase player, ActionTarget target, ItemBase item)
Definition actionbase.c:843
ref ActionReciveData m_PendingActionReciveData
override ActionReciveData GetReciveData()
void ActionManagerServer(PlayerBase player)
override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
override void OnJumpStart()
override void RequestInterruptAction()
server requests action interrupt
override void StartDeliveredAction()
override void Update(int pCurrentCommandID)
override void OnActionEnd()
override void EndOrInterruptCurrentAction()
Definition debug.c:2
Serialization general interface. Serializer API works with:
Definition serializer.c:56
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
const int UA_START
Definition constants.c:469
const int UA_AM_ACCEPTED
Definition constants.c:477
const int UA_AM_REJECTED
Definition constants.c:478
const int UA_AM_PENDING
Definition constants.c:476
DayZPlayer m_Player
Definition hand_events.c:42