const-correctness in scenario classes
This commit is contained in:
@@ -195,7 +195,7 @@ void cOutdoors::cWandering::readFrom(const cTagFile_Page& page){
|
||||
std::copy_n(temp.begin(), friendly.size(), friendly.begin());
|
||||
}
|
||||
|
||||
bool cOutdoors::cWandering::isNull(){
|
||||
bool cOutdoors::cWandering::isNull() const {
|
||||
for(short i = 0; i < 7; i++)
|
||||
if(monst[i] != 0)
|
||||
return false;
|
||||
|
@@ -45,7 +45,7 @@ public:
|
||||
short end_spec1,end_spec2;
|
||||
bool cant_flee, forced;
|
||||
|
||||
bool isNull();
|
||||
bool isNull() const;
|
||||
void import_legacy(legacy::out_wandering_type old);
|
||||
void writeTo(cTagFile_Page& page) const;
|
||||
void readFrom(const cTagFile_Page& page);
|
||||
|
@@ -304,19 +304,19 @@ static std::string format_version(const unsigned char(& ver)[3]) {
|
||||
return fmt.str();
|
||||
}
|
||||
|
||||
std::string cScenario::format_ed_version() {
|
||||
std::string cScenario::format_ed_version() const {
|
||||
return format_version(format.prog_make_ver);
|
||||
}
|
||||
|
||||
std::string cScenario::format_scen_version() {
|
||||
std::string cScenario::format_scen_version() const {
|
||||
return format_version(format.ver);
|
||||
}
|
||||
|
||||
ter_num_t cScenario::get_ground_from_ter(ter_num_t ter){
|
||||
ter_num_t cScenario::get_ground_from_ter(ter_num_t ter) const {
|
||||
return get_ter_from_ground(ter_types[ter].ground_type);
|
||||
}
|
||||
|
||||
ter_num_t cScenario::get_ter_from_ground(unsigned short ground){
|
||||
ter_num_t cScenario::get_ter_from_ground(unsigned short ground) const {
|
||||
ter_num_t archetype = -1;
|
||||
for(int i = 0; i < ter_types.size(); i++)
|
||||
if(ter_types[i].ground_type == ground) {
|
||||
@@ -328,7 +328,7 @@ ter_num_t cScenario::get_ter_from_ground(unsigned short ground){
|
||||
return std::max(archetype, ter_num_t());
|
||||
}
|
||||
|
||||
ter_num_t cScenario::get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim) {
|
||||
ter_num_t cScenario::get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim) const {
|
||||
for(int i = 0; i < ter_types.size(); i++) {
|
||||
if(ter_types[i].ground_type != ground)
|
||||
continue;
|
||||
@@ -341,7 +341,7 @@ ter_num_t cScenario::get_trim_terrain(unsigned short ground, unsigned short trim
|
||||
return 90;
|
||||
}
|
||||
|
||||
bool cScenario::is_ter_used(ter_num_t ter) {
|
||||
bool cScenario::is_ter_used(ter_num_t ter) const {
|
||||
if(ter >= ter_types.size()) return false;
|
||||
if(ter <= 90) return true;
|
||||
for(int sx = 0; sx < outdoors.width(); sx++) {
|
||||
@@ -365,7 +365,7 @@ bool cScenario::is_ter_used(ter_num_t ter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cScenario::is_monst_used(mon_num_t monst) {
|
||||
bool cScenario::is_monst_used(mon_num_t monst) const {
|
||||
if(monst >= scen_monsters.size()) return false;
|
||||
for(int sx = 0; sx < outdoors.width(); sx++) {
|
||||
for(int sy = 0; sy < outdoors.height(); sy++) {
|
||||
@@ -400,7 +400,7 @@ bool cScenario::is_monst_used(mon_num_t monst) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cScenario::is_item_used(item_num_t item) {
|
||||
bool cScenario::is_item_used(item_num_t item) const {
|
||||
if(item >= scen_items.size()) return false;
|
||||
for(int i = 0; i < towns.size(); i++) {
|
||||
for(int j = 0; j < towns[i]->preset_items.size(); j++) {
|
||||
@@ -411,7 +411,7 @@ bool cScenario::is_item_used(item_num_t item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cItem cScenario::get_stored_item(int loot) {
|
||||
cItem cScenario::get_stored_item(int loot) const {
|
||||
if(loot >= 0 && loot < scen_items.size())
|
||||
return scen_items[loot];
|
||||
return cItem();
|
||||
@@ -420,7 +420,7 @@ cItem cScenario::get_stored_item(int loot) {
|
||||
static const short loot_min[5] = {0,0,5,50,400};
|
||||
static const short loot_max[5] = {3,8,40,800,4000};
|
||||
|
||||
cItem cScenario::pull_item_of_type(unsigned int loot_max,short min_val,short max_val, const std::vector<eItemType>& types,bool allow_junk_treasure) {
|
||||
cItem cScenario::pull_item_of_type(unsigned int loot_max,short min_val,short max_val, const std::vector<eItemType>& types,bool allow_junk_treasure) const {
|
||||
// occasionally get nice item
|
||||
if(get_ran(1,0,160) == 80) {
|
||||
loot_max += 2;
|
||||
@@ -444,7 +444,7 @@ enum eTreasureType {
|
||||
SCROLL, WAND, RING, NECKLACE, POISON, GLOVES, BOOTS,
|
||||
};
|
||||
|
||||
cItem cScenario::return_treasure(int loot, bool allow_junk) {
|
||||
cItem cScenario::return_treasure(int loot, bool allow_junk) const {
|
||||
static const std::vector<eItemType>
|
||||
weapon = {eItemType::ONE_HANDED,eItemType::TWO_HANDED},
|
||||
armor = {eItemType::ARMOR}, shield = {eItemType::SHIELD}, helm = {eItemType::HELM},
|
||||
|
@@ -100,21 +100,21 @@ public:
|
||||
void import_legacy(legacy::scen_item_data_type& old);
|
||||
void writeTo(cTagFile& file) const;
|
||||
void readFrom(const cTagFile& file);
|
||||
std::string format_scen_version();
|
||||
std::string format_ed_version();
|
||||
std::string format_scen_version() const;
|
||||
std::string format_ed_version() const;
|
||||
|
||||
ter_num_t get_ground_from_ter(ter_num_t ter);
|
||||
ter_num_t get_ter_from_ground(unsigned short ground);
|
||||
ter_num_t get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim);
|
||||
ter_num_t get_ground_from_ter(ter_num_t ter) const;
|
||||
ter_num_t get_ter_from_ground(unsigned short ground) const;
|
||||
ter_num_t get_trim_terrain(unsigned short ground, unsigned short trim_g, eTrimType trim) const;
|
||||
cOutdoors& get_sector(int x, int y);
|
||||
bool is_town_entrance_valid(spec_loc_t loc) const;
|
||||
|
||||
bool is_ter_used(ter_num_t ter);
|
||||
bool is_monst_used(mon_num_t monst);
|
||||
bool is_item_used(item_num_t item);
|
||||
cItem get_stored_item(int loot);
|
||||
cItem return_treasure(int loot, bool allow_junk_treasure = false);
|
||||
cItem pull_item_of_type(unsigned int loot_max,short min_val,short max_val,const std::vector<eItemType>& types,bool allow_junk_treasure=false);
|
||||
bool is_ter_used(ter_num_t ter) const;
|
||||
bool is_monst_used(mon_num_t monst) const;
|
||||
bool is_item_used(item_num_t item) const;
|
||||
cItem get_stored_item(int loot) const;
|
||||
cItem return_treasure(int loot, bool allow_junk_treasure = false) const;
|
||||
cItem pull_item_of_type(unsigned int loot_max,short min_val,short max_val,const std::vector<eItemType>& types,bool allow_junk_treasure=false) const;
|
||||
|
||||
void reset_version();
|
||||
explicit cScenario();
|
||||
|
@@ -85,7 +85,7 @@ cShop::cShop(eShopPreset preset) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t cShop::firstEmpty() {
|
||||
size_t cShop::firstEmpty() const {
|
||||
for(size_t i = 0; i < items.size(); i++) {
|
||||
if(items[i].type == eShopItemType::EMPTY)
|
||||
return i;
|
||||
@@ -320,7 +320,7 @@ void cShop::clear() {
|
||||
items.clear();
|
||||
}
|
||||
|
||||
int cShopItem::getCost(int adj) {
|
||||
int cShopItem::getCost(int adj) const {
|
||||
int cost = item.value;
|
||||
if(item.charges > 0)
|
||||
cost *= item.charges;
|
||||
|
@@ -53,7 +53,7 @@ struct cShopItem {
|
||||
eShopItemType type = eShopItemType::EMPTY;
|
||||
size_t quantity, index;
|
||||
cItem item{ITEM_SHOP};
|
||||
int getCost(int adj);
|
||||
int getCost(int adj) const;
|
||||
};
|
||||
|
||||
enum eShopPreset {SHOP_HEALING, SHOP_JUNK};
|
||||
@@ -65,7 +65,7 @@ class cShop {
|
||||
eShopType type;
|
||||
eShopPrompt prompt;
|
||||
pic_num_t face;
|
||||
size_t firstEmpty();
|
||||
size_t firstEmpty() const;
|
||||
public:
|
||||
static const size_t INFINITE = 0;
|
||||
cShop();
|
||||
|
@@ -166,14 +166,14 @@ void cTown::cField::import_legacy(legacy::preset_field_type old){
|
||||
}
|
||||
}
|
||||
|
||||
bool cTown::cWandering::isNull(){
|
||||
bool cTown::cWandering::isNull() const {
|
||||
for(short i = 0;i < 4;i++)
|
||||
if(monst[i] != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cTown::is_cleaned_out() {
|
||||
bool cTown::is_cleaned_out() const {
|
||||
if(max_num_monst < 0) return false;
|
||||
return m_killed >= max_num_monst;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ void cTown::set_up_lights() {
|
||||
}
|
||||
}
|
||||
|
||||
short cTown::light_obscurity(short x,short y) {
|
||||
short cTown::light_obscurity(short x,short y) const {
|
||||
if(!is_on_map(loc(x,y))) return 5;
|
||||
ter_num_t what_terrain = this->terrain(x,y);
|
||||
eTerObstruct store = scenario->ter_types[what_terrain].blockage;
|
||||
|
@@ -49,7 +49,7 @@ public:
|
||||
public:
|
||||
std::array<mon_num_t,4> monst;
|
||||
|
||||
bool isNull();
|
||||
bool isNull() const;
|
||||
void import_legacy(legacy::wandering_type old);
|
||||
};
|
||||
class cItem { // formerly preset_item_type
|
||||
@@ -107,8 +107,8 @@ public:
|
||||
void import_legacy(T& old, int town_num);
|
||||
void init_start();
|
||||
void set_up_lights();
|
||||
short light_obscurity(short x,short y); // Obscurity function used for calculating lighting
|
||||
bool is_cleaned_out();
|
||||
short light_obscurity(short x,short y) const; // Obscurity function used for calculating lighting
|
||||
bool is_cleaned_out() const;
|
||||
|
||||
explicit cTown(cScenario& scenario, size_t dim);
|
||||
void import_legacy(legacy::town_record_type& old);
|
||||
|
Reference in New Issue
Block a user