Store additional information in the database:
* mp_scenario_addon_id * mp_scenario_addon_version (host's version) * mp_era_addon_id * mp_era_addon_version (host's version) * active_mod_addon_ids * active_mod_versions (host's versions)
This commit is contained in:
parent
57f833872b
commit
0f2e4f69f7
7 changed files with 32 additions and 36 deletions
|
@ -443,10 +443,10 @@ std::string fuh::get_uuid(){
|
|||
}
|
||||
}
|
||||
|
||||
void fuh::db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password){
|
||||
void fuh::db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password, const std::string& map_source, const std::string& map_version, const std::string& era_source, const std::string& era_version){
|
||||
try {
|
||||
prepared_statement<void>("insert into `" + db_game_info_table_ + "`(INSTANCE_UUID, GAME_ID, INSTANCE_VERSION, GAME_NAME, MAP_NAME, ERA_NAME, RELOAD, OBSERVERS, PUBLIC, PASSWORD) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
uuid, game_id, version, name, map_name, era_name, reload, observers, is_public, has_password);
|
||||
prepared_statement<void>("insert into `" + db_game_info_table_ + "`(INSTANCE_UUID, GAME_ID, INSTANCE_VERSION, GAME_NAME, MAP_NAME, ERA_NAME, RELOAD, OBSERVERS, PUBLIC, PASSWORD, MAP_SOURCE_ADDON, MAP_VERSION, ERA_SOURCE_ADDON, ERA_VERSION) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
uuid, game_id, version, name, map_name, era_name, reload, observers, is_public, has_password, map_source, map_version, era_source, era_version);
|
||||
} catch (const sql_error& e) {
|
||||
ERR_UH << "Could not insert into table `" + db_game_info_table_ + "`:" << e.message << std::endl;
|
||||
}
|
||||
|
@ -470,10 +470,10 @@ void fuh::db_insert_game_player_info(const std::string& uuid, int game_id, const
|
|||
}
|
||||
}
|
||||
|
||||
void fuh::db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name){
|
||||
void fuh::db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name, const std::string& modification_source, const std::string& modification_version){
|
||||
try {
|
||||
prepared_statement<void>("insert into `" + db_game_modification_info_table_ + "`(INSTANCE_UUID, GAME_ID, MODIFICATION_NAME) values(?, ?, ?)",
|
||||
uuid, game_id, modification_name);
|
||||
prepared_statement<void>("insert into `" + db_game_modification_info_table_ + "`(INSTANCE_UUID, GAME_ID, MODIFICATION_NAME, SOURCE_ADDON, VERSION) values(?, ?, ?, ?, ?)",
|
||||
uuid, game_id, modification_name, modification_source, modification_version);
|
||||
} catch (const sql_error& e) {
|
||||
ERR_UH << "Could not insert the game's modification information on table `" + db_game_modification_info_table_ + "`:" << e.message << std::endl;
|
||||
}
|
||||
|
|
|
@ -81,10 +81,10 @@ class fuh : public user_handler {
|
|||
bool use_phpbb_encryption() const { return true; }
|
||||
|
||||
std::string get_uuid();
|
||||
void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password);
|
||||
void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password, const std::string& map_source, const std::string& map_version, const std::string& era_source, const std::string& era_version);
|
||||
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_modification_info(const std::string& uuid, int game_id, const std::string& modification_name);
|
||||
void db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name, const std::string& modification_source, const std::string& modification_version);
|
||||
void db_set_oos_flag(const std::string& uuid, int game_id);
|
||||
|
||||
private:
|
||||
|
|
|
@ -237,19 +237,3 @@ std::string suh::user_info(const std::string& name) {
|
|||
std::string suh::get_uuid(){
|
||||
return "";
|
||||
}
|
||||
|
||||
void suh::db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password){
|
||||
std::cout << uuid << " - " << game_id << " - " << version << " - " << name << " - " << map_name << " - " << era_name << " - " << reload << " - " << observers << " - " << is_public << " - " << has_password << std::endl;
|
||||
}
|
||||
void suh::db_update_game_end(const std::string& uuid, int game_id, const std::string& replay_location){
|
||||
std::cout << uuid << " - " << game_id << " - " << replay_location << std::endl;
|
||||
}
|
||||
void suh::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){
|
||||
std::cout << uuid << " - " << game_id << " - " << username << " - " << side_number << " - " << is_host << " - " << faction << " - " << version << " - " << source << " - " << current_user << std::endl;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -68,11 +68,11 @@ class suh : public user_handler {
|
|||
bool use_phpbb_encryption() const { return false; }
|
||||
|
||||
std::string get_uuid();
|
||||
void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_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_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);
|
||||
void db_insert_game_info(const std::string&, int, const std::string&, const std::string&, const std::string&, const std::string&, int, int, int, int, const std::string&, const std::string&, const std::string&, const std::string&){}
|
||||
void db_update_game_end(const std::string&, int, const std::string&){}
|
||||
void db_insert_game_player_info(const std::string&, int, const std::string&, int, int, const std::string&, const std::string&, const std::string&, const std::string&){}
|
||||
void db_insert_modification_info(const std::string&, int, const std::string&, const std::string&, const std::string&){}
|
||||
void db_set_oos_flag(const std::string&, int){}
|
||||
|
||||
private:
|
||||
std::string get_mail(const std::string& user);
|
||||
|
|
|
@ -1752,7 +1752,7 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
// 1.14.9 and earlier also use whether observers are allowed to determine if the replay should be public
|
||||
// 1.14.10+ have a separate attribute for that
|
||||
bool is_public = m["private_replay"].to_string() == "" ? m["observer"].to_bool() : !m["private_replay"].to_bool();
|
||||
user_handler_->db_insert_game_info(uuid_, g.db_id(), game_config::wesnoth_version.str(), g.name(), m["mp_scenario"].to_string(), m["mp_era"].to_string(), g.is_reload(), m["observer"].to_bool(), is_public, g.has_password());
|
||||
user_handler_->db_insert_game_info(uuid_, g.db_id(), game_config::wesnoth_version.str(), g.name(), m["mp_scenario"].to_string(), m["mp_era"].to_string(), g.is_reload(), m["observer"].to_bool(), is_public, g.has_password(), m["mp_scenario_addon_id"].to_string(), m["mp_scenario_addon_version"].to_string(), m["mp_era_addon_id"].to_string(), m["mp_era_addon_version"].to_string());
|
||||
|
||||
const simple_wml::node::child_list& sides = g.get_sides_list();
|
||||
for(unsigned side_index = 0; side_index < sides.size(); ++side_index) {
|
||||
|
@ -1776,10 +1776,12 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
user_handler_->db_insert_game_player_info(uuid_, g.db_id(), side["player_id"].to_string(), side["side"].to_int(), side["is_host"].to_bool(), side["faction"].to_string(), version, source, side["current_player"].to_string());
|
||||
}
|
||||
|
||||
const std::string mods = m["active_mods"].to_string();
|
||||
if(mods != "") {
|
||||
for(const std::string mod : utils::split(mods, ',')){
|
||||
user_handler_->db_insert_modification_info(uuid_, g.db_id(), mod);
|
||||
const std::vector<std::string> mods = utils::split(m["active_mods"].to_string());
|
||||
const std::vector<std::string> mod_sources = utils::split(m["active_mod_versions"].to_string());
|
||||
const std::vector<std::string> mod_versions = utils::split(m["active_mod_addon_ids"].to_string());
|
||||
if(mods.size() != 0) {
|
||||
for(unsigned int i = 0; i < mods.size(); i++){
|
||||
user_handler_->db_insert_modification_info(uuid_, g.db_id(), mods[i], mod_sources[i], mod_versions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,10 +172,10 @@ class user_handler {
|
|||
virtual bool use_phpbb_encryption() const =0;
|
||||
|
||||
virtual std::string get_uuid() =0;
|
||||
virtual void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password) =0;
|
||||
virtual void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name, const std::string& map_name, const std::string& era_name, int reload, int observers, int is_public, int has_password, const std::string& map_source, const std::string& map_version, const std::string& era_source, const std::string& era_version) =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_modification_info(const std::string& uuid, int game_id, const std::string& modification_name) =0;
|
||||
virtual void db_insert_modification_info(const std::string& uuid, int game_id, const std::string& modification_name, const std::string& modification_source, const std::string& modification_version) =0;
|
||||
virtual void db_set_oos_flag(const std::string& uuid, int game_id) =0;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -51,7 +51,11 @@ create table extra
|
|||
-- START_TIME: when the players enter the game and begin playing
|
||||
-- END_TIME: when the game ends, for any particular reason
|
||||
-- MAP_NAME: the mp_scenario attribute value
|
||||
-- MAP_SOURCE_ADDON: the add-on the map comes from
|
||||
-- MAP_VERSION: the version of the add-on the map comes from
|
||||
-- ERA_NAME: the mp_era attribute value
|
||||
-- ERA_SOURCE_ADDON: the add-on the era comes from
|
||||
-- ERA_VERSION: the version of the add-on the era comes from
|
||||
-- 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
|
||||
|
@ -63,7 +67,11 @@ create table game_info
|
|||
START_TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
END_TIME TIMESTAMP NULL DEFAULT NULL,
|
||||
MAP_NAME VARCHAR(255) NOT NULL,
|
||||
MAP_SOURCE_ADDON VARCHAR(255) NOT NULL DEFAULT '',
|
||||
MAP_VERSION VARCHAR(255) NOT NULL DEFAULT '',
|
||||
ERA_NAME VARCHAR(255) NOT NULL,
|
||||
ERA_SOURCE_ADDON VARCHAR(255) NOT NULL DEFAULT '',
|
||||
ERA_VERSION VARCHAR(255) NOT NULL DEFAULT '',
|
||||
REPLAY_NAME VARCHAR(255),
|
||||
OOS BIT(1) NOT NULL DEFAULT 0,
|
||||
RELOAD BIT(1) NOT NULL,
|
||||
|
@ -102,5 +110,7 @@ create table game_modification_info
|
|||
INSTANCE_UUID CHAR(36) NOT NULL,
|
||||
GAME_ID INT UNSIGNED NOT NULL,
|
||||
MODIFICATION_NAME VARCHAR(255) NOT NULL,
|
||||
SOURCE_ADDON VARCHAR(255) NOT NULL DEFAULT '',
|
||||
VERSION VARCHAR(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (INSTANCE_UUID, GAME_ID, MODIFICATION_NAME)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
|
Loading…
Add table
Reference in a new issue