101 lines
1.8 KiB
C++
101 lines
1.8 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 ?
|
|
#define LOCKSTEP_BUFFER_SIZE 10
|
|
|
|
namespace td {
|
|
namespace protocol {
|
|
|
|
struct PlayerInfo {
|
|
PlayerID m_PlayerId;
|
|
std::string m_PlayerName;
|
|
};
|
|
|
|
struct MapData {
|
|
|
|
};
|
|
|
|
namespace pdata {
|
|
|
|
/** Client attempts to login (very basic) */
|
|
struct PlayerLogin {
|
|
std::string m_PlayerName;
|
|
};
|
|
|
|
/** Server indicates success */
|
|
struct LoggingSuccess {
|
|
PlayerID m_PlayerId;
|
|
};
|
|
|
|
/** Player joins the lobby */
|
|
struct PlayerJoin {
|
|
PlayerInfo m_Player;
|
|
};
|
|
|
|
/** Player leaves the lobby */
|
|
struct PlayerLeave {
|
|
PlayerID m_PlayerId;
|
|
};
|
|
|
|
struct PredictCommand {
|
|
std::unique_ptr<CommandBase> m_Command;
|
|
std::uint16_t 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;
|
|
};
|
|
|
|
// TODO: handle players joining in the first second
|
|
|
|
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 {
|
|
std::uint16_t m_FirstFrameNumber;
|
|
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 {
|
|
std::unordered_map<game::ChunkCoord, game::ChunkPtr> m_Chunks;
|
|
};
|
|
|
|
} // namespace pdata
|
|
} // namespace protocol
|
|
} // namespace td
|