diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-02-11 00:16:06 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-02-11 00:16:06 +0000 |
commit | 08fe962c3b802a708bcbd45f8a86bb2a36db811d (patch) | |
tree | 5d6a40151bb9e113de0d48425c7663f47074a8e8 /src/map/clif.c | |
parent | 20d720940edea88e061e00bb54e6e5b4cc2c0902 (diff) | |
download | hercules-08fe962c3b802a708bcbd45f8a86bb2a36db811d.tar.gz hercules-08fe962c3b802a708bcbd45f8a86bb2a36db811d.tar.bz2 hercules-08fe962c3b802a708bcbd45f8a86bb2a36db811d.tar.xz hercules-08fe962c3b802a708bcbd45f8a86bb2a36db811d.zip |
Fixed clif_party_message using an incorrect buffer length
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9845 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 535a215eb..576943c3f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5727,40 +5727,42 @@ int clif_party_join_info(struct party *p, struct map_session_data *sd) /*========================================== - * パーティ情報送信 - *------------------------------------------ - */ -int clif_party_info(struct party_data *p,int fd) + * Sends party information + * R 00fb <len>.w <party name>.24B {<ID>.l <nick>.24B <map name>.16B <leader>.B <offline>.B}.46B* + *------------------------------------------*/ +int clif_party_info(struct party_data* p, int fd) { - unsigned char buf[1024]; - int i,c; - struct map_session_data *sd=NULL; + unsigned char buf[2+2+NAME_LENGTH+(4+NAME_LENGTH+MAP_NAME_LENGTH+1+1)*MAX_PARTY]; + struct map_session_data* sd = NULL; + int i, c; nullpo_retr(0, p); - WBUFW(buf,0)=0xfb; - memcpy(WBUFP(buf,4),p->party.name,NAME_LENGTH); - for(i=c=0;i<MAX_PARTY;i++){ - struct party_member *m=&p->party.member[i]; - if(!m->account_id) - continue; - if(sd==NULL) sd=p->data[i].sd; - 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),mapindex_id2name(m->map),MAP_NAME_LENGTH); - WBUFB(buf,28+c*46+44)=(m->leader)?0:1; - WBUFB(buf,28+c*46+45)=(m->online)?0:1; + WBUFW(buf,0) = 0xfb; + memcpy(WBUFP(buf,4), p->party.name, NAME_LENGTH); + for(i = 0, c = 0; i < MAX_PARTY; i++) + { + struct party_member* m = &p->party.member[i]; + if(!m->account_id) continue; + + if(sd == NULL) sd = p->data[i].sd; // need at least one member's 'sd' so clif_send() can identify the party + + 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), mapindex_id2name(m->map), MAP_NAME_LENGTH); + WBUFB(buf,28+c*46+44) = (m->leader) ? 0 : 1; + WBUFB(buf,28+c*46+45) = (m->online) ? 0 : 1; c++; } - WBUFW(buf,2)=28+c*46; - if(fd>=0){ // fdが設定されてるならそれに送る - WFIFOHEAD(fd, 28+c*46); - memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2)); - WFIFOSET(fd,WFIFOW(fd,2)); - return 9; - } - if(sd!=NULL) - clif_send(buf,WBUFW(buf,2),&sd->bl,PARTY); + WBUFW(buf,2) = 28+c*46; + + if(fd >= 0) // send only to self + if (session[fd] && session[fd]->session_data) + clif_send(buf, WBUFW(buf,2), &((struct map_session_data *)session[fd]->session_data)->bl, SELF); + else // send to whole party + if(sd) + clif_send(buf, WBUFW(buf,2), &sd->bl, PARTY); + return 0; } /*========================================== |