From be9ffaf7e6872e8f87fafdfaceeac26d4a6e308d Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Mon, 7 Jul 2014 12:26:07 +0700 Subject: [PATCH] - Fixed 'atcommand' script failure for group with 'command_enable: false' (bugreport:9050) - Replaced 'atcommand_max_stat_bypass' config (conf/gm.conf) to group permission 'bypass_max_stat' Signed-off-by: Cydh Ramdh --- conf/battle/gm.conf | 4 ---- conf/msg_conf/map_msg.conf | 2 +- doc/permissions.txt | 7 +++++++ src/map/atcommand.c | 6 +++--- src/map/battle.c | 1 - src/map/battle.h | 1 - src/map/pc_groups.c | 4 ++++ src/map/pc_groups.h | 2 ++ src/map/script.c | 3 ++- 9 files changed, 19 insertions(+), 11 deletions(-) diff --git a/conf/battle/gm.conf b/conf/battle/gm.conf index 1821561036..6b0aec5f61 100644 --- a/conf/battle/gm.conf +++ b/conf/battle/gm.conf @@ -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 diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index a42925ea38..23a0b9fd4f 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -1452,7 +1452,7 @@ // @addperm 1378: Usage: %s 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 diff --git a/doc/permissions.txt b/doc/permissions.txt index 4c76072e83..7350517d87 100644 --- a/doc/permissions.txt +++ b/doc/permissions.txt @@ -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. + +--------------------------------------- diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 60786cb2e9..b33961070f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -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); @@ -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); @@ -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 diff --git a/src/map/battle.c b/src/map/battle.c index 0da9c007c4..0d5023f95b 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -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 }, diff --git a/src/map/battle.h b/src/map/battle.h index ad580de5e2..32c1bbdd61 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -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; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 115c41c1fd..2dacf88623 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -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) { diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h index 7bcb7c1818..12e6ecf9cc 100644 --- a/src/map/pc_groups.h +++ b/src/map/pc_groups.h @@ -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, }; @@ -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 }, }; diff --git a/src/map/script.c b/src/map/script.c index fdc44cc225..165d6f3cb4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -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; @@ -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);