From 1f1b6055e42c7685522e41d87bb1fd46d20e9e2c Mon Sep 17 00:00:00 2001 From: Robbe Bryssinck Date: Sat, 12 Mar 2022 17:22:20 +0100 Subject: [PATCH] fix: permanent fix for waiting spawn --- Code/client/Services/CharacterService.h | 1 - .../Services/Generic/CharacterService.cpp | 22 +++++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Code/client/Services/CharacterService.h b/Code/client/Services/CharacterService.h index a15872213..93c897d31 100644 --- a/Code/client/Services/CharacterService.h +++ b/Code/client/Services/CharacterService.h @@ -70,7 +70,6 @@ struct CharacterService void RunRemoteUpdates() const noexcept; void RunFactionsUpdates() const noexcept; void RunSpawnUpdates() const noexcept; - void RunWaitingUpdates() const noexcept; World& m_world; entt::dispatcher& m_dispatcher; diff --git a/Code/client/Services/Generic/CharacterService.cpp b/Code/client/Services/Generic/CharacterService.cpp index 1dd31ed8f..2abecd0ef 100644 --- a/Code/client/Services/Generic/CharacterService.cpp +++ b/Code/client/Services/Generic/CharacterService.cpp @@ -154,7 +154,6 @@ void CharacterService::OnUpdate(const UpdateEvent& acUpdateEvent) noexcept RunLocalUpdates(); RunFactionsUpdates(); RunRemoteUpdates(); - RunWaitingUpdates(); } void CharacterService::OnConnected(const ConnectedEvent& acConnectedEvent) const noexcept @@ -895,21 +894,6 @@ void CharacterService::RunRemoteUpdates() const noexcept FaceGenSystem::Update(m_world, pActor, faceGenComponent); } -} - -void CharacterService::RunWaitingUpdates() const noexcept -{ - // TODO: there's a bug here sometimes, WaitingFor3D keeps getting added, SetInventory and others get spammed (#64) - // ask cosi for a repro - // temporary fix is having a delay between check for waiting - static std::chrono::steady_clock::time_point lastWaitingSpawnTime; - constexpr auto cDelay= 250ms; - - const auto now = std::chrono::steady_clock::now(); - if (now - lastWaitingSpawnTime < cDelay) - return; - - lastWaitingSpawnTime = now; auto waitingView = m_world.view(); @@ -938,7 +922,11 @@ void CharacterService::RunWaitingUpdates() const noexcept } for (auto entity : toRemove) - m_world.remove(entity); + { + // TODO: this used to be remove(), but this didn't work. + // Maybe check if other remove() instances are also compromised? + m_world.erase(entity); + } } void CharacterService::RunFactionsUpdates() const noexcept