MCPcopy Create free account
hub / github.com/EasyRPG/Player / Setup

Method Setup

src/game_map.cpp:153–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void 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

Callers 3

DataInitMethod · 0.80
InitEmptyDBFunction · 0.80
MakeDBActorFunction · 0.80

Calls 10

SetAllowSaveMethod · 0.80
SetAllowEscapeMethod · 0.80
SetAllowTeleportMethod · 0.80
UpdateSaveCountsMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
GetXMethod · 0.45
GetPanXMethod · 0.45
GetYMethod · 0.45
GetPanYMethod · 0.45

Tested by 2

InitEmptyDBFunction · 0.64
MakeDBActorFunction · 0.64