Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
EnNetwork.c
Go to the documentation of this file.
1/*
2// Example: Custom codec functions.
3// This allows using CustomClass instances as arguments of RPCs or as replicated properties marked with
4// RplProp attribute.
5class CustomClass
6{
8 static void Encode(SSnapSerializerBase snapshot, ScriptCtx ctx, ScriptBitSerializer packet);
11 static bool Decode(ScriptBitSerializer packet, ScriptCtx ctx, SSnapSerializerBase snapshot);
12
14 static bool SnapCompare(SSnapSerializerBase lhs, SSnapSerializerBase rhs, ScriptCtx ctx);
16 //! Compares instance against snapshot. Returns true when they match or false otherwise.
17 static bool PropCompare(CustomClass instance, SSnapSerializerBase snapshot, ScriptCtx ctx);
18
20 static bool Extract(CustomClass instance, ScriptCtx ctx, SSnapSerializerBase snapshot);
23 static bool Inject(SSnapSerializerBase snapshot, ScriptCtx ctx, CustomClass instance);
25*/
26
32typedef int RplIdentity;
33typedef int RplId;
34
35class ScriptCtx : Managed
36{
37}
38
39//! Property groups that allow for replication of only part of the object.
40//! \deprecated Will be removed in the future (as-if all uses were RplGroup.Mandatory).
41[Obsolete()]
42enum RplGroup
43{
44 Mandatory,
45 Group_1,
46 Group_2,
47 Group_3,
48 Group_4,
49 Group_5,
50 Group_6,
51}
52
53
54Property annotation attribute. Use to enable property replication on Entities and components.
55*/
56class RplProp: UniqueAttribute
57{
58 RplGroup m_Group;
59 RplCondition m_Condition;
60 string m_CustomCondName;
61 string m_OnRplName;
62 ScriptCtx m_pCtx;
63
64 void RplProp(RplGroup group = RplGroup.Mandatory,
65 string onRplName = "",
66 ScriptCtx ctx = NULL,
67 RplCondition condition = RplCondition.None,
68 string customConditionName = "")
69 {
70 m_Group = group;
71 m_OnRplName = onRplName;
72 m_pCtx = ctx;
73 m_Condition = condition;
74 m_CustomCondName = customConditionName;
75 if (m_Group != RplGroup.Mandatory)
76 {
77 Print("Specifying 'group' in RplProp is deprecated and will be removed, along with RplGroup enum.", level: LogLevel.WARNING);
78 m_Group = RplGroup.Mandatory;
79 }
80 }
81}
82
83
94
95 void RplRpc(RplChannel channel,
96 RplRcver rcver,
97 RplCondition condition = RplCondition.None,
98 string customConditionName = "")
99 {
100 m_Channel = channel;
101 m_Rcver = rcver;
102 m_Condition = condition;
103 m_CustomCondName = customConditionName;
104 }
105}
106
107
114class OnRpl
115{
116}
117
118class RplBeforeInjected: UniqueAttribute
119{
120}
121
122class RplBeforeExtracted: UniqueAttribute
123{
124}
125
126class ScriptBitWriter : Managed
127{
129 proto void Write(void src, int sizeInBits);
134 proto void WriteRplId(RplId val);
139 proto void WriteEntityId(EntityID val);
146 proto void WriteInt(int val);
153 proto void WriteIntRange(int val, int min, int max);
159 proto void WriteHalf(float val);
164 proto void WriteFloat01(float val);
169 proto void WriteRadian(float val);
174 proto void WriteQuaternion(float val[4]);
181 proto void WriteString(string val);
183 proto native int Tell();
184
185 //----------------------------------------------------------------------------
186 // Helper functions for built-in types.
187 // They are safe defaults but they might use more bits than necessary.
188
189 void WriteBool(bool val) { Write(val, 1); }
190 void WriteFloat(float val) { Write(val, 32); }
192 {
193 // 3 values * 32-bits each = 96
194 Write(val, 96);
195 }
196}
197
198class ScriptBitReader : Managed
199{
201 proto bool Read(out void dst, int sizeInBits);
203 proto bool ReadRplId(out RplId val);
205 proto bool ReadEntityId(out EntityID val);
207 proto bool ReadInt(out int val);
209 proto bool ReadIntRange(out int val, int min, int max);
211 proto bool ReadHalf(out float val);
213 proto bool ReadFloat01(out float val);
215 proto bool ReadRadian(out float val);
217 proto bool ReadQuaternion(out float val[4]);
219 proto bool ReadResourceName(out ResourceName val);
221 proto bool ReadString(out string val);
223 proto native int Tell();
224
225 //----------------------------------------------------------------------------
226 // Helper functions for built-in types.
227 // They are safe defaults but they might use more bits than necessary.
228
229 bool ReadBool(out bool val) { return Read(val, 1); }
230 bool ReadFloat(out float val) { return Read(val, 32); }
231 bool ReadVector(out vector val)
232 {
233 // 3 values * 32-bits each = 96
234 return Read(val, 96);
235 }
236}
237
238class ScriptBitSerializer : Managed
239{
241 proto bool Serialize(inout void data, int sizeInBits);
242 proto bool SerializeRplId(inout RplId val);
243 proto bool SerializeEntityId(inout EntityID val);
244 proto bool SerializeInt(inout int val);
245 proto bool SerializeIntRange(inout int val, int min, int max);
246 proto bool SerializeHalf(inout float val);
247 proto bool SerializeFloat01(inout float val);
248 proto bool SerializeRadian(inout float val);
249 proto bool SerializeQuaternion(inout float val[4]);
250 proto bool SerializeResourceName(inout ResourceName val);
251 proto bool SerializeString(inout string val);
253 proto native int Tell();
254
255 //----------------------------------------------------------------------------
256 // Helper functions for built-in types.
257 // They are safe defaults but they might use more bits than necessary.
258
259 bool SerializeBool(inout bool val) { return Serialize(val, 1); }
260 bool SerializeFloat(inout float val) { return Serialize(val, 32); }
261 bool SerializeVector(inout vector val)
262 {
263 // 3 values * 32-bits each = 96
264 return Serialize(val, 96);
265 }
266}
267
268class SSnapSerializerBase: Managed
269{
271 proto void SerializeBytes(inout void data, int sizeInBytes);
272
273 void SerializeBool(inout bool val) { SerializeBytes(val, 4); }
274 void SerializeInt(inout int val) { SerializeBytes(val, 4); }
275 void SerializeFloat(inout float val) { SerializeBytes(val, 4); }
276 void SerializeVector(inout vector val) { SerializeBytes(val, 12); }
277 proto void SerializeString(inout string val);
278
279 bool EncodeBool(ScriptBitSerializer packet)
280 {
281 bool val;
282 this.SerializeBytes(val, 4);
283 packet.Serialize(val, 1);
284 return val;
285 }
286 bool DecodeBool(ScriptBitSerializer packet)
287 {
288 bool val;
289 packet.Serialize(val, 1);
290 this.SerializeBytes(val, 4);
291 return val;
292 }
293
294 int EncodeInt(ScriptBitSerializer packet)
295 {
296 int val;
297 this.SerializeBytes(val, 4);
298 packet.Serialize(val, 32);
299 return val;
300 }
301 int DecodeInt(ScriptBitSerializer packet)
302 {
303 int val;
304 packet.Serialize(val, 32);
305 this.SerializeBytes(val, 4);
306 return val;
307 }
308
309 float EncodeFloat(ScriptBitSerializer packet)
310 {
311 float val;
312 this.SerializeBytes(val, 4);
313 packet.Serialize(val, 32);
314 return val;
315 }
316 float DecodeFloat(ScriptBitSerializer packet)
317 {
318 float val;
319 packet.Serialize(val, 32);
320 this.SerializeBytes(val, 4);
321 return val;
322 }
323
324 vector EncodeVector(ScriptBitSerializer packet)
325 {
326 vector val;
327 this.SerializeBytes(val, 12);
328 packet.Serialize(val, 96);
329 return val;
330 }
331 vector DecodeVector(ScriptBitSerializer packet)
332 {
333 vector val;
334 packet.Serialize(val, 96);
335 this.SerializeBytes(val, 12);
336 return val;
337 }
338
339 proto void EncodeString(ScriptBitSerializer packet);
340 proto void DecodeString(ScriptBitSerializer packet);
341
346 proto native bool Serialize(ScriptBitSerializer serializer, int sizeInBytes);
347
349 proto native int Tell();
350
355 proto bool Compare(void data, int sizeInBytes);
356 bool CompareBool(bool val) { return Compare(val, 4); }
357 bool CompareInt(int val) { return Compare(val, 4); }
358 bool CompareFloat(float val) { return Compare(val, 4); }
359 bool CompareVector(vector val) { return Compare(val, 12); }
360 proto bool CompareString(string val);
361
366 proto native bool CompareSnapshots(SSnapSerializerBase snapshot, int sizeInBytes);
367 proto bool CompareStringSnapshots(SSnapSerializerBase snapshot);
368
369 private void SSnapSerializerBase();
370 private void ~SSnapSerializerBase();
371}
372
374class SSnapshot : Managed
375{
376 void SSnapshot(int sizeInBytes);
377}
378
380class SSnapSerializer : SSnapSerializerBase
381{
383 proto static ref SSnapSerializer MakeWriter(SSnapshot snap);
385 proto static ref SSnapSerializer MakeReader(SSnapshot snap);
387 proto native int Seek(int posInBytes);
388}
389
SCR_AIGroupSettingsComponentClass m_Group
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
Get all prefabs that have the spawner data
SCR_VONRadialDisplay Compare
proto bool Write(void value_out)
proto bool Read(void value_in)
Replication item identifier.
Definition RplId.c:14
Replication connection identity.
Definition RplIdentity.c:14
Snapshot serializer utility.
Definition EnNetwork.c:381
@ NULL
Unknown type.
Definition DataVarType.c:21
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
SSnapSerializerBase Managed SSnapshot(int sizeInBytes)
Binary data container used in conjuction with a serializer.
ScriptBitReader Managed Serialize(inout void data, int sizeInBits)
Serializes the data pointer. The size is the amount of bits serialized.
bool SerializeFloat(inout float val)
Definition EnNetwork.c:260
void WriteFloat(float val)
Definition EnNetwork.c:190
proto bool SerializeString(inout string val)
proto bool SerializeHalf(inout float val)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplCondition
Conditional replication rule. Fine grained selection of receivers.
proto void WriteInt(int val)
proto void WriteIntRange(int val, int min, int max)
RplRcver
Definition RplRcver.c:59
proto bool SerializeResourceName(inout ResourceName val)
proto bool SerializeRadian(inout float val)
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
int RplId
Definition EnNetwork.c:33
bool SerializeBool(inout bool val)
Definition EnNetwork.c:259
proto bool SerializeInt(inout int val)
Definition EnNetwork.c:4
proto bool SerializeRplId(inout RplId val)
proto void WriteResourceName(ResourceName val)
proto void WriteFloat01(float val)
proto bool SerializeFloat01(inout float val)
proto bool SerializeQuaternion(inout float val[4])
bool SerializeVector(inout vector val)
Definition EnNetwork.c:261
proto void WriteRplId(RplId val)
proto void WriteHalf(float val)
proto bool SerializeIntRange(inout int val, int min, int max)
proto native int Tell()
Returns the current position in internal storage in bits.
proto void WriteEntityId(EntityID val)
proto void WriteString(string val)
Writes a string to internal storage.
proto void WriteRadian(float val)
void WriteBool(bool val)
Definition EnNetwork.c:189
void WriteVector(vector val)
Definition EnNetwork.c:191
RplRcver m_Rcver
Definition EnNetwork.c:91
proto void WriteQuaternion(float val[4])
ScriptCtx Managed Obsolete()] enum RplGroup
Definition EnNetwork.c:41
RplCondition m_Condition
Definition EnNetwork.c:92
RplProp m_Channel
string m_CustomCondName
Definition EnNetwork.c:93
proto bool SerializeEntityId(inout EntityID val)