Author: ilor
Date: Tue Oct 14 22:37:25 2008
New Revision: 30169

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30169&view=rev
Log:
add border overlaying to [terrain_mask]. Active only if the mask is in fact a 
map (has border_size=1) and border=yes is supplied in the [terrain_mask] tag 
(to avoid changing the behaviour of existing WML).

Modified:
    trunk/src/editor2/action.cpp
    trunk/src/game_events.cpp
    trunk/src/map.cpp
    trunk/src/map.hpp

Modified: trunk/src/editor2/action.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.cpp?rev=30169&r1=30168&r2=30169&view=diff
==============================================================================
--- trunk/src/editor2/action.cpp (original)
+++ trunk/src/editor2/action.cpp Tue Oct 14 22:37:25 2008
@@ -338,7 +338,7 @@
 
 void editor_action_apply_mask::perform_without_undo(map_context& mc) const
 {
-       mc.get_map().overlay(mask_, config(), 0, 0);
+       mc.get_map().overlay(mask_, config(), 0, 0, true);
        mc.set_needs_terrain_rebuild();
 }
 

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=30169&r1=30168&r2=30169&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Tue Oct 14 22:37:25 2008
@@ -1734,8 +1734,8 @@
                        e.show(*screen);
                        return;
                }
-
-               game_map->overlay(mask, cfg.get_parsed_config(), loc.x, loc.y);
+               bool border = utils::string_bool(cfg["border"]);
+               game_map->overlay(mask, cfg.get_parsed_config(), loc.x, loc.y, 
border);
                handler.rebuild_screen() = true;
        }
 

Modified: trunk/src/map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/map.cpp?rev=30169&r1=30168&r2=30169&view=diff
==============================================================================
--- trunk/src/map.cpp (original)
+++ trunk/src/map.cpp Tue Oct 14 22:37:25 2008
@@ -487,22 +487,21 @@
        return header + "\n\n" + data;
 }
 
-void gamemap::overlay(const gamemap& m, const config& rules_cfg, const int 
xpos, const int ypos)
+void gamemap::overlay(const gamemap& m, const config& rules_cfg, int xpos, int 
ypos, bool border)
 {
        const config::child_list& rules = rules_cfg.get_children("rule");
-
-       const int xstart = std::max<int>(0, -xpos);
-       const int ystart = std::max<int>(0, -ypos-((xpos & 1) ? 1 : 0));
-       const int xend = std::min<int>(m.w(),w()-xpos);
-       const int yend = std::min<int>(m.h(),h()-ypos);
+       int actual_border = (m.border_size() == border_size()) && border ? 
border_size() : 0;
+
+       const int xstart = std::max<int>(-actual_border, -xpos - actual_border);
+       const int ystart = std::max<int>(-actual_border, -ypos - actual_border 
- ((xpos & 1) ? 1 : 0));
+       const int xend = std::min<int>(m.w() + actual_border, w() + 
actual_border - xpos);
+       const int yend = std::min<int>(m.h() + actual_border, h() + 
actual_border - ypos);
        for(int x1 = xstart; x1 < xend; ++x1) {
                for(int y1 = ystart; y1 < yend; ++y1) {
                        const int x2 = x1 + xpos;
                        const int y2 = y1 + ypos +
                                ((xpos & 1) && (x1 & 1) ? 1 : 0);
-                       if (y2 < 0 || y2 >= h()) {
-                               continue;
-                       }
+
                        const t_translation::t_terrain t = m[x1][y1 + 
m.border_size_];
                        const t_translation::t_terrain current = (*this)[x2][y2 
+ border_size_];
 

Modified: trunk/src/map.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/map.hpp?rev=30169&r1=30168&r2=30169&view=diff
==============================================================================
--- trunk/src/map.hpp (original)
+++ trunk/src/map.hpp Tue Oct 14 22:37:25 2008
@@ -101,7 +101,7 @@
                bool operator!=(const location& a) const { return 
!operator==(a); }
 
                // Adds an absolute location to a "delta" location
-               // This is not the mathematically correct bahviur, it is neither
+               // This is not the mathematically correct behviour, it is 
neither
                // commutative nor associative. Negative coordinates may give 
strange
                // results. It is retained because terain builder code relies 
in this
                // broken behaviour. Best avoid.
@@ -203,7 +203,7 @@
        std::string write() const;
 
        /** Overlays another map onto this one at the given position. */
-       void overlay(const gamemap& m, const config& rules, const int x=0, 
const int y=0);
+       void overlay(const gamemap& m, const config& rules, int x=0, int y=0, 
bool border=false);
 
        /** Effective map width. */
        int w() const { return w_; }
@@ -317,11 +317,11 @@
 
        /**
         * Tries to merge old and new terrain using the merge_settings config
-     * Relevant parameters are "layer" and "replace_conflicting"
-     * "layer" specifies the layer that should be replaced (base or overlay, 
default is both). 
-     * If "replace_conflicting" is true the new terrain will replace the old 
one if merging failed
-     * (using the default base if new terrain is an overlay terrain)
-     * Will return the resulting terrain or NONE_TERRAIN if merging failed
+        * Relevant parameters are "layer" and "replace_conflicting"
+        * "layer" specifies the layer that should be replaced (base or 
overlay, default is both). 
+        * If "replace_conflicting" is true the new terrain will replace the 
old one if merging failed
+        * (using the default base if new terrain is an overlay terrain)
+        * Will return the resulting terrain or NONE_TERRAIN if merging failed
         */
     t_translation::t_terrain merge_terrains(const t_translation::t_terrain 
old_t, const t_translation::t_terrain new_t, const tmerge_mode mode, bool 
replace_if_failed = false);
        


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to