@@ -25,10 +25,10 @@ namespace Network
2525 struct NetFields
2626 {
2727 using Meta = typename EnumTraits<TEnum>::Meta;
28- static constexpr u16 NumFields = static_cast <u16 >(Meta::EnumList .size());
28+ static constexpr u16 NUM_FIELDS = static_cast <u16 >(Meta::ENUM_FIELD_LIST .size());
2929
3030 public:
31- static_assert (NumFields > 0 , " NumFields must be greater than zero." );
31+ static_assert (NUM_FIELDS > 0 , " NUM_FIELDS must be greater than zero." );
3232
3333 template <typename T> requires std::is_trivially_copyable_v<std::decay_t <T>>
3434 void SetField (TEnum startField, T&& value, u8 fieldByteOffset = 0 , u8 fieldBitOffset = 0 , u8 bitCount = sizeof (std::decay_t <T>) * 8)
@@ -53,7 +53,7 @@ namespace Network
5353
5454 u16 startFieldIndex = static_cast <u16 >(startField);
5555 constexpr u16 numFieldsTouched = (sizeof (DecayedT) + fieldSize - 1 ) / fieldSize;
56- NC_ASSERT (startFieldIndex + numFieldsTouched <= NumFields , " Attempting to Set NetField out of bounds" );
56+ NC_ASSERT (startFieldIndex + numFieldsTouched <= NUM_FIELDS , " Attempting to Set NetField out of bounds" );
5757
5858 std::byte* base = reinterpret_cast <std::byte*>(fields);
5959 std::byte* dest = base + (startFieldIndex * fieldSize) + fieldByteOffset;
@@ -99,7 +99,7 @@ namespace Network
9999 constexpr u16 fieldBits = fieldSize * 8 ;
100100
101101 const u16 startFieldIndex = static_cast <u16 >(startField);
102- NC_ASSERT (startFieldIndex < NumFields , " Start field index out of bounds." );
102+ NC_ASSERT (startFieldIndex < NUM_FIELDS , " Start field index out of bounds." );
103103
104104 const std::byte* base = reinterpret_cast <const std::byte*>(fields);
105105 const std::byte* src = base + (startFieldIndex * fieldSize) + fieldByteOffset;
@@ -109,7 +109,7 @@ namespace Network
109109 {
110110 // Multi-field or full-field read
111111 NC_ASSERT (fieldByteOffset == 0 && fieldBitOffset == 0 , " Byte/Bit offsets only allowed for partial reads." );
112- NC_ASSERT (startFieldIndex + ((typeSize + fieldSize - 1 ) / fieldSize) <= NumFields , " Read exceeds field range." );
112+ NC_ASSERT (startFieldIndex + ((typeSize + fieldSize - 1 ) / fieldSize) <= NUM_FIELDS , " Read exceeds field range." );
113113
114114 T result;
115115 std::memcpy (&result, src, sizeof (T));
@@ -146,15 +146,15 @@ namespace Network
146146 T* GetFieldPtr (TEnum startField)
147147 {
148148 u16 startFieldIndex = static_cast <u16 >(startField);
149- NC_ASSERT (startFieldIndex < NumFields , " Start field index out of bounds." );
149+ NC_ASSERT (startFieldIndex < NUM_FIELDS , " Start field index out of bounds." );
150150
151151 T* ptr = reinterpret_cast <T*>(&fields[startFieldIndex]);
152152 return ptr;
153153 }
154154
155155 bool SerializeSetFields (Bytebuffer* buffer)
156156 {
157- constexpr u16 NumMaskQwords = (FieldMaskSize + 7 ) / 8 ;
157+ constexpr u16 NumMaskQwords = (FIELD_MASK_SIZE + 7 ) / 8 ;
158158
159159 const u64 * mask64 = reinterpret_cast <const u64 *>(setFieldMask);
160160 const u16 lastQwordIndex = NumMaskQwords - 1 ;
@@ -180,7 +180,7 @@ namespace Network
180180
181181 const u16 startByte = firstQword * 8 ;
182182 const u16 endByte = (lastQword + 1 ) * 8 ;
183- const u16 maskCount = (endByte > FieldMaskSize ? FieldMaskSize : endByte) - startByte;
183+ const u16 maskCount = (endByte > FIELD_MASK_SIZE ? FIELD_MASK_SIZE : endByte) - startByte;
184184
185185 // Header: start byte | number of mask bytes written
186186 buffer->PutU8 (static_cast <u8 >(startByte));
@@ -192,7 +192,7 @@ namespace Network
192192 // Process 64-bit chunks for set bits
193193 const u16 startBlock = startByte * 8 ;
194194 const u16 endBlock = endByte * 8 ;
195- const u16 limit = (endBlock > NumFields ) ? NumFields : endBlock;
195+ const u16 limit = (endBlock > NUM_FIELDS ) ? NUM_FIELDS : endBlock;
196196
197197 for (u16 q = firstQword; q <= lastQword; ++q)
198198 {
@@ -224,7 +224,7 @@ namespace Network
224224 if (!isDirty)
225225 return false ;
226226
227- constexpr u16 NumMaskQwords = (FieldMaskSize + 7 ) / 8 ;
227+ constexpr u16 NumMaskQwords = (FIELD_MASK_SIZE + 7 ) / 8 ;
228228
229229 const u64 * mask64 = reinterpret_cast <const u64 *>(dirtyFieldMask);
230230 const u16 lastQwordIndex = NumMaskQwords - 1 ;
@@ -251,7 +251,7 @@ namespace Network
251251
252252 const u16 startByte = firstQword * 8 ;
253253 const u16 endByte = (lastQword + 1 ) * 8 ;
254- const u16 maskCount = (endByte > FieldMaskSize ? FieldMaskSize : endByte) - startByte;
254+ const u16 maskCount = (endByte > FIELD_MASK_SIZE ? FIELD_MASK_SIZE : endByte) - startByte;
255255
256256 // Header: start byte | number of mask bytes written
257257 buffer->PutU8 (static_cast <u8 >(startByte));
@@ -263,7 +263,7 @@ namespace Network
263263 // Process 64-bit chunks for dirty bits
264264 const u16 startBlock = startByte * 8 ;
265265 const u16 endBlock = endByte * 8 ;
266- const u16 limit = (endBlock > NumFields ) ? NumFields : endBlock;
266+ const u16 limit = (endBlock > NUM_FIELDS ) ? NUM_FIELDS : endBlock;
267267
268268 for (u16 q = firstQword; q <= lastQword; ++q)
269269 {
@@ -294,7 +294,7 @@ namespace Network
294294 void SetFieldsDirty (TEnum startField, u16 numFields = 1 )
295295 {
296296 u16 startFieldIndex = static_cast <u16 >(startField);
297- if (startFieldIndex + numFields > NumFields )
297+ if (startFieldIndex + numFields > NUM_FIELDS )
298298 return ;
299299
300300 const u16 startByte = startFieldIndex / 8 ;
@@ -339,12 +339,12 @@ namespace Network
339339 }
340340
341341 public:
342- static constexpr u16 FieldMaskSize = (NumFields + 7 ) / 8 ;
342+ static constexpr u16 FIELD_MASK_SIZE = (NUM_FIELDS + 7 ) / 8 ;
343343
344344 // Fields are stored as a 4 byte integer array, however dirtymask is stored as a byte array where one bit refers to 1 field
345- u32 fields[NumFields ];
346- u8 setFieldMask[FieldMaskSize ];
347- u8 dirtyFieldMask[FieldMaskSize ];
345+ u32 fields[NUM_FIELDS ];
346+ u8 setFieldMask[FIELD_MASK_SIZE ];
347+ u8 dirtyFieldMask[FIELD_MASK_SIZE ];
348348 bool isDirty = false ;
349349 };
350350
0 commit comments