Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove committed Dec 13, 2024
1 parent 20d6bff commit fb2413c
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 8 deletions.
3 changes: 2 additions & 1 deletion skymp5-server/cpp/messages/ActivateMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ struct ActivateMessage : public MessageBase<ActivateMessage>
template <class Archive>
void Serialize(Archive& archive)
{
archive.Serialize("caster", caster)
archive.Serialize("t", kMsgType)
.Serialize("caster", caster)
.Serialize("target", target)
.Serialize("isSecondActivation", isSecondActivation);
}
Expand Down
4 changes: 3 additions & 1 deletion skymp5-server/cpp/messages/ConsoleCommandMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ struct ConsoleCommandMessage : public MessageBase<ConsoleCommandMessage>
template <class Archive>
void Serialize(Archive& archive)
{
archive.Serialize("commandName", commandName).Serialize("args", args);
archive.Serialize("t", kMsgType)
.Serialize("commandName", commandName)
.Serialize("args", args);
}

std::string commandName;
Expand Down
3 changes: 2 additions & 1 deletion skymp5-server/cpp/messages/CraftItemMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ struct CraftItemMessage : public MessageBase<CraftItemMessage>
template <class Archive>
void Serialize(Archive& archive)
{
archive.Serialize("workbench", workbench)
archive.Serialize("t", kMsgType)
.Serialize("workbench", workbench)
.Serialize("craftInputObjects", craftInputObjects)
.Serialize("resultObjectId", resultObjectId);
}
Expand Down
113 changes: 110 additions & 3 deletions skymp5-server/cpp/messages/CreateActorMessage.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,125 @@
#pragma once
#include "MessageBase.h"
#include "MsgType.h"
#include <map>
#include <type_traits>

struct CreateActorMessage : public MessageBase<CreateActorMessage>
struct Transform
{
template <class Archive>
void Serialize(Archive& archive)
{
archive.Serialize("worldOrCell", worldOrCell)
.Serialize("pos", pos)
.Serialize("rot", rot);
}

uint32_t worldOrCell = 0;
std::array<float, 3> pos = { 0.f, 0.f, 0.f };
std::array<float, 3> rot = { 0.f, 0.f, 0.f };
};

struct CreateActorMessageAdditionalProps
{
template <class Archive>
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<bool> isOpen;
std::optional<std::map<std::string, std::string>> setNodeTextureSet;
std::optional<std::map<std::string, float>> setNodeScale;
std::optional<bool> isDisabled;
std::optional<std::string> lastAnimation;
std::optional<std::string> displayName;
std::optional<bool> isHostedByOther;
std::optional<bool> isRaceMenuOpen;
std::optional<std::vector<uint32_t>> learnedSpells;
std::optional<float> healRate;
std::optional<float> healRateMult;
std::optional<float> health;
std::optional<float> magickaRate;
std::optional<float> magickaRateMult;
std::optional<float> magicka;
std::optional<float> staminaRate;
std::optional<float> staminaRateMult;
std::optional<float> stamina;
std::optional<float> healthPercentage;
std::optional<float> staminaPercentage;
std::optional<float> magickaPercentage;
std::optional<std::vector<uint32_t>> templateChain;
std::optional<Inventory> inventory;

std::optional<bool>
isDead; // TODO: take a look why doubles CreateActorMessageMainProps
};

struct CreateActorMessageMainProps
{
template <class Archive>
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<uint64_t> refrId;
std::optional<uint32_t> baseId = 0;
std::optional<Appearance> appearance;
std::optional<Equipment> equipment;
std::optional<Animation> animation;
std::optional<bool> isDead;
};

struct CreateActorMessage
: public MessageBase<CreateActorMessage>
, public CreateActorMessageMainProps
{
static constexpr auto kMsgType =
std::integral_constant<char, static_cast<char>(MsgType::CreateActor)>{};

template <class Archive>
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<std::string> baseRecordType;
Transform transform;
bool isMe = false;
CreateActorMessageAdditionalProps props;
std::string customPropsJsonDump;
};
3 changes: 1 addition & 2 deletions skymp5-server/cpp/messages/SpellCastMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ struct ActorAnimationVariables
template <class Archive>
void Serialize(Archive& archive)
{
archive.Serialize("t", kMsgType)
.Serialize("booleans", booleans)
archive.Serialize("booleans", booleans)
.Serialize("floats", floats)
.Serialize("integers", integers);
}
Expand Down

0 comments on commit fb2413c

Please sign in to comment.