Skip to content

Commit

Permalink
Fix crash in OnNotifyRelinquishControl (#732)
Browse files Browse the repository at this point in the history
The call to retrieve the Actor:: can fail, so avoid the crash.
  • Loading branch information
rfortier authored Nov 5, 2024
1 parent f4f2249 commit 4103310
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ void CharacterService::OnNotifyRelinquishControl(const NotifyRelinquishControl&
std::optional<uint32_t> serverIdRes = Utils::GetServerId(entity);
if (!serverIdRes.has_value())
{
spdlog::error("{}: failed to find server id", __FUNCTION__);
spdlog::error(__FUNCTION__ ": failed to find server id for entity");
continue;
}

Expand All @@ -992,12 +992,19 @@ void CharacterService::OnNotifyRelinquishControl(const NotifyRelinquishControl&
}

Actor* pActor = Cast<Actor>(TESForm::GetById(formIdComponent.Id));
if (!pActor)
{
// Probably left the room and/or temporary.
spdlog::info(__FUNCTION__ ": no local Actor for serverId {:X} to relinquish", serverId);
continue;
}

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

InterpolationSystem::Setup(m_world, entity);
AnimationSystem::Setup(m_world, entity);

spdlog::info("Relinquished control of actor {:X} with server id {:X}", pActor->formID, acMessage.ServerId);
spdlog::info(__FUNCTION__ ": relinquished control of actor {:X} with server id {:X}", pActor->formID, acMessage.ServerId);

return;
}
Expand Down

0 comments on commit 4103310

Please sign in to comment.