[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/worldmap dot.cxx,1.2,1.3 dot.hxx,1.3,
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/worldmap dot.cxx,1.2,1.3 dot.hxx,1.3,1.4 graph.hxx,1.15,1.16 level_dot.cxx,1.3,1.4 path_drawable.cxx,1.1,1.2 path_drawable.hxx,1.1,1.2 path_graph.cxx,1.5,1.6 path_graph.hxx,1.2,1.3 |
Date: |
13 Oct 2002 19:28:36 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/worldmap
In directory dark:/tmp/cvs-serv13258/worldmap
Modified Files:
dot.cxx dot.hxx graph.hxx level_dot.cxx path_drawable.cxx
path_drawable.hxx path_graph.cxx path_graph.hxx
Log Message:
connections between nodes work now
Index: dot.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/dot.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dot.cxx 13 Oct 2002 13:34:40 -0000 1.2
+++ dot.cxx 13 Oct 2002 19:28:34 -0000 1.3
@@ -27,19 +27,26 @@
{
assert(cur);
+ std::cout << "Dot::Dot: " << cur->name << std::endl;
+
// cur = <dot>...</dot>
cur = cur->children;
cur = XMLhelper::skip_blank(cur);
while (cur)
{
+ std::cout << "cur->name: " << cur->name << std::endl;
+
if (XMLhelper::equal_str(cur->name, "position"))
{
pos = XMLhelper::parse_vector(doc, cur);
}
else if (XMLhelper::equal_str(cur->name, "name"))
{
- XMLhelper::node_list_get_string(doc, cur, 1, name);
+ if (!XMLhelper::node_list_get_string(doc, cur->children, 1, name))
+ {
+ std::cout << "couldn't parse name" << std::endl;
+ }
}
else
{
@@ -49,6 +56,8 @@
cur = cur->next;
cur = XMLhelper::skip_blank(cur);
}
+
+ assert(!name.empty());
}
} // namespace WorldMapNS
Index: dot.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/dot.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dot.hxx 13 Oct 2002 14:19:25 -0000 1.3
+++ dot.hxx 13 Oct 2002 19:28:34 -0000 1.4
@@ -36,7 +36,9 @@
public:
Dot(xmlDocPtr doc, xmlNodePtr cur);
- float get_z_pos() const { return pos.z; }
+
+ Vector get_pos() { return pos; }
+ float get_z_pos() const { return pos.z; }
private:
Dot (const Dot&);
Dot& operator= (const Dot&);
Index: graph.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/graph.hxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- graph.hxx 12 Oct 2002 23:43:20 -0000 1.15
+++ graph.hxx 13 Oct 2002 19:28:34 -0000 1.16
@@ -96,17 +96,21 @@
return NodeId (nodes.size ()-1);
}
- void add_edge (const EdgeType& data, const NodeId& a, const NodeId& b, int
cost)
+ EdgeId add_edge (const EdgeType& data, const NodeId& a, const NodeId& b, int
cost)
{
Edge<EdgeType> new_edge (data, a, b, cost);
edges.push_back (new_edge);
resolve_node (a).next.push_back (edges.size ()-1);
+ return EdgeId (edges.size ()-1);
}
- void add_bi_edge (const EdgeType& data, const NodeId& a, const NodeId& b,
int cost)
+ std::pair<EdgeId, EdgeId>
+ add_bi_edge (const EdgeType& data, const NodeId& a, const NodeId& b, int
cost)
{
- add_edge (data, a, b, cost);
- add_edge (data, b, a, cost);
+ std::pair<EdgeId, EdgeId> ret;
+ ret.first = add_edge (data, a, b, cost);
+ ret.second = add_edge (data, b, a, cost);
+ return ret;
}
void remove_node (const NodeId& node)
Index: level_dot.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/level_dot.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- level_dot.cxx 13 Oct 2002 16:39:17 -0000 1.3
+++ level_dot.cxx 13 Oct 2002 19:28:34 -0000 1.4
@@ -37,7 +37,7 @@
void
LevelDot::draw(GraphicContext& gc)
{
- std::cout << "Drawing level dat: " << pos << std::endl;
+ //std::cout << "Drawing level dat: " << pos << std::endl;
gc.draw (green_dot_sur, pos);
}
Index: path_drawable.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_drawable.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- path_drawable.cxx 13 Oct 2002 16:39:17 -0000 1.1
+++ path_drawable.cxx 13 Oct 2002 19:28:34 -0000 1.2
@@ -17,17 +17,31 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <iostream>
+#include "../graphic_context.hxx"
#include "path_drawable.hxx"
namespace WorldMapNS {
-PathDrawable::PathDrawable(Path* path, NodeId source, NodeId destination)
+PathDrawable::PathDrawable(const Path& arg_path)
+ : path(arg_path)
{
}
void
PathDrawable::draw(GraphicContext& gc)
{
+ Path::iterator prev = path.begin();
+
+ std::cout << "<<<<<< Path start" << std::endl;
+ for(Path::iterator next = prev + 1; next != path.end(); ++next)
+ {
+ std::cout << "Pos: " << *prev << " " << *next << std::endl;
+ gc.draw_line(*prev, *next,
+ 1.0, 1.0, 1.0);
+ prev = next;
+ }
+ std::cout << ">>>>>> Path end" << std::endl;
}
void
Index: path_drawable.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_drawable.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- path_drawable.hxx 13 Oct 2002 16:39:17 -0000 1.1
+++ path_drawable.hxx 13 Oct 2002 19:28:34 -0000 1.2
@@ -30,9 +30,9 @@
class PathDrawable : public Drawable
{
private:
-
+ Path path;
public:
- PathDrawable(Path* path, NodeId source, NodeId destination);
+ PathDrawable(const Path& arg_path);
void draw(GraphicContext& gc);
void update();
Index: path_graph.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- path_graph.cxx 13 Oct 2002 16:39:17 -0000 1.5
+++ path_graph.cxx 13 Oct 2002 19:28:34 -0000 1.6
@@ -75,6 +75,8 @@
{
// add the dot to the pathfinding
NodeId id = graph.add_node(dot);
+
+ std::cout << "Adding to lookup table: " << dot->get_name() <<
std::endl;
node_lookup[dot->get_name()] = id;
// add the dot to the list of drawables
@@ -123,7 +125,7 @@
// FIXME: add path-data parsing here
Path* path = new Path();
- xmlNodePtr child_cur = cur;
+ xmlNodePtr child_cur = XMLhelper::skip_blank(cur->children);
while (child_cur)
{
if (XMLhelper::equal_str(child_cur->name, "position"))
@@ -133,22 +135,28 @@
}
else
{
- std::cout << "12929929" << std::endl;
+ std::cout << "12929929: " << child_cur->name << std::endl;
}
child_cur = child_cur->next;
child_cur = XMLhelper::skip_blank(child_cur);
}
+ Path full_path;
+
+
full_path.push_back(graph.resolve_node(lookup_node(source)).data->get_pos());
+ full_path.insert(full_path.end(), path->begin(), path->end());
+
full_path.push_back(graph.resolve_node(lookup_node(destination)).data->get_pos());
+
// FIXME: Memory leak
- worldmap->add_drawable(new PathDrawable(path,
- node_lookup[source],
- node_lookup[destination]));
+ worldmap->add_drawable(new PathDrawable(full_path));
// FIXME: No error checking,
- graph.add_bi_edge(path, // FIXME: Memory leak!
- node_lookup[source], node_lookup[destination],
- 0 /* costs */);
+ std::pair<EdgeId, EdgeId> id
+ = graph.add_bi_edge(path, // FIXME: Memory leak!
+ lookup_node(source), lookup_node(destination),
+ 0 /* costs */);
+ edge_lookup[name] = id.first;
}
else
{
@@ -171,6 +179,36 @@
// insert pathfinding magic here...
return std::vector<Vector>();
+}
+
+EdgeId
+PathGraph::lookup_edge(const std::string& name)
+{
+ std::map<std::string, EdgeId>::iterator i = edge_lookup.find(name);
+ if (i == edge_lookup.end())
+ {
+ std::cout << "Couldn't find EdgeId for: " << name << std::endl;
+ return 0;
+ }
+ else
+ {
+ return i->second;
+ }
+}
+
+NodeId
+PathGraph::lookup_node(const std::string& name)
+{
+ std::map<std::string, NodeId>::iterator i = node_lookup.find(name);
+ if (i == node_lookup.end())
+ {
+ std::cout << "Couldn't find NodeId for: " << name << std::endl;
+ return 0;
+ }
+ else
+ {
+ return i->second;
+ }
}
} // namespace WorldMapNS
Index: path_graph.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- path_graph.hxx 13 Oct 2002 01:09:18 -0000 1.2
+++ path_graph.hxx 13 Oct 2002 19:28:34 -0000 1.3
@@ -61,6 +61,9 @@
std::vector<Vector> get_path(NodeId start, NodeId end);
private:
+ EdgeId lookup_edge(const std::string& name);
+ NodeId lookup_node(const std::string& name);
+
void parse_nodes(xmlDocPtr doc, xmlNodePtr cur);
void parse_edges(xmlDocPtr doc, xmlNodePtr cur);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/worldmap dot.cxx,1.2,1.3 dot.hxx,1.3,1.4 graph.hxx,1.15,1.16 level_dot.cxx,1.3,1.4 path_drawable.cxx,1.1,1.2 path_drawable.hxx,1.1,1.2 path_graph.cxx,1.5,1.6 path_graph.hxx,1.2,1.3,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/actions angel.cxx,1.13,1.14 angel.hxx,1.12,1.13 basher.cxx,1.20,1.21 basher.hxx,1.13,1.14 blocker.cxx,1.13,1.14 blocker.hxx,1.12,1.13 boarder.cxx,1.11,1.12 boarder.hxx,1.11,1.12 bomber.cxx,1.19,1.20 bomber.hxx,1.14,1.15 bridger.cxx,1.22,1.23 bridger.hxx,1.15,1.16 climber.cxx,1.16,1.17 climber.hxx,1.11,1.12 digger.cxx,1.16,1.17 digger.hxx,1.11,1.12 drown.cxx,1.10,1.11 drown.hxx,1.10,1.11 exiter.cxx,1.10,1.11 exiter.hxx,1.10,1.11 faller.cxx,1.28,1.29 faller.hxx,1.15,1.16 floater.cxx,1.19,1.20 floater.hxx,1.12,1.13 jumper.cxx,1.15,1.16 jumper.hxx,1.10,1.11 laser_kill.cxx,1.11,1.12 laser_kill.hxx,1.11,1.12 miner.cxx,1.14,1.15 miner.hxx,1.10,1.11 rocket_launcher.cxx,1.10,1.11 rocket_launcher.hxx,1.10,1.11 slider.cxx,1.14,1.15 slider.hxx,1.10,1.11 smashed.cxx,1.10,1.11 smashed.hxx,1.11,1.12 splashed.cxx,1.10,1.11 splashed.hxx,1.11,1.12 superman.cxx,1.8,1.9 superman.hxx,1.11,1.12 teleported.cxx,1.9,1.10 teleported.hxx,1.10,1.11 waiter.cxx,1.10,1.11 waiter.hxx,1.10,1.11 walker.cxx,1.27,1.28 walker.hxx,1.10,1.11
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src config_xml.cxx,1.2,1.3 pingu_holder.cxx,1.17,1.18 pingu_info.cxx,1.5,1.6
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/actions angel.cxx,1.13,1.14 angel.hxx,1.12,1.13 basher.cxx,1.20,1.21 basher.hxx,1.13,1.14 blocker.cxx,1.13,1.14 blocker.hxx,1.12,1.13 boarder.cxx,1.11,1.12 boarder.hxx,1.11,1.12 bomber.cxx,1.19,1.20 bomber.hxx,1.14,1.15 bridger.cxx,1.22,1.23 bridger.hxx,1.15,1.16 climber.cxx,1.16,1.17 climber.hxx,1.11,1.12 digger.cxx,1.16,1.17 digger.hxx,1.11,1.12 drown.cxx,1.10,1.11 drown.hxx,1.10,1.11 exiter.cxx,1.10,1.11 exiter.hxx,1.10,1.11 faller.cxx,1.28,1.29 faller.hxx,1.15,1.16 floater.cxx,1.19,1.20 floater.hxx,1.12,1.13 jumper.cxx,1.15,1.16 jumper.hxx,1.10,1.11 laser_kill.cxx,1.11,1.12 laser_kill.hxx,1.11,1.12 miner.cxx,1.14,1.15 miner.hxx,1.10,1.11 rocket_launcher.cxx,1.10,1.11 rocket_launcher.hxx,1.10,1.11 slider.cxx,1.14,1.15 slider.hxx,1.10,1.11 smashed.cxx,1.10,1.11 smashed.hxx,1.11,1.12 splashed.cxx,1.10,1.11 splashed.hxx,1.11,1.12 superman.cxx,1.8,1.9 superman.hxx,1.11,1.12 teleported.cxx,1.9,1.10 teleported.hxx,1.10,1.11 waiter.cxx,1.10,1.11 waiter.hxx,1.10,1.11 walker.cxx,1.27,1.28 walker.hxx,1.10,1.11
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src config_xml.cxx,1.2,1.3 pingu_holder.cxx,1.17,1.18 pingu_info.cxx,1.5,1.6
- Index(es):