From 87b7dec3f5978893d897e1d61ddaf0e793a33b05 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 6 Feb 2005 22:13:39 +0000 Subject: Added setSize function to Map. --- src/map.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index d2b1590e..a9437f9f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -80,7 +80,7 @@ Tile::Tile(): Map::Map(): - width(200), height(200) + width(0), height(0) { tiles = new Tile[width * height]; } @@ -102,6 +102,8 @@ bool Map::load(char *mapFile) { fread(&oldMap, sizeof(MAP), 1, file); fclose(file); + setSize(OLD_MAP_WIDTH, OLD_MAP_HEIGHT); + // Transfer tile data int x, y; for (y = 0; y < OLD_MAP_HEIGHT; y++) { @@ -134,6 +136,14 @@ bool Map::load(char *mapFile) { return true; } +void Map::setSize(int width, int height) +{ + this->width = width; + this->height = height; + delete[] tiles; + tiles = new Tile[width * height]; +} + void Map::setWalk(int x, int y, bool walkable) { if (walkable) { tiles[x + y * width].flags |= TILE_WALKABLE; -- cgit v1.2.3-70-g09d2