pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.101,1.102 col_map.cxx,1


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src Makefile.am,1.101,1.102 col_map.cxx,1.9,1.10 col_map.hxx,1.7,1.8 config.hxx,1.4,1.5 spot_map.cxx,1.16,1.17 spot_map.hxx,1.6,1.7 xml_plf.cxx,1.20,1.21 plf_parser.cxx,1.4,NONE plf_parser.hxx,1.4,NONE plf_preview.cxx,1.2,NONE plf_preview.hxx,1.5,NONE
Date: 17 Sep 2002 16:23:32 -0000

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

Modified Files:
        Makefile.am col_map.cxx col_map.hxx config.hxx spot_map.cxx 
        spot_map.hxx xml_plf.cxx 
Removed Files:
        plf_parser.cxx plf_parser.hxx plf_preview.cxx plf_preview.hxx 
Log Message:
- fixed crash bug in the infobox
- removed lots of obsolete cruft from the spotmap
- old-style groundpieces should be handled correctly now (not much tested, so 
handle with care)

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/Makefile.am,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- Makefile.am 16 Sep 2002 20:31:09 -0000      1.101
+++ Makefile.am 17 Sep 2002 16:23:30 -0000      1.102
@@ -259,12 +259,6 @@
 playfield_view.hxx \
 plf.cxx \
 plf.hxx \
-plf_parser.cxx \
-plf_parser.hxx \
-plf_preview.cxx \
-plf_preview.hxx \
-plt_parser.cxx \
-plt_parser.hxx \
 plt_xml.cxx \
 plt_xml.hxx \
 prefab.cxx \

Index: col_map.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/col_map.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- col_map.cxx 16 Sep 2002 20:31:09 -0000      1.9
+++ col_map.cxx 17 Sep 2002 16:23:30 -0000      1.10
@@ -29,26 +29,21 @@
 #include <config.h>
 #include "my_gettext.hxx"
 
-ColMap::ColMap() 
-  : init(false)
-{
-}
-
 // Obtain the colmap from a memory area
-ColMap::ColMap(unsigned char* b, int w, int h)
+ColMap::ColMap(int w, int h)
+  : width(w),
+    height(h),
+    colmap(new unsigned char[width * height])
 {
-  init = true;
-  colmap = b;
-  width = w;
-  height = h;
 }
 
 ColMap::~ColMap()
 {
-  std::cout << "ColMap:~ColMap" << std::endl;
+  //std::cout << "ColMap:~ColMap" << std::endl;
   delete[] colmap;
 }
 
+#if 0
 int
 ColMap::load(ResDescriptor desc)
 {
@@ -90,12 +85,11 @@
   
   return 0; // never reached
 }
+#endif
 
 int
 ColMap::getpixel(int x, int y)
 {
-  assert(init);
-
   if (x >= 0 && x < width && y >= 0 && y < height) {
     return colmap[x+y*width];
   } else {
@@ -207,6 +201,7 @@
     }
 }
 
+#if 0
 int
 ColMap::load(unsigned char* b, int w, int h)
 {
@@ -223,7 +218,7 @@
       return 0;
     }
 }
-
+#endif
 bool
 ColMap::blit_allowed (int x, int y,  Groundtype::GPType gtype)
 {

Index: col_map.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/col_map.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- col_map.hxx 16 Sep 2002 20:31:09 -0000      1.7
+++ col_map.hxx 17 Sep 2002 16:23:30 -0000      1.8
@@ -35,31 +35,25 @@
 class ColMap
 {
 private:
-  /// A array of uchar, each uchar represents a pixel on the map.
-  unsigned char* colmap;
-
-  /// The width of the collision map.
+  /** The width of the collision map. */
   int    width;
 
-  /// The height of the collision map.
+  /** The height of the collision map. */
   int   height;
-
-  ///
-  bool    init;
   
-public:
-  /// Default constructor, it does nothing
-  ColMap();
+  /** A array of uchar, each uchar represents a pixel on the map. */
+  unsigned char* colmap;
 
+public:
   /** Init the colmap from a given area of memory.
       The memory will be deleted in the destructor. */
-  ColMap(unsigned char* b, int w, int h);
+  ColMap(int w, int h);
 
   /** delete[] the uchar array used for the colmap */
   ~ColMap();
 
   /** Returns the raw uchar array used for the inner representation of
-      the colmap. */
+      the colmap. This is used by the smallmap to create the radar  */
   unsigned char* get_data();
 
   /** Returns the height of the collision map. */
@@ -67,11 +61,6 @@
 
   /** Returns the height of the collision map. */
   int get_width();
-
-  ///
-  int  load(unsigned char*, int w, int h);
-
-  int  load(ResDescriptor desc);
 
   int  getpixel(int x, int y);
   

Index: config.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/config.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- config.hxx  23 Aug 2002 15:49:48 -0000      1.4
+++ config.hxx  17 Sep 2002 16:23:30 -0000      1.5
@@ -60,7 +60,7 @@
   ConfigParser(std::string);         /// Open the file and parse it
   virtual ~ConfigParser();      /// Close the file
     
-  void init(std::string);      /// Init the PLFParser and start parsing
+  void init(std::string);
   
 private:
   ConfigParser (const ConfigParser&);

Index: spot_map.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/spot_map.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- spot_map.cxx        17 Sep 2002 01:03:59 -0000      1.16
+++ spot_map.cxx        17 Sep 2002 16:23:30 -0000      1.17
@@ -104,53 +104,17 @@
 
 PingusSpotMap::PingusSpotMap(PLF* plf)
 {
-  colmap = 0;
-  load(plf);
-#ifndef NEW_GROUNDPIECES
-  gen_tiles();
-#endif
-}
-
-PingusSpotMap::~PingusSpotMap(void)
-{
-  std::cout << "PingusSpotMap:~PingusSpotMap" << std::endl;
-  std::cout << "Trying to delete the map..." << std::flush;
-
-  delete map_canvas;
-  delete colmap;
-
-  std::cout << "finished" << std::endl;
-}
-
-void
-PingusSpotMap::gen_tiles(void)
-{
-  Timer timer;
-
-  timer.start();
-
-  if (verbose) std::cout << "PingusSpotMap: Generating Tiles..." << std::flush;
-
-  if (verbose > 1) 
-    {
-      std::cout << "PingusSpotMap_TilewWidth: " << width / tile_size << 
std::endl;
-      std::cout << "PingusSpotMap_TilewHeight: " << height / tile_size << 
std::endl;
-    }  
-  
-   create_maptiles();
-
-  if (verbose) std::cout << " done " << timer.stop() << std::endl;    
-}
-
-void
-PingusSpotMap::load(PLF* plf)
-{
   width  = plf->get_width();
   height = plf->get_height();
 
+  colmap = new ColMap(width, height);
+
   // Checking that the map has the correct size, only multiples of
   // tile_size are allowed, anything else wouldn't fit very well on
   // the colmap
+
+  // FIXME: This is dirty cruft, the engine should be able to handle
+  // FIXME: all world_sizes and simply display the tiles partly
   if ((width % tile_size) != 0) 
     {
       std::cout << "Warrning: Width is not a multible of " << tile_size << 
std::endl;
@@ -169,67 +133,11 @@
   tile.resize(width/tile_size);
   for(TileIter i=0; i < tile.size(); ++i) 
     tile[i].resize(height/tile_size);
-  
-  surfaces = plf->get_groundpieces();
-
-#ifndef NEW_GROUNDPIECES
-  for (vector<GroundpieceData>::iterator i = surfaces.begin();
-       i != surfaces.end();
-       ++i) // WIN32BUG
-    {
-      i->surface = PingusResource::load_surface(i->desc);
-    }
-  create_map();
-#endif
-
 }
 
-void
-PingusSpotMap::create_map()
+PingusSpotMap::~PingusSpotMap(void)
 {
-  // Allocating the map provider
-  map_canvas = new CL_Canvas(width, height);
-  
-  // Is clearing the canvas really needed, or am I just work around
-  // another bug...?
-  Blitter::clear_canvas(map_canvas);
-  
-  // Drawing all surfaces to the provider
-  for(std::vector<GroundpieceData>::iterator i = surfaces.begin(); 
-      i != surfaces.end(); 
-      ++i)
-    {
-      mark_tiles_not_empty((int) i->pos.x, (int) i->pos.y,
-                          i->surface.get_width(), i->surface.get_height());
-      // test cause png
-      if (i->surface.get_provider()->get_depth() == 8)
-       {
-         if (i->gptype == Groundtype::GP_REMOVE)
-           {
-             Blitter::put_alpha_surface(map_canvas, i->surface.get_provider (),
-                                        (int) i->pos.x, (int) i->pos.y);
-           }
-         else
-           {
-             mark_tiles_not_empty((int) i->pos.x, (int) i->pos.y,
-                                  i->surface.get_width(), 
i->surface.get_height());
-             // FIXME: Replace this with a ClanLib built in
-             //i->surface->put_target(i->pos.x_pos, i->pos.y_pos, 0, 
map_canvas);
-             Blitter::put_surface(map_canvas, i->surface,
-                                  (int) i->pos.x, (int) i->pos.y);
-             }
-       }
-      else
-       {
-         Blitter::put_surface(map_canvas, i->surface,
-                              (int) i->pos.x, (int) i->pos.y);
-         //i->surface->put_target(i->pos.x_pos, i->pos.y_pos, 0, map_canvas);
-       }
-    }
-
-  // Generate the map surface
-  map_surface = CL_Surface (map_canvas);
-  //  std::cout << " done " << timer.stop() << std::endl;
+  delete colmap;
 }
 
 void
@@ -246,7 +154,7 @@
   //<< " w: " << w << " h: " << h << " s: " << s << std::endl;
   
 #if 0
-  { // calculate number of tiles
+  { // calculate number of used/empty tiles
     int tiles_total = 0;
     int tiles_empty = 0;
     int tiles_used  = 0;
@@ -514,104 +422,7 @@
 ColMap*
 PingusSpotMap::get_colmap(void)
 {
-  Timer timer;
-
-  if (colmap) 
-    {
-      return colmap;
-    } 
-  else 
-    {
-      if (verbose) {
-       std::cout << "PingusSpotMap: Starting ColMap creation..." << std::endl;
-      }
-      unsigned char* buffer;
-      
-      // Allocate the space for the colmap buffer
-      // But don't delete it, since the ColMap will do that.
-      buffer = new unsigned char[width * height];
-      
-      if (verbose) {
-       timer.start();
-       std::cout << "PingusSpotMap: Clearing ColMap buffer..." << std::flush;
-      }
-      for(int i=0; i < width * height; ++i) 
-       {
-         buffer[i] = Groundtype::GP_NOTHING;
-       }
-      
-      if (verbose) std::cout << "done " << timer.stop() << std::endl;
-
-      // Create a empty ColMap
-      colmap = new ColMap(buffer, width, height);
-      
-      if (verbose) {
-       timer.start();
-       std::cout << "PingusSpotMap: Generating Colision Map..." << std::flush;
-      }
-
-#ifndef NEW_GROUNDPIECES
-      for(std::vector<GroundpieceData>::iterator i2 = surfaces.begin();
-         i2 != surfaces.end(); 
-         i2++) 
-       {
-         if (i2->gptype == Groundtype::GP_REMOVE)
-           colmap->remove(i2->surface.get_provider (), (int) i2->pos.x, (int) 
i2->pos.y);
-         else
-           colmap->put(i2->surface, (int) i2->pos.x, (int) i2->pos.y, 
i2->gptype);
-       }
-#endif      
-      if (verbose)
-       std::cout << "done " << timer.stop() << std::endl;
-      
-      return colmap;
-    }
-}
-
-CL_Surface
-PingusSpotMap::get_surface(void)
-{
-  std::cout << "PingusSpotMap::get_surface() not supported" << std::endl;
-  return map_surface;
-}
-
-void
-PingusSpotMap::create_maptiles()
-{
-  CL_Canvas* canvas;
-
-  for(TileIter x=0; x < tile.size(); ++x) 
-    {
-      for(TileIter y=0; y < tile[x].size(); ++y) 
-       {
-         if (!tile[x][y].is_empty())
-           {
-             canvas = new CL_Canvas(tile_size, tile_size);
-             Blitter::clear_canvas(canvas);
-             //map_surface->put_target(-x * tile_size, -y * tile_size, 0, 
canvas);
-             Blitter::put_surface(canvas, map_surface, -x * tile_size, -y * 
tile_size);
-             tile[x][y].surface = CL_Surface (canvas, true);
-           }
-       }
-    }
-}
-
-void
-PingusSpotMap::mark_tiles_not_empty(int x_pos, int y_pos, int sur_width, int 
sur_height)
-{
-       int start_x = Math::max(0, x_pos / tile_size);
-       int start_y = Math::max(0, y_pos / tile_size);
-  int stop_x  = Math::min(width / tile_size,  (x_pos + sur_width - 1) / 
tile_size + 1);
-  int stop_y  = Math::min(height / tile_size, (y_pos + sur_height - 1) / 
tile_size + 1);
-
-  //cout << "X: " << start_x << " Y: " << start_y << endl;
-  //cout << "stop_X: " << stop_x << " stop_Y: " << stop_y << endl;
-
-  for(int y = start_y; y < stop_y; ++y) {
-    for(int x = start_x; x < stop_x; ++x) {
-      tile[x][y].set_empty(false);
-    }
-  }
+  return colmap;
 }
 
 /* EOF */

Index: spot_map.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/spot_map.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- spot_map.hxx        16 Sep 2002 20:31:09 -0000      1.6
+++ spot_map.hxx        17 Sep 2002 16:23:30 -0000      1.7
@@ -61,15 +61,12 @@
 
   typedef std::vector<MapTileSurface>::size_type TileIter;
 
-  std::vector<WorldObjsData::GroundpieceData> surfaces;
-
-  CL_Canvas* provider;
-  CL_Surface map_surface;
-  CL_Canvas* map_canvas;
-
+  /** The tiles out of which the map is constructed */
   std::vector<std::vector<MapTileSurface> > tile;
 
+  /** Width of the map */
   int width;
+  /** Height of the map */
   int height;
 
 public:
@@ -78,25 +75,26 @@
 
   void draw(GraphicContext& gc);
 
-  void generate_colmap();
   ColMap* get_colmap();
-  void load(PLF* plf);
-  void gen_tiles();
 
-  int  get_height(void);
-  int  get_width(void);
-  CL_Surface get_surface(void);
-  void remove(CL_SurfaceProvider*, int, int);
-  void put_alpha_surface(CL_Canvas* provider, CL_SurfaceProvider* sprovider,
-                        int x, int y, int real_x, int real_y);
-  void put(CL_SurfaceProvider*, int, int);
-  void create_maptiles();
-  void create_map();
-  void mark_tiles_not_empty(int, int, int, int);
+  int  get_height();
+  int  get_width();
+  
+  /** Put the gives surface provider onto the given coordinates */
+  void put(CL_SurfaceProvider*, int x, int y);
+
+  /** Remove the gives surface provider onto the given coordinates
+      (everything non-transparent is removed from the map) */
+  void remove(CL_SurfaceProvider*, int x, int y);
 
   float get_z_pos () const { return 0; }
   
 private:
+  /** Low level version of the remove() call, acts on a single canvas
+      instead on the complete map-tiles */
+  void put_alpha_surface(CL_Canvas* provider, CL_SurfaceProvider* sprovider,
+                        int x, int y, int real_x, int real_y);
+
   /** Draw the collision map onto the screen */
   void draw_colmap(GraphicContext& gc);
 

Index: xml_plf.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/xml_plf.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- xml_plf.cxx 17 Sep 2002 01:03:59 -0000      1.20
+++ xml_plf.cxx 17 Sep 2002 16:23:30 -0000      1.21
@@ -111,9 +111,13 @@
            }
          else if (XMLhelper::equal_str(cur->name, "groundpiece"))
            {
-#ifdef NEW_GROUNDPIECES
+#ifndef OLD_GROUNDPIECES
              // FIXME: This is *not* backward compatible and wreck the levels
-             worldobjs_data.push_back(WorldObjDataFactory::instance()->create 
(doc, cur));
+             // 
worldobjs_data.push_back(WorldObjDataFactory::instance()->create (doc, cur));
+
+             // This probally is backward compatible
+             //groundpieces.push_back(WorldObjsData::GroundpieceData (doc, 
cur));
+             worldobjs_data.push_back(new WorldObjsData::GroundpieceData (doc, 
cur));
 #else
              parse_groundpiece(cur);
 #endif

--- plf_parser.cxx DELETED ---

--- plf_parser.hxx DELETED ---

--- plf_preview.cxx DELETED ---

--- plf_preview.hxx DELETED ---





reply via email to

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