diff --git a/skymp5-server/cpp/messages/ActivateMessage.h b/skymp5-server/cpp/messages/ActivateMessage.h index 2cfa069d0..a20a2b14b 100644 --- a/skymp5-server/cpp/messages/ActivateMessage.h +++ b/skymp5-server/cpp/messages/ActivateMessage.h @@ -14,7 +14,8 @@ struct ActivateMessage : public MessageBase template void Serialize(Archive& archive) { - archive.Serialize("caster", caster) + archive.Serialize("t", kMsgType) + .Serialize("caster", caster) .Serialize("target", target) .Serialize("isSecondActivation", isSecondActivation); } diff --git a/skymp5-server/cpp/messages/ConsoleCommandMessage.h b/skymp5-server/cpp/messages/ConsoleCommandMessage.h index 8790a42c2..1bb914737 100644 --- a/skymp5-server/cpp/messages/ConsoleCommandMessage.h +++ b/skymp5-server/cpp/messages/ConsoleCommandMessage.h @@ -14,7 +14,9 @@ struct ConsoleCommandMessage : public MessageBase template void Serialize(Archive& archive) { - archive.Serialize("commandName", commandName).Serialize("args", args); + archive.Serialize("t", kMsgType) + .Serialize("commandName", commandName) + .Serialize("args", args); } std::string commandName; diff --git a/skymp5-server/cpp/messages/CraftItemMessage.h b/skymp5-server/cpp/messages/CraftItemMessage.h index f784f9df0..650f0defa 100644 --- a/skymp5-server/cpp/messages/CraftItemMessage.h +++ b/skymp5-server/cpp/messages/CraftItemMessage.h @@ -14,7 +14,8 @@ struct CraftItemMessage : public MessageBase template void Serialize(Archive& archive) { - archive.Serialize("workbench", workbench) + archive.Serialize("t", kMsgType) + .Serialize("workbench", workbench) .Serialize("craftInputObjects", craftInputObjects) .Serialize("resultObjectId", resultObjectId); } diff --git a/skymp5-server/cpp/messages/CreateActorMessage.h b/skymp5-server/cpp/messages/CreateActorMessage.h index 4ef5224fb..8a1c0525e 100644 --- a/skymp5-server/cpp/messages/CreateActorMessage.h +++ b/skymp5-server/cpp/messages/CreateActorMessage.h @@ -1,9 +1,103 @@ #pragma once #include "MessageBase.h" #include "MsgType.h" +#include #include -struct CreateActorMessage : public MessageBase +struct Transform +{ + template + void Serialize(Archive& archive) + { + archive.Serialize("worldOrCell", worldOrCell) + .Serialize("pos", pos) + .Serialize("rot", rot); + } + + uint32_t worldOrCell = 0; + std::array pos = { 0.f, 0.f, 0.f }; + std::array rot = { 0.f, 0.f, 0.f }; +}; + +struct CreateActorMessageAdditionalProps +{ + template + void Serialize(Archive& archive){ + archive.Serialize("isOpen", isOpen) + .Serialize("setNodeTextureSet", setNodeTextureSet) + .Serialize("setNodeScale", setNodeScale) + .Serialize("isDisabled", isDisabled) + .Serialize("lastAnimation", lastAnimation) + .Serialize("displayName", displayName) + .Serialize("isHostedByOther", isHostedByOther) + .Serialize("isRaceMenuOpen", isRaceMenuOpen) + .Serialize("learnedSpells", learnedSpells) + .Serialize("healRate", healRate) + .Serialize("healRateMult", healRateMult) + .Serialize("health", health) + .Serialize("magickaRate", magickaRate) + .Serialize("magickaRateMult", magickaRateMult) + .Serialize("magicka", magicka) + .Serialize("staminaRate", staminaRate) + .Serialize("staminaRateMult", staminaRateMult) + .Serialize("stamina", stamina) + .Serialize("healthPercentage", healthPercentage) + .Serialize("staminaPercentage", staminaPercentage) + .Serialize("magickaPercentage", magickaPercentage) + } + + std::optional isOpen; + std::optional> setNodeTextureSet; + std::optional> setNodeScale; + std::optional isDisabled; + std::optional lastAnimation; + std::optional displayName; + std::optional isHostedByOther; + std::optional isRaceMenuOpen; + std::optional> learnedSpells; + std::optional healRate; + std::optional healRateMult; + std::optional health; + std::optional magickaRate; + std::optional magickaRateMult; + std::optional magicka; + std::optional staminaRate; + std::optional staminaRateMult; + std::optional stamina; + std::optional healthPercentage; + std::optional staminaPercentage; + std::optional magickaPercentage; + std::optional> templateChain; + std::optional inventory; + + std::optional + isDead; // TODO: take a look why doubles CreateActorMessageMainProps +}; + +struct CreateActorMessageMainProps +{ + template + void Serialize(Archive& archive) + { + archive.Serialize("refrId", refrId) + .Serialize("baseId", baseId) + .Serialize("appearance", appearance) + .Serialize("equipment", equipment) + .Serialize("animation", animation) + .Serialize("isDead", isDead); + } + + std::optional refrId; + std::optional baseId = 0; + std::optional appearance; + std::optional equipment; + std::optional animation; + std::optional isDead; +}; + +struct CreateActorMessage + : public MessageBase + , public CreateActorMessageMainProps { static constexpr auto kMsgType = std::integral_constant(MsgType::CreateActor)>{}; @@ -11,8 +105,21 @@ struct CreateActorMessage : public MessageBase template void Serialize(Archive& archive) { - // TODO + archive.Serialize("t", kMsgType) + .Serialize("idx", idx) + .Serialize("baseRecordType", baseRecordType) + .Serialize("transform", transform) + .Serialize("isMe", isMe) + .Serialize("props", props) + .Serialize("customPropsJsonDump", customPropsJsonDump); + + CreateActorMessageMainProps::Serialize(archive); } - // TODO + uint32_t idx = 0; + std::optional baseRecordType; + Transform transform; + bool isMe = false; + CreateActorMessageAdditionalProps props; + std::string customPropsJsonDump; }; diff --git a/skymp5-server/cpp/messages/SpellCastMessage.h b/skymp5-server/cpp/messages/SpellCastMessage.h index b35acd044..d0c208e69 100644 --- a/skymp5-server/cpp/messages/SpellCastMessage.h +++ b/skymp5-server/cpp/messages/SpellCastMessage.h @@ -12,8 +12,7 @@ struct ActorAnimationVariables template void Serialize(Archive& archive) { - archive.Serialize("t", kMsgType) - .Serialize("booleans", booleans) + archive.Serialize("booleans", booleans) .Serialize("floats", floats) .Serialize("integers", integers); }