Only write out a map event label if there are actually events to write for its section. Otherwise, you end up writing invalid labels to file, such as '0x0'.

This commit is contained in:
Marcus Huderle 2018-02-12 09:21:44 -08:00
parent 0e268f9ede
commit 7594fbf3ed

View file

@ -698,6 +698,7 @@ void Project::saveMapEvents(Map *map) {
QString path = root + QString("/data/maps/events/%1.inc").arg(map->name);
QString text = "";
if (map->events["object"].length() > 0) {
text += QString("%1::\n").arg(map->object_events_label);
for (int i = 0; i < map->events["object"].length(); i++) {
Event *object_event = map->events["object"].value(i);
@ -729,18 +730,22 @@ void Project::saveMapEvents(Map *map) {
text += "\n";
}
text += "\n";
}
if (map->events["warp"].length() > 0) {
text += QString("%1::\n").arg(map->warps_label);
for (Event *warp : map->events["warp"]) {
text += QString("\twarp_def %1").arg(warp->get("x"));
text += QString(", %1").arg(warp->get("y"));
text += QString(", %1").arg(warp->get("elevation"));
text += QString(", %1").arg(warp->get("destination_warp"));
text += QString(", %1").arg(warp->get("destination_map"));
text += QString(", %1").arg(mapNamesToMapConstants[warp->get("destination_map_name")]);
text += "\n";
}
text += "\n";
}
if (map->events["trap"].length() > 0) {
text += QString("%1::\n").arg(map->coord_events_label);
for (Event *coords : map->events["trap"]) {
text += QString("\tcoord_event %1").arg(coords->get("x"));
@ -754,7 +759,9 @@ void Project::saveMapEvents(Map *map) {
text += "\n";
}
text += "\n";
}
if (map->events["sign"].length() + map->events["hidden item"].length() > 0) {
text += QString("%1::\n").arg(map->bg_events_label);
for (Event *sign : map->events["sign"]) {
text += QString("\tbg_event %1").arg(sign->get("x"));
@ -777,6 +784,7 @@ void Project::saveMapEvents(Map *map) {
text += "\n";
}
text += "\n";
}
text += QString("%1::\n").arg(map->events_label);
text += QString("\tmap_events %1, %2, %3, %4\n")