| 151 | } |
| 152 | |
| 153 | void Game_Map::Setup(std::unique_ptr<lcf::rpg::Map> map_in) { |
| 154 | Dispose(); |
| 155 | |
| 156 | map = std::move(map_in); |
| 157 | |
| 158 | SetupCommon(); |
| 159 | |
| 160 | panorama_on_map_init = true; |
| 161 | Parallax::ClearChangedBG(); |
| 162 | |
| 163 | SetEncounterSteps(GetMapInfo().encounter_steps); |
| 164 | SetChipset(map->chipset_id); |
| 165 | |
| 166 | std::iota(map_info.lower_tiles.begin(), map_info.lower_tiles.end(), 0); |
| 167 | std::iota(map_info.upper_tiles.begin(), map_info.upper_tiles.end(), 0); |
| 168 | |
| 169 | // Save allowed |
| 170 | const auto* current_info = &GetMapInfo(); |
| 171 | int current_index = current_info->ID; |
| 172 | int can_save = current_info->save; |
| 173 | int can_escape = current_info->escape; |
| 174 | int can_teleport = current_info->teleport; |
| 175 | |
| 176 | while (can_save == lcf::rpg::MapInfo::TriState_parent |
| 177 | || can_escape == lcf::rpg::MapInfo::TriState_parent |
| 178 | || can_teleport == lcf::rpg::MapInfo::TriState_parent) |
| 179 | { |
| 180 | const auto* parent_info = &GetParentMapInfo(*current_info); |
| 181 | int parent_index = parent_info->ID; |
| 182 | if (parent_index == 0) { |
| 183 | // If parent is 0 and flag is parent, it's implicitly enabled. |
| 184 | break; |
| 185 | } |
| 186 | if (parent_index == current_index) { |
| 187 | Output::Warning("Map {} has parent pointing to itself!", current_index); |
| 188 | break; |
| 189 | } |
| 190 | current_info = parent_info; |
| 191 | if (can_save == lcf::rpg::MapInfo::TriState_parent) { |
| 192 | can_save = current_info->save; |
| 193 | } |
| 194 | if (can_escape == lcf::rpg::MapInfo::TriState_parent) { |
| 195 | can_escape = current_info->escape; |
| 196 | } |
| 197 | if (can_teleport == lcf::rpg::MapInfo::TriState_parent) { |
| 198 | can_teleport = current_info->teleport; |
| 199 | } |
| 200 | } |
| 201 | Main_Data::game_system->SetAllowSave(can_save != lcf::rpg::MapInfo::TriState_forbid); |
| 202 | Main_Data::game_system->SetAllowEscape(can_escape != lcf::rpg::MapInfo::TriState_forbid); |
| 203 | Main_Data::game_system->SetAllowTeleport(can_teleport != lcf::rpg::MapInfo::TriState_forbid); |
| 204 | |
| 205 | auto& player = *Main_Data::game_player; |
| 206 | |
| 207 | SetPositionX(player.GetX() * SCREEN_TILE_SIZE - player.GetPanX()); |
| 208 | SetPositionY(player.GetY() * SCREEN_TILE_SIZE - player.GetPanY()); |
| 209 | |
| 210 | // Update the save counts so that if the player saves the game |