Skip to content

Commit

Permalink
fix: crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Nov 20, 2021
1 parent 4ed0172 commit 8842773
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,18 @@ void CharacterService::OnAssignCharacter(const AssignCharacterResponse& acMessag

const auto cEntity = *itor;

const auto& formIdComponent = m_world.get<FormIdComponent>(cEntity);

m_world.remove<WaitingForAssignmentComponent>(cEntity);

const auto formIdComponent = m_world.try_get<FormIdComponent>(cEntity);
if (!formIdComponent)
{
spdlog::error("Form id component doesn't exist?");
return;
}

if (m_world.any_of<LocalComponent, RemoteComponent>(cEntity))
{
auto* const pForm = TESForm::GetById(formIdComponent.Id);
auto* const pForm = TESForm::GetById(formIdComponent->Id);
auto* pActor = RTTI_CAST(pForm, TESForm, Actor);

if (!pActor)
Expand All @@ -231,15 +236,15 @@ void CharacterService::OnAssignCharacter(const AssignCharacterResponse& acMessag
}
else
{
auto* const pForm = TESForm::GetById(formIdComponent.Id);
auto* const pForm = TESForm::GetById(formIdComponent->Id);
auto* pActor = RTTI_CAST(pForm, TESForm, Actor);
if (!pActor)
{
m_world.destroy(cEntity);
return;
}

m_world.emplace_or_replace<RemoteComponent>(cEntity, acMessage.ServerId, formIdComponent.Id);
m_world.emplace_or_replace<RemoteComponent>(cEntity, acMessage.ServerId, formIdComponent->Id);

pActor->GetExtension()->SetRemote(true);

Expand Down

0 comments on commit 8842773

Please sign in to comment.