Removed temporary update commits

This commit is contained in:
Yousef Khadadeh 2025-07-31 09:34:17 +03:00
parent d19b5c4cb0
commit ed3d5f6d51
25 changed files with 125 additions and 163 deletions

View file

@ -203,14 +203,7 @@ MainServer::MainServer(World& initWorld, const std::string& serverLocalID):
if(it != data.idToComponentMap.end()) {
std::shared_ptr<DrawComponent>& comp = it->second;
message(*comp);
if(isTemp) {
comp->server_send_update_temp(*this, idToUpdate);
data.updateComponentTimers[idToUpdate] = std::chrono::steady_clock::now();
}
else {
comp->server_send_update_final(*this, idToUpdate);
data.updateComponentTimers.erase(idToUpdate);
}
comp->server_send_update(*this, idToUpdate);
}
});
netServer->add_recv_callback(SERVER_RESOURCE_INIT, [&](std::shared_ptr<NetServer::ClientData> client, cereal::PortableBinaryInputArchive& message) {
@ -309,13 +302,6 @@ void MainServer::ensure_display_name_unique(std::string& displayName) {
void MainServer::update() {
netServer->update();
std::erase_if(data.updateComponentTimers, [&](auto& c) {
auto& [id, timer] = c;
auto it = data.idToComponentMap.find(id);
if(it == data.idToComponentMap.end())
return true;
return it->second->server_update(*this, id, timer);
});
if(std::chrono::steady_clock::now() - lastKeepAliveSent > std::chrono::seconds(2)) {
netServer->send_items_to_all_clients(UNRELIABLE_COMMAND_CHANNEL, CLIENT_KEEP_ALIVE);
lastKeepAliveSent = std::chrono::steady_clock::now();