From b9246dc6b4fee54751fcb37ad3ec97f751e7926a Mon Sep 17 00:00:00 2001 From: Pentarctagon Date: Fri, 16 Aug 2019 16:17:26 -0500 Subject: [PATCH] Add a flag to record if the game encountered an OOS error. --- src/server/forum_user_handler.cpp | 9 +++++++++ src/server/forum_user_handler.hpp | 1 + src/server/sample_user_handler.cpp | 4 ++++ src/server/sample_user_handler.hpp | 1 + src/server/server.cpp | 3 +++ src/server/user_handler.hpp | 1 + utils/mp-server/table_definitions.sql | 2 ++ 7 files changed, 21 insertions(+) diff --git a/src/server/forum_user_handler.cpp b/src/server/forum_user_handler.cpp index 33791f1282b..1aae75455f1 100644 --- a/src/server/forum_user_handler.cpp +++ b/src/server/forum_user_handler.cpp @@ -482,4 +482,13 @@ void fuh::db_insert_modification_info(const std::string& uuid, int game_id, cons } } +void fuh::db_set_oos_flag(const std::string& uuid, int game_id){ + try { + prepared_statement("UPDATE `" + db_game_info_table_ + "` SET OOS = 'Y' WHERE INSTANCE_UUID = ? AND GAME_ID = ?", + uuid, game_id); + } catch (const sql_error& e) { + ERR_UH << "Could not update the game's OOS flag on table `" + db_game_info_table_ + "`:" << e.message << std::endl; + } +} + #endif //HAVE_MYSQLPP diff --git a/src/server/forum_user_handler.hpp b/src/server/forum_user_handler.hpp index edfda375570..e66c647d85d 100644 --- a/src/server/forum_user_handler.hpp +++ b/src/server/forum_user_handler.hpp @@ -87,6 +87,7 @@ class fuh : public user_handler { void db_update_game_end(const std::string& uuid, int game_id, const std::string& replay_location); void db_insert_game_player_info(const std::string& uuid, int game_id, const std::string& username, int side_number, const std::string& is_host, const std::string& faction); void db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name); + void db_set_oos_flag(const std::string& uuid, int game_id); private: std::string get_hash(const std::string& user); diff --git a/src/server/sample_user_handler.cpp b/src/server/sample_user_handler.cpp index f741e7ca919..8899fa1095e 100644 --- a/src/server/sample_user_handler.cpp +++ b/src/server/sample_user_handler.cpp @@ -252,4 +252,8 @@ void suh::db_insert_game_player_info(const std::string& uuid, int game_id, const } void suh::db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name){ std::cout << uuid << " - " << game_id << " - " << modification_name << std::endl; +} + +void suh::db_set_oos_flag(const std::string& uuid, int game_id){ + std::cout << uuid << " - " << game_id << " - " << "OOS occurred!" << std::endl; } \ No newline at end of file diff --git a/src/server/sample_user_handler.hpp b/src/server/sample_user_handler.hpp index 4d36bd1d9be..28dffa82319 100644 --- a/src/server/sample_user_handler.hpp +++ b/src/server/sample_user_handler.hpp @@ -73,6 +73,7 @@ class suh : public user_handler { void db_update_game_end(const std::string& uuid, int game_id, const std::string& replay_location); void db_insert_game_player_info(const std::string& uuid, int game_id, const std::string& username, int side_number, const std::string& is_host, const std::string& faction); void db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name); + void db_set_oos_flag(const std::string& uuid, int game_id); private: std::string get_mail(const std::string& user); diff --git a/src/server/server.cpp b/src/server/server.cpp index 248db9356de..129e2aaf913 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -1859,6 +1859,9 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptrdb_set_oos_flag(uuid_, g.id()); + } } } diff --git a/src/server/user_handler.hpp b/src/server/user_handler.hpp index edd8f7c0264..048af5bed7c 100644 --- a/src/server/user_handler.hpp +++ b/src/server/user_handler.hpp @@ -177,6 +177,7 @@ class user_handler { virtual void db_update_game_end(const std::string& uuid, int game_id, const std::string& replay_location) =0; virtual void db_insert_game_player_info(const std::string& uuid, int game_id, const std::string& username, int side_number, const std::string& is_host, const std::string& faction) =0; virtual void db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name) =0; + virtual void db_set_oos_flag(const std::string& uuid, int game_id) =0; protected: diff --git a/utils/mp-server/table_definitions.sql b/utils/mp-server/table_definitions.sql index 62681b0487b..3e495addde8 100644 --- a/utils/mp-server/table_definitions.sql +++ b/utils/mp-server/table_definitions.sql @@ -53,6 +53,7 @@ CREATE TABLE extra -- MAP_NAME: the mp_scenario attribute value -- ERA_NAME: the mp_era attribute value -- REPLAY_NAME: the file name of the replay create when the game is ended +-- OOS: Y/N flag of whether the game encountered an OOS error create table game_info ( INSTANCE_UUID CHAR(36) NOT NULL, @@ -65,6 +66,7 @@ create table game_info MAP_NAME VARCHAR(255), ERA_NAME VARCHAR(255), REPLAY_NAME VARCHAR(255), + OOS CHAR(1) NOT NULL DEFAULT 'N', primary key (INSTANCE_UUID, GAME_ID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;