2025-12-10 17:23:05 +03:00
|
|
|
#include "DelayUpdateSerializedClassManager.hpp"
|
2025-12-18 23:37:37 +03:00
|
|
|
#include <chrono>
|
2025-12-10 17:23:05 +03:00
|
|
|
|
|
|
|
|
namespace NetworkingObjects {
|
2025-12-18 23:37:37 +03:00
|
|
|
void DelayUpdateSerializedClassManager::update(NetworkingObjects::NetObjManager& netObjMan) {
|
|
|
|
|
for(auto& [objID, updatingObj] : updatingObjs) {
|
|
|
|
|
if(updatingObj.lastTemporaryUpdateTimePoint.has_value() && (std::chrono::steady_clock::now() - updatingObj.lastTemporaryUpdateTimePoint.value()) >= std::chrono::milliseconds(300)) {
|
|
|
|
|
updatingObj.sendFinalUpdate();
|
|
|
|
|
updatingObj.lastTemporaryUpdateTimePoint = std::nullopt;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-10 17:23:05 +03:00
|
|
|
std::erase_if(updatingObjs, [](auto& updatingPair) {
|
2025-12-18 23:37:37 +03:00
|
|
|
if((std::chrono::steady_clock::now() - updatingPair.second.lastUpdateTimePoint) >= std::chrono::seconds(3) && !updatingPair.second.lastTemporaryUpdateTimePoint.has_value()) {
|
2025-12-10 17:23:05 +03:00
|
|
|
updatingPair.second.setDataAfterTimeout();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|