Started work on network object system
This commit is contained in:
parent
a2ce579b8b
commit
ed4810e6ee
12 changed files with 394 additions and 74 deletions
35
include/Helpers/NetworkingObjects/NetObjIDGenerator.hpp
Normal file
35
include/Helpers/NetworkingObjects/NetObjIDGenerator.hpp
Normal 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;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue