finish serialize

This commit is contained in:
2024-10-18 15:36:00 +02:00
parent 69d96b40ec
commit 871caf9056
9 changed files with 337 additions and 20 deletions

View File

@@ -1,8 +1,8 @@
#pragma once
#include <array>
#include <string>
#include <td/Types.h>
#include <array>
namespace td {
namespace protocol {
@@ -11,13 +11,13 @@ namespace cdata {
struct PlaceTower {
CastleType m_Type : 4;
TowerType m_Type : 4;
PlayerID m_Placer : 4;
CastleCoords m_Position;
TowerCoords m_Position;
};
struct UpgradeTower {
CastleID m_Tower : 12;
TowerID m_Tower : 12;
std::uint8_t m_Upgrade : 4;
};

View File

@@ -8,11 +8,11 @@ namespace protocol {
namespace CommandFactory {
template <typename CommandDerived, typename = typename std::enable_if<std::is_base_of<Command, CommandDerived>::value>::type>
std::unique_ptr<CommandDerived> CreateCommand() {
return std::make_unique<CommandDerived>();
std::shared_ptr<CommandDerived> CreateCommand() {
return std::make_shared<CommandDerived>();
}
const std::unique_ptr<Command>& CreateReadOnlyCommand(CommandType a_Type);
const std::shared_ptr<Command>& CreateReadOnlyCommand(CommandType a_Type);
} // namespace CommandFactory
} // namespace protocol

View File

@@ -8,13 +8,13 @@ namespace protocol {
class Command;
using CommandPtr = std::unique_ptr<Command>;
using CommandPtr = std::shared_ptr<Command>;
namespace CommandSerializer {
DataBuffer Serialize(const Command& a_Command);
std::unique_ptr<Command> Deserialize(DataBuffer& a_Data);
std::shared_ptr<Command> Deserialize(DataBuffer& a_Data);
} // namespace CommandSerializer
} // namespace protocol