Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_GameModeEndData.c
Go to the documentation of this file.
1
5{
6 private int m_iEndReason;
7
8 private ref array<int> m_aWinnerIds = {};
9 private ref array<int> m_aWinnerFactionIds = {};
10
14 static SCR_GameModeEndData CreateSimple(EGameOverTypes reason = EGameOverTypes.ENDREASON_UNDEFINED, int winnerId = -1, int winnerFactionId = -1)
15 {
17 data.m_iEndReason = reason;
18
19 if (winnerId > -1)
20 {
21 data.m_aWinnerIds.Clear();
22 data.m_aWinnerIds.Insert(winnerId);
23 }
24
25 if (winnerFactionId > -1)
26 {
27 data.m_aWinnerFactionIds.Clear();
28 data.m_aWinnerFactionIds.Insert(winnerFactionId);
29 }
30 return data;
31 }
32
36 static SCR_GameModeEndData Create(EGameOverTypes reason = EGameOverTypes.ENDREASON_UNDEFINED, array<int> winnerIds = null, array<int> winnerFactionIds = null)
37 {
39 data.m_iEndReason = reason;
40
41 if (winnerIds)
42 {
43 for (int i = 0, cnt = winnerIds.Count(); i < cnt; i++)
44 data.m_aWinnerIds.Insert(winnerIds[i]);
45 }
46
47 if (winnerFactionIds)
48 {
49 for (int i = 0, cnt = winnerFactionIds.Count(); i < cnt; i++)
50 data.m_aWinnerFactionIds.Insert(winnerFactionIds[i]);
51 }
52
53 return data;
54 }
55
67 int GetEndReason()
68 {
69 return m_iEndReason;
70 }
71
76 int GetWinnerId()
77 {
78 if (m_aWinnerIds && m_aWinnerIds.Count() > 0)
79 return m_aWinnerIds[0];
80
81 return -1;
82 }
83
87 void GetWinnerIds(out notnull array<int> winnerIds)
88 {
89 winnerIds.Clear();
90 for (int i = 0, cnt = m_aWinnerIds.Count(); i < cnt; i++)
91 winnerIds.Insert(m_aWinnerIds[i]);
92 }
93
98 int GetWinnerFactionId()
99 {
100 if (m_aWinnerFactionIds && m_aWinnerFactionIds.Count() > 0)
101 return m_aWinnerFactionIds[0];
102
103 return -1;
104 }
105
109 void GetFactionWinnerIds(out notnull array<int> winnerIds)
110 {
111 winnerIds.Clear();
112 for (int i = 0, cnt = m_aWinnerFactionIds.Count(); i < cnt; i++)
113 winnerIds.Insert(m_aWinnerFactionIds[i]);
114 }
115
116 //------------------------------------------------------------------------------------------------
117 static bool Extract(SCR_GameModeEndData prop, ScriptCtx hint, SSnapSerializerBase snapshot)
118 {
119 snapshot.SerializeInt(prop.m_iEndReason);
120
121 int winnerCount = prop.m_aWinnerIds.Count();
122 snapshot.SerializeInt(winnerCount);
123 for (int i = 0; i < winnerCount; i++)
124 {
125 int id = prop.m_aWinnerIds[i];
126 snapshot.SerializeInt(id);
127 }
128
129 int factionWinnerCount = prop.m_aWinnerFactionIds.Count();
130 snapshot.SerializeInt(factionWinnerCount);
131 for (int i = 0; i < factionWinnerCount; i++)
132 {
133 int id = prop.m_aWinnerFactionIds[i];
134 snapshot.SerializeInt(id);
135 }
136
137 return true;
138 }
139
140 //------------------------------------------------------------------------------------------------
141 static bool Inject(SSnapSerializerBase snapshot, ScriptCtx hint, SCR_GameModeEndData prop)
142 {
143 snapshot.SerializeInt(prop.m_iEndReason);
144
145 int winnerCount;
146 snapshot.SerializeInt(winnerCount);
147
148 int tmp;
149 prop.m_aWinnerIds.Clear();
150 for (int i = 0; i < winnerCount; i++)
151 {
152 snapshot.SerializeInt(tmp);
153 prop.m_aWinnerIds.Insert(tmp);
154 }
155
156 int winnerFactionCount;
157 snapshot.SerializeInt(winnerFactionCount);
158
159 prop.m_aWinnerFactionIds.Clear();
160 for (int i = 0; i < winnerFactionCount; i++)
161 {
162 snapshot.SerializeInt(tmp);
163 prop.m_aWinnerFactionIds.Insert(tmp);
164 }
165
166 return true;
167 }
168
169 //------------------------------------------------------------------------------------------------
170 static void Encode(SSnapSerializerBase snapshot, ScriptCtx hint, ScriptBitSerializer packet)
171 {
172 int endReason;
173 snapshot.SerializeBytes(endReason, 4);
174 packet.Serialize(endReason, 32);
175
176 int tmp;
177
178 int winnerCount;
179 snapshot.SerializeBytes(winnerCount, 4);
180 packet.Serialize(winnerCount, 32);
181
182 for (int i = 0; i < winnerCount; i++)
183 {
184 snapshot.SerializeBytes(tmp, 4);
185 packet.Serialize(tmp, 32);
186
187 }
188
189 int factionWinnerCount;
190 snapshot.SerializeBytes(factionWinnerCount, 4);
191 packet.Serialize(factionWinnerCount, 32);
192
193 for (int i = 0; i < factionWinnerCount; i++)
194 {
195 snapshot.SerializeBytes(tmp, 4);
196 packet.Serialize(tmp, 32);
197 }
198 }
199
200 //------------------------------------------------------------------------------------------------
201 static bool Decode(ScriptBitSerializer packet, ScriptCtx hint, SSnapSerializerBase snapshot)
202 {
203 // How many int do i .Decode() ?
204 int endReason;
205 packet.Serialize(endReason, 32);
206 snapshot.SerializeBytes(endReason, 4);
207
208 int winnerCount;
209 packet.Serialize(winnerCount, 32);
210 snapshot.SerializeBytes(winnerCount, 4);
211
212 int tmp;
213 for (int i = 0; i < winnerCount; i++)
214 {
215 packet.Serialize(tmp, 32);
216 snapshot.SerializeBytes(tmp, 4);
217 }
218
219 int factionWinnerCount;
220 packet.Serialize(factionWinnerCount, 32);
221 snapshot.SerializeBytes(factionWinnerCount, 4);
222 for (int i = 0; i < factionWinnerCount; i++)
223 {
224 packet.Serialize(tmp, 32);
225 snapshot.SerializeBytes(tmp, 4);
226 }
227
228 return true;
229 }
230
231 //------------------------------------------------------------------------------------------------
232 static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx hint)
233 {
234 int lhsReason;
235 lhs.SerializeInt(lhsReason);
236
237 int rhsReason;
238 rhs.SerializeInt(rhsReason);
239
240 if (lhsReason != rhsReason)
241 return false;
242
243 // array 1
244 int lCnt;
245 lhs.SerializeInt(lCnt);
246
247 int rCnt;
248 rhs.SerializeInt(rCnt);
249
250 if (lCnt != rCnt)
251 return false;
252
253 int lTmp;
254 int rTmp;
255 for (int i = 0; i < lCnt; i++)
256 {
257 lhs.SerializeInt(lTmp);
258 rhs.SerializeInt(rTmp);
259 if (lTmp != rTmp)
260 return false;
261 }
262
263 // array 2
264 lhs.SerializeInt(lCnt);
265 rhs.SerializeInt(rCnt);
266
267 if (lCnt != rCnt)
268 return false;
269
270 for (int i = 0; i < lCnt; i++)
271 {
272 lhs.SerializeInt(lTmp);
273 rhs.SerializeInt(rTmp);
274 if (lTmp != rTmp)
275 return false;
276 }
277
278 return true;
279 }
280
281 //------------------------------------------------------------------------------------------------
282 static bool PropCompare(SCR_GameModeEndData prop, SSnapSerializerBase snapshot, ScriptCtx hint)
283 {
284 if (!snapshot.CompareInt(prop.m_iEndReason))
285 return false;
286
287 int winnerCount = prop.m_aWinnerIds.Count();
288 if (!snapshot.CompareInt(winnerCount))
289 return false;
290
291 for (int i = 0; i < winnerCount; i++)
292 {
293 if (!snapshot.CompareInt(prop.m_aWinnerIds[i]))
294 return false;
295 }
296
297 int winnerFactionCount = prop.m_aWinnerFactionIds.Count();
298 if (!snapshot.CompareInt(winnerFactionCount))
299 return false;
300
301 for (int i = 0; i < winnerFactionCount; i++)
302 {
303 if (!snapshot.CompareInt(prop.m_aWinnerFactionIds[i]))
304 return false;
305 }
306
307 return true;
308 }
309};
EGameOverTypes
Get all prefabs that have the spawner data