summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-05-15 12:04:38 -0400
committergumi <mekolat@users.noreply.github.com>2017-05-28 11:51:37 -0400
commita24eeb0c19b5301330fe532ecf575a84c13a6c9b (patch)
tree3aec6e7aabb6318191feeea3479e491cf9afb50d /src/map/atcommand.c
parent5ceccb77064b557a2f616040f937417c8f002a72 (diff)
downloadhercules-a24eeb0c19b5301330fe532ecf575a84c13a6c9b.tar.gz
hercules-a24eeb0c19b5301330fe532ecf575a84c13a6c9b.tar.bz2
hercules-a24eeb0c19b5301330fe532ecf575a84c13a6c9b.tar.xz
hercules-a24eeb0c19b5301330fe532ecf575a84c13a6c9b.zip
add support for custom atcommands in can_use_command
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 221e9a311..19a7e360b 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -10228,31 +10228,34 @@ void atcommand_db_load_groups(GroupSettings **groups, struct config_setting_t **
}
bool atcommand_can_use(struct map_session_data *sd, const char *command) {
- AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1));
+ AtCommandInfo *acmd_d;
+ struct atcmd_binding_data *bcmd_d;
nullpo_retr(false, sd);
- nullpo_retr(false, command);
- if (info == NULL)
- return false;
- if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] != 0) ||
- (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] != 0) ) {
- return true;
+ if ((acmd_d = atcommand->get_info_byname(atcommand->check_alias(command + 1))) != NULL) {
+ return ((*command == atcommand->at_symbol && acmd_d->at_groups[pcg->get_idx(sd->group)] > 0) ||
+ (*command == atcommand->char_symbol && acmd_d->char_groups[pcg->get_idx(sd->group)] > 0));
+ } else if ((bcmd_d = atcommand->get_bind_byname(atcommand->check_alias(command + 1))) != NULL) {
+ return ((*command == atcommand->at_symbol && bcmd_d->at_groups[pcg->get_idx(sd->group)] > 0) ||
+ (*command == atcommand->char_symbol && bcmd_d->char_groups[pcg->get_idx(sd->group)] > 0));
}
return false;
}
+
bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) {
- AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command));
+ AtCommandInfo *acmd_d;
+ struct atcmd_binding_data *bcmd_d;
nullpo_retr(false, sd);
- nullpo_retr(false, command);
- if (info == NULL)
- return false;
- if ((type == COMMAND_ATCOMMAND && info->at_groups[pcg->get_idx(sd->group)] != 0) ||
- (type == COMMAND_CHARCOMMAND && info->char_groups[pcg->get_idx(sd->group)] != 0) ) {
- return true;
+ if ((acmd_d = atcommand->get_info_byname(atcommand->check_alias(command))) != NULL) {
+ return ((type == COMMAND_ATCOMMAND && acmd_d->at_groups[pcg->get_idx(sd->group)] > 0) ||
+ (type == COMMAND_CHARCOMMAND && acmd_d->char_groups[pcg->get_idx(sd->group)] > 0));
+ } else if ((bcmd_d = atcommand->get_bind_byname(atcommand->check_alias(command))) != NULL) {
+ return ((type == COMMAND_ATCOMMAND && bcmd_d->at_groups[pcg->get_idx(sd->group)] > 0) ||
+ (type == COMMAND_CHARCOMMAND && bcmd_d->char_groups[pcg->get_idx(sd->group)] > 0));
}
return false;