declare packets + commands
This commit is contained in:
@@ -2,25 +2,11 @@
|
||||
|
||||
#include <string>
|
||||
#include <td/Types.h>
|
||||
#include <array>
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
|
||||
#define LOCKSTEP_BUFFER_SIZE 10
|
||||
|
||||
struct LockStepCommand {};
|
||||
|
||||
struct LockStep {
|
||||
std::uint8_t m_CommandNumber;
|
||||
std::vector<LockStepCommand> m_Commands;
|
||||
};
|
||||
|
||||
struct LockSteps {
|
||||
std::uint16_t m_FirstFrameNumber;
|
||||
std::array<LockStep, LOCKSTEP_BUFFER_SIZE> m_LockSteps;
|
||||
};
|
||||
|
||||
|
||||
namespace cdata {
|
||||
|
||||
|
||||
@@ -58,6 +44,8 @@ struct PlayerJoin {
|
||||
std::string m_Name;
|
||||
};
|
||||
|
||||
struct End {};
|
||||
|
||||
} // namespace cdata
|
||||
|
||||
|
||||
|
||||
@@ -6,15 +6,16 @@ namespace protocol {
|
||||
|
||||
/**
|
||||
* \def DeclareAllPacket
|
||||
* \brief Avoids repetitive operations on packets
|
||||
* \brief Avoids repetitive operations on commands
|
||||
*/
|
||||
#define DeclareAllCommand() \
|
||||
DeclareCommand(End) \
|
||||
DeclareCommand(PlaceTower) \
|
||||
DeclareCommand(UpgradeTower) \
|
||||
DeclareCommand(PlayerJoin) \
|
||||
DeclareCommand(SpawnTroop) \
|
||||
DeclareCommand(UseItem) \
|
||||
DeclareCommand(TeamChange) \
|
||||
DeclareCommand(PlayerJoin)
|
||||
DeclareCommand(UpgradeTower) \
|
||||
DeclareCommand(UseItem)
|
||||
|
||||
|
||||
} // namespace protocol
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
*/
|
||||
|
||||
#include <td/protocol/Dispatcher.h>
|
||||
#include <td/protocol/command/Commands.h>
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
|
||||
class CommandHandler;
|
||||
|
||||
using CommandDispatcher = Dispatcher<CommandType, CommandHandler, Command>;
|
||||
using CommandDispatcher = Dispatcher<CommandType, CommandVisitor, Command>;
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file CommandHandler.h
|
||||
* \brief File containing the td::protocol::CommandHandler class
|
||||
*/
|
||||
|
||||
#include <td/protocol/command/CommandVisitor.h>
|
||||
#include <td/protocol/command/Commands.h>
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
|
||||
#define DeclareCommand(CommandName, ...) \
|
||||
virtual void Visit(const commands::CommandName&); \
|
||||
virtual void HandleCommand(const commands::CommandName&) {}
|
||||
|
||||
/**
|
||||
* \class CommandHandler
|
||||
* \brief Class used to handle packets
|
||||
*/
|
||||
class CommandHandler : public CommandVisitor {
|
||||
public:
|
||||
CommandHandler() {}
|
||||
~CommandHandler() {}
|
||||
|
||||
DeclareAllCommand()
|
||||
};
|
||||
|
||||
#undef DeclareCommand
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <td/common/NonCopyable.h>
|
||||
#include <td/protocol/command/CommandData.h>
|
||||
#include <td/protocol/command/CommandDeclare.h>
|
||||
#include <memory>
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
@@ -104,5 +105,7 @@ DeclareAllCommand()
|
||||
|
||||
} // namespace commands
|
||||
|
||||
using LockStep = std::vector<std::shared_ptr<protocol::Command>>;
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
|
||||
Reference in New Issue
Block a user