- Simplified a bit mmo_char_tobuf (at least it looks cleaner to me now)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9932 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
skotlex 2007-02-28 06:07:41 +00:00
parent 50278812ad
commit 6c66c2095f
2 changed files with 19 additions and 38 deletions

View File

@ -1662,7 +1662,7 @@ int count_users(void) {
/// Writes char data to the buffer in the format used by the client. /// Writes char data to the buffer in the format used by the client.
/// Used in packets 0x6b (chars info) and 0x6d (new char info) /// Used in packets 0x6b (chars info) and 0x6d (new char info)
/// Returns the size (106 or 108) /// Returns the size (106 or 108)
int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p, int new_charscreen) int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
{ {
if( buf == NULL || p == NULL ) if( buf == NULL || p == NULL )
return 0; return 0;
@ -1706,15 +1706,16 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p, int new_charscreen)
WBUFB(buf,101) = (p->int_ > UCHAR_MAX) ? UCHAR_MAX : p->int_; WBUFB(buf,101) = (p->int_ > UCHAR_MAX) ? UCHAR_MAX : p->int_;
WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex; WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex;
WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk; WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk;
//Updated packet structure with rename-button included. Credits to Sara-chan //Updated packet structure with rename-button included. Credits to Sara-chan
#if PACKETVER > 7
WBUFW(buf,104) = p->char_num; WBUFW(buf,104) = p->char_num;
if( new_charscreen ) WBUFW(buf,106) = 1;// Rename bit (0=rename,1=no rename)
{ return 108;
WBUFW(buf,106) = 1;// Rename bit (0=rename,1=no rename) #else
return 108; WBUFB(buf,104) = p->char_num;
}
return 106; return 106;
#endif
} }
//---------------------------------------- //----------------------------------------
@ -1744,13 +1745,7 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
memset(WFIFOP(fd,4), 0, 20);// unknown bytes memset(WFIFOP(fd,4), 0, 20);// unknown bytes
for(i = 0; i < found_num; i++) for(i = 0; i < found_num; i++)
{ j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat[sd->found_char[i]].status);
#if PACKETVER > 7
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat[sd->found_char[i]].status, 1);
#else
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat[sd->found_char[i]].status, 0);
#endif
}
WFIFOW(fd,2) = j;// packet len WFIFOW(fd,2) = j;// packet len
WFIFOSET(fd,j); WFIFOSET(fd,j);
} }
@ -3637,13 +3632,8 @@ int parse_char(int fd) {
int len; int len;
WFIFOHEAD(fd, 110); WFIFOHEAD(fd, 110);
WFIFOW(fd,0) = 0x6d; WFIFOW(fd,0) = 0x6d;
#if PACKETVER > 7 len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status);
len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status, 1);
#else
len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat[i].status, 0);
#endif
WFIFOSET(fd,len); WFIFOSET(fd,len);
RFIFOSKIP(fd,37); RFIFOSKIP(fd,37);
} }
for(ch = 0; ch < 9; ch++) { for(ch = 0; ch < 9; ch++) {

View File

@ -1685,7 +1685,7 @@ int count_users(void) {
/// Writes char data to the buffer in the format used by the client. /// Writes char data to the buffer in the format used by the client.
/// Used in packets 0x6b (chars info) and 0x6d (new char info) /// Used in packets 0x6b (chars info) and 0x6d (new char info)
/// Returns the size (106 or 108) /// Returns the size (106 or 108)
int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p, int new_charscreen) int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p)
{ {
if( buf == NULL || p == NULL ) if( buf == NULL || p == NULL )
return 0; return 0;
@ -1729,15 +1729,15 @@ int mmo_char_tobuf(uint8* buf, struct mmo_charstatus *p, int new_charscreen)
WBUFB(buf,101) = (p->int_ > UCHAR_MAX) ? UCHAR_MAX : p->int_; WBUFB(buf,101) = (p->int_ > UCHAR_MAX) ? UCHAR_MAX : p->int_;
WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex; WBUFB(buf,102) = (p->dex > UCHAR_MAX) ? UCHAR_MAX : p->dex;
WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk; WBUFB(buf,103) = (p->luk > UCHAR_MAX) ? UCHAR_MAX : p->luk;
//Updated packet structure with rename-button included. Credits to Sara-chan //Updated packet structure with rename-button included. Credits to Sara-chan
#if PACKETVER > 7
WBUFW(buf,104) = p->char_num; WBUFW(buf,104) = p->char_num;
if( new_charscreen ) WBUFW(buf,106) = 1;// Rename bit (0=rename,1=no rename)
{ return 108;
WBUFW(buf,106) = 1;// Rename bit (0=rename,1=no rename) #else
return 108; WBUFB(buf,104) = p->char_num;
}
return 106; return 106;
#endif
} }
int mmo_char_send006b(int fd, struct char_session_data *sd) { int mmo_char_send006b(int fd, struct char_session_data *sd) {
@ -1775,15 +1775,10 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
WFIFOHEAD(fd, j + found_num*108); WFIFOHEAD(fd, j + found_num*108);
WFIFOW(fd,0) = 0x6b; WFIFOW(fd,0) = 0x6b;
memset(WFIFOP(fd,4), 0, 20);// unknown bytes memset(WFIFOP(fd,4), 0, 20);// unknown bytes
for(i = 0; i < found_num; i++) for(i = 0; i < found_num; i++)
{ {
mmo_char_fromsql_short(sd->found_char[i], &char_dat); mmo_char_fromsql_short(sd->found_char[i], &char_dat);
#if PACKETVER > 7 j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat);
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat, 1);
#else
j += mmo_char_tobuf(WFIFOP(fd,j), &char_dat, 0);
#endif
} }
WFIFOW(fd,2) = j;// packet len WFIFOW(fd,2) = j;// packet len
WFIFOSET(fd,j); WFIFOSET(fd,j);
@ -3445,11 +3440,7 @@ int parse_char(int fd) {
WFIFOHEAD(fd, 110); WFIFOHEAD(fd, 110);
WFIFOW(fd, 0) = 0x6d; WFIFOW(fd, 0) = 0x6d;
mmo_char_fromsql_short(i, &char_dat); //Only the short data is needed. mmo_char_fromsql_short(i, &char_dat); //Only the short data is needed.
#if PACKETVER > 7 len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat);
len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat, 1);
#else
len = 2 + mmo_char_tobuf(WFIFOP(fd,2), &char_dat, 0);
#endif
WFIFOSET(fd, len); WFIFOSET(fd, len);
RFIFOSKIP(fd, 37); RFIFOSKIP(fd, 37);