Author: boucman
Date: Sat Mar 31 18:33:14 2012
New Revision: 53725
URL: http://svn.gna.org/viewcvs/wesnoth?rev=53725&view=rev
Log:
apply patch 3197 by jamit, add flags to handle refogging properly
Modified:
trunk/changelog
trunk/src/game_events.cpp
trunk/src/team.cpp
trunk/src/team.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=53725&r1=53724&r2=53725&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sat Mar 31 18:33:14 2012
@@ -166,6 +166,7 @@
* Negative drain amounts will not take a unit below 1 health
* Added [show_if] support to [objectives] [note]
* New tags: [lift_fog] and [reset_fog]
+ * New keys: reset_maps= and reset_view= added to [modify_side].
* Using more than 4 multiply effects no longer wraps to negative integers
* Added: support for ranges of sides in SSF
* The [filter_vision] tag of the SUF now uses a SSF
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=53725&r1=53724&r2=53725&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Mar 31 18:33:14 2012
@@ -756,8 +756,11 @@
}
/* Implements the lifting and resetting of fog via WML.
+ * Setting reset to true causes the current fog to be discarded, which causes
+ * all tiles to be fogged for the specified teams (normally only used when
+ * clear is false).
*/
-static void toggle_fog(const bool clear, const vconfig& cfg)
+static void toggle_fog(const bool clear, const vconfig& cfg, const bool
reset=false)
{
// Filter the sides.
const vconfig &ssf = cfg.child("filter_side");
@@ -777,6 +780,9 @@
t.add_fog_override(locs);
else
t.remove_fog_override(locs);
+ // Should this side reset fog?
+ if ( reset )
+ t.refog();
}
// Flag a screen update.
@@ -792,6 +798,7 @@
WML_HANDLER_FUNCTION(reset_fog, /*event_info*/,cfg)
{
toggle_fog(false, cfg);
+ toggle_fog(false, cfg, cfg["reset_view"].to_bool(false));
}
WML_HANDLER_FUNCTION(tunnel, /*event_info*/, cfg)
@@ -979,6 +986,8 @@
WML_HANDLER_FUNCTION(modify_side, /*event_info*/, cfg)
{
std::vector<team> &teams = *resources::teams;
+
+ bool invalidate_screen = false;
std::string team_name = cfg["team_name"];
std::string user_team_name = cfg["user_team_name"];
@@ -1031,10 +1040,17 @@
config::attribute_value shroud = cfg["shroud"];
if (!shroud.empty()) {
teams[team_index].set_shroud(shroud.to_bool(true));
+ invalidate_screen = true;
+ }
+ // Reset shroud
+ if ( cfg["reset_maps"].to_bool(false) ) {
+ teams[team_index].reshroud();
+ invalidate_screen = true;
}
// Merge shroud data
if (!shroud_data.empty()) {
teams[team_index].merge_shroud_map_data(shroud_data);
+ invalidate_screen = true;
}
// Set whether team is hidden in status table
config::attribute_value hidden = cfg["hidden"];
@@ -1045,6 +1061,12 @@
config::attribute_value fog = cfg["fog"];
if (!fog.empty()) {
teams[team_index].set_fog(fog.to_bool(true));
+ invalidate_screen = true;
+ }
+ // Reset fog
+ if ( cfg["reset_view"].to_bool(false) ) {
+ teams[team_index].refog();
+ invalidate_screen = true;
}
// Set income per village
config::attribute_value village_gold = cfg["village_gold"];
@@ -1063,16 +1085,14 @@
config::attribute_value color = cfg["color"];
if(!color.empty()) {
teams[team_index].set_color(color);
- resources::screen->recalculate_minimap();
- resources::screen->invalidate_all();
+ invalidate_screen = true;
}
// Add shared view to current team
config::attribute_value share_view = cfg["share_view"];
if (!share_view.empty()){
teams[team_index].set_share_view(share_view.to_bool(true));
team::clear_caches();
- resources::screen->recalculate_minimap();
- resources::screen->invalidate_all();
+ invalidate_screen = true;
}
// Add shared maps to current team
// IMPORTANT: this MUST happen *after* share_view is changed
@@ -1080,10 +1100,15 @@
if (!share_maps.empty()){
teams[team_index].set_share_maps(share_maps.to_bool(true));
team::clear_caches();
- resources::screen->recalculate_minimap();
- resources::screen->invalidate_all();
- }
-
+ invalidate_screen = true;
+ }
+
+ }
+
+ // Flag an update of the screen, if needed.
+ if ( invalidate_screen ) {
+ resources::screen->recalculate_minimap();
+ resources::screen->invalidate_all();
}
}
Modified: trunk/src/team.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.cpp?rev=53725&r1=53724&r2=53725&view=diff
==============================================================================
--- trunk/src/team.cpp (original)
+++ trunk/src/team.cpp Sat Mar 31 18:33:14 2012
@@ -268,11 +268,6 @@
cfg.add_child("ai",ai::manager::to_config(side));
}
-void team::merge_shroud_map_data(const std::string& shroud_data)
-{
- shroud_.merge(shroud_data);
-}
-
team::team() :
savegame_config(),
gold_(0),
Modified: trunk/src/team.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.hpp?rev=53725&r1=53724&r2=53725&view=diff
==============================================================================
--- trunk/src/team.hpp (original)
+++ trunk/src/team.hpp Sat Mar 31 18:33:14 2012
@@ -224,12 +224,13 @@
bool clear_shroud(const map_location& loc) { return
shroud_.clear(loc.x+1,loc.y+1); }
void place_shroud(const map_location& loc) {
shroud_.place(loc.x+1,loc.y+1); }
bool clear_fog(const map_location& loc) { return
fog_.clear(loc.x+1,loc.y+1); }
+ void reshroud() { shroud_.reset(); }
void refog() { fog_.reset(); }
void set_shroud(bool shroud) { shroud_.set_enabled(shroud); }
void set_fog(bool fog) { fog_.set_enabled(fog); }
/** Merge a WML shroud map with the shroud data of this player. */
- void merge_shroud_map_data(const std::string& shroud_data);
+ void merge_shroud_map_data(const std::string& shroud_data) {
shroud_.merge(shroud_data); }
bool knows_about_team(size_t index, bool is_multiplayer) const;
bool copy_ally_shroud();
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits