DRY food/gold maximums. fix #79
This commit is contained in:
@@ -1105,16 +1105,16 @@ void elim_monst(unsigned short which,short spec_a,short spec_b) {
|
|||||||
//short print_mes; // 0 - no 1 - yes
|
//short print_mes; // 0 - no 1 - yes
|
||||||
void dump_gold(short print_mes) {
|
void dump_gold(short print_mes) {
|
||||||
// Mildly kludgy gold check
|
// Mildly kludgy gold check
|
||||||
if(univ.party.gold > 30000) {
|
if(univ.party.gold > MAX_GOLD) {
|
||||||
univ.party.gold = 30000;
|
univ.party.gold = MAX_GOLD;
|
||||||
if(print_mes == 1) {
|
if(print_mes == 1) {
|
||||||
put_pc_screen();
|
put_pc_screen();
|
||||||
add_string_to_buf("Excess gold dropped.");
|
add_string_to_buf("Excess gold dropped.");
|
||||||
print_buf();
|
print_buf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(univ.party.food > 25000) {
|
if(univ.party.food > MAX_FOOD) {
|
||||||
univ.party.food = 25000;
|
univ.party.food = MAX_FOOD;
|
||||||
if(print_mes == 1) {
|
if(print_mes == 1) {
|
||||||
put_pc_screen();
|
put_pc_screen();
|
||||||
add_string_to_buf("Excess food dropped.");
|
add_string_to_buf("Excess food dropped.");
|
||||||
|
@@ -35,6 +35,9 @@ namespace boost { namespace filesystem {} namespace process {}}
|
|||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
namespace bp = boost::process;
|
namespace bp = boost::process;
|
||||||
|
|
||||||
|
// Limits
|
||||||
|
const int MAX_GOLD = 30000;
|
||||||
|
const int MAX_FOOD = 25000;
|
||||||
|
|
||||||
inline bool str_to_bool(std::string str) {
|
inline bool str_to_bool(std::string str) {
|
||||||
return str == "true";
|
return str == "true";
|
||||||
|
@@ -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["number"].setTextToNum((which_to_edit == 0) ? univ.party.gold : univ.party.food);
|
||||||
|
|
||||||
dlog.run();
|
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)
|
if(which_to_edit == 0)
|
||||||
univ.party.gold = dialog_answer;
|
univ.party.gold = dialog_answer;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user