Delete cCurTown::difficulty

It seemed like it was intended as a mirror of cTown::difficulty, yet there didn't seem to
be anything that ever wrote to it.
So I just made everything use cTown::difficulty directly instead.
This commit is contained in:
2023-01-21 18:10:58 -05:00
parent 929d012aab
commit 992cbdb22c
6 changed files with 18 additions and 20 deletions

View File

@@ -887,7 +887,7 @@ static void handle_town_wait(bool& need_redraw, bool& need_reprint) {
increase_age(); increase_age();
do_monsters(); do_monsters();
do_monster_turn(); do_monster_turn();
int make_wand = get_ran(1,1,160 - univ.town.difficulty); int make_wand = get_ran(1,1,160 - univ.town->difficulty);
if(make_wand == 10) if(make_wand == 10)
create_wand_monst(); create_wand_monst();
for(int j = 0; j < 6; j++) for(int j = 0; j < 6; j++)
@@ -1491,7 +1491,7 @@ void handle_monster_actions(bool& need_redraw, bool& need_reprint) {
} }
} }
if(overall_mode == MODE_TOWN) { if(overall_mode == MODE_TOWN) {
if(get_ran(1,1,160 - univ.town.difficulty + univ.party.less_wm * 200) == 2) if(get_ran(1,1,160 - univ.town->difficulty + univ.party.less_wm * 200) == 2)
create_wand_monst(); create_wand_monst();
} }
} }

View File

@@ -1301,7 +1301,7 @@ void cast_town_spell(location where) {
if(univ.scenario.ter_types[ter].flag2 == 10) if(univ.scenario.ter_types[ter].flag2 == 10)
r1 = 10000; r1 = 10000;
else{ else{
r1 = get_ran(1,1,100) - 5 * adj + 5 * univ.town.difficulty; r1 = get_ran(1,1,100) - 5 * adj + 5 * univ.town->difficulty;
r1 += univ.scenario.ter_types[ter].flag2 * 7; r1 += univ.scenario.ter_types[ter].flag2 * 7;
} }
if(r1 < (135 - combat_percent[min(19,level)])) { if(r1 < (135 - combat_percent[min(19,level)])) {
@@ -1319,7 +1319,7 @@ void cast_town_spell(location where) {
case eSpell::DISPEL_BARRIER: case eSpell::DISPEL_BARRIER:
if((univ.town.is_fire_barr(where.x,where.y)) || (univ.town.is_force_barr(where.x,where.y))) { if((univ.town.is_fire_barr(where.x,where.y)) || (univ.town.is_force_barr(where.x,where.y))) {
r1 = get_ran(1,1,100) - 5 * adj + 5 * (univ.town.difficulty / 10) + 25 * univ.town->strong_barriers; r1 = get_ran(1,1,100) - 5 * adj + 5 * (univ.town->difficulty / 10) + 25 * univ.town->strong_barriers;
if(univ.town.is_fire_barr(where.x,where.y)) if(univ.town.is_fire_barr(where.x,where.y))
r1 -= 8; r1 -= 8;
if(r1 < (120 - combat_percent[min(19,level)])) { if(r1 < (120 - combat_percent[min(19,level)])) {

View File

@@ -1149,7 +1149,7 @@ void pick_lock(location where,short pc_num) {
if(r1 < 75) if(r1 < 75)
will_break = true; will_break = true;
r1 = get_ran(1,1,100) - 5 * univ.party[pc_num].stat_adj(eSkill::DEXTERITY) + univ.town.difficulty * 7 r1 = get_ran(1,1,100) - 5 * univ.party[pc_num].stat_adj(eSkill::DEXTERITY) + univ.town->difficulty * 7
- 5 * univ.party[pc_num].skill(eSkill::LOCKPICKING) - which_item->abil_strength * 7; - 5 * univ.party[pc_num].skill(eSkill::LOCKPICKING) - which_item->abil_strength * 7;
// Nimble? // Nimble?
@@ -1186,7 +1186,7 @@ void bash_door(location where,short pc_num) {
short r1,unlock_adjust; short r1,unlock_adjust;
terrain = univ.town->terrain(where.x,where.y); terrain = univ.town->terrain(where.x,where.y);
r1 = get_ran(1,1,100) - 15 * univ.party[pc_num].stat_adj(eSkill::STRENGTH) + univ.town.difficulty * 4; r1 = get_ran(1,1,100) - 15 * univ.party[pc_num].stat_adj(eSkill::STRENGTH) + univ.town->difficulty * 4;
if(univ.scenario.ter_types[terrain].special != eTerSpec::UNLOCKABLE) { if(univ.scenario.ter_types[terrain].special != eTerSpec::UNLOCKABLE) {
add_string_to_buf(" Wrong terrain type."); add_string_to_buf(" Wrong terrain type.");

View File

@@ -57,7 +57,7 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) {
int i = disarmer.stat_adj(eSkill::DEXTERITY); int i = disarmer.stat_adj(eSkill::DEXTERITY);
i += disarmer.get_prot_level(eItemAbil::THIEVING) / 2; i += disarmer.get_prot_level(eItemAbil::THIEVING) / 2;
skill = minmax(0,20,disarmer.skill(eSkill::DISARM_TRAPS) + skill = minmax(0,20,disarmer.skill(eSkill::DISARM_TRAPS) +
+ disarmer.skill(eSkill::LUCK) / 2 + 1 - univ.town.difficulty + 2 * i); + disarmer.skill(eSkill::LUCK) / 2 + 1 - univ.town->difficulty + 2 * i);
r1 = get_ran(1,1,100) + diff; r1 = get_ran(1,1,100) + diff;
// Nimble? // Nimble?
@@ -76,21 +76,21 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) {
case TRAP_BLADE: case TRAP_BLADE:
for(short i = 0; i < num_hits; i++) { for(short i = 0; i < num_hits; i++) {
add_string_to_buf(" A knife flies out!"); add_string_to_buf(" A knife flies out!");
r1 = get_ran(2 + univ.town.difficulty / 14,1,10); r1 = get_ran(2 + univ.town->difficulty / 14,1,10);
damage_pc(disarmer,r1,eDamageType::WEAPON,eRace::UNKNOWN,0); damage_pc(disarmer,r1,eDamageType::WEAPON,eRace::UNKNOWN,0);
} }
break; break;
case TRAP_DART: case TRAP_DART:
add_string_to_buf(" A dart flies out."); add_string_to_buf(" A dart flies out.");
r1 = 3 + univ.town.difficulty / 14; r1 = 3 + univ.town->difficulty / 14;
r1 = r1 + trap_level * 2; r1 = r1 + trap_level * 2;
disarmer.poison(r1); disarmer.poison(r1);
break; break;
case TRAP_GAS: case TRAP_GAS:
add_string_to_buf(" Poison gas pours out."); add_string_to_buf(" Poison gas pours out.");
r1 = 2 + univ.town.difficulty / 14; r1 = 2 + univ.town->difficulty / 14;
r1 = r1 + trap_level * 2; r1 = r1 + trap_level * 2;
univ.party.poison(r1); univ.party.poison(r1);
break; break;
@@ -98,14 +98,14 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) {
case TRAP_EXPLOSION: case TRAP_EXPLOSION:
for(short i = 0; i < num_hits; i++) { for(short i = 0; i < num_hits; i++) {
add_string_to_buf(" There is an explosion."); add_string_to_buf(" There is an explosion.");
r1 = get_ran(3 + univ.town.difficulty / 13,1,8); r1 = get_ran(3 + univ.town->difficulty / 13,1,8);
hit_party(r1,eDamageType::FIRE); hit_party(r1,eDamageType::FIRE);
} }
break; break;
case TRAP_SLEEP_RAY: case TRAP_SLEEP_RAY:
add_string_to_buf(" A purple ray flies out."); add_string_to_buf(" A purple ray flies out.");
r1 = 200 + univ.town.difficulty * 100; r1 = 200 + univ.town->difficulty * 100;
r1 = r1 + trap_level * 400; r1 = r1 + trap_level * 400;
// TODO: It says sleep ray but is actually paralysis ray? // TODO: It says sleep ray but is actually paralysis ray?
disarmer.sleep(eStatus::PARALYZED, r1, 50); disarmer.sleep(eStatus::PARALYZED, r1, 50);
@@ -135,14 +135,14 @@ bool run_trap(short pc_num,eTrapType trap_type,short trap_level,short diff) {
case TRAP_DISEASE: case TRAP_DISEASE:
add_string_to_buf(" You prick your finger."); add_string_to_buf(" You prick your finger.");
r1 = 3 + univ.town.difficulty / 14; r1 = 3 + univ.town->difficulty / 14;
r1 = r1 + trap_level * 2; r1 = r1 + trap_level * 2;
disarmer.disease(r1); disarmer.disease(r1);
break; break;
case TRAP_DISEASE_ALL: case TRAP_DISEASE_ALL:
add_string_to_buf(" A foul substance sprays out."); add_string_to_buf(" A foul substance sprays out.");
r1 = 2 + univ.town.difficulty / 14; r1 = 2 + univ.town->difficulty / 14;
r1 = r1 + trap_level * 2; r1 = r1 + trap_level * 2;
univ.party.disease(r1); univ.party.disease(r1);
break; break;

View File

@@ -29,8 +29,9 @@ void cCurOut::import_legacy(legacy::out_info_type& old){
void cCurTown::import_legacy(legacy::current_town_type& old){ void cCurTown::import_legacy(legacy::current_town_type& old){
univ.party.town_num = old.town_num; univ.party.town_num = old.town_num;
difficulty = old.difficulty;
record()->import_legacy(old.town); record()->import_legacy(old.town);
// TODO: Is this right? Was current_town_type::difficulty just a mirror of town difficulty?
record()->difficulty = old.difficulty;
for(int i = 0; i < 64; i++) for(int i = 0; i < 64; i++)
for(int j = 0; j < 64; j++) for(int j = 0; j < 64; j++)
fields[i][j] = old.explored[i][j]; fields[i][j] = old.explored[i][j];
@@ -824,7 +825,7 @@ void cCurOut::readFrom(std::istream& file) {
void cCurTown::writeTo(cTagFile& file) const { void cCurTown::writeTo(cTagFile& file) const {
auto& page = file.add(); auto& page = file.add();
page["TOWN"] << univ.party.town_num; page["TOWN"] << univ.party.town_num;
page["DIFFICULTY"] << difficulty; page["DIFFICULTY"] << record()->difficulty;
if(monst.hostile) page.add("HOSTILE"); if(monst.hostile) page.add("HOSTILE");
page["AT"] << univ.party.town_loc.x << univ.party.town_loc.y; page["AT"] << univ.party.town_loc.x << univ.party.town_loc.y;
for(size_t i = 0; i < items.size(); i++) { for(size_t i = 0; i < items.size(); i++) {
@@ -851,7 +852,7 @@ void cCurTown::readFrom(const cTagFile& file){
for(const auto& page : file) { for(const auto& page : file) {
if(page.index() == 0) { if(page.index() == 0) {
page["TOWN"] >> univ.party.town_num; page["TOWN"] >> univ.party.town_num;
page["DIFFICULTY"] >> difficulty; page["DIFFICULTY"] >> record()->difficulty;
monst.hostile = page.contains("HOSTILE"); monst.hostile = page.contains("HOSTILE");
page["AT"] >> univ.party.town_loc.x >> univ.party.town_loc.y; page["AT"] >> univ.party.town_loc.x >> univ.party.town_loc.y;
} else if(page.getFirstKey() == "FIELDS" || page.getFirstKey() == "TERRAIN") { } else if(page.getFirstKey() == "FIELDS" || page.getFirstKey() == "TERRAIN") {
@@ -982,7 +983,6 @@ void cCurTown::copy(const cCurTown& other) {
cur_talk_loaded = other.cur_talk_loaded; cur_talk_loaded = other.cur_talk_loaded;
quickfire_present = other.quickfire_present; quickfire_present = other.quickfire_present;
belt_present = other.belt_present; belt_present = other.belt_present;
difficulty = other.difficulty;
monst = other.monst; monst = other.monst;
items = other.items; items = other.items;
fields = other.fields; fields = other.fields;
@@ -992,7 +992,6 @@ void cCurTown::swap(cCurTown& other) {
std::swap(cur_talk_loaded, other.cur_talk_loaded); std::swap(cur_talk_loaded, other.cur_talk_loaded);
std::swap(quickfire_present, other.quickfire_present); std::swap(quickfire_present, other.quickfire_present);
std::swap(belt_present, other.belt_present); std::swap(belt_present, other.belt_present);
std::swap(difficulty, other.difficulty);
monst.swap(other.monst); monst.swap(other.monst);
std::swap(items, other.items); std::swap(items, other.items);
fields.swap(other.fields); fields.swap(other.fields);

View File

@@ -43,7 +43,6 @@ class cCurTown {
public: public:
bool quickfire_present = false, belt_present = false; bool quickfire_present = false, belt_present = false;
// formerly current_town_type // formerly current_town_type
short difficulty;
cPopulation monst; cPopulation monst;
std::vector<cItem> items; // formerly town_item_list type std::vector<cItem> items; // formerly town_item_list type