DRY food/gold maximums. fix #79

This commit is contained in:
2025-02-15 23:40:14 -06:00
committed by Celtic Minstrel
parent cff8200f02
commit c6f06ea862
3 changed files with 8 additions and 5 deletions

View File

@@ -1105,16 +1105,16 @@ void elim_monst(unsigned short which,short spec_a,short spec_b) {
//short print_mes; // 0 - no 1 - yes
void dump_gold(short print_mes) {
// Mildly kludgy gold check
if(univ.party.gold > 30000) {
univ.party.gold = 30000;
if(univ.party.gold > MAX_GOLD) {
univ.party.gold = MAX_GOLD;
if(print_mes == 1) {
put_pc_screen();
add_string_to_buf("Excess gold dropped.");
print_buf();
}
}
if(univ.party.food > 25000) {
univ.party.food = 25000;
if(univ.party.food > MAX_FOOD) {
univ.party.food = MAX_FOOD;
if(print_mes == 1) {
put_pc_screen();
add_string_to_buf("Excess food dropped.");

View File

@@ -35,6 +35,9 @@ namespace boost { namespace filesystem {} namespace process {}}
namespace fs = boost::filesystem;
namespace bp = boost::process;
// Limits
const int MAX_GOLD = 30000;
const int MAX_FOOD = 25000;
inline bool str_to_bool(std::string str) {
return str == "true";

View File

@@ -115,7 +115,7 @@ void edit_gold_or_food(short which_to_edit) {
dlog["number"].setTextToNum((which_to_edit == 0) ? univ.party.gold : univ.party.food);
dlog.run();
int dialog_answer = minmax(0,25000,dlog.getResult<long long>());
int dialog_answer = minmax(0,which_to_edit == 0 ? MAX_GOLD : MAX_FOOD,dlog.getResult<long long>());
if(which_to_edit == 0)
univ.party.gold = dialog_answer;
else