Added sync code to client ordered list

This commit is contained in:
Yousef Khadadeh 2025-12-09 13:00:38 +03:00
parent c51b7e7eb1
commit 9649135f43
16 changed files with 233 additions and 143 deletions

View file

@ -20,7 +20,7 @@ namespace NetworkingObjects {
{}
template <typename T> NetObjPtr<T>& NetObjPtr<T>::operator=(const NetObjPtr<T>& other) {
if(this != &other) {
if(sharedPtr && sharedPtr.unique())
if(sharedPtr && sharedPtr.use_count() == 2)
objMan->objectData.erase(id);
objMan = other.objMan;
id = other.id;
@ -29,7 +29,7 @@ namespace NetworkingObjects {
return *this;
}
template <typename T> NetObjPtr<T>::~NetObjPtr() {
if(sharedPtr && sharedPtr.unique())
if(sharedPtr && sharedPtr.use_count() == 2)
objMan->objectData.erase(id);
}
@ -90,9 +90,8 @@ namespace NetworkingObjects {
}
template <typename T> void NetObjPtr<T>::write_create_message(cereal::PortableBinaryOutputArchive& a) const {
auto& typeIndexData = objMan->isServer ? objMan->typeList->typeIndexDataServer[std::type_index(typeid(T*))] : objMan->typeList->typeIndexDataClient[std::type_index(typeid(T*))];
a(id, typeIndexData.netTypeID);
typeIndexData.writeConstructorFunc(this->cast<void>(), a);
a(id);
objMan->typeList->get_type_index_data<T>(objMan->isServer).writeConstructorFunc(this->cast<void>(), a);
}
template <typename T> NetObjPtr<T>::NetObjPtr(NetObjManager* initObjMan, NetObjID initID, const std::shared_ptr<T>& initPtr):