[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src unit.cpp
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src unit.cpp |
Date: |
Fri, 21 Jan 2005 16:23:31 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/01/21 21:23:31
Modified files:
src : unit.cpp
Log message:
Fix wrong code. And factor out the common piece, but do we want to keep
the submerge ability?
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.cpp.diff?tr1=1.114&tr2=1.115&r1=text&r2=text
Patches:
Index: wesnoth/src/unit.cpp
diff -u wesnoth/src/unit.cpp:1.114 wesnoth/src/unit.cpp:1.115
--- wesnoth/src/unit.cpp:1.114 Fri Jan 21 20:16:43 2005
+++ wesnoth/src/unit.cpp Fri Jan 21 21:23:31 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.cpp,v 1.114 2005/01/21 20:16:43 Sirp Exp $ */
+/* $Id: unit.cpp,v 1.115 2005/01/21 21:23:31 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -423,6 +423,10 @@
hitpoints_ = max_hitpoints();
}
+static bool is_terrain(std::string const &terrain, gamemap::TERRAIN type) {
+ return std::count(terrain.begin(), terrain.end(),
static_cast<gamemap::TERRAIN>(type));
+}
+
bool unit::invisible(const std::string& terrain, int lawful_bonus,
const gamemap::location& loc,
const unit_map& units,const std::vector<team>& teams) const
@@ -430,8 +434,7 @@
bool is_inv = false;
static const std::string forest_invisible("ambush");
- if ((has_flag(forest_invisible)) &&
- (std::count(terrain.begin(), terrain.end(), gamemap::FOREST))) {
+ if (has_flag(forest_invisible) && is_terrain(terrain, gamemap::FOREST))
{
is_inv = true;
}
else
@@ -443,11 +446,10 @@
else
{
static const std::string sea_invisible("submerge");
- if ((has_flag(sea_invisible)) &&
- ((std::count(terrain.begin(), terrain.end(),
gamemap::SEA)) ||
- (std::count(terrain.begin(), terrain.end(),
gamemap::DEEP_SEA)))) {
- is_inv = true;
- }
+ if (has_flag(sea_invisible) &&
+ (is_terrain(terrain, gamemap::SEA) ||
is_terrain(terrain, gamemap::DEEP_SEA))) {
+ is_inv = true;
+ }
}
}
- [Wesnoth-cvs-commits] wesnoth/src unit.cpp,
Guillaume Melquiond <=