also log leaving players on game destruction

This commit is contained in:
Gunter Labes 2009-03-26 00:45:09 +00:00
parent 26d73a1898
commit 4e6d11ab3b
2 changed files with 8 additions and 2 deletions

View file

@ -83,6 +83,10 @@ game::game(player_map& players, const network::connection host,
game::~game()
{
user_vector users = all_game_users();
for (user_vector::const_iterator u = users.begin(); u != users.end(); ++u) {
remove_player(*u, false, true);
}
for(std::vector<simple_wml::document*>::iterator i = history_.begin(); i != history_.end(); ++i) {
delete *i;
}
@ -935,7 +939,7 @@ bool game::add_player(const network::connection player, bool observer, bool admi
return true;
}
bool game::remove_player(const network::connection player, const bool disconnect) {
bool game::remove_player(const network::connection player, const bool disconnect, const bool destruct) {
if (!is_member(player)) {
ERR_GAME << "ERROR: User is not in this game. (socket: "
<< player << ")\n";
@ -976,6 +980,8 @@ bool game::remove_player(const network::connection player, const bool disconnect
<< (observer ? " as an observer" : "")
<< (disconnect ? " and disconnected" : "")
<< ". (socket: " << user->first << ")\n";
// No need to do anything more when the game gets destructed.
if (destruct) return true;
if (game_ended) {
send_server_message_to_all((user->second.name() + " ended the game.").c_str(), player);
return true;

View file

@ -96,7 +96,7 @@ public:
* no more players or the host left on a not yet
* started game.
*/
bool remove_player(const network::connection player, const bool disconnect=false);
bool remove_player(const network::connection player, const bool disconnect=false, const bool destruct=false);
/** Adds players and observers into one vector and returns that. */
const user_vector all_game_users() const;