diff --git a/src/mp_game_settings.cpp b/src/mp_game_settings.cpp index 19512d2d76d..baf7c30cc22 100644 --- a/src/mp_game_settings.cpp +++ b/src/mp_game_settings.cpp @@ -150,7 +150,7 @@ mp_game_settings::addon_version_info::addon_version_info(const config & cfg) min_version = cfg["min_version"].str(); } for(const auto& child : cfg.child_range("content")) { - content.emplace_back(addon_content{ child["id"].str(), child["type"].str() }); + content.emplace_back(addon_content{ child["id"].str(), child["name"].str(), child["type"].str() }); } } @@ -167,6 +167,7 @@ void mp_game_settings::addon_version_info::write(config & cfg) const { for(const auto& item : content) { config& c = cfg.add_child("content"); c["id"] = item.id; + c["name"] = item.name; c["type"] = item.type; } } @@ -188,7 +189,7 @@ void mp_game_settings::update_addon_requirements(const config & cfg) { // an add-on can contain multiple types of content // for example, an era and a scenario for(const auto& item : new_data.content) { - addon.content.emplace_back(addon_content{ item.id, item.type }); + addon.content.emplace_back(addon_content{ item.id, item.name, item.type }); } if(addon.version != new_data.version) { diff --git a/src/mp_game_settings.hpp b/src/mp_game_settings.hpp index b36367f1cf6..2f34f3d7b10 100644 --- a/src/mp_game_settings.hpp +++ b/src/mp_game_settings.hpp @@ -82,6 +82,7 @@ struct mp_game_settings struct addon_content { std::string id; + std::string name; std::string type; }; @@ -97,7 +98,8 @@ struct mp_game_settings void write(config &) const; }; - std::map addons; // the key is the addon_id + /** the key is the addon_id */ + std::map addons; /** * Takes a config with addon metadata (id, name, version, min_version) and adds diff --git a/src/saved_game.cpp b/src/saved_game.cpp index 575613173b3..c9f2a319dd7 100644 --- a/src/saved_game.cpp +++ b/src/saved_game.cpp @@ -305,6 +305,7 @@ void saved_game::check_require_scenario() scenario["required"] = starting_point_["require_scenario"].to_bool(false); config& content = scenario.add_child("content"); content["id"] = starting_point_["id"]; + content["name"] = starting_point_["name"]; content["type"] = "scenario"; mp_settings_.update_addon_requirements(scenario); @@ -330,6 +331,7 @@ void saved_game::load_non_scenario(const std::string& type, const std::string& i non_scenario["required"] = cfg[require_attr].to_bool(require_default); config& content = non_scenario.add_child("content"); content["id"] = id; + content["name"] = cfg["addon_title"].str(cfg["name"].str("Unknown")); content["type"] = type; mp_settings_.update_addon_requirements(non_scenario); diff --git a/src/server/common/dbconn.cpp b/src/server/common/dbconn.cpp index f2cb84eb8ee..2351abf787e 100644 --- a/src/server/common/dbconn.cpp +++ b/src/server/common/dbconn.cpp @@ -257,12 +257,12 @@ void dbconn::insert_game_player_info(const std::string& uuid, int game_id, const log_sql_exception("Failed to insert game player info row for UUID `"+uuid+"` and game ID `"+std::to_string(game_id)+"`", e); } } -void dbconn::db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& id, const std::string& source, const std::string& version) +void dbconn::db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version) { try { - modify(connection_, "INSERT INTO `"+db_game_content_info_table_+"`(INSTANCE_UUID, GAME_ID, TYPE, ID, SOURCE, VERSION) VALUES(?, ?, ?, ?, ?, ?)", - uuid, game_id, type, id, source, version); + modify(connection_, "INSERT INTO `"+db_game_content_info_table_+"`(INSTANCE_UUID, GAME_ID, TYPE, NAME, ID, SOURCE, VERSION) VALUES(?, ?, ?, ?, ?, ?, ?)", + uuid, game_id, type, name, id, source, version); } catch(const mariadb::exception::base& e) { diff --git a/src/server/common/dbconn.hpp b/src/server/common/dbconn.hpp index 03de857e114..c37dc67cd9f 100644 --- a/src/server/common/dbconn.hpp +++ b/src/server/common/dbconn.hpp @@ -47,7 +47,7 @@ class dbconn void insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, int reload, int observers, int is_public, int has_password); void update_game_end(const std::string& uuid, int game_id, const std::string& replay_location); void insert_game_player_info(const std::string& uuid, int game_id, const std::string& username, int side_number, int is_host, const std::string& faction, const std::string& version, const std::string& source, const std::string& current_user); - void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& id, const std::string& source, const std::string& version); + void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version); void set_oos_flag(const std::string& uuid, int game_id); private: diff --git a/src/server/common/forum_user_handler.cpp b/src/server/common/forum_user_handler.cpp index dca6d792539..0de8d0f0551 100644 --- a/src/server/common/forum_user_handler.cpp +++ b/src/server/common/forum_user_handler.cpp @@ -229,8 +229,8 @@ void fuh::db_insert_game_player_info(const std::string& uuid, int game_id, const conn_.insert_game_player_info(uuid, game_id, username, side_number, is_host, faction, version, source, current_user); } -void fuh::db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& id, const std::string& source, const std::string& version){ - conn_.db_insert_game_content_info(uuid, game_id, type, id, source, version); +void fuh::db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version){ + conn_.db_insert_game_content_info(uuid, game_id, type, name, id, source, version); } void fuh::db_set_oos_flag(const std::string& uuid, int game_id){ diff --git a/src/server/common/forum_user_handler.hpp b/src/server/common/forum_user_handler.hpp index 198ea270848..889b9027414 100644 --- a/src/server/common/forum_user_handler.hpp +++ b/src/server/common/forum_user_handler.hpp @@ -74,7 +74,7 @@ public: void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, int reload, int observers, int is_public, int has_password); 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, int is_host, const std::string& faction, const std::string& version, const std::string& source, const std::string& current_user); - void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& id, const std::string& source, const std::string& version); + void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version); void db_set_oos_flag(const std::string& uuid, int game_id); void async_test_query(boost::asio::io_service& io_service, int limit); diff --git a/src/server/common/user_handler.hpp b/src/server/common/user_handler.hpp index 608cc6e9293..0ef75d29ecf 100644 --- a/src/server/common/user_handler.hpp +++ b/src/server/common/user_handler.hpp @@ -144,7 +144,7 @@ public: virtual void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, int reload, int observers, int is_public, int has_password) = 0; 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, int is_host, const std::string& faction, const std::string& version, const std::string& source, const std::string& current_user) = 0; - virtual void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& id, const std::string& source, const std::string& version) = 0; + virtual void db_insert_game_content_info(const std::string& uuid, int game_id, const std::string& type, const std::string& name, const std::string& id, const std::string& source, const std::string& version) = 0; virtual void db_set_oos_flag(const std::string& uuid, int game_id) = 0; virtual void async_test_query(boost::asio::io_service& io_service, int limit) = 0; }; diff --git a/src/server/wesnothd/server.cpp b/src/server/wesnothd/server.cpp index 7dea1067d7b..e2dc5797202 100644 --- a/src/server/wesnothd/server.cpp +++ b/src/server/wesnothd/server.cpp @@ -1636,7 +1636,7 @@ void server::handle_player_in_game(socket_ptr socket, simple_wml::document& data // [addon] info handling for(const auto& addon : m.children("addon")) { for(const auto& content : addon->children("content")) { - user_handler_->db_insert_game_content_info(uuid_, g.db_id(), content->attr("type").to_string(), content->attr("id").to_string(), addon->attr("id").to_string(), addon->attr("version").to_string()); + user_handler_->db_insert_game_content_info(uuid_, g.db_id(), content->attr("type").to_string(), content->attr("name").to_string(), content->attr("id").to_string(), addon->attr("id").to_string(), addon->attr("version").to_string()); } } diff --git a/utils/mp-server/table_definitions.sql b/utils/mp-server/table_definitions.sql index 530cb4a4b0b..bd4543cc1cf 100644 --- a/utils/mp-server/table_definitions.sql +++ b/utils/mp-server/table_definitions.sql @@ -101,6 +101,7 @@ create table game_player_info -- information about the scenario/era/modifications for the game -- TYPE: one of era/scenario/modification -- ID: the id of the content +-- NAME: the content's user-visible name -- SOURCE: the id of the add-on that the particular content came from -- VERSION: the version of the source add-on create table game_content_info @@ -109,6 +110,7 @@ create table game_content_info GAME_ID INT UNSIGNED NOT NULL, TYPE VARCHAR(255) NOT NULL, ID VARCHAR(255) NOT NULL, + NAME VARCHAR(255), SOURCE VARCHAR(255) NOT NULL, VERSION VARCHAR(255) NOT NULL, PRIMARY KEY (INSTANCE_UUID, GAME_ID, TYPE, ID)