diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-09-05 20:27:08 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-09-05 20:27:08 +0000 |
commit | 61d9a63c900b02ac23a77420e71ee653de6edaa0 (patch) | |
tree | c2e8c50c5c71a9d37efee1dbd084390eae444b8b /src/map | |
parent | 961c1f83daaceecd086816d6fd7a0968c61ec250 (diff) | |
download | hercules-61d9a63c900b02ac23a77420e71ee653de6edaa0.tar.gz hercules-61d9a63c900b02ac23a77420e71ee653de6edaa0.tar.bz2 hercules-61d9a63c900b02ac23a77420e71ee653de6edaa0.tar.xz hercules-61d9a63c900b02ac23a77420e71ee653de6edaa0.zip |
- applied the Ultra Mage's suggestion to have the map server strip trailing spaces/comments from the config files. It will also now print out when an unknown config setting is found.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8642 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/map.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/map/map.c b/src/map/map.c index c25c61e79..492283125 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3302,7 +3302,7 @@ int parse_console(char *buf) { *------------------------------------------ */ int map_config_read(char *cfgName) { - char line[1024], w1[1024], w2[1024]; + char line[1024], w1[1024], w2[1024], *ptr; FILE *fp; fp = fopen(cfgName,"r"); @@ -3313,7 +3313,17 @@ int map_config_read(char *cfgName) { while(fgets(line, sizeof(line) -1, fp)) { if (line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) { + + if ((ptr = strstr(line, "//")) != NULL) + *ptr = '\n'; //Strip comments + + if (sscanf(line, "%[^:]: %[^\t\r\n]", w1, w2) == 2) { + //Strip trailing spaces + ptr = w2 + strlen(w2); + while (--ptr >= w2 && *ptr == ' '); + ptr++; + *ptr = '\0'; + if(strcmpi(w1,"timestamp_format")==0){ strncpy(timestamp_format, w2, 20); } else if(strcmpi(w1,"console_silent")==0){ @@ -3390,7 +3400,8 @@ int map_config_read(char *cfgName) { enable_spy = 0; } else if (strcmpi(w1, "import") == 0) { map_config_read(w2); - } + } else + ShowWarning("Unknown setting [%s] in file %s\n", w1, cfgName); } } fclose(fp); |