Author: soliton
Date: Sun Apr 27 08:14:45 2008
New Revision: 26161
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26161&view=rev
Log:
* abort games with more than MAX_PLAYERS sides
Modified:
branches/1.4/src/server/game.cpp
branches/1.4/src/server/server.cpp
Modified: branches/1.4/src/server/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/game.cpp?rev=26161&r1=26160&r2=26161&view=diff
==============================================================================
--- branches/1.4/src/server/game.cpp (original)
+++ branches/1.4/src/server/game.cpp Sun Apr 27 08:14:45 2008
@@ -841,7 +841,7 @@
turn_ended = true;
}
// Skip over empty sides.
- for (int i = 0; i < nsides_ && side_controllers_[current_side()] ==
"null"; ++i) {
+ for (int i = 0; i < nsides_ && nsides_ <= gamemap::MAX_PLAYERS &&
side_controllers_[current_side()] == "null"; ++i) {
++end_turn_;
if (current_side() == 0) {
turn_ended = true;
Modified: branches/1.4/src/server/server.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/src/server/server.cpp?rev=26161&r1=26160&r2=26161&view=diff
==============================================================================
--- branches/1.4/src/server/server.cpp (original)
+++ branches/1.4/src/server/server.cpp Sun Apr 27 08:14:45 2008
@@ -20,6 +20,7 @@
#include "../config.hpp"
#include "../game_config.hpp"
#include "../log.hpp"
+#include "../map.hpp" // gamemap::MAX_PLAYERS
#include "../network.hpp"
#include "../filesystem.hpp"
#include "../serialization/parser.hpp"
@@ -1210,15 +1211,26 @@
if (!g->is_owner(sock)) {
return;
}
-
- const bool is_init = g->level_init();
+ size_t nsides = 0;
+ const simple_wml::node::child_list& sides =
data.root().children("side");
+ for (simple_wml::node::child_list::const_iterator s =
sides.begin(); s != sides.end(); ++s) {
+ ++nsides;
+ }
+ if (nsides > gamemap::MAX_PLAYERS) {
+ delete_game(itor);
+ std::stringstream msg;
+ msg << "This server does not support games with more
than "
+ << gamemap::MAX_PLAYERS << " sides.";
+ lobby_.send_server_message(msg.str().c_str(), sock);
+ return;
+ }
// If this game is having its level data initialized
// for the first time, and is ready for players to join.
// We should currently have a summary of the game in g->level().
// We want to move this summary to the games_and_users_list_,
and
// place a pointer to that summary in the game's description.
// g->level() should then receive the full data for the game.
- if (!is_init) {
+ if (!g->level_init()) {
LOG_SERVER << network::ip_address(sock) << "\t" <<
pl->second.name()
<< "\tcreated game:\t\"" << g->name() << "\" ("
<< g->id() << ").\n";
@@ -1306,6 +1318,19 @@
<< pl->second.name() << "\tsent
[store_next_scenario] in game:\t\""
<< g->name() << "\" (" << g->id()
<< ") while the scenario is not yet
initialized.";
+ return;
+ }
+ size_t nsides = 0;
+ const simple_wml::node::child_list& sides =
data.root().children("side");
+ for (simple_wml::node::child_list::const_iterator s =
sides.begin(); s != sides.end(); ++s) {
+ ++nsides;
+ }
+ if (nsides > gamemap::MAX_PLAYERS) {
+ delete_game(itor);
+ std::stringstream msg;
+ msg << "This server does not support games with more
than "
+ << gamemap::MAX_PLAYERS << " sides.";
+ lobby_.send_server_message(msg.str().c_str(), sock);
return;
}
const simple_wml::node& s = *data.child("store_next_scenario");
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits