summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-01-20 15:50:07 +0100
committerHaru <haru@dotalux.com>2014-01-22 14:50:55 +0100
commit0b96dc2756d97048fc8d4bf2c0eca8ae2555a82e (patch)
treedd9a2d354c61b0514e8a66006187ce5930aace00 /src
parent1da48873bb0c9e29e53528eca04593560bcea57f (diff)
downloadhercules-0b96dc2756d97048fc8d4bf2c0eca8ae2555a82e.tar.gz
hercules-0b96dc2756d97048fc8d4bf2c0eca8ae2555a82e.tar.bz2
hercules-0b96dc2756d97048fc8d4bf2c0eca8ae2555a82e.tar.xz
hercules-0b96dc2756d97048fc8d4bf2c0eca8ae2555a82e.zip
Renamed atcommand->parse to atcommand->exec
- Renamed function to a more appropriate name. - Changed its last argument 'int type' to 'bool player_invoked' to make its purpose more obvious. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c22
-rw-r--r--src/map/atcommand.h2
-rw-r--r--src/map/clif.c42
-rw-r--r--src/map/map.c2
-rw-r--r--src/map/script.c4
5 files changed, 37 insertions, 35 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 31357c074..6177fad23 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -9755,9 +9755,14 @@ void atcommand_get_suggestions(struct map_session_data* sd, const char *name, bo
dbi_destroy(alias_iter);
}
-/// Executes an at-command.
-bool is_atcommand(const int fd, struct map_session_data* sd, const char* message, int type)
-{
+/**
+ * Executes an at-command
+ * @param fd fd associated to the invoking character
+ * @param sd sd associated to the invoking character
+ * @param message atcommand arguments
+ * @param player_invoked true if the command was invoked by a player, false if invoked by the server (bypassing any restrictions)
+ */
+bool atcommand_exec(const int fd, struct map_session_data *sd, const char *message, bool player_invoked) {
char charname[NAME_LENGTH], params[100];
char charname2[NAME_LENGTH], params2[100];
char command[100];
@@ -9787,9 +9792,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
if ( *message != atcommand->at_symbol && *message != atcommand->char_symbol )
return false;
- // type value 0 = server invoked: bypass restrictions
- // 1 = player invoked
- if ( type == 1) {
+ if (player_invoked) {
//Commands are disabled on maps flagged as 'nocommand'
if ( map->list[sd->bl.m].nocommand && pc_get_group_level(sd) < map->list[sd->bl.m].nocommand ) {
clif->message(fd, msg_txt(143));
@@ -9859,7 +9862,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
params[0] = '\0';
// @commands (script based)
- if(type == 1 && atcommand->binding_count > 0) {
+ if(player_invoked && atcommand->binding_count > 0) {
struct atcmd_binding_data * binding;
// Get atcommand binding
@@ -9906,8 +9909,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
return false;
}
- // type == 1 : player invoked
- if (type == 1) {
+ if (player_invoked) {
int i;
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) ) {
@@ -10243,7 +10245,7 @@ void atcommand_defaults(void) {
atcommand->init = do_init_atcommand;
atcommand->final = do_final_atcommand;
- atcommand->parse = is_atcommand;
+ atcommand->exec = atcommand_exec;
atcommand->create = atcommand_hp_add;
atcommand->can_use = atcommand_can_use;
atcommand->can_use2 = atcommand_can_use2;
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 710499a43..f95940924 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -80,7 +80,7 @@ struct atcommand_interface {
void (*init) (bool minimal);
void (*final) (void);
/* */
- bool (*parse) (const int fd, struct map_session_data* sd, const char* message, int type);
+ bool (*exec) (const int fd, struct map_session_data *sd, const char *message, bool player_invoked);
bool (*create) (char *name, AtCommandFunc func);
bool (*can_use) (struct map_session_data *sd, const char *command);
bool (*can_use2) (struct map_session_data *sd, const char *command, AtCommandType type);
diff --git a/src/map/clif.c b/src/map/clif.c
index 975a5aa01..5f835a8ab 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -9814,7 +9814,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( atcommand->parse(fd, sd, message, 1) )
+ if( atcommand->exec(fd, sd, message, true) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -9948,7 +9948,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd)
map_name = (char*)RFIFOP(fd,2);
map_name[MAP_NAME_LENGTH_EXT-1]='\0';
sprintf(command, "%cmapmove %s %d %d", atcommand->at_symbol, map_name, RFIFOW(fd,18), RFIFOW(fd,20));
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -10318,7 +10318,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 1, &target, &namelen, &message, &messagelen) )
return;
- if ( atcommand->parse(fd, sd, message, 1) )
+ if ( atcommand->exec(fd, sd, message, true) )
return;
if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))
@@ -10477,7 +10477,7 @@ void clif_parse_Broadcast(int fd, struct map_session_data* sd) {
mes_len_check(msg, len, CHAT_SIZE_MAX);
sprintf(command, "%ckami %s", atcommand->at_symbol, msg);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -11812,7 +11812,7 @@ void clif_parse_ResetChar(int fd, struct map_session_data *sd) {
else
sprintf(cmd,"%cstreset",atcommand->at_symbol);
- atcommand->parse(fd, sd, cmd, 1);
+ atcommand->exec(fd, sd, cmd, true);
}
@@ -11829,7 +11829,7 @@ void clif_parse_LocalBroadcast(int fd, struct map_session_data* sd)
mes_len_check(msg, len, CHAT_SIZE_MAX);
sprintf(command, "%clkami %s", atcommand->at_symbol, msg);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -12140,7 +12140,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( atcommand->parse(fd, sd, message, 1) )
+ if( atcommand->exec(fd, sd, message, true) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -13200,7 +13200,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( atcommand->parse(fd, sd, message, 1) )
+ if( atcommand->exec(fd, sd, message, true) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
@@ -13415,7 +13415,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) {
{
char command[NAME_LENGTH+6];
sprintf(command, "%ckick %s", atcommand->at_symbol, status->get_name(target));
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
break;
@@ -13460,7 +13460,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) {
void clif_parse_GMKickAll(int fd, struct map_session_data* sd) {
char cmd[15];
sprintf(cmd,"%ckickall",atcommand->at_symbol);
- atcommand->parse(fd, sd, cmd, 1);
+ atcommand->exec(fd, sd, cmd, true);
}
@@ -13480,7 +13480,7 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd)
player_name[NAME_LENGTH-1] = '\0';
sprintf(command, "%cjumpto %s", atcommand->at_symbol, player_name);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -13495,7 +13495,7 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd) {
if( (pl_sd = map->id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
}
@@ -13516,7 +13516,7 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd)
player_name[NAME_LENGTH-1] = '\0';
sprintf(command, "%crecall %s", atcommand->at_symbol, player_name);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -13531,7 +13531,7 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd) {
if( (pl_sd = map->id2sd(account_id)) != NULL ) {
char command[NAME_LENGTH+8];
sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
}
@@ -13576,14 +13576,14 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
snprintf(command, sizeof(command)-1, "%citem2 %d 1 0 0 0 0 0 0 0", atcommand->at_symbol, item_array[i]->nameid);
else
snprintf(command, sizeof(command)-1, "%citem %d 20", atcommand->at_symbol, item_array[i]->nameid);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
return;
}
}
if( strcmp("money", item_monster_name) == 0 ){
snprintf(command, sizeof(command)-1, "%czeny %d", atcommand->at_symbol, INT_MAX);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
return;
}
@@ -13600,7 +13600,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd) {
if( i < count ){
snprintf(command, sizeof(command)-1, "%cmonster %s", atcommand->at_symbol, mob_array[i]->sprite);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
}
}
@@ -13615,7 +13615,7 @@ void clif_parse_GMHide(int fd, struct map_session_data *sd) {
sprintf(cmd,"%chide",atcommand->at_symbol);
- atcommand->parse(fd, sd, cmd, 1);
+ atcommand->exec(fd, sd, cmd, true);
}
@@ -13669,7 +13669,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) {
}
sprintf(command, "%cmute %d %s", atcommand->at_symbol, value, dstsd->status.name);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -13683,7 +13683,7 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd)
name[NAME_LENGTH-1] = '\0';
sprintf(command, "%cmute %d %s", atcommand->at_symbol, 60, name);
- atcommand->parse(fd, sd, command, 1);
+ atcommand->exec(fd, sd, command, true);
}
@@ -16190,7 +16190,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd)
if( !clif->process_message(sd, 0, &name, &namelen, &message, &messagelen) )
return;
- if( atcommand->parse(fd, sd, message, 1) )
+ if( atcommand->exec(fd, sd, message, true) )
return;
if( sd->sc.data[SC_BERSERK] || sd->sc.data[SC_DEEP_SLEEP] || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) )
diff --git a/src/map/map.c b/src/map/map.c
index 07881ea56..33721b028 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -5316,7 +5316,7 @@ CPCMD(gm_use) {
return;
}
map->cpsd->fd = -2;
- if( !atcommand->parse(map->cpsd->fd, map->cpsd, line, 0) )
+ if( !atcommand->exec(map->cpsd->fd, map->cpsd, line, false) )
ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' failed\n",line);
else
ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line);
diff --git a/src/map/script.c b/src/map/script.c
index 8e8f89727..adea269c7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -12659,7 +12659,7 @@ BUILDIN(atcommand) {
}
}
- if (!atcommand->parse(fd, sd, cmd, 0)) {
+ if (!atcommand->exec(fd, sd, cmd, false)) {
ShowWarning("script: buildin_atcommand: failed to execute command '%s'\n", cmd);
script->reportsrc(st);
ret = false;
@@ -17320,7 +17320,7 @@ BUILDIN(useatcmd) {
cmd++;
}
- atcommand->parse(fd, sd, cmd, 1);
+ atcommand->exec(fd, sd, cmd, true);
if (dummy_sd) aFree(dummy_sd);
return true;
}