diff options
-rw-r--r-- | Changelog-Trunk.txt | 3 | ||||
-rw-r--r-- | src/map/map.c | 17 |
2 files changed, 17 insertions, 3 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 41c72d498..8f99c67f6 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/09/05
+ * 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. [Skotlex]
* Fixed status change resistance not being invoked at all for pretty much
all cases. [Skotlex]
* Corrected SC_INTRAVISION not starting. [Skotlex]
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); |