Started work on network object system

This commit is contained in:
Yousef Khadadeh 2025-12-06 14:16:50 +03:00
parent a2ce579b8b
commit ed4810e6ee
12 changed files with 394 additions and 74 deletions

View file

@ -0,0 +1,35 @@
#pragma once
#include <cstdint>
#include "../Hashes.hpp"
namespace NetworkingObjects {
struct NetObjID {
typedef uint16_t ClientPortion;
typedef uint64_t ObjectPortion;
ClientPortion clientID = 0;
ObjectPortion objID = 0;
bool operator==(const NetObjID&) const = default;
template <typename Archive> void serialize(Archive& a) {
a(clientID, objID);
}
};
class NetObjIDGenerator {
public:
void set_starting_id(NetObjID c);
NetObjID gen();
private:
NetObjID currentID;
};
}
template <> struct std::hash<NetworkingObjects::NetObjID> {
size_t operator()(const NetworkingObjects::NetObjID& v) const
{
uint64_t h = 0;
hash_combine(h, v.clientID, v.objID);
return h;
}
};