Skip to content

Commit

Permalink
fix: server message crash
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeBryssinck committed Apr 17, 2022
1 parent a51a909 commit 645edf1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Code/client/Services/Generic/CommandService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ void CommandService::OnCommandEvent(const CommandEvent& acEvent) noexcept
TeleportCommandRequest request{};
request.TargetPlayer = acEvent.Command.substr(commandWordPos + 1, acEvent.Command.size());

spdlog::info("Target player: '{}'", request.TargetPlayer);

m_transport.Send(request);

spdlog::info("Target player: '{}'", request.TargetPlayer);
}
else
{
Expand All @@ -42,6 +42,7 @@ void CommandService::OnCommandEvent(const CommandEvent& acEvent) noexcept

void CommandService::OnTeleportCommandResponse(const TeleportCommandResponse& acMessage) noexcept
{
spdlog::info("TeleportCommandResponse: {:X}:{:X} at position {}, {}, {}", acMessage.CellId.ModId, acMessage.CellId.BaseId, acMessage.Position.x, acMessage.Position.y, acMessage.Position.z);
auto& modSystem = m_world.GetModSystem();

const uint32_t cellId = modSystem.GetGameId(acMessage.CellId);
Expand Down
4 changes: 3 additions & 1 deletion Code/encoding/Messages/ServerMessageFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <Messages/NotifySyncExperience.h>
#include <Messages/NotifyEquipmentChanges.h>
#include <Messages/NotifyChatMessageBroadcast.h>
#include <Messages/TeleportCommandResponse.h>

using TiltedPhoques::UniquePtr;

Expand All @@ -59,7 +60,8 @@ struct ServerMessageFactory
NotifyLockChange, AssignObjectsResponse, NotifyDeathStateChange, NotifyOwnershipTransfer,
NotifyObjectInventoryChanges, NotifySpellCast, NotifyProjectileLaunch, NotifyInterruptCast,
NotifyAddTarget, NotifyScriptAnimation, NotifyDrawWeapon, NotifyMount, NotifyNewPackage,
NotifyRespawn, NotifySyncExperience, NotifyEquipmentChanges, NotifyChatMessageBroadcast>;
NotifyRespawn, NotifySyncExperience, NotifyEquipmentChanges, NotifyChatMessageBroadcast,
TeleportCommandResponse>;

return s_visitor(std::forward<T>(func));
}
Expand Down
2 changes: 2 additions & 0 deletions Code/encoding/Messages/TeleportCommandResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ void TeleportCommandResponse::SerializeRaw(TiltedPhoques::Buffer::Writer& aWrite

void TeleportCommandResponse::DeserializeRaw(TiltedPhoques::Buffer::Reader& aReader) noexcept
{
ServerMessage::DeserializeRaw(aReader);

CellId.Deserialize(aReader);
Position.Deserialize(aReader);
}
2 changes: 2 additions & 0 deletions Code/server/Services/CommandService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ void CommandService::OnTeleportCommandRequest(const PacketEvent<TeleportCommandR
}
}

spdlog::info("TeleportCommandResponse: {:X}:{:X} at position {}, {}, {}", response.CellId.ModId, response.CellId.BaseId, response.Position.x, response.Position.y, response.Position.z);

acMessage.pPlayer->Send(response);
}

0 comments on commit 645edf1

Please sign in to comment.