mail[Wesnoth-commits] r43665 - in /trunk/src: ./ ai/ ai/composite/ ai/default/ ai/formula/ ai/testing/ pathfind/


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

Header


Content

Posted by alinktomine on June 24, 2010 - 03:49:
Author: alink
Date: Thu Jun 24 03:49:14 2010
New Revision: 43665

URL: http://svn.gna.org/viewcvs/wesnoth?rev=43665&view=rev
Log:
Use resources in unit::invisible()
It was already using it via get_ability_bool("hides")

Modified:
    trunk/src/actions.cpp
    trunk/src/ai/composite/goal.cpp
    trunk/src/ai/contexts.cpp
    trunk/src/ai/default/contexts.cpp
    trunk/src/ai/formula/callable_objects.cpp
    trunk/src/ai/formula/candidates.cpp
    trunk/src/ai/testing/aspect_attacks.cpp
    trunk/src/game_display.cpp
    trunk/src/generate_report.cpp
    trunk/src/menu_events.cpp
    trunk/src/mouse_events.cpp
    trunk/src/pathfind/pathfind.cpp
    trunk/src/unit.cpp
    trunk/src/unit.hpp
    trunk/src/unit_display.cpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Thu Jun 24 03:49:14 2010
@@ -1881,7 +1881,7 @@
 
 
                if (!recorder.is_skipping() && update_display &&
-                   !(u.invisible(u.get_location(), units, *resources::teams) 
&&
+                   !(u.invisible(u.get_location()) &&
                      
(*resources::teams)[resources::screen->viewing_team()].is_enemy(side)))
                {
                        unit_healing_struct uhs = { &u, healers, healing };
@@ -2075,7 +2075,7 @@
 
                        const unit_map::const_iterator sighted = 
resources::units->find(*it);
                        if (sighted.valid() &&
-                           (!sighted->invisible(*it, *resources::units, 
*resources::teams)
+                           (!sighted->invisible(*it)
                             || !tm.is_enemy(sighted->side())))
                        {
                                //check if we know this unit, but we always 
know ourself
@@ -2323,7 +2323,7 @@
 
                        const unit_map::const_iterator it = 
units.find(adjacent[i]);
                        if (it != units.end() && tm->is_enemy(it->side()) &&
-                           it->invisible(it->get_location(), units, teams))
+                           it->invisible(it->get_location()))
                        {
                                discovered_unit = true;
                                should_clear_stack = true;
@@ -2390,7 +2390,7 @@
        for(int i = 0; i != 6; ++i) {
                const unit_map::const_iterator it = units.find(adjacent[i]);
                if (it != units.end() && tm->is_enemy(it->side()) &&
-                               it->invisible(it->get_location(), units, 
teams))
+                               it->invisible(it->get_location()))
                        disp.invalidate(adjacent[i]);
        }
 

Modified: trunk/src/ai/composite/goal.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/composite/goal.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/ai/composite/goal.cpp (original)
+++ trunk/src/ai/composite/goal.cpp Thu Jun 24 03:49:14 2010
@@ -195,10 +195,7 @@
                DBG_AI_GOAL << goal_type << " goal with criteria" << 
std::endl << cfg_.child("criteria") << std::endl;
        }
 
-
        unit_map &units = *resources::units;
-       std::vector<team> &teams = *resources::teams;
-
 
        std::set<map_location> items;
        if (protect_unit_) {
@@ -224,7 +221,7 @@
                {
                        int distance = distance_between(u.get_location(), 
loc);
                        if (current_team().is_enemy(u.side()) && distance < 
radius_ &&
-                           !u.invisible(u.get_location(), units, teams))
+                           !u.invisible(u.get_location()))
                        {
                                DBG_AI_GOAL << "in " << goal_type << ": found 
threat target. " << u.get_location() << " is a threat to "<< loc << '\n';
                                *target_list = target(u.get_location(),

Modified: trunk/src/ai/contexts.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/contexts.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/ai/contexts.cpp (original)
+++ trunk/src/ai/contexts.cpp Thu Jun 24 03:49:14 2010
@@ -335,7 +335,7 @@
                }
 
                // We can't see where invisible enemy units might move.
-               if (enemy && un_it->invisible(un_it->get_location(), units, 
*resources::teams) && !see_all) {
+               if (enemy && un_it->invisible(un_it->get_location()) && 
!see_all) {
                        continue;
                }
                // If it's an enemy unit, reset its moves while we do the 
calculations.

Modified: trunk/src/ai/default/contexts.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/default/contexts.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/ai/default/contexts.cpp (original)
+++ trunk/src/ai/default/contexts.cpp Thu Jun 24 03:49:14 2010
@@ -85,7 +85,7 @@
                        ret += count_free_hexes_in_castle(adj[n], 
checked_hexes);
                        if (u == units_.end()
                                || (current_team().is_enemy(u->side())
-                                       && u->invisible(adj[n], units_, 
*resources::teams))
+                                       && u->invisible(adj[n]))
                                || ((&(*resources::teams)[u->side() - 1]) == 
&current_team()
                                        && u->movement_left() > 0)) {
                                ret += 1;
@@ -237,7 +237,7 @@
                for(u = units_.begin(); u != units_.end(); ++u) {
                        //is a visible enemy leader
                        if (u->can_recruit() && 
current_team().is_enemy(u->side())
-                           && !u->invisible(u->get_location(), units_, 
teams_)) {
+                           && !u->invisible(u->get_location())) {
                                assert(map_.on_board(u->get_location()));
                                LOG_AI << "found enemy leader (side: " << 
u->side() << ") target... " << u->get_location() << " with value: " << 
get_leader_value() << "\n";
                                targets.push_back(target(u->get_location(), 
get_leader_value(), target::LEADER));

Modified: trunk/src/ai/formula/callable_objects.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/formula/callable_objects.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/ai/formula/callable_objects.cpp (original)
+++ trunk/src/ai/formula/callable_objects.cpp Thu Jun 24 03:49:14 2010
@@ -208,7 +208,7 @@
                /* if tile is occupied by friendly or petrified/invisible 
unit */
                if (!ai_.current_team().is_enemy(unit->side())  ||
                    unit->incapacitated() ||
-                   unit->invisible(unit->get_location(), units_, 
*resources::teams))
+                   unit->invisible(unit->get_location()))
                        continue;
                /* add attacks with default weapon */
                attack_callable* item = new 
attack_callable(attacker_location, attack_position, adj[n], -1);

Modified: trunk/src/ai/formula/candidates.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/formula/candidates.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/ai/formula/candidates.cpp (original)
+++ trunk/src/ai/formula/candidates.cpp Thu Jun 24 03:49:14 2010
@@ -217,7 +217,7 @@
                        }
                } else
                {
-                       if (ai->current_team().is_enemy(i->side()) && 
!i->incapacitated() && !i->invisible(i->get_location(), *resources::units, 
*resources::teams)) {
+                       if (ai->current_team().is_enemy(i->side()) && 
!i->incapacitated() && !i->invisible(i->get_location())) {
                                enemy_res.push_back(variant(new 
unit_callable(*i)));
                        }
                }

Modified: trunk/src/ai/testing/aspect_attacks.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/testing/aspect_attacks.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/ai/testing/aspect_attacks.cpp (original)
+++ trunk/src/ai/testing/aspect_attacks.cpp Thu Jun 24 03:49:14 2010
@@ -96,7 +96,7 @@
                // Attack anyone who is on the enemy side,
                // and who is not invisible or petrified.
                if (current_team().is_enemy(j->side()) && !j->incapacitated() 
&&
-                   !j->invisible(j->get_location(),units_,*resources::teams))
+                   !j->invisible(j->get_location()))
                {
                        if (!j->matches_filter(vconfig(filter_enemy_), 
j->get_location())) {
                                continue;

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Thu Jun 24 03:49:14 2010
@@ -468,7 +468,7 @@
        for(unit_map::const_iterator u = units_.begin(); u != units_.end(); 
++u) {
                if (fogged(u->get_location()) ||
                    (teams_[currentTeam_].is_enemy(u->side()) &&
-                    u->invisible(u->get_location(), units_,teams_))) {
+                    u->invisible(u->get_location()))) {
                        continue;
                }
 

Modified: trunk/src/generate_report.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/generate_report.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/generate_report.cpp (original)
+++ trunk/src/generate_report.cpp Thu Jun 24 03:49:14 2010
@@ -166,7 +166,7 @@
        case UNIT_STATUS: {
                report res;
                if (map.on_board(displayed_unit_hex) &&
-                   u->invisible(displayed_unit_hex, units, teams))
+                   u->invisible(displayed_unit_hex))
                {
                        add_status(res, "misc/invisible.png", N_("invisible: 
"),
                                N_("This unit is invisible. It cannot be seen 
or attacked by enemy units."));
@@ -419,7 +419,7 @@
                                    !current_team.fogged(loc) &&
                                    seen_units.count(u_it->type_id()) == 0 &&
                                    (!current_team.is_enemy(u_it->side()) ||
-                                    !u_it->invisible(loc, units, teams)))
+                                    !u_it->invisible(loc)))
                                {
                                        seen_units.insert(u_it->type_id());
                                        int resistance = 
u_it->resistance_against(at, false, loc) - 100;

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Thu Jun 24 03:49:14 2010
@@ -256,7 +256,7 @@
                        row << IMAGE_PREFIX << "misc/poisoned.png" << 
IMG_TEXT_SEPARATOR;
                if(i->get_state(unit::STATE_SLOWED))
                        row << IMAGE_PREFIX << "misc/slowed.png"   << 
IMG_TEXT_SEPARATOR;
-               if(i->invisible(i->get_location(), units_, teams_ ,false))
+               if(i->invisible(i->get_location(),false))
                        row << IMAGE_PREFIX << "misc/invisible.png";
                row << COLUMN_SEPARATOR;
 
@@ -1248,7 +1248,7 @@
 
        // Compute enemy movement positions
        for(unit_map::iterator u = units_.begin(); u != units_.end(); ++u) {
-               bool invisible = u->invisible(u->get_location(), units_, 
teams_);
+               bool invisible = u->invisible(u->get_location());
 
                if (teams_[side_num - 1].is_enemy(u->side()) &&
                    !gui_->fogged(u->get_location()) && !u->incapacitated() 
&& !invisible)
@@ -2960,7 +2960,7 @@
                                                last_search_.begin(), 
last_search_.end(),
                                                chars_equal_insensitive) != 
name.end()) {
                                        if 
(!teams_[gui_->viewing_team()].is_enemy(ui->side()) ||
-                                           
!ui->invisible(ui->get_location(), units_,teams_)) {
+                                           
!ui->invisible(ui->get_location())) {
                                                found = true;
                                        }
                                }

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Thu Jun 24 03:49:14 2010
@@ -922,7 +922,7 @@
                return false;
 
        if (current_team().is_enemy(int(gui().viewing_team()+1)) &&
-           it->invisible(it->get_location(), units_, teams_))
+           it->invisible(it->get_location()))
                return false;
 
        if (it->get_hidden())

Modified: trunk/src/pathfind/pathfind.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind/pathfind.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/pathfind/pathfind.cpp (original)
+++ trunk/src/pathfind/pathfind.cpp Thu Jun 24 03:49:14 2010
@@ -421,7 +421,7 @@
 
                        ++turns;
 
-                       bool invisible = u.invisible(*i,units,teams,false);
+                       bool invisible = u.invisible(*i,false);
 
                        res.marks[*i] = marked_route::mark(turns, pass_here, 
zoc, capture, invisible);
 
@@ -432,7 +432,7 @@
                                return res; //we can't reach destination
                        }
                } else if (pass_here) {
-                       bool invisible = u.invisible(*i,units,teams,false);
+                       bool invisible = u.invisible(*i,false);
                        res.marks[*i] = marked_route::mark(0, pass_here, zoc, 
false, invisible);
                }
 

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Thu Jun 24 03:49:14 2010
@@ -1439,7 +1439,7 @@
                        std::set<int>::const_iterator viewer, viewer_end = 
viewers.end();
                        for (viewer = viewers.begin(); viewer != viewer_end; 
++viewer) {
                                bool not_fogged = 
!teams_manager::get_teams()[*viewer - 1].fogged(loc);
-                               bool not_hiding = !this->invisible(loc, 
*resources::units, teams_manager::get_teams()/*, false(?) */);
+                               bool not_hiding = !this->invisible(loc/*, 
false(?) */);
                                if (visible != not_fogged && not_hiding) {
                                        return false;
                                }
@@ -1761,7 +1761,7 @@
        game_display &disp = *game_display::get_singleton();
        const gamemap &map = disp.get_map();
        if (!loc_.valid() || hidden_ || disp.fogged(loc_) ||
-           (invisible(loc_, disp.get_units(), disp.get_teams())
+           (invisible(loc_)
        && disp.get_teams()[disp.viewing_team()].is_enemy(side())))
        {
                clear_haloes();
@@ -1786,7 +1786,7 @@
        // do not set to 0 so we can distinguih the flying from the "not on 
submerge terrain"
         params.submerge= is_flying() ? 0.01 : terrain_info.unit_submerge();
 
-       if (invisible(loc_, disp.get_units(), disp.get_teams()) &&
+       if (invisible(loc_) &&
                        params.highlight_ratio > 0.5) {
                params.highlight_ratio = 0.5;
        }
@@ -2624,8 +2624,7 @@
        max_experience_ = std::max<int>(1, (max_experience_ * exp_accel + 
50)/100);
 }
 
-bool unit::invisible(const map_location& loc,
-               const unit_map& units,const std::vector<team>& teams, bool 
see_all) const
+bool unit::invisible(const map_location& loc, bool see_all) const
 {
        // Fetch from cache
        /**
@@ -2643,7 +2642,8 @@
        static const std::string hides("hides");
        bool is_inv = !get_state(STATE_UNCOVERED) && 
get_ability_bool(hides,loc);
        if(is_inv){
-               foreach (const unit &u, units)
+               const std::vector<team>& teams = *resources::teams;
+               foreach (const unit &u, *resources::units)
                {
                        const map_location &u_loc = u.get_location();
                        if (teams[side_-1].is_enemy(u.side()) && 
tiles_adjacent(loc, u_loc)) {
@@ -2653,7 +2653,7 @@
                                        is_inv = false;
                                        break;
                                } else if (!teams[side_-1].fogged(u_loc)
-                               && !u.invisible(u_loc, units, teams, true)) {
+                               && !u.invisible(u_loc, true)) {
                                        is_inv = false;
                                        break;
                                }
@@ -2750,7 +2750,7 @@
        if (see_all) return u;
        if (!u.valid() || current_team.fogged(loc) ||
            (current_team.is_enemy(u->side()) &&
-            u->invisible(loc, units, *resources::teams)))
+            u->invisible(loc)))
                return units.end();
        return u;
 }

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Thu Jun 24 03:49:14 2010
@@ -315,8 +315,7 @@
        void generate_name(rand_rng::simple_rng *rng = 0);
 
        // Only see_all=true use caching
-       bool invisible(const map_location& loc,
-               const unit_map& units,const std::vector<team>& teams, bool 
see_all=true) const;
+       bool invisible(const map_location& loc, bool see_all=true) const;
 
        /** Mark this unit as clone so it can be insterted to unit_map
         * @returns                   self (for convenience)

Modified: trunk/src/unit_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_display.cpp?rev=43665&r1=43664&r2=43665&view=diff
==============================================================================
--- trunk/src/unit_display.cpp (original)
+++ trunk/src/unit_display.cpp Thu Jun 24 03:49:14 2010
@@ -135,10 +135,8 @@
                return;
        }
 
-       const unit_map& units = disp->get_units();
-
        bool invisible = 
teams[u.side()-1].is_enemy(int(disp->viewing_team()+1)) &&
-               u.invisible(path[0],units,teams);
+               u.invisible(path[0]);
 
        bool was_hidden = u.get_hidden();
        // Original unit is usually hidden (but still on map, so count is 
correct)
@@ -179,8 +177,8 @@
        for(size_t i = 0; i+1 < path.size(); ++i) {
 
                invisible = 
teams[temp_unit.side()-1].is_enemy(int(disp->viewing_team()+1)) &&
-                               temp_unit.invisible(path[i],units,teams) &&
-                               temp_unit.invisible(path[i+1],units,teams);
+                               temp_unit.invisible(path[i]) &&
+                               temp_unit.invisible(path[i+1]);
 
                if(!invisible) {
                        if (!disp->tile_fully_on_screen(path[i]) || 
!disp->tile_fully_on_screen(path[i+1])) {




Related Messages


Powered by MHonArc, Updated Thu Jun 24 04:00:18 2010