summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c140
1 files changed, 50 insertions, 90 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 6ab8ea438..ccd54c086 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1187,21 +1187,15 @@ 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)
+static void 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_name,MAP_NAME_LENGTH_EXT);
+ safestrncpy((char*)WFIFOP(fd,8), mapindex_getmapname_ext(map[m].name,NULL), MAP_NAME_LENGTH_EXT);
WFIFOSET(fd,packet_len(0x192));
-
- return 0;
}
// new and improved weather display [Valaris]
@@ -1650,49 +1644,38 @@ void clif_setwaitclose(int fd)
/*==========================================
*
*------------------------------------------*/
-int clif_changemap(struct map_session_data *sd, short map, int x, int y)
+void clif_changemap(struct map_session_data *sd, short map, int x, int y)
{
int fd;
- char map_name[MAP_NAME_LENGTH_EXT];
-
- nullpo_retr(0, sd);
-
+ nullpo_retv(sd);
fd = sd->fd;
- 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_EXT);
+ safestrncpy((char*)WFIFOP(fd,2), mapindex_getmapname_ext(mapindex_id2name(map),NULL), MAP_NAME_LENGTH_EXT);
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOSET(fd, packet_len(0x91));
-
- return 0;
}
/*==========================================
* Tells the client to connect to another map-server
*------------------------------------------*/
-int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x, int y, uint32 ip, uint16 port)
+void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port)
{
int fd;
-
- nullpo_retr(0, sd);
-
+ nullpo_retv(sd);
fd = sd->fd;
+
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_EXT);
+ safestrncpy((char*)WFIFOP(fd,2), mapindex_getmapname_ext(mapindex_id2name(map_index),NULL), MAP_NAME_LENGTH_EXT);
WFIFOB(fd,17) = 0; //Null terminator for mapname
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
WFIFOL(fd,22) = htonl(ip);
WFIFOW(fd,26) = ntows(htons(port)); // [!] LE byte order here [!]
WFIFOSET(fd, packet_len(0x92));
-
- return 0;
}
int clif_blown(struct block_list *bl)
@@ -4717,22 +4700,21 @@ int clif_skill_delunit(struct skill_unit *unit)
/*==========================================
* ワープ場所選択
*------------------------------------------*/
-int clif_skill_warppoint(struct map_session_data* sd, int skill_num, int skill_lv, int map1, int map2, int map3, int map4)
+void clif_skill_warppoint(struct map_session_data* sd, int skill_num, int skill_lv, int map1, int map2, int map3, int map4)
{
int fd;
-
- nullpo_retr(0, sd);
+ nullpo_retv(sd);
fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x11c));
WFIFOW(fd,0) = 0x11c;
WFIFOW(fd,2) = skill_num;
memset(WFIFOP(fd,4), 0x00, 4*MAP_NAME_LENGTH_EXT);
- if (map1 == -1) strcpy((char*)WFIFOP(fd, 4), "Random");
- if (map1 > 0) snprintf((char*)WFIFOP(fd, 4), MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(map1));
- if (map2 > 0) snprintf((char*)WFIFOP(fd,20), MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(map2));
- if (map3 > 0) snprintf((char*)WFIFOP(fd,36), MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(map3));
- if (map4 > 0) snprintf((char*)WFIFOP(fd,52), MAP_NAME_LENGTH_EXT, "%s.gat", mapindex_id2name(map4));
+ if (map1 == -1) safestrncpy((char*)WFIFOP(fd, 4), "Random", MAP_NAME_LENGTH_EXT);
+ if (map1 > 0) safestrncpy((char*)WFIFOP(fd, 4), mapindex_getmapname_ext(mapindex_id2name(map1),NULL), MAP_NAME_LENGTH_EXT);
+ if (map2 > 0) safestrncpy((char*)WFIFOP(fd,20), mapindex_getmapname_ext(mapindex_id2name(map2),NULL), MAP_NAME_LENGTH_EXT);
+ if (map3 > 0) safestrncpy((char*)WFIFOP(fd,36), mapindex_getmapname_ext(mapindex_id2name(map3),NULL), MAP_NAME_LENGTH_EXT);
+ if (map4 > 0) safestrncpy((char*)WFIFOP(fd,52), mapindex_getmapname_ext(mapindex_id2name(map4),NULL), MAP_NAME_LENGTH_EXT);
WFIFOSET(fd,packet_len(0x11c));
sd->menuskill_id = skill_num;
@@ -4740,7 +4722,6 @@ int clif_skill_warppoint(struct map_session_data* sd, int skill_num, int skill_l
sd->menuskill_val = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here.
else
sd->menuskill_val = skill_lv;
- return 0;
}
/*==========================================
* メモ応答
@@ -5698,7 +5679,6 @@ 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_EXT];
if (!sd) { //Pick any party member (this call is used when changing item share rules)
int i;
@@ -5707,17 +5687,15 @@ 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_EXT, "%s.gat", mapindex_id2name(sd->mapindex));
-
- WBUFW(buf,0)=0x1e9;
- WBUFL(buf,2)= sd->status.account_id;
- WBUFL(buf,6)= 0; //Apparently setting this to 1 makes you adoptable.
- WBUFW(buf,10)=sd->bl.x;
- WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=0; //Unconfirmed byte, could be online/offline.
+ WBUFW(buf, 0) = 0x1e9;
+ WBUFL(buf, 2) = sd->status.account_id;
+ WBUFL(buf, 6) = 0; //Apparently setting this to 1 makes you adoptable.
+ WBUFW(buf,10) = sd->bl.x;
+ WBUFW(buf,12) = sd->bl.y;
+ 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_EXT);
+ safestrncpy((char*)WBUFP(buf,63), mapindex_getmapname_ext(mapindex_id2name(sd->mapindex),NULL), 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);
@@ -5742,17 +5720,13 @@ 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_EXT];
-
if(!m->account_id) continue;
if(party_sd == NULL) party_sd = p->data[i].sd;
- 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_EXT);
+ safestrncpy((char*)WBUFP(buf,28+c*46+28), mapindex_getmapname_ext(mapindex_id2name(m->map),NULL), 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++;
@@ -6016,27 +5990,23 @@ int clif_hpmeter(struct map_session_data *sd)
/*==========================================
* パーティ場所移動(未使用)
*------------------------------------------*/
-int clif_party_move(struct party *p,struct map_session_data *sd,int online)
+void clif_party_move(struct party* p, struct map_session_data* sd, int online)
{
unsigned char buf[128];
- char map_name[MAP_NAME_LENGTH_EXT];
- nullpo_retr(0, sd);
- nullpo_retr(0, p);
-
- 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;
- WBUFL(buf, 6)=0;
- WBUFW(buf,10)=sd->bl.x;
- WBUFW(buf,12)=sd->bl.y;
- WBUFB(buf,14)=!online;
+ nullpo_retv(sd);
+ nullpo_retv(p);
+
+ WBUFW(buf, 0) = 0x104;
+ WBUFL(buf, 2) = sd->status.account_id;
+ WBUFL(buf, 6) = 0;
+ WBUFW(buf,10) = sd->bl.x;
+ WBUFW(buf,12) = sd->bl.y;
+ 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_EXT);
+ safestrncpy((char*)WBUFP(buf,63), mapindex_getmapname_ext(map[sd->bl.m].name,NULL), MAP_NAME_LENGTH_EXT);
clif_send(buf,packet_len(0x104),&sd->bl,PARTY);
- return 0;
}
/*==========================================
* 攻撃するために移動が必要
@@ -6411,13 +6381,10 @@ int clif_bladestop(struct block_list *src,struct block_list *dst,
/*==========================================
*
*------------------------------------------*/
-int clif_changemapcell(int m,int x,int y,int cell_type,int type)
+void clif_changemapcell(short m, short x, short 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;
@@ -6427,13 +6394,8 @@ 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_name,MAP_NAME_LENGTH_EXT);
- if(!type)
- clif_send(buf,packet_len(0x192),&bl,AREA);
- else
- clif_send(buf,packet_len(0x192),&bl,ALL_SAMEMAP);
-
- return 0;
+ safestrncpy((char*)WBUFP(buf,8), mapindex_getmapname_ext(map[m].name,NULL), MAP_NAME_LENGTH_EXT);
+ clif_send(buf,packet_len(0x192),&bl,(!type)?AREA:ALL_SAMEMAP);
}
/*==========================================
@@ -7786,20 +7748,17 @@ void clif_gospel_info(struct map_session_data *sd, int type)
* Info about Star Glaldiator save map [Komurka]
* type: 1: Information, 0: Map registered
*------------------------------------------*/
-void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsigned char 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_EXT];
-
- 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_EXT);
- WFIFOL(fd,26)=sd->bl.id;
- WFIFOB(fd,30)=feel_level;
- WFIFOB(fd,31)=type?1:0;
- WFIFOSET(fd, packet_len(0x20e));
+ WFIFOW(fd,0) = 0x20e;
+ safestrncpy((char*)WFIFOP(fd,2), mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index),NULL), MAP_NAME_LENGTH_EXT);
+ WFIFOL(fd,26) = sd->bl.id;
+ WFIFOB(fd,30) = feel_level;
+ WFIFOB(fd,31) = type?1:0;
+ WFIFOSET(fd,packet_len(0x20e));
}
/*==========================================
@@ -9701,10 +9660,11 @@ void clif_parse_UseSkillToPosMoreInfo(int fd, struct map_session_data *sd)
/*==========================================
* スキル使用(map指定)
*------------------------------------------*/
-void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
+void clif_parse_UseSkillMap(int fd, struct map_session_data* sd)
{
- int skill_num;
- skill_num = RFIFOW(fd,2);
+ int skill_num = RFIFOW(fd,2);
+ char map_name[MAP_NAME_LENGTH];
+ mapindex_getmapname((char*)RFIFOP(fd,4), map_name);
if(skill_num != sd->menuskill_id)
return;
@@ -9716,7 +9676,7 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
}
pc_delinvincibletimer(sd);
- skill_castend_map(sd,skill_num,(char*)RFIFOP(fd,4));
+ skill_castend_map(sd,skill_num,map_name);
}
/*==========================================
* メモ要求