mail[Wesnoth-commits] r43984 - /trunk/src/tod_manager.cpp


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

Header


Content

Posted by alinktomine on July 07, 2010 - 14:47:
Author: alink
Date: Wed Jul  7 14:47:07 2010
New Revision: 43984

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43984&view=rev
Log:
Small optimization of time_of_day_at

Modified:
    trunk/src/tod_manager.cpp

Modified: trunk/src/tod_manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tod_manager.cpp?rev=43984&r1=43983&r2=43984&view=diff
==============================================================================
--- trunk/src/tod_manager.cpp (original)
+++ trunk/src/tod_manager.cpp Wed Jul  7 14:47:07 2010
@@ -247,10 +247,12 @@
 
 time_of_day tod_manager::time_of_day_at(const unit_map& units,const 
map_location& loc, const gamemap& map) const
 {
-       int lighten = 
std::max<int>(map.get_terrain_info(map.get_terrain(loc)).light_modification() 
, 0);
-       int darken = 
std::min<int>(map.get_terrain_info(map.get_terrain(loc)).light_modification() 
, 0);
-
-       time_of_day tod = get_time_of_day(lighten + darken,loc);
+       int light_modif =  
map.get_terrain_info(map.get_terrain(loc)).light_modification();
+       int lighten = std::max<int>(light_modif, 0);
+       int darken = std::min<int>(light_modif, 0);
+       int illumination = lighten + darken;
+
+       time_of_day tod = get_time_of_day(illumination, loc);
 
        if(loc.valid()) {
                map_location locs[7];
@@ -275,8 +277,11 @@
                                darken = std::min<int>(mod, darken);
                        }
                }
-       }
-       tod = get_time_of_day(lighten + darken,loc);
+               if(lighten + darken != illumination) {
+                       //update tod with the corrected  illumination
+                       tod = get_time_of_day(lighten + darken,loc);
+               }
+       }
 
        return tod;
 }




Related Messages


Powered by MHonArc, Updated Wed Jul 07 15:00:11 2010