Skip to content

Commit

Permalink
- Fixed 'atcommand' script failure for group with 'command_enable: fa…
Browse files Browse the repository at this point in the history
…lse' (bugreport:9050)

- Replaced 'atcommand_max_stat_bypass' config (conf/gm.conf) to group permission 'bypass_max_stat'

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
  • Loading branch information
cydh committed Jul 7, 2014
1 parent fcd79d6 commit be9ffaf
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 11 deletions.
4 changes: 0 additions & 4 deletions conf/battle/gm.conf
Expand Up @@ -18,10 +18,6 @@ atcommand_slave_clone_limit: 25
// current map server.
partial_name_scan: yes

// (@) @allstats/@str/@agi/@vit/@int/@dex/@luk
// allow gms to bypass the maximum stat parameter? ( if yes gm stats can go up to 32k ) default: no
atcommand_max_stat_bypass: no

// Ban people that try trade dupe.
// Duration of the ban, in minutes (default: 5). To disable the ban, set 0.
ban_hack_trade: 5
Expand Down
2 changes: 1 addition & 1 deletion conf/msg_conf/map_msg.conf
Expand Up @@ -1452,7 +1452,7 @@
// @addperm
1378: Usage: %s <permission_name>
1379: -- Permission List
1380: '%s' is not a known permission.
1380: '%s' is unknown permission.
1381: User '%s' already possesses the '%s' permission.
1382: User '%s' doesn't possess the '%s' permission.
1383: -- User '%s' Permissions
Expand Down
7 changes: 7 additions & 0 deletions doc/permissions.txt
Expand Up @@ -199,3 +199,10 @@ Enable to use atcommand while talking with NPC.
Bypass max parameter limit while using @clonestat

---------------------------------------

*bypass_max_stat

Allow to bypass the maximum stat parameter (at conf/player.conf) to
maximum value 32,767.

---------------------------------------
6 changes: 3 additions & 3 deletions src/map/atcommand.c
Expand Up @@ -2523,7 +2523,7 @@ ACMD_FUNC(param)
status[4] = &sd->status.dex;
status[5] = &sd->status.luk;

if( battle_config.atcommand_max_stat_bypass )
if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
else {
max_status[0] = pc_maxparameter(sd,PARAM_STR);
Expand Down Expand Up @@ -2585,7 +2585,7 @@ ACMD_FUNC(stat_all)
max_status[5] = pc_maxparameter(sd,PARAM_LUK);
value = SHRT_MAX;
} else {
if( battle_config.atcommand_max_stat_bypass )
if( pc_has_permission(sd, PC_PERM_BYPASS_MAX_STAT) )
max_status[0] = max_status[1] = max_status[2] = max_status[3] = max_status[4] = max_status[5] = SHRT_MAX;
else {
max_status[0] = pc_maxparameter(sd,PARAM_STR);
Expand Down Expand Up @@ -10073,7 +10073,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
return false;

//If cannot use atcomamnd while talking with NPC [Kichi]
if (sd->npc_id && sd->state.disable_atcommand_on_npc)
if (type == 1 && sd->npc_id && sd->state.disable_atcommand_on_npc)
return false;

//Block NOCHAT but do not display it as a normal message
Expand Down
1 change: 0 additions & 1 deletion src/map/battle.c
Expand Up @@ -7780,7 +7780,6 @@ static const struct _battle_data {
{ "max_trans_parameter", &battle_config.max_trans_parameter, 99, 10, SHRT_MAX, },
{ "max_third_trans_parameter", &battle_config.max_third_trans_parameter, 135, 10, SHRT_MAX, },
{ "max_extended_parameter", &battle_config.max_extended_parameter, 125, 10, SHRT_MAX, },
{ "atcommand_max_stat_bypass", &battle_config.atcommand_max_stat_bypass, 0, 0, 100, },
{ "skill_amotion_leniency", &battle_config.skill_amotion_leniency, 90, 0, 300 },
{ "mvp_tomb_enabled", &battle_config.mvp_tomb_enabled, 1, 0, 1 },
{ "feature.atcommand_suggestions", &battle_config.atcommand_suggestions_enabled, 0, 0, 1 },
Expand Down
1 change: 0 additions & 1 deletion src/map/battle.h
Expand Up @@ -495,7 +495,6 @@ extern struct Battle_Config
int max_trans_parameter;
int max_third_trans_parameter;
int max_extended_parameter;
int atcommand_max_stat_bypass;
int max_third_aspd;
int vcast_stat_scale;

Expand Down
4 changes: 4 additions & 0 deletions src/map/pc_groups.c
Expand Up @@ -344,6 +344,10 @@ bool pc_group_can_use_command(int group_id, const char *command, AtCommandType t
}
return false;
}
/**
* Load permission for player based on group id
* @param sd Player
*/
void pc_group_pc_load(struct map_session_data * sd) {
GroupSettings *group = NULL;
if ((group = id2group(sd->group_id)) == NULL) {
Expand Down
2 changes: 2 additions & 0 deletions src/map/pc_groups.h
Expand Up @@ -48,6 +48,7 @@ enum e_pc_permission {
PC_PERM_ITEM_UNCONDITIONAL = 0x00800000,
PC_PERM_ENABLE_COMMAND = 0x01000000,
PC_PERM_BYPASS_STAT_ONCLONE = 0x02000000,
PC_PERM_BYPASS_MAX_STAT = 0x04000000,
//.. add other here
PC_PERM_ALLPERMISSION = 0xFFFFFFFF,
};
Expand Down Expand Up @@ -82,6 +83,7 @@ static const struct {
{ "item_unconditional", PC_PERM_ITEM_UNCONDITIONAL },
{ "command_enable",PC_PERM_ENABLE_COMMAND },
{ "bypass_stat_onclone",PC_PERM_BYPASS_STAT_ONCLONE },
{ "bypass_max_stat",PC_PERM_BYPASS_MAX_STAT },
{ "all_permission", PC_PERM_ALLPERMISSION },
};

Expand Down
3 changes: 2 additions & 1 deletion src/map/script.c
Expand Up @@ -3769,6 +3769,7 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
if(st->rid && (sd = map_id2sd(st->rid))!=NULL) {
sd->st = st->bk_st;
sd->npc_id = st->bk_npcid;
sd->state.disable_atcommand_on_npc = 0;
if(st->bk_st) {
//Remove tag for removal.
st->bk_st = NULL;
Expand Down Expand Up @@ -3818,7 +3819,7 @@ static void script_attach_state(struct script_state* st)
sd->st = st;
sd->npc_id = st->oid;
sd->npc_item_flag = st->npc_item_flag; // load default.
sd->state.disable_atcommand_on_npc = !pc_has_permission(sd, PC_PERM_ENABLE_COMMAND);
sd->state.disable_atcommand_on_npc = (!pc_has_permission(sd, PC_PERM_ENABLE_COMMAND));
#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer == INVALID_TIMER )
sd->npc_idle_timer = add_timer(gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
Expand Down

0 comments on commit be9ffaf

Please sign in to comment.