Author: fendrin
Date: Tue Jan 12 14:38:04 2010
New Revision: 40678

URL: http://svn.gna.org/viewcvs/wesnoth?rev=40678&view=rev
Log:
Code cleanups. Removed debug output.

Modified:
    branches/fendrin_pathfind/src/astarsearch.cpp
    branches/fendrin_pathfind/src/pathfind.cpp
    branches/fendrin_pathfind/src/pathfind.hpp

Modified: branches/fendrin_pathfind/src/astarsearch.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/astarsearch.cpp?rev=40678&r1=40677&r2=40678&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/astarsearch.cpp (original)
+++ branches/fendrin_pathfind/src/astarsearch.cpp Tue Jan 12 14:38:04 2010
@@ -99,7 +99,6 @@
                        const std::vector<std::set<map_location> > 
&destinations = teleports->get_destinations();
 
                        it = destinations.begin();
-
                        for(; it != destinations.end(); ++it) {
                                std::set<map_location>::const_iterator it2;
                                for(it2 = it->begin(); it2 != it->end(); ++it2) 
{
@@ -146,7 +145,6 @@
 plain_route a_star_search(const map_location& src, const map_location& dst,
                             double stop_at, const cost_calculator *calc, const 
size_t width,
                             const size_t height,
-                            //const std::set<map_location>* teleports,
                             const teleport_map *teleports) {
        //----------------- PRE_CONDITIONS ------------------
        assert(src.valid(width, height));
@@ -164,8 +162,6 @@
                return locRoute;
        }
 
-//     if (teleports && teleports->empty()) teleports = NULL;
-
        // increment search_counter but skip the range equivalent to 
uninitialized
        search_counter += 2;
        if (search_counter - bad_search_counter <= 1u)
@@ -183,13 +179,9 @@
        std::vector<int> pq;
        pq.push_back(index(src));
 
-       ERR_PF << "Expandiere den Knoten: " << pq.front() << "\n";
-
        while (!pq.empty()) {
                node& n = nodes[pq.front()];
 
-               ERR_PF << "Expandiere den Knoten: " << n.curr.x << " " << 
n.curr.y << "\n";
-
                n.in = search_counter;
 
                std::pop_heap(pq.begin(), pq.end(), node_comp);
@@ -197,8 +189,6 @@
 
                if (n.t >= nodes[index(dst)].g) break;
 
-//             std::set<map_location>::iterator teleports_iterator;
-
                std::vector<map_location> locs;
 
                int i;
@@ -206,26 +196,16 @@
 
                        const std::set<map_location>& allowed_teleports = 
teleports->get_adjacents(n.curr);
 
-//                     teleports_iterator = teleports->get_adjacents(n.curr);
-//                     i = teleports_iterator != teleports->end() ? 
(*(teleports_iterator->second)).size() + 6 : 6;
-
                        i = allowed_teleports.size() +6;
                        locs = std::vector<map_location>(i);
 
-//                     if (teleports_iterator != teleports->end() ) {
                        std::copy(allowed_teleports.begin(), 
allowed_teleports.end(), locs.begin() + 6);
-//                     }
-
                } else
                { locs = std::vector<map_location>(6); i = 6;}
 
                get_adjacent_tiles(n.curr, &locs[0]);
 
                for (; i-- > 0;) {
-
-                       if (i != 5) {
-                               ERR_PF << "Keine normale anzahl\n";
-                       }
 
                        if (!locs[i].valid(width, height)) continue;
                        if (locs[i] == n.curr) continue;
@@ -256,7 +236,6 @@
                route.move_cost = static_cast<int>(nodes[index(dst)].g);
                for (node curr = nodes[index(dst)]; curr.prev != 
map_location::null_location; curr = nodes[index(curr.prev)]) {
                        route.steps.push_back(curr.curr);
-                       ERR_PF << "sowas\n";
                }
                route.steps.push_back(src);
                std::reverse(route.steps.begin(), route.steps.end());
@@ -264,7 +243,6 @@
                LOG_PF << "aborted a* search  " << "\n";
                route.move_cost = static_cast<int>(calc->getNoPathValue());
        }
-       ERR_PF << "fertig\n";
        return route;
 }
 

Modified: branches/fendrin_pathfind/src/pathfind.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/pathfind.cpp?rev=40678&r1=40677&r2=40678&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/pathfind.cpp (original)
+++ branches/fendrin_pathfind/src/pathfind.cpp Tue Jan 12 14:38:04 2010
@@ -40,8 +40,6 @@
 
 teleport_map::teleport_map(std::vector<teleport_group> groups) : 
teleport_map_(), sources_(), destinations_(), empty_() {
 
-       //sources_.push_back(std::set<map_location>() );
-
        for (std::vector<teleport_group>::iterator it = groups.begin(); it != 
groups.end(); it++) {
                sources_.push_back(it->first);
                destinations_.push_back(it->second);
@@ -54,35 +52,23 @@
                }
                destinations_it++;
        }
-
-//     foreach (const teleport_group& group, groups) {
-//             sources_.insert(group.first);
-//             destinations_.insert(group.second);
-//     }
 }
 
 //TODO move to the right place
 const std::set<map_location>& teleport_map::get_adjacents(map_location loc) 
const {
 
        if (teleport_map_.count(loc) == 0) {
-//             const std::set<map_location> ret = sources_[0];
+               //TODO remove the empty hack
                return empty_;
        } else {
-
                const std::set<map_location>& ret = 
*(teleport_map_.find(loc)->second);
-               for (std::set<map_location>::const_iterator it = ret.begin(); 
it != ret.end(); it++) {
-                       ERR_PF << it->x << "/" << it->y << "\n";
-               }
-               //              return *(teleport_map_.find(loc)->second);
+               //TODO remove debug output
+//             for (std::set<map_location>::const_iterator it = ret.begin(); 
it != ret.end(); it++) {
+//                     ERR_PF << it->x << "/" << it->y << "\n";
+//             }
                return ret;
        }
-
-//     return ret;
-//     return teleport_map_.count(loc) == 0 ? &(sources_[0]) : 
*(teleport_map_.find(loc)->second);
-}
-
-
-
+}
 
 map_location find_vacant_tile(const gamemap& map,
                                const unit_map& units,
@@ -179,48 +165,11 @@
 
        groups.push_back(village_group);
 
-//     std::map<map_location, std::set<map_location>* > res;
-//     foreach (const map_location &v, villages)
-//     {
-//             res.insert(std::make_pair(v, &villages));
-//     }
+       //TODO add the custom teleports
+
        const teleport_map res = teleport_map(groups);
        return res;
 }
-
-
-
-
-
-//std::map<map_location, std::set<map_location>* > 
get_teleport_locations(const unit &u,
-//     const unit_map &units, const team &viewing_team,
-//     bool see_all, bool ignore_units)
-//{
-//     std::set<map_location> villages;
-//     if (!u.get_ability_bool("teleport")) return 
resources::game_map->tunnels();
-//
-//     const team &current_team = (*resources::teams)[u.side() - 1];
-//     const map_location &loc = u.get_location();
-//     foreach (const map_location &l, current_team.villages())
-//     {
-//             // This must be a vacant village (or occupied by the unit)
-//             // to be able to teleport.
-//             if (!see_all && viewing_team.is_enemy(u.side()) && 
viewing_team.fogged(l))
-//                     continue;
-//             if (!ignore_units && l != loc &&
-//                 get_visible_unit(units, l, viewing_team, see_all))
-//                     continue;
-//             villages.insert(l);
-//     }
-//
-//     std::map<map_location, std::set<map_location>* > res;
-//     foreach (const map_location &v, villages)
-//     {
-//             res.insert(std::make_pair(v, &villages));
-//     }
-//
-//     return res;
-//}
 
 static unsigned search_counter;
 
@@ -294,10 +243,6 @@
        }
 
        const int total_movement = u.total_movement();
-
-//     std::vector<map_location> locs(6 + teleports.size());
-       //TODO copy the teleports
-//     std::copy(teleports.begin(), teleports.end(), locs.begin() + 6);
 
        search_counter += 2;
        if (search_counter == 0) search_counter = 2;

Modified: branches/fendrin_pathfind/src/pathfind.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_pathfind/src/pathfind.hpp?rev=40678&r1=40677&r2=40678&view=diff
==============================================================================
--- branches/fendrin_pathfind/src/pathfind.hpp (original)
+++ branches/fendrin_pathfind/src/pathfind.hpp Tue Jan 12 14:38:04 2010
@@ -52,25 +52,7 @@
        std::vector<std::set<map_location> > sources_;
        std::vector<std::set<map_location> > destinations_;
        std::set<map_location> empty_;
-
-/*
-       class teleport_group {
-        std::set<map_location> locations_;
-                bool is_unit_allowed_to_use_this_teleport_group(const unit&);
-        std::map<map_location, std::set<map_location>* > easy_access_cache_;
-       };
-
-       class teleportation_map{
-        std::vector< teleport_group > teleport_groups_;
-       };
- */
-
-};
-
-
-
-
-
+};
 
 enum VACANT_TILE_TYPE { VACANT_CASTLE, VACANT_ANY };
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to