Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
CareerBackend.c
Go to the documentation of this file.
2{
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
16 {
17 return m_eTraitID;
18 }
19
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
44{
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)
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 //------------------------------------------------------------------------------------------------
84 {
86 }
87
88 //------------------------------------------------------------------------------------------------
90 {
91 return m_iFriendlyKills;
92 }
93
94 //------------------------------------------------------------------------------------------------
96 {
97 return m_iKills;
98 }
99
100 //------------------------------------------------------------------------------------------------
102 {
103 return m_iDeaths;
104 }
105
106 //------------------------------------------------------------------------------------------------
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
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
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 //------------------------------------------------------------------------------------------------
151 {
152 if (!m_sessionInfo)
153 {
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 {
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
235 return;
236
239 }
240
241 //------------------------------------------------------------------------------------------------
242 override void OnError( int errorCode )
243 {
244 Print("OnError: " + errorCode );
245 }
246
247 //------------------------------------------------------------------------------------------------
249 {
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//------------------------------------------------------------------------------------------------
EProfileSkillID
Used to identify various player skills.
@ SCOUT
@ WEAPON_HANDLER
@ GLOBAL
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_CommunicationSoundComponentClass DRIVER
SCR_CommunicationSoundComponentClass OPERATOR
Backend Api instance.
Definition BackendApi.c:14
ref SCR_SessionInfo m_sessionInfo
void AddSkillXP(EProfileSkillID skillID, int XP)
void AddKill(bool friendly=false)
ref array< ref GameplayTrait > m_aGameplayTraits
float GetTravelledDistance()
ref array< ref SCR_SessionInfo > m_aSessionInfos
override void OnSuccess(int errorCode)
SCR_SessionInfo GetSessionInfo()
void SetFaction(string factionKey)
override void OnError(int errorCode)
int GetSkillXP(EProfileSkillID skillID)
static const int SESSIONS_TO_STORE
void UpdateCareerData()
static CareerMenuUI m_sInstance
DS server Session.
Definition DSSession.c:14
EProfileSkillID GetTraitID()
EProfileSkillID m_eTraitID
void GameplayTrait(EProfileSkillID thisId, int n)
void AddXP(int n)
base classes for filtering in server browser
void SetFactionKey(FactionKey factionKey)
void SetLogoutTime(int year, int month, int day, int hour, int minute, int second)
void SetLoginTime(int year, int month, int day, int hour, int minute, int second)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14