mail[Wesnoth-commits] r29037 - in /trunk/src/server: game.cpp game.hpp server.cpp


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

Header


Content

Posted by paniemin on August 27, 2008 - 23:58:
Author: suokko
Date: Wed Aug 27 23:58:28 2008
New Revision: 29037

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29037&view=rev
Log:
Moved server game class to wesnothd namespace

Modified:
    trunk/src/server/game.cpp
    trunk/src/server/game.hpp
    trunk/src/server/server.cpp

Modified: trunk/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.cpp?rev=29037&r1=29036&r2=29037&view=diff
==============================================================================
--- trunk/src/server/game.cpp (original)
+++ trunk/src/server/game.cpp Wed Aug 27 23:58:28 2008
@@ -49,6 +49,7 @@
 
 } // end chat_message namespace
 
+namespace wesnothd {
 int game::id_num = 1;
 
 game::game(player_map& players, const network::connection host, 
@@ -1355,3 +1356,4 @@
                send_to_one(doc, sock);
        }
 }
+}

Modified: trunk/src/server/game.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.hpp?rev=29037&r1=29036&r2=29037&view=diff
==============================================================================
--- trunk/src/server/game.hpp (original)
+++ trunk/src/server/game.hpp Wed Aug 27 23:58:28 2008
@@ -24,6 +24,8 @@
 #include <vector>
 
 //class player;
+
+namespace wesnothd {
 
 typedef std::map<network::connection,player> player_map;
 typedef std::vector<network::connection> user_vector;
@@ -217,11 +219,12 @@
 };
 
 struct game_id_matches {
-       game_id_matches(int id) : id_(id) {}
+       game_id_matches(int id) : id_(id) {};
        bool operator()(const game* g) const { return g->id() == id_; }
 
 private:
        int id_;
 };
-
+}
 #endif
+

Modified: trunk/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=29037&r1=29036&r2=29037&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Wed Aug 27 23:58:28 2008
@@ -62,6 +62,7 @@
 #ifndef _WIN32
 #include <sys/times.h>
 
+
 namespace {
 
 clock_t get_cpu_time(bool active) {
@@ -279,10 +280,10 @@
        player_map players_;
        player_map ghost_players_ ;
 
-       std::vector<game*> games_;
-       game not_logged_in_;
+       std::vector<wesnothd::game*> games_;
+       wesnothd::game not_logged_in_;
        //! The lobby is implemented as a game.
-       game lobby_;
+       wesnothd::game lobby_;
 
        //! server socket/fifo
        input_stream& input_;
@@ -346,9 +347,9 @@
                                simple_wml::document& data);
        void process_data_game(const network::connection sock,
                               simple_wml::document& data);
-       void delete_game(std::vector<game*>::iterator game_it);
-
-       void update_game_in_lobby(const game* g, network::connection 
exclude=0);
+       void delete_game(std::vector<wesnothd::game*>::iterator game_it);
+
+       void update_game_in_lobby(const wesnothd::game* g, 
network::connection exclude=0);
 
        void start_new_server();
 };
@@ -814,7 +815,7 @@
                                        << "\thas logged off. (socket: " << 
e.socket << ")\n";
                                                 
                        } else {
-                               for (std::vector<game*>::iterator g = 
games_.begin();
+                               for (std::vector<wesnothd::game*>::iterator g 
= games_.begin();
                                        g != games_.end(); ++g)
                                {
                                        if (!(*g)->is_member(e.socket)) {
@@ -1094,7 +1095,7 @@
        LOG_SERVER << network::ip_address(sock) << "\t" << username
                << "\thas logged on. (socket: " << sock << ")\n";
 
-       for (std::vector<game*>::const_iterator g = games_.begin(); g != 
games_.end(); ++g) {
+       for (std::vector<wesnothd::game*>::const_iterator g = games_.begin(); 
g != games_.end(); ++g) {
                // Note: This string is parsed by the client to identify 
lobby join messages!
                (*g)->send_server_message_to_all((username + " has logged 
into the lobby").c_str());
        }
@@ -1218,7 +1219,7 @@
                }
                lobby_.send_server_message_to_all(parameters.c_str());
                if (command == "msg") {
-                       for (std::vector<game*>::const_iterator g = 
games_.begin(); g != games_.end(); ++g) {
+                       for (std::vector<wesnothd::game*>::const_iterator g = 
games_.begin(); g != games_.end(); ++g) {
                                
(*g)->send_server_message_to_all(parameters.c_str());
                        }
                }
@@ -1514,7 +1515,7 @@
                        continue;
                }
 
-               std::vector<game*>::const_iterator g;
+               std::vector<wesnothd::game*>::const_iterator g;
                for (g = games_.begin(); g != games_.end(); ++g) {
                        if (!(*g)->is_member(i->first)) continue;
                        // Don't send to players in a running game the sender 
is part of.
@@ -1569,8 +1570,8 @@
                        << "\tcreates a new game: \"" << game_name << "\".\n";
                // Create the new game, remove the player from the lobby
                // and set the player as the host/owner.
-               games_.push_back(new game(players_, sock, game_name));
-               game& g = *games_.back();
+               games_.push_back(new wesnothd::game(players_, sock, 
game_name));
+               wesnothd::game& g = *games_.back();
                if(game_password.empty() == false) {
                        g.set_password(game_password);
                }
@@ -1591,7 +1592,7 @@
                const std::string& password = 
(*data.root().child("join"))["password"].to_string();
                int game_id = (*data.root().child("join"))["id"].to_int();
 
-               const std::vector<game*>::iterator g =
+               const std::vector<wesnothd::game*>::iterator g =
                        std::find_if(games_.begin(),games_.end(), 
game_id_matches(game_id));
 
                static simple_wml::document 
leave_game_doc("[leave_game]\n[/leave_game]\n", simple_wml::INIT_COMPRESSED);
@@ -1679,7 +1680,7 @@
                return;
        }
 
-       std::vector<game*>::iterator itor;
+       std::vector<wesnothd::game*>::iterator itor;
        for (itor = games_.begin(); itor != games_.end(); ++itor) {
                if ((*itor)->is_owner(sock) || (*itor)->is_member(sock))
                        break;
@@ -1690,7 +1691,7 @@
                return;
        }
 
-       game* g = *itor;
+       wesnothd::game* g = *itor;
 
        // If this is data describing the level for a game.
        if (data.root().child("side")) {
@@ -2018,7 +2019,7 @@
                << ". (socket:" << sock << ")\n" << data.output();
 }
 
-void server::delete_game(std::vector<game*>::iterator game_it) {
+void server::delete_game(std::vector<wesnothd::game*>::iterator game_it) {
        metrics_.game_terminated((*game_it)->termination_reason());
 
        simple_wml::node* const gamelist = 
games_and_users_list_.child("gamelist");
@@ -2077,7 +2078,7 @@
        games_.erase(game_it);
 }
 
-void server::update_game_in_lobby(const game* g, network::connection exclude)
+void server::update_game_in_lobby(const wesnothd::game* g, 
network::connection exclude)
 {
        simple_wml::document diff;
        if(make_change_diff(*games_and_users_list_.root().child("gamelist"), 
"gamelist", "game", g->description(), diff)) {




Related Messages


Powered by MHonArc, Updated Thu Aug 28 00:01:27 2008