mail[Wesnoth-commits] r44101 - in /trunk/src: display.cpp display.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by alinktomine on July 11, 2010 - 06:28:
Author: alink
Date: Sun Jul 11 06:28:11 2010
New Revision: 44101

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44101&view=rev
Log:
Better separate fog/shroud generation from terrain images

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=44101&r1=44100&r2=44101&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sun Jul 11 06:28:11 2010
@@ -594,9 +594,9 @@
        return dirs[n >= sizeof(dirs)/sizeof(*dirs) ? 0 : n];
 }
 
-std::vector<std::string> display::get_fog_shroud_graphics(const 
map_location& loc)
-{
-       std::vector<std::string> res;
+std::vector<surface> display::get_fog_shroud_images(const map_location& loc, 
image::TYPE image_type)
+{
+       std::vector<std::string> names;
 
        map_location adjacent[6];
        get_adjacent_tiles(loc,adjacent);
@@ -616,7 +616,6 @@
                        tiles[i] = CLEAR;
                }
        }
-
 
        for(int v = FOG; v != CLEAR; ++v) {
                // Find somewhere that doesn't have overlap to use as a 
starting point
@@ -654,12 +653,21 @@
                                }
 
                                if(!name.empty()) {
-                                       res.push_back(name + ".png");
+                                       names.push_back(name + ".png");
                                }
                        } else {
                                i = (i+1)%6;
                        }
                }
+       }
+
+       // now get the surfaces
+       std::vector<surface> res;
+
+       foreach(std::string& name, names) {
+               const surface surf(image::get_image(name, image_type));
+               if (surf)
+                       res.push_back(surf);
        }
 
        return res;
@@ -671,24 +679,6 @@
                ADJACENT_TERRAIN_TYPE terrain_type)
 {
        std::vector<surface> res;
-
-       if(terrain_type == ADJACENT_FOGSHROUD) {
-               const std::vector<std::string> fog_shroud = 
get_fog_shroud_graphics(loc);
-
-               if(!fog_shroud.empty()) {
-                       for(std::vector<std::string>::const_iterator it = 
fog_shroud.begin(); it != fog_shroud.end(); ++it) {
-                               image::locator image(*it);
-
-                               const surface surface(image::get_image(image, 
image_type));
-                               if (!surface.null()) {
-                                       res.push_back(surface);
-                               }
-                       }
-
-               }
-
-               return res;
-       }
 
        terrain_builder::ADJACENT_TERRAIN_TYPE builder_terrain_type =
              (terrain_type == ADJACENT_FOREGROUND ?
@@ -713,11 +703,11 @@
                        // not the location, since the transitions are 
rendered
                        // over the offmap-terrain and these need a ToD 
coloring.
                        const bool off_map = (image.get_filename() == 
off_map_name);
-                       const surface surface(image::get_image(image,
+                       const surface surf(image::get_image(image,
                                off_map ? image::UNMASKED : image_type));
 
-                       if (!surface.null()) {
-                               res.push_back(surface);
+                       if (!surf.null()) {
+                               res.push_back(surf);
                        }
                }
        }
@@ -2001,7 +1991,7 @@
 
        if(!shrouded(loc)) {
                drawing_buffer_add(LAYER_FOG_SHROUD, loc, tblit(xpos, ypos,
-                       get_terrain_images(loc, tod.id, image_type, 
ADJACENT_FOGSHROUD)));
+                       get_fog_shroud_images(loc, image_type)));
        }
        if (on_map) {
                if (draw_coordinates_) {

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=44101&r1=44100&r2=44101&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sun Jul 11 06:28:11 2010
@@ -533,14 +533,14 @@
 
        void draw_minimap();
 
-       enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, 
ADJACENT_FOREGROUND, ADJACENT_FOGSHROUD };
+       enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, 
ADJACENT_FOREGROUND};
 
        std::vector<surface> get_terrain_images(const map_location &loc,
                                        const std::string& timeid,
                                        image::TYPE type,
                                        ADJACENT_TERRAIN_TYPE terrain_type);
 
-       std::vector<std::string> get_fog_shroud_graphics(const map_location& 
loc);
+       std::vector<surface> get_fog_shroud_images(const map_location& loc, 
image::TYPE image_type);
 
        void draw_image_for_report(surface& img, SDL_Rect& rect);
 




Related Messages


Powered by MHonArc, Updated Sun Jul 11 06:40:12 2010