summaryrefslogtreecommitdiffstats
path: root/src/PatchedClonkControl.cpp
blob: e19a486272d3bd1c19b86f5c7c73daee2d785d66 (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
#include "PatchedClonkControl.hpp"

#define CMD_SIGN "/"

PatchedClonkControl::PatchedClonkControl()
{

}

void PatchedClonkControl::abortCountdown()
{
    rawCommand("abort");
}

void PatchedClonkControl::alert()
{
    rawCommand("alert");
}

void PatchedClonkControl::kick(const ClientInfo& client, const QString& reason)
{
    rawCommand("kick " + client.pcName + (reason.isEmpty() ? "" : " " + reason));
}

void PatchedClonkControl::rawCommand(const QString& command)
{
    controller->writeToServer(CMD_SIGN + command + "\n");
}

void PatchedClonkControl::serverMessage(const QString& msg, bool action)
{
    if(action)
    {
        rawCommand("me " + msg);
    }
    else
    {
        if(msg.startsWith(CMD_SIGN))
        {
            controller->writeToServer(" " + msg + "\n");
        }
        else
        {
            controller->writeToServer(msg + "\n");
        }
    }
}

void PatchedClonkControl::setCommand(const QString& command)
{
    rawCommand("set " + command);
}

void PatchedClonkControl::setCountdown(unsigned int countdown)
{
    rawCommand("start " + QString::number(countdown));
}

void PatchedClonkControl::watchdog(const QString& id)
{
    rawCommand("watchdog " + id);
}