[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src game.cpp
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src game.cpp |
Date: |
Sat, 29 Jan 2005 05:05:07 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/01/29 10:05:07
Modified files:
src : game.cpp
Log message:
Fixed a crash with unknown side type. And switch to an imo better
scheme: use side id instead of side type, and fallback on random side when not
provided. So it means that the switch to get the rebels is no more
'--side1=Elvish Captain' but simply '--side1=Rebels'.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.184&tr2=1.185&r1=text&r2=text
Patches:
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.184 wesnoth/src/game.cpp:1.185
--- wesnoth/src/game.cpp:1.184 Thu Jan 27 22:19:24 2005
+++ wesnoth/src/game.cpp Sat Jan 29 10:05:07 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.184 2005/01/27 22:19:24 ydirson Exp $ */
+/* $Id: game.cpp,v 1.185 2005/01/29 10:05:07 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -729,20 +729,24 @@
controller =
side_controllers.find(side_num),
algorithm =
side_algorithms.find(side_num);
- const config* side = type == side_types.end() ?
era_cfg->child("multiplayer_side") :
-
era_cfg->find_child("multiplayer_side","type",type->second);
-
- if((*side)["random_faction"] == "yes") {
+ const config* side = type == side_types.end() ?
+ era_cfg->find_child("multiplayer_side",
"random_faction", "yes") :
+ era_cfg->find_child("multiplayer_side", "id",
type->second);
+
+ if (side == NULL) {
+ unknown_side_id:
+ std::string side_name = (type == side_types.end() ?
"default" : type->second);
+ std::cerr << "Could not find side '" << side_name << "'
for side " << side_num << "\n";
+ return false;
+ }
+
+ if ((*side)["random_faction"] == "yes") {
const config::child_list& eras =
era_cfg->get_children("multiplayer_side");
for(int i = 0; i != 100 && (*side)["random_faction"] ==
"yes"; ++i) {
side = eras[rand()%eras.size()];
}
- }
-
- if(side == NULL || (*side)["random_faction"] == "yes" ||
(*side)["type"] == "random") {
- std::string side_name = (type == side_types.end() ?
"default" : type->second);
- std::cerr << "Could not find side '" << side_name << "'
for side " << side_num << "\n";
- return false;
+ if ((*side)["random_faction"] == "yes")
+ goto unknown_side_id;
}
char buf[20];