More read/write tests for town and outdoors, including maps/dialogue

Fixes:
- For towns, the "has tavern" flag was not saved or loaded
- Outdoor roads were not saved or loaded
- For outdoor encounters, the "can't flee" and "forced" flags were not loaded, and "forced" was not saved
--> These two flags have also been separated in the code
This commit is contained in:
2015-09-30 17:00:05 -04:00
parent 16a09988f3
commit 43e82281af
26 changed files with 576 additions and 20 deletions

View File

@@ -92,6 +92,7 @@ template<> void ticpp::Printer::PushElement(std::string tagName, cMonster::cAtta
template<> void ticpp::Printer::PushElement(std::string tagName, cOutdoors::cWandering enc, bool) {
OpenElement(tagName);
PushAttribute("can-flee", !enc.cant_flee);
PushAttribute("force", enc.forced);
for(size_t i = 0; i < enc.monst.size(); i++) {
PushElement("monster", enc.monst[i]);
}
@@ -719,6 +720,8 @@ void writeTownToXml(ticpp::Printer&& data, cTown& town) {
data.PushElement("defy-scrying", true);
if(town.is_hidden)
data.PushElement("hidden", true);
if(town.has_tavern)
data.PushElement("tavern", true);
data.CloseElement("flags");
for(int i = 0; i < town.wandering.size(); i++) {
if(town.wandering[i].isNull()) continue;
@@ -849,6 +852,8 @@ map_data buildOutMapData(location which, cScenario& scenario) {
terrain.set(x, y, sector.terrain[x][y]);
if(sector.special_spot[x][y])
terrain.addFeature(x, y, eMapFeature::FIELD, SPECIAL_SPOT);
if(sector.roads[x][y])
terrain.addFeature(x, y, eMapFeature::FIELD, SPECIAL_ROAD);
}
}
for(size_t i = 0; i < sector.special_locs.size(); i++) {

View File

@@ -520,8 +520,8 @@ static void put_out_wand_in_dlog(cDialog& me, short which, const cOutdoors::cWan
// TODO: Wait a second, if 0 is no monster, does that mean it's impossible to use monster 0? Should 1 be subtracted here?
else me[id].setText(scenario.scen_monsters[wand.friendly[i]].m_name);
}
dynamic_cast<cLed&>(me["no-flee"]).setState(wand.cant_flee % 10 == 1 ? led_red : led_off);
dynamic_cast<cLed&>(me["forced"]).setState(wand.cant_flee >= 10 ? led_red : led_off);
dynamic_cast<cLed&>(me["no-flee"]).setState(wand.cant_flee ? led_red : led_off);
dynamic_cast<cLed&>(me["forced"]).setState(wand.forced ? led_red : led_off);
me["onmeet"].setTextToNum(wand.spec_on_meet);
me["onwin"].setTextToNum(wand.spec_on_win);
me["onflee"].setTextToNum(wand.spec_on_flee);
@@ -536,11 +536,8 @@ static void save_out_wand(cDialog& me, short which, cOutdoors::cWandering& wand,
wand.end_spec1 = me["endx"].getTextAsNum();
wand.end_spec2 = me["endy"].getTextAsNum();
wand.cant_flee = 0;
if(dynamic_cast<cLed&>(me["forced"]).getState() != led_off)
wand.cant_flee += 10;
if(dynamic_cast<cLed&>(me["no-flee"]).getState() != led_off)
wand.cant_flee += 1;
wand.forced = dynamic_cast<cLed&>(me["forced"]).getState() != led_off;
wand.cant_flee = dynamic_cast<cLed&>(me["no-flee"]).getState() != led_off;
switch(mode) {
case 0: