diff --git a/src/boe.monster.cpp b/src/boe.monster.cpp index 3c2091b5..a3bc2724 100644 --- a/src/boe.monster.cpp +++ b/src/boe.monster.cpp @@ -54,7 +54,7 @@ void create_wand_monst() { place_outd_wand_monst(univ.out->wandering_locs[r2], univ.out->wandering[r1],0); } } else if(!univ.town->wandering[r1].isNull() && univ.town.countMonsters() <= 50 - && univ.party.m_killed[univ.town.num] < univ.town->max_num_monst) { + && !univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num])) { // won't place wandering if more than 50 monsters r2 = get_ran(1,0,univ.town->wandering.size() - 1); while(point_onscreen(univ.town->wandering_locs[r2],univ.town.p_loc) && diff --git a/src/boe.town.cpp b/src/boe.town.cpp index a4357286..10dec770 100644 --- a/src/boe.town.cpp +++ b/src/boe.town.cpp @@ -221,7 +221,7 @@ void start_town_mode(short which_town, short entry_dir) { // TODO: Should these two cases be separated? if(univ.town->town_chop_time > 0 && day_reached(univ.town->town_chop_time,univ.town->town_chop_key)) univ.town.monst[i].active += 10; - else if(univ.party.m_killed[univ.town.num] > univ.town->max_num_monst) + else if(univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num])) univ.town.monst[i].active += 10; else univ.town.monst[i].active = 0; if(univ.town.monst[i].active >= 10) @@ -291,7 +291,7 @@ void start_town_mode(short which_town, short entry_dir) { // TODO: Should these two cases be separated? if(univ.town->town_chop_time > 0 && day_reached(univ.town->town_chop_time,univ.town->town_chop_key)) univ.town.monst[i].active += 10; - else if(univ.party.m_killed[univ.town.num] > univ.town->max_num_monst) + else if(univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num])) univ.town.monst[i].active += 10; else univ.town.monst[i].active = 0; break; @@ -320,7 +320,7 @@ void start_town_mode(short which_town, short entry_dir) { // Thrash town? - if(univ.party.m_killed[univ.town.num] > univ.town->max_num_monst) { + if(univ.town->is_cleaned_out(univ.party.m_killed[univ.town.num])) { town_toast = true; add_string_to_buf("Area has been cleaned out."); } diff --git a/src/classes/party.hpp b/src/classes/party.hpp index b0a31ab7..f3c4c225 100644 --- a/src/classes/party.hpp +++ b/src/classes/party.hpp @@ -110,7 +110,7 @@ public: std::vector party_event_timers; std::set spec_items; std::set help_received; - short m_killed[200]; // monsters killed per town, I think + long m_killed[200]; // monsters killed per town long long total_m_killed, total_dam_done, total_xp_gained, total_dam_taken; std::string scen_name; private: diff --git a/src/classes/town.cpp b/src/classes/town.cpp index 680fcb54..296b5d9b 100644 --- a/src/classes/town.cpp +++ b/src/classes/town.cpp @@ -179,6 +179,11 @@ bool cTown::cWandering::isNull(){ return true; } +bool cTown::is_cleaned_out(long m_killed) { + if(max_num_monst < 0) return false; + return m_killed >= max_num_monst; +} + void cTown::set_up_lights() { using namespace std::placeholders; short rad; diff --git a/src/classes/town.hpp b/src/classes/town.hpp index d5b60465..525b2c03 100644 --- a/src/classes/town.hpp +++ b/src/classes/town.hpp @@ -76,7 +76,7 @@ public: rectangle in_town_rect; std::vector preset_items; std::vector creatures; - short max_num_monst; + long max_num_monst; std::vector preset_fields; short spec_on_entry,spec_on_entry_if_dead; short spec_on_hostile; @@ -104,6 +104,7 @@ public: void init_start(); void set_up_lights(); short light_obscurity(short x,short y); // Obscurity function used for calculating lighting + bool is_cleaned_out(long m_killed); explicit cTown(cScenario& scenario); void append(legacy::town_record_type& old);