summaryrefslogtreecommitdiffstats
path: root/src/ClonkInterface.cpp
blob: 2642568cf332118420d4d223036be3fe93c06a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "ClonkInterface.hpp"


ClonkOutputInterface::~ClonkOutputInterface() { }

bool ClonkOutputInterface::raw(const QString &msg) { Q_UNUSED(msg); return false; }

bool ClonkOutputInterface::rawTimed(const QString &msg, const QTime &time) { Q_UNUSED(msg); Q_UNUSED(time); return false; }

bool ClonkOutputInterface::lobbyCountdown(unsigned int seconds) { Q_UNUSED(seconds); return false; }

bool ClonkOutputInterface::lobbyCountdownAborted() { return false; }

bool ClonkOutputInterface::playerRemoved(const QString &name) { Q_UNUSED(name); return false; }

bool ClonkOutputInterface::playerJoined(const ClientInfo &client, const QString &name) { Q_UNUSED(client); Q_UNUSED(name); return false; }

bool ClonkOutputInterface::watchdog(const QString &id) { Q_UNUSED(id); return false; }

bool 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); return false; }

bool ClonkOutputInterface::clientConnected(const ClientInfo &client) { Q_UNUSED(client); return false; }

bool ClonkOutputInterface::clientRemoved(const ClientInfo &client, const QString& reason) { Q_UNUSED(client); Q_UNUSED(reason); return false; }

bool ClonkOutputInterface::clientStateChanged(const ClientInfo &client, bool activated) { Q_UNUSED(client); Q_UNUSED(activated); return false; }

bool ClonkOutputInterface::gameLoading() { return false; }

bool ClonkOutputInterface::gameStarted() { return false; }

bool ClonkOutputInterface::masterserverError(const QString& msg)
{ Q_UNUSED(msg); return false; }

ClonkControlInterface::~ClonkControlInterface() {}

void ClonkControlInterface::setController(ClonkControllerInterface *controller)
{
    this->controller = controller;
}

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)\
{\
    if(target->x)\
    {\
        break;\
    }\
}

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()
{

}