From 3fe710cb029522b86ef27c322f0cb793b1368051 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 21 Mar 2017 22:00:59 +0100 Subject: Move Parser into own class --- src/ClonkInterface.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/ClonkInterface.cpp (limited to 'src/ClonkInterface.cpp') diff --git a/src/ClonkInterface.cpp b/src/ClonkInterface.cpp new file mode 100644 index 0000000..8d6ab98 --- /dev/null +++ b/src/ClonkInterface.cpp @@ -0,0 +1,95 @@ +#include "ClonkInterface.hpp" + + +ClonkOutputInterface::~ClonkOutputInterface() { } + +void ClonkOutputInterface::raw(const QString &msg) { Q_UNUSED(msg); } + +void ClonkOutputInterface::rawTimed(const QString &msg, const QTime &time) { Q_UNUSED(msg); Q_UNUSED(time); } + +void ClonkOutputInterface::lobbyCountdown(unsigned int seconds) { Q_UNUSED(seconds); } + +void ClonkOutputInterface::lobbyCountdownAborted() {} + +void ClonkOutputInterface::playerRemoved(const QString &name) { Q_UNUSED(name); } + +void ClonkOutputInterface::playerJoined(const ClientInfo &client, const QString &name) { Q_UNUSED(client); Q_UNUSED(name); } + +void ClonkOutputInterface::watchdog(const QString &id) { Q_UNUSED(id); } + +void ClonkOutputInterface::clientMessage(ClientInfo &client, const QString &message, ClonkOutputInterface::MessageType type, const QTime &time) { Q_UNUSED(client); Q_UNUSED(message); Q_UNUSED(type); Q_UNUSED(time); } + +void ClonkOutputInterface::clientConnected(const ClientInfo &client) { Q_UNUSED(client); } + +void ClonkOutputInterface::clientRemoved(const ClientInfo &client, const QString& reason) { Q_UNUSED(client); Q_UNUSED(reason); } + +void ClonkOutputInterface::clientStateChanged(const ClientInfo &client, bool activated) { Q_UNUSED(client); Q_UNUSED(activated); } + +void ClonkOutputInterface::gameLoading() {} + +void ClonkOutputInterface::gameStarted() {} + +void ClonkOutputInterface::masterserverError(const QString &msg) { Q_UNUSED(msg); } + +ClonkParser::ClonkParser(CRSMSession &session) : Session(session) +{ + +} + +ClonkParser::~ClonkParser() +{ + +} + +void ClonkParser::addTarget(ClonkOutputInterface *target) +{ + if(!targets.contains(target)) + { + targets.push_back(target); + } +} + +void ClonkParser::removeTarget(ClonkOutputInterface *target) +{ + targets.removeAll(target); +} + +#define dispatch(x) for(auto target : targets)\ +{\ + target->x;\ +} + +void ClonkParser::raw(const QString &msg) { dispatch(raw(msg)) } + +void ClonkParser::rawTimed(const QString &msg, const QTime &time) { dispatch(rawTimed(msg, time)) } + +void ClonkParser::lobbyCountdown(unsigned int seconds) { dispatch(lobbyCountdown(seconds)) } + +void ClonkParser::lobbyCountdownAborted() { dispatch(lobbyCountdownAborted()) } + +void ClonkParser::playerRemoved(const QString &name) { dispatch(playerRemoved(name)) } + +void ClonkParser::playerJoined(const ClientInfo &client, const QString &name) { dispatch(playerJoined(client, name)) } + +void ClonkParser::watchdog(const QString &id) { dispatch(watchdog(id)) } + +void ClonkParser::clientMessage(ClientInfo &client, const QString &message, ClonkOutputInterface::MessageType type, const QTime &time) { dispatch(clientMessage(client, message, type, time)) } + +void ClonkParser::clientConnected(const ClientInfo &client) { dispatch(clientConnected(client)) } + +void ClonkParser::clientRemoved(const ClientInfo &client, const QString& reason) { dispatch(clientRemoved(client, reason)) } + +void ClonkParser::clientStateChanged(const ClientInfo &client, bool activated) { dispatch(clientStateChanged(client, activated)) } + +void ClonkParser::gameLoading() { dispatch(gameLoading()) } + +void ClonkParser::gameStarted() { dispatch(gameStarted()) } + +void ClonkParser::masterserverError(const QString &msg) { dispatch(masterserverError(msg)) } + +#undef dispatch + +ClonkControllerInterface::~ClonkControllerInterface() +{ + +} -- cgit v1.2.3-54-g00ecf