[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src playlevel.cpp
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src playlevel.cpp |
Date: |
Thu, 03 Feb 2005 15:54:55 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/02/03 20:54:55
Modified files:
src : playlevel.cpp
Log message:
A bit of cleanup. Don't display victory or defeat dialogs for
observers; use another one instead, handcrafted with existing strings for the
moment. Display reports for all persistent players, not only human players.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playlevel.cpp.diff?tr1=1.174&tr2=1.175&r1=text&r2=text
Patches:
Index: wesnoth/src/playlevel.cpp
diff -u wesnoth/src/playlevel.cpp:1.174 wesnoth/src/playlevel.cpp:1.175
--- wesnoth/src/playlevel.cpp:1.174 Thu Feb 3 19:03:51 2005
+++ wesnoth/src/playlevel.cpp Thu Feb 3 20:54:55 2005
@@ -1,4 +1,4 @@
-/* $Id: playlevel.cpp,v 1.174 2005/02/03 19:03:51 silene Exp $ */
+/* $Id: playlevel.cpp,v 1.175 2005/02/03 20:54:55 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -710,15 +710,20 @@
} //end for loop
} catch(end_level_exception& end_level) {
-
- //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
+ bool obs = is_observer(teams);
if (end_level.result == DEFEAT || end_level.result == VICTORY) {
- config cfg;
- config& info = cfg.add_child("info");
- info["type"] = "termination";
- info["condition"] = "game over";
- network::send_data(cfg);
+ // 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 (!obs) {
+ config cfg;
+ config& info = cfg.add_child("info");
+ info["type"] = "termination";
+ info["condition"] = "game over";
+ network::send_data(cfg);
+ } else
+ gui::show_dialog(gui, NULL, "",
+ _("Victory") + std::string(" /
") + _("Defeat"),
+ gui::OK_ONLY);
}
if(end_level.result == QUIT) {
@@ -729,12 +734,14 @@
} catch(end_level_exception&) {
}
- gui::show_dialog(gui,NULL,
- _("Defeat"),
- _("You have been defeated!"),
- gui::OK_ONLY);
+ if (!obs)
+ gui::show_dialog(gui, NULL,
+ _("Defeat"),
+ _("You have been defeated!"),
+ gui::OK_ONLY);
return DEFEAT;
- } else if(end_level.result == VICTORY || end_level.result ==
LEVEL_CONTINUE || end_level.result == LEVEL_CONTINUE_NO_SAVE) {
+ } else if (end_level.result == VICTORY || end_level.result ==
LEVEL_CONTINUE ||
+ end_level.result == LEVEL_CONTINUE_NO_SAVE) {
try {
game_events::fire("victory");
} catch(end_level_exception&) {
@@ -744,7 +751,8 @@
state_of_game.scenario =
(*level)["next_scenario"];
}
- const bool has_next_scenario = state_of_game.scenario
!= "null" && state_of_game.scenario != "";
+ const bool has_next_scenario =
!state_of_game.scenario.empty() &&
+ state_of_game.scenario
!= "null";
//add all the units that survived the scenario
for(std::map<gamemap::location,unit>::iterator un =
units.begin(); un != units.end(); ++un) {
@@ -774,20 +782,21 @@
std::stringstream report;
for(std::vector<team>::iterator i=teams.begin();
i!=teams.end(); ++i) {
- if(i->is_human() == false) {
+ if (!i->is_persistent())
continue;
- }
player_info
*player=state_of_game.get_player(i->save_id());
const int remaining_gold = i->gold();
- const int finishing_bonus_per_turn =
map.villages().size()*game_config::village_income + game_config::base_income;
+ const int finishing_bonus_per_turn =
+ map.villages().size() *
game_config::village_income +
+ game_config::base_income;
const int turns_left =
maximum<int>(0,status.number_of_turns() - status.turn());
const int finishing_bonus =
end_level.gold_bonus ?
(finishing_bonus_per_turn *
turns_left) : 0;
if(player) {
- player->gold =
((remaining_gold+finishing_bonus)*80)/100;
+ player->gold = ((remaining_gold +
finishing_bonus) * 80) / 100;
if(state_of_game.players.size()>1) {
if(i!=teams.begin()) {
@@ -812,16 +821,18 @@
}
// xgettext:no-c-format
- report << "\n" << _("80% of gold is
retained for the next scenario") << "\n" << _("Retained Gold") << ": " <<
player->gold;
+ report << "\n" << _("80% of gold is
retained for the next scenario") << "\n"
+ << _("Retained Gold") << ": " <<
player->gold;
}
}
- gui::show_dialog(gui,NULL,_("Victory"),
- _("You have emerged
victorious!"),gui::OK_ONLY);
+ if (!obs)
+ gui::show_dialog(gui, NULL, _("Victory"),
+ _("You have emerged
victorious!"), gui::OK_ONLY);
+
+ if (state_of_game.players.size() > 0 &&
has_next_scenario)
+ gui::show_dialog(gui, NULL, _("Scenario
Report"), report.str(), gui::OK_ONLY);
- if(state_of_game.players.size()>0 && has_next_scenario)
{
- gui::show_dialog(gui,NULL,_("Scenario
Report"),report.str(),gui::OK_ONLY);
- }
return VICTORY;
}
} //end catch