mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-14 06:50:11 +00:00
Store content names for game history viewer.
This commit is contained in:
parent
ba7ea3ca98
commit
96243ad778
@ -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) {
|
||||
|
@ -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<std::string, addon_version_info> addons; // the key is the addon_id
|
||||
/** the key is the addon_id */
|
||||
std::map<std::string, addon_version_info> addons;
|
||||
|
||||
/**
|
||||
* Takes a config with addon metadata (id, name, version, min_version) and adds
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user