mail[Wesnoth-commits] r44103 - /trunk/src/builder.cpp


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:21 2010
New Revision: 44103

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44103&view=rev
Log:
Simplify some redundancy in background/foreground terrain cases

Modified:
    trunk/src/builder.cpp

Modified: trunk/src/builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/builder.cpp?rev=44103&r1=44102&r2=44103&view=diff
==============================================================================
--- trunk/src/builder.cpp (original)
+++ trunk/src/builder.cpp Sun Jul 11 06:28:21 2010
@@ -88,13 +88,12 @@
                else
                        basey -= BASE_Y_INTERVAL/2;
 
-               if(layer < 0 || (layer == 0 && basey < UNITPOS)) {
-                       
images_background.push_back(tod_variant->second.image);
-                       
images_background.back().set_animation_time(itor->second.first%images_background.back().get_animation_duration());
-               } else {
-                       
images_foreground.push_back(tod_variant->second.image);
-                       
images_foreground.back().set_animation_time(itor->second.first%images_foreground.back().get_animation_duration());
-               }
+               bool is_background = layer < 0 || (layer == 0 && basey < 
UNITPOS);
+               imagelist& img_list =
+                               is_background ? images_background : 
images_foreground;
+       
+               img_list.push_back(tod_variant->second.image);
+               img_list.back().set_animation_time(itor->second.first % 
img_list.back().get_animation_duration());
        }
 }
 
@@ -235,14 +234,11 @@
                tile_at.last_tod = tod;
        }
 
-       if(terrain_type == BACKGROUND) {
-               if(!tile_at.images_background.empty())
-                       return &tile_at.images_background;
-       }
-
-       if(terrain_type == FOREGROUND) {
-               if(!tile_at.images_foreground.empty())
-                       return &tile_at.images_foreground;
+       const imagelist& img_list = (terrain_type == BACKGROUND) ?
+                       tile_at.images_background : tile_at.images_foreground;
+
+       if(!img_list.empty()) {
+               return &img_list;
        }
 
        return NULL;
@@ -253,22 +249,19 @@
        if(!tile_map_.on_map(loc))
                return false;
 
-       imagelist& bg = tile_map_[loc].images_background;
-       imagelist& fg = tile_map_[loc].images_foreground;
        bool changed = false;
 
-       imagelist::iterator itor = bg.begin();
-       for(; itor != bg.end(); ++itor) {
-               if(itor->need_update())
+       tile& btile = tile_map_[loc];
+
+       foreach(animated<image::locator>& a, btile.images_background) {
+               if(a.need_update())
                        changed = true;
-               itor->update_last_draw_time();
-       }
-
-       itor = fg.begin();
-       for(; itor != fg.end(); ++itor) {
-               if(itor->need_update())
+               a.update_last_draw_time();
+       }
+       foreach(animated<image::locator>& a, btile.images_foreground) {
+               if(a.need_update())
                        changed = true;
-               itor->update_last_draw_time();
+               a.update_last_draw_time();
        }
 
        return changed;




Related Messages


Powered by MHonArc, Updated Sun Jul 11 17:20:08 2010