diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-10-04 19:06:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-10-04 19:06:59 +0300 |
commit | b844884ba160f7a0204382cbbce4c98ecae1139b (patch) | |
tree | 6cc2e3a3c539a45563cf0986791817f5f44de3a0 /src/resources | |
parent | 0a731a66a23061f24f83ce093f8d516497c17144 (diff) | |
download | manaverse-b844884ba160f7a0204382cbbce4c98ecae1139b.tar.gz manaverse-b844884ba160f7a0204382cbbce4c98ecae1139b.tar.bz2 manaverse-b844884ba160f7a0204382cbbce4c98ecae1139b.tar.xz manaverse-b844884ba160f7a0204382cbbce4c98ecae1139b.zip |
Move collisiontype into enums directory.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/map/map.h | 12 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 29 |
2 files changed, 21 insertions, 20 deletions
diff --git a/src/resources/map/map.h b/src/resources/map/map.h index 40c0df7c1..a1f8c9f5a 100644 --- a/src/resources/map/map.h +++ b/src/resources/map/map.h @@ -69,18 +69,6 @@ class Map final : public Properties, public MemoryCounter { public: - enum CollisionTypes - { - COLLISION_EMPTY = 0, // no collision - COLLISION_WALL = 1, // full collison - COLLISION_AIR = 2, // air units can walk - COLLISION_WATER = 3, // water units can walk - COLLISION_GROUNDTOP = 4, // no collision (chair, bed, etc) - COLLISION_PLAYER_WALL = 5, // full collision for player - COLLISION_MONSTER_WALL = 6, // full collision for monster - COLLISION_MAX = 7 // count index - }; - /** * Constructor, taking map and tile size as parameters. */ diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index d7e182cac..809e19e1f 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -30,6 +30,7 @@ #include "const/resources/map/map.h" +#include "enums/resources/map/collisiontype.h" #include "enums/resources/map/mapitemtype.h" #include "enums/resources/map/maplayertype.h" @@ -560,29 +561,41 @@ inline static void setTile(Map *const map, { if (map->getVersion() >= 1) { - switch (gid - set->getFirstGid()) + const int collisionId = gid - set->getFirstGid(); + CollisionTypeT type; + if (collisionId < 0 || + collisionId >= CAST_S32(CollisionType::COLLISION_MAX)) { - case Map::COLLISION_EMPTY: + type = CollisionType::COLLISION_EMPTY; + } + else + { + type = static_cast<CollisionTypeT>(collisionId); + } + switch (type) + { + case CollisionType::COLLISION_EMPTY: map->addBlockMask(x, y, BlockType::GROUND); break; - case Map::COLLISION_WALL: + case CollisionType::COLLISION_WALL: map->addBlockMask(x, y, BlockType::WALL); break; - case Map::COLLISION_AIR: + case CollisionType::COLLISION_AIR: map->addBlockMask(x, y, BlockType::AIR); break; - case Map::COLLISION_WATER: + case CollisionType::COLLISION_WATER: map->addBlockMask(x, y, BlockType::WATER); break; - case Map::COLLISION_GROUNDTOP: + case CollisionType::COLLISION_GROUNDTOP: map->addBlockMask(x, y, BlockType::GROUNDTOP); break; - case Map::COLLISION_PLAYER_WALL: + case CollisionType::COLLISION_PLAYER_WALL: map->addBlockMask(x, y, BlockType::PLAYERWALL); break; - case Map::COLLISION_MONSTER_WALL: + case CollisionType::COLLISION_MONSTER_WALL: map->addBlockMask(x, y, BlockType::MONSTERWALL); break; + case CollisionType::COLLISION_MAX: default: break; } |