فهرست منبع

fix crash

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@455 54d463be-8e91-2dee-dedb-b68131a5f0ec
amber 20 سال پیش
والد
کامیت
ba9ef1f2ca
3فایلهای تغییر یافته به همراه19 افزوده شده و 19 حذف شده
  1. 1 1
      src/map/chrif.c
  2. 17 17
      src/map/map.c
  3. 1 1
      src/map/map.h

+ 1 - 1
src/map/chrif.c

@@ -140,7 +140,7 @@ int chrif_sendmap(int fd)
 
 	WFIFOW(fd,0) = 0x2afa;
 	for(i = 0; i < map_num; i++)
-                if (map[i].alias[0] != '\0') // [MouseJstr] map aliasing
+                if (map[i].alias != '\0') // [MouseJstr] map aliasing
 		    memcpy(WFIFOP(fd,4+i*16), map[i].alias, 16);
 		else
 		    memcpy(WFIFOP(fd,4+i*16), map[i].name, 16);

+ 17 - 17
src/map/map.c

@@ -1582,7 +1582,8 @@ static int map_readmap(int m,char *fn, char *alias) {
 	map[m].npc_num=0;
 	map[m].users=0;
 	memset(&map[m].flag,0,sizeof(map[m].flag));
-	if(battle_config.pk_mode) map[m].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
+	if(battle_config.pk_mode) 
+		map[m].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
 	wh=map_waterheight(map[m].name);
 	for(y=0;y<ys;y++){
 		p=(struct gat_1cell*)(gat+y*xs*20+14);
@@ -1606,6 +1607,9 @@ static int map_readmap(int m,char *fn, char *alias) {
 	size = map[m].bxs*map[m].bys*sizeof(int);
 	map[m].block_count = (int *)aCalloc(1,size);
 	map[m].block_mob_count=(int *)aCalloc(1,size);
+	if (alias)
+           strdb_insert(map_db,alias,&map[m]);
+        else
            strdb_insert(map_db,map[m].name,&map[m]);
 
 //	printf("%s read done\n",fn);
@@ -1635,23 +1639,19 @@ int map_readallmap(void) {
 			fclose(afm_file);
 		}
 		else if(strstr(map[i].name,".gat")!=NULL) {
-			char *p = strstr(map[i].name, ">"); // [MouseJstr]
+			char *p = strstr(map[i].name, "<"); // [MouseJstr]
 			if (p != NULL) {
-				char alias[64];
-				*p = '\0';
-				strcpy(alias, map[i].name);
-				strcpy(map[i].name, p + 1);
-				sprintf(fn,"data\\%s",map[i].name);
-				if(map_readmap(i,fn, alias) == -1) {
-					map_delmap(map[i].name);
-					maps_removed++;
-				}
-			} else {
-				sprintf(fn,"data\\%s",map[i].name);
-				if(map_readmap(i,fn, NULL) == -1) {
-					map_delmap(map[i].name);
-					maps_removed++;
-				}
+				char buf[64];
+				*p++ = '\0';
+				sprintf(buf,"data\\%s", p);
+				map[i].alias = strdup(buf);
+			} else
+				map[i].alias = NULL;
+
+			sprintf(fn,"data\\%s",map[i].name);
+			if(map_readmap(i,fn, p) == -1) {
+				map_delmap(map[i].name);
+				maps_removed++;
 			}
 		}
 	}

+ 1 - 1
src/map/map.h

@@ -482,7 +482,7 @@ enum { ATK_LUCKY=1,ATK_FLEE,ATK_DEF};	// 
 
 struct map_data {
 	char name[24];
-	char alias[24]; // [MouseJstr]
+	char *alias; // [MouseJstr]
 	unsigned char *gat;	// NULL‚Ȃ牺‚Ìmap_data_other_server‚Æ‚µ‚Ĉµ‚¤
 	struct block_list **block;
 	struct block_list **block_mob;