[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth data/multiplayer.cfg src/game.cpp src/g...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth data/multiplayer.cfg src/game.cpp src/g... |
Date: |
Tue, 21 Sep 2004 16:42:06 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 04/09/21 20:35:48
Modified files:
data : multiplayer.cfg
src : game.cpp gamestatus.cpp multiplayer_client.cpp
multiplayer_connect.cpp
Log message:
Adding the ability to choose a random leader in a faction.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/multiplayer.cfg.diff?tr1=1.78&tr2=1.79&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.137&tr2=1.138&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/gamestatus.cpp.diff?tr1=1.43&tr2=1.44&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_client.cpp.diff?tr1=1.66&tr2=1.67&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.cpp.diff?tr1=1.70&tr2=1.71&r1=text&r2=text
Patches:
Index: wesnoth/data/multiplayer.cfg
diff -u wesnoth/data/multiplayer.cfg:1.78 wesnoth/data/multiplayer.cfg:1.79
--- wesnoth/data/multiplayer.cfg:1.78 Tue Sep 21 05:50:31 2004
+++ wesnoth/data/multiplayer.cfg Tue Sep 21 20:35:48 2004
@@ -21,7 +21,7 @@
[multiplayer_side]
name= _ "&random-enemy.png,Random"
- type=random
+ random_faction=yes
[/multiplayer_side]
[multiplayer_side]
@@ -102,7 +102,7 @@
[multiplayer_side]
name= _ "&random-enemy.png,Random"
- type=random
+ random_faction=yes
[/multiplayer_side]
[multiplayer_side]
@@ -183,7 +183,7 @@
[multiplayer_side]
name= _ "&random-enemy.png,Random"
- type=random
+ random_faction=yes
[/multiplayer_side]
[multiplayer_side]
@@ -265,7 +265,7 @@
[multiplayer_side]
name= _ "&random-enemy.png,Random"
- type=random
+ random_faction=yes
[/multiplayer_side]
[multiplayer_side]
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.137 wesnoth/src/game.cpp:1.138
--- wesnoth/src/game.cpp:1.137 Sun Sep 19 16:12:08 2004
+++ wesnoth/src/game.cpp Tue Sep 21 20:35:48 2004
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.137 2004/09/19 16:12:08 ydirson Exp $ */
+/* $Id: game.cpp,v 1.138 2004/09/21 20:35:48 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -184,7 +184,7 @@
if(state.scenario == current_scenario)
state.scenario = (*scenario)["next_scenario"];
- scenario = game_config.find_child(type,"id",state.scenario);
+ scenario = game_config.find_child(type,"id",state.scenario);
//if this isn't the last scenario, then save the game
if(scenario != NULL && save_game_after_scenario) {
@@ -707,13 +707,15 @@
const config* side = type == side_types.end() ?
era_cfg->child("multiplayer_side") :
era_cfg->find_child("multiplayer_side","type",type->second);
+#if 0
size_t tries = 0;
while(side != NULL && (*side)["type"] == "random" && ++tries <
100) {
const config::child_list& v =
era_cfg->get_children("multiplayer_side");
side = v[rand()%v.size()];
}
+#endif
- if(side == NULL || (*side)["type"] == "random") {
+ 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;
Index: wesnoth/src/gamestatus.cpp
diff -u wesnoth/src/gamestatus.cpp:1.43 wesnoth/src/gamestatus.cpp:1.44
--- wesnoth/src/gamestatus.cpp:1.43 Sun Sep 19 02:27:23 2004
+++ wesnoth/src/gamestatus.cpp Tue Sep 21 20:35:48 2004
@@ -1,4 +1,4 @@
-/* $Id: gamestatus.cpp,v 1.43 2004/09/19 02:27:23 Sirp Exp $ */
+/* $Id: gamestatus.cpp,v 1.44 2004/09/21 20:35:48 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -194,24 +194,24 @@
player_info read_player(const game_data& data, const config* cfg)
{
- player_info res;
+ player_info res;
- res.gold = atoi((*cfg)["gold"].c_str());
+ res.gold = atoi((*cfg)["gold"].c_str());
- const config::child_list& units = cfg->get_children("unit");
- for(config::child_list::const_iterator i = units.begin(); i != units.end();
++i) {
- res.available_units.push_back(unit(data,**i));
- }
+ const config::child_list& units = cfg->get_children("unit");
+ for(config::child_list::const_iterator i = units.begin(); i !=
units.end(); ++i) {
+ res.available_units.push_back(unit(data,**i));
+ }
- res.can_recruit.clear();
+ res.can_recruit.clear();
- const std::string& can_recruit_str = (*cfg)["can_recruit"];
- if(can_recruit_str != "") {
- const std::vector<std::string> can_recruit =
config::split(can_recruit_str);
-
std::copy(can_recruit.begin(),can_recruit.end(),std::inserter(res.can_recruit,res.can_recruit.end()));
- }
+ const std::string& can_recruit_str = (*cfg)["can_recruit"];
+ if(can_recruit_str != "") {
+ const std::vector<std::string> can_recruit =
config::split(can_recruit_str);
+
std::copy(can_recruit.begin(),can_recruit.end(),std::inserter(res.can_recruit,res.can_recruit.end()));
+ }
- return res;
+ return res;
}
game_state read_game(const game_data& data, const config* cfg)
Index: wesnoth/src/multiplayer_client.cpp
diff -u wesnoth/src/multiplayer_client.cpp:1.66
wesnoth/src/multiplayer_client.cpp:1.67
--- wesnoth/src/multiplayer_client.cpp:1.66 Sun Sep 19 07:24:59 2004
+++ wesnoth/src/multiplayer_client.cpp Tue Sep 21 20:35:48 2004
@@ -605,7 +605,7 @@
leaders_.clear();
- if(side["type"] == "random") {
+ if(side["random_faction"] == "yes") {
if(combo_ != NULL) {
std::vector<std::string> dummy;
dummy.push_back("-");
@@ -638,7 +638,7 @@
if (default_index == leaders_.size()) {
leaders_.push_back(default_leader);
}
-
+
std::vector<std::string> leader_strings;
for(itor = leaders_.begin(); itor != leaders_.end(); ++itor) {
@@ -656,6 +656,10 @@
}
}
+ leaders_.push_back("random");
+ // FIXME: Maybe this should not code into the code.
+ leader_strings.push_back(_("&random-enemy.png,Random"));
+
if(combo_ != NULL) {
combo_->set_items(leader_strings);
combo_->set_selected(default_index);
Index: wesnoth/src/multiplayer_connect.cpp
diff -u wesnoth/src/multiplayer_connect.cpp:1.70
wesnoth/src/multiplayer_connect.cpp:1.71
--- wesnoth/src/multiplayer_connect.cpp:1.70 Sun Sep 19 19:10:27 2004
+++ wesnoth/src/multiplayer_connect.cpp Tue Sep 21 20:35:48 2004
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.cpp,v 1.70 2004/09/19 19:10:27 gruikya Exp $ */
+/* $Id: multiplayer_connect.cpp,v 1.71 2004/09/21 20:35:48 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -726,20 +726,12 @@
for(config::child_iterator side = sides.first; side !=
sides.second; ++side) {
int ntry = 0;
- while((**side)["type"] == "random" && ntry < 1000) {
+ while((**side)["random_faction"] == "yes" && ntry <
1000) {
const int choice = rand()%real_sides.size();
(**side)["name"] =
(*real_sides[choice])["name"];
- // Choose a random leader type.
- std::vector<std::string> types =
-
config::split((*real_sides[choice])["leader"]);
- if (!types.empty()) {
- const int lchoice = rand() %
types.size();
- (**side)["type"] = types[lchoice];
- } else {
- (**side)["type"] =
(*real_sides[choice])["type"];
- }
+ (**side)["type"] = "random";
(**side)["recruit"] =
(*real_sides[choice])["recruit"];
(**side)["music"] =
(*real_sides[choice])["music"];
@@ -750,6 +742,18 @@
++ntry;
}
+
+ if ((**side)["type"] == "random" ||
(**side)["type"].empty()) {
+ // Choose a random leader type.
+ std::vector<std::string> types =
+ config::split((**side)["leader"]);
+ if (!types.empty()) {
+ const int lchoice = rand() %
types.size();
+ (**side)["type"] = types[lchoice];
+ } else {
+
+ }
+ }
}
start_game = true;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth data/multiplayer.cfg src/game.cpp src/g...,
Philippe Plantier <=