From fc607f09216470a3ac761b8e9c50f7dcb40eccfe Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Sat, 18 Sep 2004 12:13:09 +0000 Subject: [PATCH] Contrib worldmaps are now being saved. TODO: a slot based saving might be neat. SVN-Revision: 1946 --- src/title.cpp | 16 ++++++++++++++-- src/worldmap.cpp | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/title.cpp b/src/title.cpp index 305466768..77b00a99f 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -189,8 +189,20 @@ void check_levels_contrib_menu() std::set::iterator it = worldmap_list.begin(); for(int i = index - contrib_subsets.size(); i > 0; --i) ++it; - worldmap.loadmap((*it)); - worldmap.display(); + + std::string map_filename = *it; + + worldmap.loadmap(map_filename); + + // hack to erase the extension + unsigned int ext_pos = it->find_last_of("."); + if(ext_pos != std::string::npos) + map_filename.erase(ext_pos, map_filename.size() - ext_pos); + + // TODO: slots should be available for contrib maps + worldmap.loadgame(st_save_dir + "/" + map_filename + "-slot1.stsg"); + + worldmap.display(); // run the map Menu::set_current(main_menu); } diff --git a/src/worldmap.cpp b/src/worldmap.cpp index e682d80ba..714375ae5 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -1254,7 +1254,6 @@ WorldMap::loadgame(const std::string& filename) { std::cout << "loadgame: " << filename << std::endl; savegame_file = filename; - map_filename = "icyisland.stwm"; if (access(filename.c_str(), F_OK) != 0) { @@ -1282,8 +1281,10 @@ WorldMap::loadgame(const std::string& filename) LispReader reader(cur); /* Get the Map filename and then load it before setting special_tile settings */ + std::string cur_map_filename = map_filename; reader.read_string("map", map_filename); - load_map(); + if(cur_map_filename != map_filename) + load_map(); reader.read_int("lives", player_status.lives); reader.read_int("distros", player_status.distros); -- 2.11.0