diff --git a/ParsecSoda/ChatBot.cpp b/ParsecSoda/ChatBot.cpp index 8d4591fc..1d1d1127 100644 --- a/ParsecSoda/ChatBot.cpp +++ b/ParsecSoda/ChatBot.cpp @@ -14,7 +14,7 @@ ACommand * ChatBot::identifyUserDataMessage(const char* msg, Guest &sender, bool //if (CommandIpFilter::containsIp(msg)) return new CommandIpFilter(msg, sender, _parsec, _ban, isHost); if (msgIsEqual(msg, CommandJoin::prefixes())) return new CommandJoin(); if (msgIsEqual(msg, CommandMirror::prefixes())) return new CommandMirror(sender, _gamepadClient); - if (msgIsEqual(msg, CommandMultitap::prefixes())) return new CommandMultitap(sender, _gamepadClient); + if (msgIsEqual(msg, CommandMultitap::prefixes())) return new CommandMultitap(sender, _gamepadClient); if (msgIsEqual(msg, CommandPads::prefixes())) return new CommandPads(_gamepadClient); if (msgStartsWith(msg, CommandSwap::prefixes())) return new CommandSwap(msg, sender, _gamepadClient, _hotseatManager); if (msgIsEqual(msg, CommandTime::prefixes())) return new CommandTime(sender, _hotseatManager); diff --git a/ParsecSoda/Commands/ACommandIntegerArg.h b/ParsecSoda/Commands/ACommandIntegerArg.h index 3a983190..7a3a6625 100644 --- a/ParsecSoda/Commands/ACommandIntegerArg.h +++ b/ParsecSoda/Commands/ACommandIntegerArg.h @@ -30,6 +30,8 @@ class ACommandIntegerArg : public ACommandPrefix } } + inline const int getArg() const { return _intArg; } + protected: int _intArg; }; diff --git a/ParsecSoda/Commands/ACommandPrefix.h b/ParsecSoda/Commands/ACommandPrefix.h index fdeff159..af70d780 100644 --- a/ParsecSoda/Commands/ACommandPrefix.h +++ b/ParsecSoda/Commands/ACommandPrefix.h @@ -26,6 +26,9 @@ class ACommandPrefix : public ACommand return false; } + inline const string getPrefix() const { return _prefix; } + inline const string getMessage() const { return _msg; } + protected: const char* _msg; const char* _prefix; diff --git a/ParsecSoda/Commands/ACommandStringArg.h b/ParsecSoda/Commands/ACommandStringArg.h index f48765da..9301d134 100644 --- a/ParsecSoda/Commands/ACommandStringArg.h +++ b/ParsecSoda/Commands/ACommandStringArg.h @@ -2,6 +2,7 @@ #include "ACommandPrefix.h" #include "../Stringer.h" +#include class ACommandStringArg : public ACommandPrefix { @@ -24,6 +25,8 @@ class ACommandStringArg : public ACommandPrefix return true; } + inline const string& getArg() const { return _stringArg; } + protected: string _stringArg; }; diff --git a/ParsecSoda/Commands/CommandSwap.h b/ParsecSoda/Commands/CommandSwap.h index ddbb793b..d424b38e 100644 --- a/ParsecSoda/Commands/CommandSwap.h +++ b/ParsecSoda/Commands/CommandSwap.h @@ -2,6 +2,7 @@ #include #include +#include "ACommandStringArg.h" #include "ACommandIntegerArg.h" #include "../GamepadClient.h" @@ -19,8 +20,25 @@ class CommandSwap : public ACommandIntegerArg if (!ACommandIntegerArg::run()) { - _replyMessage = "[ChatBot]\tUsage: !swap \nExample: !swap 4\0"; - return false; + bool recoverySuccess = false; + + const string msg = getMessage(); + if (!msg.empty()) + { + ACommandStringArg stringArg(msg.c_str(), internalPrefixes()); + stringArg.run(); + if (Stringer::compareNoCase(stringArg.getArg(), "Any") == 0) + { + _intArg = 0; + recoverySuccess = true; + } + } + + if (!recoverySuccess) + { + _replyMessage = "[ChatBot]\tUsage: !swap \nExample: !swap 4\0"; + return false; + } } bool rv = false; diff --git a/ParsecSoda/HotseatManager.cpp b/ParsecSoda/HotseatManager.cpp index a41d6e8c..852f486a 100644 --- a/ParsecSoda/HotseatManager.cpp +++ b/ParsecSoda/HotseatManager.cpp @@ -69,7 +69,21 @@ int HotseatManager::setDesiredSeat(uint32_t userID, int desiredSeatIndex) if (desiredSeatIndex != currentSeatIndex && desiredSeatIndex != HotseatGuest::ANY_SEAT) { seat.guest.desiredSeatIndex = result; - reverse(currentSeatIndex); + + if (seat.timer.getRemainingTime() > 0.90f * seat.timer.getDuration()) + { + reverse(currentSeatIndex); + } + else + { + HotseatGuest guest = seat.guest; + spectateSeat(currentSeatIndex); + enqueue(guest); + } + } + else + { + seat.guest.desiredSeatIndex = result; } });