summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/map/atcommand.c56
-rw-r--r--src/map/atcommand.h4
-rw-r--r--src/map/charcommand.c50
-rw-r--r--src/map/charcommand.h4
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/map.c5
-rw-r--r--src/map/script.c8
7 files changed, 80 insertions, 65 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 7e641bd1e..213f864d5 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -776,37 +776,13 @@ int get_atcommand_level(const AtCommandType type) {
return 100; // 100: command can not be used
}
-/*==========================================
- *is_atcommand @コマンドに存在するかどうか確認する
- *------------------------------------------
- */
AtCommandType
-is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
- const char* str = message;
- int s_flag = 0;
+atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
AtCommandInfo info;
AtCommandType type;
- nullpo_retr(AtCommand_None, sd);
-
- if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
- return AtCommand_Unknown;
- }
-
- if (!message || !*message)
- return AtCommand_None;
-
malloc_set(&info, 0, sizeof(info));
- str += strlen(sd->status.name);
- while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
- if (*str == ':')
- s_flag = 1;
- str++;
- }
- if (!*str)
- return AtCommand_None;
- if (!gmlvl) gmlvl = pc_isGM(sd);
type = atcommand(sd, gmlvl, str, &info);
if (type != AtCommand_None) {
char command[100];
@@ -848,6 +824,36 @@ is_atcommand(const int fd, struct map_session_data* sd, const char* message, int
}
/*==========================================
+ *is_atcommand @コマンドに存在するかどうか確認する
+ *------------------------------------------
+ */
+AtCommandType
+is_atcommand(const int fd, struct map_session_data* sd, const char* message) {
+ const char* str = message;
+ int s_flag = 0;
+
+ nullpo_retr(AtCommand_None, sd);
+
+ if (sd->sc.count && sd->sc.data[SC_NOCHAT].timer != -1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCOMMAND) {
+ return AtCommand_Unknown;
+ }
+
+ if (!message || !*message)
+ return AtCommand_None;
+
+ str += strlen(sd->status.name);
+ while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
+ if (*str == ':')
+ s_flag = 1;
+ str++;
+ }
+ if (!*str)
+ return AtCommand_None;
+
+ return atcommand_sub(fd,sd,str,pc_isGM(sd));
+}
+
+/*==========================================
*
*------------------------------------------
*/
diff --git a/src/map/atcommand.h b/src/map/atcommand.h
index 06bd3664f..aebe49965 100644
--- a/src/map/atcommand.h
+++ b/src/map/atcommand.h
@@ -299,7 +299,9 @@ typedef struct AtCommandInfo {
} AtCommandInfo;
AtCommandType
-is_atcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl);
+is_atcommand(const int fd, struct map_session_data* sd, const char* message);
+AtCommandType
+atcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl);
AtCommandType atcommand(
struct map_session_data *sd,
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 8264aa6ef..0b6bd8c60 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -122,33 +122,13 @@ int get_charcommand_level(const CharCommandType type) {
return 100; // 100: command can not be used
}
-/*==========================================
- *is_charcommand @コマンドに存在するかどうか確認する
- *------------------------------------------
- */
-CharCommandType
-is_charcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl) {
- const char* str = message;
- int s_flag = 0;
+CharCommandType
+charcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl) {
CharCommandInfo info;
CharCommandType type;
- nullpo_retr(CharCommand_None, sd);
-
- if (!message || !*message)
- return CharCommand_None;
-
malloc_set(&info, 0, sizeof(info));
- str += strlen(sd->status.name);
- while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
- if (*str == ':')
- s_flag = 1;
- str++;
- }
- if (!*str)
- return CharCommand_None;
- if (!gmlvl) gmlvl = pc_isGM(sd);
type = charcommand(sd, gmlvl, str, &info);
if (type != CharCommand_None) {
char command[100];
@@ -191,6 +171,32 @@ is_charcommand(const int fd, struct map_session_data* sd, const char* message, i
}
/*==========================================
+ *is_charcommand @コマンドに存在するかどうか確認する
+ *------------------------------------------
+ */
+CharCommandType
+is_charcommand(const int fd, struct map_session_data* sd, const char* message) {
+ const char* str = message;
+ int s_flag = 0;
+
+ nullpo_retr(CharCommand_None, sd);
+
+ if (!message || !*message)
+ return CharCommand_None;
+
+ str += strlen(sd->status.name);
+ while (*str && (isspace(*str) || (s_flag == 0 && *str == ':'))) {
+ if (*str == ':')
+ s_flag = 1;
+ str++;
+ }
+ if (!*str)
+ return CharCommand_None;
+
+ return charcommand_sub(fd,sd,str,pc_isGM(sd));
+}
+
+/*==========================================
*
*------------------------------------------
*/
diff --git a/src/map/charcommand.h b/src/map/charcommand.h
index a081000d8..2f75f75c5 100644
--- a/src/map/charcommand.h
+++ b/src/map/charcommand.h
@@ -60,7 +60,9 @@ typedef struct CharCommandInfo {
} CharCommandInfo;
CharCommandType
-is_charcommand(const int fd, struct map_session_data* sd, const char* message, int gmlvl);
+is_charcommand(const int fd, struct map_session_data* sd, const char* message);
+CharCommandType
+charcommand_sub(const int fd, struct map_session_data* sd, const char* str, int gmlvl);
CharCommandType charcommand(
struct map_session_data* sd, const int level, const char* message, CharCommandInfo* info);
diff --git a/src/map/clif.c b/src/map/clif.c
index 27f634164..a79cbf0fd 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8694,8 +8694,8 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c <
return;
}
- if ((is_atcommand(fd, sd, message, 0) != AtCommand_None) ||
- (is_charcommand(fd, sd, message,0) != CharCommand_None))
+ if ((is_atcommand(fd, sd, message) != AtCommand_None) ||
+ (is_charcommand(fd, sd, message) != CharCommand_None))
return;
if (sd->sc.count &&
@@ -9059,8 +9059,8 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni
gm_command = (char*)aMallocA((strlen((const char*)RFIFOP(fd,28)) + 28)*sizeof(char)); // 24+3+(RFIFOW(fd,2)-28)+1 or 24+3+(strlen(RFIFOP(fd,28))+1 (size can be wrong with hacker)
sprintf(gm_command, "%s : %s", sd->status.name, RFIFOP(fd,28));
- if ((is_charcommand(fd, sd, gm_command, 0) != CharCommand_None) ||
- (is_atcommand(fd, sd, gm_command, 0) != AtCommand_None)) {
+ if ((is_charcommand(fd, sd, gm_command) != CharCommand_None) ||
+ (is_atcommand(fd, sd, gm_command) != AtCommand_None)) {
if(gm_command) aFree(gm_command);
return;
}
@@ -10428,8 +10428,8 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) {
void clif_parse_PartyMessage(int fd, struct map_session_data *sd) {
RFIFOHEAD(fd);
- if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != CharCommand_None ||
- is_atcommand(fd, sd, (char*)RFIFOP(fd,4), 0) != AtCommand_None)
+ if (is_charcommand(fd, sd, (char*)RFIFOP(fd,4)) != CharCommand_None ||
+ is_atcommand(fd, sd, (char*)RFIFOP(fd,4)) != AtCommand_None)
return;
if (sd->sc.count && (
@@ -10672,8 +10672,8 @@ void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) {
void clif_parse_GuildMessage(int fd,struct map_session_data *sd) {
RFIFOHEAD(fd);
- if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != CharCommand_None ||
- is_atcommand(fd, sd, (char*)RFIFOP(fd, 4), 0) != AtCommand_None)
+ if (is_charcommand(fd, sd, (char*)RFIFOP(fd, 4)) != CharCommand_None ||
+ is_atcommand(fd, sd, (char*)RFIFOP(fd, 4)) != AtCommand_None)
return;
if (sd->sc.count && (
@@ -11427,7 +11427,7 @@ void clif_parse_GMKillAll(int fd,struct map_session_data *sd)
char message[50];
strncpy(message,sd->status.name, NAME_LENGTH);
- is_atcommand(fd, sd, strcat(message," : @kickall"),0);
+ is_atcommand(fd, sd, strcat(message," : @kickall"));
return;
}
diff --git a/src/map/map.c b/src/map/map.c
index 1036edd15..75c428293 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3233,7 +3233,7 @@ static int char_ip_set = 0;
*------------------------------------------
*/
int parse_console(char *buf) {
- char type[64],command[64],map[64], buf2[72];
+ char type[64],command[64],map[64];
int x = 0, y = 0;
int m, n;
struct map_session_data sd;
@@ -3263,8 +3263,7 @@ int parse_console(char *buf) {
ShowInfo("Type of command: %s || Command: %s || Map: %s Coords: %d %d\n",type,command,map,x,y);
if ( strcmpi("admin",type) == 0 && n == 5 ) {
- sprintf(buf2,"console: %s",command);
- if( is_atcommand(sd.fd,&sd,buf2,99) == AtCommand_None )
+ if( atcommand_sub(sd.fd,&sd,command,99) == AtCommand_None )
printf("Console: not atcommand\n");
} else if ( strcmpi("server",type) == 0 && n == 2 ) {
if ( strcmpi("shutdown", command) == 0 || strcmpi("exit",command) == 0 || strcmpi("quit",command) == 0 ) {
diff --git a/src/map/script.c b/src/map/script.c
index 551e286f1..414181f98 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10102,7 +10102,7 @@ int buildin_atcommand(struct script_state *st)
if (st->rid)
sd = script_rid2sd(st);
- if (sd) is_atcommand(sd->fd, sd, cmd, 99);
+ if (sd) atcommand_sub(sd->fd, sd, cmd, 99);
else { //Use a dummy character.
struct map_session_data dummy_sd;
struct block_list *bl = NULL;
@@ -10113,7 +10113,7 @@ int buildin_atcommand(struct script_state *st)
if (bl->type == BL_NPC)
strncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
}
- is_atcommand(0, &dummy_sd, cmd, 99);
+ atcommand_sub(0, &dummy_sd, cmd, 99);
}
return 0;
@@ -10129,7 +10129,7 @@ int buildin_charcommand(struct script_state *st)
if (st->rid)
sd = script_rid2sd(st);
- if (sd) is_charcommand(sd->fd, sd, cmd, 99);
+ if (sd) charcommand_sub(sd->fd, sd, cmd,99);
else { //Use a dummy character.
struct map_session_data dummy_sd;
struct block_list *bl = NULL;
@@ -10140,7 +10140,7 @@ int buildin_charcommand(struct script_state *st)
if (bl->type == BL_NPC)
strncpy(dummy_sd.status.name, ((TBL_NPC*)bl)->name, NAME_LENGTH);
}
- is_charcommand(0, &dummy_sd, cmd, 99);
+ charcommand_sub(0, &dummy_sd, cmd, 99);
}
return 0;