From 21d4d5f0de6bd8ed1cdab4f7fe6b9596dd390252 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 6 Apr 2017 17:22:23 +0200 Subject: Move clonk control specific parts into ClonkControl There are still many clonk commands hardcoded through the pass-CRSM-Commands --- src/PatchedClonkControl.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'src/PatchedClonkControl.cpp') diff --git a/src/PatchedClonkControl.cpp b/src/PatchedClonkControl.cpp index 47758d2..45b6d68 100644 --- a/src/PatchedClonkControl.cpp +++ b/src/PatchedClonkControl.cpp @@ -1,6 +1,62 @@ #include "PatchedClonkControl.hpp" +#define CMD_SIGN "/" + PatchedClonkControl::PatchedClonkControl() { } + +void PatchedClonkControl::abortCountdown() +{ + rawCommand("stop"); +} + +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); +} -- cgit v1.2.3-54-g00ecf