diff options
Diffstat (limited to 'src/map.cpp')
| -rw-r--r-- | src/map.cpp | 107 |
1 files changed, 20 insertions, 87 deletions
| diff --git a/src/map.cpp b/src/map.cpp index fa940ef..c4f31d1 100644 --- a/src/map.cpp +++ b/src/map.cpp | |||
| @@ -20,14 +20,7 @@ Map::Map(const Map& map) | |||
| 20 | 20 | ||
| 21 | id = map.id; | 21 | id = map.id; |
| 22 | title = map.title; | 22 | title = map.title; |
| 23 | leftMap = map.leftMap; | 23 | adjacents = map.adjacents; |
| 24 | rightMap = map.rightMap; | ||
| 25 | downMap = map.downMap; | ||
| 26 | upMap = map.upMap; | ||
| 27 | leftType = map.leftType; | ||
| 28 | rightType = map.rightType; | ||
| 29 | upType = map.upType; | ||
| 30 | downType = map.downType; | ||
| 31 | entities = map.entities; | 24 | entities = map.entities; |
| 32 | } | 25 | } |
| 33 | 26 | ||
| @@ -52,14 +45,7 @@ void swap(Map& first, Map& second) | |||
| 52 | { | 45 | { |
| 53 | std::swap(first.mapdata, second.mapdata); | 46 | std::swap(first.mapdata, second.mapdata); |
| 54 | std::swap(first.title, second.title); | 47 | std::swap(first.title, second.title); |
| 55 | std::swap(first.leftMap, second.leftMap); | 48 | std::swap(first.adjacents, second.adjacents); |
| 56 | std::swap(first.rightMap, second.rightMap); | ||
| 57 | std::swap(first.downMap, second.downMap); | ||
| 58 | std::swap(first.upMap, second.upMap); | ||
| 59 | std::swap(first.leftType, second.leftType); | ||
| 60 | std::swap(first.rightType, second.rightType); | ||
| 61 | std::swap(first.upType, second.upType); | ||
| 62 | std::swap(first.downType, second.downType); | ||
| 63 | std::swap(first.id, second.id); | 49 | std::swap(first.id, second.id); |
| 64 | std::swap(first.entities, second.entities); | 50 | std::swap(first.entities, second.entities); |
| 65 | } | 51 | } |
| @@ -109,44 +95,24 @@ Map::MoveType Map::moveTypeForShort(std::string str) | |||
| 109 | return MoveType::Wall; | 95 | return MoveType::Wall; |
| 110 | } | 96 | } |
| 111 | 97 | ||
| 112 | Map::MoveType Map::getLeftMoveType() const | 98 | Map::MoveDir Map::moveDirForShort(std::string str) |
| 113 | { | 99 | { |
| 114 | return leftType; | 100 | if (str == "right") return MoveDir::Right; |
| 115 | } | 101 | if (str == "up") return MoveDir::Up; |
| 116 | 102 | if (str == "down") return MoveDir::Down; | |
| 117 | Map::MoveType Map::getRightMoveType() const | 103 | |
| 118 | { | 104 | return MoveDir::Left; |
| 119 | return rightType; | ||
| 120 | } | ||
| 121 | |||
| 122 | Map::MoveType Map::getUpMoveType() const | ||
| 123 | { | ||
| 124 | return upType; | ||
| 125 | } | ||
| 126 | |||
| 127 | Map::MoveType Map::getDownMoveType() const | ||
| 128 | { | ||
| 129 | return downType; | ||
| 130 | } | ||
| 131 | |||
| 132 | int Map::getLeftMapID() const | ||
| 133 | { | ||
| 134 | return leftMap; | ||
| 135 | } | ||
| 136 | |||
| 137 | int Map::getRightMapID() const | ||
| 138 | { | ||
| 139 | return rightMap; | ||
| 140 | } | ||
| 141 | |||
| 142 | int Map::getUpMapID() const | ||
| 143 | { | ||
| 144 | return upMap; | ||
| 145 | } | 105 | } |
| 146 | 106 | ||
| 147 | int Map::getDownMapID() const | 107 | static const Map::Adjacent defaultAdjacent {}; |
| 108 | const Map::Adjacent& Map::getAdjacent(MoveDir dir) const | ||
| 148 | { | 109 | { |
| 149 | return downMap; | 110 | if (adjacents.count(dir) > 0) |
| 111 | { | ||
| 112 | return adjacents.at(dir); | ||
| 113 | } else { | ||
| 114 | return defaultAdjacent; | ||
| 115 | } | ||
| 150 | } | 116 | } |
| 151 | 117 | ||
| 152 | bool Map::moveTypeTakesMap(MoveType type) | 118 | bool Map::moveTypeTakesMap(MoveType type) |
| @@ -171,44 +137,11 @@ void Map::setTitle(std::string title) | |||
| 171 | this->title = title; | 137 | this->title = title; |
| 172 | } | 138 | } |
| 173 | 139 | ||
| 174 | void Map::setLeftMoveType(MoveType type) | 140 | void Map::setAdjacent(MoveDir dir, MoveType type, int map) |
| 175 | { | ||
| 176 | leftType = type; | ||
| 177 | } | ||
| 178 | |||
| 179 | void Map::setRightMoveType(MoveType type) | ||
| 180 | { | ||
| 181 | rightType = type; | ||
| 182 | } | ||
| 183 | |||
| 184 | void Map::setUpMoveType(MoveType type) | ||
| 185 | { | ||
| 186 | upType = type; | ||
| 187 | } | ||
| 188 | |||
| 189 | void Map::setDownMoveType(MoveType type) | ||
| 190 | { | ||
| 191 | downType = type; | ||
| 192 | } | ||
| 193 | |||
| 194 | void Map::setLeftMapID(int id) | ||
| 195 | { | ||
| 196 | leftMap = id; | ||
| 197 | } | ||
| 198 | |||
| 199 | void Map::setRightMapID(int id) | ||
| 200 | { | ||
| 201 | rightMap = id; | ||
| 202 | } | ||
| 203 | |||
| 204 | void Map::setUpMapID(int id) | ||
| 205 | { | ||
| 206 | upMap = id; | ||
| 207 | } | ||
| 208 | |||
| 209 | void Map::setDownMapID(int id) | ||
| 210 | { | 141 | { |
| 211 | downMap = id; | 142 | Adjacent& cur = adjacents[dir]; |
| 143 | cur.type = type; | ||
| 144 | if (map != -1) cur.map = map; | ||
| 212 | } | 145 | } |
| 213 | 146 | ||
| 214 | void Map::addEntity(EntityData& data) | 147 | void Map::addEntity(EntityData& data) |
