diff --git a/src/boe.actions.cpp b/src/boe.actions.cpp index 4a9b0e7a..4b7aa97b 100644 --- a/src/boe.actions.cpp +++ b/src/boe.actions.cpp @@ -396,12 +396,12 @@ static void handle_pause(bool& did_something, bool& need_redraw) { } } else { // The above could leave you stranded in a single-tile passable area, so pausing again should re-enter the boat. - int boat = univ.party.boats.size(); - if(overall_mode == MODE_OUTDOORS && (boat = out_boat_there(univ.party.out_loc)) < univ.party.boats.size()) - univ.party.in_boat = boat; - else if(overall_mode == MODE_TOWN && (boat = town_boat_there(univ.party.town_loc)) < univ.party.boats.size()) - univ.party.in_boat = boat; - if(boat < univ.party.boats.size()) + cVehicle* boat = nullptr; + if(overall_mode == MODE_OUTDOORS && (boat = out_boat_there(univ.party.out_loc))) + univ.party.in_boat = boat - &univ.party.boats[0]; + else if(overall_mode == MODE_TOWN && (boat = town_boat_there(univ.party.town_loc))) + univ.party.in_boat = boat - &univ.party.boats[0]; + if(boat) ASB("You board the boat."); } put_pc_screen(); @@ -2788,7 +2788,6 @@ static void run_waterfalls(short mode){ // mode 0 - town, 1 - outdoors } bool outd_move_party(location destination,bool forced) { - short boat_num,horse_num; location real_dest, sector_p_in; bool keep_going = true,check_f; location store_corner,store_iwc; @@ -2866,7 +2865,7 @@ bool outd_move_party(location destination,bool forced) { univ.party.in_boat = -1; } else if(((real_dest.x != univ.party.out_loc.x) && (real_dest.y != univ.party.out_loc.y)) - || (!forced && (out_boat_there(destination) < 30))) + || (!forced && out_boat_there(destination))) return false; else if(!outd_is_blocked(real_dest) && univ.scenario.ter_types[ter].boat_over @@ -2886,14 +2885,15 @@ bool outd_move_party(location destination,bool forced) { univ.party.direction = set_direction(univ.party.out_loc, destination); std::string dir_str = dir_string[univ.party.direction]; - if(((boat_num = out_boat_there(real_dest)) < 30) && (univ.party.in_boat < 0) && (univ.party.in_horse < 0)) { + cVehicle* enter; + if((enter = out_boat_there(real_dest)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) { if(flying()) { add_string_to_buf("You land first."); univ.party.status[ePartyStatus::FLIGHT] = 0; } give_help(61,0); add_string_to_buf("Move: You board the boat."); - univ.party.in_boat = boat_num; + univ.party.in_boat = enter - &univ.party.boats[0]; univ.party.out_loc = real_dest; univ.party.i_w_c.x = (univ.party.out_loc.x > 48) ? 1 : 0; @@ -2906,7 +2906,7 @@ bool outd_move_party(location destination,bool forced) { return true; } - else if(((horse_num = out_horse_there(real_dest)) < 30) && (univ.party.in_boat < 0) && (univ.party.in_horse < 0)) { + else if((enter = out_horse_there(real_dest)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) { if(flying()) { add_string_to_buf("Land before mounting horses."); return false; @@ -2915,7 +2915,7 @@ bool outd_move_party(location destination,bool forced) { give_help(60,0); add_string_to_buf("Move: You mount the horses."); play_sound(84); - univ.party.in_horse = horse_num; + univ.party.in_horse = enter - &univ.party.horses[0]; univ.party.out_loc = real_dest; univ.party.i_w_c.x = (univ.party.out_loc.x > 48) ? 1 : 0; @@ -2984,7 +2984,6 @@ bool outd_move_party(location destination,bool forced) { bool town_move_party(location destination,short forced) { bool keep_going = true; - short boat_there,horse_there; ter_num_t ter; bool check_f = false; @@ -3023,7 +3022,7 @@ bool town_move_party(location destination,short forced) { } } // boat in destination - else if(town_boat_there(destination) < 30) { + else if(town_boat_there(destination)) { add_string_to_buf(" Boat there already."); return false; } @@ -3034,29 +3033,30 @@ bool town_move_party(location destination,short forced) { univ.party.direction = set_direction(univ.party.town_loc, destination); std::string dir_str = dir_string[univ.party.direction]; - if(((boat_there = town_boat_there(destination)) < 30) && (univ.party.in_boat < 0)) { - if(univ.party.boats[boat_there].property) { + cVehicle* there; + if((there = town_boat_there(destination)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) { + if(there->property) { add_string_to_buf(" Not your boat."); return false; } give_help(61,0); add_string_to_buf("Move: You board the boat."); - univ.party.in_boat = boat_there; + univ.party.in_boat = there - &univ.party.boats[0]; univ.party.town_loc = destination; center = univ.party.town_loc; return true; } - else if(((horse_there = town_horse_there(destination)) < 30) && (univ.party.in_horse < 0)) { - if(univ.party.horses[horse_there].property) { + else if((there = town_horse_there(destination)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) { + if(there->property) { add_string_to_buf(" Not your horses."); return false; } give_help(60,0); add_string_to_buf("Move: You mount the horses."); play_sound(84); - univ.party.in_horse = horse_there; + univ.party.in_horse = there - &univ.party.horses[0]; univ.party.town_loc = destination; center = univ.party.town_loc; diff --git a/src/boe.specials.cpp b/src/boe.specials.cpp index eda373da..d2cf8e81 100644 --- a/src/boe.specials.cpp +++ b/src/boe.specials.cpp @@ -227,7 +227,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, } // TODO: Just verify that yes, it works with this and doesn't work without it. - if(mode == eSpecCtx::COMBAT_MOVE && town_boat_there(where_check) < 3) { + if(mode == eSpecCtx::COMBAT_MOVE && town_boat_there(where_check)) { add_string_to_buf("Blocked: Can't enter boats in combat"); can_enter = false; } @@ -304,9 +304,9 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, // if the party is flying, in a boat, or entering a boat, they cannot be harmed by terrain if(flying() || univ.party.in_boat >= 0) break; - if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check) < 30) + if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check)) break; - if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check) < 30) + if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check)) break; if(ter_flag3 > 0 && ter_flag3 < 8) dam_type = (eDamageType) ter_flag3; @@ -363,9 +363,9 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc, // if the party is flying, in a boat, or entering a boat, they cannot be harmed by terrain if(flying() || univ.party.in_boat >= 0) break; - if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check) < 30) + if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check)) break; - if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check) < 30) + if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check)) break; //one_sound(17); for(short i = mode == eSpecCtx::COMBAT_MOVE ? univ.get_target_i(which_pc) : 0 ; i < 6; i++) diff --git a/src/boe.text.cpp b/src/boe.text.cpp index 32f356da..c823a290 100644 --- a/src/boe.text.cpp +++ b/src/boe.text.cpp @@ -743,9 +743,9 @@ short do_look(location space) { if(univ.out->roads[space.x][space.y]) add_string_to_buf(" Road"); - if(out_boat_there(space) < 30) + if(out_boat_there(space)) add_string_to_buf(" Boat"); - if(out_horse_there(space) < 30) + if(out_horse_there(space)) add_string_to_buf(" Horse"); if(univ.out->special_spot[space.x][space.y]) add_string_to_buf(" Special Encounter"); @@ -754,9 +754,9 @@ short do_look(location space) { if((overall_mode == MODE_LOOK_TOWN) || (overall_mode == MODE_LOOK_COMBAT)) { if(univ.town.is_road(space.x,space.y)) add_string_to_buf(" Track"); - if(town_boat_there(space) < 30) + if(town_boat_there(space)) add_string_to_buf(" Boat"); - if(town_horse_there(space) < 30) + if(town_horse_there(space)) add_string_to_buf(" Horse"); if(univ.town.is_web(space.x,space.y)) @@ -844,36 +844,36 @@ short do_look(location space) { return print_terrain(space); } -short town_boat_there(location where) { +cVehicle* town_boat_there(location where) { for(short i = 0; i < univ.party.boats.size(); i++) if(univ.party.boats[i].exists && univ.party.boats[i].which_town == univ.party.town_num && (where == univ.party.boats[i].loc)) - return i; - return univ.party.boats.size(); + return &univ.party.boats[i]; + return nullptr; } -short out_boat_there(location where) { +cVehicle* out_boat_there(location where) { where = global_to_local(where); for(short i = 0; i < univ.party.boats.size(); i++) if((univ.party.boats[i].exists) && (where == univ.party.boats[i].loc) && (univ.party.boats[i].which_town == 200)) - return i; - return univ.party.boats.size(); + return &univ.party.boats[i]; + return nullptr; } -short town_horse_there(location where) { +cVehicle* town_horse_there(location where) { for(short i = 0; i < univ.party.horses.size(); i++) if(univ.party.horses[i].exists && univ.party.horses[i].which_town == univ.party.town_num && (where == univ.party.horses[i].loc)) - return i; - return univ.party.horses.size(); + return &univ.party.horses[i]; + return nullptr; } -short out_horse_there(location where) { +cVehicle* out_horse_there(location where) { where = global_to_local(where); for(short i = 0; i < univ.party.horses.size(); i++) if((univ.party.horses[i].exists) && (where == univ.party.horses[i].loc) && (univ.party.horses[i].which_town == 200)) - return i; - return univ.party.horses.size(); + return &univ.party.horses[i]; + return nullptr; } void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) { std::string msg; diff --git a/src/boe.text.hpp b/src/boe.text.hpp index 7590d1d5..0db1bc5f 100644 --- a/src/boe.text.hpp +++ b/src/boe.text.hpp @@ -1,5 +1,7 @@ #include +class cVehicle; + void put_pc_screen(); void place_buy_button(short position,short pc_num,short item_num); void put_item_screen(short screen_num); @@ -12,10 +14,10 @@ short total_encumbrance(short pc_num); void draw_pc_effects(short pc); void print_party_stats() ; short do_look(location space); -short town_boat_there(location where); -short out_boat_there(location where); -short town_horse_there(location where); -short out_horse_there(location where); +cVehicle* town_boat_there(location where); +cVehicle* out_boat_there(location where); +cVehicle* town_horse_there(location where); +cVehicle* out_horse_there(location where); void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) ; std::string get_m_name(mon_num_t num); std::string get_ter_name(ter_num_t num); diff --git a/src/classes/creature.cpp b/src/classes/creature.cpp index dfbd803e..01f583d1 100644 --- a/src/classes/creature.cpp +++ b/src/classes/creature.cpp @@ -18,11 +18,8 @@ const short cCreature::charm_odds[21] = {90,90,85,80,78, 75,73,60,40,30, 20,10,4,1,0, 0,0,0,0,0, 0}; cCreature::cCreature() { - active = 0; attitude = eAttitude::DOCILE; cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80; - summon_time = 0; - target = 6; } cCreature::cCreature(int num) : cCreature() { diff --git a/src/classes/creature.hpp b/src/classes/creature.hpp index e15ba385..a361e1df 100644 --- a/src/classes/creature.hpp +++ b/src/classes/creature.hpp @@ -18,17 +18,17 @@ class cCreature : public cMonster, public cTownperson, public iLiving { public: static const short charm_odds[21]; - short active; + short active = 0; eAttitude attitude; location cur_loc; - short summon_time; + short summon_time = 0; bool party_summoned; - short target; + short target = 6; location targ_loc; - short health; - short mp; - short max_mp; - short morale,m_morale; // these are calculated in-game based on the level + short health = 0; + short mp = 0; + short max_mp = 0; + short morale = 0,m_morale = 0; // these are calculated in-game based on the level cCreature(); cCreature(int num); diff --git a/src/classes/universe.cpp b/src/classes/universe.cpp index 4970ac86..86f28daa 100644 --- a/src/classes/universe.cpp +++ b/src/classes/universe.cpp @@ -42,6 +42,7 @@ void cCurTown::import_legacy(legacy::big_tr_type& old){ for(short i = 0; i < record()->max_dim; i++) for(short j = 0; j < record()->max_dim; j++) record()->terrain(i,j) = old.terrain[i][j]; + record()->area_desc.resize(16); for(short i = 0; i < 16; i++){ record()->area_desc[i].top = old.room_rect[i].top; record()->area_desc[i].left = old.room_rect[i].left; diff --git a/src/tools/fileio_scen.cpp b/src/tools/fileio_scen.cpp index 9c44b55f..10a99659 100644 --- a/src/tools/fileio_scen.cpp +++ b/src/tools/fileio_scen.cpp @@ -1896,6 +1896,7 @@ void loadOutMapData(map_data&& data, location which, cScenario& scen) { case eMapFeature::BOAT: is_boat = true; case eMapFeature::HORSE: + (is_boat ? scen.boats : scen.horses).resize(abs(feat.second)); what = &(is_boat ? scen.boats : scen.horses)[abs(feat.second) - 1]; what->which_town = 200; what->sector = which; @@ -1943,6 +1944,7 @@ void loadTownMapData(map_data&& data, int which, cScenario& scen) { case eMapFeature::BOAT: is_boat = true; case eMapFeature::HORSE: + (is_boat ? scen.boats : scen.horses).resize(abs(feat.second)); what = &(is_boat ? scen.boats : scen.horses)[abs(feat.second) - 1]; what->which_town = which; what->loc = loc(x,y); diff --git a/test/catch.cpp b/test/catch.cpp index 612d2f78..c4ebda42 100644 --- a/test/catch.cpp +++ b/test/catch.cpp @@ -4,9 +4,11 @@ // After this are some globals that are referenced from common code but not defined, and not used in the test cases #include "graphtool.hpp" +#include "universe.hpp" sf::RenderWindow mainPtr; std::string scenario_temp_dir_name = "test_scenario"; cCustomGraphics spec_scen_g; +cUniverse univ; // And these are referenced from the scenario code, though not used in test cases #include "scenario.hpp" diff --git a/test/item_legacy.cpp b/test/item_legacy.cpp index a6e7a0c3..fad8ba29 100644 --- a/test/item_legacy.cpp +++ b/test/item_legacy.cpp @@ -28,7 +28,7 @@ TEST_CASE("Converting items from legacy scenarios") { cItem new_item; SECTION("Basic info") { - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::ARROW); CHECK(new_item.item_level == 7); CHECK(new_item.awkward == 2); @@ -56,7 +56,7 @@ TEST_CASE("Converting items from legacy scenarios") { set_item_name(old_item, "Test Sword", "Sword"); old_item.variety = 2; old_item.type = 1; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::TWO_HANDED); CHECK(new_item.weap_type == eSkill::EDGED_WEAPONS); CHECK(new_item.full_name == "Test Sword"); @@ -66,7 +66,7 @@ TEST_CASE("Converting items from legacy scenarios") { set_item_name(old_item, "Test Mace", "Mace"); old_item.variety = 1; old_item.type = 2; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::ONE_HANDED); CHECK(new_item.weap_type == eSkill::BASHING_WEAPONS); CHECK(new_item.full_name == "Test Mace"); @@ -76,7 +76,7 @@ TEST_CASE("Converting items from legacy scenarios") { set_item_name(old_item, "Test Spear", "Spear"); old_item.variety = 2; old_item.type = 3; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::TWO_HANDED); CHECK(new_item.weap_type == eSkill::POLE_WEAPONS); CHECK(new_item.full_name == "Test Spear"); @@ -85,7 +85,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Bow") { set_item_name(old_item, "Test Bow", "Bow"); old_item.variety = 4; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::BOW); CHECK(new_item.weap_type == eSkill::ARCHERY); CHECK(new_item.full_name == "Test Bow"); @@ -94,7 +94,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Crossbow") { set_item_name(old_item, "Test Crossbow", "Crossbow"); old_item.variety = 23; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::CROSSBOW); CHECK(new_item.weap_type == eSkill::ARCHERY); CHECK(new_item.full_name == "Test Crossbow"); @@ -103,7 +103,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Sling") { set_item_name(old_item, "Test Sling", "Sling"); old_item.variety = 25; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::MISSILE_NO_AMMO); CHECK(new_item.weap_type == eSkill::ARCHERY); CHECK(new_item.missile == 12); @@ -113,31 +113,31 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Arrows") { set_item_name(old_item, "Test Arrows", "Arrows"); old_item.variety = 5; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::ARROW); CHECK(new_item.missile == 4); CHECK(new_item.full_name == "Test Arrows"); CHECK(new_item.name == "Arrows"); old_item.item_properties = 0; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.missile == 3); } SECTION("Bolts") { set_item_name(old_item, "Test Bolts", "Bolts"); old_item.variety = 24; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::BOLTS); CHECK(new_item.missile == 4); CHECK(new_item.full_name == "Test Bolts"); CHECK(new_item.name == "Bolts"); old_item.item_properties = 0; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.missile == 3); } SECTION("Darts") { set_item_name(old_item, "Test Darts", "Darts"); old_item.variety = 6; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::THROWN_MISSILE); CHECK(new_item.weap_type == eSkill::THROWN_MISSILES); CHECK(new_item.missile == 1); @@ -147,7 +147,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Knives") { set_item_name(old_item, "Test Knives", "Knives"); old_item.variety = 6; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::THROWN_MISSILE); CHECK(new_item.weap_type == eSkill::THROWN_MISSILES); CHECK(new_item.missile == 10); @@ -157,7 +157,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Javelins") { set_item_name(old_item, "Test Javelins", "Javelins"); old_item.variety = 6; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::THROWN_MISSILE); CHECK(new_item.weap_type == eSkill::THROWN_MISSILES); CHECK(new_item.missile == 5); @@ -167,7 +167,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Razordisks") { set_item_name(old_item, "Test Razordisks", "Razordisks"); old_item.variety = 6; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::THROWN_MISSILE); CHECK(new_item.weap_type == eSkill::THROWN_MISSILES); CHECK(new_item.missile == 7); @@ -177,7 +177,7 @@ TEST_CASE("Converting items from legacy scenarios") { SECTION("Rocks") { set_item_name(old_item, "Test Rocks", "Rocks"); old_item.variety = 6; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.variety == eItemType::THROWN_MISSILE); CHECK(new_item.weap_type == eSkill::THROWN_MISSILES); CHECK(new_item.missile == 12); @@ -192,94 +192,94 @@ TEST_CASE("Converting items from legacy scenarios") { // Weapon abilities SECTION("Flaming Weapon") { old_item.ability = 1; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGING_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eDamageType::UNBLOCKABLE)); } SECTION("Demon Slayer") { old_item.ability = 2; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::DEMON)); } SECTION("Undead Slayer") { old_item.ability = 3; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::UNDEAD)); } SECTION("Lizard Slayer") { old_item.ability = 4; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::REPTILE)); } SECTION("Giant Slayer") { old_item.ability = 5; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::GIANT)); } SECTION("Mage Slayer") { old_item.ability = 6; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::MAGE)); } SECTION("Priest Slayer") { old_item.ability = 7; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::PRIEST)); } SECTION("Bug Slayer") { old_item.ability = 8; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eRace::BUG)); } SECTION("Acidic Weapon") { old_item.ability = 9; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::STATUS_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::ACID)); } SECTION("Soulsucker") { old_item.ability = 10; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SOULSUCKER); CHECK(new_item.abil_data[0] == 120); } SECTION("Drain Missiles") { old_item.ability = 11; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DRAIN_MISSILES); CHECK(new_item.abil_data[0] == 120); } SECTION("Weak Weapon") { old_item.ability = 12; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::WEAK_WEAPON); CHECK(new_item.abil_data[0] == 120); } SECTION("Causes Fear") { old_item.ability = 13; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAUSES_FEAR); CHECK(new_item.abil_data[0] == 120); } SECTION("Poisoned Weapon") { old_item.ability = 14; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::STATUS_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::POISON)); @@ -288,62 +288,62 @@ TEST_CASE("Converting items from legacy scenarios") { // Inherent abilities SECTION("Protection") { old_item.ability = 30; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGE_PROTECTION); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eDamageType::WEAPON)); } SECTION("Full Protection") { old_item.ability = 31; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::FULL_PROTECTION); CHECK(new_item.abil_data[0] == 120); } SECTION("Fire Protection") { old_item.ability = 32; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGE_PROTECTION); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eDamageType::FIRE)); } SECTION("Cold Protection") { old_item.ability = 33; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGE_PROTECTION); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eDamageType::COLD)); } SECTION("Poison Protection") { old_item.ability = 34; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::STATUS_PROTECTION); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::POISON)); } SECTION("Magic Protection") { old_item.ability = 35; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGE_PROTECTION); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eDamageType::MAGIC)); } SECTION("Acid Protection") { old_item.ability = 36; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::STATUS_PROTECTION); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::ACID)); } SECTION("Skill") { old_item.ability = 37; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SKILL); CHECK(new_item.abil_data[0] == 7); CHECK(new_item.abil_data[1] == 120); } SECTION("Strength") { old_item.ability = 38; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::BOOST_STAT); CHECK(new_item.abil_data[0] == 1); CHECK(new_item.abil_data[1] == int(eSkill::STRENGTH)); @@ -351,7 +351,7 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Dexterity") { old_item.ability = 39; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::BOOST_STAT); CHECK(new_item.abil_data[0] == 1); CHECK(new_item.abil_data[1] == int(eSkill::DEXTERITY)); @@ -359,7 +359,7 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Intelligence") { old_item.ability = 40; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::BOOST_STAT); CHECK(new_item.abil_data[0] == 1); CHECK(new_item.abil_data[1] == int(eSkill::INTELLIGENCE)); @@ -367,38 +367,38 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Accuracy") { old_item.ability = 41; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::ACCURACY); CHECK(new_item.abil_data[0] == 120); } SECTION("Thieving") { old_item.ability = 42; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::THIEVING); CHECK(new_item.abil_data[0] == 120); } SECTION("Giant Strength") { old_item.ability = 43; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::GIANT_STRENGTH); CHECK(new_item.abil_data[0] == 7); CHECK(new_item.abil_data[1] == 120); } SECTION("Lighter Object") { old_item.ability = 44; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::LIGHTER_OBJECT); CHECK(new_item.abil_data[0] == 120); } SECTION("Heavier Object") { old_item.ability = 45; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::HEAVIER_OBJECT); CHECK(new_item.abil_data[0] == 120); } SECTION("Occasional Bless") { old_item.ability = 46; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::OCCASIONAL_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::BLESS_CURSE)); @@ -406,7 +406,7 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Occasional Haste") { old_item.ability = 47; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::OCCASIONAL_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::HASTE_SLOW)); @@ -414,31 +414,31 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Life Saving") { old_item.ability = 48; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::LIFE_SAVING); CHECK(new_item.abil_data[0] == 120); } SECTION("Protect from Petrify") { old_item.ability = 49; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::PROTECT_FROM_PETRIFY); CHECK(new_item.abil_data[0] == 120); } SECTION("Regenerate") { old_item.ability = 50; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::REGENERATE); CHECK(new_item.abil_data[0] == 120); } SECTION("Poison Augment") { old_item.ability = 51; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::POISON_AUGMENT); CHECK(new_item.abil_data[0] == 120); } SECTION("Disease Party") { old_item.ability = 52; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::OCCASIONAL_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::DISEASE)); @@ -446,66 +446,66 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Will") { old_item.ability = 53; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::WILL); CHECK(new_item.abil_data[0] == 120); } SECTION("Free Action") { old_item.ability = 54; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::FREE_ACTION); CHECK(new_item.abil_data[0] == 120); } SECTION("Speed") { old_item.ability = 55; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SPEED); CHECK(new_item.abil_data[0] == 18); } SECTION("Slow Wearer") { old_item.ability = 56; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLOW_WEARER); CHECK(new_item.abil_data[0] == 24); } SECTION("Protection from Undead") { old_item.ability = 57; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGE_PROTECTION); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eDamageType::UNDEAD)); } SECTION("Protection from Demons") { old_item.ability = 58; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGE_PROTECTION); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eDamageType::DEMON)); } SECTION("Protection from Humanoids") { old_item.ability = 59; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::PROTECT_FROM_SPECIES); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eRace::HUMANOID)); } SECTION("Protection from Reptiles") { old_item.ability = 60; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::PROTECT_FROM_SPECIES); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eRace::REPTILE)); } SECTION("Protection from Giants") { old_item.ability = 61; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::PROTECT_FROM_SPECIES); CHECK(new_item.abil_data[0] == 60); CHECK(new_item.abil_data[1] == int(eRace::GIANT)); } SECTION("Protection from Disease") { old_item.ability = 62; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::STATUS_PROTECTION); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::DISEASE)); @@ -514,149 +514,149 @@ TEST_CASE("Converting items from legacy scenarios") { // Non-spell usable abilities SECTION("Poison Weapon") { old_item.ability = 70; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::POISON_WEAPON); CHECK(new_item.abil_data[0] == 120); } SECTION("Curse/Bless User") { old_item.ability = 71; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::BLESS_CURSE)); } SECTION("Cure/Cause Poison") { old_item.ability = 72; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::POISON)); } SECTION("Speed/Slow User") { old_item.ability = 73; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::HASTE_SLOW)); } SECTION("Add/Lose Invulnerability") { old_item.ability = 74; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::INVULNERABLE)); } SECTION("Add/Lose Magic Resistance") { old_item.ability = 75; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::MAGIC_RESISTANCE)); } SECTION("Add/Lose Web") { old_item.ability = 76; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::WEBS)); } SECTION("Cure/Cause Disease") { old_item.ability = 77; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::DISEASE)); } SECTION("Add/Lose Sanctuary") { old_item.ability = 78; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::INVISIBLE)); } SECTION("Cure/Cause Dumbfounding") { old_item.ability = 79; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::DUMB)); } SECTION("Add/Lose Martyr's Shield") { old_item.ability = 80; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::MARTYRS_SHIELD)); } SECTION("Cure/Cause Sleep") { old_item.ability = 81; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::ASLEEP)); } SECTION("Cure/Cause Paralysis") { old_item.ability = 82; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::PARALYZED)); } SECTION("Cure/Cause Acid") { old_item.ability = 83; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eStatus::ACID)); } SECTION("Bliss") { old_item.ability = 84; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::BLISS_DOOM); CHECK(new_item.abil_data[0] == 120); CHECK_FALSE(new_item.abil_harms()); } SECTION("Add/Lose Experience") { old_item.ability = 85; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_EXPERIENCE); CHECK(new_item.abil_data[0] == 120); } SECTION("Add/Lose Skill Points") { old_item.ability = 86; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_SKILL_POINTS); CHECK(new_item.abil_data[0] == 120); } SECTION("Add/Lose Health") { old_item.ability = 87; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_HEALTH); CHECK(new_item.abil_data[0] == 120); } SECTION("Add/Lose Spell Points") { old_item.ability = 88; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_SPELL_POINTS); CHECK(new_item.abil_data[0] == 120); } SECTION("Doom") { old_item.ability = 89; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::BLISS_DOOM); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_harms()); } SECTION("Light") { old_item.ability = 90; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::LIGHT); CHECK(new_item.abil_data[0] == 120); CHECK_FALSE(new_item.abil_harms()); } SECTION("Stealth") { old_item.ability = 91; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_PARTY_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(ePartyStatus::STEALTH)); @@ -664,7 +664,7 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Firewalk") { old_item.ability = 92; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_PARTY_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(ePartyStatus::FIREWALK)); @@ -672,7 +672,7 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Flying") { old_item.ability = 93; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::AFFECT_PARTY_STATUS); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(ePartyStatus::FLIGHT)); @@ -680,7 +680,7 @@ TEST_CASE("Converting items from legacy scenarios") { } SECTION("Major Healing") { old_item.ability = 94; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::HEALTH_POISON); CHECK(new_item.abil_data[0] == 120); CHECK_FALSE(new_item.abil_harms()); @@ -689,181 +689,181 @@ TEST_CASE("Converting items from legacy scenarios") { // Spell usable abilities SECTION("Flame") { old_item.ability = 110; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::FLAME)); } SECTION("Fireball") { old_item.ability = 111; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::FIREBALL)); } SECTION("Firestorem") { old_item.ability = 112; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::FIRESTORM)); } SECTION("Kill") { old_item.ability = 113; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::KILL)); } SECTION("Ice Bolt") { old_item.ability = 114; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::ICE_BOLT)); } SECTION("Slow") { old_item.ability = 115; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::SLOW)); } SECTION("Shockwave") { old_item.ability = 116; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::SHOCKWAVE)); } SECTION("Dispel Undead") { old_item.ability = 117; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::DISPEL_UNDEAD)); } SECTION("Dispel Spirit") { old_item.ability = 118; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::RAVAGE_SPIRIT)); } SECTION("Summoning") { old_item.ability = 119; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SUMMONING); CHECK(new_item.abil_data[0] == 50); CHECK(new_item.abil_data[1] == 120); } SECTION("Mass Summoning") { old_item.ability = 120; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::MASS_SUMMONING); CHECK(new_item.abil_data[0] == 6); CHECK(new_item.abil_data[1] == 120); } SECTION("Acid Spray") { old_item.ability = 121; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::ACID_SPRAY)); } SECTION("Stinking Cloud") { old_item.ability = 122; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::FOUL_VAPOR)); } SECTION("Sleep Field") { old_item.ability = 123; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::CLOUD_SLEEP)); } SECTION("Venom") { old_item.ability = 124; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::POISON)); } SECTION("Shockstorm") { old_item.ability = 125; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::SHOCKSTORM)); } SECTION("Paralysis") { old_item.ability = 126; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::PARALYZE_BEAM)); } SECTION("Web Spell") { old_item.ability = 127; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::GOO_BOMB)); } SECTION("Strengthen Target") { old_item.ability = 128; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::STRENGTHEN_TARGET)); } SECTION("Quickfire") { old_item.ability = 129; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::QUICKFIRE); CHECK(new_item.abil_data[0] == 120); } SECTION("Mass Charm") { old_item.ability = 130; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::CHARM_MASS)); } SECTION("Magic Map") { old_item.ability = 131; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::MAGIC_MAP)); } SECTION("Dispel Barrier") { old_item.ability = 132; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::DISPEL_BARRIER)); } SECTION("Ice Wall") { old_item.ability = 133; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::WALL_ICE_BALL)); } SECTION("Charm") { old_item.ability = 134; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eSpell::CHARM_FOE)); } SECTION("Antimagic Cloud") { old_item.ability = 135; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::CAST_SPELL); CHECK(new_item.abil_data[0] == 241); CHECK(new_item.abil_data[1] == int(eSpell::ANTIMAGIC)); @@ -872,62 +872,62 @@ TEST_CASE("Converting items from legacy scenarios") { // Reagent abilities SECTION("Holly/Toadstool") { old_item.ability = 150; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::HOLLY); } SECTION("Comfrey Root") { old_item.ability = 151; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::COMFREY); } SECTION("Glowing Nettle") { old_item.ability = 152; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::NETTLE); } SECTION("Crypt Shroom/Wormgrass") { old_item.ability = 153; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::WORMGRASS); } SECTION("Asptongue Mold") { old_item.ability = 154; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::ASPTONGUE); } SECTION("Ember Flowers") { old_item.ability = 155; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::EMBERF); } SECTION("Graymold") { old_item.ability = 156; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::GRAYMOLD); } SECTION("Mandrake Root") { old_item.ability = 157; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::MANDRAKE); } SECTION("Sapphire") { old_item.ability = 158; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SAPPHIRE); } SECTION("Smoky Crystal") { old_item.ability = 159; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SMOKY_CRYSTAL); } SECTION("Resurrection Balm") { old_item.ability = 160; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::RESURRECTION_BALM); } SECTION("Lockpicks") { old_item.ability = 161; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::LOCKPICKS); CHECK(new_item.abil_data[0] == 120); } @@ -935,47 +935,47 @@ TEST_CASE("Converting items from legacy scenarios") { // Missile Abilities SECTION("Returning Missile") { old_item.ability = 170; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::RETURNING_MISSILE); } SECTION("Lightning Missile") { old_item.ability = 171; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::DAMAGING_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eDamageType::FIRE)); } SECTION("Exploding Missile") { old_item.ability = 172; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::EXPLODING_WEAPON); CHECK(new_item.abil_data[0] == 120); CHECK(new_item.abil_data[1] == int(eDamageType::FIRE)); } SECTION("Acid Missile") { old_item.ability = 173; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::STATUS_WEAPON); CHECK(new_item.abil_data[0] == 240); CHECK(new_item.abil_data[1] == int(eStatus::ACID)); } SECTION("Slay Undead") { old_item.ability = 174; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 123); CHECK(new_item.abil_data[1] == int(eRace::UNDEAD)); } SECTION("Slay Demon") { old_item.ability = 175; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::SLAYER_WEAPON); CHECK(new_item.abil_data[0] == 123); CHECK(new_item.abil_data[1] == int(eRace::DEMON)); } SECTION("Heal Target") { old_item.ability = 176; - new_item.append(old_item); + new_item.import_legacy(old_item); CHECK(new_item.ability == eItemAbil::HEALING_WEAPON); CHECK(new_item.abil_data[0] == 120); } diff --git a/test/map_read.cpp b/test/map_read.cpp index 73440b6e..d86bf982 100644 --- a/test/map_read.cpp +++ b/test/map_read.cpp @@ -10,7 +10,7 @@ #include "catch.hpp" #include "map_parse.hpp" #include "scenario.hpp" -#include "regtown.hpp" +#include "town.hpp" using namespace std; ostream& operator<< (ostream& out, eMapFeature feat); @@ -162,7 +162,7 @@ TEST_CASE("Interpreting loaded map data") { cScenario scen; scen.outdoors.resize(1,1); scen.outdoors[0][0] = new cOutdoors(scen); - scen.addTown(); + scen.addTown(AREA_TINY); scen.ter_types.resize(50); SECTION("Basic") { diff --git a/test/map_write.cpp b/test/map_write.cpp index a57c51c5..b66ef12c 100644 --- a/test/map_write.cpp +++ b/test/map_write.cpp @@ -10,7 +10,7 @@ #include "catch.hpp" #include "map_parse.hpp" #include "scenario.hpp" -#include "regtown.hpp" +#include "town.hpp" using namespace std; @@ -45,7 +45,7 @@ static void in_and_out(cScenario& scen, bool town) { scen.ter_types.resize(50); if(town) { // Reconstruct the town, to ensure that it doesn't just pass due to old data still being around - scen.addTown(); + scen.addTown(AREA_TINY); loadTownMapData(move(map), 0, scen); } else { // Reconstruct the sector, to ensure that it doesn't just pass due to old data still being around @@ -163,7 +163,7 @@ TEST_CASE("Building map data") { cScenario scen; scen.outdoors.resize(1,1); scen.outdoors[0][0] = new cOutdoors(scen); - scen.addTown(); + scen.addTown(AREA_TINY); scen.ter_types.resize(50); for(int x = 0; x < 5; x++) @@ -186,10 +186,12 @@ TEST_CASE("Building map data") { } } SECTION("With vehicles") { + scen.boats.resize(2); scen.boats[0].property = true; scen.boats[0].loc = {1,1}; scen.boats[1].property = false; scen.boats[1].loc = {2,2}; + scen.horses.resize(2); scen.horses[0].property = true; scen.horses[0].loc = {3,3}; scen.horses[1].property = false; @@ -200,6 +202,8 @@ TEST_CASE("Building map data") { scen.boats[0].sector = scen.horses[0].sector = {0,0}; scen.boats[1].sector = scen.horses[1].sector = {0,0}; in_and_out(scen, false); + REQUIRE(scen.boats.size() >= 2); + REQUIRE(scen.horses.size() >= 2); CHECK(scen.boats[0].property); CHECK(scen.boats[0].loc == loc(1,1)); CHECK(scen.boats[0].which_town == 200); @@ -221,6 +225,8 @@ TEST_CASE("Building map data") { scen.boats[0].which_town = scen.horses[0].which_town = 0; scen.boats[1].which_town = scen.horses[1].which_town = 0; in_and_out(scen, true); + REQUIRE(scen.boats.size() >= 2); + REQUIRE(scen.horses.size() >= 2); CHECK(scen.boats[0].property); CHECK(scen.boats[0].loc == loc(1,1)); CHECK(scen.boats[0].which_town == 0); diff --git a/test/monst_legacy.cpp b/test/monst_legacy.cpp index 8b10d1b9..73f12c96 100644 --- a/test/monst_legacy.cpp +++ b/test/monst_legacy.cpp @@ -29,7 +29,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { cMonster new_monst; SECTION("Basic monster") { - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.level == 5); CHECK(new_monst.m_name == "Test Monster"); CHECK(new_monst.m_health == 50); @@ -81,7 +81,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { old_monst.breath = 12; SECTION("Fire") { old_monst.breath_type = 0; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DAMAGE2].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE2].gen.type == eMonstGen::BREATH); @@ -93,7 +93,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Cold") { old_monst.breath_type = 1; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DAMAGE2].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE2].gen.type == eMonstGen::BREATH); @@ -105,7 +105,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Electricity") { old_monst.breath_type = 2; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DAMAGE2].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE2].gen.type == eMonstGen::BREATH); @@ -117,7 +117,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Darkness") { old_monst.breath_type = 3; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DAMAGE2].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE2].gen.type == eMonstGen::BREATH); @@ -130,7 +130,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("With poison") { old_monst.poison = 8; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS2].active); CHECK(new_monst.abil[eMonstAbil::STATUS2].gen.type == eMonstGen::TOUCH); @@ -141,7 +141,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { SECTION("With primary abilities") { SECTION("Throws Darts") { old_monst.spec_skill = 1; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::DART); @@ -154,7 +154,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Shoots Arrows") { old_monst.spec_skill = 2; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::ARROW); @@ -167,7 +167,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Throws Spears") { old_monst.spec_skill = 3; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::SPEAR); @@ -180,7 +180,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Throws Rocks 4-24") { old_monst.spec_skill = 4; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::BOULDER); @@ -193,7 +193,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Throws Rocks 5-30") { old_monst.spec_skill = 5; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::BOULDER); @@ -206,7 +206,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Throws Rocks 6-36") { old_monst.spec_skill = 6; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::BOULDER); @@ -219,7 +219,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Throws Razordisks") { old_monst.spec_skill = 7; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::RAZORDISK); @@ -232,7 +232,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Petrification Ray") { old_monst.spec_skill = 8; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::PETRIFY].active); CHECK(new_monst.abil[eMonstAbil::PETRIFY].gen.type == eMonstGen::GAZE); @@ -242,7 +242,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Spell Point Drain Ray") { old_monst.spec_skill = 9; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DRAIN_SP].active); CHECK(new_monst.abil[eMonstAbil::DRAIN_SP].gen.type == eMonstGen::GAZE); @@ -252,7 +252,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Heat Ray") { old_monst.spec_skill = 10; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RAY_HEAT].active); CHECK(new_monst.abil[eMonstAbil::RAY_HEAT].special.extra1 == 6); @@ -261,13 +261,13 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Invisible") { old_monst.spec_skill = 11; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.abil.size() == 0); CHECK(new_monst.invisible); } SECTION("Splits When Hit") { old_monst.spec_skill = 12; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::SPLITS].active); CHECK(new_monst.abil[eMonstAbil::SPLITS].special.extra1 == 1000); @@ -275,13 +275,13 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Mindless") { old_monst.spec_skill = 13; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.abil.size() == 0); CHECK(new_monst.mindless); } SECTION("Breathes Stinking Clouds") { old_monst.spec_skill = 14; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::FIELD].active); CHECK(new_monst.abil[eMonstAbil::FIELD].gen.type == eMonstGen::BREATH); @@ -293,7 +293,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Icy Touch") { old_monst.spec_skill = 15; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DAMAGE].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE].gen.type == eMonstGen::TOUCH); @@ -303,7 +303,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Experience Draining Touch") { old_monst.spec_skill = 16; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DRAIN_XP].active); CHECK(new_monst.abil[eMonstAbil::DRAIN_XP].gen.type == eMonstGen::TOUCH); @@ -312,7 +312,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Icy and Draining Touch") { old_monst.spec_skill = 17; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 2); REQUIRE(new_monst.abil[eMonstAbil::DAMAGE].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE].gen.type == eMonstGen::TOUCH); @@ -326,7 +326,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Slowing Touch") { old_monst.spec_skill = 18; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STUN].active); CHECK(new_monst.abil[eMonstAbil::STUN].gen.type == eMonstGen::TOUCH); @@ -336,7 +336,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Shoots Web") { old_monst.spec_skill = 19; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE_WEB].active); CHECK(new_monst.abil[eMonstAbil::MISSILE_WEB].special.extra1 == 4); @@ -344,7 +344,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Good Archer") { old_monst.spec_skill = 20; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::RAPID_ARROW); @@ -357,7 +357,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Steals Food") { old_monst.spec_skill = 21; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STEAL_FOOD].active); CHECK(new_monst.abil[eMonstAbil::STEAL_FOOD].gen.type == eMonstGen::TOUCH); @@ -366,7 +366,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Permanent Martyr's Shield") { old_monst.spec_skill = 22; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MARTYRS_SHIELD].active); CHECK(new_monst.abil[eMonstAbil::MARTYRS_SHIELD].special.extra1 == 1000); @@ -374,7 +374,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Paralysis Ray") { old_monst.spec_skill = 23; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::RAY); @@ -385,7 +385,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Dumbfounding Touch") { old_monst.spec_skill = 24; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::TOUCH); @@ -395,7 +395,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Disease Touch") { old_monst.spec_skill = 25; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::TOUCH); @@ -405,7 +405,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Absorbs Spells") { old_monst.spec_skill = 26; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::ABSORB_SPELLS].active); CHECK(new_monst.abil[eMonstAbil::ABSORB_SPELLS].special.extra1 == 1000); @@ -413,7 +413,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Web Touch") { old_monst.spec_skill = 27; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::TOUCH); @@ -423,7 +423,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Sleep Touch") { old_monst.spec_skill = 28; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::TOUCH); @@ -433,7 +433,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Paralysis Touch") { old_monst.spec_skill = 29; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::TOUCH); @@ -443,7 +443,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Petrification Touch") { old_monst.spec_skill = 30; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::PETRIFY].active); CHECK(new_monst.abil[eMonstAbil::PETRIFY].gen.type == eMonstGen::TOUCH); @@ -452,7 +452,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Acid Touch") { old_monst.spec_skill = 31; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::TOUCH); @@ -462,7 +462,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Breathes Sleep Clouds") { old_monst.spec_skill = 32; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::FIELD].active); CHECK(new_monst.abil[eMonstAbil::FIELD].gen.type == eMonstGen::BREATH); @@ -474,7 +474,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Acid Spit") { old_monst.spec_skill = 33; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS].gen.type == eMonstGen::SPIT); @@ -486,7 +486,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Shoots Spines") { old_monst.spec_skill = 34; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::MISSILE].active); CHECK(new_monst.abil[eMonstAbil::MISSILE].missile.type == eMonstMissile::SPINE); @@ -499,7 +499,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Death Touch") { old_monst.spec_skill = 35; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::KILL].active); CHECK(new_monst.abil[eMonstAbil::KILL].gen.type == eMonstGen::TOUCH); @@ -508,13 +508,13 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Invulnerable") { old_monst.spec_skill = 36; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.abil.size() == 0); CHECK(new_monst.invuln); } SECTION("Guard") { old_monst.spec_skill = 37; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.abil.size() == 0); CHECK(new_monst.guard); } @@ -523,7 +523,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { old_monst.radiate_2 = 50; SECTION("Radiate Fire Fields") { old_monst.radiate_1 = 1; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RADIATE].active); CHECK(new_monst.abil[eMonstAbil::RADIATE].radiate.type == WALL_FIRE); @@ -532,7 +532,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Radiate Ice Fields") { old_monst.radiate_1 = 2; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RADIATE].active); CHECK(new_monst.abil[eMonstAbil::RADIATE].radiate.type == WALL_ICE); @@ -541,7 +541,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Radiate Shock Fields") { old_monst.radiate_1 = 3; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RADIATE].active); CHECK(new_monst.abil[eMonstAbil::RADIATE].radiate.type == WALL_FORCE); @@ -550,7 +550,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Radiate Antimagic Fields") { old_monst.radiate_1 = 4; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RADIATE].active); CHECK(new_monst.abil[eMonstAbil::RADIATE].radiate.type == FIELD_ANTIMAGIC); @@ -559,7 +559,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Radiate Sleep Fields") { old_monst.radiate_1 = 5; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RADIATE].active); CHECK(new_monst.abil[eMonstAbil::RADIATE].radiate.type == CLOUD_SLEEP); @@ -568,7 +568,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Radiate Stink Fields") { old_monst.radiate_1 = 6; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::RADIATE].active); CHECK(new_monst.abil[eMonstAbil::RADIATE].radiate.type == CLOUD_STINK); @@ -577,7 +577,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Summon 5% chance") { old_monst.radiate_1 = 10; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::SUMMON].active); CHECK(new_monst.abil[eMonstAbil::SUMMON].summon.type == eMonstSummon::TYPE); @@ -589,7 +589,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Summon 20% chance") { old_monst.radiate_1 = 11; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::SUMMON].active); CHECK(new_monst.abil[eMonstAbil::SUMMON].summon.type == eMonstSummon::TYPE); @@ -601,7 +601,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Summon 50% chance") { old_monst.radiate_1 = 12; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::SUMMON].active); CHECK(new_monst.abil[eMonstAbil::SUMMON].summon.type == eMonstSummon::TYPE); @@ -613,7 +613,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { } SECTION("Death Triggers Scenario Special") { old_monst.radiate_1 = 15; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 1); REQUIRE(new_monst.abil[eMonstAbil::DEATH_TRIGGER].active); CHECK(new_monst.abil[eMonstAbil::DEATH_TRIGGER].special.extra1 == 50); @@ -623,7 +623,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { SECTION("Poison and acid touch") { old_monst.poison = 8; old_monst.spec_skill = 31; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 2); CHECK(new_monst.abil[eMonstAbil::STATUS].active); CHECK(new_monst.abil[eMonstAbil::STATUS2].active); @@ -631,7 +631,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { SECTION("Poison and stun") { old_monst.poison = 8; old_monst.spec_skill = 18; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 2); CHECK(new_monst.abil[eMonstAbil::STATUS2].active); CHECK(new_monst.abil[eMonstAbil::STUN].active); @@ -640,7 +640,7 @@ TEST_CASE("Converting monsters from legacy scenarios") { old_monst.breath = 8; old_monst.breath_type = 1; old_monst.spec_skill = 17; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); REQUIRE(new_monst.abil.size() == 3); CHECK(new_monst.abil[eMonstAbil::DAMAGE].active); CHECK(new_monst.abil[eMonstAbil::DAMAGE2].active); @@ -654,7 +654,7 @@ TEST_CASE("Converting placed monsters from legacy scenarios") { cTownperson new_monst; SECTION("Basic info") { - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.number == 12); CHECK(new_monst.start_attitude == eAttitude::HOSTILE_A); CHECK(new_monst.start_loc == loc(4,4)); @@ -671,37 +671,37 @@ TEST_CASE("Converting placed monsters from legacy scenarios") { old_monst.time_code = 19; SECTION("Appear on day") { old_monst.time_flag = 1; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::APPEAR_ON_DAY); } SECTION("Disappear on day") { old_monst.time_flag = 2; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::DISAPPEAR_ON_DAY); } SECTION("Sometimes A") { old_monst.time_flag = 4; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::SOMETIMES_A); } SECTION("Sometimes B") { old_monst.time_flag = 5; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::SOMETIMES_B); } SECTION("Sometimes C") { old_monst.time_flag = 6; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::SOMETIMES_C); } SECTION("Appear when event") { old_monst.time_flag = 7; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::APPEAR_WHEN_EVENT); } SECTION("Disappear when event") { old_monst.time_flag = 8; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.time_flag == eMonstTime::DISAPPEAR_WHEN_EVENT); } CHECK(new_monst.monster_time == 17); @@ -728,7 +728,7 @@ TEST_CASE("Converting monsters from legacy saves") { cCreature new_monst; SECTION("Basic info") { - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.m_name == "Test Monster"); CHECK(new_monst.health == 45); CHECK(new_monst.m_health == 50); @@ -748,13 +748,13 @@ TEST_CASE("Converting monsters from legacy saves") { } SECTION("Summoned by party") { old_monst.summoned = 20; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.summon_time == 20); CHECK(new_monst.party_summoned); } SECTION("Summoned by monster") { old_monst.summoned = 120; - new_monst.append(old_monst); + new_monst.import_legacy(old_monst); CHECK(new_monst.summon_time == 20); CHECK_FALSE(new_monst.party_summoned); } diff --git a/test/out_legacy.cpp b/test/out_legacy.cpp index 36f14450..766af3c2 100644 --- a/test/out_legacy.cpp +++ b/test/out_legacy.cpp @@ -31,7 +31,7 @@ TEST_CASE("Converting legacy outdoor section data") { cScenario scen; scen.ter_types.resize(1); cOutdoors sector(scen); - sector.append(old_sector); + sector.import_legacy(old_sector); SECTION("General Data") { CHECK(sector.ambient_sound == AMBIENT_NONE); diff --git a/test/out_read.cpp b/test/out_read.cpp index ba9b9466..2fe8bfe8 100644 --- a/test/out_read.cpp +++ b/test/out_read.cpp @@ -88,7 +88,7 @@ TEST_CASE("Loading an outdoor section definition") { fin.open("files/outdoor/minimal.xml"); doc = xmlDocFromStream(fin, "minimal.xml"); REQUIRE_NOTHROW(readOutdoorsFromXml(move(doc), sector)); - CHECK(sector.out_name == "Test Sector"); + CHECK(sector.name == "Test Sector"); } SECTION("With an arbitrary ambient sound") { fin.open("files/outdoor/sound.xml"); diff --git a/test/out_write.cpp b/test/out_write.cpp index 325d5a80..34db884c 100644 --- a/test/out_write.cpp +++ b/test/out_write.cpp @@ -43,10 +43,10 @@ static void in_and_out(string name, cOutdoors& out, cScenario& scen) { TEST_CASE("Saving an outdoors sector") { cScenario scen; cOutdoors out(scen); - out.out_name = "The Outdoors Test"; + out.name = "The Outdoors Test"; SECTION("With the minimal required information") { in_and_out("basic", out, scen); - CHECK(out.out_name == "The Outdoors Test"); + CHECK(out.name == "The Outdoors Test"); } SECTION("With some optional information") { out.comment = "Let's make a comment about comments."; diff --git a/test/scen_legacy.cpp b/test/scen_legacy.cpp index 32d04fec..8537dcc3 100644 --- a/test/scen_legacy.cpp +++ b/test/scen_legacy.cpp @@ -55,7 +55,7 @@ TEST_CASE("Converting legacy scenario data") { 2 }; cScenario scen; - scen.append(old_scen); + scen.import_legacy(old_scen); SECTION("Basic header data") { CHECK(scen.adjust_diff); @@ -86,7 +86,8 @@ TEST_CASE("Converting legacy scenario data") { REQUIRE(scen.boats.size() >= 1); CHECK(scen.boats[0].exists); CHECK(scen.boats[0].loc == loc(33,33)); - CHECK(scen.boats[0].loc_in_sec == loc(22,22)); + // TODO: This field is meaningless in legacy scenario boats but matters in legacy svaed game boats. +// CHECK(scen.boats[0].loc_in_sec == loc(22,22)); CHECK(scen.boats[0].property); CHECK(scen.boats[0].sector == loc(1,1)); CHECK(scen.boats[0].which_town == 2); diff --git a/test/scen_write.cpp b/test/scen_write.cpp index b4911ab1..fe5d2bde 100644 --- a/test/scen_write.cpp +++ b/test/scen_write.cpp @@ -5,7 +5,7 @@ #include "dialog.hpp" #include "catch.hpp" #include "scenario.hpp" -#include "regtown.hpp" +#include "town.hpp" #include "restypes.hpp" using namespace std; @@ -81,9 +81,9 @@ TEST_CASE("Saving a scenario record") { CHECK(scen.out_start == loc(12,21)); } SECTION("With some towns and sectors") { - scen.addTown(); - scen.addTown(); - scen.addTown(); + scen.addTown(AREA_SMALL); + scen.addTown(AREA_MEDIUM); + scen.addTown(AREA_LARGE); scen.outdoors.resize(2,5); in_and_out("town§or", scen); CHECK(scen.towns.size() == 3); diff --git a/test/spec_legacy.cpp b/test/spec_legacy.cpp index b89519f3..453912d0 100644 --- a/test/spec_legacy.cpp +++ b/test/spec_legacy.cpp @@ -28,7 +28,7 @@ TEST_CASE("When converting legacy special nodes (general)") { oldSpec.m1 = 2; oldSpec.m2 = 3; oldSpec.sd1 = 4; oldSpec.sd2 = 5; oldSpec.ex1a = 6; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::SET_SDF); CHECK(newSpec.m1 == 2); CHECK(newSpec.m2 == 3); CHECK(newSpec.sd1 == 4); CHECK(newSpec.sd2 == 5); @@ -37,7 +37,7 @@ TEST_CASE("When converting legacy special nodes (general)") { } SECTION("Secret Passage") { oldSpec.type = 4; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::CANT_ENTER); CHECK(newSpec.ex1a == 0); CHECK(newSpec.ex2a == 1); @@ -47,7 +47,7 @@ TEST_CASE("When converting legacy special nodes (general)") { oldSpec.type = 7; oldSpec.m1 = 4; oldSpec.m2 = 5; oldSpec.ex1a = 1; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::IF_CONTEXT); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.ex1a == int(eSpecCtx::OUT_MOVE)); @@ -58,7 +58,7 @@ TEST_CASE("When converting legacy special nodes (general)") { oldSpec.type = 8; oldSpec.m1 = 4; oldSpec.m2 = 5; oldSpec.ex1a = 1; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::IF_CONTEXT); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.ex1a == int(eSpecCtx::TOWN_MOVE)); @@ -69,7 +69,7 @@ TEST_CASE("When converting legacy special nodes (general)") { oldSpec.type = 9; oldSpec.m1 = 4; oldSpec.m2 = 5; oldSpec.ex1a = 1; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::IF_CONTEXT); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.ex1a == int(eSpecCtx::COMBAT_MOVE)); @@ -79,7 +79,7 @@ TEST_CASE("When converting legacy special nodes (general)") { SECTION("Looking Block") { oldSpec.type = 10; oldSpec.m1 = 4; oldSpec.m2 = 5; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::IF_LOOKING); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.jumpto == 12); @@ -104,7 +104,7 @@ TEST_CASE("When converting legacy special nodes (one-shot)") { oldSpec.ex1b = 2500; oldSpec.ex2a = 1500; oldSpec.ex2b = 10; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::ONCE_GIVE_ITEM); CHECK(newSpec.sd1 == 8); CHECK(newSpec.sd2 == 7); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); @@ -131,7 +131,7 @@ TEST_CASE("When converting legacy special nodes (affect)") { oldSpec.type = 80; oldSpec.ex1a = 1; oldSpec.ex1b = 10; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::SELECT_TARGET); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.ex1a == 1); @@ -157,7 +157,7 @@ TEST_CASE("When converting legacy special nodes (if-then)") { oldSpec.ex1b = 10; oldSpec.ex2a = 9; oldSpec.ex2b = 13; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::IF_SDF); CHECK(newSpec.sd1 == 8); CHECK(newSpec.sd2 == 7); CHECK(newSpec.ex1a == 1); @@ -181,7 +181,7 @@ TEST_CASE("When converting legacy special nodes (town)") { SECTION("Town Hostile") { oldSpec.type = 170; oldSpec.jumpto = 12; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::MAKE_TOWN_HOSTILE); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.jumpto == 12); @@ -207,7 +207,7 @@ TEST_CASE("When converting legacy special nodes (rect)") { oldSpec.m1 = 4; oldSpec.m2 = 5; oldSpec.pic = 1; oldSpec.sd1 = 75; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::RECT_PLACE_FIELD); CHECK(newSpec.m1 == 4); CHECK(newSpec.m2 == 5); CHECK(newSpec.pic == 1); @@ -233,7 +233,7 @@ TEST_CASE("When converting legacy special nodes (outdoors)") { oldSpec.jumpto = 12; SECTION("Make Outdoor Wandering") { oldSpec.type = 225; - newSpec.append(oldSpec); + newSpec.import_legacy(oldSpec); CHECK(newSpec.type == eSpecType::OUT_MAKE_WANDER); CHECK(newSpec.jumpto == 12); } diff --git a/test/ter_legacy.cpp b/test/ter_legacy.cpp index b76a3908..28b952c7 100644 --- a/test/ter_legacy.cpp +++ b/test/ter_legacy.cpp @@ -18,7 +18,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { true, 17, 3, 'c', 0, 0, 0, }; SECTION("Basic information") { - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.picture == 26); CHECK(new_ter.blockage == eTerObstruct::BLOCK_MONSTERS); CHECK(new_ter.trans_to_what == 12); @@ -44,7 +44,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 1; old_ter.flag1 = 20; old_ter.flag2 = 200; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CHANGE_WHEN_STEP_ON); CHECK(new_ter.flag1 == 20); CHECK(new_ter.flag2 == -1); @@ -53,7 +53,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 2; old_ter.flag1 = 3; old_ter.flag2 = 6; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::DAMAGING); CHECK(new_ter.flag1 == 3); CHECK(new_ter.flag2 == 6); @@ -63,7 +63,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 3; old_ter.flag1 = 3; old_ter.flag2 = 6; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::DAMAGING); CHECK(new_ter.flag1 == 3); CHECK(new_ter.flag2 == 6); @@ -73,7 +73,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 4; old_ter.flag1 = 3; old_ter.flag2 = 6; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::DAMAGING); CHECK(new_ter.flag1 == 3); CHECK(new_ter.flag2 == 6); @@ -83,7 +83,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 5; old_ter.flag1 = 8; old_ter.flag2 = 75; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::DANGEROUS); CHECK(new_ter.flag1 == 8); CHECK(new_ter.flag2 == 75); @@ -93,7 +93,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 6; old_ter.flag1 = 8; old_ter.flag2 = 75; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::DANGEROUS); CHECK(new_ter.flag1 == 8); CHECK(new_ter.flag2 == 75); @@ -101,7 +101,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { } SECTION("Crumbling") { old_ter.special = 7; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CRUMBLING); CHECK(new_ter.flag1 == 0); CHECK(new_ter.flag2 == 0); @@ -109,7 +109,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { SECTION("Lockable") { old_ter.special = 8; old_ter.flag1 = 20; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::LOCKABLE); CHECK(new_ter.flag1 == 20); } @@ -117,7 +117,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 9; old_ter.flag1 = 20; old_ter.flag2 = 10; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::UNLOCKABLE); CHECK(new_ter.flag1 == 20); CHECK(new_ter.flag2 == 10); @@ -127,7 +127,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 10; old_ter.flag1 = 20; old_ter.flag2 = 10; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::UNLOCKABLE); CHECK(new_ter.flag1 == 20); CHECK(new_ter.flag2 == 10); @@ -135,13 +135,13 @@ TEST_CASE("Converting terrain types from legacy scenarios") { } SECTION("Sign") { old_ter.special = 11; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::IS_A_SIGN); } SECTION("Call local special") { old_ter.special = 12; old_ter.flag1 = 20; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CALL_SPECIAL); CHECK(new_ter.flag1 == 20); CHECK(new_ter.flag2 == 1); @@ -149,19 +149,19 @@ TEST_CASE("Converting terrain types from legacy scenarios") { SECTION("Call global special") { old_ter.special = 13; old_ter.flag1 = 20; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CALL_SPECIAL); CHECK(new_ter.flag1 == 20); CHECK(new_ter.flag2 == 0); } SECTION("Container") { old_ter.special = 14; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::IS_A_CONTAINER); } SECTION("Waterfall") { old_ter.special = 15; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::WATERFALL_CAVE); CHECK(new_ter.flag1 == DIR_S); CHECK(new_ter.flag2 == 5); @@ -169,37 +169,37 @@ TEST_CASE("Converting terrain types from legacy scenarios") { } SECTION("Conveyor belt (north)") { old_ter.special = 16; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CONVEYOR); CHECK(new_ter.flag1 == DIR_N); } SECTION("Conveyor belt (east)") { old_ter.special = 17; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CONVEYOR); CHECK(new_ter.flag1 == DIR_E); } SECTION("Conveyor belt (south)") { old_ter.special = 18; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CONVEYOR); CHECK(new_ter.flag1 == DIR_S); } SECTION("Conveyor belt (west)") { old_ter.special = 19; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CONVEYOR); CHECK(new_ter.flag1 == DIR_W); } SECTION("Blocked to monsters") { old_ter.special = 20; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::BLOCKED_TO_MONSTERS); } SECTION("Town entrance") { old_ter.special = 21; old_ter.flag1 = 20; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::TOWN_ENTRANCE); CHECK(new_ter.flag1 == 20); } @@ -207,7 +207,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { old_ter.special = 22; old_ter.flag1 = 20; old_ter.flag2 = 200; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CHANGE_WHEN_USED); CHECK(new_ter.flag1 == 20); // Unlike change when step, this didn't originally have special allowance for no sound @@ -216,7 +216,7 @@ TEST_CASE("Converting terrain types from legacy scenarios") { SECTION("Call scenario special when used") { old_ter.special = 23; old_ter.flag1 = 20; - new_ter.append(old_ter); + new_ter.import_legacy(old_ter); CHECK(new_ter.special == eTerSpec::CALL_SPECIAL_WHEN_USED); CHECK(new_ter.flag1 == 20); CHECK(new_ter.flag2 == 0); diff --git a/test/town_read.cpp b/test/town_read.cpp index 3dffb377..38dd663f 100644 --- a/test/town_read.cpp +++ b/test/town_read.cpp @@ -131,7 +131,7 @@ TEST_CASE("Loading a town definition") { doc = xmlDocFromStream(fin, "minimal.xml"); REQUIRE_NOTHROW(readTownFromXml(move(doc), town, scen)); CHECK(town->max_dim == 32); - CHECK(town->town_name == "Test Town"); + CHECK(town->name == "Test Town"); CHECK(town->in_town_rect == rect(4, 4, 28, 28)); CHECK(town->difficulty == 1); CHECK(town->lighting_type == LIGHT_NORMAL); @@ -143,8 +143,8 @@ TEST_CASE("Loading a town definition") { CHECK(town->comment[0] == "This is a silly little comment."); CHECK(town->spec_on_entry == 12); CHECK(town->spec_on_entry_if_dead == 13); - CHECK(town->exit_locs[0] == loc(4,16)); - CHECK(town->exit_specs[0] == 52); + CHECK(town->exits[0] == loc(4,16)); + CHECK(town->exits[0].spec == 52); CHECK(town->spec_on_hostile == 42); CHECK(town->town_chop_time == 18); CHECK(town->town_chop_key == 4); diff --git a/test/town_write.cpp b/test/town_write.cpp index 69d4b166..95074125 100644 --- a/test/town_write.cpp +++ b/test/town_write.cpp @@ -10,7 +10,7 @@ #include "catch.hpp" #include "tinyprint.h" #include "scenario.hpp" -#include "regtown.hpp" +#include "town.hpp" using namespace std; using namespace ticpp; @@ -38,15 +38,15 @@ static void in_and_out(string name, cTown*& town, cScenario& scen) { TEST_CASE("Saving a town") { cScenario scen; - cTown* town = new cTinyTown(scen); - town->town_name = "Test Town"; + cTown* town = new cTown(scen, AREA_SMALL); + town->name = "Test Town"; town->in_town_rect = {2,3,30,29}; town->difficulty = 1; town->lighting_type = LIGHT_NONE; SECTION("With the minimal required information") { in_and_out("basic", town, scen); CHECK(town->max_dim == 32); - CHECK(town->town_name == "Test Town"); + CHECK(town->name == "Test Town"); CHECK(town->in_town_rect == rect(2,3,30,29)); CHECK(town->difficulty == 1); CHECK(town->lighting_type == LIGHT_NONE); @@ -58,8 +58,8 @@ TEST_CASE("Saving a town") { town->spec_on_entry = 42; town->spec_on_entry_if_dead = 19; town->spec_on_hostile = 47; - town->exit_specs[0] = 16; - town->exit_locs[0] = {24,2}; + town->exits[0] = {24,2}; + town->exits[0].spec = 16; town->town_chop_time = 25; town->town_chop_key = 6; town->max_num_monst = 100000; @@ -79,8 +79,8 @@ TEST_CASE("Saving a town") { CHECK(town->spec_on_entry == 42); CHECK(town->spec_on_entry_if_dead == 19); CHECK(town->spec_on_hostile == 47); - CHECK(town->exit_specs[0] == 16); - CHECK(town->exit_locs[0] == loc(24,2)); + CHECK(town->exits[0].spec == 16); + CHECK(town->exits[0] == loc(24,2)); CHECK(town->town_chop_time == 25); CHECK(town->town_chop_key == 6); CHECK(town->max_num_monst == 100000);