Skip to content

Commit

Permalink
fix: permanent fix for waiting spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Mar 12, 2022
1 parent 9c4e697 commit 1f1b605
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion Code/client/Services/CharacterService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 5 additions & 17 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ void CharacterService::OnUpdate(const UpdateEvent& acUpdateEvent) noexcept
RunLocalUpdates();
RunFactionsUpdates();
RunRemoteUpdates();
RunWaitingUpdates();
}

void CharacterService::OnConnected(const ConnectedEvent& acConnectedEvent) const noexcept
Expand Down Expand Up @@ -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<FormIdComponent, RemoteComponent, WaitingFor3D>();

Expand Down Expand Up @@ -938,7 +922,11 @@ void CharacterService::RunWaitingUpdates() const noexcept
}

for (auto entity : toRemove)
m_world.remove<WaitingFor3D>(entity);
{
// TODO: this used to be remove(), but this didn't work.
// Maybe check if other remove() instances are also compromised?
m_world.erase<WaitingFor3D>(entity);
}
}

void CharacterService::RunFactionsUpdates() const noexcept
Expand Down

0 comments on commit 1f1b605

Please sign in to comment.