Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
actionmanagerserver.c
Go to the documentation of this file.
1
class
ActionManagerServer
:
ActionManagerBase
2
{
3
protected
ActionBase
m_PendingAction
;
4
ref ActionReciveData
m_PendingActionReciveData
;
5
6
void
ActionManagerServer
(
PlayerBase
player)
7
{
8
m_PendingAction
= null;
9
m_PendingActionReciveData
= null;
10
}
11
12
//------------------------------------------
13
//EVENTS
14
//------------------------------------------
15
override
void
OnJumpStart
()
16
{
17
EndOrInterruptCurrentAction
();
18
}
19
20
override
void
EndOrInterruptCurrentAction
()
21
{
22
if
(
m_CurrentActionData
)
23
{
24
if
(
m_CurrentActionData
.m_State ==
UA_AM_PENDING
||
m_CurrentActionData
.m_State ==
UA_AM_REJECTED
||
m_CurrentActionData
.m_State ==
UA_AM_ACCEPTED
)
25
{
26
OnActionEnd
();
27
m_PendingActionAcknowledgmentID
= -1;
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
{
40
case
INPUT_UDT_STANDARD_ACTION_START
:
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
63
m_PendingActionAcknowledgmentID
= ackID;
64
}
65
66
break
;
67
68
}
69
70
case
INPUT_UDT_STANDARD_ACTION_END_REQUEST
:
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");
79
RequestInterruptAction
();
80
}
81
else
82
{
83
//Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | m_ActionWantEndRequest");
84
m_ActionWantEndRequest
=
true
;
85
}
86
}
87
88
case
INPUT_UDT_STANDARD_ACTION_INPUT_END
:
89
{
90
//Debug.Log("Action input ended, STS = " + m_Player.GetSimulationTimeStamp());
91
m_ActionInputWantEnd
=
true
;
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
{
106
RequestInterruptAction
();
107
}
108
109
return
false
;
110
}
111
return
true
;
112
113
}
114
115
override
void
StartDeliveredAction
()
116
{
117
if
(!
m_CurrentActionData
)
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
158
m_CurrentActionData
.m_State =
UA_AM_PENDING
;
159
DayZPlayerSyncJunctures
.
SendActionAcknowledgment
(
m_Player
,
m_PendingActionAcknowledgmentID
,
true
);
160
}
161
else
162
{
163
m_CurrentActionData
.m_State =
UA_AM_ACCEPTED
;
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
{
179
RequestInterruptAction
();
180
}
181
}
182
}
183
184
override
void
OnActionEnd
()
185
{
186
//Debug.Log("Action ended - hard, STS = " + m_Player.GetSimulationTimeStamp());
187
if
(
m_CurrentActionData
)
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
{
205
if
(
m_CurrentActionData
)
206
{
207
DayZPlayerSyncJunctures
.
SendActionAcknowledgment
(
m_Player
,
m_PendingActionAcknowledgmentID
,
false
);
208
}
209
else
210
{
211
m_ActionWantEndRequest
=
false
;
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
222
if
(!
m_PendingAction
.SetupAction(
m_Player
,target,
m_Player
.GetItemInHands(),
m_CurrentActionData
))
223
{
224
success =
false
;
225
}
226
//Debug.Log("[AM] Action data synced (" + m_Player + ") success: " + success);
227
228
if
(success)
229
{
230
StartDeliveredAction
();
231
}
232
else
233
{
234
if
(
m_PendingAction
.UseAcknowledgment())
235
{
236
DayZPlayerSyncJunctures
.
SendActionAcknowledgment
(
m_Player
,
m_PendingActionAcknowledgmentID
,
false
);
237
}
238
else
239
{
240
RequestInterruptAction
();
241
}
242
}
243
}
244
245
m_PendingAction
= null;
246
m_PendingActionReciveData
= null;
247
}
248
249
if
(
m_CurrentActionData
)
250
{
251
if
(
m_CurrentActionData
.m_State !=
UA_AM_PENDING
&&
m_CurrentActionData
.m_State !=
UA_AM_REJECTED
&&
m_CurrentActionData
.m_State !=
UA_AM_ACCEPTED
)
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
{
269
m_CurrentActionData
.m_State =
UA_START
;
270
m_CurrentActionData
.m_Action.Start(
m_CurrentActionData
);
271
272
if
(
m_CurrentActionData
.m_Action &&
m_CurrentActionData
.m_Action.IsInstant())
273
OnActionEnd
();
274
}
275
else
276
{
277
RequestInterruptAction
();
278
}
279
m_PendingActionAcknowledgmentID
= -1;
280
break
;
281
282
case
UA_AM_REJECTED
:
283
OnActionEnd
();
284
m_PendingActionAcknowledgmentID
= -1;
285
break
;
286
287
default
:
288
if
(
m_ActionInputWantEnd
)
289
{
290
m_ActionInputWantEnd
=
false
;
291
m_CurrentActionData
.m_Action.EndInput(
m_CurrentActionData
);
292
}
293
294
if
(
m_ActionWantEndRequest
)
295
{
296
m_ActionWantEndRequest
=
false
;
297
m_CurrentActionData
.m_Action.EndRequest(
m_CurrentActionData
);
298
}
299
break
;
300
}
301
}
302
}
303
305
override
void
RequestInterruptAction
()
306
{
307
if
(
m_CurrentActionData
)
308
DayZPlayerSyncJunctures
.
SendActionInterrupt
(
m_Player
);
309
}
310
311
override
ActionReciveData
GetReciveData
()
312
{
313
return
m_PendingActionReciveData
;
314
}
315
}
INPUT_UDT_STANDARD_ACTION_END_REQUEST
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Definition
_constants.c:3
INPUT_UDT_STANDARD_ACTION_START
const int INPUT_UDT_STANDARD_ACTION_START
Definition
_constants.c:2
INPUT_UDT_STANDARD_ACTION_INPUT_END
const int INPUT_UDT_STANDARD_ACTION_INPUT_END
Definition
_constants.c:4
GetAction
override ActionBase GetAction()
Definition
actioninput.c:483
m_Interrupted
bool m_Interrupted
Definition
actionmanagerbase.c:49
m_CurrentActionData
ref ActionData m_CurrentActionData
Definition
actionmanagerbase.c:61
m_ActionInputWantEnd
bool m_ActionInputWantEnd
Definition
actionmanagerbase.c:53
ActionPossibilityCheck
bool ActionPossibilityCheck(int pCurrentCommandID)
Definition
actionmanagerbase.c:244
ActionManagerBase
void ActionManagerBase(PlayerBase player)
Definition
actionmanagerbase.c:63
m_PendingActionAcknowledgmentID
int m_PendingActionAcknowledgmentID
Definition
actionmanagerbase.c:59
m_ActionWantEndRequest
bool m_ActionWantEndRequest
Definition
actionmanagerbase.c:52
ActionTarget
class ActionTargets ActionTarget
m_Player
map m_Player
ActionBase
Definition
actionbase.c:59
ActionBase::UseAcknowledgment
bool UseAcknowledgment()
Definition
actionbase.c:1146
ActionBase::ComputeConditionMask
static int ComputeConditionMask(PlayerBase player, ActionTarget target, ItemBase item)
Definition
actionbase.c:819
ActionBase::Can
bool Can(PlayerBase player, ActionTarget target, ItemBase item, int condition_mask)
Definition
actionbase.c:873
ActionBase::ReadFromContext
bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
Definition
actionbase.c:494
ActionBase::AddActionJuncture
bool AddActionJuncture(ActionData action_data)
Definition
actionbase.c:1075
ActionManagerServer::m_PendingAction
ActionBase m_PendingAction
Definition
actionmanagerserver.c:3
ActionManagerServer::OnInputUserDataProcess
override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
Definition
actionmanagerserver.c:36
ActionManagerServer::OnActionEnd
override void OnActionEnd()
Definition
actionmanagerserver.c:184
ActionManagerServer::Update
override void Update(int pCurrentCommandID)
Definition
actionmanagerserver.c:196
ActionManagerServer::GetReciveData
override ActionReciveData GetReciveData()
Definition
actionmanagerserver.c:311
ActionManagerServer::EndOrInterruptCurrentAction
override void EndOrInterruptCurrentAction()
Definition
actionmanagerserver.c:20
ActionManagerServer::m_PendingActionReciveData
ref ActionReciveData m_PendingActionReciveData
Definition
actionmanagerserver.c:4
ActionManagerServer::ActionManagerServer
void ActionManagerServer(PlayerBase player)
Definition
actionmanagerserver.c:6
ActionManagerServer::StartDeliveredAction
override void StartDeliveredAction()
Definition
actionmanagerserver.c:115
ActionManagerServer::OnJumpStart
override void OnJumpStart()
Definition
actionmanagerserver.c:15
ActionManagerServer::RequestInterruptAction
override void RequestInterruptAction()
server requests action interrupt
Definition
actionmanagerserver.c:305
DayZPlayerSyncJunctures
Definition
dayzplayersyncjunctures.c:5
DayZPlayerSyncJunctures::SendActionAcknowledgment
static void SendActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
Action Acknowledgment.
Definition
dayzplayersyncjunctures.c:280
DayZPlayerSyncJunctures::SendActionInterrupt
static void SendActionInterrupt(DayZPlayer pPlayer)
Action interrupt.
Definition
dayzplayersyncjunctures.c:265
Debug
Definition
debug.c:2
Debug::ActionLog
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition
debug.c:187
ItemBase
Definition
inventoryitem.c:742
LogManager
Definition
debug.c:692
LogManager::IsActionLogEnable
static bool IsActionLogEnable()
Definition
debug.c:736
PlayerBase
Definition
playerbaseclient.c:2
Serializer::Read
proto bool Read(void value_in)
vector
Definition
enconvert.c:119
vector::Zero
static const vector Zero
Definition
enconvert.c:123
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition
dayzplayer.c:602
ParamsReadContext
Serializer ParamsReadContext
Definition
gameplay.c:15
UA_START
const int UA_START
Definition
constants.c:472
UA_AM_ACCEPTED
const int UA_AM_ACCEPTED
Definition
constants.c:480
UA_AM_REJECTED
const int UA_AM_REJECTED
Definition
constants.c:481
UA_AM_PENDING
const int UA_AM_PENDING
Definition
constants.c:479
Games
Dayz
scripts
4_world
classes
useractionscomponent
actionmanagerserver.c
Generated by
1.17.0