summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--src/char/char.c2
-rw-r--r--src/char_sql/char.c2
-rw-r--r--src/char_sql/int_guild.c1
-rw-r--r--src/common/mapindex.c7
-rw-r--r--src/map/chrif.c1
-rw-r--r--src/map/clif.c39
-rw-r--r--src/map/guild.c2
-rw-r--r--src/map/script.c7
9 files changed, 34 insertions, 29 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 79a163d3e..1900ee2f4 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,8 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+2007/08/09
+ * The new functions now clear junk from the output buffer [ultramage]
2007/08/08
* Moved damage logging to mob_log_damage, now non-damage targetted (or
splash) skills also get logged into the monster's 'damage history' which
diff --git a/src/char/char.c b/src/char/char.c
index b1675b7ab..7d39e6d92 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -3451,7 +3451,7 @@ int parse_char(int fd)
WFIFOHEAD(fd,28);
WFIFOW(fd,0) = 0x71;
WFIFOL(fd,2) = cd->char_id;
- safestrncpy((char*)WFIFOP(fd,6), mapindex_getmapname_ext(mapindex_id2name(cd->last_point.map),NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(mapindex_id2name(cd->last_point.map), (char*)WFIFOP(fd,6));
{
// Advanced subnet check [LuzZza]
uint32 subnet_map_ip;
diff --git a/src/char_sql/char.c b/src/char_sql/char.c
index 1b598b662..d3081df57 100644
--- a/src/char_sql/char.c
+++ b/src/char_sql/char.c
@@ -3187,7 +3187,7 @@ int parse_char(int fd)
WFIFOHEAD(fd,28);
WFIFOW(fd,0) = 0x71;
WFIFOL(fd,2) = char_dat.char_id;
- safestrncpy((char*)WFIFOP(fd,6), mapindex_getmapname_ext(mapindex_id2name(char_dat.last_point.map),NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(mapindex_id2name(char_dat.last_point.map), (char*)WFIFOP(fd,6));
{
// Advanced subnet check [LuzZza]
uint32 subnet_map_ip;
diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c
index e516da9e6..93de44571 100644
--- a/src/char_sql/int_guild.c
+++ b/src/char_sql/int_guild.c
@@ -441,6 +441,7 @@ struct guild * inter_guild_fromsql(int guild_id)
strncpy(g->mes2,sql_row[10],119);
g->emblem_len=atoi(sql_row[11]);
g->emblem_id=atoi(sql_row[12]);
+ //FIXME: check for sql_row[13]==NULL, just in case
for(i=0,pstr=sql_row[13],pEmblemData=g->emblem_data; i < g->emblem_len; i++,pstr+=2){
int c1=pstr[0],c2=pstr[1],x1=0,x2=0;
if(c1>='0' && c1<='9')
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index 7e55daff8..a7f7aca5a 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -39,7 +39,8 @@ const char* mapindex_getmapname(const char* string, char* output)
len -= 4; // strip .gat extension
len = min(len, MAP_NAME_LENGTH-1);
- safestrncpy(dest, string, len+1);
+ strncpy(dest, string, len+1);
+ memset(&dest[len], '\0', MAP_NAME_LENGTH-len);
return dest;
}
@@ -57,12 +58,14 @@ const char* mapindex_getmapname_ext(const char* string, char* output)
len--;
}
- safestrncpy(dest, string, len+1);
+ strncpy(dest, string, len+1);
if (len < 4 || stricmp(&dest[len-4], ".gat") != 0) {
strcpy(&dest[len], ".gat");
len += 4; // add .gat extension
}
+
+ memset(&dest[len], '\0', MAP_NAME_LENGTH_EXT-len);
return dest;
}
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 4a73ffbc6..74733b548 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -314,7 +314,6 @@ int chrif_changemapserver(struct map_session_data* sd, short map, int x, int y,
/// R 2b06 <account_id>.L <login_id1>.L <login_id2>.L <char_id>.L <map_index>.W <x>.W <y>.W <ip>.L <port>.W
int chrif_changemapserverack(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port)
{
-
struct map_session_data *sd;
sd = map_id2sd(account_id);
diff --git a/src/map/clif.c b/src/map/clif.c
index ccd54c086..2c54e0787 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1189,19 +1189,19 @@ static void clif_spiritball_single(int fd, struct map_session_data *sd)
*------------------------------------------*/
static void clif_set0192(int fd, int m, int x, int y, int type)
{
- WFIFOHEAD(fd, packet_len(0x192));
+ WFIFOHEAD(fd,packet_len(0x192));
WFIFOW(fd,0) = 0x192;
WFIFOW(fd,2) = x;
WFIFOW(fd,4) = y;
WFIFOW(fd,6) = type;
- safestrncpy((char*)WFIFOP(fd,8), mapindex_getmapname_ext(map[m].name,NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(map[m].name, (char*)WFIFOP(fd,8));
WFIFOSET(fd,packet_len(0x192));
}
// new and improved weather display [Valaris]
static void clif_weather_sub(int fd, int id, int type)
{
- WFIFOHEAD(fd, packet_len(0x1f3));
+ WFIFOHEAD(fd,packet_len(0x1f3));
WFIFOW(fd,0) = 0x1f3;
WFIFOL(fd,2) = id;
WFIFOL(fd,6) = type;
@@ -1650,12 +1650,12 @@ void clif_changemap(struct map_session_data *sd, short map, int x, int y)
nullpo_retv(sd);
fd = sd->fd;
- WFIFOHEAD(fd, packet_len(0x91));
+ WFIFOHEAD(fd,packet_len(0x91));
WFIFOW(fd,0) = 0x91;
- safestrncpy((char*)WFIFOP(fd,2), mapindex_getmapname_ext(mapindex_id2name(map),NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(mapindex_id2name(map), (char*)WFIFOP(fd,2));
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
- WFIFOSET(fd, packet_len(0x91));
+ WFIFOSET(fd,packet_len(0x91));
}
/*==========================================
@@ -1667,15 +1667,14 @@ void clif_changemapserver(struct map_session_data* sd, unsigned short map_index,
nullpo_retv(sd);
fd = sd->fd;
- WFIFOHEAD(fd, packet_len(0x92));
+ WFIFOHEAD(fd,packet_len(0x92));
WFIFOW(fd,0) = 0x92;
- 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
+ mapindex_getmapname_ext(mapindex_id2name(map_index), (char*)WFIFOP(fd,2));
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));
+ WFIFOSET(fd,packet_len(0x92));
}
int clif_blown(struct block_list *bl)
@@ -4710,11 +4709,11 @@ void clif_skill_warppoint(struct map_session_data* sd, int skill_num, int skill_
WFIFOW(fd,0) = 0x11c;
WFIFOW(fd,2) = skill_num;
memset(WFIFOP(fd,4), 0x00, 4*MAP_NAME_LENGTH_EXT);
- 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);
+ if (map1 == -1) strcpy((char*)WFIFOP(fd,4), "Random");
+ if (map1 > 0) mapindex_getmapname_ext(mapindex_id2name(map1), (char*)WFIFOP(fd,4));
+ if (map2 > 0) mapindex_getmapname_ext(mapindex_id2name(map2), (char*)WFIFOP(fd,20));
+ if (map3 > 0) mapindex_getmapname_ext(mapindex_id2name(map3), (char*)WFIFOP(fd,36));
+ if (map4 > 0) mapindex_getmapname_ext(mapindex_id2name(map4), (char*)WFIFOP(fd,52));
WFIFOSET(fd,packet_len(0x11c));
sd->menuskill_id = skill_num;
@@ -5695,7 +5694,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);
- safestrncpy((char*)WBUFP(buf,63), mapindex_getmapname_ext(mapindex_id2name(sd->mapindex),NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(mapindex_id2name(sd->mapindex), (char*)WBUFP(buf,63));
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);
@@ -5726,7 +5725,7 @@ int clif_party_info(struct party_data* p, struct map_session_data *sd)
WBUFL(buf,28+c*46) = m->account_id;
memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH);
- safestrncpy((char*)WBUFP(buf,28+c*46+28), mapindex_getmapname_ext(mapindex_id2name(m->map),NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(mapindex_id2name(m->map), (char*)WBUFP(buf,28+c*46+28));
WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1;
WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1;
c++;
@@ -6005,7 +6004,7 @@ void 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);
- safestrncpy((char*)WBUFP(buf,63), mapindex_getmapname_ext(map[sd->bl.m].name,NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(map[sd->bl.m].name, (char*)WBUFP(buf,63));
clif_send(buf,packet_len(0x104),&sd->bl,PARTY);
}
/*==========================================
@@ -6394,7 +6393,7 @@ void clif_changemapcell(short m, short x, short y, int cell_type, int type)
WBUFW(buf,2) = x;
WBUFW(buf,4) = y;
WBUFW(buf,6) = cell_type;
- safestrncpy((char*)WBUFP(buf,8), mapindex_getmapname_ext(map[m].name,NULL), MAP_NAME_LENGTH_EXT);
+ mapindex_getmapname_ext(map[m].name,(char*)WBUFP(buf,8));
clif_send(buf,packet_len(0x192),&bl,(!type)?AREA:ALL_SAMEMAP);
}
@@ -7754,7 +7753,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig
WFIFOHEAD(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);
+ mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), (char*)WFIFOP(fd,2));
WFIFOL(fd,26) = sd->bl.id;
WFIFOB(fd,30) = feel_level;
WFIFOB(fd,31) = type?1:0;
diff --git a/src/map/guild.c b/src/map/guild.c
index ba0fc2829..b1a8ea8a2 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -185,7 +185,7 @@ static int guild_read_castledb(void)
gc=(struct guild_castle *)aCalloc(1,sizeof(struct guild_castle));
gc->castle_id=atoi(str[0]);
- safestrncpy(gc->map_name,mapindex_getmapname(str[1],NULL),MAP_NAME_LENGTH);
+ mapindex_getmapname(str[1],gc->map_name);
safestrncpy(gc->castle_name,str[2],NAME_LENGTH);
safestrncpy(gc->castle_event,str[3],NAME_LENGTH);
diff --git a/src/map/script.c b/src/map/script.c
index 8412d0019..a08d06466 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9650,10 +9650,11 @@ BUILDIN_FUNC(getcastledata)
BUILDIN_FUNC(setcastledata)
{
- int index=script_getnum(st,3);
- int value=script_getnum(st,4);
+ const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL);
+ int index = script_getnum(st,3);
+ int value = script_getnum(st,4);
- struct guild_castle* gc = guild_mapname2gc( mapindex_getmapname(script_getstr(st,2),NULL) );
+ struct guild_castle* gc = guild_mapname2gc(mapname);
if(gc) {
// Save Data byself First