Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
CareerBackend.c
Go to the documentation of this file.
1
class
GameplayTrait
:
JsonApiStruct
2
{
3
protected
EProfileSkillID
m_eTraitID
;
4
protected
int
m_iTraitXP
;
5
6
void
GameplayTrait
(
EProfileSkillID
thisId,
int
n)
7
{
8
m_eTraitID
= thisId;
9
m_iTraitXP
= n;
10
11
RegV(
"m_eTraitID"
);
12
RegV(
"m_iTraitXP"
);
13
}
14
15
EProfileSkillID
GetTraitID
()
16
{
17
return
m_eTraitID
;
18
}
19
20
int
GetTraitXP
()
21
{
22
return
m_iTraitXP
;
23
}
24
25
void
AddXP
(
int
n)
26
{
27
m_iTraitXP
+=n;
28
}
29
30
#ifdef ENABLE_DIAG
31
string
toString()
32
{
33
string
toRet =
""
;
34
toRet +=
"Gameplay Trait ID is "
+
m_eTraitID
;
35
toRet+=
", XP is "
+
m_iTraitXP
;
36
return
toRet;
37
}
38
#endif
39
};
40
41
42
43
class
CareerBackendData
:
JsonApiStruct
44
{
45
protected
ref
SCR_SessionInfo
m_sessionInfo
;
46
protected
static
const
int
SESSIONS_TO_STORE
= 8;
47
48
// Backend-stored variables
49
float
m_fRank
;
50
protected
int
m_iKills
;
51
protected
int
m_iFriendlyKills
;
52
protected
int
m_iDeaths
;
53
protected
float
m_fTravelledDistance
;
54
55
protected
ref array<ref GameplayTrait>
m_aGameplayTraits
;
56
protected
ref array<ref SCR_SessionInfo>
m_aSessionInfos
;
57
58
//------------------------------------------------------------------------------------------------
59
void
AddKill
(
bool
friendly =
false
)
60
{
61
if
(friendly)
62
m_iFriendlyKills
++;
63
else
64
m_iKills
++;
65
}
66
67
//------------------------------------------------------------------------------------------------
68
void
AddDeath
()
69
{
70
m_iDeaths
++;
71
}
72
73
//------------------------------------------------------------------------------------------------
74
void
AddSkillXP
(
EProfileSkillID
skillID,
int
XP)
75
{
76
if
(skillID >= 0 && skillID <
m_aGameplayTraits
.Count())
77
m_aGameplayTraits
.Get(skillID).AddXP(XP);
78
else
79
Print
(
"CareerBackend::AddSkillXP Wrong skillID! Can't add experience to the unknown skillID: "
+skillID,
LogLevel
.ERROR);
80
}
81
82
//------------------------------------------------------------------------------------------------
83
float
GetTravelledDistance
()
84
{
85
return
m_fTravelledDistance
;
86
}
87
88
//------------------------------------------------------------------------------------------------
89
int
GetFriendlyKills
()
90
{
91
return
m_iFriendlyKills
;
92
}
93
94
//------------------------------------------------------------------------------------------------
95
int
GetKills
()
96
{
97
return
m_iKills
;
98
}
99
100
//------------------------------------------------------------------------------------------------
101
int
GetDeaths
()
102
{
103
return
m_iDeaths
;
104
}
105
106
//------------------------------------------------------------------------------------------------
107
int
GetSkillXP
(
EProfileSkillID
skillID)
108
{
109
if
(skillID >= 0 && skillID <
m_aGameplayTraits
.Count())
110
return
m_aGameplayTraits
.Get(skillID).GetTraitXP();
111
else
112
{
113
Print
(
"CareerBackend::GetSkillXP Wrong skillID!"
,
LogLevel
.ERROR);
114
return
-1;
115
}
116
}
117
118
//------------------------------------------------------------------------------------------------
119
//Called upon faction selection
120
void
SetFaction
(
string
factionKey)
121
{
122
GetSessionInfo
().
SetFactionKey
(factionKey);
123
}
124
125
//------------------------------------------------------------------------------------------------
126
//Called upon login
127
void
SetLoginTime
()
128
{
129
int
year, month, day, hour, minute, second;
130
131
System
.GetYearMonthDay(year, month, day);
132
System
.GetHourMinuteSecond(hour, minute, second);
133
134
GetSessionInfo
().
SetLoginTime
(year, month, day, hour, minute, second);
135
}
136
137
//------------------------------------------------------------------------------------------------
138
//Called upon logout
139
void
SetLogoutTime
()
140
{
141
int
year, month, day, hour, minute, second;
142
143
System
.GetYearMonthDay(year, month, day);
144
System
.GetHourMinuteSecond(hour, minute, second);
145
146
GetSessionInfo
().
SetLogoutTime
(year, month, day, hour, minute, second);
147
}
148
149
//------------------------------------------------------------------------------------------------
150
SCR_SessionInfo
GetSessionInfo
()
151
{
152
if
(!
m_sessionInfo
)
153
{
154
m_sessionInfo
=
new
SCR_SessionInfo
();
155
BackendApi
bApi =
GetGame
().GetBackendApi();
156
157
if
(bApi)
158
{
159
DSSession
session = bApi.GetDSSession();
160
161
if
(session)
162
m_sessionInfo
.SetRoomID(session.RoomID());
163
}
164
}
165
166
return
m_sessionInfo
;
167
}
168
169
//****************//
170
//OVERRIDE METHODS//
171
//****************//
172
173
//------------------------------------------------------------------------------------------------
174
override
void
OnSuccess
(
int
errorCode )
175
{
176
// Register infos array if needed, resize if it overflows max size, make sure newest data is first
177
int
sessionsCnt;
178
179
if
(!
m_aSessionInfos
)
180
m_aSessionInfos
=
new
array<ref SCR_SessionInfo>();
181
else
182
{
183
sessionsCnt =
m_aSessionInfos
.Count();
184
185
if
(sessionsCnt >=
SESSIONS_TO_STORE
)
186
{
187
m_aSessionInfos
.Resize(
SESSIONS_TO_STORE
- 1);
188
sessionsCnt =
SESSIONS_TO_STORE
- 1;
189
}
190
}
191
192
// Check m_aSessionInfos for data stored for this session
193
BackendApi
bApi =
GetGame
().GetBackendApi();
194
195
if
(bApi && sessionsCnt != 0)
196
{
197
DSSession
session = bApi.GetDSSession();
198
199
if
(session)
200
{
201
string
roomID = session.RoomID();
202
203
if
(!roomID.IsEmpty())
204
{
205
for
(
int
i = 0; i < sessionsCnt; i++)
206
{
207
SCR_SessionInfo
sessionInfo =
m_aSessionInfos
[i];
208
209
if
(!sessionInfo)
210
continue
;
211
212
if
(sessionInfo.
GetRoomID
() == roomID)
213
{
214
// Session data found - register and set as the first element
215
m_sessionInfo
= sessionInfo;
216
m_aSessionInfos
.RemoveOrdered(i);
217
m_aSessionInfos
.InsertAt(
m_sessionInfo
, 0);
218
break
;
219
}
220
}
221
}
222
}
223
}
224
225
// Session data not stored, store new instance if backend returns proper ID
226
if
(!
m_sessionInfo
)
227
{
228
SCR_SessionInfo
sessionInfo =
GetSessionInfo
();
229
230
if
(!sessionInfo.
GetRoomID
().IsEmpty())
231
m_aSessionInfos
.InsertAt(
GetSessionInfo
(), 0);
232
}
233
234
if
(!
CareerMenuUI
.
m_sInstance
)
235
return
;
236
237
if
(
CareerMenuUI
.
m_sInstance
)
238
CareerMenuUI
.
m_sInstance
.
UpdateCareerData
();
239
}
240
241
//------------------------------------------------------------------------------------------------
242
override
void
OnError
(
int
errorCode )
243
{
244
Print
(
"OnError: "
+ errorCode );
245
}
246
247
//------------------------------------------------------------------------------------------------
248
void
CareerBackendData
()
249
{
250
m_aGameplayTraits
= {};
251
252
typename
type =
EProfileSkillID
;
253
254
for
(
int
i = 0; i < type.GetVariableCount(); i++)
255
{
256
m_aGameplayTraits
.Insert(
new
GameplayTrait
(i, 0));
257
}
258
259
RegV(
"m_fRank"
);
260
RegV(
"m_iKills"
);
261
RegV(
"m_iFriendlyKills"
);
262
RegV(
"m_iDeaths"
);
263
RegV(
"m_fTravelledDistance"
);
264
265
RegV(
"m_aGameplayTraits"
);
266
RegV(
"m_aSessionInfos"
);
267
}
268
};
269
270
//------------------------------------------------------------------------------------------------
272
enum
EProfileSkillID
273
{
274
GLOBAL
,
275
WEAPON_HANDLER
,
276
DRIVER
,
277
SCOUT
,
278
OPERATOR
279
};
EProfileSkillID
EProfileSkillID
Used to identify various player skills.
Definition
CareerBackend.c:273
SCOUT
@ SCOUT
Definition
CareerBackend.c:277
WEAPON_HANDLER
@ WEAPON_HANDLER
Definition
CareerBackend.c:275
GLOBAL
@ GLOBAL
Definition
CareerBackend.c:274
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
DRIVER
SCR_CommunicationSoundComponentClass DRIVER
OPERATOR
SCR_CommunicationSoundComponentClass OPERATOR
BackendApi
Backend Api instance.
Definition
BackendApi.c:14
CareerBackendData::GetFriendlyKills
int GetFriendlyKills()
Definition
CareerBackend.c:89
CareerBackendData::m_iDeaths
int m_iDeaths
Definition
CareerBackend.c:52
CareerBackendData::GetKills
int GetKills()
Definition
CareerBackend.c:95
CareerBackendData::SetLogoutTime
void SetLogoutTime()
Definition
CareerBackend.c:139
CareerBackendData::m_sessionInfo
ref SCR_SessionInfo m_sessionInfo
Definition
CareerBackend.c:45
CareerBackendData::m_fTravelledDistance
float m_fTravelledDistance
Definition
CareerBackend.c:53
CareerBackendData::AddSkillXP
void AddSkillXP(EProfileSkillID skillID, int XP)
Definition
CareerBackend.c:74
CareerBackendData::SetLoginTime
void SetLoginTime()
Definition
CareerBackend.c:127
CareerBackendData::AddKill
void AddKill(bool friendly=false)
Definition
CareerBackend.c:59
CareerBackendData::m_aGameplayTraits
ref array< ref GameplayTrait > m_aGameplayTraits
Definition
CareerBackend.c:55
CareerBackendData::m_iFriendlyKills
int m_iFriendlyKills
Definition
CareerBackend.c:51
CareerBackendData::GetTravelledDistance
float GetTravelledDistance()
Definition
CareerBackend.c:83
CareerBackendData::CareerBackendData
void CareerBackendData()
Definition
CareerBackend.c:248
CareerBackendData::AddDeath
void AddDeath()
Definition
CareerBackend.c:68
CareerBackendData::m_aSessionInfos
ref array< ref SCR_SessionInfo > m_aSessionInfos
Definition
CareerBackend.c:56
CareerBackendData::GetDeaths
int GetDeaths()
Definition
CareerBackend.c:101
CareerBackendData::OnSuccess
override void OnSuccess(int errorCode)
Definition
CareerBackend.c:174
CareerBackendData::m_iKills
int m_iKills
Definition
CareerBackend.c:50
CareerBackendData::GetSessionInfo
SCR_SessionInfo GetSessionInfo()
Definition
CareerBackend.c:150
CareerBackendData::SetFaction
void SetFaction(string factionKey)
Definition
CareerBackend.c:120
CareerBackendData::OnError
override void OnError(int errorCode)
Definition
CareerBackend.c:242
CareerBackendData::GetSkillXP
int GetSkillXP(EProfileSkillID skillID)
Definition
CareerBackend.c:107
CareerBackendData::SESSIONS_TO_STORE
static const int SESSIONS_TO_STORE
Definition
CareerBackend.c:46
CareerBackendData::m_fRank
float m_fRank
Definition
CareerBackend.c:49
CareerMenuUI
Definition
CareerMenuUI.c:3
CareerMenuUI::UpdateCareerData
void UpdateCareerData()
Definition
CareerMenuUI.c:87
CareerMenuUI::m_sInstance
static CareerMenuUI m_sInstance
Definition
CareerMenuUI.c:28
DSSession
DS server Session.
Definition
DSSession.c:14
GameplayTrait
Definition
CareerBackend.c:2
GameplayTrait::GetTraitID
EProfileSkillID GetTraitID()
Definition
CareerBackend.c:15
GameplayTrait::GetTraitXP
int GetTraitXP()
Definition
CareerBackend.c:20
GameplayTrait::m_iTraitXP
int m_iTraitXP
Definition
CareerBackend.c:4
GameplayTrait::m_eTraitID
EProfileSkillID m_eTraitID
Definition
CareerBackend.c:3
GameplayTrait::GameplayTrait
void GameplayTrait(EProfileSkillID thisId, int n)
Definition
CareerBackend.c:6
GameplayTrait::AddXP
void AddXP(int n)
Definition
CareerBackend.c:25
JsonApiStruct
base classes for filtering in server browser
Definition
SCR_FeedbackDialogUI.c:3
SCR_SessionInfo
Definition
SCR_SessionInfo.c:2
SCR_SessionInfo::SetFactionKey
void SetFactionKey(FactionKey factionKey)
Definition
SCR_SessionInfo.c:35
SCR_SessionInfo::SetLogoutTime
void SetLogoutTime(int year, int month, int day, int hour, int minute, int second)
Definition
SCR_SessionInfo.c:66
SCR_SessionInfo::SetLoginTime
void SetLoginTime(int year, int month, int day, int hour, int minute, int second)
Definition
SCR_SessionInfo.c:47
SCR_SessionInfo::GetRoomID
string GetRoomID()
Definition
SCR_SessionInfo.c:29
System
Definition
System.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
scripts
Game
UI
Backend
CareerBackend.c
Generated by
1.17.0