Skip to content

Commit

Permalink
Add battle_config.max_rate limit (500). GMs cannot go above this
Browse files Browse the repository at this point in the history
Blame Ledmitz (:
  • Loading branch information
specing committed Apr 11, 2024
1 parent dc9c104 commit 45d4a85
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
63 changes: 35 additions & 28 deletions src/map/atcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 45d4a85

Please sign in to comment.