Author: esr
Date: Wed Aug 20 19:06:27 2008
New Revision: 28791
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28791&view=rev
Log:
Refactor out a magic constant.
Modified:
trunk/src/ai.cpp
trunk/src/generate_report.cpp
trunk/src/help.cpp
trunk/src/unit_types.hpp
Modified: trunk/src/ai.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai.cpp?rev=28791&r1=28790&r2=28791&view=diff
==============================================================================
--- trunk/src/ai.cpp (original)
+++ trunk/src/ai.cpp Wed Aug 20 19:06:27 2008
@@ -1496,7 +1496,7 @@
j_end = terrain.end(); j != j_end; ++j)
{
// Use only reachable tiles when computing the average defense.
- if (a.movement_type().movement_cost(map_, j->first) < 99) {
+ if (a.movement_type().movement_cost(map_, j->first) <
unit_movement_type::UNREACHABLE) {
defense += a.movement_type().defense_modifier(map_,
j->first) * j->second;
weighting_sum += j->second;
}
Modified: trunk/src/generate_report.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/generate_report.cpp?rev=28791&r1=28790&r2=28791&view=diff
==============================================================================
--- trunk/src/generate_report.cpp (original)
+++ trunk/src/generate_report.cpp Wed Aug 20 19:06:27 2008
@@ -478,7 +478,7 @@
const int move_cost = u->second.movement_cost(terrain);
const int defense = 100 - u->second.defense_modifier(terrain);
- if(move_cost < 99) {
+ if(move_cost < unit_movement_type::UNREACHABLE) {
str << " (" << defense << "%," << move_cost << ")";
} else if (mouseover == displayed_unit_hex) {
str << " (" << defense << "%,-)";
Modified: trunk/src/help.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/help.cpp?rev=28791&r1=28790&r2=28791&view=diff
==============================================================================
--- trunk/src/help.cpp (original)
+++ trunk/src/help.cpp Wed Aug 20 19:06:27 2008
@@ -1518,7 +1518,7 @@
row.push_back(std::make_pair(markup,
font::line_width(str.str(), normal_font_size)));
- //movement - range: 1 .. 5,
99=impassable
+ //movement - range: 1 .. 5,
unit_movement_type::UNREACHABLE=impassable
str.str(clear_stringstream);
if (moves > type_.movement() )
// cannot move in this terrain
color = "red";
Modified: trunk/src/unit_types.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_types.hpp?rev=28791&r1=28790&r2=28791&view=diff
==============================================================================
--- trunk/src/unit_types.hpp (original)
+++ trunk/src/unit_types.hpp Wed Aug 20 19:06:27 2008
@@ -115,6 +115,9 @@
class unit_movement_type
{
public:
+ // maximum possible move distance
+ static const int UNREACHABLE = 99;
+
//this class assumes that the passed in reference will remain valid
//for at least as long as the class instance
unit_movement_type(const config& cfg, const unit_movement_type*
parent=NULL);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits