diff --git a/CMakeLists.txt b/CMakeLists.txt index 39f0cff..cf84a82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin") # Includes # ----------------------- set(COMMON_DAIDE_CLIENT + ${SRC_DIR}/bots/basebot/basebot.cpp ${SRC_DIR}/daide_client/main.cpp ${SRC_DIR}/daide_client/adjudicator.cpp - ${SRC_DIR}/daide_client/base_bot.cpp ${SRC_DIR}/daide_client/error_log.cpp ${SRC_DIR}/daide_client/map_and_units.cpp ${SRC_DIR}/daide_client/socket.cpp @@ -27,12 +27,12 @@ add_executable(dumbbot ${COMMON_DAIDE_CLIENT}) target_include_directories(dumbbot PUBLIC ${SRC_DIR}/bots/dumbbot ${SRC_DIR}/bots/basebot ${SRC_DIR}) -add_executable(randbot - ${SRC_DIR}/bots/randbot/randbot.cpp - ${COMMON_DAIDE_CLIENT}) -target_include_directories(randbot PUBLIC ${SRC_DIR}/bots/randbot ${SRC_DIR}/bots/basebot ${SRC_DIR}) - add_executable(holdbot ${SRC_DIR}/bots/holdbot/holdbot.cpp ${COMMON_DAIDE_CLIENT}) target_include_directories(holdbot PUBLIC ${SRC_DIR}/bots/holdbot ${SRC_DIR}/bots/basebot ${SRC_DIR}) + +add_executable(randbot + ${SRC_DIR}/bots/randbot/randbot.cpp + ${COMMON_DAIDE_CLIENT}) +target_include_directories(randbot PUBLIC ${SRC_DIR}/bots/randbot ${SRC_DIR}/bots/basebot ${SRC_DIR}) diff --git a/bin/dumbbot b/bin/dumbbot index c76d22e..72975ba 100755 Binary files a/bin/dumbbot and b/bin/dumbbot differ diff --git a/bin/holdbot b/bin/holdbot index f9dfc9a..dae7a8e 100755 Binary files a/bin/holdbot and b/bin/holdbot differ diff --git a/bin/randbot b/bin/randbot index 969dd8c..6870598 100755 Binary files a/bin/randbot and b/bin/randbot differ diff --git a/daide_client/base_bot.cpp b/bots/basebot/basebot.cpp similarity index 94% rename from daide_client/base_bot.cpp rename to bots/basebot/basebot.cpp index f3ac443..2ceaac9 100644 --- a/daide_client/base_bot.cpp +++ b/bots/basebot/basebot.cpp @@ -16,8 +16,8 @@ #include #include +#include "basebot.h" #include "daide_client/ai_client.h" -#include "daide_client/base_bot.h" #include "daide_client/error_log.h" #include "daide_client/map_and_units.h" #include "daide_client/socket.h" @@ -74,7 +74,7 @@ bool BaseBot::initialize(const std::string &command_line_a) { } // Connection failure - if (!m_socket.Connect(parameters.server_name, parameters.port_number)) { + if (!m_socket.Connect(parameters.server_name.c_str(), parameters.port_number)) { log_error("Failed to connect to server"); return false; } @@ -150,15 +150,9 @@ void BaseBot::send_name_and_version_to_server(const std::string &name, const std TokenMessage name_message {}; TokenMessage name_tokens {}; TokenMessage version_tokens {}; - std::string name_prefix {}; - - // Prepending 'POW:' if a power has been requested - if (!m_parameters.reconnect_power.empty()) { - name_prefix = m_parameters.reconnect_power + ":"; - } // Setting and sending - name_tokens.set_message_from_text("'" + name_prefix + name + "'"); + name_tokens.set_message_from_text("'" + name + "'"); version_tokens.set_message_from_text("'" + version + "'"); name_message = TOKEN_COMMAND_NME & name_tokens & version_tokens; send_message_to_server(name_message); @@ -261,6 +255,7 @@ void BaseBot::process_diplomacy_message(char *message, int message_length) { // Act on that token lead_token = incoming_msg.get_token(0); + // FIXME use a switch statement // Messages that BaseBot handles initially if (lead_token == TOKEN_COMMAND_HLO) { process_hlo(incoming_msg); @@ -421,6 +416,7 @@ void BaseBot::process_sco(const TokenMessage &incoming_msg) { void BaseBot::process_not(const TokenMessage &incoming_msg) { TokenMessage not_message = incoming_msg.get_submessage(1); + // FIXME using switch statement if (not_message.get_token(0) == TOKEN_COMMAND_CCD) { process_not_ccd(incoming_msg, not_message.get_submessage(1)); } else if (not_message.get_token(0) == TOKEN_COMMAND_TME) { @@ -434,6 +430,7 @@ void BaseBot::process_not(const TokenMessage &incoming_msg) { void BaseBot::process_rej(const TokenMessage &incoming_msg) { TokenMessage rej_message = incoming_msg.get_submessage(1); + // FIXME using switch statement if (rej_message.get_token(0) == TOKEN_COMMAND_NME) { process_rej_nme_message(incoming_msg, rej_message.get_submessage(1)); } else if (rej_message.get_token(0) == TOKEN_COMMAND_IAM) { @@ -471,7 +468,7 @@ void BaseBot::process_rej(const TokenMessage &incoming_msg) { // Process the REJ(NOT()) message. Split according to next token void BaseBot::process_rej_not(const TokenMessage &incoming_msg, const TokenMessage &rej_not_params) { - + // FIXME using switch statement if (rej_not_params.get_token(0) == TOKEN_COMMAND_GOF) { process_rej_not_gof_message(incoming_msg, rej_not_params.get_submessage(1)); } else if (rej_not_params.get_token(0) == TOKEN_COMMAND_DRW) { @@ -485,6 +482,7 @@ void BaseBot::process_rej_not(const TokenMessage &incoming_msg, const TokenMessa void BaseBot::process_yes(const TokenMessage &incoming_msg) { TokenMessage yes_message = incoming_msg.get_submessage(1); + // FIXME use switch statement if (yes_message.get_token(0) == TOKEN_COMMAND_NME) { process_yes_nme_message(incoming_msg, yes_message.get_submessage(1)); } else if (yes_message.get_token(0) == TOKEN_COMMAND_OBS) { @@ -508,6 +506,7 @@ void BaseBot::process_yes(const TokenMessage &incoming_msg) { // Process the YES(NOT()) message. Split according to next token void BaseBot::process_yes_not(const TokenMessage &incoming_msg, const TokenMessage &yes_not_params) { + // FIXME use switch staetment if (yes_not_params.get_token(0) == TOKEN_COMMAND_GOF) { process_yes_not_gof_message(incoming_msg, yes_not_params.get_submessage(1)); } else if (yes_not_params.get_token(0) == TOKEN_COMMAND_DRW) { @@ -628,10 +627,15 @@ void BaseBot::process_rej_nme_message(const TokenMessage & /*incoming_msg*/, con } } +std::string BaseBot::get_bot_name() const +{ + return (m_parameters.power_specified ? m_parameters.power + "__" + BOT_FAMILY : BOT_FAMILY); +} + // Determine whether to try and reconnect to game. Default uses values passed on command line. bool BaseBot::get_reconnect_details(Token &power, int &passcode) { if (m_parameters.reconnection_specified) { - power = TokenTextMap::instance()->m_text_to_token_map[m_parameters.reconnect_power]; + power = TokenTextMap::instance()->m_text_to_token_map[m_parameters.power]; passcode = m_parameters.reconnect_passcode; } return m_parameters.reconnection_specified; @@ -856,11 +860,18 @@ bool BaseBot::extract_parameters(const std::string &command_line_a, COMMAND_LINE parameters.log_level = stoi(parameter); break; + case 'c': + parameters.power_specified = true; + parameters.power = parameter.substr(0, 3); + for (auto &c : parameters.power) { c = static_cast(toupper(c)); } + break; + case 'r': if (parameter[3] == ':') { parameters.reconnection_specified = true; - parameters.reconnect_power = parameter.substr(0, 3); - for (auto &c : parameters.reconnect_power) { c = static_cast(toupper(c)); } + parameters.power_specified = true; + parameters.power = parameter.substr(0, 3); + for (auto &c : parameters.power) { c = static_cast(toupper(c)); } parameters.reconnect_passcode = stoi(parameter.substr(4)); } else { std::cout << "-r should be followed by 'POW:passcode'\nPOW should be three characters" << std::endl; @@ -868,9 +879,9 @@ bool BaseBot::extract_parameters(const std::string &command_line_a, COMMAND_LINE break; default: - std::cout << std::string(BOT_FAMILY) << " - version " << std::string(BOT_GENERATION) << std::endl; - std::cout << "Usage: " << std::string(BOT_FAMILY) - << " [-sServerName|-iIPAddress] [-pPortNumber] [-lLogLevel] [-rPOW:passcode]" << std::endl; + std::cout << BOT_FAMILY << " - version " << BOT_GENERATION << std::endl; + std::cout << "Usage: " << BOT_FAMILY + << " [-sServerName|-iIPAddress] [-pPortNumber] [-lLogLevel] [-cPOW] [-rPOW:passcode]" << std::endl; extracted_ok = false; } param_start = m_command_line.find('-', search_start); diff --git a/daide_client/base_bot.h b/bots/basebot/basebot.h similarity index 96% rename from daide_client/base_bot.h rename to bots/basebot/basebot.h index e3d9327..1b95f72 100644 --- a/daide_client/base_bot.h +++ b/bots/basebot/basebot.h @@ -14,8 +14,8 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_BASE_BOT_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_BASE_BOT_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_BASE_BOT_H +#define DAIDE_CLIENT_DAIDE_CLIENT_BASE_BOT_H #include "daide_client/ai_client_types.h" #include "daide_client/error_log.h" @@ -146,6 +146,9 @@ class BaseBot { // Handle an incoming REJ( NME() ) message. virtual void process_rej_nme_message(const TokenMessage &incoming_msg, const TokenMessage &msg_params); + // Get the name of the bot including the requested power if any + std::string get_bot_name() const; + // Get the details to reconnect to the game. Return true if reconnect required, or false if reconnect is not to // be attempted. Default implementation uses parameters from the command line virtual bool get_reconnect_details(Token &power, int &passcode); @@ -395,4 +398,4 @@ class BaseBot { } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_BASE_BOT_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_BASE_BOT_H diff --git a/bots/basebot/bot_type.h b/bots/basebot/bot_type.h index 8805ad5..5050785 100644 --- a/bots/basebot/bot_type.h +++ b/bots/basebot/bot_type.h @@ -21,10 +21,10 @@ * Change the #define BOT_GENERATION to specify the generation (base version) of your Bot. * *******************************************************************************************/ -#ifndef _DAIDE_CLIENT_BOTS_BASEBOT_BOT_TYPE_H -#define _DAIDE_CLIENT_BOTS_BASEBOT_BOT_TYPE_H +#ifndef DAIDE_CLIENT_BOTS_BASEBOT_BOT_TYPE_H +#define DAIDE_CLIENT_BOTS_BASEBOT_BOT_TYPE_H -#include "daide_client/base_bot.h" +#include "base_bot.h" namespace DAIDE { @@ -35,4 +35,4 @@ using BOT_TYPE = BaseBot; } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_BASEBOT_BOT_TYPE_H +#endif // DAIDE_CLIENT_BOTS_BASEBOT_BOT_TYPE_H diff --git a/bots/dumbbot/bot_type.h b/bots/dumbbot/bot_type.h index 57b3e5c..d458d9c 100644 --- a/bots/dumbbot/bot_type.h +++ b/bots/dumbbot/bot_type.h @@ -21,10 +21,10 @@ * Change the #define BOT_GENERATION to specify the generation (base version) of your Bot. * *******************************************************************************************/ -#ifndef _DAIDE_CLIENT_BOTS_DUMBBOT_BOT_TYPE_H -#define _DAIDE_CLIENT_BOTS_DUMBBOT_BOT_TYPE_H +#ifndef DAIDE_CLIENT_BOTS_DUMBBOT_BOT_TYPE_H +#define DAIDE_CLIENT_BOTS_DUMBBOT_BOT_TYPE_H -#include "bots/dumbbot/dumbbot.h" +#include "dumbbot.h" namespace DAIDE { @@ -35,4 +35,4 @@ using BOT_TYPE = DumbBot; } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_DUMBBOT_BOT_TYPE_H +#endif // DAIDE_CLIENT_BOTS_DUMBBOT_BOT_TYPE_H diff --git a/bots/dumbbot/dumbbot.cpp b/bots/dumbbot/dumbbot.cpp index d09782d..d71e17e 100644 --- a/bots/dumbbot/dumbbot.cpp +++ b/bots/dumbbot/dumbbot.cpp @@ -15,8 +15,8 @@ **/ #include -#include "bots/dumbbot/bot_type.h" -#include "bots/dumbbot/dumbbot.h" +#include "bot_type.h" +#include "dumbbot.h" #include "daide_client/error_log.h" #include "daide_client/token_text_map.h" @@ -80,7 +80,7 @@ DumbBot::DumbBot() : {} void DumbBot::send_nme_or_obs() { - send_name_and_version_to_server(BOT_FAMILY, BOT_GENERATION); + send_name_and_version_to_server(get_bot_name(), BOT_GENERATION); } void DumbBot::process_mdf_message(const TokenMessage & /*incoming_msg*/) { @@ -174,6 +174,7 @@ int DumbBot::get_power_index(const Token &power_token) { } void DumbBot::process_now_message(const TokenMessage & /*incoming_msg*/) { + send_message_to_server(TOKEN_COMMAND_NOT & TOKEN_COMMAND_GOF); // Spring Moves/Retreats if ((m_map_and_units->current_season == DAIDE::TOKEN_SEASON_SPR) @@ -227,6 +228,7 @@ void DumbBot::process_now_message(const TokenMessage & /*incoming_msg*/) { // Submitting orders send_orders_to_server(); + send_message_to_server(TOKEN_COMMAND_GOF); } void DumbBot::calculate_factors(const WEIGHTING proximity_attack_weight, const WEIGHTING proximity_defense_weight) { @@ -886,117 +888,3 @@ int DumbBot::rand_no(int max_value) { int answer = rand() % max_value; return answer; } - -bool DumbBot::extract_parameters(const std::string &command_line_a, DAIDE::COMMAND_LINE_PARAMETERS ¶meters) { - int search_start; // Position to start searching command line - int param_start; // Start of the next parameter - int param_end; // End of the next parameter - char param_token; // The token specifying the parameter type - std::string parameter; // The parameter - bool extracted_ok = true; // Whether the parameters were OK - - parameters.ip_specified = false; - parameters.name_specified = false; - parameters.port_specified = false; - parameters.log_level_specified = false; - parameters.reconnection_specified = false; - - std::string m_command_line = command_line_a; - - // Strip the program name off the command line - if (m_command_line[0] == '"') { - // Program name is in quotes. - param_start = m_command_line.find('"', 1); - - if (param_start != std::string::npos) { - m_command_line = m_command_line.substr(param_start + 1); - } - } else { - // Program name is not quoted, so is terminated by a space - param_start = m_command_line.find(' '); - - if (param_start != std::string::npos) { - m_command_line = m_command_line.substr(param_start); - } - } - - param_start = m_command_line.find('-', 0); - - while (param_start != std::string::npos) { - param_token = m_command_line[param_start + 1]; - - param_end = m_command_line.find(' ', param_start); - - if (param_end == std::string::npos) { - parameter = m_command_line.substr(param_start + 2); - - search_start = m_command_line.size(); - } else { - parameter = m_command_line.substr(0, param_end).substr(param_start + 2); - - search_start = param_end; - } - - switch (param_token) { - case 's': { - parameters.name_specified = true; - parameters.server_name = parameter; - - break; - } - - case 'i': { - parameters.ip_specified = true; - parameters.server_name = parameter; - - break; - } - - case 'p': { - parameters.port_specified = true; - parameters.port_number = stoi(parameter); - - break; - } - - case 'l': { - parameters.log_level_specified = true; - parameters.log_level = stoi(parameter); - - break; - } - - case 'r': { - if (parameter[3] == ':') { - parameters.reconnection_specified = true; - parameters.reconnect_power = parameter.substr(0, 3); - for (auto &c : parameters.reconnect_power) { c = toupper(c); } - parameters.reconnect_passcode = stoi(parameter.substr(4)); - } else { - std::cout << "-r should be followed by 'POW:passcode'\n" - "POW should be three characters" << std::endl; - } - - break; - } - - default: { - std::cout << std::string(BOT_FAMILY) << " - version " << std::string(BOT_GENERATION) << std::endl; - std::cout << "Usage: " << std::string(BOT_FAMILY) << - " [-sServerName|-iIPAddress] [-pPortNumber] " - "[-lLogLevel] [-rPOW:passcode] [-d]" << std::endl; - extracted_ok = false; - } - } - - param_start = m_command_line.find('-', search_start); - } - - if ((parameters.ip_specified) && (parameters.name_specified)) { - std::cout << "You must not specify Server name and IP address" << std::endl; - - extracted_ok = false; - } - - return extracted_ok; -} diff --git a/bots/dumbbot/dumbbot.h b/bots/dumbbot/dumbbot.h index 2bac7f0..8979f6a 100644 --- a/bots/dumbbot/dumbbot.h +++ b/bots/dumbbot/dumbbot.h @@ -14,10 +14,10 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_BOTS_DUMBBOT_DUMBBOT_H -#define _DAIDE_CLIENT_BOTS_DUMBBOT_DUMBBOT_H +#ifndef DAIDE_CLIENT_BOTS_DUMBBOT_DUMBBOT_H +#define DAIDE_CLIENT_BOTS_DUMBBOT_DUMBBOT_H -#include "daide_client/base_bot.h" +#include "basebot.h" #include "daide_client/map_and_units.h" namespace DAIDE { @@ -75,8 +75,6 @@ class DumbBot : public DAIDE::BaseBot { static int rand_no(int max_value); - virtual bool extract_parameters(const std::string &command_line_a, DAIDE::COMMAND_LINE_PARAMETERS ¶meters); - private: // The attack value for each province. @@ -165,4 +163,4 @@ class DumbBot : public DAIDE::BaseBot { } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_DUMBBOT_DUMBBOT_H +#endif // DAIDE_CLIENT_BOTS_DUMBBOT_DUMBBOT_H diff --git a/bots/holdbot/bot_type.h b/bots/holdbot/bot_type.h index 4f5dade..5cbe2d2 100644 --- a/bots/holdbot/bot_type.h +++ b/bots/holdbot/bot_type.h @@ -21,10 +21,10 @@ * Change the #define BOT_GENERATION to specify the generation (base version) of your Bot. * *******************************************************************************************/ -#ifndef _DAIDE_CLIENT_BOTS_HOLDBOT_BOT_TYPE_H -#define _DAIDE_CLIENT_BOTS_HOLDBOT_BOT_TYPE_H +#ifndef DAIDE_CLIENT_BOTS_HOLDBOT_BOT_TYPE_H +#define DAIDE_CLIENT_BOTS_HOLDBOT_BOT_TYPE_H -#include "bots/holdbot/holdbot.h" +#include "holdbot.h" namespace DAIDE { @@ -35,4 +35,4 @@ using BOT_TYPE = HoldBot; } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_HOLDBOT_BOT_TYPE_H +#endif // DAIDE_CLIENT_BOTS_HOLDBOT_BOT_TYPE_H diff --git a/bots/holdbot/holdbot.cpp b/bots/holdbot/holdbot.cpp index ccc6bbd..7b0dcb0 100644 --- a/bots/holdbot/holdbot.cpp +++ b/bots/holdbot/holdbot.cpp @@ -14,18 +14,19 @@ * Release 8~3 **/ -#include "bots/holdbot/bot_type.h" -#include "bots/holdbot/holdbot.h" +#include "bot_type.h" +#include "holdbot.h" #include "daide_client/map_and_units.h" using DAIDE::HoldBot; using DAIDE::TokenMessage; void HoldBot::send_nme_or_obs() { - send_name_and_version_to_server(BOT_FAMILY, BOT_GENERATION); + send_name_and_version_to_server(get_bot_name(), BOT_GENERATION); } void HoldBot::process_now_message(const TokenMessage & /*incoming_message*/) { + send_message_to_server(TOKEN_COMMAND_NOT & TOKEN_COMMAND_GOF); // Movement - Order all units to hold. if ((m_map_and_units->current_season == DAIDE::TOKEN_SEASON_SPR) @@ -62,4 +63,5 @@ void HoldBot::process_now_message(const TokenMessage & /*incoming_message*/) { // Submitting orders send_orders_to_server(); + send_message_to_server(TOKEN_COMMAND_NOT & TOKEN_COMMAND_GOF); } diff --git a/bots/holdbot/holdbot.h b/bots/holdbot/holdbot.h index 4fc9b31..186df75 100644 --- a/bots/holdbot/holdbot.h +++ b/bots/holdbot/holdbot.h @@ -14,10 +14,10 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_BOTS_HOLDBOT_HOLDBOT_H -#define _DAIDE_CLIENT_BOTS_HOLDBOT_HOLDBOT_H +#ifndef DAIDE_CLIENT_BOTS_HOLDBOT_HOLDBOT_H +#define DAIDE_CLIENT_BOTS_HOLDBOT_HOLDBOT_H -#include "daide_client/base_bot.h" +#include "basebot.h" namespace DAIDE { @@ -37,4 +37,4 @@ class HoldBot : public DAIDE::BaseBot { } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_HOLDBOT_HOLDBOT_H +#endif // DAIDE_CLIENT_BOTS_HOLDBOT_HOLDBOT_H diff --git a/bots/randbot/bot_type.h b/bots/randbot/bot_type.h index 2e2fb9c..52d796a 100644 --- a/bots/randbot/bot_type.h +++ b/bots/randbot/bot_type.h @@ -21,10 +21,10 @@ * Change the #define BOT_GENERATION to specify the generation (base version) of your Bot. * *******************************************************************************************/ -#ifndef _DAIDE_CLIENT_BOTS_RANDBOT_BOT_TYPE_H -#define _DAIDE_CLIENT_BOTS_RANDBOT_BOT_TYPE_H +#ifndef DAIDE_CLIENT_BOTS_RANDBOT_BOT_TYPE_H +#define DAIDE_CLIENT_BOTS_RANDBOT_BOT_TYPE_H -#include "bots/randbot/randbot.h" +#include "randbot.h" namespace DAIDE { @@ -35,4 +35,4 @@ using BOT_TYPE = RandBot; } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_RANDBOT_BOT_TYPE_H +#endif // DAIDE_CLIENT_BOTS_RANDBOT_BOT_TYPE_H diff --git a/bots/randbot/randbot.cpp b/bots/randbot/randbot.cpp index dddd659..cb02e48 100644 --- a/bots/randbot/randbot.cpp +++ b/bots/randbot/randbot.cpp @@ -14,8 +14,8 @@ * Release 8~3 **/ -#include "bots/randbot/bot_type.h" -#include "bots/randbot/randbot.h" +#include "bot_type.h" +#include "randbot.h" #include "daide_client/map_and_units.h" using DAIDE::RandBot; @@ -23,7 +23,7 @@ using DAIDE::MapAndUnits; using DAIDE::TokenMessage; void RandBot::send_nme_or_obs() { - send_name_and_version_to_server(BOT_FAMILY, BOT_GENERATION); + send_name_and_version_to_server(get_bot_name(), BOT_GENERATION); } template @@ -45,6 +45,7 @@ void RandBot::process_now_message(const TokenMessage & /*incoming_message*/) { MapAndUnits::PROVINCE_COASTS *build_coast_info {nullptr}; if (!m_map_and_units->game_over) { + send_message_to_server(TOKEN_COMMAND_NOT & TOKEN_COMMAND_GOF); // Movement - Order units to move randomly. if ((m_map_and_units->current_season == DAIDE::TOKEN_SEASON_SPR) @@ -99,5 +100,6 @@ void RandBot::process_now_message(const TokenMessage & /*incoming_message*/) { // Submitting orders send_orders_to_server(); + send_message_to_server(TOKEN_COMMAND_GOF); } } diff --git a/bots/randbot/randbot.h b/bots/randbot/randbot.h index 8e15f2e..c96a774 100644 --- a/bots/randbot/randbot.h +++ b/bots/randbot/randbot.h @@ -14,10 +14,10 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_BOTS_RANDBOT_RANDBOT_H -#define _DAIDE_CLIENT_BOTS_RANDBOT_RANDBOT_H +#ifndef DAIDE_CLIENT_BOTS_RANDBOT_RANDBOT_H +#define DAIDE_CLIENT_BOTS_RANDBOT_RANDBOT_H -#include "daide_client/base_bot.h" +#include "basebot.h" namespace DAIDE { @@ -37,4 +37,4 @@ class RandBot : public DAIDE::BaseBot { } // namespace DAIDE -#endif // _DAIDE_CLIENT_BOTS_RANDBOT_RANDBOT_H +#endif // DAIDE_CLIENT_BOTS_RANDBOT_RANDBOT_H diff --git a/daide_client/adjudicator.cpp b/daide_client/adjudicator.cpp index b42efb3..47b44b3 100644 --- a/daide_client/adjudicator.cpp +++ b/daide_client/adjudicator.cpp @@ -12,7 +12,7 @@ * Release 8~3 **/ -#include "daide_client/map_and_units.h" +#include "map_and_units.h" using DAIDE::MapAndUnits; diff --git a/daide_client/ai_client.h b/daide_client/ai_client.h index e699c54..1d78455 100644 --- a/daide_client/ai_client.h +++ b/daide_client/ai_client.h @@ -4,8 +4,8 @@ // Release 8~3 -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_H +#define DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_H #include "bot_type.h" @@ -15,4 +15,4 @@ extern BOT_TYPE the_bot; } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_H diff --git a/daide_client/ai_client_types.h b/daide_client/ai_client_types.h index 2f64ef5..6fb753c 100644 --- a/daide_client/ai_client_types.h +++ b/daide_client/ai_client_types.h @@ -14,8 +14,8 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_TYPES_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_TYPES_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_TYPES_H +#define DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_TYPES_H #include @@ -30,10 +30,11 @@ typedef struct { bool log_level_specified; // Whether the log level was specified int log_level; // The level to log at bool reconnection_specified; // Whether the reconnection parameters have been provided - std::string reconnect_power; // Power to reconnect as + bool power_specified; // Whether the desired power was specified + std::string power; // Power to (re)connect as int reconnect_passcode; // Passcode to reconnect as } COMMAND_LINE_PARAMETERS; } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_TYPES_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_AI_CLIENT_TYPES_H diff --git a/daide_client/error_log.cpp b/daide_client/error_log.cpp index 3cbe688..9794383 100644 --- a/daide_client/error_log.cpp +++ b/daide_client/error_log.cpp @@ -17,7 +17,7 @@ #include #include #include -#include "daide_client/error_log.h" +#include "error_log.h" // TODO - REWRITE completely // Avoid using variadic functions diff --git a/daide_client/error_log.h b/daide_client/error_log.h index 9952e89..da7b631 100644 --- a/daide_client/error_log.h +++ b/daide_client/error_log.h @@ -14,10 +14,10 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_ERROR_LOG_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_ERROR_LOG_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_ERROR_LOG_H +#define DAIDE_CLIENT_DAIDE_CLIENT_ERROR_LOG_H -#include "daide_client/token_message.h" +#include "token_message.h" namespace DAIDE { @@ -35,4 +35,4 @@ void close_logs(); } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_ERROR_LOG_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_ERROR_LOG_H diff --git a/daide_client/main.cpp b/daide_client/main.cpp index 04ab555..17f663d 100644 --- a/daide_client/main.cpp +++ b/daide_client/main.cpp @@ -6,7 +6,7 @@ #include #include -#include "daide_client/ai_client.h" +#include "ai_client.h" using DAIDE::BOT_TYPE; using DAIDE::the_bot; diff --git a/daide_client/map_and_units.cpp b/daide_client/map_and_units.cpp index fe59365..08eeb0d 100644 --- a/daide_client/map_and_units.cpp +++ b/daide_client/map_and_units.cpp @@ -12,8 +12,8 @@ * Release 8~3 **/ -#include "daide_client/map_and_units.h" -#include "daide_client/token_message.h" +#include "map_and_units.h" +#include "token_message.h" using DAIDE::MapAndUnits; using DAIDE::Token; diff --git a/daide_client/map_and_units.h b/daide_client/map_and_units.h index e5f6264..2f3de48 100644 --- a/daide_client/map_and_units.h +++ b/daide_client/map_and_units.h @@ -12,12 +12,12 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_MAP_AND_UNITS_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_MAP_AND_UNITS_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_MAP_AND_UNITS_H +#define DAIDE_CLIENT_DAIDE_CLIENT_MAP_AND_UNITS_H -#include "daide_client/types.h" -#include "daide_client/tokens.h" -#include "daide_client/token_message.h" +#include "types.h" +#include "tokens.h" +#include "token_message.h" namespace DAIDE { @@ -556,4 +556,4 @@ class MapAndUnits { } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_MAP_AND_UNITS_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_MAP_AND_UNITS_H diff --git a/daide_client/socket.cpp b/daide_client/socket.cpp index 2fa88cf..bebb8ca 100644 --- a/daide_client/socket.cpp +++ b/daide_client/socket.cpp @@ -13,9 +13,9 @@ #include #include -#include "daide_client/ai_client.h" -#include "daide_client/error_log.h" -#include "daide_client/socket.h" +#include "ai_client.h" +#include "error_log.h" +#include "socket.h" ///////////////////////////////////////////////////////////////////////////// @@ -279,7 +279,7 @@ void Socket::AdjustOrdering(const MessagePtr &message, short length) { #if LITTLE_ENDIAN MessageHeader* message_header = get_message_header(message); - auto* message_content = get_message_content(message); + short* message_content = get_message_content(message); AdjustOrdering(message_header->length); for (int i = length / static_cast(sizeof(short)) - 1; i >= 0; i--) { AdjustOrdering(message_content[i]); diff --git a/daide_client/socket.h b/daide_client/socket.h index dcc9dc4..32a44fe 100644 --- a/daide_client/socket.h +++ b/daide_client/socket.h @@ -6,8 +6,8 @@ ///////////////////////////////////////////////////////////////////////////// -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_SOCKET_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_SOCKET_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_SOCKET_H +#define DAIDE_CLIENT_DAIDE_CLIENT_SOCKET_H #include #include @@ -15,7 +15,7 @@ #include #include -#include "daide_client/windaide_symbols.h" +#include "windaide_symbols.h" namespace DAIDE { @@ -103,4 +103,4 @@ T* get_message_content(const Socket::MessagePtr &message) { } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_SOCKET_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_SOCKET_H diff --git a/daide_client/token_message.cpp b/daide_client/token_message.cpp index db9a968..c9afad5 100644 --- a/daide_client/token_message.cpp +++ b/daide_client/token_message.cpp @@ -15,8 +15,8 @@ #include #include -#include "daide_client/token_message.h" -#include "daide_client/token_text_map.h" +#include "token_message.h" +#include "token_text_map.h" using DAIDE::Token; using DAIDE::TokenMessage; diff --git a/daide_client/token_message.h b/daide_client/token_message.h index 9952e6b..ccbffe1 100644 --- a/daide_client/token_message.h +++ b/daide_client/token_message.h @@ -12,11 +12,11 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_MESSAGE_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_MESSAGE_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_MESSAGE_H +#define DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_MESSAGE_H -#include "daide_client/tokens.h" -#include "daide_client/types.h" +#include "tokens.h" +#include "types.h" namespace DAIDE { @@ -126,4 +126,4 @@ class TokenMessage { } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_MESSAGE_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_MESSAGE_H diff --git a/daide_client/token_text_map.cpp b/daide_client/token_text_map.cpp index a8c79cb..1699de5 100644 --- a/daide_client/token_text_map.cpp +++ b/daide_client/token_text_map.cpp @@ -12,7 +12,7 @@ * Release 8~3 **/ -#include "daide_client/token_text_map.h" +#include "token_text_map.h" using DAIDE::TokenTextMap; diff --git a/daide_client/token_text_map.h b/daide_client/token_text_map.h index f81f210..074add3 100644 --- a/daide_client/token_text_map.h +++ b/daide_client/token_text_map.h @@ -12,10 +12,10 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_TEXT_MAP_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_TEXT_MAP_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_TEXT_MAP_H +#define DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_TEXT_MAP_H -#include "daide_client/tokens.h" +#include "tokens.h" namespace DAIDE { @@ -41,4 +41,4 @@ class TokenTextMap { } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_TEXT_MAP_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_TOKEN_TEXT_MAP_H diff --git a/daide_client/tokens.h b/daide_client/tokens.h index c2ea249..d6ba9c1 100644 --- a/daide_client/tokens.h +++ b/daide_client/tokens.h @@ -12,10 +12,10 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_TOKENS_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_TOKENS_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_TOKENS_H +#define DAIDE_CLIENT_DAIDE_CLIENT_TOKENS_H -#include "daide_client/types.h" +#include "types.h" namespace DAIDE { @@ -363,4 +363,4 @@ const Token TOKEN_END_OF_MESSAGE {0x5FFF}; } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_TOKENS_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_TOKENS_H diff --git a/daide_client/types.h b/daide_client/types.h index 0553b78..04e75a5 100644 --- a/daide_client/types.h +++ b/daide_client/types.h @@ -12,8 +12,8 @@ * Release 8~3 **/ -#ifndef _DAIDE_CLIENT_DAIDE_CLIENT_TYPES_H -#define _DAIDE_CLIENT_DAIDE_CLIENT_TYPES_H +#ifndef DAIDE_CLIENT_DAIDE_CLIENT_TYPES_H +#define DAIDE_CLIENT_DAIDE_CLIENT_TYPES_H #include #include @@ -28,4 +28,4 @@ const int ADJUDICATOR_NO_ERROR = -1; } // namespace DAIDE -#endif // _DAIDE_CLIENT_DAIDE_CLIENT_TYPES_H +#endif // DAIDE_CLIENT_DAIDE_CLIENT_TYPES_H diff --git a/daide_client/windaide_symbols.cpp b/daide_client/windaide_symbols.cpp index 3b72869..d27c142 100644 --- a/daide_client/windaide_symbols.cpp +++ b/daide_client/windaide_symbols.cpp @@ -1,3 +1,3 @@ -#include "daide_client/windaide_symbols.h" +#include "windaide_symbols.h" int WSAGetLastError() { return errno; }