[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth ./changelog src/actions.cpp src/playlev...
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth ./changelog src/actions.cpp src/playlev... |
Date: |
Sat, 22 Jan 2005 05:47:17 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/01/22 10:47:17
Modified files:
. : changelog
src : actions.cpp playlevel.cpp playlevel.hpp
playturn.cpp team.cpp team.hpp
Log message:
Added droid patch (#3651) from Darthfool.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/changelog.diff?tr1=1.450&tr2=1.451&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/actions.cpp.diff?tr1=1.184&tr2=1.185&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.cpp.diff?tr1=1.168&tr2=1.169&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.hpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.320&tr2=1.321&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/team.cpp.diff?tr1=1.76&tr2=1.77&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/team.hpp.diff?tr1=1.51&tr2=1.52&r1=text&r2=text
Patches:
Index: wesnoth/changelog
diff -u wesnoth/changelog:1.450 wesnoth/changelog:1.451
--- wesnoth/changelog:1.450 Sat Jan 22 04:32:29 2005
+++ wesnoth/changelog Sat Jan 22 10:47:16 2005
@@ -87,6 +87,7 @@
relative-positioning syntax
* added support for theme inheritance, to avoid duplicating mostly-unchanged
code
+ * added a "droid" game command, and allow for computer player to do a campaign
* updated unix manpages
* "," is no longer the column separator, it does not have to be escaped
anymore in some translations, "=" is the new separator (#10368)
Index: wesnoth/src/actions.cpp
diff -u wesnoth/src/actions.cpp:1.184 wesnoth/src/actions.cpp:1.185
--- wesnoth/src/actions.cpp:1.184 Fri Jan 21 23:17:15 2005
+++ wesnoth/src/actions.cpp Sat Jan 22 10:47:16 2005
@@ -1,4 +1,4 @@
-/* $Id: actions.cpp,v 1.184 2005/01/21 23:17:15 Sirp Exp $ */
+/* $Id: actions.cpp,v 1.185 2005/01/22 10:47:16 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1322,7 +1322,7 @@
}
bool found_enemies = false;
- bool found_human = false;
+ bool found_player = false;
for(size_t n = 0; n != seen_leaders.size(); ++n) {
const size_t side = seen_leaders[n]-1;
@@ -1335,13 +1335,13 @@
}
}
- if(side < teams.size() && teams[side].is_human()) {
- found_human = true;
+ if (side < teams.size() && (teams[side].is_human() ||
teams[side].is_persistent())) {
+ found_player = true;
}
}
if(found_enemies == false) {
- if(found_human) {
+ if (found_player) {
game_events::fire("enemies defeated");
if (victory_conditions::victory_when_enemies_defeated()
== false) {
// this level has asked not to be ended by this
condition
@@ -1360,7 +1360,7 @@
}
LOG_NG << "throwing end level exception...\n";
- throw end_level_exception(found_human ? VICTORY : DEFEAT);
+ throw end_level_exception(found_player ? VICTORY : DEFEAT);
}
//remove any units which are leaderless
Index: wesnoth/src/playlevel.cpp
diff -u wesnoth/src/playlevel.cpp:1.168 wesnoth/src/playlevel.cpp:1.169
--- wesnoth/src/playlevel.cpp:1.168 Fri Jan 21 07:03:01 2005
+++ wesnoth/src/playlevel.cpp Sat Jan 22 10:47:16 2005
@@ -1,4 +1,4 @@
-/* $Id: playlevel.cpp,v 1.168 2005/01/21 07:03:01 j_daniel Exp $ */
+/* $Id: playlevel.cpp,v 1.169 2005/01/22 10:47:16 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -221,7 +221,7 @@
LOG_NG << "initializing team...\n";
- if(first_human_team == -1 && (**ui)["controller"] == "human") {
+ if (first_human_team == -1 && ((**ui)["controller"] == "human"
|| (**ui)["persistent"] == "1")) {
first_human_team = ui - unit_cfg.begin();
}
@@ -585,9 +585,14 @@
}
}
-
play_turn(gameinfo,state_of_game,status,game_config,
- level, key, gui, map, teams,
player_number,
- units, textbox_info,
replay_sender);
+ try {
+
play_turn(gameinfo,state_of_game,status,game_config,
+ level, key, gui, map,
teams, player_number,
+ units, textbox_info,
replay_sender);
+ } catch(end_turn_exception& end_turn) {
+ if (end_turn.redo ==
player_number)
+ goto redo_turn;
+ }
if(game_config::debug)
display::clear_debug_highlights();
@@ -701,12 +706,6 @@
} catch(end_level_exception& end_level) {
- if((end_level.result == DEFEAT || end_level.result == VICTORY)
&& is_observer(teams)) {
- gui::show_dialog(gui,NULL,_("Game Over"),
- _("The game is over."),
gui::OK_ONLY);
- return end_level.result;
- }
-
//if we're a player, and the result is victory/defeat, then
send a message to notify
//the server of the reason for the game ending
if(end_level.result == DEFEAT || end_level.result == VICTORY &&
network::nconnections() > 0) {
Index: wesnoth/src/playlevel.hpp
diff -u wesnoth/src/playlevel.hpp:1.18 wesnoth/src/playlevel.hpp:1.19
--- wesnoth/src/playlevel.hpp:1.18 Sat Sep 11 21:22:57 2004
+++ wesnoth/src/playlevel.hpp Sat Jan 22 10:47:16 2005
@@ -1,4 +1,4 @@
-/* $Id: playlevel.hpp,v 1.18 2004/09/11 21:22:57 gruikya Exp $ */
+/* $Id: playlevel.hpp,v 1.19 2005/01/22 10:47:16 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -44,6 +44,11 @@
bool gold_bonus;
};
+struct end_turn_exception {
+ end_turn_exception(int r = 0): redo(r) {}
+ int redo;
+};
+
LEVEL_RESULT play_level(game_data& gameinfo, const config& terrain_config,
config* level, CVideo& video,
game_state& state_of_game,
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.320 wesnoth/src/playturn.cpp:1.321
--- wesnoth/src/playturn.cpp:1.320 Sat Jan 22 09:05:30 2005
+++ wesnoth/src/playturn.cpp Sat Jan 22 10:47:16 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.320 2005/01/22 09:05:30 silene Exp $ */
+/* $Id: playturn.cpp,v 1.321 2005/01/22 10:47:16 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -2373,6 +2373,18 @@
if(cmd == "refresh") {
image::flush_cache();
gui_.redraw_everything();
+ } else if (cmd == "droid") {
+ const int side = lexical_cast_default<int>(data, 1);
+ const size_t index = static_cast<size_t>(side - 1);
+ if (index >= teams_.size() || teams_[index].is_network()) {
+ //do nothing
+ } else if (teams_[index].is_human()) {
+ teams_[index].make_ai();
+ close_textbox();
+ throw end_turn_exception(side);
+ } else if (teams_[index].is_ai()) {
+ teams_[index].make_human();
+ }
} else if(cmd == "ban") {
config cfg;
config& ban = cfg.add_child("ban");
Index: wesnoth/src/team.cpp
diff -u wesnoth/src/team.cpp:1.76 wesnoth/src/team.cpp:1.77
--- wesnoth/src/team.cpp:1.76 Fri Dec 31 21:01:37 2004
+++ wesnoth/src/team.cpp Sat Jan 22 10:47:17 2005
@@ -1,4 +1,4 @@
-/* $Id: team.cpp,v 1.76 2004/12/31 21:01:37 isaaccp Exp $ */
+/* $Id: team.cpp,v 1.77 2005/01/22 10:47:17 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -100,15 +100,21 @@
}
}
- if(cfg["controller"] == "human")
+ std::string control = cfg["controller"];
+ if (control == "human")
controller = HUMAN;
- else if(cfg["controller"] == "network")
+ else if (control == "network")
controller = NETWORK;
- else if(cfg["controller"] == "null")
+ else if (control == "null")
controller = EMPTY;
else
controller = AI;
+ bool persistent;
+ std::string persist = cfg["persistent"];
+ if (persist.empty()) persistent = controller == HUMAN;
+ else persistent = persist == "1";
+
ai_algorithm = cfg["ai_algorithm"];
if(ai_algorithm.empty()) {
@@ -225,6 +231,8 @@
default: wassert(false);
}
+ cfg["persistent"] = persistent ? "1" : "0";
+
sprintf(buf,"%d",villages_per_scout);
cfg["villages_per_scout"] = buf;
@@ -480,6 +488,11 @@
return info_.controller == team_info::EMPTY;
}
+bool team::is_persistent() const
+{
+ return info_.persistent;
+}
+
void team::make_human()
{
info_.controller = team_info::HUMAN;
Index: wesnoth/src/team.hpp
diff -u wesnoth/src/team.hpp:1.51 wesnoth/src/team.hpp:1.52
--- wesnoth/src/team.hpp:1.51 Fri Dec 31 21:01:37 2004
+++ wesnoth/src/team.hpp Sat Jan 22 10:47:17 2005
@@ -1,4 +1,4 @@
-/* $Id: team.hpp,v 1.51 2004/12/31 21:01:37 isaaccp Exp $ */
+/* $Id: team.hpp,v 1.52 2005/01/22 10:47:17 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -75,6 +75,7 @@
enum CONTROLLER { HUMAN, AI, NETWORK, EMPTY };
CONTROLLER controller;
+ bool persistent;
std::string ai_algorithm;
std::vector<config> ai_params;
@@ -132,6 +133,8 @@
bool is_ai() const;
bool is_empty() const;
+ bool is_persistent() const;
+
void make_human();
void make_network();
void make_ai();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth ./changelog src/actions.cpp src/playlev...,
Guillaume Melquiond <=