added some more non-45 degree triangle modes
[supertux.git] / src / tile_manager.h
index a72777b..6c2e8cc 100644 (file)
@@ -24,6 +24,9 @@
 #include <set>
 #include <vector>
 #include <string>
+#include <map>
+#include <stdint.h>
+#include <assert.h>
 
 class Tile;
 
@@ -44,9 +47,11 @@ class TileManager
   TileManager();
   ~TileManager();
   
-  std::vector<Tile*> tiles;
+  typedef std::vector<Tile*> Tiles;
+  Tiles tiles;
+
   static TileManager* instance_ ;
-  static std::set<TileGroup>* tilegroups_;
+  std::set<TileGroup> tilegroups;
   void load_tileset(std::string filename);
 
   std::string current_tileset;
@@ -57,27 +62,29 @@ class TileManager
   static void destroy_instance()
   { delete instance_; instance_ = 0; }
 
-  void draw_tile(DrawingContext& context, unsigned int id,
-      const Vector& pos, int layer);
-  
-  static std::set<TileGroup>* tilegroups() { if(!instance_) { instance_ = new TileManager(); } return tilegroups_ ? tilegroups_ : tilegroups_ = new std::set<TileGroup>; }
-
-  unsigned int total_ids()
-    { return tiles.size(); }
-
-  Tile& get(unsigned int id) {
+  const std::set<TileGroup>& get_tilegroups() const
+  {
+    return tilegroups;
+  }
 
-    if(id < tiles.size())
+  const Tile* get(uint32_t id) const
+  {
+    assert(id < tiles.size());
+    Tile* t = tiles[id];
+    if (t) 
       {
-        return *tiles[id]; 
+        return t;
       }
     else
       {
-        // Never return 0, but return the 0th tile instead so that
-        // user code doesn't have to check for NULL pointers all over
-        // the place
-        return *tiles[0]; 
-      } 
+        std::cout << "TileManager: Invalid tile: " << id << std::endl;
+        return tiles[0];
+      }
+  }
+
+  uint32_t get_max_tileid() const
+  {
+    return tiles.size();
   }
 };