summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-03-07 16:47:51 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-03-07 16:47:51 +0000
commitdfb7b664299f5af5503d14bf914c5ca4bfb745be (patch)
tree8fad35db57f5bce2a81076a1b5ef3226f48b05fc /src/map/map.c
parentda7c46685d6426706c6f5ded6d7df4e62ee06261 (diff)
downloadhercules-dfb7b664299f5af5503d14bf914c5ca4bfb745be.tar.gz
hercules-dfb7b664299f5af5503d14bf914c5ca4bfb745be.tar.bz2
hercules-dfb7b664299f5af5503d14bf914c5ca4bfb745be.tar.xz
hercules-dfb7b664299f5af5503d14bf914c5ca4bfb745be.zip
- Made the map server abort when it can't open the mapcache file.
- Added a normalizing function to map.c which handles removing the extension of the map name. - Applied said function when reading maps from maps_athena, since the mapcache lookup fails without it (maps are stored there without extensions) - TODO: Apply the normalizing function everywhere when parsing map related scripts. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9973 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 2ae720ddf..48ca20dff 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2447,6 +2447,20 @@ struct map_cache_info {
FILE *map_cache_fp;
+char *map_normalize_name(char *mapname)
+{
+ char *ptr, *ptr2;
+ ptr = strchr(mapname, '.');
+ if (ptr) { //Check and remove extension.
+ while (ptr[1] && (ptr2 = strchr(ptr+1, '.')))
+ ptr = ptr2; //Skip to the last dot.
+ if(stricmp(ptr,".gat") == 0 ||
+ stricmp(ptr,".afm") == 0)
+ *ptr = '\0'; //Remove extension.
+ }
+ return mapname;
+}
+
int map_readmap(struct map_data *m)
{
int i;
@@ -2489,7 +2503,8 @@ int map_addmap(char *mapname) {
CL_WHITE"%s"CL_RESET"', the limit of maps has been reached.\n",mapname);
return 1;
}
- memcpy(map[map_num].name, mapname, MAP_NAME_LENGTH-1);
+
+ memcpy(map[map_num].name, map_normalize_name(mapname), MAP_NAME_LENGTH-1);
map_num++;
return 0;
}
@@ -2529,7 +2544,10 @@ int map_readallmaps()
int maps_removed = 0;
if(!(map_cache_fp = fopen(map_cache_file, "rb")))
- ShowError("Unable to open map cache file "CL_WHITE"%s"CL_RESET"\n", map_cache_file);
+ {
+ ShowFatalError("Unable to open map cache file "CL_WHITE"%s"CL_RESET"\n", map_cache_file);
+ exit(1); //No use launching server if maps can't be read.
+ }
ShowStatus("Loading maps...\n");