More migration to const & in legacy importing methods.

This commit is contained in:
C.W. Betts
2021-10-01 14:48:57 +02:00
committed by Celtic Minstrel
parent 976794e8b6
commit b2c2ad8475
10 changed files with 30 additions and 30 deletions

View File

@@ -20,7 +20,7 @@
#include "spell.hpp" #include "spell.hpp"
#include "gfxsheets.hpp" // for NO_PIC #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; level = old.level;
m_name = std::string((char*) old.m_name, 26); m_name = std::string((char*) old.m_name, 26);
m_name.erase(m_name.begin() + m_name.find_first_of('\0'), m_name.end()); 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; 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; number = old.number;
start_attitude = eAttitude(old.start_attitude); start_attitude = eAttitude(old.start_attitude);
start_loc.x = old.start_loc.x; start_loc.x = old.start_loc.x;

View File

@@ -73,7 +73,7 @@ public:
std::map<eMonstAbil,uAbility>::iterator addAbil(eMonstAbilTemplate what, int param = 0); std::map<eMonstAbil,uAbility>::iterator addAbil(eMonstAbilTemplate what, int param = 0);
int addAttack(unsigned short dice, unsigned short sides, eMonstMelee type = eMonstMelee::SWING); 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(); cMonster();
void writeTo(std::ostream& file) const; void writeTo(std::ostream& file) const;
void readFrom(std::istream& file); void readFrom(std::istream& file);
@@ -92,7 +92,7 @@ public:
short special_on_kill, special_on_talk; short special_on_kill, special_on_talk;
pic_num_t facial_pic; pic_num_t facial_pic;
void import_legacy(legacy::creature_start_type old); void import_legacy(legacy::creature_start_type const &old);
cTownperson(); cTownperson();
cTownperson(location loc, mon_num_t num, const cMonster& monst); cTownperson(location loc, mon_num_t num, const cMonster& monst);
}; };

View File

@@ -17,7 +17,7 @@
#include "oldstructs.hpp" #include "oldstructs.hpp"
#include "scenario.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; ambient_sound = AMBIENT_NONE;
// Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat. // Collect a list of unused special nodes, to be used for fixing specials that could be triggered in a boat.
std::vector<int> unused_special_slots; std::vector<int> unused_special_slots;
@@ -126,7 +126,7 @@ cOutdoors::cOutdoors(cScenario& scenario) : cArea(AREA_MEDIUM), scenario(&scenar
comment = "Comment"; 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++) for(int i = 0; i < 7; i++)
monst[i] = old.monst[i]; monst[i] = old.monst[i];
for(int j = 0; j < 3; j++) 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; 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; exists = old.exists;
direction = old.direction; direction = old.direction;
what_monst.import_legacy(old.what_monst); what_monst.import_legacy(old.what_monst);

View File

@@ -45,7 +45,7 @@ public:
bool cant_flee, forced; bool cant_flee, forced;
bool isNull(); 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 writeTo(std::ostream& file, std::string prefix = "") const;
void readFrom(std::istream& sin); void readFrom(std::istream& sin);
cWandering(); cWandering();
@@ -57,7 +57,7 @@ public:
cWandering what_monst; cWandering what_monst;
location which_sector,m_loc,home_sector; // home_sector is the sector it was spawned in 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. short x,y; // Used while loading legacy scenarios.
std::vector<spec_loc_t> city_locs; std::vector<spec_loc_t> city_locs;
@@ -72,7 +72,7 @@ public:
int bg_out, bg_fight, bg_town, bg_dungeon; int bg_out, bg_fight, bg_town, bg_dungeon;
explicit cOutdoors(cScenario& scenario); 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); void reattach(cScenario& to);
}; };

View File

@@ -210,7 +210,7 @@ cScenario::cItemStorage::cItemStorage() : ter_type(-1), property(0) {
item_odds[i] = 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; is_legacy = true;
difficulty = old.difficulty; difficulty = old.difficulty;
intro_pic = old.intro_pic; intro_pic = old.intro_pic;
@@ -277,7 +277,7 @@ void cScenario::import_legacy(legacy::scenario_data_type& old){
adjust_diff = true; 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; 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_num[i] = old.item_num[i];
for(int i = 0; i < 10; i++) item_odds[i] = old.item_odds[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; 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); scen_items.resize(400);
for(short i = 0; i < 400; i++) for(short i = 0; i < 400; i++)
scen_items[i].import_legacy(old.scen_items[i]); scen_items[i].import_legacy(old.scen_items[i]);

View File

@@ -46,7 +46,7 @@ public:
short item_odds[10]; short item_odds[10];
short property; short property;
cItemStorage(); cItemStorage();
cItemStorage& operator = (legacy::item_storage_shortcut_type& old); cItemStorage& operator = (legacy::item_storage_shortcut_type const &old);
}; };
void destroy_terrain(); void destroy_terrain();
public: public:
@@ -94,8 +94,8 @@ public:
towns.push_back(new cTown(*this, dim)); towns.push_back(new cTown(*this, dim));
} }
void import_legacy(legacy::scenario_data_type& old); void import_legacy(legacy::scenario_data_type const &old);
void import_legacy(legacy::scen_item_data_type& old); void import_legacy(legacy::scen_item_data_type const &old);
void writeTo(std::ostream& file) const; void writeTo(std::ostream& file) const;
void readFrom(std::istream& file); void readFrom(std::istream& file);
std::string format_scen_version(); std::string format_scen_version();

View File

@@ -18,7 +18,7 @@
#include "gfxsheets.hpp" // for NO_PIC #include "gfxsheets.hpp" // for NO_PIC
#include "damage.hpp" #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<int> archetypes = { static const std::set<int> archetypes = {
// This lists graphics that represent the archetypal terrains for each ground type // This lists graphics that represent the archetypal terrains for each ground type
// One line per graphics sheet; last line is the animated sheet // One line per graphics sheet; last line is the animated sheet

View File

@@ -46,7 +46,7 @@ public:
unsigned short i; // for temporary use in porting unsigned short i; // for temporary use in porting
bool blocksMove() const; 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; void writeTo(std::ostream& file) const;
}; };

View File

@@ -20,13 +20,13 @@
#include "fileio.hpp" #include "fileio.hpp"
#include "gfxsheets.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 i = 0; i < 96; i++)
for(int j = 0; j < 96; j++) for(int j = 0; j < 96; j++)
out_e[i][j] = old.expl[i][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; univ.party.town_num = old.town_num;
difficulty = old.difficulty; difficulty = old.difficulty;
record()->import_legacy(old.town); record()->import_legacy(old.town);
@@ -39,7 +39,7 @@ void cCurTown::import_legacy(legacy::current_town_type& old){
cur_talk_loaded = old.town_num; 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 i = 0; i < record()->max_dim; i++)
for(short j = 0; j < record()->max_dim; j++) for(short j = 0; j < record()->max_dim; j++)
record()->terrain(i,j) = old.terrain[i][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); items.resize(115);
for(int i = 0; i < 115; i++) for(int i = 0; i < 115; i++)
items[i].import_legacy(old.items[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(int n = 0; n < scenario.towns.size(); n++)
for(size_t j = 0; j < scenario.towns[n]->maps.size(); j++) for(size_t j = 0; j < scenario.towns[n]->maps.size(); j++)
for(int i = 0; i < scenario.towns[n]->maps[j].size(); i++) 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; 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 x = 0; x < scenario.outdoors.width(); x++)
for(int y = 0; y < scenario.outdoors.height(); y++) for(int y = 0; y < scenario.outdoors.height(); y++)
for(int i = 0; i < 48; i++) for(int i = 0; i < 48; i++)

View File

@@ -47,10 +47,10 @@ public:
unsigned long fields[64][64]; unsigned long fields[64][64];
void import_legacy(legacy::current_town_type& old); void import_legacy(legacy::current_town_type const &old);
void import_legacy(legacy::town_item_list& old); void import_legacy(legacy::town_item_list const &old);
void import_reset_fields_legacy(); 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 -> ();
cTown& operator * (); cTown& operator * ();
@@ -141,7 +141,7 @@ public:
bool is_spot(int x, int y); bool is_spot(int x, int y);
bool is_road(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]; typedef ter_num_t arr_96[96];
arr_96& operator [] (size_t i); arr_96& operator [] (size_t i);
@@ -206,8 +206,8 @@ public:
bool node_step_through { false }; bool node_step_through { false };
void clear_stored_pcs(); void clear_stored_pcs();
void import_legacy(legacy::stored_town_maps_type& old); void import_legacy(legacy::stored_town_maps_type const &old);
void import_legacy(legacy::stored_outdoor_maps_type& old); void import_legacy(legacy::stored_outdoor_maps_type const &old);
void enter_scenario(const std::string& name); void enter_scenario(const std::string& name);
void refresh_store_items(); void refresh_store_items();
void generate_job_bank(int which, job_bank_t& bank); void generate_job_bank(int which, job_bank_t& bank);