Skip to content

Commit

Permalink
fix: invalid ids sent by the client
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamashi committed May 6, 2022
1 parent ab1c98f commit ca45005
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Code/server/Services/MagicService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ void MagicService::OnSpellCastRequest(const PacketEvent<SpellCastRequest>& acMes
notify.DesiredTarget = message.DesiredTarget;

const entt::entity cCasterEntity = static_cast<entt::entity>(message.CasterId);
if (!m_world.valid(cCasterEntity))
{
spdlog::warn("OnSpellCastRequest received invalid caster id!");
return;
}

GameServer::Get()->SendToPlayersInRange(notify, cCasterEntity, acMessage.GetSender());
}

Expand All @@ -42,6 +48,12 @@ void MagicService::OnInterruptCastRequest(const PacketEvent<InterruptCastRequest
notify.CasterId = message.CasterId;

const entt::entity cCasterEntity = static_cast<entt::entity>(message.CasterId);
if (!m_world.valid(cCasterEntity))
{
spdlog::warn("OnInterruptCastRequest received invalid caster id!");
return;
}

GameServer::Get()->SendToPlayersInRange(notify, cCasterEntity, acMessage.GetSender());
}

Expand All @@ -56,6 +68,12 @@ void MagicService::OnAddTargetRequest(const PacketEvent<AddTargetRequest>& acMes
notify.Magnitude = message.Magnitude;

const entt::entity cTargetEntity = static_cast<entt::entity>(message.TargetId);
if (!m_world.valid(cTargetEntity))
{
spdlog::warn("OnAddTargetRequest received invalid caster id!");
return;
}

GameServer::Get()->SendToPlayersInRange(notify, cTargetEntity, acMessage.GetSender());
}

0 comments on commit ca45005

Please sign in to comment.