| 239 | } // namespace Poseidon::Foundation |
| 240 | |
| 241 | NetworkMessageFormatBase::NetworkMessageFormatBase() = default; |
| 242 | |
| 243 | void NetworkMessageFormatBase::Init(NetworkMessageIndices* indices) |
| 244 | { |
| 245 | NET_ERROR(indices); |
| 246 | NET_ERROR(_map.NItems() == 0); |
| 247 | |
| 248 | // create _map |
| 249 | int n = _items.Size(); |
| 250 | for (int i = 0; i < n; i++) |
| 251 | { |
| 252 | const char* name = _items[i].name; |
| 253 | |
| 254 | // avoid duplicity in names |
| 255 | const NameToIndex& check = _map[name]; |
| 256 | NET_ERROR(_map.IsNull(check)); |
| 257 | |
| 258 | _map.Add(NameToIndex(name, i)); |
| 259 | } |
| 260 | |
| 261 | // scan indices |
| 262 | _indices = indices; |
| 263 | _indices->Scan(this); |
| 264 | } |
| 265 | |