wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src actions.cpp actions.hpp playturn.cpp


From: Philippe Plantier
Subject: [Wesnoth-cvs-commits] wesnoth/src actions.cpp actions.hpp playturn.cpp
Date: Sat, 27 Aug 2005 18:24:10 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      05/08/27 22:24:10

Modified files:
        src            : actions.cpp actions.hpp playturn.cpp 

Log message:
        Applying a refactored version of patch #4267 (thanks Ihsan) to fix 
#13638.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/actions.cpp.diff?tr1=1.238&tr2=1.239&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/actions.hpp.diff?tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.393&tr2=1.394&r1=text&r2=text

Patches:
Index: wesnoth/src/actions.cpp
diff -u wesnoth/src/actions.cpp:1.238 wesnoth/src/actions.cpp:1.239
--- wesnoth/src/actions.cpp:1.238       Fri Aug 26 15:21:46 2005
+++ wesnoth/src/actions.cpp     Sat Aug 27 22:24:10 2005
@@ -1,4 +1,4 @@
-/* $Id: actions.cpp,v 1.238 2005/08/26 15:21:46 darthfool Exp $ */
+/* $Id: actions.cpp,v 1.239 2005/08/27 22:24:10 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -86,6 +86,23 @@
        }
 }
 
+bool can_recruit_on(const gamemap& map, const gamemap::location& leader, const 
gamemap::location loc) 
+{
+       if(!map.on_board(loc))
+               return false;
+
+       if(!map.is_castle(loc))
+               return false;
+
+       castle_cost_calculator calc(map);
+       const paths::route& rt = a_star_search(leader, loc, 100.0, &calc, 
map.x(), map.y());
+
+       if(rt.steps.empty())
+               return false;
+
+       return true;
+}
+
 std::string recruit_unit(const gamemap& map, int side,
        std::map<gamemap::location,unit>& units, unit& new_unit,
        gamemap::location& recruit_location, display* disp, bool need_castle, 
bool full_movement)
@@ -115,11 +132,10 @@
                return _("You must have your leader on a keep to recruit or 
recall units.");
        }
 
-       if(need_castle && map.on_board(recruit_location)) {
-               castle_cost_calculator calc(map);
-               const paths::route& rt = a_star_search(u->first, 
recruit_location, 100.0, &calc, map.x(), map.y());
-               if(rt.steps.empty() || units.find(recruit_location) != 
units.end() ||
-                  !map.is_castle(recruit_location)) {
+       if(need_castle) {
+               if (units.find(recruit_location) != units.end() ||
+                       !can_recruit_on(map, u->first, recruit_location)) {
+
                        recruit_location = gamemap::location();
                }
        }
Index: wesnoth/src/actions.hpp
diff -u wesnoth/src/actions.hpp:1.52 wesnoth/src/actions.hpp:1.53
--- wesnoth/src/actions.hpp:1.52        Sat Jul  2 21:37:18 2005
+++ wesnoth/src/actions.hpp     Sat Aug 27 22:24:10 2005
@@ -1,4 +1,4 @@
-/* $Id: actions.hpp,v 1.52 2005/07/02 21:37:18 ott Exp $ */
+/* $Id: actions.hpp,v 1.53 2005/08/27 22:24:10 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -29,6 +29,7 @@
 
 //this file defines various functions which implement different in-game
 //events and commands.
+bool can_recruit_on(const gamemap& map, const gamemap::location& leader, const 
gamemap::location loc);
 
 //recruit_unit: function which recruits a unit into the game. A
 //copy of u will be created and inserted as the new recruited unit.
@@ -42,8 +43,8 @@
 //If the unit cannot be recruited, then a human-readable message
 //describing why not will be returned. On success, the return string is empty
 std::string recruit_unit(const gamemap& map, int team, unit_map& units,
-                                                unit& u, gamemap::location& 
recruit_location,
-                         display *disp=NULL, bool need_castle=true, bool 
full_movement=false);
+               unit& u, gamemap::location& recruit_location,
+               display *disp=NULL, bool need_castle=true, bool 
full_movement=false);
 
 //a structure which defines all the statistics for a potential
 //battle that could take place.
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.393 wesnoth/src/playturn.cpp:1.394
--- wesnoth/src/playturn.cpp:1.393      Sat Aug 27 20:27:39 2005
+++ wesnoth/src/playturn.cpp    Sat Aug 27 22:24:10 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.393 2005/08/27 20:27:39 Sirp Exp $ */
+/* $Id: playturn.cpp,v 1.394 2005/08/27 22:24:10 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -1032,10 +1032,16 @@
        //Only display these if the mouse is over a castle or keep tile
        case hotkey::HOTKEY_RECRUIT:
        case hotkey::HOTKEY_REPEAT_RECRUIT:
-       case hotkey::HOTKEY_RECALL:
+       case hotkey::HOTKEY_RECALL: {
                // last_hex_ is set by turn_info::mouse_motion
                // Enable recruit/recall on castle/keep tiles
-               return map_.is_castle(last_hex_);
+               const unit_map::const_iterator leader = 
team_leader(team_num_,units_);
+               if (leader != units_.end()) {
+                       return can_recruit_on(map_, leader->first, last_hex_);
+               } else {
+                       return false;
+               }
+       }
        default:
                return true;
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]