summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-02-08 00:42:11 +0100
committerHaru <haru@dotalux.com>2020-02-09 20:23:14 +0100
commitab0eb2c722872ecf33c1449e74468e362a879ba4 (patch)
treea52875a03d2b6c66578dbbe59fc8e858d8b14e00 /src/map
parent4d046fc7de712e8e3ab0b330e7455894f35c98a0 (diff)
downloadhercules-ab0eb2c722872ecf33c1449e74468e362a879ba4.tar.gz
hercules-ab0eb2c722872ecf33c1449e74468e362a879ba4.tar.bz2
hercules-ab0eb2c722872ecf33c1449e74468e362a879ba4.tar.xz
hercules-ab0eb2c722872ecf33c1449e74468e362a879ba4.zip
Update ACMD(reloadnpc) path verification
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 0d84dd46e..c92995977 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -4526,30 +4526,32 @@ ACMD(unloadnpc)
**/
ACMD(reloadnpc)
{
- char file_path[100] = {'\0'};
+ char format[20];
+
+ snprintf(format, sizeof(format), "%%%ds %%1d", MAX_DIR_PATH);
+
+ char file_path[MAX_DIR_PATH + 1] = {'\0'};
int flag = 1;
- if (*message == '\0' || (sscanf(message, "%99s %1d", file_path, &flag) < 1)) {
+ if (*message == '\0' || (sscanf(message, format, file_path, &flag) < 1)) {
clif->message(fd, msg_fd(fd, 1516)); /// Usage: @reloadnpc <path> {<flag>}
return false;
}
- const char *dot = strrchr(file_path, '.');
-
- if (dot == NULL) {
- clif->message(fd, msg_fd(fd, 1518)); /// No file extension specified.
+ if (!exists(file_path)) {
+ clif->message(fd, msg_fd(fd, 1387)); /// File not found.
return false;
}
- if (strlen(dot) < 4 || strncmp(dot, ".txt", 4) != 0) {
- clif->message(fd, msg_fd(fd, 1519)); /// Not a TXT file.
+ if (!is_file(file_path)) {
+ clif->message(fd, msg_fd(fd, 1518)); /// Not a file.
return false;
}
FILE *fp = fopen(file_path, "r");
if (fp == NULL) {
- clif->message(fd, msg_fd(fd, 1387)); /// File not found.
+ clif->message(fd, msg_fd(fd, 1519)); /// Can't open file.
return false;
}