Files
Tower-Defense2/include/td/protocol/packet/PacketData.h

122 lines
2.1 KiB
C++

#pragma once
#include <td/Types.h>
#include <vector>
#include <td/protocol/command/Commands.h>
#include <td/common/Array.h>
#include <td/game/WorldTypes.h>
// Make it dynamic ?
#ifdef NDEBUG
#define LOCKSTEP_BUFFER_SIZE 10
#else
#define LOCKSTEP_BUFFER_SIZE 1
#endif
namespace td {
namespace protocol {
struct MapData {
};
namespace pdata {
/** Server indicates success */
struct LoggingSuccess {
PlayerID m_PlayerId;
};
/** Client attempts to login (very basic) */
struct PlayerLogin {
std::string m_PlayerName;
};
/** Player joins the lobby */
struct PlayerJoin {
PlayerInfo m_Player;
};
/** Player leaves the lobby */
struct PlayerLeave {
PlayerID m_PlayerId;
};
/** List of players who joined before */
struct PlayerList {
std::vector<PlayerInfo> m_Players;
};
struct PredictCommand {
CommandPtr m_Command;
StepTime m_FrameNumber;
};
/** Keep alive */
struct KeepAlive {
std::uint64_t m_KeepAliveId;
};
/** Can be used by both client and server */
struct Disconnect {
std::string m_Reason;
};
/** Chat message */
struct ChatMessage {
std::string m_Text;
};
struct BeginGame {
std::vector<PlayerInfo> m_BlueTeam;
std::vector<PlayerInfo> m_RedTeam;
// optional, used for players joining mid game
std::vector<LockStep> m_FirstLocksteps;
};
struct LockSteps {
StepTime m_FirstFrameNumber;
std::array<LockStep, LOCKSTEP_BUFFER_SIZE> m_LockSteps;
};
struct WorldHeader {
game::TowerTileColorPalette m_TowerPlacePalette;
Color m_WalkablePalette;
std::vector<Color> m_DecorationPalette;
Color m_Background;
game::SpawnColorPalette m_SpawnColorPalette;
game::TilePalette m_TilePalette;
game::Spawn m_RedSpawn, m_BlueSpawn;
game::TeamCastle m_RedCastle, m_BlueCastle;
};
struct WorldData {
game::ChunkList m_Chunks;
};
// TODO: spawn multiple troops at the same time
struct SpawnTroop {
sp::BitField<EntityType, 5> m_Type;
sp::BitField<std::uint8_t, 3> m_Level;
};
struct PlaceTower {
TowerType m_Type;
TowerCoords m_Position;
};
struct LockStepRequest {
std::vector<StepTime> m_Missing;
};
struct LockStepResponse {
std::map<StepTime, LockStep> m_Steps;
};
} // namespace pdata
} // namespace protocol
} // namespace td