summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-10-04 19:06:59 +0300
committerAndrei Karas <akaras@inbox.ru>2016-10-04 19:06:59 +0300
commitb844884ba160f7a0204382cbbce4c98ecae1139b (patch)
tree6cc2e3a3c539a45563cf0986791817f5f44de3a0 /src
parent0a731a66a23061f24f83ce093f8d516497c17144 (diff)
downloadmv-b844884ba160f7a0204382cbbce4c98ecae1139b.tar.gz
mv-b844884ba160f7a0204382cbbce4c98ecae1139b.tar.bz2
mv-b844884ba160f7a0204382cbbce4c98ecae1139b.tar.xz
mv-b844884ba160f7a0204382cbbce4c98ecae1139b.zip
Move collisiontype into enums directory.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/enums/resources/map/collisiontype.h41
-rw-r--r--src/resources/map/map.h12
-rw-r--r--src/resources/mapreader.cpp29
5 files changed, 64 insertions, 20 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3e83dd3fd..74e4150ab 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1091,6 +1091,7 @@ SET(SRCS
maingui.h
enums/resources/map/blockmask.h
enums/resources/map/blocktype.h
+ enums/resources/map/collisiontype.h
enums/resources/skill/casttype.h
resources/map/location.h
resources/map/map.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 3fab04574..1e61acaa4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1327,6 +1327,7 @@ manaplus_SOURCES += main.cpp \
resources/updatefile.h \
enums/resources/map/blockmask.h \
enums/resources/map/blocktype.h \
+ enums/resources/map/collisiontype.h \
enums/resources/skill/casttype.h \
resources/map/location.h \
resources/map/map.cpp \
diff --git a/src/enums/resources/map/collisiontype.h b/src/enums/resources/map/collisiontype.h
new file mode 100644
index 000000000..7f52ff003
--- /dev/null
+++ b/src/enums/resources/map/collisiontype.h
@@ -0,0 +1,41 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2016 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ENUMS_RESOURCES_MAP_COLLISIONTYPE_H
+#define ENUMS_RESOURCES_MAP_COLLISIONTYPE_H
+
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(CollisionType)
+{
+ 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
+}
+enumEnd(CollisionType);
+
+#endif // ENUMS_RESOURCES_MAP_COLLISIONTYPE_H
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;
}