diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-16 16:19:32 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-16 16:19:32 +0000 |
commit | 3531bd5992af838ba43f886a4c9c01745bb6062a (patch) | |
tree | 26887862d4541850158d42c08a2f3890b32ad9c0 /src | |
parent | 6170c4fe2a6dc695a87b79c7d5d0aa4b395af7fa (diff) | |
download | hercules-3531bd5992af838ba43f886a4c9c01745bb6062a.tar.gz hercules-3531bd5992af838ba43f886a4c9c01745bb6062a.tar.bz2 hercules-3531bd5992af838ba43f886a4c9c01745bb6062a.tar.xz hercules-3531bd5992af838ba43f886a4c9c01745bb6062a.zip |
- Removed water_height.txt reading (since it is always done from the rsw now)
- Fixed a possible crash in grfio_find_file
- Corrected water-level-reading to account for a return of null from the previously mentioned function
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6117 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/common/grfio.c | 5 | ||||
-rw-r--r-- | src/map/map.c | 52 |
2 files changed, 12 insertions, 45 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c index 612932e24..81a5ef7c5 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -20,6 +20,7 @@ * 2003/10/21 ... The data of alpha client was read.
* 2003/11/10 ... Ready new grf format.
* 2003/11/11 ... version check fix & bug fix
+ * 2006/04/16 ... fixed crash grfio_find_file when file is not found.
*/
#include <stdio.h>
@@ -456,7 +457,9 @@ static FILELIST *filelist_find(char *fname) }
char *grfio_find_file(char *fname){
- return ((filelist_find(fname)->fnd == NULL)? filelist_find(fname)->fn: filelist_find(fname)->fnd);
+ FILELIST *filelist = filelist_find(fname);
+ if (!filelist) return NULL;
+ return (!filelist->fnd?filelist->fn:filelist->fnd);
}
/*==========================================
diff --git a/src/map/map.c b/src/map/map.c index 94bc6a57c..5eef78856 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2290,15 +2290,6 @@ int map_eraseipport(unsigned short mapindex,unsigned long ip,int port) return 0; } -// 初期化周り -/*========================================== - * 水場高さ設定 - *------------------------------------------ - */ -//static struct waterlist_ { -// char mapname[MAP_NAME_LENGTH], clonemapname[MAP_NAME_LENGTH]; -//} *waterlist=NULL; - #define NO_WATER 1000000 static int map_setwaterheight_sub(int m) { @@ -2345,7 +2336,7 @@ int map_setwaterheight(int m, char *mapname, int height) { * Returns water height (or NO_WATER if file doesn't exist) * or other error is encountered. * This receives a map-name, and changes the extension to rsw if it isn't set already. - * assumed path for file is data/mapname.rsw + * Assumed path for file is data/mapname.rsw * Credits to LittleWolf */ int map_waterheight(char *mapname) { @@ -2354,18 +2345,16 @@ int map_waterheight(char *mapname) { float whtemp; int wh; - //Look up for clone map. - //if(waterlist){ - // int i; - // for(i=0;waterlist[i].mapname[0] && i < MAX_MAP_PER_SERVER;i++) - // if(strcmp(waterlist[i].mapname,mapname)==0) - // return map_waterheight(waterlist[i].clonemapname); - //} //Look up for the rsw - sprintf(fn,"data\\%s",mapname); + if(!strstr(mapname,"data\\")) + sprintf(fn,"data\\%s", mapname); + else + strcpy(fn, mapname); found = grfio_find_file(fn); - if(!strstr(found,"data\\")) + if (!found) + ; //Stick to the current fn + else if(!strstr(found,"data\\")) sprintf(fn,"data\\%s", found); else strcpy(fn, found); @@ -2387,30 +2376,6 @@ int map_waterheight(char *mapname) { return NO_WATER; } -//static void map_readwater(char *watertxt) { -// char line[1024],w1[1024],w2[1024]; -// FILE *fp=NULL; -// int n=0; -// -// fp=fopen(watertxt,"r"); -// if(fp==NULL){ -// ShowError("file not found: %s\n",watertxt); -// return; -// } -// if(waterlist==NULL) -// waterlist = (struct waterlist_*)aCallocA(MAX_MAP_PER_SERVER,sizeof(*waterlist)); -// while(fgets(line,1020,fp) && n < MAX_MAP_PER_SERVER){ -// if(line[0] == '/' && line[1] == '/') -// continue; -// if(sscanf(line,"%s %s",w1,w2) < 2){ -// continue; -// } -// memcpy(waterlist[n].mapname,w1, MAP_NAME_LENGTH-1); -// memcpy(waterlist[n].clonemapname, w2, MAP_NAME_LENGTH-1); -// n++; -// } -// fclose(fp); -//} /*========================================== * マップキャッシュに追加する *===========================================*/ @@ -3133,7 +3098,6 @@ int map_readallmaps (void) } // finished map loading - //aFree(waterlist); printf("\r"); ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps.%30s\n",map_num,""); |