Save unlocked doors. (Fix #207)
This commit is contained in:
@@ -1368,6 +1368,7 @@ void cast_town_spell(location where) {
|
|||||||
add_string_to_buf(" Door unlocked.");
|
add_string_to_buf(" Door unlocked.");
|
||||||
play_sound(9);
|
play_sound(9);
|
||||||
univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[ter].flag1;
|
univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[ter].flag1;
|
||||||
|
univ.town->door_unlocked.push_back(where);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
play_sound(41);
|
play_sound(41);
|
||||||
|
@@ -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?
|
// TODO: This means cleared webs reappear, for example. Is that right?
|
||||||
univ.town.place_preset_fields();
|
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;
|
univ.town.belt_present = false;
|
||||||
// Set up map, using stored map
|
// Set up map, using stored map
|
||||||
for(short i = 0; i < univ.town->max_dim; i++)
|
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.");
|
add_string_to_buf(" Door unlocked.");
|
||||||
play_sound(9);
|
play_sound(9);
|
||||||
univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1;
|
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.");
|
add_string_to_buf(" Lock breaks.");
|
||||||
play_sound(9);
|
play_sound(9);
|
||||||
univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1;
|
univ.town->terrain(where.x,where.y) = univ.scenario.ter_types[terrain].flag1;
|
||||||
|
univ.town->door_unlocked.push_back(where);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -544,6 +544,8 @@ void cScenario::writeTo(cTagFile& file) const {
|
|||||||
for(int i = 0; i < towns.size(); i++) {
|
for(int i = 0; i < towns.size(); i++) {
|
||||||
if(towns[i]->item_taken.any())
|
if(towns[i]->item_taken.any())
|
||||||
page["ITEMTAKEN"] << i << towns[i]->item_taken;
|
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)
|
if(towns[i]->can_find)
|
||||||
page["TOWNVISIBLE"] << i;
|
page["TOWNVISIBLE"] << i;
|
||||||
else page["TOWNHIDDEN"] << i;
|
else page["TOWNHIDDEN"] << i;
|
||||||
@@ -554,9 +556,12 @@ void cScenario::writeTo(cTagFile& file) const {
|
|||||||
|
|
||||||
void cScenario::readFrom(const cTagFile& file){
|
void cScenario::readFrom(const cTagFile& file){
|
||||||
std::map<int, boost::dynamic_bitset<>> taken;
|
std::map<int, boost::dynamic_bitset<>> taken;
|
||||||
|
std::map<int, std::vector<location>> unlocked;
|
||||||
std::vector<size_t> visible, hidden, slaughter;
|
std::vector<size_t> visible, hidden, slaughter;
|
||||||
auto& page = file[0];
|
auto& page = file[0];
|
||||||
page["ITEMTAKEN"].extractSparse(taken);
|
page["ITEMTAKEN"].extractSparse(taken);
|
||||||
|
if(page.contains("DOORUNLOCKED"))
|
||||||
|
page["DOORUNLOCKED"].extractSparse(unlocked);
|
||||||
page["TOWNVISIBLE"].extract(visible);
|
page["TOWNVISIBLE"].extract(visible);
|
||||||
page["TOWNHIDDEN"].extract(hidden);
|
page["TOWNHIDDEN"].extract(hidden);
|
||||||
page["TOWNSLAUGHTER"].extractSparse(slaughter);
|
page["TOWNSLAUGHTER"].extractSparse(slaughter);
|
||||||
@@ -565,6 +570,8 @@ void cScenario::readFrom(const cTagFile& file){
|
|||||||
for(size_t i = 0; i < towns.size(); i++) {
|
for(size_t i = 0; i < towns.size(); i++) {
|
||||||
if(taken.find(i) != taken.end()) towns[i]->item_taken = taken[i];
|
if(taken.find(i) != taken.end()) towns[i]->item_taken = taken[i];
|
||||||
else towns[i]->item_taken.clear();
|
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];
|
if(i < slaughter.size()) towns[i]->m_killed = slaughter[i];
|
||||||
else towns[i]->m_killed = 0;
|
else towns[i]->m_killed = 0;
|
||||||
if(std::binary_search(visible.begin(), visible.end(), i)) {
|
if(std::binary_search(visible.begin(), visible.end(), i)) {
|
||||||
|
@@ -101,6 +101,7 @@ private:
|
|||||||
// Persistent data for saved games
|
// Persistent data for saved games
|
||||||
boost::dynamic_bitset<> item_taken;
|
boost::dynamic_bitset<> item_taken;
|
||||||
public:
|
public:
|
||||||
|
std::vector<location> door_unlocked;
|
||||||
bool can_find;
|
bool can_find;
|
||||||
long m_killed = 0;
|
long m_killed = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user