pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.10,1.11 pat


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldmap path_graph.cxx,1.10,1.11 pathfinder.hxx,1.5,1.6
Date: 15 Oct 2002 17:13:01 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv22868/worldmap

Modified Files:
        path_graph.cxx pathfinder.hxx 
Log Message:
- fixed sorting problem with the priority_queue


Index: path_graph.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- path_graph.cxx      15 Oct 2002 15:48:49 -0000      1.10
+++ path_graph.cxx      15 Oct 2002 17:12:59 -0000      1.11
@@ -167,7 +167,7 @@
           }
           
           // FIXME: Memory leak
-          worldmap->add_drawable(new PathDrawable(full_path));
+          //worldmap->add_drawable(new PathDrawable(full_path));
           
           // FIXME: No error checking, 
           EdgeId id1 = graph.add_edge(path, // FIXME: Memory leak!

Index: pathfinder.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/pathfinder.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pathfinder.hxx      15 Oct 2002 15:48:49 -0000      1.5
+++ pathfinder.hxx      15 Oct 2002 17:12:59 -0000      1.6
@@ -49,14 +49,27 @@
   };
 
 private:
+  struct CostComp 
+  {
+    Pathfinder<T, C>& pathfinder;
+    
+    CostComp(Pathfinder<T, C>& p) : pathfinder(p) {}
+
+    bool operator()(NodeId a, NodeId b)
+    {
+      std::cout << "Coast: " << pathfinder.stat_graph[a].cost << " " << 
pathfinder.stat_graph[b].cost << std::endl;
+      return pathfinder.stat_graph[a].cost > pathfinder.stat_graph[b].cost;
+    }
+  };
+
   Graph<T, C>& graph;
   NodeId start;
-  std::priority_queue<NodeId> open_nodes;
+  std::priority_queue<NodeId, std::vector<NodeId>, CostComp> open_nodes;
   std::vector<NodeStat>   stat_graph;
   
 public:
   Pathfinder (Graph<T, C>& g, NodeId s)
-    : graph (g), start (s)
+    : graph (g), start (s), open_nodes(CostComp(*this))
   {
     stat_graph.resize (graph.max_node_handler_value());
     push_to_open (start);





reply via email to

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