diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-29 23:59:08 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-09-29 23:59:08 +0000 |
commit | e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3 (patch) | |
tree | e8dc775e12f6b4eb0a6d56448f05286c774bbb8a /src/map.cpp | |
parent | 0e8c09433f3a193b5a94a1ad572d8237113cdfbf (diff) | |
download | mana-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.tar.gz mana-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.tar.bz2 mana-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.tar.xz mana-e8f94fe7ca5e7e7838eaa84f1792b4b42b4bada3.zip |
Merged trunk changes from revision 2618 to 2716 into the 0.1.0 branch.
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/map.cpp b/src/map.cpp index 5063a754..3ccaafc0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -63,8 +63,11 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mOnClosedList(1), mOnOpenList(2), mLastScrollX(0.0f), mLastScrollY(0.0f) { - mMetaTiles = new MetaTile[mWidth * mHeight]; - mTiles = new Image*[mWidth * mHeight * 3]; + int size = mWidth * mHeight; + + mMetaTiles = new MetaTile[size]; + mTiles = new Image*[size * 3]; + std::fill_n(mTiles, size * 3, (Image*)0); } Map::~Map() @@ -86,12 +89,17 @@ Map::~Map() void Map::setSize(int width, int height) { - mWidth = width; - mHeight = height; delete[] mMetaTiles; delete[] mTiles; - mMetaTiles = new MetaTile[mWidth * mHeight]; - mTiles = new Image*[mWidth * mHeight * 3]; + + mWidth = width; + mHeight = height; + + int size = width * height; + + mMetaTiles = new MetaTile[size]; + mTiles = new Image*[size * 3]; + std::fill_n(mTiles, size * 3, (Image*)0); } void @@ -330,8 +338,8 @@ Map::getWalk(int x, int y) /* // Check for collision with a being - Beings *beings = beingManager->getAll(); - for (BeingIterator i = beings->begin(); i != beings->end(); i++) { + Beings &beings = beingManager->getAll(); + for (BeingIterator i = beings.begin(); i != beings.end(); i++) { // job 45 is a portal, they don't collide if ((*i)->mX / 32 == x && (*i)->mY / 32 == y && (*i)->mJob != 45) { return false; |