Author: mordante
Date: Sun May 27 13:17:21 2007
New Revision: 17902
URL: http://svn.gna.org/viewcvs/wesnoth?rev=17902&view=rev
Log:
convert the border tiles to the new off map types.
This is step 1 to change to the new background
Modified:
trunk/src/map.cpp
Modified: trunk/src/map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/map.cpp?rev=17902&r1=17901&r2=17902&view=diff
==============================================================================
--- trunk/src/map.cpp (original)
+++ trunk/src/map.cpp Sun May 27 13:17:21 2007
@@ -422,11 +422,48 @@
}
}
+// loc the location
+// w the width of the map in hexes
+// h the height of the map in hexes
+static t_translation::t_letter get_border_terrain(const gamemap::location&
loc,
+ const int w, const int h)
+{
+ if(loc.x == 0) {
+ if(loc.y == 0) return t_translation::OFF_MAP_BORDER_TOP_LEFT;
+ if(loc.y == h) return t_translation::OFF_MAP_BORDER_TOP_RIGHT;
+ return t_translation::OFF_MAP_BORDER_TOP;
+ }
+
+ if(loc.x == w) {
+ if(loc.y == 0) return t_translation::OFF_MAP_BORDER_BOTTOM_LEFT;
+ if(loc.y == h) return
t_translation::OFF_MAP_BORDER_BOTTOM_RIGHT;
+ return t_translation::OFF_MAP_BORDER_BOTTOM;
+ }
+
+ if(loc.y == 0) return t_translation::OFF_MAP_BORDER_LEFT;
+ if(loc.y == h) return t_translation::OFF_MAP_BORDER_RIGHT;
+
+ return t_translation::OFF_MAP;
+}
+
t_translation::t_letter gamemap::get_terrain(const gamemap::location& loc)
const
{
- if(on_board(loc))
+ if(on_board(loc)) {
return tiles_[loc.x][loc.y];
-
+ }
+
+ const std::map<location, t_translation::t_letter>::const_iterator itor
= borderCache_.find(loc);
+ if(itor != borderCache_.end()) {
+ return itor->second;
+ }
+
+ const t_translation::t_letter result = get_border_terrain(loc, x(),
y());
+ borderCache_.insert(std::pair<location, t_translation::t_letter>(loc,
result));
+ return result;
+
+#if 0
+ // This code will be used for the editor to expand the map, thus keep
it for now
+
const std::map<location, t_translation::t_letter>::const_iterator itor
= borderCache_.find(loc);
if(itor != borderCache_.end())
return itor->second;
@@ -460,6 +497,7 @@
borderCache_.insert(std::pair<location,
t_translation::t_letter>(loc,used_terrain));
return used_terrain;
+#endif
}
const gamemap::location& gamemap::starting_position(int n) const
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits