mail[Wesnoth-commits] r44559 - in /trunk/src: game_events.cpp menu_events.cpp tod_manager.cpp tod_manager.hpp


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

Header


Content

Posted by guillaume . melquiond on July 22, 2010 - 22:05:
Author: silene
Date: Thu Jul 22 22:05:42 2010
New Revision: 44559

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44559&view=rev
Log:
Simplified code by changing access to number of turns from relative to 
absolute.

Modified:
    trunk/src/game_events.cpp
    trunk/src/menu_events.cpp
    trunk/src/tod_manager.cpp
    trunk/src/tod_manager.hpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=44559&r1=44558&r2=44559&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Thu Jul 22 22:05:42 2010
@@ -966,8 +966,7 @@
        if(!add.empty()) {
                tod_man.modify_turns(add);
        } else if(!value.empty()) {
-               tod_man.add_turns(-tod_man.number_of_turns());
-               tod_man.add_turns(lexical_cast_default<int>(value,-1));
+               
tod_man.set_number_of_turns(lexical_cast_default<int>(value,-1));
        }
        // change current turn only after applying mods
        if(!current.empty()) {

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=44559&r1=44558&r2=44559&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Thu Jul 22 22:05:42 2010
@@ -3299,8 +3299,7 @@
        tod_manager& tod_man = *resources::tod_manager;
        int limit =
                get_data().empty() ? -1 : 
lexical_cast_default<int>(get_data(), 1);
-       tod_man.add_turns(-tod_man.number_of_turns());
-       tod_man.add_turns(lexical_cast_default<int>(limit,-1));
+       tod_man.set_number_of_turns(limit);
        menu_handler_.gui_->redraw_everything();
 }
 

Modified: trunk/src/tod_manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tod_manager.cpp?rev=44559&r1=44558&r2=44559&view=diff
==============================================================================
--- trunk/src/tod_manager.cpp (original)
+++ trunk/src/tod_manager.cpp Thu Jul 22 22:05:42 2010
@@ -283,9 +283,9 @@
 {
        num_turns_ = 
std::max<int>(utils::apply_modifier(num_turns_,mod,0),-1);
 }
-void tod_manager::add_turns(int num)
-{
-       num_turns_ = std::max<int>(num_turns_ + num,-1);
+void tod_manager::set_number_of_turns(int num)
+{
+       num_turns_ = std::max<int>(num, -1);
 }
 
 void tod_manager::set_turn(unsigned int num)
@@ -299,7 +299,7 @@
        set_time_of_day(current_time);
 
        if(static_cast<int>(num) > num_turns_ && num_turns_ != -1) {
-               add_turns(num - num_turns_);
+               set_number_of_turns(num);
        }
        turn_ = num;
 

Modified: trunk/src/tod_manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tod_manager.hpp?rev=44559&r1=44558&r2=44559&view=diff
==============================================================================
--- trunk/src/tod_manager.hpp (original)
+++ trunk/src/tod_manager.hpp Thu Jul 22 22:05:42 2010
@@ -95,7 +95,7 @@
                size_t turn() const {return turn_;}
                int number_of_turns() const {return num_turns_;}
                void modify_turns(const std::string& mod);
-               void add_turns(int num);
+               void set_number_of_turns(int num);
 
                /** Dynamically change the current turn number. */
                void set_turn(unsigned int num);




Related Messages


Powered by MHonArc, Updated Thu Jul 22 22:20:13 2010