mail[Wesnoth-commits] r20163 - /branches/1.2/src/server/server.cpp


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

Header


Content

Posted by Soliton on September 07, 2007 - 08:52:
Author: soliton
Date: Fri Sep  7 08:51:50 2007
New Revision: 20163

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20163&view=rev
Log:
nicer logging and error reporting

Modified:
    branches/1.2/src/server/server.cpp

Modified: branches/1.2/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.2/src/server/server.cpp?rev=20163&r1=20162&r2=20163&view=diff
==============================================================================
--- branches/1.2/src/server/server.cpp (original)
+++ branches/1.2/src/server/server.cpp Fri Sep  7 08:51:50 2007
@@ -407,7 +407,7 @@
                                        network::disconnect(sock);
                                } else if(ip_exceeds_connection_limit(ip)) {
                                        std::cerr << "rejected ip '" << ip << 
"' due to excessive connections\n";
-                                       
network::send_data(construct_error("Too many connections from your 
host."),sock);
+                                       
network::send_data(construct_error("Too many connections from your 
IP."),sock);
                                        network::disconnect(sock);
                                } else {
                                        
network::send_data(version_query_response_,sock);
@@ -428,7 +428,7 @@
                                std::cerr << "fatal network error: " << 
e.message << "\n";
                                break;
                        } else {
-                               std::cerr << "socket closed: " << e.message 
<< "\n";
+                               LOG_SERVER << "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() : "";
@@ -439,6 +439,7 @@
                                                
initial_response_.remove_child("user",index);
 
                                        players_.erase(pl_it);
+                                       std::cerr << "'" << pl_name << "' (" 
<< network::ip_address(e.socket) << ") has logged off\n";
                                }
 
                                not_logged_in_.remove_player(e.socket);
@@ -985,7 +986,7 @@
        //if the owner is banning someone from the game
        if(g->is_owner(sock) && (data.child("ban") != NULL || 
data.child("kick") != NULL)) {
                std::string name;
-               bool ban = false;;
+               bool ban = false;
                if (data.child("ban") != NULL) {
                        const config& u = *data.child("ban");
                        name = u["username"];
@@ -993,7 +994,6 @@
                } else if (data.child("kick") != NULL) {
                        const config& u = *data.child("kick");
                        name = u["username"];
-                       std::cerr << "kick: " << u["username"] << "\n";
                        ban = false;
                }
 
@@ -1005,17 +1005,21 @@
                }
 
                if(pl->first != sock && pl != players_.end()) {
+                       std::string owner = g->find_player(sock)->name();
                        if (ban) {
-                               g->ban_player(pl->first);
                                const config& msg = 
construct_server_message("You have been banned",*g);
                                network::send_data(msg, pl->first);
-
                                const config& p_msg = 
construct_server_message(pl->second.name() + " has been banned",*g);
                                g->send_data(p_msg);
+                               g->ban_player(pl->first);
+                               std::cerr << owner << " banned: " << name << 
" from game: " << g->id() << "\n";
                        } else {
+                               const config& msg = 
construct_server_message("You have been kicked",*g);
+                               network::send_data(msg, pl->first);
                                const config& p_msg = 
construct_server_message(pl->second.name() + " has been kicked",*g);
                                g->send_data(p_msg);
                                g->remove_player(pl->first);
+                               std::cerr << owner << " kicked: " << name << 
" from game: " << g->id() << "\n";
                        }
 
                        config leave_game;
@@ -1035,16 +1039,16 @@
                        
lobby_players_.send_data(sync_initial_response(),sock);
                } else if(pl == players_.end()) {
                        const config& response = construct_server_message(
-                                    "Ban failed: user '" + name + "' not 
found",*g);
+                                    "Kick/ban failed: user '" + name + "' 
not found",*g);
                        network::send_data(response,sock);
                }
        } else if(data.child("ban")) {
                const config& response = construct_server_message(
-                            "You cannot ban: not the game creator",*g);
+                            "You cannot ban: not the game host",*g);
                network::send_data(response,sock);
        } else if(data.child("kick")) {
                const config& response = construct_server_message(
-                            "You cannot kick: not the game creator",*g);
+                            "You cannot kick: not the game host",*g);
                network::send_data(response,sock);
        }
 




Related Messages


Powered by MHonArc, Updated Fri Sep 07 09:00:28 2007