diff options
author | Fedja Beader <fedja@protonmail.ch> | 2024-04-12 01:13:10 +0200 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-04-12 01:14:11 +0200 |
commit | 45d4a85fe4b9e6804a454daab19bd41638aec874 (patch) | |
tree | bec39f653e5ab1822a3a8c6bc8167a1e8a4b06ab | |
parent | dc9c104ad231e6ba9f695072d36d586e2e3d3d4c (diff) | |
download | tmwa-45d4a85fe4b9e6804a454daab19bd41638aec874.tar.gz tmwa-45d4a85fe4b9e6804a454daab19bd41638aec874.tar.bz2 tmwa-45d4a85fe4b9e6804a454daab19bd41638aec874.tar.xz tmwa-45d4a85fe4b9e6804a454daab19bd41638aec874.zip |
Add battle_config.max_rate limit (500). GMs cannot go above this
Blame Ledmitz (:
-rw-r--r-- | src/map/atcommand.cpp | 63 | ||||
-rwxr-xr-x | tools/config.py | 1 |
2 files changed, 36 insertions, 28 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 20743dd..311ca76 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -1667,20 +1667,38 @@ ATCE atcommand_pvpoff(Session *s, dumb_ptr<map_session_data> sd, return ATCE::OKAY; } + + +static int extract_rate(Session *s, ZString message) +{ + int rate; + AString output; + + if (!extract(message, &rate)) + { + clif_displaymessage(s, "Please enter the new rate"_s); + return -1; + } + if (rate <= 0 || rate > battle_config.max_rate) + { + output = STRPRINTF("Rate adjustment must be between 1 and %d%%"_fmt, + battle_config.max_rate); + clif_displaymessage(s, output); + return -1; + } + return rate; +} + // Command not removed during bexprate/jexprate split // because serverdata calls it. static ATCE atcommand_exprate(Session *s, dumb_ptr<map_session_data>, ZString message) { - int rate; - - if (!extract(message, &rate) || !rate) - { - clif_displaymessage(s, - "Please, enter a rate adjustement (usage: @exprate <percent>)."_s); + int rate = extract_rate(s, message); + if (rate < 0) return ATCE::USAGE; - } + battle_config.base_exp_rate = rate; battle_config.job_exp_rate = rate; AString output = STRPRINTF("Base & job XP rates now at %d percent"_fmt, rate); @@ -1692,14 +1710,10 @@ static ATCE atcommand_bexprate(Session *s, dumb_ptr<map_session_data>, ZString message) { - int rate; - - if (!extract(message, &rate) || !rate) - { - clif_displaymessage(s, - "Please, enter a rate adjustement (usage: @bexprate <percent>)."_s); + int rate = extract_rate(s, message); + if (rate < 0) return ATCE::USAGE; - } + battle_config.base_exp_rate = rate; AString output = STRPRINTF("Base XP rate now at %d percent"_fmt, rate); clif_displaymessage(s, output); @@ -1710,14 +1724,10 @@ static ATCE atcommand_jexprate(Session *s, dumb_ptr<map_session_data>, ZString message) { - int rate; - - if (!extract(message, &rate) || !rate) - { - clif_displaymessage(s, - "Please, enter a rate adjustement (usage: @jexprate <percent>)."_s); + int rate = extract_rate(s, message); + if (rate < 0) return ATCE::USAGE; - } + battle_config.job_exp_rate = rate; AString output = STRPRINTF("Job XP rate now at %d percent"_fmt, rate); clif_displaymessage(s, output); @@ -1728,14 +1738,10 @@ static ATCE atcommand_droprate(Session *s, dumb_ptr<map_session_data>, ZString message) { - int rate; - - if (!extract(message, &rate) || !rate) - { - clif_displaymessage(s, - "Please, enter a rate adjustement (usage: @droprate <percent>)."_s); + int rate = extract_rate(s, message); + if (rate < 0) return ATCE::USAGE; - } + battle_config.drop_rate = rate; AString output = STRPRINTF("Drops rate now at %d percent"_fmt, rate); clif_displaymessage(s, output); @@ -1754,6 +1760,7 @@ ATCE atcommand_rates(Session *s, dumb_ptr<map_session_data>, return ATCE::OKAY; } + static ATCE atcommand_pvpon(Session *s, dumb_ptr<map_session_data> sd, ZString) diff --git a/tools/config.py b/tools/config.py index 49339bd..2f0781d 100755 --- a/tools/config.py +++ b/tools/config.py @@ -602,6 +602,7 @@ def build_config(): battle_conf.opt('base_exp_rate', percent, '100') battle_conf.opt('job_exp_rate', percent, '100') battle_conf.opt('drop_rate', percent, '100') + battle_conf.opt('max_rate', percent, '500') battle_conf.opt('death_penalty_type', i32, '0', min='0', max='2') battle_conf.opt('death_penalty_base', per10kd, '0') battle_conf.opt('death_penalty_job', per10kd, '0') |