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 dot.cxx,NONE,1.1 dot.hxx,NON


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/worldmap dot.cxx,NONE,1.1 dot.hxx,NONE,1.1 level_dot.cxx,NONE,1.1 level_dot.hxx,NONE,1.1 Makefile.am,1.6,1.7 dot_factory.cxx,1.2,1.3 drawable.hxx,1.1,1.2 path_graph.cxx,1.1,1.2 path_graph.hxx,1.1,1.2 worldmap.cxx,1.16,1.17 worldmap.hxx,1.15,1.16
Date: 13 Oct 2002 01:09:20 -0000

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

Modified Files:
        Makefile.am dot_factory.cxx drawable.hxx path_graph.cxx 
        path_graph.hxx worldmap.cxx worldmap.hxx 
Added Files:
        dot.cxx dot.hxx level_dot.cxx level_dot.hxx 
Log Message:
- started with the worldmap rewirte, worldmap is now broken and will not work 
for the next few days

--- NEW FILE: dot.cxx ---
//  $Id: dot.cxx,v 1.1 2002/10/13 01:09:18 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#include "dot.hxx"

namespace WorldMapNS {

Dot::Dot(xmlDocPtr doc, xmlNodePtr cur)
  : Drawable("bla")
{
  
}

std::string
Dot::get_name()
{
  return name;
}

} // namespace WorldMapNS

/* EOF */

--- NEW FILE: dot.hxx ---
//  $Id: dot.hxx,v 1.1 2002/10/13 01:09:18 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_PINGUS_DOT_HXX
#define HEADER_PINGUS_DOT_HXX

#include <string>
#include "../libxmlfwd.hxx"
#include "drawable.hxx"

namespace WorldMapNS {

/** A Dot is a node between all the pathes on the worldmap, there are
    LevelDots TubeDots and other availabe. */
class Dot : public Drawable
{
private:
  std::string name;
public:
  Dot(xmlDocPtr doc, xmlNodePtr cur);

  std::string get_name();
private:
  Dot (const Dot&);
  Dot& operator= (const Dot&);
};

} // namespace WorldMapNS

#endif

/* EOF */

--- NEW FILE: level_dot.cxx ---
//  $Id: level_dot.cxx,v 1.1 2002/10/13 01:09:18 grumbel Exp $
//
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  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 "../xml_helper.hxx"
#include "level_dot.hxx"

namespace WorldMapNS {

LevelDot::LevelDot(xmlDocPtr doc, xmlNodePtr cur)
  : Dot(doc, XMLhelper::skip_blank(cur->children))
{
}

void
LevelDot::draw(GraphicContext& gc)
{
  std::cout << "Drawing level dat" << std::endl;
}

void
LevelDot::update()
{
}

} // namespace WorldMapNS

/* EOF */

--- NEW FILE: level_dot.hxx ---
//  $Id: level_dot.hxx,v 1.1 2002/10/13 01:09:18 grumbel Exp $
// 
//  Pingus - A free Lemmings clone
//  Copyright (C) 2002 Ingo Ruhnke <address@hidden>
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_PINGUS_WORLDMAP_LEVEL_DOT_HXX
#define HEADER_PINGUS_WORLDMAP_LEVEL_DOT_HXX

#include "dot.hxx"

namespace WorldMapNS {

/** */
class LevelDot : public Dot
{
private:
public:
  LevelDot(xmlDocPtr doc, xmlNodePtr cur);

  void draw(GraphicContext& gc);
  void update();

private:
  LevelDot (const LevelDot&);
  LevelDot& operator= (const LevelDot&);
};

} // namespace WorldMapNS

#endif

/* EOF */

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Makefile.am 12 Oct 2002 23:43:20 -0000      1.6
+++ Makefile.am 13 Oct 2002 01:09:18 -0000      1.7
@@ -29,7 +29,9 @@
 surface_drawable.hxx surface_drawable.cxx \
 drawable_factory.hxx drawable_factory.cxx \
 path_graph.hxx path_graph.cxx \
-dot_factory.hxx dot_factory.cxx
+dot_factory.hxx dot_factory.cxx \
+dot.hxx dot.cxx \
+level_dot.hxx level_dot.cxx
 
 #node.cxx
 #node.hxx

Index: dot_factory.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/dot_factory.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- dot_factory.cxx     12 Oct 2002 23:43:20 -0000      1.2
+++ dot_factory.cxx     13 Oct 2002 01:09:18 -0000      1.3
@@ -19,6 +19,7 @@
 
 #include "../pingus_error.hxx"
 #include "../xml_helper.hxx"
+#include "level_dot.hxx"
 #include "dot_factory.hxx"
 
 namespace WorldMapNS {
@@ -36,9 +37,10 @@
     }
   else
     {
-      PingusError::raise("DotFactory: unknown tag: ");
+      //PingusError::raise("DotFactory: unknown tag: ");
     }
-  return 0;
+
+  return new LevelDot(doc, cur);
 }
 
 } // namespace WorldMapNS

Index: drawable.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/drawable.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- drawable.hxx        12 Oct 2002 23:37:23 -0000      1.1
+++ drawable.hxx        13 Oct 2002 01:09:18 -0000      1.2
@@ -49,7 +49,7 @@
   Drawable(xmlDocPtr doc, xmlNodePtr cur) 
     : visible(true)
   {
-    if (!XMLhelper::get_prop (cur, "id", name))
+    if (!XMLhelper::get_prop (cur, "name", name))
       {
         PingusError::raise("Drawable: Couldn't get name of object");
       }

Index: path_graph.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- path_graph.cxx      12 Oct 2002 23:34:43 -0000      1.1
+++ path_graph.cxx      13 Oct 2002 01:09:18 -0000      1.2
@@ -17,15 +17,21 @@
 //  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 "../xml_helper.hxx"
 #include "../pingus_error.hxx"
+#include "dot.hxx"
 #include "dot_factory.hxx"
+#include "worldmap.hxx"
 #include "path_graph.hxx"
 
 namespace WorldMapNS {
 
-PathGraph::PathGraph(WorldMap* worldmap, xmlDocPtr doc, xmlNodePtr cur)
+PathGraph::PathGraph(WorldMap* arg_worldmap, xmlDocPtr doc, xmlNodePtr cur)
+  : worldmap(arg_worldmap)
 {
+  std::cout << "PathGraph::PathGraph(WorldMap* arg_worldmap, xmlDocPtr doc, 
xmlNodePtr cur)" << std::endl;
+
   // cur is at <graph>...
   cur = cur->children;
   cur = XMLhelper::skip_blank(cur);
@@ -34,27 +40,62 @@
     {
       if (XMLhelper::equal_str(cur->name, "nodes"))
         {
-
+          parse_nodes(doc, cur);
         }
       else if (XMLhelper::equal_str(cur->name, "edges"))
         {
-          
+          parse_edges(doc, cur);
+        }
+      else
+        {
+          std::cout << "PathGraph: Can't parse: " << cur->name << std::endl;
         }
+
+      cur = cur->next;
+      cur = XMLhelper::skip_blank(cur);
     }
 }
 
 void
 PathGraph::parse_nodes(xmlDocPtr doc, xmlNodePtr cur)
 {
+  cur = cur->children;
+  cur = XMLhelper::skip_blank(cur);
+
+  std::cout << "PathGraph::parse_nodes(xmlDocPtr doc, xmlNodePtr cur)" << 
std::endl;
+  
   while (cur)
     {
-      DotFactory::create(doc, cur);
+      std::cout << "parsing nodes" << std::endl;
+
+      Dot* dot = DotFactory::create(doc, cur);
+      if (dot)
+        {
+          // add the dot to the pathfinding
+          NodeId id = graph.add_node(dot);
+          node_lookup[dot->get_name()] = id;
+
+          // add the dot to the list of drawables
+          worldmap->add_drawable(dot);
+        }
+      else
+        {
+          std::cout << "PathGraph: Couldn't create node" << std::endl;
+        }
+
+      cur = cur->next;
+      cur = XMLhelper::skip_blank(cur);
     }  
 }
 
 void
 PathGraph::parse_edges(xmlDocPtr doc, xmlNodePtr cur)
 {
+  cur = cur->children;
+  cur = XMLhelper::skip_blank(cur);
+
+  std::cout << "PathGraph::parse_edges(xmlDocPtr doc, xmlNodePtr cur)" << 
std::endl;
+
   while (cur)
     {
       if (XMLhelper::equal_str(cur->name, "edge"))
@@ -63,7 +104,7 @@
           std::string source;
           std::string destination;
 
-          if (!XMLhelper::get_prop(cur, "id", name))
+          if (!XMLhelper::get_prop(cur, "name", name))
             {
               PingusError::raise("PathGraph: Missing Edge Name");
             }
@@ -80,8 +121,9 @@
 
           // FIXME: add path-data parsing here
 
-          // FIXME: No error checking
-          graph.add_bi_edge((Path*)0, node_lookup[source], 
node_lookup[destination], 
+          // FIXME: No error checking, 
+          graph.add_bi_edge(new Path(), // FIXME: Memory leak!
+                            node_lookup[source], node_lookup[destination], 
                             0 /* costs */);
         }
       else

Index: path_graph.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/path_graph.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- path_graph.hxx      12 Oct 2002 23:34:43 -0000      1.1
+++ path_graph.hxx      13 Oct 2002 01:09:18 -0000      1.2
@@ -38,6 +38,8 @@
 class PathGraph
 {
 private:
+  WorldMap* worldmap;
+
   // FIXME: Memory leak? Where do we free stuff data inside the graph?
   Graph<Dot*, Path*> graph;
 

Index: worldmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- worldmap.cxx        12 Oct 2002 23:34:43 -0000      1.16
+++ worldmap.cxx        13 Oct 2002 01:09:18 -0000      1.17
@@ -116,7 +116,7 @@
         }
       else
         {
-          std::cout << "Parse Error" << std::endl;
+          std::cout << "WorldMap::parse_objects: Parse Error" << std::endl;
         }
       
       cur = cur->next;
@@ -127,9 +127,6 @@
 void
 WorldMap::parse_graph(xmlDocPtr doc, xmlNodePtr cur)
 {
-  cur = cur->children;
-  cur = XMLhelper::skip_blank(cur);
-  
   path_graph = new PathGraph(this, doc, cur);
 }
 
@@ -158,6 +155,18 @@
     {
       (*i)->update ();
     }
+}
+
+void
+WorldMap::add_drawable(Drawable* drawable)
+{
+  drawables.push_back(drawable);
+}
+
+void
+WorldMap::remove_drawable(Drawable* drawable)
+{
+  
 }
 
 void

Index: worldmap.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/worldmap/worldmap.hxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- worldmap.hxx        12 Oct 2002 23:34:43 -0000      1.15
+++ worldmap.hxx        13 Oct 2002 01:09:18 -0000      1.16
@@ -72,6 +72,10 @@
   
   /** The the pingu to the given Node */
   void set_pingus(NodeId id);
+  
+  /** FIXME: Memory leak?! */
+  void add_drawable(Drawable* drawable);
+  void remove_drawable(Drawable* drawable);
 
   /** @return the shortest path between node1 and node2  */
   std::vector<EdgeId> find_path (NodeId node1, NodeId node2);





reply via email to

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