-
Notifications
You must be signed in to change notification settings - Fork 2.7k
How to delete a map
This article describes the required steps to delete a map from your project. As of writing this is not possible via Porymap (and that's unlikely to change), so you'll need to do it yourself. As an example, we'll delete the map AncientTomb
.
Before beginning, ensure you actually want to delete all the data for this map from your project. If your end goal is simply to remove the map from your game, you can save time by just making it inaccessible (delete any warps or connections to the map). If you'd definitely like to remove it from your project entirely, continue below.
This is the folder in data/maps/
that contains our map's header data, events, and scripts. Before deleting it, you may wish to examine your map's map.json
to make a note of its id
and layout
constants for later. For our example we delete the folder data/maps/AncientTomb
, and we've noted our constants are MAP_ANCIENT_TOMB
and LAYOUT_ANCIENT_TOMB
.
Every map has an entry in data/maps/map_groups.json
to let the game know what group it belongs to and how to generate data for it. We need to remove the entry for our map.
NOTE: The last entry in each map group list must not end with a comma.
"gMapGroup_Dungeons": [
...
"IslandCave",
- "AncientTomb",
"Underwater_Route134",
...
A "layout" is what contains the map blocks and border metatiles for each map. Some of these are shared by multiple maps (for example, every Pokémon Center has the same layout). If another map uses the same layout, then it will have the same layout
constant (LAYOUT_ANCIENT_TOMB
in our example) in its data/maps/<mapname>/map.json
file. If you're deleting a map that shares a layout with another map that you're not deleting, then skip this step.
AncientTomb
's layout LAYOUT_ANCIENT_TOMB
is unique to the map we're deleting, so we can delete the layout data. We delete the folder data/layouts/AncientTomb
, then we go to data/layouts/layouts.json
and delete its layout entry:
...
},
- {
- "id": "LAYOUT_ANCIENT_TOMB",
- "name": "AncientTomb_Layout",
- "width": 17,
- "height": 33,
- "primary_tileset": "gTileset_General",
- "secondary_tileset": "gTileset_Cave",
- "border_filepath": "data/layouts/AncientTomb/border.bin",
- "blockdata_filepath": "data/layouts/AncientTomb/map.bin"
- },
{
...
We deleted (among other things) our map's scripts.inc
file in step 1. We need to tell the game it doesn't exist anymore. In data/event_scripts.s
, remove the .include
for your map's scripts file (if it's a new map you added with Porymap, it will be near the bottom of the file).
NOTE: If any of your map's scripts happened to be referenced in another file, those references will also need to be removed.
...
.include "data/maps/IslandCave/scripts.inc"
- .include "data/maps/AncientTomb/scripts.inc"
.include "data/maps/Underwater_Route134/scripts.inc"
...
The map constant (MAP_ANCIENT_TOMB
) for our deleted map will become invalid. If we did step 3, so will its layout constant (LAYOUT_ANCIENT_TOMB
). We need to remove any uses of these constants throughout our repo. Examples of places they might be used include warps/connections from other maps, as an argument to a script command, or in a map number/group macro in C (e.g. MAP_NUM(ANCIENT_TOMB)
). This step is largely the reason Porymap is unable to delete maps for us.
You can either search for these yourself (e.g. git grep "ANCIENT_TOMB"
), or let the compiler errors when you try to build find them for you. The former is preferable to avoid confusion, but in case you do the latter some example errors are listed below, along with how the usage might be removed. The exact changes will depend on the map you're deleting, and what you want the new behavior to be.
Error:
src/braille_puzzles.c: In function `ShouldDoBrailleRegisteelEffect':
src/braille_puzzles.c:221: `MAP_ANCIENT_TOMB' undeclared (first use in this function)
Fix (in src/braille_puzzles.c
):
bool8 ShouldDoBrailleRegisteelEffect(void)
{
- if (!FlagGet(FLAG_SYS_REGISTEEL_PUZZLE_COMPLETED) && (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ANCIENT_TOMB) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ANCIENT_TOMB)))
- {
- if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25)
- {
- sIsRegisteelPuzzle = TRUE;
- return TRUE;
- }
- }
return FALSE;
}
Error:
data/maps/Route120/events.inc: Assembler messages:
data/maps/Route120/events.inc:52: Error: invalid operands (*UND* and *ABS* sections) for `&'
data/maps/Route120/events.inc:52: Error: invalid operands (*UND* and *ABS* sections) for `>>'
Fix (in data/maps/Route120/map.json
):
"warp_events": [
- {
- "x": 7,
- "y": 55,
- "elevation": 0,
- "dest_map": "MAP_ANCIENT_TOMB",
- "dest_warp_id": "0"
- },
{
There may be other things associated with your old map you'd also like to delete. There may be now-unused tilesets, or location data (see MAPSEC_ANCIENT_TOMB
for our example), or some map-specific code (like the now-pointless Ancient Tomb puzzle), but changing/deleting all of that is up to you.