#include "td/protocol/PacketHandler.h"
#include "td/protocol/Packets.h"

#define REGISTER_DISPATCH_CLASS(className)  void className::Dispatch(PacketHandler* handler) const { \
                                                handler->HandlePacket(this);\
                                            }

namespace td {
namespace protocol {

void Packet::WritePacketID(DataBuffer& data, bool packetID) const {
	if (packetID)
		data << GetID();
}

REGISTER_DISPATCH_CLASS(PlayerLoginPacket)
REGISTER_DISPATCH_CLASS(WorldBeginDataPacket)
REGISTER_DISPATCH_CLASS(WorldDataPacket)
REGISTER_DISPATCH_CLASS(KeepAlivePacket)
REGISTER_DISPATCH_CLASS(UpdateExpPacket)
REGISTER_DISPATCH_CLASS(UpdateMoneyPacket)
REGISTER_DISPATCH_CLASS(UpdateLobbyTimePacket)
REGISTER_DISPATCH_CLASS(UpdateGameStatePacket)
REGISTER_DISPATCH_CLASS(PlayerListPacket)
REGISTER_DISPATCH_CLASS(PlayerJoinPacket)
REGISTER_DISPATCH_CLASS(PlayerLeavePacket)
REGISTER_DISPATCH_CLASS(ConnexionInfoPacket)
REGISTER_DISPATCH_CLASS(SelectTeamPacket)
REGISTER_DISPATCH_CLASS(UpdatePlayerTeamPacket)
REGISTER_DISPATCH_CLASS(DisconnectPacket)
REGISTER_DISPATCH_CLASS(ServerTpsPacket)
REGISTER_DISPATCH_CLASS(SpawnMobPacket)
REGISTER_DISPATCH_CLASS(PlaceTowerPacket)
REGISTER_DISPATCH_CLASS(WorldAddTowerPacket)
REGISTER_DISPATCH_CLASS(RemoveTowerPacket)
REGISTER_DISPATCH_CLASS(SendMobsPacket)
REGISTER_DISPATCH_CLASS(UpgradeTowerPacket)
REGISTER_DISPATCH_CLASS(UpdateCastleLifePacket)
REGISTER_DISPATCH_CLASS(UpdateMobStatesPacket)
REGISTER_DISPATCH_CLASS(PlayerBuyItemPacket)
REGISTER_DISPATCH_CLASS(PlayerBuyMobUpgradePacket)
REGISTER_DISPATCH_CLASS(RemoveMobPacket)

} // namespace protocol
} // namespace td