Skip to content

Commit

Permalink
fix: double applying of RemoteComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed May 29, 2022
1 parent 2ca9a43 commit c6bf19c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ void CharacterService::OnAssignCharacter(const AssignCharacterResponse& acMessag
}

// This code path triggers when the character has been spawned through CharacterSpawnRequest
// TODO(cosideci): since I check for WaitingForAssignmentComponent now, this path shouldn't ever trigger
if (m_world.any_of<LocalComponent, RemoteComponent>(cEntity))
{
Actor* pActor = Cast<Actor>(TESForm::GetById(formIdComponent->Id));
Expand All @@ -311,7 +312,7 @@ void CharacterService::OnAssignCharacter(const AssignCharacterResponse& acMessag
if (pActor->actorState.IsWeaponDrawn() != acMessage.IsWeaponDrawn)
m_weaponDrawUpdates[formIdComponent->Id] = {0, acMessage.IsWeaponDrawn};

spdlog::info("Applied updates on assignment response, form id: {:X}", formIdComponent->Id);
spdlog::critical("Applied updates on assignment response, form id: {:X}", formIdComponent->Id);

return;
}
Expand Down Expand Up @@ -405,6 +406,18 @@ void CharacterService::OnCharacterSpawn(const CharacterSpawnRequest& acMessage)
}
else
{
auto waitingView = m_world.view<FormIdComponent, WaitingForAssignmentComponent>();
const auto waitingItor = std::find_if(std::begin(waitingView), std::end(waitingView), [waitingView, Id = acMessage.FormId](auto entity)
{
return waitingView.get<FormIdComponent>(entity).Id == Id;
});

if (waitingItor != std::end(waitingView))
{
spdlog::info("Character with form id {:X} already has a spawn request in progress.", acMessage.FormId);
return;
}

const auto cActorId = World::Get().GetModSystem().GetGameId(acMessage.FormId);

auto* const pForm = TESForm::GetById(cActorId);
Expand Down Expand Up @@ -1289,7 +1302,7 @@ void CharacterService::RequestServerAssignment(const entt::entity aEntity) const
if (!pNpc)
return;

AssignCharacterRequest message;
AssignCharacterRequest message{};

message.Cookie = sCookieSeed;

Expand Down

0 comments on commit c6bf19c

Please sign in to comment.