[Wesnoth-commits] r10097 - /trunk/src/server/server.cpp (February 13, 2006 - 17:01)

Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Headers

 

Author: xan
Date: Mon Feb 13 17:01:10 2006
New Revision: 10097

URL: http://svn.gna.org/viewcvs/wesnoth?rev=10097&view=rev
Log:
[Message when player disconnects]: Get the player's name before it's removed. >.<

Modified:
    trunk/src/server/server.cpp

Modified: trunk/src/server/server.cpp
URL: http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=10097&r1=10096&r2=10097&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Mon Feb 13 17:01:10 2006
@@ -415,6 +415,7 @@
 				std::cerr << "socket closed: " << e.message << "\n";
 
 				const std::map<network::connection,player>::iterator pl_it = players_.find(e.socket);
+				const std::string pl_name = pl_it != players_.end() ? pl_it->second.name() : "";
 				if(pl_it != players_.end()) {
 					const config::child_list& users = initial_response_.get_children("user");
 					const size_t index = std::find(users.begin(),users.end(),pl_it->second.config_address()) - users.begin();
@@ -433,9 +434,8 @@
 						break;
 					} else {
 						bool observer = i->is_observer(e.socket);
-						const player_map::iterator pl = players_.find(e.socket);
-						if(! observer && pl != players_.end()) {
-							i->send_data(construct_server_message(pl->second.name() + " has disconnected",*i));
+						if(! observer && pl_name != "") {
+							i->send_data(construct_server_message(pl_name + " has disconnected",*i));
 						}
 						i->remove_player(e.socket);
 					}



Related Mails




Powered by MHonArc, Updated Mon Feb 13 17:40:20 2006