Store the client version in the database.
This will now store the version of the client playing a side in `game_player_info`.
This commit is contained in:
parent
f7a21a02e4
commit
c04ecaa8fb
5 changed files with 14 additions and 12 deletions
|
@ -445,10 +445,10 @@ void fuh::db_update_game_end(const std::string& uuid, int game_id, const std::st
|
|||
}
|
||||
}
|
||||
|
||||
void fuh::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){
|
||||
void fuh::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){
|
||||
try {
|
||||
prepared_statement<void>("INSERT INTO `" + db_game_player_info_table_ + "`(INSTANCE_UUID, GAME_ID, USER_ID, SIDE_NUMBER, IS_HOST, FACTION) VALUES(?, ?, IFNULL((SELECT user_id FROM `"+db_users_table_+"` WHERE username = ?), -1), ?, ?, ?)",
|
||||
uuid, game_id, username, side_number, is_host, faction);
|
||||
prepared_statement<void>("INSERT INTO `" + db_game_player_info_table_ + "`(INSTANCE_UUID, GAME_ID, USER_ID, SIDE_NUMBER, IS_HOST, FACTION, CLIENT_VERSION) VALUES(?, ?, IFNULL((SELECT user_id FROM `"+db_users_table_+"` WHERE username = ?), -1), ?, ?, ?, ?)",
|
||||
uuid, game_id, username, side_number, is_host, faction, version);
|
||||
} catch (const sql_error& e) {
|
||||
ERR_UH << "Could not insert the game's player information on table `" + db_game_player_info_table_ + "`:" << e.message << std::endl;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class fuh : public user_handler {
|
|||
void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name);
|
||||
void db_update_game_start(const std::string& uuid, int game_id, const std::string& map_name, const std::string& era_name, int reload);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
|
|
|
@ -1620,7 +1620,8 @@ void server::handle_player_in_game(socket_ptr socket, std::shared_ptr<simple_wml
|
|||
const simple_wml::node::child_list& sides = g.get_sides_list();
|
||||
for(unsigned side_index = 0; side_index < sides.size(); ++side_index) {
|
||||
const simple_wml::node& side = *sides[side_index];
|
||||
user_handler_->db_insert_game_player_info(uuid_, g.id(), side["player_id"].to_string(), side["side"].to_int(), side["is_host"].to_bool(), side["faction"].to_string());
|
||||
std::string version = player_connections_.get<name_t>().find(side["player_id"].to_string())->info().version();
|
||||
user_handler_->db_insert_game_player_info(uuid_, g.id(), side["player_id"].to_string(), side["side"].to_int(), side["is_host"].to_bool(), side["faction"].to_string(), version);
|
||||
}
|
||||
|
||||
const std::string mods = multiplayer["active_mods"].to_string();
|
||||
|
|
|
@ -138,7 +138,7 @@ class user_handler {
|
|||
virtual void db_insert_game_info(const std::string& uuid, int game_id, const std::string& version, const std::string& name) =0;
|
||||
virtual void db_update_game_start(const std::string& uuid, int game_id, const std::string& map_name, const std::string& era_name, int reload) =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) =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) =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;
|
||||
};
|
||||
|
|
|
@ -81,12 +81,13 @@ create table game_info
|
|||
-- STATUS: the status of the side, currently only updated at game end
|
||||
create table game_player_info
|
||||
(
|
||||
INSTANCE_UUID CHAR(36) NOT NULL,
|
||||
GAME_ID INT UNSIGNED NOT NULL,
|
||||
USER_ID INT NOT NULL,
|
||||
SIDE_NUMBER SMALLINT UNSIGNED NOT NULL,
|
||||
IS_HOST BIT(1) NOT NULL,
|
||||
FACTION VARCHAR(255) NOT NULL,
|
||||
INSTANCE_UUID CHAR(36) NOT NULL,
|
||||
GAME_ID INT UNSIGNED NOT NULL,
|
||||
USER_ID INT NOT NULL,
|
||||
SIDE_NUMBER SMALLINT UNSIGNED NOT NULL,
|
||||
IS_HOST BIT(1) NOT NULL,
|
||||
FACTION VARCHAR(255) NOT NULL,
|
||||
CLIENT_VERSION VARCHAR(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (INSTANCE_UUID, GAME_ID, SIDE_NUMBER)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue