Author: soliton
Date: Wed Apr  1 11:56:55 2009
New Revision: 34371

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34371&view=rev
Log:
added some more logging and checks to figure out why players sometimes not get 
properly removed from a game (or readded as observers)

Modified:
    branches/1.6/changelog
    branches/1.6/src/server/game.cpp
    branches/1.6/src/server/server.cpp

Modified: branches/1.6/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/changelog?rev=34371&r1=34370&r2=34371&view=diff
==============================================================================
--- branches/1.6/changelog (original)
+++ branches/1.6/changelog Wed Apr  1 11:56:55 2009
@@ -12,7 +12,7 @@
    * updated translations: British English, Catalan, Chinese (Simplified),
      Czech, German, Finnish, Hebrew, Italian, Russian, Slovak, Turkish
  * Multiplayer server:
-     * Implemented automatic saving of game replays.
+   * Implemented automatic saving of game replays.
  * Miscellaneous and bugfixes:
    * Fixed an infinite loop issue when no music tracks could be loaded
    * Fixed compilation with -D_GLIBCXX_PARALLEL

Modified: branches/1.6/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/server/game.cpp?rev=34371&r1=34370&r2=34371&view=diff
==============================================================================
--- branches/1.6/src/server/game.cpp (original)
+++ branches/1.6/src/server/game.cpp Wed Apr  1 11:56:55 2009
@@ -416,7 +416,8 @@
        }
        sides_[side_num - 1] = 0;
        // If the old player lost his last side, make him an observer.
-       if (std::find(sides_.begin(), sides_.end(), old_player) == 
sides_.end()) {
+       if (std::find(sides_.begin(), sides_.end(), old_player) == sides_.end()
+       && is_player(old_player)) {
                observers_.push_back(old_player);
                players_.erase(std::remove(players_.begin(), players_.end(), 
old_player), players_.end());
                // Tell others that the player becomes an observer.
@@ -443,7 +444,11 @@
                const std::string controller)
 {
        DBG_GAME << __func__ << "...\n";
-       if (player == player_info_->end()) return;
+       if (player == player_info_->end()) {
+               ERR_GAME << "ERROR: Could not find player in player_info_."
+                               " Can't change controller!\n";
+               return;
+       }
 
        const network::connection sock = player->first;
        const std::string& player_name = player->second.name();
@@ -899,6 +904,10 @@
                // Send observer join to everyone except the new observer.
                send_data(observer_join, player);
        }
+       LOG_GAME << network::ip_address(player) << "\t" << user->second.name()
+               << "\tjoined game:\t\"" << name_ << "\" (" << id_ << ")"
+               << (observer || became_observer ? " as an observer" : "")
+               << ". (socket: " << player << ")\n";
        user->second.mark_available(id_, name_);
        DBG_GAME << debug_player_info();
        // Send the user the game data.

Modified: branches/1.6/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/server/server.cpp?rev=34371&r1=34370&r2=34371&view=diff
==============================================================================
--- branches/1.6/src/server/server.cpp (original)
+++ branches/1.6/src/server/server.cpp Wed Apr  1 11:56:55 2009
@@ -1872,20 +1872,17 @@
                        send_doc(games_and_users_list_, sock);
                        return;
                }
+               // Hack to work around problems of players not getting properly 
removed
+               // from a game. Still need to figure out actual cause...
                const std::vector<wesnothd::game*>::iterator g2 =
                        std::find_if(games_.begin(),games_.end(), 
wesnothd::game_is_member(sock));
                if (g2 != games_.end()) {
                        WRN_SERVER << network::ip_address(sock) << "\t" << 
pl->second.name()
                                << "\tattempted to join a second game. He's 
already in game:\t\""
-                               << (*g2)->name() << "\" (" << (*g2)->id() << 
")." << "(socket: "
-                               << sock << ")\n";
-                       send_doc(leave_game_doc, sock);
-                       lobby_.send_server_message(("Attempt to join a second 
game."
-                                       " You're already in game: \"" + 
(*g2)->name() + "\"."
-                                       " (You may have to log off and back on 
to get your client"
-                                       " in sync again.)").c_str(), sock);
-                       send_doc(games_and_users_list_, sock);
-                       return;
+                               << (*g2)->name() << "\" (" << (*g2)->id()
+                               << ") and the lobby. (socket: " << sock << ")\n"
+                               << "Removing him from that game to fix the 
inconsistency...\n";
+                       (*g2)->remove_player(sock);
                }
                bool joined = (*g)->add_player(sock, observer, admin);
                if (!joined) {
@@ -1897,10 +1894,6 @@
                        send_doc(games_and_users_list_, sock);
                        return;
                }
-               LOG_SERVER << network::ip_address(sock) << "\t" << 
pl->second.name()
-                       << "\tjoined game:\t\"" << (*g)->name()
-                       << "\" (" << game_id << ")" << (observer ? " as an 
observer" : "")
-                       << ". (socket: " << sock << ")\n";
                lobby_.remove_player(sock);
                (*g)->describe_slots();
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to