6 private int m_iEndReason;
8 private ref array<int> m_aWinnerIds = {};
9 private ref array<int> m_aWinnerFactionIds = {};
17 data.m_iEndReason = reason;
21 data.m_aWinnerIds.Clear();
22 data.m_aWinnerIds.Insert(winnerId);
25 if (winnerFactionId > -1)
27 data.m_aWinnerFactionIds.Clear();
28 data.m_aWinnerFactionIds.Insert(winnerFactionId);
39 data.m_iEndReason = reason;
43 for (
int i = 0, cnt = winnerIds.Count(); i < cnt; i++)
44 data.m_aWinnerIds.Insert(winnerIds[i]);
49 for (
int i = 0, cnt = winnerFactionIds.Count(); i < cnt; i++)
50 data.m_aWinnerFactionIds.Insert(winnerFactionIds[i]);
78 if (m_aWinnerIds && m_aWinnerIds.Count() > 0)
79 return m_aWinnerIds[0];
87 void GetWinnerIds(out notnull array<int> winnerIds)
90 for (
int i = 0, cnt = m_aWinnerIds.Count(); i < cnt; i++)
91 winnerIds.Insert(m_aWinnerIds[i]);
98 int GetWinnerFactionId()
100 if (m_aWinnerFactionIds && m_aWinnerFactionIds.Count() > 0)
101 return m_aWinnerFactionIds[0];
109 void GetFactionWinnerIds(out notnull array<int> winnerIds)
112 for (
int i = 0, cnt = m_aWinnerFactionIds.Count(); i < cnt; i++)
113 winnerIds.Insert(m_aWinnerFactionIds[i]);
117 static bool Extract(
SCR_GameModeEndData prop, ScriptCtx hint, SSnapSerializerBase snapshot)
119 snapshot.SerializeInt(prop.m_iEndReason);
121 int winnerCount = prop.m_aWinnerIds.Count();
122 snapshot.SerializeInt(winnerCount);
123 for (
int i = 0; i < winnerCount; i++)
125 int id = prop.m_aWinnerIds[i];
126 snapshot.SerializeInt(
id);
129 int factionWinnerCount = prop.m_aWinnerFactionIds.Count();
130 snapshot.SerializeInt(factionWinnerCount);
131 for (
int i = 0; i < factionWinnerCount; i++)
133 int id = prop.m_aWinnerFactionIds[i];
134 snapshot.SerializeInt(
id);
143 snapshot.SerializeInt(prop.m_iEndReason);
146 snapshot.SerializeInt(winnerCount);
149 prop.m_aWinnerIds.Clear();
150 for (
int i = 0; i < winnerCount; i++)
152 snapshot.SerializeInt(tmp);
153 prop.m_aWinnerIds.Insert(tmp);
156 int winnerFactionCount;
157 snapshot.SerializeInt(winnerFactionCount);
159 prop.m_aWinnerFactionIds.Clear();
160 for (
int i = 0; i < winnerFactionCount; i++)
162 snapshot.SerializeInt(tmp);
163 prop.m_aWinnerFactionIds.Insert(tmp);
170 static void Encode(SSnapSerializerBase snapshot, ScriptCtx hint, ScriptBitSerializer packet)
173 snapshot.SerializeBytes(endReason, 4);
174 packet.Serialize(endReason, 32);
179 snapshot.SerializeBytes(winnerCount, 4);
180 packet.Serialize(winnerCount, 32);
182 for (
int i = 0; i < winnerCount; i++)
184 snapshot.SerializeBytes(tmp, 4);
185 packet.Serialize(tmp, 32);
189 int factionWinnerCount;
190 snapshot.SerializeBytes(factionWinnerCount, 4);
191 packet.Serialize(factionWinnerCount, 32);
193 for (
int i = 0; i < factionWinnerCount; i++)
195 snapshot.SerializeBytes(tmp, 4);
196 packet.Serialize(tmp, 32);
201 static bool Decode(ScriptBitSerializer packet, ScriptCtx hint, SSnapSerializerBase snapshot)
205 packet.Serialize(endReason, 32);
206 snapshot.SerializeBytes(endReason, 4);
209 packet.Serialize(winnerCount, 32);
210 snapshot.SerializeBytes(winnerCount, 4);
213 for (
int i = 0; i < winnerCount; i++)
215 packet.Serialize(tmp, 32);
216 snapshot.SerializeBytes(tmp, 4);
219 int factionWinnerCount;
220 packet.Serialize(factionWinnerCount, 32);
221 snapshot.SerializeBytes(factionWinnerCount, 4);
222 for (
int i = 0; i < factionWinnerCount; i++)
224 packet.Serialize(tmp, 32);
225 snapshot.SerializeBytes(tmp, 4);
232 static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx hint)
235 lhs.SerializeInt(lhsReason);
238 rhs.SerializeInt(rhsReason);
240 if (lhsReason != rhsReason)
245 lhs.SerializeInt(lCnt);
248 rhs.SerializeInt(rCnt);
255 for (
int i = 0; i < lCnt; i++)
257 lhs.SerializeInt(lTmp);
258 rhs.SerializeInt(rTmp);
264 lhs.SerializeInt(lCnt);
265 rhs.SerializeInt(rCnt);
270 for (
int i = 0; i < lCnt; i++)
272 lhs.SerializeInt(lTmp);
273 rhs.SerializeInt(rTmp);
282 static bool PropCompare(
SCR_GameModeEndData prop, SSnapSerializerBase snapshot, ScriptCtx hint)
284 if (!snapshot.CompareInt(prop.m_iEndReason))
287 int winnerCount = prop.m_aWinnerIds.Count();
288 if (!snapshot.CompareInt(winnerCount))
291 for (
int i = 0; i < winnerCount; i++)
293 if (!snapshot.CompareInt(prop.m_aWinnerIds[i]))
297 int winnerFactionCount = prop.m_aWinnerFactionIds.Count();
298 if (!snapshot.CompareInt(winnerFactionCount))
301 for (
int i = 0; i < winnerFactionCount; i++)
303 if (!snapshot.CompareInt(prop.m_aWinnerFactionIds[i]))