diff --git a/src/game/boe.party.cpp b/src/game/boe.party.cpp index a72d0e07..328cc367 100644 --- a/src/game/boe.party.cpp +++ b/src/game/boe.party.cpp @@ -1368,6 +1368,7 @@ void cast_town_spell(location where) { add_string_to_buf(" Door unlocked."); play_sound(9); univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[ter].flag1; + univ.town->door_unlocked.push_back(where); } else { play_sound(41); diff --git a/src/game/boe.town.cpp b/src/game/boe.town.cpp index b8cd73a1..f978fa21 100644 --- a/src/game/boe.town.cpp +++ b/src/game/boe.town.cpp @@ -122,7 +122,14 @@ void start_town_mode(short which_town, short entry_dir, bool debug_enter) { // TODO: This means cleared webs reappear, for example. Is that right? univ.town.place_preset_fields(); - + + for(location unlocked : univ.town->door_unlocked){ + if(is_unlockable(unlocked)){ + ter_num_t terrain = univ.town->terrain(unlocked.x,unlocked.y); + univ.town->terrain(unlocked.x,unlocked.y) = univ.scenario.ter_types[terrain].flag1; + } + } + univ.town.belt_present = false; // Set up map, using stored map for(short i = 0; i < univ.town->max_dim; i++) @@ -1181,6 +1188,7 @@ void pick_lock(location where,short pc_num) { add_string_to_buf(" Door unlocked."); play_sound(9); univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1; + univ.town->door_unlocked.push_back(where); } } @@ -1205,6 +1213,7 @@ void bash_door(location where,short pc_num) { add_string_to_buf(" Lock breaks."); play_sound(9); univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1; + univ.town->door_unlocked.push_back(where); } } diff --git a/src/scenario/scenario.cpp b/src/scenario/scenario.cpp index 884e22ac..78c4b66b 100644 --- a/src/scenario/scenario.cpp +++ b/src/scenario/scenario.cpp @@ -544,6 +544,8 @@ void cScenario::writeTo(cTagFile& file) const { for(int i = 0; i < towns.size(); i++) { if(towns[i]->item_taken.any()) page["ITEMTAKEN"] << i << towns[i]->item_taken; + if(!towns[i]->door_unlocked.empty()) + page["DOORUNLOCKED"] << i << towns[i]->door_unlocked; if(towns[i]->can_find) page["TOWNVISIBLE"] << i; else page["TOWNHIDDEN"] << i; @@ -554,9 +556,12 @@ void cScenario::writeTo(cTagFile& file) const { void cScenario::readFrom(const cTagFile& file){ std::map> taken; + std::map> unlocked; std::vector visible, hidden, slaughter; auto& page = file[0]; page["ITEMTAKEN"].extractSparse(taken); + if(page.contains("DOORUNLOCKED")) + page["DOORUNLOCKED"].extractSparse(unlocked); page["TOWNVISIBLE"].extract(visible); page["TOWNHIDDEN"].extract(hidden); page["TOWNSLAUGHTER"].extractSparse(slaughter); @@ -565,6 +570,8 @@ void cScenario::readFrom(const cTagFile& file){ for(size_t i = 0; i < towns.size(); i++) { if(taken.find(i) != taken.end()) towns[i]->item_taken = taken[i]; else towns[i]->item_taken.clear(); + if(unlocked.find(i) != unlocked.end()) towns[i]->door_unlocked = unlocked[i]; + else towns[i]->door_unlocked.clear(); if(i < slaughter.size()) towns[i]->m_killed = slaughter[i]; else towns[i]->m_killed = 0; if(std::binary_search(visible.begin(), visible.end(), i)) { diff --git a/src/scenario/town.hpp b/src/scenario/town.hpp index 0a34e725..11bd33a8 100644 --- a/src/scenario/town.hpp +++ b/src/scenario/town.hpp @@ -101,6 +101,7 @@ private: // Persistent data for saved games boost::dynamic_bitset<> item_taken; public: + std::vector door_unlocked; bool can_find; long m_killed = 0;