summaryrefslogtreecommitdiffstats
path: root/src/ClonkInterface.cpp
blob: 036b9318b154cba73ddc192793008bdd8981a45c (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
#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); }

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

}