From b2c2ad84752456fc6d530a0a214af5842a35e95a Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Fri, 1 Oct 2021 14:48:57 +0200 Subject: [PATCH] More migration to const & in legacy importing methods. --- src/scenario/monster.cpp | 4 ++-- src/scenario/monster.hpp | 4 ++-- src/scenario/outdoors.cpp | 6 +++--- src/scenario/outdoors.hpp | 6 +++--- src/scenario/scenario.cpp | 6 +++--- src/scenario/scenario.hpp | 6 +++--- src/scenario/terrain.cpp | 2 +- src/scenario/terrain.hpp | 2 +- src/universe/universe.cpp | 12 ++++++------ src/universe/universe.hpp | 12 ++++++------ 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/scenario/monster.cpp b/src/scenario/monster.cpp index e8fac908..865e7734 100644 --- a/src/scenario/monster.cpp +++ b/src/scenario/monster.cpp @@ -20,7 +20,7 @@ #include "spell.hpp" #include "gfxsheets.hpp" // for NO_PIC -void cMonster::import_legacy(legacy::monster_record_type& old){ +void cMonster::import_legacy(legacy::monster_record_type const &old){ level = old.level; m_name = std::string((char*) old.m_name, 26); m_name.erase(m_name.begin() + m_name.find_first_of('\0'), m_name.end()); @@ -437,7 +437,7 @@ cTownperson::cTownperson(location loc, mon_num_t num, const cMonster& monst) : c facial_pic = monst.default_facial_pic; } -void cTownperson::import_legacy(legacy::creature_start_type old){ +void cTownperson::import_legacy(legacy::creature_start_type const &old){ number = old.number; start_attitude = eAttitude(old.start_attitude); start_loc.x = old.start_loc.x; diff --git a/src/scenario/monster.hpp b/src/scenario/monster.hpp index 431f7bb0..1a492e5e 100644 --- a/src/scenario/monster.hpp +++ b/src/scenario/monster.hpp @@ -73,7 +73,7 @@ public: std::map::iterator addAbil(eMonstAbilTemplate what, int param = 0); int addAttack(unsigned short dice, unsigned short sides, eMonstMelee type = eMonstMelee::SWING); - void import_legacy(legacy::monster_record_type& old); + void import_legacy(legacy::monster_record_type const &old); cMonster(); void writeTo(std::ostream& file) const; void readFrom(std::istream& file); @@ -92,7 +92,7 @@ public: short special_on_kill, special_on_talk; pic_num_t facial_pic; - void import_legacy(legacy::creature_start_type old); + void import_legacy(legacy::creature_start_type const &old); cTownperson(); cTownperson(location loc, mon_num_t num, const cMonster& monst); }; diff --git a/src/scenario/outdoors.cpp b/src/scenario/outdoors.cpp index f7b65c50..d4b677b4 100644 --- a/src/scenario/outdoors.cpp +++ b/src/scenario/outdoors.cpp @@ -17,7 +17,7 @@ #include "oldstructs.hpp" #include "scenario.hpp" -void cOutdoors::import_legacy(legacy::outdoor_record_type& old){ +void cOutdoors::import_legacy(legacy::outdoor_record_type const &old){ ambient_sound = AMBIENT_NONE; // Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat. std::vector unused_special_slots; @@ -126,7 +126,7 @@ cOutdoors::cOutdoors(cScenario& scenario) : cArea(AREA_MEDIUM), scenario(&scenar comment = "Comment"; } -void cOutdoors::cWandering::import_legacy(legacy::out_wandering_type old){ +void cOutdoors::cWandering::import_legacy(legacy::out_wandering_type const &old){ for(int i = 0; i < 7; i++) monst[i] = old.monst[i]; for(int j = 0; j < 3; j++) @@ -140,7 +140,7 @@ void cOutdoors::cWandering::import_legacy(legacy::out_wandering_type old){ end_spec2 = old.end_spec2; } -void cOutdoors::cCreature::import_legacy(legacy::outdoor_creature_type old){ +void cOutdoors::cCreature::import_legacy(legacy::outdoor_creature_type const &old){ exists = old.exists; direction = old.direction; what_monst.import_legacy(old.what_monst); diff --git a/src/scenario/outdoors.hpp b/src/scenario/outdoors.hpp index cfa79d4d..6c46dc49 100644 --- a/src/scenario/outdoors.hpp +++ b/src/scenario/outdoors.hpp @@ -45,7 +45,7 @@ public: bool cant_flee, forced; bool isNull(); - void import_legacy(legacy::out_wandering_type old); + void import_legacy(legacy::out_wandering_type const &old); void writeTo(std::ostream& file, std::string prefix = "") const; void readFrom(std::istream& sin); cWandering(); @@ -57,7 +57,7 @@ public: cWandering what_monst; location which_sector,m_loc,home_sector; // home_sector is the sector it was spawned in - void import_legacy(legacy::outdoor_creature_type old); + void import_legacy(legacy::outdoor_creature_type const &old); }; short x,y; // Used while loading legacy scenarios. std::vector city_locs; @@ -72,7 +72,7 @@ public: int bg_out, bg_fight, bg_town, bg_dungeon; explicit cOutdoors(cScenario& scenario); - void import_legacy(legacy::outdoor_record_type& old); + void import_legacy(legacy::outdoor_record_type const &old); void reattach(cScenario& to); }; diff --git a/src/scenario/scenario.cpp b/src/scenario/scenario.cpp index 5f989b65..6b7ff301 100644 --- a/src/scenario/scenario.cpp +++ b/src/scenario/scenario.cpp @@ -210,7 +210,7 @@ cScenario::cItemStorage::cItemStorage() : ter_type(-1), property(0) { item_odds[i] = 0; } -void cScenario::import_legacy(legacy::scenario_data_type& old){ +void cScenario::import_legacy(legacy::scenario_data_type const &old){ is_legacy = true; difficulty = old.difficulty; intro_pic = old.intro_pic; @@ -277,7 +277,7 @@ void cScenario::import_legacy(legacy::scenario_data_type& old){ adjust_diff = true; } -cScenario::cItemStorage& cScenario::cItemStorage::operator = (legacy::item_storage_shortcut_type& old){ +cScenario::cItemStorage& cScenario::cItemStorage::operator = (legacy::item_storage_shortcut_type const &old){ ter_type = old.ter_type; for(int i = 0; i < 10; i++) item_num[i] = old.item_num[i]; for(int i = 0; i < 10; i++) item_odds[i] = old.item_odds[i]; @@ -285,7 +285,7 @@ cScenario::cItemStorage& cScenario::cItemStorage::operator = (legacy::item_stora return *this; } -void cScenario::import_legacy(legacy::scen_item_data_type& old){ +void cScenario::import_legacy(legacy::scen_item_data_type const &old){ scen_items.resize(400); for(short i = 0; i < 400; i++) scen_items[i].import_legacy(old.scen_items[i]); diff --git a/src/scenario/scenario.hpp b/src/scenario/scenario.hpp index a141c813..de9e395a 100644 --- a/src/scenario/scenario.hpp +++ b/src/scenario/scenario.hpp @@ -46,7 +46,7 @@ public: short item_odds[10]; short property; cItemStorage(); - cItemStorage& operator = (legacy::item_storage_shortcut_type& old); + cItemStorage& operator = (legacy::item_storage_shortcut_type const &old); }; void destroy_terrain(); public: @@ -94,8 +94,8 @@ public: towns.push_back(new cTown(*this, dim)); } - void import_legacy(legacy::scenario_data_type& old); - void import_legacy(legacy::scen_item_data_type& old); + void import_legacy(legacy::scenario_data_type const &old); + void import_legacy(legacy::scen_item_data_type const &old); void writeTo(std::ostream& file) const; void readFrom(std::istream& file); std::string format_scen_version(); diff --git a/src/scenario/terrain.cpp b/src/scenario/terrain.cpp index 54230c37..c3f772a9 100644 --- a/src/scenario/terrain.cpp +++ b/src/scenario/terrain.cpp @@ -18,7 +18,7 @@ #include "gfxsheets.hpp" // for NO_PIC #include "damage.hpp" -void cTerrain::import_legacy(legacy::terrain_type_type& old){ +void cTerrain::import_legacy(legacy::terrain_type_type const &old){ static const std::set archetypes = { // This lists graphics that represent the archetypal terrains for each ground type // One line per graphics sheet; last line is the animated sheet diff --git a/src/scenario/terrain.hpp b/src/scenario/terrain.hpp index 0a8c8473..a6b817e2 100644 --- a/src/scenario/terrain.hpp +++ b/src/scenario/terrain.hpp @@ -46,7 +46,7 @@ public: unsigned short i; // for temporary use in porting bool blocksMove() const; - void import_legacy(legacy::terrain_type_type& old); + void import_legacy(legacy::terrain_type_type const &old); void writeTo(std::ostream& file) const; }; diff --git a/src/universe/universe.cpp b/src/universe/universe.cpp index 51228573..555c63ec 100644 --- a/src/universe/universe.cpp +++ b/src/universe/universe.cpp @@ -20,13 +20,13 @@ #include "fileio.hpp" #include "gfxsheets.hpp" -void cCurOut::import_legacy(legacy::out_info_type& old){ +void cCurOut::import_legacy(legacy::out_info_type const &old){ for(int i = 0; i < 96; i++) for(int j = 0; j < 96; j++) out_e[i][j] = old.expl[i][j]; } -void cCurTown::import_legacy(legacy::current_town_type& old){ +void cCurTown::import_legacy(legacy::current_town_type const &old){ univ.party.town_num = old.town_num; difficulty = old.difficulty; record()->import_legacy(old.town); @@ -39,7 +39,7 @@ void cCurTown::import_legacy(legacy::current_town_type& old){ cur_talk_loaded = old.town_num; } -void cCurTown::import_legacy(legacy::big_tr_type& old){ +void cCurTown::import_legacy(legacy::big_tr_type const &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]; @@ -59,13 +59,13 @@ void cCurTown::import_legacy(legacy::big_tr_type& old){ } } -void cCurTown::import_legacy(legacy::town_item_list& old){ +void cCurTown::import_legacy(legacy::town_item_list const &old){ items.resize(115); for(int i = 0; i < 115; i++) items[i].import_legacy(old.items[i]); } -void cUniverse::import_legacy(legacy::stored_town_maps_type& old){ +void cUniverse::import_legacy(legacy::stored_town_maps_type const &old){ for(int n = 0; n < scenario.towns.size(); n++) for(size_t j = 0; j < scenario.towns[n]->maps.size(); j++) for(int i = 0; i < scenario.towns[n]->maps[j].size(); i++) @@ -76,7 +76,7 @@ static short onm(char x_sector,char y_sector, char w) { return y_sector * w + x_sector; } -void cUniverse::import_legacy(legacy::stored_outdoor_maps_type& old){ +void cUniverse::import_legacy(legacy::stored_outdoor_maps_type const &old){ for(int x = 0; x < scenario.outdoors.width(); x++) for(int y = 0; y < scenario.outdoors.height(); y++) for(int i = 0; i < 48; i++) diff --git a/src/universe/universe.hpp b/src/universe/universe.hpp index da1a8e70..a7174cdf 100644 --- a/src/universe/universe.hpp +++ b/src/universe/universe.hpp @@ -47,10 +47,10 @@ public: unsigned long fields[64][64]; - void import_legacy(legacy::current_town_type& old); - void import_legacy(legacy::town_item_list& old); + void import_legacy(legacy::current_town_type const &old); + void import_legacy(legacy::town_item_list const &old); void import_reset_fields_legacy(); - void import_legacy(legacy::big_tr_type& old); + void import_legacy(legacy::big_tr_type const &old); cTown* operator -> (); cTown& operator * (); @@ -141,7 +141,7 @@ public: bool is_spot(int x, int y); bool is_road(int x, int y); - void import_legacy(legacy::out_info_type& old); + void import_legacy(legacy::out_info_type const &old); typedef ter_num_t arr_96[96]; arr_96& operator [] (size_t i); @@ -206,8 +206,8 @@ public: bool node_step_through { false }; void clear_stored_pcs(); - void import_legacy(legacy::stored_town_maps_type& old); - void import_legacy(legacy::stored_outdoor_maps_type& old); + void import_legacy(legacy::stored_town_maps_type const &old); + void import_legacy(legacy::stored_outdoor_maps_type const &old); void enter_scenario(const std::string& name); void refresh_store_items(); void generate_job_bank(int which, job_bank_t& bank);