Skip to content

Commit

Permalink
fix: update health server side
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed May 11, 2022
1 parent 31ffbf5 commit f49753e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 0 additions & 6 deletions Code/client/Services/Generic/CharacterService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,6 @@ void CharacterService::OnAssignCharacter(const AssignCharacterResponse& acMessag
return;
}

const auto* pNpc = Cast<TESNPC>(pActor->baseForm);
if (pNpc)
{
spdlog::warn("Spawn Actor: {:X}, and NPC {}", pActor->formID, pNpc->fullName.value);
}

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

pActor->GetExtension()->SetRemote(true);
Expand Down
10 changes: 10 additions & 0 deletions Code/server/Services/ActorValueService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ void ActorValueService::OnHealthChangeBroadcast(const PacketEvent<RequestHealthC
auto& message = acMessage.Packet;

// TODO(cosideci): should server side health not be updated?
auto actorValuesView = m_world.view<ActorValuesComponent, OwnerComponent>();

auto it = actorValuesView.find(static_cast<entt::entity>(message.Id));

if (it != actorValuesView.end())
{
auto& actorValuesComponent = actorValuesView.get<ActorValuesComponent>(*it);
auto currentHealth = actorValuesComponent.CurrentActorValues.ActorValuesList[24];
actorValuesComponent.CurrentActorValues.ActorValuesList[24] = currentHealth - message.DeltaHealth;

This comment has been minimized.

Copy link
@Force67

Force67 May 11, 2022

Member

If the index is hardcoded, it should either be a constant kSomethingDescriptive = 24, or possibly an enum.

This comment has been minimized.

Copy link
@RobbeBryssinck

RobbeBryssinck May 11, 2022

Author Member

There's an enum for it, but it's in the client code. Can be moved to common though i suppose.

}

NotifyHealthChangeBroadcast notify;
notify.Id = message.Id;
Expand Down

0 comments on commit f49753e

Please sign in to comment.