summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorDracoRPG <DracoRPG@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-06 17:22:40 +0000
committerDracoRPG <DracoRPG@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-06 17:22:40 +0000
commitded1f674755335a9cbb5c08e321b4a4c092a0e8d (patch)
tree4ff5231731935b41f9ef1fdccf9b14ef5b4e85b3 /src/map
parent2d75543b172d4cf141278bbd224e2353f19b5c86 (diff)
downloadhercules-ded1f674755335a9cbb5c08e321b4a4c092a0e8d.tar.gz
hercules-ded1f674755335a9cbb5c08e321b4a4c092a0e8d.tar.bz2
hercules-ded1f674755335a9cbb5c08e321b4a4c092a0e8d.tar.xz
hercules-ded1f674755335a9cbb5c08e321b4a4c092a0e8d.zip
I'm still here!
Rewrote fame ranking lists- changed MAP_NAME_LENGTH to 12, now there's MAP_NAME_LENGTH_EXT at 16 for uses where there is / may be the .gat extension, code adjusted accordingly - moved map_normalize_name to mapindex_normalize_name so that everything handling map names uses the same extension-removing function - greatly enhanced the map cache generator, complete documentation on the tool and the map cache format can be found in doc/ - the map cache format changed a bit as a consequence, but of course a new valid one is included (contains latest Nameless Island maps) - fixed a duplicate entry in map index git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10167 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c20
-rw-r--r--src/map/charcommand.c4
-rw-r--r--src/map/chrif.c2
-rw-r--r--src/map/clif.c61
-rw-r--r--src/map/guild.c5
-rw-r--r--src/map/map.c70
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/npc.c14
-rw-r--r--src/map/script.c18
-rw-r--r--src/map/skill.c14
10 files changed, 104 insertions, 107 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index f77d04044..2ce3009eb 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1310,7 +1310,7 @@ int atcommand_send(const int fd, struct map_session_data* sd, const char* comman
*/
int atcommand_rura( const int fd, struct map_session_data* sd, const char* command, const char* message)
{
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
unsigned short mapindex;
int x = 0, y = 0;
int m = -1;
@@ -1698,7 +1698,7 @@ int atcommand_whomap3(const int fd, struct map_session_data* sd, const char* com
int i, count, users;
int pl_GM_level, GM_level;
int map_id;
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
memset(atcmd_output, '\0', sizeof(atcmd_output));
memset(map_name, '\0', sizeof(map_name));
@@ -1752,7 +1752,7 @@ int atcommand_whomap2(const int fd, struct map_session_data* sd, const char* com
int i, count, users;
int pl_GM_level, GM_level;
int map_id = 0;
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
nullpo_retr(-1, sd);
@@ -1810,7 +1810,7 @@ int atcommand_whomap(const int fd, struct map_session_data* sd, const char* comm
int i, count, users;
int pl_GM_level, GM_level;
int map_id = 0;
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
struct guild *g;
struct party_data *p;
@@ -3190,10 +3190,10 @@ int atcommand_go(const int fd, struct map_session_data* sd, const char* command,
{
int i;
int town;
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
int m;
- const struct { char map[MAP_NAME_LENGTH]; int x, y; } data[] = {
+ const struct { char map[MAP_NAME_LENGTH_EXT]; int x, y; } data[] = {
{ MAP_PRONTERA, 156, 191 }, // 0=Prontera
{ MAP_MORROC, 156, 93 }, // 1=Morroc
{ MAP_GEFFEN, 119, 59 }, // 2=Geffen
@@ -3250,7 +3250,7 @@ int atcommand_go(const int fd, struct map_session_data* sd, const char* command,
return -1;
} else {
// get possible name of the city
- map_name[MAP_NAME_LENGTH-1] = '\0';
+ map_name[MAP_NAME_LENGTH_EXT-1] = '\0';
for (i = 0; map_name[i]; i++)
map_name[i] = TOLOWER(map_name[i]);
// try to see if it's a name, and not a number (try a lot of possibilities, write errors and abbreviations too)
@@ -3636,7 +3636,7 @@ static int atkillmonster_sub(struct block_list *bl, va_list ap)
void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const char* message, const int drop)
{
int map_id;
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
if (!sd) return;
@@ -5432,8 +5432,8 @@ int atcommand_mapinfo(const int fd, struct map_session_data* sd, const char* com
}
if (atcmd_player_name[0] == '\0') {
- memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH);
- atcmd_player_name[MAP_NAME_LENGTH] = '\0';
+ memcpy(atcmd_player_name, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH_EXT);
+ atcmd_player_name[MAP_NAME_LENGTH_EXT] = '\0';
m_id = map_mapindex2mapid(sd->mapindex);
} else {
m_id = map_mapname2mapid(atcmd_player_name);
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index e826d42b8..415f216d5 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -617,7 +617,7 @@ int charcommand_save(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
char character[NAME_LENGTH];
struct map_session_data* pl_sd;
int x = 0, y = 0;
@@ -1130,7 +1130,7 @@ int charcommand_warp(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
char character[NAME_LENGTH];
int x = 0, y = 0;
struct map_session_data *pl_sd;
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 3fef01c5c..2af51c20d 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -328,7 +328,7 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y,
int chrif_changemapserverack(int fd)
{
struct map_session_data *sd;
- char mapname[MAP_NAME_LENGTH+1];
+ char mapname[MAP_NAME_LENGTH_EXT];
RFIFOHEAD(fd);
sd = map_id2sd(RFIFOL(fd,2));
diff --git a/src/map/clif.c b/src/map/clif.c
index 615b5fee3..36ae1d658 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1208,12 +1208,16 @@ static void clif_spiritball_single(int fd, struct map_session_data *sd)
*------------------------------------------
*/
static int clif_set0192(int fd, int m, int x, int y, int type) {
+ char map_name[MAP_NAME_LENGTH_EXT];
+
+ sprintf(map_name, "%s.gat", map[m].name);
+
WFIFOHEAD(fd, packet_len(0x192));
WFIFOW(fd,0) = 0x192;
WFIFOW(fd,2) = x;
WFIFOW(fd,4) = y;
WFIFOW(fd,6) = type;
- memcpy(WFIFOP(fd,8),map[m].name,MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,8),map_name,MAP_NAME_LENGTH_EXT);
WFIFOSET(fd,packet_len(0x192));
return 0;
@@ -1600,17 +1604,17 @@ void clif_setwaitclose(int fd) {
*/
int clif_changemap(struct map_session_data *sd, short map, int x, int y) {
int fd;
- char map_name[MAP_NAME_LENGTH];
-
+ char map_name[MAP_NAME_LENGTH_EXT];
+
nullpo_retr(0, sd);
fd = sd->fd;
- snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(map));
+ sprintf(map_name, "%s.gat", mapindex_id2name(map));
WFIFOHEAD(fd, packet_len(0x91));
WFIFOW(fd,0) = 0x91;
- memcpy(WFIFOP(fd,2), map_name, MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,2), map_name, MAP_NAME_LENGTH_EXT);
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOSET(fd, packet_len(0x91));
@@ -1631,7 +1635,7 @@ int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x
WFIFOHEAD(fd, packet_len(0x92));
WFIFOW(fd,0) = 0x92;
//Better not trust the null-terminator is there. [Skotlex]
- memcpy(WFIFOP(fd,2), mapname, MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,2), mapname, MAP_NAME_LENGTH_EXT);
WFIFOB(fd,17) = 0; //Null terminator for mapname
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
@@ -4661,10 +4665,10 @@ int clif_skill_warppoint(struct map_session_data *sd,int skill_num,int skill_lv,
WFIFOHEAD(fd,packet_len(0x11c));
WFIFOW(fd,0)=0x11c;
WFIFOW(fd,2)=skill_num;
- strncpy((char*)WFIFOP(fd, 4),map1,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,20),map2,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,36),map3,MAP_NAME_LENGTH);
- strncpy((char*)WFIFOP(fd,52),map4,MAP_NAME_LENGTH);
+ strncpy((char*)WFIFOP(fd, 4),map1,MAP_NAME_LENGTH_EXT);
+ strncpy((char*)WFIFOP(fd,20),map2,MAP_NAME_LENGTH_EXT);
+ strncpy((char*)WFIFOP(fd,36),map3,MAP_NAME_LENGTH_EXT);
+ strncpy((char*)WFIFOP(fd,52),map4,MAP_NAME_LENGTH_EXT);
WFIFOSET(fd,packet_len(0x11c));
sd->menuskill_id = skill_num;
if (skill_num == AL_WARP)
@@ -5660,7 +5664,7 @@ int clif_party_created(struct map_session_data *sd,int flag)
int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
{
unsigned char buf[96];
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
if (!sd) { //Pick any party member (this call is used when changing item share rules)
int i;
@@ -5669,7 +5673,7 @@ int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
sd = p->data[i].sd;
}
- snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->mapindex));
+ snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->mapindex));
WBUFW(buf,0)=0x1e9;
WBUFL(buf,2)= sd->status.account_id;
@@ -5679,7 +5683,7 @@ int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
WBUFB(buf,14)=0; //Unconfirmed byte, could be online/offline.
memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63), map_name, MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,63), map_name, MAP_NAME_LENGTH_EXT);
WBUFB(buf,79) = (p->party.item&1)?1:0;
WBUFB(buf,80) = (p->party.item&2)?1:0;
clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
@@ -5693,7 +5697,7 @@ int clif_party_member_info(struct party_data *p, struct map_session_data *sd)
*------------------------------------------*/
int clif_party_info(struct party_data* p, struct map_session_data *sd)
{
- unsigned char buf[2+2+NAME_LENGTH+(4+NAME_LENGTH+MAP_NAME_LENGTH+1+1)*MAX_PARTY];
+ unsigned char buf[2+2+NAME_LENGTH+(4+NAME_LENGTH+MAP_NAME_LENGTH_EXT+1+1)*MAX_PARTY];
struct map_session_data* party_sd = NULL;
int i, c;
@@ -5704,17 +5708,17 @@ int clif_party_info(struct party_data* p, struct map_session_data *sd)
for(i = 0, c = 0; i < MAX_PARTY; i++)
{
struct party_member* m = &p->party.member[i];
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
if(!m->account_id) continue;
if(party_sd == NULL) party_sd = p->data[i].sd;
- snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(m->map));
+ snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(m->map));
WBUFL(buf,28+c*46) = m->account_id;
memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH);
- memcpy(WBUFP(buf,28+c*46+28), map_name, MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,28+c*46+28), map_name, MAP_NAME_LENGTH_EXT);
WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1;
WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1;
c++;
@@ -5993,12 +5997,12 @@ int clif_hpmeter(struct map_session_data *sd)
int clif_party_move(struct party *p,struct map_session_data *sd,int online)
{
unsigned char buf[128];
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
nullpo_retr(0, sd);
nullpo_retr(0, p);
- snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", map[sd->bl.m].name);
+ snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", map[sd->bl.m].name);
WBUFW(buf, 0)=0x104;
WBUFL(buf, 2)=sd->status.account_id;
@@ -6008,7 +6012,7 @@ int clif_party_move(struct party *p,struct map_session_data *sd,int online)
WBUFB(buf,14)=!online;
memcpy(WBUFP(buf,15),p->name, NAME_LENGTH);
memcpy(WBUFP(buf,39),sd->status.name, NAME_LENGTH);
- memcpy(WBUFP(buf,63),map_name, MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,63),map_name, MAP_NAME_LENGTH_EXT);
clif_send(buf,packet_len(0x104),&sd->bl,PARTY);
return 0;
}
@@ -6415,6 +6419,9 @@ int clif_changemapcell(int m,int x,int y,int cell_type,int type)
{
struct block_list bl;
unsigned char buf[32];
+ char map_name[MAP_NAME_LENGTH_EXT];
+
+ snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", map[m].name);
bl.type = BL_NUL;
bl.m = m;
@@ -6424,7 +6431,7 @@ int clif_changemapcell(int m,int x,int y,int cell_type,int type)
WBUFW(buf,2) = x;
WBUFW(buf,4) = y;
WBUFW(buf,6) = cell_type;
- memcpy(WBUFP(buf,8),map[m].name,MAP_NAME_LENGTH);
+ memcpy(WBUFP(buf,8),map_name,MAP_NAME_LENGTH_EXT);
if(!type)
clif_send(buf,packet_len(0x192),&bl,AREA);
else
@@ -7850,13 +7857,13 @@ void clif_gospel_info(struct map_session_data *sd, int type)
void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsigned char type)
{
int fd=sd->fd;
- char map_name[MAP_NAME_LENGTH];
+ char map_name[MAP_NAME_LENGTH_EXT];
- snprintf(map_name, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->feel_map[feel_level].index));
+ snprintf(map_name, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->feel_map[feel_level].index));
WFIFOHEAD(fd,packet_len(0x20e));
WFIFOW(fd,0)=0x20e;
- memcpy(WFIFOP(fd,2),map_name, MAP_NAME_LENGTH);
+ memcpy(WFIFOP(fd,2),map_name, MAP_NAME_LENGTH_EXT);
WFIFOL(fd,26)=sd->bl.id;
WFIFOB(fd,30)=feel_level;
WFIFOB(fd,31)=type?1:0;
@@ -8636,8 +8643,8 @@ int clif_message(struct block_list *bl, const char* msg)
*/
void clif_parse_MapMove(int fd, struct map_session_data *sd) {
// /m /mapmove (as @rura GM command)
- char output[MAP_NAME_LENGTH+15]; // Max length of a short: ' -6XXXX' -> 7 digits
- char message[MAP_NAME_LENGTH+15+5]; // "/mm "+output
+ char output[MAP_NAME_LENGTH_EXT+15]; // Max length of a short: ' -6XXXX' -> 7 digits
+ char message[MAP_NAME_LENGTH_EXT+15+5]; // "/mm "+output
char *map_name;
RFIFOHEAD(fd);
@@ -8647,7 +8654,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) {
return;
map_name = RFIFOP(fd,2);
- map_name[MAP_NAME_LENGTH-1]='\0';
+ map_name[MAP_NAME_LENGTH_EXT-1]='\0';
sprintf(output, "%s %d %d", map_name, RFIFOW(fd,18), RFIFOW(fd,20));
atcommand_rura(fd, sd, "@rura", output);
if(log_config.gm && get_atcommand_level(AtCommand_MapMove) >= log_config.gm)
diff --git a/src/map/guild.c b/src/map/guild.c
index 64af2e12a..8399022e3 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -9,6 +9,7 @@
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/malloc.h"
+#include "../common/mapindex.h"
#include "../common/showmsg.h"
#include "../common/ers.h"
@@ -183,7 +184,7 @@ static int guild_read_castledb(void)
gc=(struct guild_castle *)aCalloc(1,sizeof(struct guild_castle));
gc->castle_id=atoi(str[0]);
- memcpy(gc->map_name,map_normalize_name(str[1]),MAP_NAME_LENGTH-1);
+ memcpy(gc->map_name,mapindex_normalize_name(str[1]),MAP_NAME_LENGTH-1);
memcpy(gc->castle_name,str[2],NAME_LENGTH-1);
memcpy(gc->castle_event,str[3],NAME_LENGTH-1);
@@ -254,7 +255,7 @@ struct guild_castle *guild_mapname2gc(char *mapname)
int i;
struct guild_castle *gc=NULL;
- map_normalize_name(mapname);
+ mapindex_normalize_name(mapname);
for(i=0;i<MAX_GUILDCASTLE;i++){
gc=guild_castle_search(i);
diff --git a/src/map/map.c b/src/map/map.c
index f9c60d428..b69bd4367 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -145,6 +145,20 @@ struct charid2nick {
int req_id;
};
+// This is the main header found at the very beginning of the map cache
+struct map_cache_main_header {
+ unsigned long file_size;
+ unsigned short map_count;
+};
+
+// This is the header appended before every compressed map cells info in the map cache
+struct map_cache_map_info {
+ char name[MAP_NAME_LENGTH];
+ short xs;
+ short ys;
+ long len;
+};
+
char map_cache_file[256]="db/map_cache.dat";
char db_path[256] = "db";
char motd_txt[256] = "conf/motd.txt";
@@ -2410,61 +2424,34 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
* Map cache reading
*===========================================*/
-// This is the header appended before every compressed map cells info
-struct map_cache_info {
- char name[MAP_NAME_LENGTH];
- unsigned short index;
- short xs;
- short ys;
- long len;
-};
-
-FILE *map_cache_fp;
-
-// Removes the extension from a map name
-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 ||
- stricmp(ptr,".af2") == 0)
- *ptr = '\0'; //Remove extension.
- }
- return mapname;
-}
-
-int map_readmap(struct map_data *m)
+int map_readfromcache(struct map_data *m, FILE *fp)
{
int i;
- unsigned short map_count;
- struct map_cache_info info;
+ struct map_cache_main_header header;
+ struct map_cache_map_info info;
unsigned long size;
unsigned char *buf;
- if(!map_cache_fp)
+ if(!fp)
return 0;
- fseek(map_cache_fp, 0, SEEK_SET);
- fread(&map_count, sizeof(map_count), 1, map_cache_fp);
+ fseek(fp, 0, SEEK_SET);
+ fread(&header, sizeof(struct map_cache_main_header), 1, fp);
- for(i = 0; i < map_count; i++) {
- fread(&info, sizeof(info), 1, map_cache_fp);
+ for(i = 0; i < header.map_count; i++) {
+ fread(&info, sizeof(struct map_cache_map_info), 1, fp);
if(strcmp(m->name, info.name) == 0) { // Map found
m->xs = info.xs;
m->ys = info.ys;
m->gat = (unsigned char *)aMalloc(m->xs*m->ys); // Allocate room for map cells data
buf = aMalloc(info.len); // Allocate a temp buffer to read the zipped map
- fread(buf, info.len, 1, map_cache_fp);
+ fread(buf, info.len, 1, fp);
size = m->xs*m->ys;
decode_zip(m->gat, &size, buf, info.len); // Unzip the map from the buffer
aFree(buf);
return 1;
} else // Map not found, jump to the beginning of the next map info header
- fseek(map_cache_fp, info.len, SEEK_CUR);
+ fseek(fp, info.len, SEEK_CUR);
}
return 0;
@@ -2482,7 +2469,7 @@ int map_addmap(char *mapname) {
return 1;
}
- memcpy(map[map_num].name, map_normalize_name(mapname), MAP_NAME_LENGTH-1);
+ memcpy(map[map_num].name, mapindex_normalize_name(mapname), MAP_NAME_LENGTH-1);
map_num++;
return 0;
}
@@ -2520,8 +2507,9 @@ int map_readallmaps (void)
{
int i;
int maps_removed = 0;
+ FILE *fp;
- if(!(map_cache_fp = fopen(map_cache_file, "rb")))
+ if(!(fp = fopen(map_cache_file, "rb")))
{
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.
@@ -2559,7 +2547,7 @@ int map_readallmaps (void)
fflush(stdout);
}
- if(!map_readmap(&map[i])) {
+ if(!map_readfromcache(&map[i], fp)) {
map_delmapid(i);
maps_removed++;
i--;
@@ -2609,6 +2597,8 @@ int map_readallmaps (void)
map[i].block_mob_count = (int*)aCallocA(size, 1);
}
+ fclose(fp);
+
// finished map loading
printf("\r");
ShowInfo("Successfully loaded '"CL_WHITE"%d"CL_RESET"' maps.%30s\n",map_num,"");
diff --git a/src/map/map.h b/src/map/map.h
index 96b2b79b8..468f7a7d6 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1030,7 +1030,7 @@ enum { ATK_LUCKY=1,ATK_FLEE,ATK_DEF}; // 囲まれペナルティ計算用
struct map_data {
char name[MAP_NAME_LENGTH];
unsigned short index; //Index is the map index used by the mapindex* functions.
- unsigned char *gat; // NULLなら下のmap_data_other_serverとして扱う
+ unsigned char *gat; // If this is NULL the map is not on this map-server
unsigned char *cell; //Contains temporary cell data that is set/unset on tiles.
#ifdef CELL_NOSTACK
unsigned char *cell_bl; //Holds amount of bls in any given cell.
@@ -1350,7 +1350,6 @@ void map_foreachpc(int (*func)(DBKey,void*,va_list),...);
int map_foreachiddb(int (*)(DBKey,void*,va_list),...);
void map_addnickdb(struct map_session_data *);
struct map_session_data * map_nick2sd(const char*);
-char *map_normalize_name(char *mapname);
// その他
int map_check_dir(int s_dir,int t_dir);
diff --git a/src/map/npc.c b/src/map/npc.c
index f4be64e16..9d12fa2d6 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1659,7 +1659,7 @@ int npc_parse_warp (char *w1,char *w2,char *w3,char *w4)
{
int x, y, xs, ys, to_x, to_y, m;
int i;
- char mapname[MAP_NAME_LENGTH], to_mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT], to_mapname[MAP_NAME_LENGTH_EXT];
struct npc_data *nd;
// 引数の個数チェック
@@ -1723,7 +1723,7 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
#define MAX_SHOPITEM 100
char *p;
int x, y, dir, m, pos = 0;
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
struct npc_data *nd;
if (strcmp(w1, "-") == 0) {
@@ -1953,7 +1953,7 @@ static int npc_skip_script (char *w1,char *w2,char *w3,char *w4,char *first_line
static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines,const char* file)
{
int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
unsigned char *srcbuf = NULL;
struct script_code *script;
int srcsize = 65536;
@@ -2380,7 +2380,7 @@ int npc_parse_mob2 (struct spawn_data *mob, int index)
int npc_parse_mob (char *w1, char *w2, char *w3, char *w4)
{
int level, num, class_, mode, x,y,xs,ys;
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
char mobname[NAME_LENGTH];
struct spawn_data mob, *data;
@@ -2515,7 +2515,7 @@ int npc_parse_mob (char *w1, char *w2, char *w3, char *w4)
static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4)
{
int m;
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
int state = 1;
// 引数の個数チェック
@@ -2530,7 +2530,7 @@ static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4)
//マップフラグ
if (strcmpi(w3, "nosave") == 0) {
- char savemap[MAP_NAME_LENGTH];
+ char savemap[MAP_NAME_LENGTH_EXT];
int savex, savey;
if (state == 0)
; //Map flag disabled.
@@ -2764,7 +2764,7 @@ static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4)
static int npc_parse_mapcell (char *w1, char *w2, char *w3, char *w4)
{
int m, cell, x, y, x0, y0, x1, y1;
- char type[24], mapname[MAP_NAME_LENGTH];
+ char type[24], mapname[MAP_NAME_LENGTH_EXT];
if (sscanf(w1, "%15[^,]", mapname) != 1)
return 1;
diff --git a/src/map/script.c b/src/map/script.c
index b0f582b58..602020cf2 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9119,10 +9119,10 @@ BUILDIN_FUNC(flagemblem)
BUILDIN_FUNC(getcastlename)
{
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
struct guild_castle *gc;
- strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH);
+ strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH_EXT);
gc = guild_mapname2gc(mapname);
if(gc)
@@ -9134,13 +9134,13 @@ BUILDIN_FUNC(getcastlename)
BUILDIN_FUNC(getcastledata)
{
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
int index=script_getnum(st,3);
const char *event=NULL;
struct guild_castle *gc;
int i;
- strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH);
+ strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH_EXT);
gc = guild_mapname2gc(mapname);
if(script_hasdata(st,4) && index==0 && gc) {
@@ -9202,12 +9202,12 @@ BUILDIN_FUNC(getcastledata)
BUILDIN_FUNC(setcastledata)
{
- char mapname[MAP_NAME_LENGTH];
+ char mapname[MAP_NAME_LENGTH_EXT];
int index=script_getnum(st,3);
int value=script_getnum(st,4);
struct guild_castle *gc;
- strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH);
+ strncpy(mapname, script_getstr(st,2), MAP_NAME_LENGTH_EXT);
gc = guild_mapname2gc(mapname);
if(gc) {
@@ -11084,9 +11084,9 @@ BUILDIN_FUNC(getsavepoint)
y=sd->status.save_point.y;
switch(type){
case 0:
- mapname=(char *) aMallocA((MAP_NAME_LENGTH+1)*sizeof(char));
+ mapname=(char *) aMallocA((MAP_NAME_LENGTH)*sizeof(char));
memcpy(mapname, mapindex_id2name(sd->status.save_point.map), MAP_NAME_LENGTH);
- mapname[MAP_NAME_LENGTH]='\0';
+ mapname[MAP_NAME_LENGTH-1]='\0';
script_pushstr(st,mapname);
break;
case 1:
@@ -11133,7 +11133,7 @@ BUILDIN_FUNC(getmapxy)
char prefix;
int x,y,type;
- char mapname[MAP_NAME_LENGTH+1];
+ char mapname[MAP_NAME_LENGTH];
memset(mapname, 0, sizeof(mapname));
if( !data_isreference(script_getdata(st,2)) ){
diff --git a/src/map/skill.c b/src/map/skill.c
index 1aaecb778..b44219db1 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -4445,8 +4445,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
} else {
if (sd->skillitem != AL_TELEPORT)
{
- char save_map[MAP_NAME_LENGTH];
- snprintf(save_map, MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->status.save_point.map));
+ char save_map[MAP_NAME_LENGTH_EXT];
+ snprintf(save_map, MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->status.save_point.map));
clif_skill_warppoint(sd,skillid,skilllv,"Random",save_map,"","");
}
else //Autocasted Teleport level 2??
@@ -6086,14 +6086,14 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, int s
case AL_WARP:
if(sd) {
- char memo[4][MAP_NAME_LENGTH] = {"", "", "", ""};
- snprintf(memo[0], MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->status.save_point.map));
+ char memo[4][MAP_NAME_LENGTH_EXT] = {"", "", "", ""};
+ snprintf(memo[0], MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->status.save_point.map));
if (skilllv>1 && sd->status.memo_point[0].map)
- snprintf(memo[1], MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->status.memo_point[0].map));
+ snprintf(memo[1], MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->status.memo_point[0].map));
if (skilllv>2 && sd->status.memo_point[1].map)
- snprintf(memo[2], MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->status.memo_point[1].map));
+ snprintf(memo[2], MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->status.memo_point[1].map));
if (skilllv>3 && sd->status.memo_point[2].map)
- snprintf(memo[3], MAP_NAME_LENGTH, "%s.gat", mapindex_id2name(sd->status.memo_point[2].map));
+ snprintf(memo[3], MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(sd->status.memo_point[2].map));
clif_skill_warppoint(sd,skillid,skilllv,
memo[0],memo[1],memo[2],memo[3]);