From 60a426c0742b3e7d8c5b557c7578df6eeeea377b Mon Sep 17 00:00:00 2001 From: brianluau Date: Wed, 5 Dec 2012 02:53:33 +0000 Subject: - Undid r16968: SVN Replaced with source:/trunk/src/@16966 (tid:74924). [16969:16991/trunk/src/] will be re-committed in the next 24 hours. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16992 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 21226 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 10713 insertions(+), 10513 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 362930b84..5e7c7f9bf 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -56,8 +56,8 @@ static struct eri *delay_clearunit_ers; //#define DUMP_INVALID_PACKET struct Clif_Config { - int packet_db_ver; //Preferred packet version. - int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex] + int packet_db_ver; //Preferred packet version. + int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex] } clif_config; struct s_packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; @@ -65,120 +65,120 @@ struct s_packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; //Converts item type in case of pet eggs. static inline int itemtype(int type) { - return (type == IT_PETEGG) ? IT_WEAPON : type; + return ( type == IT_PETEGG ) ? IT_WEAPON : type; } -static inline void WBUFPOS(uint8 *p, unsigned short pos, short x, short y, unsigned char dir) +static inline void WBUFPOS(uint8* p, unsigned short pos, short x, short y, unsigned char dir) { - p += pos; - p[0] = (uint8)(x>>2); - p[1] = (uint8)((x<<6) | ((y>>4)&0x3f)); - p[2] = (uint8)((y<<4) | (dir&0xf)); + p += pos; + p[0] = (uint8)(x>>2); + p[1] = (uint8)((x<<6) | ((y>>4)&0x3f)); + p[2] = (uint8)((y<<4) | (dir&0xf)); } // client-side: x0+=sx0*0.0625-0.5 and y0+=sy0*0.0625-0.5 -static inline void WBUFPOS2(uint8 *p, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0) +static inline void WBUFPOS2(uint8* p, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0) { - p += pos; - p[0] = (uint8)(x0>>2); - p[1] = (uint8)((x0<<6) | ((y0>>4)&0x3f)); - p[2] = (uint8)((y0<<4) | ((x1>>6)&0x0f)); - p[3] = (uint8)((x1<<2) | ((y1>>8)&0x03)); - p[4] = (uint8)y1; - p[5] = (uint8)((sx0<<4) | (sy0&0x0f)); + p += pos; + p[0] = (uint8)(x0>>2); + p[1] = (uint8)((x0<<6) | ((y0>>4)&0x3f)); + p[2] = (uint8)((y0<<4) | ((x1>>6)&0x0f)); + p[3] = (uint8)((x1<<2) | ((y1>>8)&0x03)); + p[4] = (uint8)y1; + p[5] = (uint8)((sx0<<4) | (sy0&0x0f)); } static inline void WFIFOPOS(int fd, unsigned short pos, short x, short y, unsigned char dir) { - WBUFPOS(WFIFOP(fd,pos), 0, x, y, dir); + WBUFPOS(WFIFOP(fd,pos), 0, x, y, dir); } static inline void WFIFOPOS2(int fd, unsigned short pos, short x0, short y0, short x1, short y1, unsigned char sx0, unsigned char sy0) { - WBUFPOS2(WFIFOP(fd,pos), 0, x0, y0, x1, y1, sx0, sy0); + WBUFPOS2(WFIFOP(fd,pos), 0, x0, y0, x1, y1, sx0, sy0); } -static inline void RBUFPOS(const uint8 *p, unsigned short pos, short *x, short *y, unsigned char *dir) +static inline void RBUFPOS(const uint8* p, unsigned short pos, short* x, short* y, unsigned char* dir) { - p += pos; + p += pos; - if (x) { - x[0] = ((p[0] & 0xff) << 2) | (p[1] >> 6); - } + if( x ) { + x[0] = ( ( p[0] & 0xff ) << 2 ) | ( p[1] >> 6 ); + } - if (y) { - y[0] = ((p[1] & 0x3f) << 4) | (p[2] >> 4); - } + if( y ) { + y[0] = ( ( p[1] & 0x3f ) << 4 ) | ( p[2] >> 4 ); + } - if (dir) { - dir[0] = (p[2] & 0x0f); - } + if( dir ) { + dir[0] = ( p[2] & 0x0f ); + } } -static inline void RBUFPOS2(const uint8 *p, unsigned short pos, short *x0, short *y0, short *x1, short *y1, unsigned char *sx0, unsigned char *sy0) +static inline void RBUFPOS2(const uint8* p, unsigned short pos, short* x0, short* y0, short* x1, short* y1, unsigned char* sx0, unsigned char* sy0) { - p += pos; + p += pos; - if (x0) { - x0[0] = ((p[0] & 0xff) << 2) | (p[1] >> 6); - } + if( x0 ) { + x0[0] = ( ( p[0] & 0xff ) << 2 ) | ( p[1] >> 6 ); + } - if (y0) { - y0[0] = ((p[1] & 0x3f) << 4) | (p[2] >> 4); - } + if( y0 ) { + y0[0] = ( ( p[1] & 0x3f ) << 4 ) | ( p[2] >> 4 ); + } - if (x1) { - x1[0] = ((p[2] & 0x0f) << 6) | (p[3] >> 2); - } + if( x1 ) { + x1[0] = ( ( p[2] & 0x0f ) << 6 ) | ( p[3] >> 2 ); + } - if (y1) { - y1[0] = ((p[3] & 0x03) << 8) | (p[4] >> 0); - } + if( y1 ) { + y1[0] = ( ( p[3] & 0x03 ) << 8 ) | ( p[4] >> 0 ); + } - if (sx0) { - sx0[0] = (p[5] & 0xf0) >> 4; - } + if( sx0 ) { + sx0[0] = ( p[5] & 0xf0 ) >> 4; + } - if (sy0) { - sy0[0] = (p[5] & 0x0f) >> 0; - } + if( sy0 ) { + sy0[0] = ( p[5] & 0x0f ) >> 0; + } } -static inline void RFIFOPOS(int fd, unsigned short pos, short *x, short *y, unsigned char *dir) +static inline void RFIFOPOS(int fd, unsigned short pos, short* x, short* y, unsigned char* dir) { - RBUFPOS(RFIFOP(fd,pos), 0, x, y, dir); + RBUFPOS(RFIFOP(fd,pos), 0, x, y, dir); } -static inline void RFIFOPOS2(int fd, unsigned short pos, short *x0, short *y0, short *x1, short *y1, unsigned char *sx0, unsigned char *sy0) +static inline void RFIFOPOS2(int fd, unsigned short pos, short* x0, short* y0, short* x1, short* y1, unsigned char* sx0, unsigned char* sy0) { - RBUFPOS2(WFIFOP(fd,pos), 0, x0, y0, x1, y1, sx0, sy0); + RBUFPOS2(WFIFOP(fd,pos), 0, x0, y0, x1, y1, sx0, sy0); } //To idenfity disguised characters. -static inline bool disguised(struct block_list *bl) +static inline bool disguised(struct block_list* bl) { - return (bool)(bl->type == BL_PC && ((TBL_PC *)bl)->disguise); + return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise ); } //Guarantees that the given string does not exceeds the allowed size, as well as making sure it's null terminated. [Skotlex] -static inline unsigned int mes_len_check(char *mes, unsigned int len, unsigned int max) +static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned int max) { - if (len > max) - len = max; + if( len > max ) + len = max; - mes[len-1] = '\0'; + mes[len-1] = '\0'; - return len; + return len; } @@ -188,34 +188,34 @@ static uint32 bind_ip = INADDR_ANY; static uint16 map_port = 5121; int map_fd; -static int clif_parse(int fd); +static int clif_parse (int fd); /*========================================== * Ip setting of map-server *------------------------------------------*/ -int clif_setip(const char *ip) +int clif_setip(const char* ip) { - char ip_str[16]; - map_ip = host2ip(ip); - if (!map_ip) { - ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip); - return 0; - } + char ip_str[16]; + map_ip = host2ip(ip); + if (!map_ip) { + ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip); + return 0; + } - strncpy(map_ip_str, ip, sizeof(map_ip_str)); - ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(map_ip, ip_str)); - return 1; + strncpy(map_ip_str, ip, sizeof(map_ip_str)); + ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(map_ip, ip_str)); + return 1; } -void clif_setbindip(const char *ip) +void clif_setbindip(const char* ip) { - char ip_str[16]; - bind_ip = host2ip(ip); - if (bind_ip) { - ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(bind_ip, ip_str)); - } else { - ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip); - } + char ip_str[16]; + bind_ip = host2ip(ip); + if (bind_ip) { + ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(bind_ip, ip_str)); + } else { + ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip); + } } /*========================================== @@ -224,7 +224,7 @@ void clif_setbindip(const char *ip) *------------------------------------------*/ void clif_setport(uint16 port) { - map_port = port; + map_port = port; } /*========================================== @@ -232,21 +232,21 @@ void clif_setport(uint16 port) *------------------------------------------*/ uint32 clif_getip(void) { - return map_ip; + return map_ip; } //Refreshes map_server ip, returns the new ip if the ip changed, otherwise it returns 0. uint32 clif_refresh_ip(void) { - uint32 new_ip; + uint32 new_ip; - new_ip = host2ip(map_ip_str); - if (new_ip && new_ip != map_ip) { - map_ip = new_ip; - ShowInfo("Updating IP resolution of [%s].\n", map_ip_str); - return map_ip; - } - return 0; + new_ip = host2ip(map_ip_str); + if (new_ip && new_ip != map_ip) { + map_ip = new_ip; + ShowInfo("Updating IP resolution of [%s].\n", map_ip_str); + return map_ip; + } + return 0; } /*========================================== @@ -254,36 +254,24 @@ uint32 clif_refresh_ip(void) *------------------------------------------*/ uint16 clif_getport(void) { - return map_port; + return map_port; } #if PACKETVER >= 20071106 -static inline unsigned char clif_bl_type(struct block_list *bl) -{ - switch (bl->type) { - case BL_PC: - return disguised(bl)?0x1:0x0; //PC_TYPE - case BL_ITEM: - return 0x2; //ITEM_TYPE - case BL_SKILL: - return 0x3; //SKILL_TYPE - case BL_CHAT: - return 0x4; //UNKNOWN_TYPE - case BL_MOB: - return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE - case BL_NPC: - return 0x6; //NPC_EVT_TYPE - case BL_PET: - return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE - case BL_HOM: - return 0x8; //NPC_HOM_TYPE - case BL_MER: - return 0x9; //NPC_MERSOL_TYPE - case BL_ELEM: - return 0xa; //NPC_ELEMENTAL_TYPE - default: - return 0x1; //NPC_TYPE - } +static inline unsigned char clif_bl_type(struct block_list *bl) { + switch (bl->type) { + case BL_PC: return disguised(bl)?0x1:0x0; //PC_TYPE + case BL_ITEM: return 0x2; //ITEM_TYPE + case BL_SKILL: return 0x3; //SKILL_TYPE + case BL_CHAT: return 0x4; //UNKNOWN_TYPE + case BL_MOB: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE + case BL_NPC: return 0x6; //NPC_EVT_TYPE + case BL_PET: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE + case BL_HOM: return 0x8; //NPC_HOM_TYPE + case BL_MER: return 0x9; //NPC_MERSOL_TYPE + case BL_ELEM: return 0xa; //NPC_ELEMENTAL_TYPE + default: return 0x1; //NPC_TYPE + } } #endif @@ -299,338 +287,352 @@ static inline unsigned char clif_bl_type(struct block_list *bl) *------------------------------------------*/ static int clif_send_sub(struct block_list *bl, va_list ap) { - struct block_list *src_bl; - struct map_session_data *sd; - unsigned char *buf; - int len, type, fd; - - nullpo_ret(bl); - nullpo_ret(sd = (struct map_session_data *)bl); - - fd = sd->fd; - if (!fd) //Don't send to disconnected clients. - return 0; - - buf = va_arg(ap,unsigned char *); - len = va_arg(ap,int); - nullpo_ret(src_bl = va_arg(ap,struct block_list *)); - type = va_arg(ap,int); - - switch (type) { - case AREA_WOS: - if (bl == src_bl) - return 0; - break; - case AREA_WOC: - if (sd->chatID || bl == src_bl) - return 0; - break; - case AREA_WOSC: { - if (src_bl->type == BL_PC) { - struct map_session_data *ssd = (struct map_session_data *)src_bl; - if (ssd && sd->chatID && (sd->chatID == ssd->chatID)) - return 0; - } else if (src_bl->type == BL_NPC) { - struct npc_data *nd = (struct npc_data *)src_bl; - if (nd && sd->chatID && (sd->chatID == nd->chat_id)) - return 0; - } - } - break; - } - - if (session[fd] == NULL) - return 0; - - WFIFOHEAD(fd, len); - if (WFIFOP(fd,0) == buf) { - ShowError("WARNING: Invalid use of clif_send function\n"); - ShowError(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0)); - ShowError(" Please correct your code.\n"); - // don't send to not move the pointer of the packet for next sessions in the loop - //WFIFOSET(fd,0);//## TODO is this ok? - //NO. It is not ok. There is the chance WFIFOSET actually sends the buffer data, and shifts elements around, which will corrupt the buffer. - return 0; - } - - if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - - return 0; + struct block_list *src_bl; + struct map_session_data *sd; + unsigned char *buf; + int len, type, fd; + + nullpo_ret(bl); + nullpo_ret(sd = (struct map_session_data *)bl); + + fd = sd->fd; + if (!fd) //Don't send to disconnected clients. + return 0; + + buf = va_arg(ap,unsigned char*); + len = va_arg(ap,int); + nullpo_ret(src_bl = va_arg(ap,struct block_list*)); + type = va_arg(ap,int); + + switch(type) + { + case AREA_WOS: + if (bl == src_bl) + return 0; + break; + case AREA_WOC: + if (sd->chatID || bl == src_bl) + return 0; + break; + case AREA_WOSC: + { + if(src_bl->type == BL_PC){ + struct map_session_data *ssd = (struct map_session_data *)src_bl; + if (ssd && sd->chatID && (sd->chatID == ssd->chatID)) + return 0; + } + else if(src_bl->type == BL_NPC) { + struct npc_data *nd = (struct npc_data *)src_bl; + if (nd && sd->chatID && (sd->chatID == nd->chat_id)) + return 0; + } + } + break; + } + + if (session[fd] == NULL) + return 0; + + WFIFOHEAD(fd, len); + if (WFIFOP(fd,0) == buf) { + ShowError("WARNING: Invalid use of clif_send function\n"); + ShowError(" Packet x%4x use a WFIFO of a player instead of to use a buffer.\n", WBUFW(buf,0)); + ShowError(" Please correct your code.\n"); + // don't send to not move the pointer of the packet for next sessions in the loop + //WFIFOSET(fd,0);//## TODO is this ok? + //NO. It is not ok. There is the chance WFIFOSET actually sends the buffer data, and shifts elements around, which will corrupt the buffer. + return 0; + } + + if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + } + + return 0; } /*========================================== * Packet Delegation (called on all packets that require data to be sent to more than one client) * functions that are sent solely to one use whose ID it posses use WFIFOSET *------------------------------------------*/ -int clif_send(const uint8 *buf, int len, struct block_list *bl, enum send_target type) -{ - int i; - struct map_session_data *sd, *tsd; - struct party_data *p = NULL; - struct guild *g = NULL; - struct battleground_data *bg = NULL; - int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd; - struct s_mapiterator *iter; - - if (type != ALL_CLIENT && type != CHAT_MAINCHAT) - nullpo_ret(bl); - - sd = BL_CAST(BL_PC, bl); - - switch (type) { - - case ALL_CLIENT: //All player clients. - iter = mapit_getallusers(); - while ((tsd = (TBL_PC *)mapit_next(iter)) != NULL) { - if (packet_db[tsd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(tsd->fd, len); - memcpy(WFIFOP(tsd->fd,0), buf, len); - WFIFOSET(tsd->fd,len); - } - } - mapit_free(iter); - break; - - case ALL_SAMEMAP: //All players on the same map - iter = mapit_getallusers(); - while ((tsd = (TBL_PC *)mapit_next(iter)) != NULL) { - if (bl->m == tsd->bl.m && packet_db[tsd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(tsd->fd, len); - memcpy(WFIFOP(tsd->fd,0), buf, len); - WFIFOSET(tsd->fd,len); - } - } - mapit_free(iter); - break; - - case AREA: - case AREA_WOSC: - if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex] - clif_send(buf, len, bl, SELF); - case AREA_WOC: - case AREA_WOS: - map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, - BL_PC, buf, len, bl, type); - break; - case AREA_CHAT_WOC: - map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), - bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); - break; - - case CHAT: - case CHAT_WOS: { - struct chat_data *cd; - if (sd) { - cd = (struct chat_data *)map_id2bl(sd->chatID); - } else if (bl->type == BL_CHAT) { - cd = (struct chat_data *)bl; - } else break; - if (cd == NULL) - break; - for (i = 0; i < cd->users; i++) { - if (type == CHAT_WOS && cd->usersd[i] == sd) - continue; - if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version - if ((fd=cd->usersd[i]->fd) >0 && session[fd]) { // Added check to see if session exists [PoW] - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - } - } - } - break; - - case CHAT_MAINCHAT: //[LuzZza] - iter = mapit_getallusers(); - while ((tsd = (TBL_PC *)mapit_next(iter)) != NULL) { - if (tsd->state.mainchat && tsd->chatID == 0 && packet_db[tsd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(tsd->fd, len); - memcpy(WFIFOP(tsd->fd,0), buf, len); - WFIFOSET(tsd->fd,len); - } - } - mapit_free(iter); - break; - - case PARTY_AREA: - case PARTY_AREA_WOS: - x0 = bl->x - AREA_SIZE; - y0 = bl->y - AREA_SIZE; - x1 = bl->x + AREA_SIZE; - y1 = bl->y + AREA_SIZE; - case PARTY: - case PARTY_WOS: - case PARTY_SAMEMAP: - case PARTY_SAMEMAP_WOS: - if (sd && sd->status.party_id) - p = party_search(sd->status.party_id); - - if (p) { - for (i=0; idata[i].sd) == NULL) - continue; - - if (!(fd=sd->fd)) - continue; - - if (sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS)) - continue; - - if (type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m) - continue; - - if ((type == PARTY_AREA || type == PARTY_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1)) - continue; - - if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - } - if (!enable_spy) //Skip unnecessary parsing. [Skotlex] - break; - - iter = mapit_getallusers(); - while ((tsd = (TBL_PC *)mapit_next(iter)) != NULL) { - if (tsd->partyspy == p->party.party_id && packet_db[tsd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(tsd->fd, len); - memcpy(WFIFOP(tsd->fd,0), buf, len); - WFIFOSET(tsd->fd,len); - } - } - mapit_free(iter); - } - break; - - case DUEL: - case DUEL_WOS: - if (!sd || !sd->duel_group) break; //Invalid usage. - - iter = mapit_getallusers(); - while ((tsd = (TBL_PC *)mapit_next(iter)) != NULL) { - if (type == DUEL_WOS && bl->id == tsd->bl.id) - continue; - if (sd->duel_group == tsd->duel_group && packet_db[tsd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(tsd->fd, len); - memcpy(WFIFOP(tsd->fd,0), buf, len); - WFIFOSET(tsd->fd,len); - } - } - mapit_free(iter); - break; - - case SELF: - if (sd && (fd=sd->fd) && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - break; - - // New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex] - case GUILD_AREA: - case GUILD_AREA_WOS: - x0 = bl->x - AREA_SIZE; - y0 = bl->y - AREA_SIZE; - x1 = bl->x + AREA_SIZE; - y1 = bl->y + AREA_SIZE; - case GUILD_SAMEMAP: - case GUILD_SAMEMAP_WOS: - case GUILD: - case GUILD_WOS: - case GUILD_NOBG: - if (sd && sd->status.guild_id) - g = guild_search(sd->status.guild_id); - - if (g) { - for (i = 0; i < g->max_member; i++) { - if ((sd = g->member[i].sd) != NULL) { - if (!(fd=sd->fd)) - continue; - - if (type == GUILD_NOBG && sd->bg_id) - continue; - - if (sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS)) - continue; - - if (type != GUILD && type != GUILD_NOBG && type != GUILD_WOS && sd->bl.m != bl->m) - continue; - - if ((type == GUILD_AREA || type == GUILD_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1)) - continue; - - if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - } - } - if (!enable_spy) //Skip unnecessary parsing. [Skotlex] - break; - - iter = mapit_getallusers(); - while ((tsd = (TBL_PC *)mapit_next(iter)) != NULL) { - if (tsd->guildspy == g->guild_id && packet_db[tsd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(tsd->fd, len); - memcpy(WFIFOP(tsd->fd,0), buf, len); - WFIFOSET(tsd->fd,len); - } - } - mapit_free(iter); - } - break; - - case BG_AREA: - case BG_AREA_WOS: - x0 = bl->x - AREA_SIZE; - y0 = bl->y - AREA_SIZE; - x1 = bl->x + AREA_SIZE; - y1 = bl->y + AREA_SIZE; - case BG_SAMEMAP: - case BG_SAMEMAP_WOS: - case BG: - case BG_WOS: - if (sd && sd->bg_id && (bg = bg_team_search(sd->bg_id)) != NULL) { - for (i = 0; i < MAX_BG_MEMBERS; i++) { - if ((sd = bg->members[i].sd) == NULL || !(fd = sd->fd)) - continue; - if (sd->bl.id == bl->id && (type == BG_WOS || type == BG_SAMEMAP_WOS || type == BG_AREA_WOS)) - continue; - if (type != BG && type != BG_WOS && sd->bl.m != bl->m) - continue; - if ((type == BG_AREA || type == BG_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1)) - continue; - if (packet_db[sd->packet_ver][RBUFW(buf,0)].len) { - // packet must exist for the client version - WFIFOHEAD(fd,len); - memcpy(WFIFOP(fd,0), buf, len); - WFIFOSET(fd,len); - } - } - } - break; - - default: - ShowError("clif_send: Unrecognized type %d\n",type); - return -1; - } - - return 0; +int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type) +{ + int i; + struct map_session_data *sd, *tsd; + struct party_data *p = NULL; + struct guild *g = NULL; + struct battleground_data *bg = NULL; + int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd; + struct s_mapiterator* iter; + + if( type != ALL_CLIENT && type != CHAT_MAINCHAT ) + nullpo_ret(bl); + + sd = BL_CAST(BL_PC, bl); + + switch(type) { + + case ALL_CLIENT: //All player clients. + iter = mapit_getallusers(); + while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) + { + if( packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(tsd->fd, len); + memcpy(WFIFOP(tsd->fd,0), buf, len); + WFIFOSET(tsd->fd,len); + } + } + mapit_free(iter); + break; + + case ALL_SAMEMAP: //All players on the same map + iter = mapit_getallusers(); + while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) + { + if( bl->m == tsd->bl.m && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(tsd->fd, len); + memcpy(WFIFOP(tsd->fd,0), buf, len); + WFIFOSET(tsd->fd,len); + } + } + mapit_free(iter); + break; + + case AREA: + case AREA_WOSC: + if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex] + clif_send (buf, len, bl, SELF); + case AREA_WOC: + case AREA_WOS: + map_foreachinarea(clif_send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, + BL_PC, buf, len, bl, type); + break; + case AREA_CHAT_WOC: + map_foreachinarea(clif_send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), + bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); + break; + + case CHAT: + case CHAT_WOS: + { + struct chat_data *cd; + if (sd) { + cd = (struct chat_data*)map_id2bl(sd->chatID); + } else if (bl->type == BL_CHAT) { + cd = (struct chat_data*)bl; + } else break; + if (cd == NULL) + break; + for(i = 0; i < cd->users; i++) { + if (type == CHAT_WOS && cd->usersd[i] == sd) + continue; + if (packet_db[cd->usersd[i]->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version + if ((fd=cd->usersd[i]->fd) >0 && session[fd]) // Added check to see if session exists [PoW] + { + WFIFOHEAD(fd,len); + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + } + } + } + } + break; + + case CHAT_MAINCHAT: //[LuzZza] + iter = mapit_getallusers(); + while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) + { + if( tsd->state.mainchat && tsd->chatID == 0 && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(tsd->fd, len); + memcpy(WFIFOP(tsd->fd,0), buf, len); + WFIFOSET(tsd->fd,len); + } + } + mapit_free(iter); + break; + + case PARTY_AREA: + case PARTY_AREA_WOS: + x0 = bl->x - AREA_SIZE; + y0 = bl->y - AREA_SIZE; + x1 = bl->x + AREA_SIZE; + y1 = bl->y + AREA_SIZE; + case PARTY: + case PARTY_WOS: + case PARTY_SAMEMAP: + case PARTY_SAMEMAP_WOS: + if (sd && sd->status.party_id) + p = party_search(sd->status.party_id); + + if (p) { + for(i=0;idata[i].sd) == NULL ) + continue; + + if( !(fd=sd->fd) ) + continue; + + if( sd->bl.id == bl->id && (type == PARTY_WOS || type == PARTY_SAMEMAP_WOS || type == PARTY_AREA_WOS) ) + continue; + + if( type != PARTY && type != PARTY_WOS && bl->m != sd->bl.m ) + continue; + + if( (type == PARTY_AREA || type == PARTY_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) ) + continue; + + if( packet_db[sd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(fd,len); + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + } + } + if (!enable_spy) //Skip unnecessary parsing. [Skotlex] + break; + + iter = mapit_getallusers(); + while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) + { + if( tsd->partyspy == p->party.party_id && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(tsd->fd, len); + memcpy(WFIFOP(tsd->fd,0), buf, len); + WFIFOSET(tsd->fd,len); + } + } + mapit_free(iter); + } + break; + + case DUEL: + case DUEL_WOS: + if (!sd || !sd->duel_group) break; //Invalid usage. + + iter = mapit_getallusers(); + while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) + { + if( type == DUEL_WOS && bl->id == tsd->bl.id ) + continue; + if( sd->duel_group == tsd->duel_group && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(tsd->fd, len); + memcpy(WFIFOP(tsd->fd,0), buf, len); + WFIFOSET(tsd->fd,len); + } + } + mapit_free(iter); + break; + + case SELF: + if (sd && (fd=sd->fd) && packet_db[sd->packet_ver][RBUFW(buf,0)].len) { // packet must exist for the client version + WFIFOHEAD(fd,len); + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + } + break; + + // New definitions for guilds [Valaris] - Cleaned up and reorganized by [Skotlex] + case GUILD_AREA: + case GUILD_AREA_WOS: + x0 = bl->x - AREA_SIZE; + y0 = bl->y - AREA_SIZE; + x1 = bl->x + AREA_SIZE; + y1 = bl->y + AREA_SIZE; + case GUILD_SAMEMAP: + case GUILD_SAMEMAP_WOS: + case GUILD: + case GUILD_WOS: + case GUILD_NOBG: + if (sd && sd->status.guild_id) + g = guild_search(sd->status.guild_id); + + if (g) { + for(i = 0; i < g->max_member; i++) { + if( (sd = g->member[i].sd) != NULL ) + { + if( !(fd=sd->fd) ) + continue; + + if( type == GUILD_NOBG && sd->bg_id ) + continue; + + if( sd->bl.id == bl->id && (type == GUILD_WOS || type == GUILD_SAMEMAP_WOS || type == GUILD_AREA_WOS) ) + continue; + + if( type != GUILD && type != GUILD_NOBG && type != GUILD_WOS && sd->bl.m != bl->m ) + continue; + + if( (type == GUILD_AREA || type == GUILD_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) ) + continue; + + if( packet_db[sd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(fd,len); + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + } + } + } + if (!enable_spy) //Skip unnecessary parsing. [Skotlex] + break; + + iter = mapit_getallusers(); + while( (tsd = (TBL_PC*)mapit_next(iter)) != NULL ) + { + if( tsd->guildspy == g->guild_id && packet_db[tsd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(tsd->fd, len); + memcpy(WFIFOP(tsd->fd,0), buf, len); + WFIFOSET(tsd->fd,len); + } + } + mapit_free(iter); + } + break; + + case BG_AREA: + case BG_AREA_WOS: + x0 = bl->x - AREA_SIZE; + y0 = bl->y - AREA_SIZE; + x1 = bl->x + AREA_SIZE; + y1 = bl->y + AREA_SIZE; + case BG_SAMEMAP: + case BG_SAMEMAP_WOS: + case BG: + case BG_WOS: + if( sd && sd->bg_id && (bg = bg_team_search(sd->bg_id)) != NULL ) + { + for( i = 0; i < MAX_BG_MEMBERS; i++ ) + { + if( (sd = bg->members[i].sd) == NULL || !(fd = sd->fd) ) + continue; + if( sd->bl.id == bl->id && (type == BG_WOS || type == BG_SAMEMAP_WOS || type == BG_AREA_WOS) ) + continue; + if( type != BG && type != BG_WOS && sd->bl.m != bl->m ) + continue; + if( (type == BG_AREA || type == BG_AREA_WOS) && (sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1) ) + continue; + if( packet_db[sd->packet_ver][RBUFW(buf,0)].len ) + { // packet must exist for the client version + WFIFOHEAD(fd,len); + memcpy(WFIFOP(fd,0), buf, len); + WFIFOSET(fd,len); + } + } + } + break; + + default: + ShowError("clif_send: Unrecognized type %d\n",type); + return -1; + } + + return 0; } @@ -640,22 +642,22 @@ int clif_send(const uint8 *buf, int len, struct block_list *bl, enum send_target void clif_authok(struct map_session_data *sd) { #if PACKETVER < 20080102 - const int cmd = 0x73; + const int cmd = 0x73; #else - const int cmd = 0x2eb; + const int cmd = 0x2eb; #endif - int fd = sd->fd; - - WFIFOHEAD(fd,packet_len(cmd)); - WFIFOW(fd, 0) = cmd; - WFIFOL(fd, 2) = gettick(); - WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir); - WFIFOB(fd, 9) = 5; // ignored - WFIFOB(fd,10) = 5; // ignored + int fd = sd->fd; + + WFIFOHEAD(fd,packet_len(cmd)); + WFIFOW(fd, 0) = cmd; + WFIFOL(fd, 2) = gettick(); + WFIFOPOS(fd, 6, sd->bl.x, sd->bl.y, sd->ud.dir); + WFIFOB(fd, 9) = 5; // ignored + WFIFOB(fd,10) = 5; // ignored #if PACKETVER >= 20080102 - WFIFOW(fd,11) = sd->user_font; // FIXME: Font is currently not saved. + WFIFOW(fd,11) = sd->user_font; // FIXME: Font is currently not saved. #endif - WFIFOSET(fd,packet_len(cmd)); + WFIFOSET(fd,packet_len(cmd)); } @@ -669,10 +671,10 @@ void clif_authok(struct map_session_data *sd) /// 4 = mobile - waiting state void clif_authrefuse(int fd, uint8 error_code) { - WFIFOHEAD(fd,packet_len(0x74)); - WFIFOW(fd,0) = 0x74; - WFIFOB(fd,2) = error_code; - WFIFOSET(fd,packet_len(0x74)); + WFIFOHEAD(fd,packet_len(0x74)); + WFIFOW(fd,0) = 0x74; + WFIFOB(fd,2) = error_code; + WFIFOSET(fd,packet_len(0x74)); } @@ -710,14 +712,14 @@ void clif_authrefuse(int fd, uint8 error_code) /// ? = disconnected -> MsgStringTable[3] void clif_authfail_fd(int fd, int type) { - if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players! - return; + if (!fd || !session[fd] || session[fd]->func_parse != clif_parse) //clif_authfail should only be invoked on players! + return; - WFIFOHEAD(fd, packet_len(0x81)); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = type; - WFIFOSET(fd,packet_len(0x81)); - set_eof(fd); + WFIFOHEAD(fd, packet_len(0x81)); + WFIFOW(fd,0) = 0x81; + WFIFOB(fd,2) = type; + WFIFOSET(fd,packet_len(0x81)); + set_eof(fd); } @@ -728,43 +730,43 @@ void clif_authfail_fd(int fd, int type) /// ? = nothing void clif_charselectok(int id, uint8 ok) { - struct map_session_data *sd; - int fd; + struct map_session_data* sd; + int fd; - if ((sd = map_id2sd(id)) == NULL || !sd->fd) - return; + if ((sd = map_id2sd(id)) == NULL || !sd->fd) + return; - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xb3)); - WFIFOW(fd,0) = 0xb3; - WFIFOB(fd,2) = ok; - WFIFOSET(fd,packet_len(0xb3)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xb3)); + WFIFOW(fd,0) = 0xb3; + WFIFOB(fd,2) = ok; + WFIFOSET(fd,packet_len(0xb3)); } /// Makes an item appear on the ground. /// 009e .L .W .B .W .W .B .B .W (ZC_ITEM_FALL_ENTRY) /// 084b (ZC_ITEM_FALL_ENTRY4) -void clif_dropflooritem(struct flooritem_data *fitem) +void clif_dropflooritem(struct flooritem_data* fitem) { - uint8 buf[17]; - int view; + uint8 buf[17]; + int view; - nullpo_retv(fitem); + nullpo_retv(fitem); - if (fitem->item_data.nameid <= 0) - return; + if (fitem->item_data.nameid <= 0) + return; - WBUFW(buf, 0) = 0x9e; - WBUFL(buf, 2) = fitem->bl.id; - WBUFW(buf, 6) = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid; - WBUFB(buf, 8) = fitem->item_data.identify; - WBUFW(buf, 9) = fitem->bl.x; - WBUFW(buf,11) = fitem->bl.y; - WBUFB(buf,13) = fitem->subx; - WBUFB(buf,14) = fitem->suby; - WBUFW(buf,15) = fitem->item_data.amount; + WBUFW(buf, 0) = 0x9e; + WBUFL(buf, 2) = fitem->bl.id; + WBUFW(buf, 6) = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid; + WBUFB(buf, 8) = fitem->item_data.identify; + WBUFW(buf, 9) = fitem->bl.x; + WBUFW(buf,11) = fitem->bl.y; + WBUFB(buf,13) = fitem->subx; + WBUFB(buf,14) = fitem->suby; + WBUFW(buf,15) = fitem->item_data.amount; - clif_send(buf, packet_len(0x9e), &fitem->bl, AREA); + clif_send(buf, packet_len(0x9e), &fitem->bl, AREA); } @@ -773,20 +775,20 @@ void clif_dropflooritem(struct flooritem_data *fitem) /// 00a1 .L (ZC_ITEM_DISAPPEAR) void clif_clearflooritem(struct flooritem_data *fitem, int fd) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(fitem); + nullpo_retv(fitem); - WBUFW(buf,0) = 0xa1; - WBUFL(buf,2) = fitem->bl.id; + WBUFW(buf,0) = 0xa1; + WBUFL(buf,2) = fitem->bl.id; - if (fd == 0) { - clif_send(buf, packet_len(0xa1), &fitem->bl, AREA); - } else { - WFIFOHEAD(fd,packet_len(0xa1)); - memcpy(WFIFOP(fd,0), buf, packet_len(0xa1)); - WFIFOSET(fd,packet_len(0xa1)); - } + if (fd == 0) { + clif_send(buf, packet_len(0xa1), &fitem->bl, AREA); + } else { + WFIFOHEAD(fd,packet_len(0xa1)); + memcpy(WFIFOP(fd,0), buf, packet_len(0xa1)); + WFIFOSET(fd,packet_len(0xa1)); + } } @@ -800,11 +802,11 @@ void clif_clearflooritem(struct flooritem_data *fitem, int fd) /// 4 = trickdead void clif_clearunit_single(int id, clr_type type, int fd) { - WFIFOHEAD(fd, packet_len(0x80)); - WFIFOW(fd,0) = 0x80; - WFIFOL(fd,2) = id; - WFIFOB(fd,6) = type; - WFIFOSET(fd, packet_len(0x80)); + WFIFOHEAD(fd, packet_len(0x80)); + WFIFOW(fd,0) = 0x80; + WFIFOL(fd,2) = id; + WFIFOB(fd,6) = type; + WFIFOSET(fd, packet_len(0x80)); } /// Makes a unit (char, npc, mob, homun) disappear to all clients in area (ZC_NOTIFY_VANISH). @@ -815,22 +817,22 @@ void clif_clearunit_single(int id, clr_type type, int fd) /// 2 = logged out /// 3 = teleport /// 4 = trickdead -void clif_clearunit_area(struct block_list *bl, clr_type type) +void clif_clearunit_area(struct block_list* bl, clr_type type) { - unsigned char buf[8]; + unsigned char buf[8]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x80; - WBUFL(buf,2) = bl->id; - WBUFB(buf,6) = type; + WBUFW(buf,0) = 0x80; + WBUFL(buf,2) = bl->id; + WBUFB(buf,6) = type; - clif_send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA : AREA_WOS); + clif_send(buf, packet_len(0x80), bl, type == CLR_DEAD ? AREA : AREA_WOS); - if (disguised(bl)) { - WBUFL(buf,2) = -bl->id; - clif_send(buf, packet_len(0x80), bl, SELF); - } + if(disguised(bl)) { + WBUFL(buf,2) = -bl->id; + clif_send(buf, packet_len(0x80), bl, SELF); + } } @@ -839,352 +841,361 @@ void clif_clearunit_area(struct block_list *bl, clr_type type) /// automatically. static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, intptr_t data) { - struct block_list *bl = (struct block_list *)data; - clif_clearunit_area(bl, (clr_type) id); - ers_free(delay_clearunit_ers,bl); - return 0; + struct block_list *bl = (struct block_list *)data; + clif_clearunit_area(bl, (clr_type) id); + ers_free(delay_clearunit_ers,bl); + return 0; } -void clif_clearunit_delayed(struct block_list *bl, clr_type type, unsigned int tick) +void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int tick) { - struct block_list *tbl = ers_alloc(delay_clearunit_ers, struct block_list); - memcpy(tbl, bl, sizeof(struct block_list)); - add_timer(tick, clif_clearunit_delayed_sub, (int)type, (intptr_t)tbl); + struct block_list *tbl = ers_alloc(delay_clearunit_ers, struct block_list); + memcpy (tbl, bl, sizeof (struct block_list)); + add_timer(tick, clif_clearunit_delayed_sub, (int)type, (intptr_t)tbl); } -void clif_get_weapon_view(struct map_session_data *sd, unsigned short *rhand, unsigned short *lhand) +void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand) { - if (sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER)) { - *rhand = *lhand = 0; - return; - } + if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER)) + { + *rhand = *lhand = 0; + return; + } #if PACKETVER < 4 - *rhand = sd->status.weapon; - *lhand = sd->status.shield; + *rhand = sd->status.weapon; + *lhand = sd->status.shield; #else - if (sd->equip_index[EQI_HAND_R] >= 0 && - sd->inventory_data[sd->equip_index[EQI_HAND_R]]) { - struct item_data *id = sd->inventory_data[sd->equip_index[EQI_HAND_R]]; - if (id->view_id > 0) - *rhand = id->view_id; - else - *rhand = id->nameid; - } else - *rhand = 0; - - if (sd->equip_index[EQI_HAND_L] >= 0 && - sd->equip_index[EQI_HAND_L] != sd->equip_index[EQI_HAND_R] && - sd->inventory_data[sd->equip_index[EQI_HAND_L]]) { - struct item_data *id = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; - if (id->view_id > 0) - *lhand = id->view_id; - else - *lhand = id->nameid; - } else - *lhand = 0; + if (sd->equip_index[EQI_HAND_R] >= 0 && + sd->inventory_data[sd->equip_index[EQI_HAND_R]]) + { + struct item_data* id = sd->inventory_data[sd->equip_index[EQI_HAND_R]]; + if (id->view_id > 0) + *rhand = id->view_id; + else + *rhand = id->nameid; + } else + *rhand = 0; + + if (sd->equip_index[EQI_HAND_L] >= 0 && + sd->equip_index[EQI_HAND_L] != sd->equip_index[EQI_HAND_R] && + sd->inventory_data[sd->equip_index[EQI_HAND_L]]) + { + struct item_data* id = sd->inventory_data[sd->equip_index[EQI_HAND_L]]; + if (id->view_id > 0) + *lhand = id->view_id; + else + *lhand = id->nameid; + } else + *lhand = 0; #endif } //To make the assignation of the level based on limits clearer/easier. [Skotlex] static int clif_setlevel_sub(int lv) { - if (lv < battle_config.max_lv) { - ; - } else if (lv < battle_config.aura_lv) { - lv = battle_config.max_lv - 1; - } else { - lv = battle_config.max_lv; - } - - return lv; -} - -static int clif_setlevel(struct block_list *bl) -{ - int lv = status_get_lv(bl); - if (battle_config.client_limit_unit_lv&bl->type) - return clif_setlevel_sub(lv); - switch (bl->type) { - case BL_NPC: - case BL_PET: - // npcs and pets do not have level - return 0; - } - return lv; + if( lv < battle_config.max_lv ) + { + ; + } + else if( lv < battle_config.aura_lv ) + { + lv = battle_config.max_lv - 1; + } + else + { + lv = battle_config.max_lv; + } + + return lv; +} + +static int clif_setlevel(struct block_list* bl) +{ + int lv = status_get_lv(bl); + if( battle_config.client_limit_unit_lv&bl->type ) + return clif_setlevel_sub(lv); + switch( bl->type ) + { + case BL_NPC: + case BL_PET: + // npcs and pets do not have level + return 0; + } + return lv; } /*========================================== * Prepares 'unit standing/spawning' packet *------------------------------------------*/ -static int clif_set_unit_idle(struct block_list *bl, unsigned char *buffer, bool spawn) +static int clif_set_unit_idle(struct block_list* bl, unsigned char* buffer, bool spawn) { - struct map_session_data *sd; - struct status_change *sc = status_get_sc(bl); - struct view_data *vd = status_get_viewdata(bl); - unsigned char *buf = WBUFP(buffer,0); + struct map_session_data* sd; + struct status_change* sc = status_get_sc(bl); + struct view_data* vd = status_get_viewdata(bl); + unsigned char *buf = WBUFP(buffer,0); #if PACKETVER < 20091103 - bool type = !pcdb_checkid(vd->class_); + bool type = !pcdb_checkid(vd->class_); #endif #if PACKETVER >= 7 - unsigned short offset = 0; + unsigned short offset = 0; #endif #if PACKETVER >= 20091103 - const char *name; + const char *name; #endif - sd = BL_CAST(BL_PC, bl); + sd = BL_CAST(BL_PC, bl); #if PACKETVER < 20091103 - if (type) - WBUFW(buf,0) = spawn?0x7c:0x78; - else + if(type) + WBUFW(buf,0) = spawn?0x7c:0x78; + else #endif #if PACKETVER < 4 - WBUFW(buf,0) = spawn?0x79:0x78; + WBUFW(buf,0) = spawn?0x79:0x78; #elif PACKETVER < 7 - WBUFW(buf,0) = spawn?0x1d9:0x1d8; + WBUFW(buf,0) = spawn?0x1d9:0x1d8; #elif PACKETVER < 20080102 - WBUFW(buf,0) = spawn?0x22b:0x22a; + WBUFW(buf,0) = spawn?0x22b:0x22a; #elif PACKETVER < 20091103 - WBUFW(buf,0) = spawn?0x2ed:0x2ee; + WBUFW(buf,0) = spawn?0x2ed:0x2ee; #elif PACKETVER < 20101124 - WBUFW(buf,0) = spawn?0x7f8:0x7f9; + WBUFW(buf,0) = spawn?0x7f8:0x7f9; #else - WBUFW(buf,0) = spawn?0x858:0x857; + WBUFW(buf,0) = spawn?0x858:0x857; #endif #if PACKETVER >= 20091103 - name = status_get_name(bl); + name = status_get_name(bl); #if PACKETVER < 20110111 - WBUFW(buf,2) = (spawn?62:63)+strlen(name); + WBUFW(buf,2) = (spawn?62:63)+strlen(name); #else - WBUFW(buf,2) = (spawn?64:65)+strlen(name); + WBUFW(buf,2) = (spawn?64:65)+strlen(name); #endif - WBUFB(buf,4) = clif_bl_type(bl); - offset+=3; - buf = WBUFP(buffer,offset); + WBUFB(buf,4) = clif_bl_type(bl); + offset+=3; + buf = WBUFP(buffer,offset); #elif PACKETVER >= 20071106 - if (type) { //Non-player packets - WBUFB(buf,2) = clif_bl_type(bl); - offset++; - buf = WBUFP(buffer,offset); - } + if (type) { //Non-player packets + WBUFB(buf,2) = clif_bl_type(bl); + offset++; + buf = WBUFP(buffer,offset); + } #endif - WBUFL(buf, 2) = bl->id; - WBUFW(buf, 6) = status_get_speed(bl); - WBUFW(buf, 8) = (sc)? sc->opt1 : 0; - WBUFW(buf,10) = (sc)? sc->opt2 : 0; + WBUFL(buf, 2) = bl->id; + WBUFW(buf, 6) = status_get_speed(bl); + WBUFW(buf, 8) = (sc)? sc->opt1 : 0; + WBUFW(buf,10) = (sc)? sc->opt2 : 0; #if PACKETVER < 20091103 - if (type&&spawn) { //uses an older and different packet structure - WBUFW(buf,12) = (sc)? sc->option : 0; - WBUFW(buf,14) = vd->hair_style; - WBUFW(buf,16) = vd->weapon; - WBUFW(buf,18) = vd->head_bottom; - WBUFW(buf,20) = vd->class_; //Pet armor (ignored by client) - WBUFW(buf,22) = vd->shield; - } else { + if (type&&spawn) { //uses an older and different packet structure + WBUFW(buf,12) = (sc)? sc->option : 0; + WBUFW(buf,14) = vd->hair_style; + WBUFW(buf,16) = vd->weapon; + WBUFW(buf,18) = vd->head_bottom; + WBUFW(buf,20) = vd->class_; //Pet armor (ignored by client) + WBUFW(buf,22) = vd->shield; + } else { #endif #if PACKETVER >= 20091103 - WBUFL(buf,12) = (sc)? sc->option : 0; - offset+=2; - buf = WBUFP(buffer,offset); + WBUFL(buf,12) = (sc)? sc->option : 0; + offset+=2; + buf = WBUFP(buffer,offset); #elif PACKETVER >= 7 - if (!type) { - WBUFL(buf,12) = (sc)? sc->option : 0; - offset+=2; - buf = WBUFP(buffer,offset); - } else - WBUFW(buf,12) = (sc)? sc->option : 0; + if (!type) { + WBUFL(buf,12) = (sc)? sc->option : 0; + offset+=2; + buf = WBUFP(buffer,offset); + } else + WBUFW(buf,12) = (sc)? sc->option : 0; #else - WBUFW(buf,12) = (sc)? sc->option : 0; + WBUFW(buf,12) = (sc)? sc->option : 0; #endif - WBUFW(buf,14) = vd->class_; - WBUFW(buf,16) = vd->hair_style; - WBUFW(buf,18) = vd->weapon; + WBUFW(buf,14) = vd->class_; + WBUFW(buf,16) = vd->hair_style; + WBUFW(buf,18) = vd->weapon; #if PACKETVER < 4 - WBUFW(buf,20) = vd->head_bottom; - WBUFW(buf,22) = vd->shield; + WBUFW(buf,20) = vd->head_bottom; + WBUFW(buf,22) = vd->shield; #else - WBUFW(buf,20) = vd->shield; - WBUFW(buf,22) = vd->head_bottom; + WBUFW(buf,20) = vd->shield; + WBUFW(buf,22) = vd->head_bottom; #endif #if PACKETVER < 20091103 - } + } #endif - WBUFW(buf,24) = vd->head_top; - WBUFW(buf,26) = vd->head_mid; - - if (bl->type == BL_NPC && vd->class_ == FLAG_CLASS) { - //The hell, why flags work like this? - WBUFW(buf,22) = status_get_emblem_id(bl); - WBUFW(buf,24) = GetWord(status_get_guild_id(bl), 1); - WBUFW(buf,26) = GetWord(status_get_guild_id(bl), 0); - } - - WBUFW(buf,28) = vd->hair_color; - WBUFW(buf,30) = vd->cloth_color; - WBUFW(buf,32) = (sd)? sd->head_dir : 0; + WBUFW(buf,24) = vd->head_top; + WBUFW(buf,26) = vd->head_mid; + + if( bl->type == BL_NPC && vd->class_ == FLAG_CLASS ) + { //The hell, why flags work like this? + WBUFW(buf,22) = status_get_emblem_id(bl); + WBUFW(buf,24) = GetWord(status_get_guild_id(bl), 1); + WBUFW(buf,26) = GetWord(status_get_guild_id(bl), 0); + } + + WBUFW(buf,28) = vd->hair_color; + WBUFW(buf,30) = vd->cloth_color; + WBUFW(buf,32) = (sd)? sd->head_dir : 0; #if PACKETVER < 20091103 - if (type&&spawn) { //End of packet 0x7c - WBUFB(buf,34) = (sd)?sd->status.karma:0; // karma - WBUFB(buf,35) = vd->sex; - WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl)); - WBUFB(buf,39) = 0; - WBUFB(buf,40) = 0; - return packet_len(0x7c); - } + if (type&&spawn) { //End of packet 0x7c + WBUFB(buf,34) = (sd)?sd->status.karma:0; // karma + WBUFB(buf,35) = vd->sex; + WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl)); + WBUFB(buf,39) = 0; + WBUFB(buf,40) = 0; + return packet_len(0x7c); + } #endif #if PACKETVER >= 20110111 - WBUFW(buf,34) = vd->robe; - offset+= 2; - buf = WBUFP(buffer,offset); + WBUFW(buf,34) = vd->robe; + offset+= 2; + buf = WBUFP(buffer,offset); #endif - WBUFL(buf,34) = status_get_guild_id(bl); - WBUFW(buf,38) = status_get_emblem_id(bl); - WBUFW(buf,40) = (sd)? sd->status.manner : 0; + WBUFL(buf,34) = status_get_guild_id(bl); + WBUFW(buf,38) = status_get_emblem_id(bl); + WBUFW(buf,40) = (sd)? sd->status.manner : 0; #if PACKETVER >= 20091103 - WBUFL(buf,42) = (sc)? sc->opt3 : 0; - offset+=2; - buf = WBUFP(buffer,offset); + WBUFL(buf,42) = (sc)? sc->opt3 : 0; + offset+=2; + buf = WBUFP(buffer,offset); #elif PACKETVER >= 7 - if (!type) { - WBUFL(buf,42) = (sc)? sc->opt3 : 0; - offset+=2; - buf = WBUFP(buffer,offset); - } else - WBUFW(buf,42) = (sc)? sc->opt3 : 0; + if (!type) { + WBUFL(buf,42) = (sc)? sc->opt3 : 0; + offset+=2; + buf = WBUFP(buffer,offset); + } else + WBUFW(buf,42) = (sc)? sc->opt3 : 0; #else - WBUFW(buf,42) = (sc)? sc->opt3 : 0; + WBUFW(buf,42) = (sc)? sc->opt3 : 0; #endif - WBUFB(buf,44) = (sd)? sd->status.karma : 0; - WBUFB(buf,45) = vd->sex; - WBUFPOS(buf,46,bl->x,bl->y,unit_getdir(bl)); - WBUFB(buf,49) = (sd)? 5 : 0; - WBUFB(buf,50) = (sd)? 5 : 0; - if (!spawn) { - WBUFB(buf,51) = vd->dead_sit; - offset++; - buf = WBUFP(buffer,offset); - } - WBUFW(buf,51) = clif_setlevel(bl); + WBUFB(buf,44) = (sd)? sd->status.karma : 0; + WBUFB(buf,45) = vd->sex; + WBUFPOS(buf,46,bl->x,bl->y,unit_getdir(bl)); + WBUFB(buf,49) = (sd)? 5 : 0; + WBUFB(buf,50) = (sd)? 5 : 0; + if (!spawn) { + WBUFB(buf,51) = vd->dead_sit; + offset++; + buf = WBUFP(buffer,offset); + } + WBUFW(buf,51) = clif_setlevel(bl); #if PACKETVER < 20091103 - if (type) //End for non-player packet - return packet_len(WBUFW(buffer,0)); + if (type) //End for non-player packet + return packet_len(WBUFW(buffer,0)); #endif #if PACKETVER >= 20080102 - WBUFW(buf,53) = sd?sd->user_font:0; + WBUFW(buf,53) = sd?sd->user_font:0; #endif #if PACKETVER >= 20091103 - memcpy((char *)WBUFP(buf,55), name, NAME_LENGTH); - return WBUFW(buffer,2); + memcpy((char*)WBUFP(buf,55), name, NAME_LENGTH); + return WBUFW(buffer,2); #else - return packet_len(WBUFW(buffer,0)); + return packet_len(WBUFW(buffer,0)); #endif } /*========================================== * Prepares 'unit walking' packet *------------------------------------------*/ -static int clif_set_unit_walking(struct block_list *bl, struct unit_data *ud, unsigned char *buffer) +static int clif_set_unit_walking(struct block_list* bl, struct unit_data* ud, unsigned char* buffer) { - struct map_session_data *sd; - struct status_change *sc = status_get_sc(bl); - struct view_data *vd = status_get_viewdata(bl); - unsigned char *buf = WBUFP(buffer,0); + struct map_session_data* sd; + struct status_change* sc = status_get_sc(bl); + struct view_data* vd = status_get_viewdata(bl); + unsigned char* buf = WBUFP(buffer,0); #if PACKETVER >= 7 - unsigned short offset = 0; + unsigned short offset = 0; #endif #if PACKETVER >= 20091103 - const char *name; + const char *name; #endif - sd = BL_CAST(BL_PC, bl); + sd = BL_CAST(BL_PC, bl); #if PACKETVER < 4 - WBUFW(buf, 0) = 0x7b; + WBUFW(buf, 0) = 0x7b; #elif PACKETVER < 7 - WBUFW(buf, 0) = 0x1da; + WBUFW(buf, 0) = 0x1da; #elif PACKETVER < 20080102 - WBUFW(buf, 0) = 0x22c; + WBUFW(buf, 0) = 0x22c; #elif PACKETVER < 20091103 - WBUFW(buf, 0) = 0x2ec; + WBUFW(buf, 0) = 0x2ec; #elif PACKETVER < 20101124 - WBUFW(buf, 0) = 0x7f7; + WBUFW(buf, 0) = 0x7f7; #else - WBUFW(buf, 0) = 0x856; + WBUFW(buf, 0) = 0x856; #endif #if PACKETVER >= 20091103 - name = status_get_name(bl); + name = status_get_name(bl); #if PACKETVER < 20110111 - WBUFW(buf, 2) = 69+strlen(name); + WBUFW(buf, 2) = 69+strlen(name); #else - WBUFW(buf, 2) = 71+strlen(name); + WBUFW(buf, 2) = 71+strlen(name); #endif - offset+=2; - buf = WBUFP(buffer,offset); + offset+=2; + buf = WBUFP(buffer,offset); #endif #if PACKETVER >= 20071106 - WBUFB(buf, 2) = clif_bl_type(bl); - offset++; - buf = WBUFP(buffer,offset); + WBUFB(buf, 2) = clif_bl_type(bl); + offset++; + buf = WBUFP(buffer,offset); #endif - WBUFL(buf, 2) = bl->id; - WBUFW(buf, 6) = status_get_speed(bl); - WBUFW(buf, 8) = (sc)? sc->opt1 : 0; - WBUFW(buf,10) = (sc)? sc->opt2 : 0; + WBUFL(buf, 2) = bl->id; + WBUFW(buf, 6) = status_get_speed(bl); + WBUFW(buf, 8) = (sc)? sc->opt1 : 0; + WBUFW(buf,10) = (sc)? sc->opt2 : 0; #if PACKETVER < 7 - WBUFW(buf,12) = (sc)? sc->option : 0; + WBUFW(buf,12) = (sc)? sc->option : 0; #else - WBUFL(buf,12) = (sc)? sc->option : 0; - offset+=2; //Shift the rest of elements by 2 bytes. - buf = WBUFP(buffer,offset); + WBUFL(buf,12) = (sc)? sc->option : 0; + offset+=2; //Shift the rest of elements by 2 bytes. + buf = WBUFP(buffer,offset); #endif - WBUFW(buf,14) = vd->class_; - WBUFW(buf,16) = vd->hair_style; - WBUFW(buf,18) = vd->weapon; + WBUFW(buf,14) = vd->class_; + WBUFW(buf,16) = vd->hair_style; + WBUFW(buf,18) = vd->weapon; #if PACKETVER < 4 - WBUFW(buf,20) = vd->head_bottom; - WBUFL(buf,22) = gettick(); - WBUFW(buf,26) = vd->shield; + WBUFW(buf,20) = vd->head_bottom; + WBUFL(buf,22) = gettick(); + WBUFW(buf,26) = vd->shield; #else - WBUFW(buf,20) = vd->shield; - WBUFW(buf,22) = vd->head_bottom; - WBUFL(buf,24) = gettick(); + WBUFW(buf,20) = vd->shield; + WBUFW(buf,22) = vd->head_bottom; + WBUFL(buf,24) = gettick(); #endif - WBUFW(buf,28) = vd->head_top; - WBUFW(buf,30) = vd->head_mid; - WBUFW(buf,32) = vd->hair_color; - WBUFW(buf,34) = vd->cloth_color; - WBUFW(buf,36) = (sd)? sd->head_dir : 0; + WBUFW(buf,28) = vd->head_top; + WBUFW(buf,30) = vd->head_mid; + WBUFW(buf,32) = vd->hair_color; + WBUFW(buf,34) = vd->cloth_color; + WBUFW(buf,36) = (sd)? sd->head_dir : 0; #if PACKETVER >= 20110111 - WBUFW(buf,38) = vd->robe; - offset+= 2; - buf = WBUFP(buffer,offset); + WBUFW(buf,38) = vd->robe; + offset+= 2; + buf = WBUFP(buffer,offset); #endif - WBUFL(buf,38) = status_get_guild_id(bl); - WBUFW(buf,42) = status_get_emblem_id(bl); - WBUFW(buf,44) = (sd)? sd->status.manner : 0; + WBUFL(buf,38) = status_get_guild_id(bl); + WBUFW(buf,42) = status_get_emblem_id(bl); + WBUFW(buf,44) = (sd)? sd->status.manner : 0; #if PACKETVER < 7 - WBUFW(buf,46) = (sc)? sc->opt3 : 0; + WBUFW(buf,46) = (sc)? sc->opt3 : 0; #else - WBUFL(buf,46) = (sc)? sc->opt3 : 0; - offset+=2; //Shift the rest of elements by 2 bytes. - buf = WBUFP(buffer,offset); + WBUFL(buf,46) = (sc)? sc->opt3 : 0; + offset+=2; //Shift the rest of elements by 2 bytes. + buf = WBUFP(buffer,offset); #endif - WBUFB(buf,48) = (sd)? sd->status.karma : 0; - WBUFB(buf,49) = vd->sex; - WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFB(buf,56) = (sd)? 5 : 0; - WBUFB(buf,57) = (sd)? 5 : 0; - WBUFW(buf,58) = clif_setlevel(bl); + WBUFB(buf,48) = (sd)? sd->status.karma : 0; + WBUFB(buf,49) = vd->sex; + WBUFPOS2(buf,50,bl->x,bl->y,ud->to_x,ud->to_y,8,8); + WBUFB(buf,56) = (sd)? 5 : 0; + WBUFB(buf,57) = (sd)? 5 : 0; + WBUFW(buf,58) = clif_setlevel(bl); #if PACKETVER >= 20080102 - WBUFW(buf,60) = sd?sd->user_font:0; + WBUFW(buf,60) = sd?sd->user_font:0; #endif #if PACKETVER >= 20091103 - memcpy((char *)WBUFP(buf,62), name, NAME_LENGTH); - return WBUFW(buffer,2); + memcpy((char*)WBUFP(buf,62), name, NAME_LENGTH); + return WBUFW(buffer,2); #else - return packet_len(WBUFW(buffer,0)); + return packet_len(WBUFW(buffer,0)); #endif } @@ -1193,15 +1204,15 @@ static int clif_set_unit_walking(struct block_list *bl, struct unit_data *ud, un static void clif_setdisguise(struct block_list *bl, unsigned char *buf,int len) { #if PACKETVER >= 20091103 - WBUFB(buf,4)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE - WBUFL(buf,5)=-bl->id; + WBUFB(buf,4)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + WBUFL(buf,5)=-bl->id; #elif PACKETVER >= 20071106 - WBUFB(buf,2)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE - WBUFL(buf,3)=-bl->id; + WBUFB(buf,2)= pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE + WBUFL(buf,3)=-bl->id; #else - WBUFL(buf,2)=-bl->id; + WBUFL(buf,2)=-bl->id; #endif - clif_send(buf, len, bl, SELF); + clif_send(buf, len, bl, SELF); } @@ -1211,18 +1222,18 @@ static void clif_setdisguise(struct block_list *bl, unsigned char *buf,int len) /// unused void clif_class_change(struct block_list *bl,int class_,int type) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(bl); + nullpo_retv(bl); - if (!pcdb_checkid(class_)) { - // player classes yield missing sprites - WBUFW(buf,0)=0x1b0; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=type; - WBUFL(buf,7)=class_; - clif_send(buf,packet_len(0x1b0),bl,AREA); - } + if(!pcdb_checkid(class_)) + {// player classes yield missing sprites + WBUFW(buf,0)=0x1b0; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=type; + WBUFL(buf,7)=class_; + clif_send(buf,packet_len(0x1b0),bl,AREA); + } } @@ -1231,11 +1242,11 @@ void clif_class_change(struct block_list *bl,int class_,int type) /// 01e1 .L .W (ZC_SPIRITS2) static void clif_spiritball_single(int fd, struct map_session_data *sd) { - WFIFOHEAD(fd, packet_len(0x1e1)); - WFIFOW(fd,0)=0x1e1; - WFIFOL(fd,2)=sd->bl.id; - WFIFOW(fd,6)=sd->spiritball; - WFIFOSET(fd, packet_len(0x1e1)); + WFIFOHEAD(fd, packet_len(0x1e1)); + WFIFOW(fd,0)=0x1e1; + WFIFOL(fd,2)=sd->bl.id; + WFIFOW(fd,6)=sd->spiritball; + WFIFOSET(fd, packet_len(0x1e1)); } /*========================================== @@ -1243,12 +1254,12 @@ static void clif_spiritball_single(int fd, struct map_session_data *sd) *------------------------------------------*/ static void clif_talisman_single(int fd, struct map_session_data *sd, short type) { - WFIFOHEAD(fd, packet_len(0x08cf)); - WFIFOW(fd,0)=0x08cf; - WFIFOL(fd,2)=sd->bl.id; - WFIFOW(fd,6)=type; - WFIFOW(fd,8)=sd->talisman[type]; - WFIFOSET(fd, packet_len(0x08cf)); + WFIFOHEAD(fd, packet_len(0x08cf)); + WFIFOW(fd,0)=0x08cf; + WFIFOL(fd,2)=sd->bl.id; + WFIFOW(fd,6)=type; + WFIFOW(fd,8)=sd->talisman[type]; + WFIFOSET(fd, packet_len(0x08cf)); } /*========================================== @@ -1257,194 +1268,200 @@ static void clif_talisman_single(int fd, struct map_session_data *sd, short type *------------------------------------------*/ static void clif_weather_check(struct map_session_data *sd) { - int m = sd->bl.m, fd = sd->fd; - - if (map[m].flag.snow - || map[m].flag.clouds - || map[m].flag.fog - || map[m].flag.fireworks - || map[m].flag.sakura - || map[m].flag.leaves - /** - * No longer available, keeping here just in case it's back someday. [Ind] - **/ - //|| map[m].flag.rain - || map[m].flag.clouds2) { - if (map[m].flag.snow) - clif_specialeffect_single(&sd->bl, 162, fd); - if (map[m].flag.clouds) - clif_specialeffect_single(&sd->bl, 233, fd); - if (map[m].flag.clouds2) - clif_specialeffect_single(&sd->bl, 516, fd); - if (map[m].flag.fog) - clif_specialeffect_single(&sd->bl, 515, fd); - if (map[m].flag.fireworks) { - clif_specialeffect_single(&sd->bl, 297, fd); - clif_specialeffect_single(&sd->bl, 299, fd); - clif_specialeffect_single(&sd->bl, 301, fd); - } - if (map[m].flag.sakura) - clif_specialeffect_single(&sd->bl, 163, fd); - if (map[m].flag.leaves) - clif_specialeffect_single(&sd->bl, 333, fd); - /** - * No longer available, keeping here just in case it's back someday. [Ind] - **/ - //if (map[m].flag.rain) - // clif_specialeffect_single(&sd->bl, 161, fd); - } + int m = sd->bl.m, fd = sd->fd; + + if (map[m].flag.snow + || map[m].flag.clouds + || map[m].flag.fog + || map[m].flag.fireworks + || map[m].flag.sakura + || map[m].flag.leaves + /** + * No longer available, keeping here just in case it's back someday. [Ind] + **/ + //|| map[m].flag.rain + || map[m].flag.clouds2) + { + if (map[m].flag.snow) + clif_specialeffect_single(&sd->bl, 162, fd); + if (map[m].flag.clouds) + clif_specialeffect_single(&sd->bl, 233, fd); + if (map[m].flag.clouds2) + clif_specialeffect_single(&sd->bl, 516, fd); + if (map[m].flag.fog) + clif_specialeffect_single(&sd->bl, 515, fd); + if (map[m].flag.fireworks) { + clif_specialeffect_single(&sd->bl, 297, fd); + clif_specialeffect_single(&sd->bl, 299, fd); + clif_specialeffect_single(&sd->bl, 301, fd); + } + if (map[m].flag.sakura) + clif_specialeffect_single(&sd->bl, 163, fd); + if (map[m].flag.leaves) + clif_specialeffect_single(&sd->bl, 333, fd); + /** + * No longer available, keeping here just in case it's back someday. [Ind] + **/ + //if (map[m].flag.rain) + // clif_specialeffect_single(&sd->bl, 161, fd); + } } /** * Run when the weather on a map changes, throws all players in map id 'm' to clif_weather_check function **/ void clif_weather(int m) { - struct s_mapiterator *iter; - struct map_session_data *sd=NULL; + struct s_mapiterator* iter; + struct map_session_data *sd=NULL; - iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data *)mapit_next(iter)) { - if (sd->bl.m == m) - clif_weather_check(sd); - } - mapit_free(iter); + iter = mapit_getallusers(); + for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) ) + { + if( sd->bl.m == m ) + clif_weather_check(sd); + } + mapit_free(iter); } /** * Main function to spawn a unit on the client (player/mob/pet/etc) **/ int clif_spawn(struct block_list *bl) { - unsigned char buf[128]; - struct view_data *vd; - int len; - - vd = status_get_viewdata(bl); - if (!vd || vd->class_ == INVISIBLE_CLASS) - return 0; - - /** - * Hide NPC from maya purple card. - **/ - if (bl->type == BL_NPC && !((TBL_NPC *)bl)->chat_id && (((TBL_NPC *)bl)->sc.option&OPTION_INVISIBLE)) - return 0; - - len = clif_set_unit_idle(bl, buf,true); - clif_send(buf, len, bl, AREA_WOS); - if (disguised(bl)) - clif_setdisguise(bl, buf, len); - - if (vd->cloth_color) - clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS); - - switch (bl->type) { - case BL_PC: { - TBL_PC *sd = ((TBL_PC *)bl); - int i; - if (sd->spiritball > 0) - clif_spiritball(&sd->bl); - if (sd->state.size==SZ_BIG) // tiny/big players [Valaris] - clif_specialeffect(bl,423,AREA); - else if (sd->state.size==SZ_MEDIUM) - clif_specialeffect(bl,421,AREA); - if (sd->bg_id && map[sd->bl.m].flag.battleground) - clif_sendbgemblem_area(sd); - if (sd->sc.option&OPTION_MOUNTING) { - //New Mounts are not complaint to the original method, so we gotta tell this guy that he is mounting. - clif_status_load_notick(&sd->bl,SI_ALL_RIDING,2,1,0,0); - } - for (i = 1; i < 5; i++) { - if (sd->talisman[i] > 0) - clif_talisman(sd, i); - } -#ifdef NEW_CARTS - if (sd->sc.data[SC_PUSH_CART]) - clif_status_load_notick(&sd->bl, SI_ON_PUSH_CART, 2, sd->sc.data[SC_PUSH_CART]->val1, 0, 0); -#endif -#if PACKETVER <= 20120207 - if (sd->status.robe) - clif_refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA); -#endif - } - break; - case BL_MOB: { - TBL_MOB *md = ((TBL_MOB *)bl); - if (md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris] - clif_specialeffect(&md->bl,423,AREA); - else if (md->special_state.size==SZ_MEDIUM) - clif_specialeffect(&md->bl,421,AREA); - } - break; - case BL_NPC: { - TBL_NPC *nd = ((TBL_NPC *)bl); - if (nd->size == SZ_BIG) - clif_specialeffect(&nd->bl,423,AREA); - else if (nd->size == SZ_MEDIUM) - clif_specialeffect(&nd->bl,421,AREA); - } - break; - case BL_PET: - if (vd->head_bottom) - clif_pet_equip_area((TBL_PET *)bl); // needed to display pet equip properly - break; - } - return 0; + unsigned char buf[128]; + struct view_data *vd; + int len; + + vd = status_get_viewdata(bl); + if( !vd || vd->class_ == INVISIBLE_CLASS ) + return 0; + + /** + * Hide NPC from maya purple card. + **/ + if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)) + return 0; + + len = clif_set_unit_idle(bl, buf,true); + clif_send(buf, len, bl, AREA_WOS); + if (disguised(bl)) + clif_setdisguise(bl, buf, len); + + if (vd->cloth_color) + clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS); + + switch (bl->type) + { + case BL_PC: + { + TBL_PC *sd = ((TBL_PC*)bl); + int i; + if (sd->spiritball > 0) + clif_spiritball(&sd->bl); + if(sd->state.size==SZ_BIG) // tiny/big players [Valaris] + clif_specialeffect(bl,423,AREA); + else if(sd->state.size==SZ_MEDIUM) + clif_specialeffect(bl,421,AREA); + if( sd->bg_id && map[sd->bl.m].flag.battleground ) + clif_sendbgemblem_area(sd); + if( sd->sc.option&OPTION_MOUNTING ) { + //New Mounts are not complaint to the original method, so we gotta tell this guy that he is mounting. + clif_status_load_notick(&sd->bl,SI_ALL_RIDING,2,1,0,0); + } + for(i = 1; i < 5; i++){ + if( sd->talisman[i] > 0 ) + clif_talisman(sd, i); + } + #ifdef NEW_CARTS + if( sd->sc.data[SC_PUSH_CART] ) + clif_status_load_notick(&sd->bl, SI_ON_PUSH_CART, 2, sd->sc.data[SC_PUSH_CART]->val1, 0, 0); + #endif + #if PACKETVER <= 20120207 + if (sd->status.robe) + clif_refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA); + #endif + } + break; + case BL_MOB: + { + TBL_MOB *md = ((TBL_MOB*)bl); + if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris] + clif_specialeffect(&md->bl,423,AREA); + else if(md->special_state.size==SZ_MEDIUM) + clif_specialeffect(&md->bl,421,AREA); + } + break; + case BL_NPC: + { + TBL_NPC *nd = ((TBL_NPC*)bl); + if( nd->size == SZ_BIG ) + clif_specialeffect(&nd->bl,423,AREA); + else if( nd->size == SZ_MEDIUM ) + clif_specialeffect(&nd->bl,421,AREA); + } + break; + case BL_PET: + if (vd->head_bottom) + clif_pet_equip_area((TBL_PET*)bl); // needed to display pet equip properly + break; + } + return 0; } /// Sends information about owned homunculus to the client (ZC_PROPERTY_HOMUN). [orn] /// 022e .24B .B .W .W .W .W .W .W .W .W .W .W .W .W .W .W .W .W .L .L .W .W void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag) { - struct status_data *status; - unsigned char buf[128]; - int m_class; - - nullpo_retv(hd); - - status = &hd->battle_status; - m_class = hom_class2mapid(hd->homunculus.class_); - - memset(buf,0,packet_len(0x22e)); - WBUFW(buf,0)=0x22e; - memcpy(WBUFP(buf,2),hd->homunculus.name,NAME_LENGTH); - // Bit field, bit 0 : rename_flag (1 = already renamed), bit 1 : homunc vaporized (1 = true), bit 2 : homunc dead (1 = true) - WBUFB(buf,26)=(battle_config.hom_rename?0:hd->homunculus.rename_flag) | (hd->homunculus.vaporize << 1) | (hd->homunculus.hp?0:4); - WBUFW(buf,27)=hd->homunculus.level; - WBUFW(buf,29)=hd->homunculus.hunger; - WBUFW(buf,31)=(unsigned short)(hd->homunculus.intimacy / 100) ; - WBUFW(buf,33)=0; // equip id - WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, INT16_MAX); - WBUFW(buf,37)=cap_value(status->matk_max, 0, INT16_MAX); - WBUFW(buf,39)=status->hit; - if (battle_config.hom_setting&0x10) - WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious] - else - WBUFW(buf,41)=status->cri/10; - WBUFW(buf,43)=status->def + status->vit ; - WBUFW(buf,45)=status->mdef; - WBUFW(buf,47)=status->flee; - WBUFW(buf,49)=(flag)?0:status->amotion; - if (status->max_hp > INT16_MAX) { - WBUFW(buf,51) = status->hp/(status->max_hp/100); - WBUFW(buf,53) = 100; - } else { - WBUFW(buf,51)=status->hp; - WBUFW(buf,53)=status->max_hp; - } - if (status->max_sp > INT16_MAX) { - WBUFW(buf,55) = status->sp/(status->max_sp/100); - WBUFW(buf,57) = 100; - } else { - WBUFW(buf,55)=status->sp; - WBUFW(buf,57)=status->max_sp; - } - WBUFL(buf,59)=hd->homunculus.exp; - if (((m_class&HOM_REG) && hd->homunculus.level >= battle_config.hom_max_level) || ((m_class&HOM_S) && hd->homunculus.level >= battle_config.hom_S_max_level)) - WBUFL(buf,63)=0; - else - WBUFL(buf,63)=hd->exp_next; - WBUFW(buf,67)=hd->homunculus.skillpts; - WBUFW(buf,69)=status_get_range(&hd->bl); - clif_send(buf,packet_len(0x22e),&sd->bl,SELF); + struct status_data *status; + unsigned char buf[128]; + int m_class; + + nullpo_retv(hd); + + status = &hd->battle_status; + m_class = hom_class2mapid(hd->homunculus.class_); + + memset(buf,0,packet_len(0x22e)); + WBUFW(buf,0)=0x22e; + memcpy(WBUFP(buf,2),hd->homunculus.name,NAME_LENGTH); + // Bit field, bit 0 : rename_flag (1 = already renamed), bit 1 : homunc vaporized (1 = true), bit 2 : homunc dead (1 = true) + WBUFB(buf,26)=(battle_config.hom_rename?0:hd->homunculus.rename_flag) | (hd->homunculus.vaporize << 1) | (hd->homunculus.hp?0:4); + WBUFW(buf,27)=hd->homunculus.level; + WBUFW(buf,29)=hd->homunculus.hunger; + WBUFW(buf,31)=(unsigned short) (hd->homunculus.intimacy / 100) ; + WBUFW(buf,33)=0; // equip id + WBUFW(buf,35)=cap_value(status->rhw.atk2+status->batk, 0, INT16_MAX); + WBUFW(buf,37)=cap_value(status->matk_max, 0, INT16_MAX); + WBUFW(buf,39)=status->hit; + if (battle_config.hom_setting&0x10) + WBUFW(buf,41)=status->luk/3 + 1; //crit is a +1 decimal value! Just display purpose.[Vicious] + else + WBUFW(buf,41)=status->cri/10; + WBUFW(buf,43)=status->def + status->vit ; + WBUFW(buf,45)=status->mdef; + WBUFW(buf,47)=status->flee; + WBUFW(buf,49)=(flag)?0:status->amotion; + if (status->max_hp > INT16_MAX) { + WBUFW(buf,51) = status->hp/(status->max_hp/100); + WBUFW(buf,53) = 100; + } else { + WBUFW(buf,51)=status->hp; + WBUFW(buf,53)=status->max_hp; + } + if (status->max_sp > INT16_MAX) { + WBUFW(buf,55) = status->sp/(status->max_sp/100); + WBUFW(buf,57) = 100; + } else { + WBUFW(buf,55)=status->sp; + WBUFW(buf,57)=status->max_sp; + } + WBUFL(buf,59)=hd->homunculus.exp; + if( ((m_class&HOM_REG) && hd->homunculus.level >= battle_config.hom_max_level) || ((m_class&HOM_S) && hd->homunculus.level >= battle_config.hom_S_max_level) ) + WBUFL(buf,63)=0; + else + WBUFL(buf,63)=hd->exp_next; + WBUFW(buf,67)=hd->homunculus.skillpts; + WBUFW(buf,69)=status_get_range(&hd->bl); + clif_send(buf,packet_len(0x22e),&sd->bl,SELF); } @@ -1459,87 +1476,84 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag) /// 3 = accessory? /// ? = ignored void clif_send_homdata(struct map_session_data *sd, int state, int param) -{ - //[orn] - int fd = sd->fd; +{ //[orn] + int fd = sd->fd; - if ((state == SP_INTIMATE) && (param >= 910) && (sd->hd->homunculus.class_ == sd->hd->homunculusDB->evo_class)) - merc_hom_calc_skilltree(sd->hd, 0); + if ( (state == SP_INTIMATE) && (param >= 910) && (sd->hd->homunculus.class_ == sd->hd->homunculusDB->evo_class) ) + merc_hom_calc_skilltree(sd->hd, 0); - WFIFOHEAD(fd, packet_len(0x230)); - WFIFOW(fd,0)=0x230; - WFIFOB(fd,2)=0; - WFIFOB(fd,3)=state; - WFIFOL(fd,4)=sd->hd->bl.id; - WFIFOL(fd,8)=param; - WFIFOSET(fd,packet_len(0x230)); + WFIFOHEAD(fd, packet_len(0x230)); + WFIFOW(fd,0)=0x230; + WFIFOB(fd,2)=0; + WFIFOB(fd,3)=state; + WFIFOL(fd,4)=sd->hd->bl.id; + WFIFOL(fd,8)=param; + WFIFOSET(fd,packet_len(0x230)); } int clif_homskillinfoblock(struct map_session_data *sd) -{ - //[orn] - struct homun_data *hd; - int fd = sd->fd; - int i,j,len=4,id; - WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL); - - hd = sd->hd; - if (!hd) - return 0 ; - - WFIFOW(fd,0)=0x235; - for (i = 0; i < MAX_HOMUNSKILL; i++) { - if ((id = hd->homunculus.hskill[i].id) != 0) { - j = id - HM_SKILLBASE; - WFIFOW(fd,len) = id; - WFIFOW(fd,len+2) = skill_get_inf(id); - WFIFOW(fd,len+4) = 0; - WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv; - WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv); - WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv); - safestrncpy((char *)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH); - WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0; - len+=37; - } - } - WFIFOW(fd,2)=len; - WFIFOSET(fd,len); - - return 0; +{ //[orn] + struct homun_data *hd; + int fd = sd->fd; + int i,j,len=4,id; + WFIFOHEAD(fd, 4+37*MAX_HOMUNSKILL); + + hd = sd->hd; + if ( !hd ) + return 0 ; + + WFIFOW(fd,0)=0x235; + for ( i = 0; i < MAX_HOMUNSKILL; i++){ + if( (id = hd->homunculus.hskill[i].id) != 0 ){ + j = id - HM_SKILLBASE; + WFIFOW(fd,len ) = id; + WFIFOW(fd,len+2) = skill_get_inf(id); + WFIFOW(fd,len+4) = 0; + WFIFOW(fd,len+6) = hd->homunculus.hskill[j].lv; + WFIFOW(fd,len+8) = skill_get_sp(id,hd->homunculus.hskill[j].lv); + WFIFOW(fd,len+10)= skill_get_range2(&sd->hd->bl, id,hd->homunculus.hskill[j].lv); + safestrncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH); + WFIFOB(fd,len+36) = (hd->homunculus.hskill[j].lv < merc_skill_tree_get_max(id, hd->homunculus.class_))?1:0; + len+=37; + } + } + WFIFOW(fd,2)=len; + WFIFOSET(fd,len); + + return 0; } void clif_homskillup(struct map_session_data *sd, int skill_num) -{ - //[orn] - struct homun_data *hd; - int fd, skillid; - nullpo_retv(sd); - skillid = skill_num - HM_SKILLBASE; +{ //[orn] + struct homun_data *hd; + int fd, skillid; + nullpo_retv(sd); + skillid = skill_num - HM_SKILLBASE; - fd=sd->fd; - hd=sd->hd; + fd=sd->fd; + hd=sd->hd; - WFIFOHEAD(fd, packet_len(0x239)); - WFIFOW(fd,0) = 0x239; - WFIFOW(fd,2) = skill_num; - WFIFOW(fd,4) = hd->homunculus.hskill[skillid].lv; - WFIFOW(fd,6) = skill_get_sp(skill_num,hd->homunculus.hskill[skillid].lv); - WFIFOW(fd,8) = skill_get_range2(&hd->bl, skill_num,hd->homunculus.hskill[skillid].lv); - WFIFOB(fd,10) = (hd->homunculus.hskill[skillid].lv < skill_get_max(hd->homunculus.hskill[skillid].id)) ? 1 : 0; - WFIFOSET(fd,packet_len(0x239)); + WFIFOHEAD(fd, packet_len(0x239)); + WFIFOW(fd,0) = 0x239; + WFIFOW(fd,2) = skill_num; + WFIFOW(fd,4) = hd->homunculus.hskill[skillid].lv; + WFIFOW(fd,6) = skill_get_sp(skill_num,hd->homunculus.hskill[skillid].lv); + WFIFOW(fd,8) = skill_get_range2(&hd->bl, skill_num,hd->homunculus.hskill[skillid].lv); + WFIFOB(fd,10) = (hd->homunculus.hskill[skillid].lv < skill_get_max(hd->homunculus.hskill[skillid].id)) ? 1 : 0; + WFIFOSET(fd,packet_len(0x239)); } -int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn] +int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn] { - int fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x22f)); - WFIFOW(fd,0)=0x22f; - WFIFOB(fd,2)=fail; - WFIFOW(fd,3)=foodid; - WFIFOSET(fd,packet_len(0x22f)); + int fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x22f)); + WFIFOW(fd,0)=0x22f; + WFIFOB(fd,2)=fail; + WFIFOW(fd,3)=foodid; + WFIFOSET(fd,packet_len(0x22f)); - return 0; + return 0; } @@ -1547,54 +1561,57 @@ int clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn] /// 0087 .L .6B void clif_walkok(struct map_session_data *sd) { - int fd=sd->fd; + int fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x87)); - WFIFOW(fd,0)=0x87; - WFIFOL(fd,2)=gettick(); - WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); - WFIFOSET(fd,packet_len(0x87)); + WFIFOHEAD(fd, packet_len(0x87)); + WFIFOW(fd,0)=0x87; + WFIFOL(fd,2)=gettick(); + WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); + WFIFOSET(fd,packet_len(0x87)); } static void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *ud) { - uint8 buf[128]; - int len; - - len = clif_set_unit_walking(bl,ud,buf); - clif_send(buf,len,bl,AREA_WOS); - if (disguised(bl)) - clif_setdisguise(bl, buf, len); - - if (vd->cloth_color) - clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS); - - switch (bl->type) { - case BL_PC: { - TBL_PC *sd = ((TBL_PC *)bl); - // clif_movepc(sd); - if (sd->state.size==SZ_BIG) // tiny/big players [Valaris] - clif_specialeffect(&sd->bl,423,AREA); - else if (sd->state.size==SZ_MEDIUM) - clif_specialeffect(&sd->bl,421,AREA); - } - break; - case BL_MOB: { - TBL_MOB *md = ((TBL_MOB *)bl); - if (md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris] - clif_specialeffect(&md->bl,423,AREA); - else if (md->special_state.size==SZ_MEDIUM) - clif_specialeffect(&md->bl,421,AREA); - } - break; - case BL_PET: - if (vd->head_bottom) { - // needed to display pet equip properly - clif_pet_equip_area((TBL_PET *)bl); - } - break; - } + uint8 buf[128]; + int len; + + len = clif_set_unit_walking(bl,ud,buf); + clif_send(buf,len,bl,AREA_WOS); + if (disguised(bl)) + clif_setdisguise(bl, buf, len); + + if(vd->cloth_color) + clif_refreshlook(bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,AREA_WOS); + + switch(bl->type) + { + case BL_PC: + { + TBL_PC *sd = ((TBL_PC*)bl); +// clif_movepc(sd); + if(sd->state.size==SZ_BIG) // tiny/big players [Valaris] + clif_specialeffect(&sd->bl,423,AREA); + else if(sd->state.size==SZ_MEDIUM) + clif_specialeffect(&sd->bl,421,AREA); + } + break; + case BL_MOB: + { + TBL_MOB *md = ((TBL_MOB*)bl); + if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris] + clif_specialeffect(&md->bl,423,AREA); + else if(md->special_state.size==SZ_MEDIUM) + clif_specialeffect(&md->bl,421,AREA); + } + break; + case BL_PET: + if( vd->head_bottom ) + {// needed to display pet equip properly + clif_pet_equip_area((TBL_PET*)bl); + } + break; + } } @@ -1603,37 +1620,38 @@ static void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_ /// Note: unit must not be self void clif_move(struct unit_data *ud) { - unsigned char buf[16]; - struct view_data *vd; - struct block_list *bl = ud->bl; - - vd = status_get_viewdata(bl); - if (!vd || vd->class_ == INVISIBLE_CLASS) - return; //This performance check is needed to keep GM-hidden objects from being notified to bots. - - /** - * Hide NPC from maya purple card. - **/ - if (bl->type == BL_NPC && !((TBL_NPC *)bl)->chat_id && (((TBL_NPC *)bl)->sc.option&OPTION_INVISIBLE)) - return; - - if (ud->state.speed_changed) { - // Since we don't know how to update the speed of other objects, - // use the old walk packet to update the data. - ud->state.speed_changed = 0; - clif_move2(bl, vd, ud); - return; - } - - WBUFW(buf,0)=0x86; - WBUFL(buf,2)=bl->id; - WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFL(buf,12)=gettick(); - clif_send(buf, packet_len(0x86), bl, AREA_WOS); - if (disguised(bl)) { - WBUFL(buf,2)=-bl->id; - clif_send(buf, packet_len(0x86), bl, SELF); - } + unsigned char buf[16]; + struct view_data* vd; + struct block_list* bl = ud->bl; + + vd = status_get_viewdata(bl); + if (!vd || vd->class_ == INVISIBLE_CLASS) + return; //This performance check is needed to keep GM-hidden objects from being notified to bots. + + /** + * Hide NPC from maya purple card. + **/ + if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)) + return; + + if (ud->state.speed_changed) { + // Since we don't know how to update the speed of other objects, + // use the old walk packet to update the data. + ud->state.speed_changed = 0; + clif_move2(bl, vd, ud); + return; + } + + WBUFW(buf,0)=0x86; + WBUFL(buf,2)=bl->id; + WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); + WBUFL(buf,12)=gettick(); + clif_send(buf, packet_len(0x86), bl, AREA_WOS); + if (disguised(bl)) + { + WBUFL(buf,2)=-bl->id; + clif_send(buf, packet_len(0x86), bl, SELF); + } } @@ -1642,12 +1660,12 @@ void clif_move(struct unit_data *ud) *------------------------------------------*/ static int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { - struct map_session_data *sd = NULL; + struct map_session_data *sd = NULL; - //Remove player from map server - if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. - map_quit(sd); - return 0; + //Remove player from map server + if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. + map_quit(sd); + return 0; } /*========================================== @@ -1655,59 +1673,59 @@ static int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) *------------------------------------------*/ void clif_quitsave(int fd,struct map_session_data *sd) { - if (!battle_config.prevent_logout || - DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) - map_quit(sd); - else if (sd->fd) { - //Disassociate session from player (session is deleted after this function was called) - //And set a timer to make him quit later. - session[sd->fd]->session_data = NULL; - sd->fd = 0; - add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0); - } + if (!battle_config.prevent_logout || + DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) + map_quit(sd); + else if (sd->fd) + { //Disassociate session from player (session is deleted after this function was called) + //And set a timer to make him quit later. + session[sd->fd]->session_data = NULL; + sd->fd = 0; + add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0); + } } /// Notifies the client of a position change to coordinates on given map (ZC_NPCACK_MAPMOVE). /// 0091 .16B .W .W void clif_changemap(struct map_session_data *sd, short map, int x, int y) { - int fd; - nullpo_retv(sd); - fd = sd->fd; + int fd; + nullpo_retv(sd); + fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x91)); - WFIFOW(fd,0) = 0x91; - mapindex_getmapname_ext(mapindex_id2name(map), (char *)WFIFOP(fd,2)); - WFIFOW(fd,18) = x; - WFIFOW(fd,20) = y; - WFIFOSET(fd,packet_len(0x91)); + WFIFOHEAD(fd,packet_len(0x91)); + WFIFOW(fd,0) = 0x91; + mapindex_getmapname_ext(mapindex_id2name(map), (char*)WFIFOP(fd,2)); + WFIFOW(fd,18) = x; + WFIFOW(fd,20) = y; + WFIFOSET(fd,packet_len(0x91)); } /// Notifies the client of a position change to coordinates on given map, which is on another map-server (ZC_NPCACK_SERVERMOVE). /// 0092 .16B .W .W .L .W -void clif_changemapserver(struct map_session_data *sd, unsigned short map_index, 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_retv(sd); - fd = sd->fd; + int fd; + nullpo_retv(sd); + fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x92)); - WFIFOW(fd,0) = 0x92; - 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)); + WFIFOHEAD(fd,packet_len(0x92)); + WFIFOW(fd,0) = 0x92; + 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)); } void clif_blown(struct block_list *bl) { - //Aegis packets says fixpos, but it's unsure whether slide works better or not. - // clif_fixpos(bl); - clif_slide(bl, bl->x, bl->y); +//Aegis packets says fixpos, but it's unsure whether slide works better or not. +// clif_fixpos(bl); + clif_slide(bl, bl->x, bl->y); } @@ -1717,35 +1735,36 @@ void clif_blown(struct block_list *bl) /// 0088 .L .W .W void clif_fixpos(struct block_list *bl) { - unsigned char buf[10]; - nullpo_retv(bl); + unsigned char buf[10]; + nullpo_retv(bl); - WBUFW(buf,0) = 0x88; - WBUFL(buf,2) = bl->id; - WBUFW(buf,6) = bl->x; - WBUFW(buf,8) = bl->y; - clif_send(buf, packet_len(0x88), bl, AREA); + WBUFW(buf,0) = 0x88; + WBUFL(buf,2) = bl->id; + WBUFW(buf,6) = bl->x; + WBUFW(buf,8) = bl->y; + clif_send(buf, packet_len(0x88), bl, AREA); - if (disguised(bl)) { - WBUFL(buf,2) = -bl->id; - clif_send(buf, packet_len(0x88), bl, SELF); - } + if( disguised(bl) ) + { + WBUFL(buf,2) = -bl->id; + clif_send(buf, packet_len(0x88), bl, SELF); + } } /// Displays the buy/sell dialog of an NPC shop (ZC_SELECT_DEALTYPE). /// 00c4 .L -void clif_npcbuysell(struct map_session_data *sd, int id) +void clif_npcbuysell(struct map_session_data* sd, int id) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0xc4)); - WFIFOW(fd,0)=0xc4; - WFIFOL(fd,2)=id; - WFIFOSET(fd,packet_len(0xc4)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0xc4)); + WFIFOW(fd,0)=0xc4; + WFIFOL(fd,2)=id; + WFIFOSET(fd,packet_len(0xc4)); } @@ -1753,30 +1772,31 @@ void clif_npcbuysell(struct map_session_data *sd, int id) /// 00c6 .W { .L .L .B .W }* void clif_buylist(struct map_session_data *sd, struct npc_data *nd) { - int fd,i,c; + int fd,i,c; - nullpo_retv(sd); - nullpo_retv(nd); - - fd = sd->fd; - WFIFOHEAD(fd, 4 + nd->u.shop.count * 11); - WFIFOW(fd,0) = 0xc6; - - c = 0; - for (i = 0; i < nd->u.shop.count; i++) { - struct item_data *id = itemdb_exists(nd->u.shop.shop_item[i].nameid); - int val = nd->u.shop.shop_item[i].value; - if (id == NULL) - continue; - WFIFOL(fd, 4+c*11) = val; - WFIFOL(fd, 8+c*11) = pc_modifybuyvalue(sd,val); - WFIFOB(fd,12+c*11) = itemtype(id->type); - WFIFOW(fd,13+c*11) = (id->view_id > 0) ? id->view_id : id->nameid; - c++; - } + nullpo_retv(sd); + nullpo_retv(nd); + + fd = sd->fd; + WFIFOHEAD(fd, 4 + nd->u.shop.count * 11); + WFIFOW(fd,0) = 0xc6; - WFIFOW(fd,2) = 4 + c*11; - WFIFOSET(fd,WFIFOW(fd,2)); + c = 0; + for( i = 0; i < nd->u.shop.count; i++ ) + { + struct item_data* id = itemdb_exists(nd->u.shop.shop_item[i].nameid); + int val = nd->u.shop.shop_item[i].value; + if( id == NULL ) + continue; + WFIFOL(fd, 4+c*11) = val; + WFIFOL(fd, 8+c*11) = pc_modifybuyvalue(sd,val); + WFIFOB(fd,12+c*11) = itemtype(id->type); + WFIFOW(fd,13+c*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid; + c++; + } + + WFIFOW(fd,2) = 4 + c*11; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -1784,32 +1804,34 @@ void clif_buylist(struct map_session_data *sd, struct npc_data *nd) /// 00c7 .W { .W .L .L }* void clif_selllist(struct map_session_data *sd) { - int fd,i,c=0,val; + int fd,i,c=0,val; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4); - WFIFOW(fd,0)=0xc7; - for (i = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].nameid > 0 && sd->inventory_data[i]) { - if (!itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd))) - continue; - - if (sd->status.inventory[i].expire_time) - continue; // Cannot Sell Rental Items - - val=sd->inventory_data[i]->value_sell; - if (val < 0) - continue; - WFIFOW(fd,4+c*10)=i+2; - WFIFOL(fd,6+c*10)=val; - WFIFOL(fd,10+c*10)=pc_modifysellvalue(sd,val); - c++; - } - } - WFIFOW(fd,2)=c*10+4; - WFIFOSET(fd,WFIFOW(fd,2)); + fd=sd->fd; + WFIFOHEAD(fd, MAX_INVENTORY * 10 + 4); + WFIFOW(fd,0)=0xc7; + for( i = 0; i < MAX_INVENTORY; i++ ) + { + if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] ) + { + if( !itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd)) ) + continue; + + if( sd->status.inventory[i].expire_time ) + continue; // Cannot Sell Rental Items + + val=sd->inventory_data[i]->value_sell; + if( val < 0 ) + continue; + WFIFOW(fd,4+c*10)=i+2; + WFIFOL(fd,6+c*10)=val; + WFIFOL(fd,10+c*10)=pc_modifysellvalue(sd,val); + c++; + } + } + WFIFOW(fd,2)=c*10+4; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -1823,15 +1845,15 @@ void clif_selllist(struct map_session_data *sd) /// - append this text void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) { - int fd = sd->fd; - int slen = strlen(mes) + 9; + int fd = sd->fd; + int slen = strlen(mes) + 9; - WFIFOHEAD(fd, slen); - WFIFOW(fd,0)=0xb4; - WFIFOW(fd,2)=slen; - WFIFOL(fd,4)=npcid; - memcpy((char *)WFIFOP(fd,8), mes, slen-8); - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOHEAD(fd, slen); + WFIFOW(fd,0)=0xb4; + WFIFOW(fd,2)=slen; + WFIFOL(fd,4)=npcid; + memcpy((char*)WFIFOP(fd,8), mes, slen-8); + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -1847,15 +1869,15 @@ void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) /// - remove 'next' button void clif_scriptnext(struct map_session_data *sd,int npcid) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0xb5)); - WFIFOW(fd,0)=0xb5; - WFIFOL(fd,2)=npcid; - WFIFOSET(fd,packet_len(0xb5)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0xb5)); + WFIFOW(fd,0)=0xb5; + WFIFOL(fd,2)=npcid; + WFIFOSET(fd,packet_len(0xb5)); } @@ -1876,15 +1898,15 @@ void clif_scriptnext(struct map_session_data *sd,int npcid) /// - 0146 .L void clif_scriptclose(struct map_session_data *sd, int npcid) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0xb6)); - WFIFOW(fd,0)=0xb6; - WFIFOL(fd,2)=npcid; - WFIFOSET(fd,packet_len(0xb6)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0xb6)); + WFIFOW(fd,0)=0xb6; + WFIFOL(fd,2)=npcid; + WFIFOSET(fd,packet_len(0xb6)); } /*========================================== @@ -1892,24 +1914,24 @@ void clif_scriptclose(struct map_session_data *sd, int npcid) *------------------------------------------*/ void clif_sendfakenpc(struct map_session_data *sd, int npcid) { - unsigned char *buf; - int fd = sd->fd; - sd->state.using_fake_npc = 1; + unsigned char *buf; + int fd = sd->fd; + sd->state.using_fake_npc = 1; - WFIFOHEAD(fd, packet_len(0x78)); - buf = WFIFOP(fd,0); - memset(WBUFP(buf,0), 0, packet_len(0x78)); - WBUFW(buf,0)=0x78; + WFIFOHEAD(fd, packet_len(0x78)); + buf = WFIFOP(fd,0); + memset(WBUFP(buf,0), 0, packet_len(0x78)); + WBUFW(buf,0)=0x78; #if PACKETVER >= 20071106 - WBUFB(buf,2) = 0; // object type - buf = WFIFOP(fd,1); + WBUFB(buf,2) = 0; // object type + buf = WFIFOP(fd,1); #endif - WBUFL(buf,2)=npcid; - WBUFW(buf,14)=111; - WBUFPOS(buf,46,sd->bl.x,sd->bl.y,sd->ud.dir); - WBUFB(buf,49)=5; - WBUFB(buf,50)=5; - WFIFOSET(fd, packet_len(0x78)); + WBUFL(buf,2)=npcid; + WBUFW(buf,14)=111; + WBUFPOS(buf,46,sd->bl.x,sd->bl.y,sd->ud.dir); + WBUFB(buf,49)=5; + WBUFB(buf,50)=5; + WFIFOSET(fd, packet_len(0x78)); } @@ -1933,23 +1955,23 @@ void clif_sendfakenpc(struct map_session_data *sd, int npcid) /// WARNING: the 'cancel' button closes other windows besides the dialog window and the menu window. /// Which suggests their have intertwined behavior. (probably the mouse targeting) /// TODO investigate behavior of other windows [FlavioJS] -void clif_scriptmenu(struct map_session_data *sd, int npcid, const char *mes) +void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) { - int fd = sd->fd; - int slen = strlen(mes) + 9; - struct block_list *bl = NULL; + int fd = sd->fd; + int slen = strlen(mes) + 9; + struct block_list *bl = NULL; - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif_sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif_sendfakenpc(sd, npcid); - WFIFOHEAD(fd, slen); - WFIFOW(fd,0)=0xb7; - WFIFOW(fd,2)=slen; - WFIFOL(fd,4)=npcid; - memcpy((char *)WFIFOP(fd,8), mes, slen-8); - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOHEAD(fd, slen); + WFIFOW(fd,0)=0xb7; + WFIFOW(fd,2)=slen; + WFIFOL(fd,4)=npcid; + memcpy((char*)WFIFOP(fd,8), mes, slen-8); + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -1966,21 +1988,21 @@ void clif_scriptmenu(struct map_session_data *sd, int npcid, const char *mes) /// - close inputnum window void clif_scriptinput(struct map_session_data *sd, int npcid) { - int fd; - struct block_list *bl = NULL; + int fd; + struct block_list *bl = NULL; - nullpo_retv(sd); + nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif_sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif_sendfakenpc(sd, npcid); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x142)); - WFIFOW(fd,0)=0x142; - WFIFOL(fd,2)=npcid; - WFIFOSET(fd,packet_len(0x142)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0x142)); + WFIFOW(fd,0)=0x142; + WFIFOL(fd,2)=npcid; + WFIFOSET(fd,packet_len(0x142)); } @@ -1997,21 +2019,21 @@ void clif_scriptinput(struct map_session_data *sd, int npcid) /// - close inputstr window void clif_scriptinputstr(struct map_session_data *sd, int npcid) { - int fd; - struct block_list *bl = NULL; + int fd; + struct block_list *bl = NULL; - nullpo_retv(sd); + nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || - bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || - bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) - clif_sendfakenpc(sd, npcid); + if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || + bl->xbl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || + bl->ybl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) + clif_sendfakenpc(sd, npcid); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x1d4)); - WFIFOW(fd,0)=0x1d4; - WFIFOL(fd,2)=npcid; - WFIFOSET(fd,packet_len(0x1d4)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0x1d4)); + WFIFOW(fd,0)=0x1d4; + WFIFOL(fd,2)=npcid; + WFIFOSET(fd,packet_len(0x1d4)); } @@ -2027,20 +2049,20 @@ void clif_scriptinputstr(struct map_session_data *sd, int npcid) /// 0x00RRGGBB void clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, int y, int id, int color) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x144)); - WFIFOW(fd,0)=0x144; - WFIFOL(fd,2)=npc_id; - WFIFOL(fd,6)=type; - WFIFOL(fd,10)=x; - WFIFOL(fd,14)=y; - WFIFOB(fd,18)=id; - WFIFOL(fd,19)=color; - WFIFOSET(fd,packet_len(0x144)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0x144)); + WFIFOW(fd,0)=0x144; + WFIFOL(fd,2)=npc_id; + WFIFOL(fd,6)=type; + WFIFOL(fd,10)=x; + WFIFOL(fd,14)=y; + WFIFOB(fd,18)=id; + WFIFOL(fd,19)=color; + WFIFOSET(fd,packet_len(0x144)); } @@ -2053,72 +2075,72 @@ void clif_viewpoint(struct map_session_data *sd, int npc_id, int type, int x, in /// 2 = bottom right corner /// 3 = middle of screen, inside a movable window /// 4 = middle of screen, movable with a close button, chrome-less -void clif_cutin(struct map_session_data *sd, const char *image, int type) +void clif_cutin(struct map_session_data* sd, const char* image, int type) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x1b3)); - WFIFOW(fd,0)=0x1b3; - strncpy((char *)WFIFOP(fd,2),image,64); - WFIFOB(fd,66)=type; - WFIFOSET(fd,packet_len(0x1b3)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0x1b3)); + WFIFOW(fd,0)=0x1b3; + strncpy((char*)WFIFOP(fd,2),image,64); + WFIFOB(fd,66)=type; + WFIFOSET(fd,packet_len(0x1b3)); } /*========================================== * Fills in card data from the given item and into the buffer. [Skotlex] *------------------------------------------*/ -static void clif_addcards(unsigned char *buf, struct item *item) -{ - int i=0,j; - if (item == NULL) { //Blank data - WBUFW(buf,0) = 0; - WBUFW(buf,2) = 0; - WBUFW(buf,4) = 0; - WBUFW(buf,6) = 0; - return; - } - if (item->card[0] == CARD0_PET) { //pet eggs - WBUFW(buf,0) = 0; - WBUFW(buf,2) = 0; - WBUFW(buf,4) = 0; - WBUFW(buf,6) = item->card[3]; //Pet renamed flag. - return; - } - if (item->card[0] == CARD0_FORGE || item->card[0] == CARD0_CREATE) { //Forged/created items - WBUFW(buf,0) = item->card[0]; - WBUFW(buf,2) = item->card[1]; - WBUFW(buf,4) = item->card[2]; - WBUFW(buf,6) = item->card[3]; - return; - } - //Client only receives four cards.. so randomly send them a set of cards. [Skotlex] - if (MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4) - i = rnd()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rnd()%3; - - //Normal items. - if (item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0) - WBUFW(buf,0) = j; - else - WBUFW(buf,0) = item->card[i]; - - if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0) - WBUFW(buf,2) = j; - else - WBUFW(buf,2) = item->card[i]; - - if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0) - WBUFW(buf,4) = j; - else - WBUFW(buf,4) = item->card[i]; - - if (item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0) - WBUFW(buf,6) = j; - else - WBUFW(buf,6) = item->card[i]; +static void clif_addcards(unsigned char* buf, struct item* item) +{ + int i=0,j; + if( item == NULL ) { //Blank data + WBUFW(buf,0) = 0; + WBUFW(buf,2) = 0; + WBUFW(buf,4) = 0; + WBUFW(buf,6) = 0; + return; + } + if( item->card[0] == CARD0_PET ) { //pet eggs + WBUFW(buf,0) = 0; + WBUFW(buf,2) = 0; + WBUFW(buf,4) = 0; + WBUFW(buf,6) = item->card[3]; //Pet renamed flag. + return; + } + if( item->card[0] == CARD0_FORGE || item->card[0] == CARD0_CREATE ) { //Forged/created items + WBUFW(buf,0) = item->card[0]; + WBUFW(buf,2) = item->card[1]; + WBUFW(buf,4) = item->card[2]; + WBUFW(buf,6) = item->card[3]; + return; + } + //Client only receives four cards.. so randomly send them a set of cards. [Skotlex] + if( MAX_SLOTS > 4 && (j = itemdb_slot(item->nameid)) > 4 ) + i = rnd()%(j-3); //eg: 6 slots, possible i values: 0->3, 1->4, 2->5 => i = rnd()%3; + + //Normal items. + if( item->card[i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 ) + WBUFW(buf,0) = j; + else + WBUFW(buf,0) = item->card[i]; + + if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 ) + WBUFW(buf,2) = j; + else + WBUFW(buf,2) = item->card[i]; + + if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 ) + WBUFW(buf,4) = j; + else + WBUFW(buf,4) = item->card[i]; + + if( item->card[++i] > 0 && (j=itemdb_viewid(item->card[i])) > 0 ) + WBUFW(buf,6) = j; + else + WBUFW(buf,6) = item->card[i]; } @@ -2128,69 +2150,72 @@ static void clif_addcards(unsigned char *buf, struct item *item) /// 02d4 .W .W .W .B .B .B .W .W .W .W .W .B .B .L .W (ZC_ITEM_PICKUP_ACK3) void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { - int fd; + int fd; #if PACKETVER < 20061218 - const int cmd = 0xa0; + const int cmd = 0xa0; #elif PACKETVER < 20071002 - const int cmd = 0x29a; + const int cmd = 0x29a; #else - const int cmd = 0x2d4; + const int cmd = 0x2d4; #endif - nullpo_retv(sd); - - fd = sd->fd; - if (!session_isActive(fd)) //Sasuke- - return; - - WFIFOHEAD(fd,packet_len(cmd)); - if (fail) { - WFIFOW(fd,0)=cmd; - WFIFOW(fd,2)=n+2; - WFIFOW(fd,4)=amount; - WFIFOW(fd,6)=0; - WFIFOB(fd,8)=0; - WFIFOB(fd,9)=0; - WFIFOB(fd,10)=0; - WFIFOW(fd,11)=0; - WFIFOW(fd,13)=0; - WFIFOW(fd,15)=0; - WFIFOW(fd,17)=0; - WFIFOW(fd,19)=0; - WFIFOB(fd,21)=0; - WFIFOB(fd,22)=fail; + nullpo_retv(sd); + + fd = sd->fd; + if( !session_isActive(fd) ) //Sasuke- + return; + + WFIFOHEAD(fd,packet_len(cmd)); + if( fail ) + { + WFIFOW(fd,0)=cmd; + WFIFOW(fd,2)=n+2; + WFIFOW(fd,4)=amount; + WFIFOW(fd,6)=0; + WFIFOB(fd,8)=0; + WFIFOB(fd,9)=0; + WFIFOB(fd,10)=0; + WFIFOW(fd,11)=0; + WFIFOW(fd,13)=0; + WFIFOW(fd,15)=0; + WFIFOW(fd,17)=0; + WFIFOW(fd,19)=0; + WFIFOB(fd,21)=0; + WFIFOB(fd,22)=fail; #if PACKETVER >= 20061218 - WFIFOL(fd,23)=0; + WFIFOL(fd,23)=0; #endif #if PACKETVER >= 20071002 - WFIFOW(fd,27)=0; // unknown + WFIFOW(fd,27)=0; // unknown #endif - } else { - if (n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL) - return; - - WFIFOW(fd,0)=cmd; - WFIFOW(fd,2)=n+2; - WFIFOW(fd,4)=amount; - if (sd->inventory_data[n]->view_id > 0) - WFIFOW(fd,6)=sd->inventory_data[n]->view_id; - else - WFIFOW(fd,6)=sd->status.inventory[n].nameid; - WFIFOB(fd,8)=sd->status.inventory[n].identify; - WFIFOB(fd,9)=sd->status.inventory[n].attribute; - WFIFOB(fd,10)=sd->status.inventory[n].refine; - clif_addcards(WFIFOP(fd,11), &sd->status.inventory[n]); - WFIFOW(fd,19)=pc_equippoint(sd,n); - WFIFOB(fd,21)=itemtype(sd->inventory_data[n]->type); - WFIFOB(fd,22)=fail; + } + else + { + if( n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL ) + return; + + WFIFOW(fd,0)=cmd; + WFIFOW(fd,2)=n+2; + WFIFOW(fd,4)=amount; + if (sd->inventory_data[n]->view_id > 0) + WFIFOW(fd,6)=sd->inventory_data[n]->view_id; + else + WFIFOW(fd,6)=sd->status.inventory[n].nameid; + WFIFOB(fd,8)=sd->status.inventory[n].identify; + WFIFOB(fd,9)=sd->status.inventory[n].attribute; + WFIFOB(fd,10)=sd->status.inventory[n].refine; + clif_addcards(WFIFOP(fd,11), &sd->status.inventory[n]); + WFIFOW(fd,19)=pc_equippoint(sd,n); + WFIFOB(fd,21)=itemtype(sd->inventory_data[n]->type); + WFIFOB(fd,22)=fail; #if PACKETVER >= 20061218 - WFIFOL(fd,23)=sd->status.inventory[n].expire_time; + WFIFOL(fd,23)=sd->status.inventory[n].expire_time; #endif #if PACKETVER >= 20071002 - WFIFOW(fd,27)=0; // unknown + WFIFOW(fd,27)=0; // unknown #endif - } + } - WFIFOSET(fd,packet_len(cmd)); + WFIFOSET(fd,packet_len(cmd)); } @@ -2198,16 +2223,16 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) /// 00af .W .W void clif_dropitem(struct map_session_data *sd,int n,int amount) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0xaf)); - WFIFOW(fd,0)=0xaf; - WFIFOW(fd,2)=n+2; - WFIFOW(fd,4)=amount; - WFIFOSET(fd,packet_len(0xaf)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0xaf)); + WFIFOW(fd,0)=0xaf; + WFIFOW(fd,2)=n+2; + WFIFOW(fd,4)=amount; + WFIFOSET(fd,packet_len(0xaf)); } @@ -2225,20 +2250,20 @@ void clif_dropitem(struct map_session_data *sd,int n,int amount) void clif_delitem(struct map_session_data *sd,int n,int amount, short reason) { #if PACKETVER < 20091117 - clif_dropitem(sd,n,amount); + clif_dropitem(sd,n,amount); #else - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; + fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x7fa)); - WFIFOW(fd,0)=0x7fa; - WFIFOW(fd,2)=reason; - WFIFOW(fd,4)=n+2; - WFIFOW(fd,6)=amount; - WFIFOSET(fd,packet_len(0x7fa)); + WFIFOHEAD(fd, packet_len(0x7fa)); + WFIFOW(fd,0)=0x7fa; + WFIFOW(fd,2)=reason; + WFIFOW(fd,4)=n+2; + WFIFOW(fd,6)=amount; + WFIFOSET(fd,packet_len(0x7fa)); #endif } @@ -2248,323 +2273,335 @@ void clif_delitem(struct map_session_data *sd,int n,int amount, short reason) // armor/egg) -1 for stackable items, -2 for stackable items where arrows must send in the equip-point. void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data *id, int equip) { - if (id->view_id > 0) - WBUFW(buf,n)=id->view_id; - else - WBUFW(buf,n)=i->nameid; - WBUFB(buf,n+2)=itemtype(id->type); - WBUFB(buf,n+3)=i->identify; - if (equip >= 0) { //Equippable item - WBUFW(buf,n+4)=equip; - WBUFW(buf,n+6)=i->equip; - WBUFB(buf,n+8)=i->attribute; - WBUFB(buf,n+9)=i->refine; - } else { //Stackable item. - WBUFW(buf,n+4)=i->amount; - if (equip == -2 && id->equip == EQP_AMMO) - WBUFW(buf,n+6)=EQP_AMMO; - else - WBUFW(buf,n+6)=0; - } - -} -void clif_favorite_item(struct map_session_data *sd, unsigned short index); + if (id->view_id > 0) + WBUFW(buf,n)=id->view_id; + else + WBUFW(buf,n)=i->nameid; + WBUFB(buf,n+2)=itemtype(id->type); + WBUFB(buf,n+3)=i->identify; + if (equip >= 0) { //Equippable item + WBUFW(buf,n+4)=equip; + WBUFW(buf,n+6)=i->equip; + WBUFB(buf,n+8)=i->attribute; + WBUFB(buf,n+9)=i->refine; + } else { //Stackable item. + WBUFW(buf,n+4)=i->amount; + if (equip == -2 && id->equip == EQP_AMMO) + WBUFW(buf,n+6)=EQP_AMMO; + else + WBUFW(buf,n+6)=0; + } + +} +void clif_favorite_item(struct map_session_data* sd, unsigned short index); //Unified inventory function which sends all of the inventory (requires two packets, one for equipable items and one for stackable ones. [Skotlex] void clif_inventorylist(struct map_session_data *sd) { - int i,n,ne,arrow=-1; - unsigned char *buf; - unsigned char *bufe; + int i,n,ne,arrow=-1; + unsigned char *buf; + unsigned char *bufe; #if PACKETVER < 5 - const int s = 10; //Entry size. + const int s = 10; //Entry size. #elif PACKETVER < 20080102 - const int s = 18; + const int s = 18; #else - const int s = 22; + const int s = 22; #endif #if PACKETVER < 20071002 - const int se = 20; + const int se = 20; #elif PACKETVER < 20100629 - const int se = 26; + const int se = 26; #else - const int se = 28; + const int se = 28; #endif - buf = (unsigned char *)aMalloc(MAX_INVENTORY * s + 4); - bufe = (unsigned char *)aMalloc(MAX_INVENTORY * se + 4); + buf = (unsigned char*)aMalloc(MAX_INVENTORY * s + 4); + bufe = (unsigned char*)aMalloc(MAX_INVENTORY * se + 4); - for (i = 0, n = 0, ne = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL) - continue; + for( i = 0, n = 0, ne = 0; i < MAX_INVENTORY; i++ ) + { + if( sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL ) + continue; - if (!itemdb_isstackable2(sd->inventory_data[i])) { - //Non-stackable (Equippable) - WBUFW(bufe,ne*se+4)=i+2; - clif_item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i)); - clif_addcards(WBUFP(bufe, ne*se+16), &sd->status.inventory[i]); + if( !itemdb_isstackable2(sd->inventory_data[i]) ) + { //Non-stackable (Equippable) + WBUFW(bufe,ne*se+4)=i+2; + clif_item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i)); + clif_addcards(WBUFP(bufe, ne*se+16), &sd->status.inventory[i]); #if PACKETVER >= 20071002 - WBUFL(bufe,ne*se+24)=sd->status.inventory[i].expire_time; - WBUFW(bufe,ne*se+28)=0; //Unknown + WBUFL(bufe,ne*se+24)=sd->status.inventory[i].expire_time; + WBUFW(bufe,ne*se+28)=0; //Unknown #endif #if PACKETVER >= 20100629 - if (sd->inventory_data[i]->equip&EQP_VISIBLE) - WBUFW(bufe,ne*se+30)= sd->inventory_data[i]->look; - else - WBUFW(bufe,ne*se+30)=0; + if (sd->inventory_data[i]->equip&EQP_VISIBLE) + WBUFW(bufe,ne*se+30)= sd->inventory_data[i]->look; + else + WBUFW(bufe,ne*se+30)=0; #endif - ne++; - } else { - //Stackable. - WBUFW(buf,n*s+4)=i+2; - clif_item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2); - if (sd->inventory_data[i]->equip == EQP_AMMO && sd->status.inventory[i].equip) - arrow=i; + ne++; + } + else + { //Stackable. + WBUFW(buf,n*s+4)=i+2; + clif_item_sub(buf, n*s+6, &sd->status.inventory[i], sd->inventory_data[i], -2); + if( sd->inventory_data[i]->equip == EQP_AMMO && sd->status.inventory[i].equip ) + arrow=i; #if PACKETVER >= 5 - clif_addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]); + clif_addcards(WBUFP(buf, n*s+14), &sd->status.inventory[i]); #endif #if PACKETVER >= 20080102 - WBUFL(buf,n*s+22)=sd->status.inventory[i].expire_time; + WBUFL(buf,n*s+22)=sd->status.inventory[i].expire_time; #endif - n++; - } - } - if (n) { + n++; + } + } + if( n ) + { #if PACKETVER < 5 - WBUFW(buf,0)=0xa3; + WBUFW(buf,0)=0xa3; #elif PACKETVER < 20080102 - WBUFW(buf,0)=0x1ee; + WBUFW(buf,0)=0x1ee; #else - WBUFW(buf,0)=0x2e8; + WBUFW(buf,0)=0x2e8; #endif - WBUFW(buf,2)=4+n*s; - clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); - } - if (arrow >= 0) - clif_arrowequip(sd,arrow); - - if (ne) { + WBUFW(buf,2)=4+n*s; + clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); + } + if( arrow >= 0 ) + clif_arrowequip(sd,arrow); + + if( ne ) + { #if PACKETVER < 20071002 - WBUFW(bufe,0)=0xa4; + WBUFW(bufe,0)=0xa4; #else - WBUFW(bufe,0)=0x2d0; + WBUFW(bufe,0)=0x2d0; #endif - WBUFW(bufe,2)=4+ne*se; - clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); - } + WBUFW(bufe,2)=4+ne*se; + clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); + } #if PACKETVER >= 20111122 - for (i = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL) - continue; + for( i = 0; i < MAX_INVENTORY; i++ ) { + if( sd->status.inventory[i].nameid <= 0 || sd->inventory_data[i] == NULL ) + continue; - if (sd->status.inventory[i].favorite) - clif_favorite_item(sd, i); - } + if ( sd->status.inventory[i].favorite ) + clif_favorite_item(sd, i); + } #endif - if (buf) aFree(buf); - if (bufe) aFree(bufe); + if( buf ) aFree(buf); + if( bufe ) aFree(bufe); } //Required when items break/get-repaired. Only sends equippable item list. void clif_equiplist(struct map_session_data *sd) { - int i,n,fd = sd->fd; - unsigned char *buf; + int i,n,fd = sd->fd; + unsigned char *buf; #if PACKETVER < 20071002 - const int cmd = 20; + const int cmd = 20; #elif PACKETVER < 20100629 - const int cmd = 26; + const int cmd = 26; #else - const int cmd = 28; + const int cmd = 28; #endif - WFIFOHEAD(fd, MAX_INVENTORY * cmd + 4); - buf = WFIFOP(fd,0); + WFIFOHEAD(fd, MAX_INVENTORY * cmd + 4); + buf = WFIFOP(fd,0); - for (i=0,n=0; istatus.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL) - continue; + for(i=0,n=0;istatus.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL) + continue; - if (itemdb_isstackable2(sd->inventory_data[i])) - continue; - //Equippable - WBUFW(buf,n*cmd+4)=i+2; - clif_item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i)); - clif_addcards(WBUFP(buf, n*cmd+16), &sd->status.inventory[i]); + if(itemdb_isstackable2(sd->inventory_data[i])) + continue; + //Equippable + WBUFW(buf,n*cmd+4)=i+2; + clif_item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i)); + clif_addcards(WBUFP(buf, n*cmd+16), &sd->status.inventory[i]); #if PACKETVER >= 20071002 - WBUFL(buf,n*cmd+24)=sd->status.inventory[i].expire_time; - WBUFW(buf,n*cmd+28)=0; //Unknown + WBUFL(buf,n*cmd+24)=sd->status.inventory[i].expire_time; + WBUFW(buf,n*cmd+28)=0; //Unknown #endif #if PACKETVER >= 20100629 - if (sd->inventory_data[i]->equip&EQP_VISIBLE) - WBUFW(buf,n*cmd+30)= sd->inventory_data[i]->look; - else - WBUFW(buf,n*cmd+30)=0; + if (sd->inventory_data[i]->equip&EQP_VISIBLE) + WBUFW(buf,n*cmd+30)= sd->inventory_data[i]->look; + else + WBUFW(buf,n*cmd+30)=0; #endif - n++; - } - if (n) { + n++; + } + if (n) { #if PACKETVER < 20071002 - WBUFW(buf,0)=0xa4; + WBUFW(buf,0)=0xa4; #else - WBUFW(buf,0)=0x2d0; + WBUFW(buf,0)=0x2d0; #endif - WBUFW(buf,2)=4+n*cmd; - WFIFOSET(fd,WFIFOW(fd,2)); - } + WBUFW(buf,2)=4+n*cmd; + WFIFOSET(fd,WFIFOW(fd,2)); + } } -void clif_storagelist(struct map_session_data *sd, struct item *items, int items_length) +void clif_storagelist(struct map_session_data* sd, struct item* items, int items_length) { - struct item_data *id; - int i,n,ne; - unsigned char *buf; - unsigned char *bufe; + struct item_data *id; + int i,n,ne; + unsigned char *buf; + unsigned char *bufe; #if PACKETVER < 5 - const int s = 10; //Entry size. + const int s = 10; //Entry size. #elif PACKETVER < 20080102 - const int s = 18; + const int s = 18; #else - const int s = 22; + const int s = 22; #endif #if PACKETVER < 20071002 - const int cmd = 20; + const int cmd = 20; #elif PACKETVER < 20100629 - const int cmd = 26; + const int cmd = 26; #else - const int cmd = 28; + const int cmd = 28; #endif - buf = (unsigned char *)aMalloc(items_length * s + 4); - bufe = (unsigned char *)aMalloc(items_length * cmd + 4); - - for (i = 0, n = 0, ne = 0; i < items_length; i++) { - if (items[i].nameid <= 0) - continue; - id = itemdb_search(items[i].nameid); - if (!itemdb_isstackable2(id)) { - //Equippable - WBUFW(bufe,ne*cmd+4)=i+1; - clif_item_sub(bufe, ne*cmd+6, &items[i], id, id->equip); - clif_addcards(WBUFP(bufe, ne*cmd+16), &items[i]); + buf = (unsigned char*)aMalloc(items_length * s + 4); + bufe = (unsigned char*)aMalloc(items_length * cmd + 4); + + for( i = 0, n = 0, ne = 0; i < items_length; i++ ) + { + if( items[i].nameid <= 0 ) + continue; + id = itemdb_search(items[i].nameid); + if( !itemdb_isstackable2(id) ) + { //Equippable + WBUFW(bufe,ne*cmd+4)=i+1; + clif_item_sub(bufe, ne*cmd+6, &items[i], id, id->equip); + clif_addcards(WBUFP(bufe, ne*cmd+16), &items[i]); #if PACKETVER >= 20071002 - WBUFL(bufe,ne*cmd+24)=items[i].expire_time; - WBUFW(bufe,ne*cmd+28)=0; //Unknown + WBUFL(bufe,ne*cmd+24)=items[i].expire_time; + WBUFW(bufe,ne*cmd+28)=0; //Unknown #endif - ne++; - } else { - //Stackable - WBUFW(buf,n*s+4)=i+1; - clif_item_sub(buf, n*s+6, &items[i], id,-1); + ne++; + } + else + { //Stackable + WBUFW(buf,n*s+4)=i+1; + clif_item_sub(buf, n*s+6, &items[i], id,-1); #if PACKETVER >= 5 - clif_addcards(WBUFP(buf,n*s+14), &items[i]); + clif_addcards(WBUFP(buf,n*s+14), &items[i]); #endif #if PACKETVER >= 20080102 - WBUFL(buf,n*s+22)=items[i].expire_time; + WBUFL(buf,n*s+22)=items[i].expire_time; #endif - n++; - } - } - if (n) { + n++; + } + } + if( n ) + { #if PACKETVER < 5 - WBUFW(buf,0)=0xa5; + WBUFW(buf,0)=0xa5; #elif PACKETVER < 20080102 - WBUFW(buf,0)=0x1f0; + WBUFW(buf,0)=0x1f0; #else - WBUFW(buf,0)=0x2ea; + WBUFW(buf,0)=0x2ea; #endif - WBUFW(buf,2)=4+n*s; - clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); - } - if (ne) { + WBUFW(buf,2)=4+n*s; + clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); + } + if( ne ) + { #if PACKETVER < 20071002 - WBUFW(bufe,0)=0xa6; + WBUFW(bufe,0)=0xa6; #else - WBUFW(bufe,0)=0x2d1; + WBUFW(bufe,0)=0x2d1; #endif - WBUFW(bufe,2)=4+ne*cmd; - clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); - } + WBUFW(bufe,2)=4+ne*cmd; + clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); + } - if (buf) aFree(buf); - if (bufe) aFree(bufe); + if( buf ) aFree(buf); + if( bufe ) aFree(bufe); } void clif_cartlist(struct map_session_data *sd) { - struct item_data *id; - int i,n,ne; - unsigned char *buf; - unsigned char *bufe; + struct item_data *id; + int i,n,ne; + unsigned char *buf; + unsigned char *bufe; #if PACKETVER < 5 - const int s = 10; //Entry size. + const int s = 10; //Entry size. #elif PACKETVER < 20080102 - const int s = 18; + const int s = 18; #else - const int s = 22; + const int s = 22; #endif #if PACKETVER < 20071002 - const int cmd = 20; + const int cmd = 20; #elif PACKETVER < 20100629 - const int cmd = 26; + const int cmd = 26; #else - const int cmd = 28; + const int cmd = 28; #endif - buf = (unsigned char *)aMalloc(MAX_CART * s + 4); - bufe = (unsigned char *)aMalloc(MAX_CART * cmd + 4); - - for (i = 0, n = 0, ne = 0; i < MAX_CART; i++) { - if (sd->status.cart[i].nameid <= 0) - continue; - id = itemdb_search(sd->status.cart[i].nameid); - if (!itemdb_isstackable2(id)) { - //Equippable - WBUFW(bufe,ne*cmd+4)=i+2; - clif_item_sub(bufe, ne*cmd+6, &sd->status.cart[i], id, id->equip); - clif_addcards(WBUFP(bufe, ne*cmd+16), &sd->status.cart[i]); + buf = (unsigned char*)aMalloc(MAX_CART * s + 4); + bufe = (unsigned char*)aMalloc(MAX_CART * cmd + 4); + + for( i = 0, n = 0, ne = 0; i < MAX_CART; i++ ) + { + if( sd->status.cart[i].nameid <= 0 ) + continue; + id = itemdb_search(sd->status.cart[i].nameid); + if( !itemdb_isstackable2(id) ) + { //Equippable + WBUFW(bufe,ne*cmd+4)=i+2; + clif_item_sub(bufe, ne*cmd+6, &sd->status.cart[i], id, id->equip); + clif_addcards(WBUFP(bufe, ne*cmd+16), &sd->status.cart[i]); #if PACKETVER >= 20071002 - WBUFL(bufe,ne*cmd+24)=sd->status.cart[i].expire_time; - WBUFW(bufe,ne*cmd+28)=0; //Unknown + WBUFL(bufe,ne*cmd+24)=sd->status.cart[i].expire_time; + WBUFW(bufe,ne*cmd+28)=0; //Unknown #endif - ne++; - } else { - //Stackable - WBUFW(buf,n*s+4)=i+2; - clif_item_sub(buf, n*s+6, &sd->status.cart[i], id,-1); + ne++; + } + else + { //Stackable + WBUFW(buf,n*s+4)=i+2; + clif_item_sub(buf, n*s+6, &sd->status.cart[i], id,-1); #if PACKETVER >= 5 - clif_addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]); + clif_addcards(WBUFP(buf,n*s+14), &sd->status.cart[i]); #endif #if PACKETVER >= 20080102 - WBUFL(buf,n*s+22)=sd->status.cart[i].expire_time; + WBUFL(buf,n*s+22)=sd->status.cart[i].expire_time; #endif - n++; - } - } - if (n) { + n++; + } + } + if( n ) + { #if PACKETVER < 5 - WBUFW(buf,0)=0x123; + WBUFW(buf,0)=0x123; #elif PACKETVER < 20080102 - WBUFW(buf,0)=0x1ef; + WBUFW(buf,0)=0x1ef; #else - WBUFW(buf,0)=0x2e9; + WBUFW(buf,0)=0x2e9; #endif - WBUFW(buf,2)=4+n*s; - clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); - } - if (ne) { + WBUFW(buf,2)=4+n*s; + clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); + } + if( ne ) + { #if PACKETVER < 20071002 - WBUFW(bufe,0)=0x122; + WBUFW(bufe,0)=0x122; #else - WBUFW(bufe,0)=0x2d2; + WBUFW(bufe,0)=0x2d2; #endif - WBUFW(bufe,2)=4+ne*cmd; - clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); - } + WBUFW(bufe,2)=4+ne*cmd; + clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); + } - if (buf) aFree(buf); - if (bufe) aFree(bufe); + if( buf ) aFree(buf); + if( bufe ) aFree(bufe); } @@ -2575,9 +2612,9 @@ void clif_cartlist(struct map_session_data *sd) /// The Num & Weight values of the cart are left untouched and the cart is NOT removed. void clif_clearcart(int fd) { - WFIFOHEAD(fd, packet_len(0x12b)); - WFIFOW(fd,0) = 0x12b; - WFIFOSET(fd, packet_len(0x12b)); + WFIFOHEAD(fd, packet_len(0x12b)); + WFIFOW(fd,0) = 0x12b; + WFIFOSET(fd, packet_len(0x12b)); } @@ -2586,15 +2623,15 @@ void clif_clearcart(int fd) /// 01eb .L .W .W void clif_guild_xy(struct map_session_data *sd) { - unsigned char buf[10]; + unsigned char buf[10]; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0)=0x1eb; - WBUFL(buf,2)=sd->status.account_id; - WBUFW(buf,6)=sd->bl.x; - WBUFW(buf,8)=sd->bl.y; - clif_send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS); + WBUFW(buf,0)=0x1eb; + WBUFL(buf,2)=sd->status.account_id; + WBUFW(buf,6)=sd->bl.x; + WBUFW(buf,8)=sd->bl.y; + clif_send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS); } /*========================================== @@ -2602,29 +2639,29 @@ void clif_guild_xy(struct map_session_data *sd) *------------------------------------------*/ void clif_guild_xy_single(int fd, struct map_session_data *sd) { - if (sd->bg_id) - return; + if( sd->bg_id ) + return; - WFIFOHEAD(fd,packet_len(0x1eb)); - WFIFOW(fd,0)=0x1eb; - WFIFOL(fd,2)=sd->status.account_id; - WFIFOW(fd,6)=sd->bl.x; - WFIFOW(fd,8)=sd->bl.y; - WFIFOSET(fd,packet_len(0x1eb)); + WFIFOHEAD(fd,packet_len(0x1eb)); + WFIFOW(fd,0)=0x1eb; + WFIFOL(fd,2)=sd->status.account_id; + WFIFOW(fd,6)=sd->bl.x; + WFIFOW(fd,8)=sd->bl.y; + WFIFOSET(fd,packet_len(0x1eb)); } // Guild XY locators [Valaris] void clif_guild_xy_remove(struct map_session_data *sd) { - unsigned char buf[10]; + unsigned char buf[10]; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0)=0x1eb; - WBUFL(buf,2)=sd->status.account_id; - WBUFW(buf,6)=-1; - WBUFW(buf,8)=-1; - clif_send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS); + WBUFW(buf,0)=0x1eb; + WBUFL(buf,2)=sd->status.account_id; + WBUFW(buf,6)=-1; + WBUFW(buf,8)=-1; + clif_send(buf,packet_len(0x1eb),&sd->bl,GUILD_SAMEMAP_WOS); } /*========================================== @@ -2632,42 +2669,42 @@ void clif_guild_xy_remove(struct map_session_data *sd) *------------------------------------------*/ static int clif_hpmeter_sub(struct block_list *bl, va_list ap) { - struct map_session_data *sd, *tsd; + struct map_session_data *sd, *tsd; #if PACKETVER < 20100126 - const int cmd = 0x106; + const int cmd = 0x106; #else - const int cmd = 0x80e; + const int cmd = 0x80e; #endif - sd = va_arg(ap, struct map_session_data *); - tsd = (TBL_PC *)bl; + sd = va_arg(ap, struct map_session_data *); + tsd = (TBL_PC *)bl; - nullpo_ret(sd); - nullpo_ret(tsd); + nullpo_ret(sd); + nullpo_ret(tsd); - if (!tsd->fd || tsd == sd) - return 0; + if( !tsd->fd || tsd == sd ) + return 0; - if (!pc_has_permission(tsd, PC_PERM_VIEW_HPMETER)) - return 0; - WFIFOHEAD(tsd->fd,packet_len(cmd)); - WFIFOW(tsd->fd,0) = cmd; - WFIFOL(tsd->fd,2) = sd->status.account_id; + if( !pc_has_permission(tsd, PC_PERM_VIEW_HPMETER) ) + return 0; + WFIFOHEAD(tsd->fd,packet_len(cmd)); + WFIFOW(tsd->fd,0) = cmd; + WFIFOL(tsd->fd,2) = sd->status.account_id; #if PACKETVER < 20100126 - if (sd->battle_status.max_hp > INT16_MAX) { - //To correctly display the %hp bar. [Skotlex] - WFIFOW(tsd->fd,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100); - WFIFOW(tsd->fd,8) = 100; - } else { - WFIFOW(tsd->fd,6) = sd->battle_status.hp; - WFIFOW(tsd->fd,8) = sd->battle_status.max_hp; - } + if( sd->battle_status.max_hp > INT16_MAX ) + { //To correctly display the %hp bar. [Skotlex] + WFIFOW(tsd->fd,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100); + WFIFOW(tsd->fd,8) = 100; + } else { + WFIFOW(tsd->fd,6) = sd->battle_status.hp; + WFIFOW(tsd->fd,8) = sd->battle_status.max_hp; + } #else - WFIFOL(tsd->fd,6) = sd->battle_status.hp; - WFIFOL(tsd->fd,10) = sd->battle_status.max_hp; + WFIFOL(tsd->fd,6) = sd->battle_status.hp; + WFIFOL(tsd->fd,10) = sd->battle_status.max_hp; #endif - WFIFOSET(tsd->fd,packet_len(cmd)); - return 0; + WFIFOSET(tsd->fd,packet_len(cmd)); + return 0; } /*========================================== @@ -2676,9 +2713,9 @@ static int clif_hpmeter_sub(struct block_list *bl, va_list ap) *------------------------------------------*/ static int clif_hpmeter(struct map_session_data *sd) { - nullpo_ret(sd); - map_foreachinarea(clif_hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); - return 0; + nullpo_ret(sd); + map_foreachinarea(clif_hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); + return 0; } /// Notifies client of a character parameter change. @@ -2692,245 +2729,246 @@ static int clif_hpmeter(struct map_session_data *sd) /// FIXME: Packet lengths from packet_len(cmd) void clif_updatestatus(struct map_session_data *sd,int type) { - int fd,len=8; - - nullpo_retv(sd); - - fd=sd->fd; - - if (!session_isActive(fd)) // Invalid pointer fix, by sasuke [Kevin] - return; - - WFIFOHEAD(fd, 14); - WFIFOW(fd,0)=0xb0; - WFIFOW(fd,2)=type; - switch (type) { - // 00b0 - case SP_WEIGHT: - pc_updateweightstatus(sd); - WFIFOHEAD(fd,14); - WFIFOW(fd,0)=0xb0; //Need to re-set as pc_updateweightstatus can alter the buffer. [Skotlex] - WFIFOW(fd,2)=type; - WFIFOL(fd,4)=sd->weight; - break; - case SP_MAXWEIGHT: - WFIFOL(fd,4)=sd->max_weight; - break; - case SP_SPEED: - WFIFOL(fd,4)=sd->battle_status.speed; - break; - case SP_BASELEVEL: - WFIFOL(fd,4)=sd->status.base_level; - break; - case SP_JOBLEVEL: - WFIFOL(fd,4)=sd->status.job_level; - break; - case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance] - WFIFOL(fd,4)=sd->status.karma; - break; - case SP_MANNER: - WFIFOL(fd,4)=sd->status.manner; - break; - case SP_STATUSPOINT: - WFIFOL(fd,4)=sd->status.status_point; - break; - case SP_SKILLPOINT: - WFIFOL(fd,4)=sd->status.skill_point; - break; - case SP_HIT: - WFIFOL(fd,4)=sd->battle_status.hit; - break; - case SP_FLEE1: - WFIFOL(fd,4)=sd->battle_status.flee; - break; - case SP_FLEE2: - WFIFOL(fd,4)=sd->battle_status.flee2/10; - break; - case SP_MAXHP: - WFIFOL(fd,4)=sd->battle_status.max_hp; - break; - case SP_MAXSP: - WFIFOL(fd,4)=sd->battle_status.max_sp; - break; - case SP_HP: - WFIFOL(fd,4)=sd->battle_status.hp; - // TODO: Won't these overwrite the current packet? - clif_hpmeter(sd); - if (!battle_config.party_hp_mode && sd->status.party_id) - clif_party_hp(sd); - if (sd->bg_id) - clif_bg_hp(sd); - break; - case SP_SP: - WFIFOL(fd,4)=sd->battle_status.sp; - break; - case SP_ASPD: - WFIFOL(fd,4)=sd->battle_status.amotion; - break; - case SP_ATK1: - WFIFOL(fd,4)=pc_leftside_atk(sd); - break; - case SP_DEF1: - WFIFOL(fd,4)=pc_leftside_def(sd); - break; - case SP_MDEF1: - WFIFOL(fd,4)=pc_leftside_mdef(sd); - break; - case SP_ATK2: - WFIFOL(fd,4)=pc_rightside_atk(sd); - break; - case SP_DEF2: - WFIFOL(fd,4)=pc_rightside_def(sd); - break; - case SP_MDEF2: { - //negative check (in case you have something like Berserk active) - int mdef2 = pc_rightside_mdef(sd); - - WFIFOL(fd,4)= + int fd,len=8; + + nullpo_retv(sd); + + fd=sd->fd; + + if ( !session_isActive(fd) ) // Invalid pointer fix, by sasuke [Kevin] + return; + + WFIFOHEAD(fd, 14); + WFIFOW(fd,0)=0xb0; + WFIFOW(fd,2)=type; + switch(type){ + // 00b0 + case SP_WEIGHT: + pc_updateweightstatus(sd); + WFIFOHEAD(fd,14); + WFIFOW(fd,0)=0xb0; //Need to re-set as pc_updateweightstatus can alter the buffer. [Skotlex] + WFIFOW(fd,2)=type; + WFIFOL(fd,4)=sd->weight; + break; + case SP_MAXWEIGHT: + WFIFOL(fd,4)=sd->max_weight; + break; + case SP_SPEED: + WFIFOL(fd,4)=sd->battle_status.speed; + break; + case SP_BASELEVEL: + WFIFOL(fd,4)=sd->status.base_level; + break; + case SP_JOBLEVEL: + WFIFOL(fd,4)=sd->status.job_level; + break; + case SP_KARMA: // Adding this back, I wonder if the client intercepts this - [Lance] + WFIFOL(fd,4)=sd->status.karma; + break; + case SP_MANNER: + WFIFOL(fd,4)=sd->status.manner; + break; + case SP_STATUSPOINT: + WFIFOL(fd,4)=sd->status.status_point; + break; + case SP_SKILLPOINT: + WFIFOL(fd,4)=sd->status.skill_point; + break; + case SP_HIT: + WFIFOL(fd,4)=sd->battle_status.hit; + break; + case SP_FLEE1: + WFIFOL(fd,4)=sd->battle_status.flee; + break; + case SP_FLEE2: + WFIFOL(fd,4)=sd->battle_status.flee2/10; + break; + case SP_MAXHP: + WFIFOL(fd,4)=sd->battle_status.max_hp; + break; + case SP_MAXSP: + WFIFOL(fd,4)=sd->battle_status.max_sp; + break; + case SP_HP: + WFIFOL(fd,4)=sd->battle_status.hp; + // TODO: Won't these overwrite the current packet? + clif_hpmeter(sd); + if( !battle_config.party_hp_mode && sd->status.party_id ) + clif_party_hp(sd); + if( sd->bg_id ) + clif_bg_hp(sd); + break; + case SP_SP: + WFIFOL(fd,4)=sd->battle_status.sp; + break; + case SP_ASPD: + WFIFOL(fd,4)=sd->battle_status.amotion; + break; + case SP_ATK1: + WFIFOL(fd,4)=pc_leftside_atk(sd); + break; + case SP_DEF1: + WFIFOL(fd,4)=pc_leftside_def(sd); + break; + case SP_MDEF1: + WFIFOL(fd,4)=pc_leftside_mdef(sd); + break; + case SP_ATK2: + WFIFOL(fd,4)=pc_rightside_atk(sd); + break; + case SP_DEF2: + WFIFOL(fd,4)=pc_rightside_def(sd); + break; + case SP_MDEF2: { + //negative check (in case you have something like Berserk active) + int mdef2 = pc_rightside_mdef(sd); + + WFIFOL(fd,4)= #ifndef RENEWAL - (mdef2 < 0) ? 0 : + ( mdef2 < 0 ) ? 0 : #endif - mdef2; - - } - break; - case SP_CRITICAL: - WFIFOL(fd,4)=sd->battle_status.cri/10; - break; - case SP_MATK1: - WFIFOL(fd,4)=pc_rightside_matk(sd); - break; - case SP_MATK2: - WFIFOL(fd,4)=pc_leftside_matk(sd); - break; - - - case SP_ZENY: - WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=sd->status.zeny; - break; - case SP_BASEEXP: - WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=sd->status.base_exp; - break; - case SP_JOBEXP: - WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=sd->status.job_exp; - break; - case SP_NEXTBASEEXP: - WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=pc_nextbaseexp(sd); - break; - case SP_NEXTJOBEXP: - WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=pc_nextjobexp(sd); - break; - - /** - * SP_U are used to update the amount of points necessary to increase that stat - **/ - case SP_USTR: - case SP_UAGI: - case SP_UVIT: - case SP_UINT: - case SP_UDEX: - case SP_ULUK: - WFIFOW(fd,0)=0xbe; - WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1); - len=5; - break; - - /** - * Tells the client how far it is allowed to attack (weapon range) - **/ - case SP_ATTACKRANGE: - WFIFOW(fd,0)=0x13a; - WFIFOW(fd,2)=sd->battle_status.rhw.range; - len=4; - break; - - case SP_STR: - WFIFOW(fd,0)=0x141; - WFIFOL(fd,2)=type; - WFIFOL(fd,6)=sd->status.str; - WFIFOL(fd,10)=sd->battle_status.str - sd->status.str; - len=14; - break; - case SP_AGI: - WFIFOW(fd,0)=0x141; - WFIFOL(fd,2)=type; - WFIFOL(fd,6)=sd->status.agi; - WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi; - len=14; - break; - case SP_VIT: - WFIFOW(fd,0)=0x141; - WFIFOL(fd,2)=type; - WFIFOL(fd,6)=sd->status.vit; - WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit; - len=14; - break; - case SP_INT: - WFIFOW(fd,0)=0x141; - WFIFOL(fd,2)=type; - WFIFOL(fd,6)=sd->status.int_; - WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_; - len=14; - break; - case SP_DEX: - WFIFOW(fd,0)=0x141; - WFIFOL(fd,2)=type; - WFIFOL(fd,6)=sd->status.dex; - WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex; - len=14; - break; - case SP_LUK: - WFIFOW(fd,0)=0x141; - WFIFOL(fd,2)=type; - WFIFOL(fd,6)=sd->status.luk; - WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk; - len=14; - break; - - case SP_CARTINFO: - WFIFOW(fd,0)=0x121; - WFIFOW(fd,2)=sd->cart_num; - WFIFOW(fd,4)=MAX_CART; - WFIFOL(fd,6)=sd->cart_weight; - WFIFOL(fd,10)=sd->cart_weight_max; - len=14; - break; - - default: - ShowError("clif_updatestatus : unrecognized type %d\n",type); - return; - } - WFIFOSET(fd,len); + mdef2; + + } + break; + case SP_CRITICAL: + WFIFOL(fd,4)=sd->battle_status.cri/10; + break; + case SP_MATK1: + WFIFOL(fd,4)=sd->battle_status.matk_max; + break; + case SP_MATK2: + WFIFOL(fd,4)=sd->battle_status.matk_min; + break; + + + case SP_ZENY: + WFIFOW(fd,0)=0xb1; + WFIFOL(fd,4)=sd->status.zeny; + break; + case SP_BASEEXP: + WFIFOW(fd,0)=0xb1; + WFIFOL(fd,4)=sd->status.base_exp; + break; + case SP_JOBEXP: + WFIFOW(fd,0)=0xb1; + WFIFOL(fd,4)=sd->status.job_exp; + break; + case SP_NEXTBASEEXP: + WFIFOW(fd,0)=0xb1; + WFIFOL(fd,4)=pc_nextbaseexp(sd); + break; + case SP_NEXTJOBEXP: + WFIFOW(fd,0)=0xb1; + WFIFOL(fd,4)=pc_nextjobexp(sd); + break; + + /** + * SP_U are used to update the amount of points necessary to increase that stat + **/ + case SP_USTR: + case SP_UAGI: + case SP_UVIT: + case SP_UINT: + case SP_UDEX: + case SP_ULUK: + WFIFOW(fd,0)=0xbe; + WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1); + len=5; + break; + + /** + * Tells the client how far it is allowed to attack (weapon range) + **/ + case SP_ATTACKRANGE: + WFIFOW(fd,0)=0x13a; + WFIFOW(fd,2)=sd->battle_status.rhw.range; + len=4; + break; + + case SP_STR: + WFIFOW(fd,0)=0x141; + WFIFOL(fd,2)=type; + WFIFOL(fd,6)=sd->status.str; + WFIFOL(fd,10)=sd->battle_status.str - sd->status.str; + len=14; + break; + case SP_AGI: + WFIFOW(fd,0)=0x141; + WFIFOL(fd,2)=type; + WFIFOL(fd,6)=sd->status.agi; + WFIFOL(fd,10)=sd->battle_status.agi - sd->status.agi; + len=14; + break; + case SP_VIT: + WFIFOW(fd,0)=0x141; + WFIFOL(fd,2)=type; + WFIFOL(fd,6)=sd->status.vit; + WFIFOL(fd,10)=sd->battle_status.vit - sd->status.vit; + len=14; + break; + case SP_INT: + WFIFOW(fd,0)=0x141; + WFIFOL(fd,2)=type; + WFIFOL(fd,6)=sd->status.int_; + WFIFOL(fd,10)=sd->battle_status.int_ - sd->status.int_; + len=14; + break; + case SP_DEX: + WFIFOW(fd,0)=0x141; + WFIFOL(fd,2)=type; + WFIFOL(fd,6)=sd->status.dex; + WFIFOL(fd,10)=sd->battle_status.dex - sd->status.dex; + len=14; + break; + case SP_LUK: + WFIFOW(fd,0)=0x141; + WFIFOL(fd,2)=type; + WFIFOL(fd,6)=sd->status.luk; + WFIFOL(fd,10)=sd->battle_status.luk - sd->status.luk; + len=14; + break; + + case SP_CARTINFO: + WFIFOW(fd,0)=0x121; + WFIFOW(fd,2)=sd->cart_num; + WFIFOW(fd,4)=MAX_CART; + WFIFOL(fd,6)=sd->cart_weight; + WFIFOL(fd,10)=sd->cart_weight_max; + len=14; + break; + + default: + ShowError("clif_updatestatus : unrecognized type %d\n",type); + return; + } + WFIFOSET(fd,len); } /// Notifies client of a parameter change of an another player (ZC_PAR_CHANGE_USER). /// 01ab .L .W .L -void clif_changestatus(struct map_session_data *sd,int type,int val) +void clif_changestatus(struct map_session_data* sd,int type,int val) { - unsigned char buf[12]; + unsigned char buf[12]; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0)=0x1ab; - WBUFL(buf,2)=sd->bl.id; - WBUFW(buf,6)=type; + WBUFW(buf,0)=0x1ab; + WBUFL(buf,2)=sd->bl.id; + WBUFW(buf,6)=type; - switch (type) { - case SP_MANNER: - WBUFL(buf,8)=val; - break; - default: - ShowError("clif_changestatus : unrecognized type %d.\n",type); - return; - } + switch(type) + { + case SP_MANNER: + WBUFL(buf,8)=val; + break; + default: + ShowError("clif_changestatus : unrecognized type %d.\n",type); + return; + } - clif_send(buf,packet_len(0x1ab),&sd->bl,AREA_WOS); + clif_send(buf,packet_len(0x1ab),&sd->bl,AREA_WOS); } @@ -2939,156 +2977,161 @@ void clif_changestatus(struct map_session_data *sd,int type,int val) /// 01d7 .L .B .L (ZC_SPRITE_CHANGE2) void clif_changelook(struct block_list *bl,int type,int val) { - unsigned char buf[16]; - struct map_session_data *sd = NULL; - struct status_change *sc; - struct view_data *vd; - enum send_target target = AREA; - nullpo_retv(bl); - - sd = BL_CAST(BL_PC, bl); - sc = status_get_sc(bl); - vd = status_get_viewdata(bl); - //nullpo_ret(vd); - if (vd) //temp hack to let Warp Portal change appearance - switch (type) { - case LOOK_WEAPON: - if (sd) { - clif_get_weapon_view(sd, &vd->weapon, &vd->shield); - val = vd->weapon; - } else vd->weapon = val; - break; - case LOOK_SHIELD: - if (sd) { - clif_get_weapon_view(sd, &vd->weapon, &vd->shield); - val = vd->shield; - } else vd->shield = val; - break; - case LOOK_BASE: - vd->class_ = val; - if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS || vd->class_ == JOB_SUMMER) - vd->weapon = vd->shield = 0; - if (vd->cloth_color && ( - (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) || - (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette) || - (vd->class_ == JOB_SUMMER && battle_config.summer_ignorepalette) - )) - clif_changelook(bl,LOOK_CLOTHES_COLOR,0); - break; - case LOOK_HAIR: - vd->hair_style = val; - break; - case LOOK_HEAD_BOTTOM: - vd->head_bottom = val; - break; - case LOOK_HEAD_TOP: - vd->head_top = val; - break; - case LOOK_HEAD_MID: - vd->head_mid = val; - break; - case LOOK_HAIR_COLOR: - vd->hair_color = val; - break; - case LOOK_CLOTHES_COLOR: - if (val && ( - (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) || - (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette) || - (vd->class_ == JOB_SUMMER && battle_config.summer_ignorepalette) - )) - val = 0; - vd->cloth_color = val; - break; - case LOOK_SHOES: + unsigned char buf[16]; + struct map_session_data* sd = NULL; + struct status_change* sc; + struct view_data* vd; + enum send_target target = AREA; + nullpo_retv(bl); + + sd = BL_CAST(BL_PC, bl); + sc = status_get_sc(bl); + vd = status_get_viewdata(bl); + //nullpo_ret(vd); + if( vd ) //temp hack to let Warp Portal change appearance + switch(type) + { + case LOOK_WEAPON: + if (sd) + { + clif_get_weapon_view(sd, &vd->weapon, &vd->shield); + val = vd->weapon; + } + else vd->weapon = val; + break; + case LOOK_SHIELD: + if (sd) + { + clif_get_weapon_view(sd, &vd->weapon, &vd->shield); + val = vd->shield; + } + else vd->shield = val; + break; + case LOOK_BASE: + vd->class_ = val; + if (vd->class_ == JOB_WEDDING || vd->class_ == JOB_XMAS || vd->class_ == JOB_SUMMER) + vd->weapon = vd->shield = 0; + if (vd->cloth_color && ( + (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) || + (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette) || + (vd->class_ == JOB_SUMMER && battle_config.summer_ignorepalette) + )) + clif_changelook(bl,LOOK_CLOTHES_COLOR,0); + break; + case LOOK_HAIR: + vd->hair_style = val; + break; + case LOOK_HEAD_BOTTOM: + vd->head_bottom = val; + break; + case LOOK_HEAD_TOP: + vd->head_top = val; + break; + case LOOK_HEAD_MID: + vd->head_mid = val; + break; + case LOOK_HAIR_COLOR: + vd->hair_color = val; + break; + case LOOK_CLOTHES_COLOR: + if (val && ( + (vd->class_ == JOB_WEDDING && battle_config.wedding_ignorepalette) || + (vd->class_ == JOB_XMAS && battle_config.xmas_ignorepalette) || + (vd->class_ == JOB_SUMMER && battle_config.summer_ignorepalette) + )) + val = 0; + vd->cloth_color = val; + break; + case LOOK_SHOES: #if PACKETVER > 3 - if (sd) { - int n; - if ((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) { - if (sd->inventory_data[n]->view_id > 0) - val = sd->inventory_data[n]->view_id; - else - val = sd->status.inventory[n].nameid; - } else - val = 0; - } + if (sd) { + int n; + if((n = sd->equip_index[2]) >= 0 && sd->inventory_data[n]) { + if(sd->inventory_data[n]->view_id > 0) + val = sd->inventory_data[n]->view_id; + else + val = sd->status.inventory[n].nameid; + } else + val = 0; + } #endif - //Shoes? No packet uses this.... - break; - case LOOK_BODY: - case LOOK_FLOOR: - // unknown purpose - break; - case LOOK_ROBE: + //Shoes? No packet uses this.... + break; + case LOOK_BODY: + case LOOK_FLOOR: + // unknown purpose + break; + case LOOK_ROBE: #if PACKETVER < 20110111 - return; + return; #else - vd->robe = val; + vd->robe = val; #endif - break; - } + break; + } - // prevent leaking the presence of GM-hidden objects - if (sc && sc->option&OPTION_INVISIBLE) - target = SELF; + // prevent leaking the presence of GM-hidden objects + if( sc && sc->option&OPTION_INVISIBLE ) + target = SELF; #if PACKETVER < 4 - WBUFW(buf,0)=0xc3; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=type; - WBUFB(buf,7)=val; - clif_send(buf,packet_len(0xc3),bl,target); + WBUFW(buf,0)=0xc3; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=type; + WBUFB(buf,7)=val; + clif_send(buf,packet_len(0xc3),bl,target); #else - WBUFW(buf,0)=0x1d7; - WBUFL(buf,2)=bl->id; - if (type == LOOK_WEAPON || type == LOOK_SHIELD) { - WBUFB(buf,6)=LOOK_WEAPON; - WBUFW(buf,7)=vd->weapon; - WBUFW(buf,9)=vd->shield; - } else { - WBUFB(buf,6)=type; - WBUFL(buf,7)=val; - } - clif_send(buf,packet_len(0x1d7),bl,target); + WBUFW(buf,0)=0x1d7; + WBUFL(buf,2)=bl->id; + if(type == LOOK_WEAPON || type == LOOK_SHIELD) { + WBUFB(buf,6)=LOOK_WEAPON; + WBUFW(buf,7)=vd->weapon; + WBUFW(buf,9)=vd->shield; + } else { + WBUFB(buf,6)=type; + WBUFL(buf,7)=val; + } + clif_send(buf,packet_len(0x1d7),bl,target); #endif } //Sends a change-base-look packet required for traps as they are triggered. void clif_changetraplook(struct block_list *bl,int val) { - unsigned char buf[32]; + unsigned char buf[32]; #if PACKETVER < 4 - WBUFW(buf,0)=0xc3; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=LOOK_BASE; - WBUFB(buf,7)=val; - clif_send(buf,packet_len(0xc3),bl,AREA); + WBUFW(buf,0)=0xc3; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=LOOK_BASE; + WBUFB(buf,7)=val; + clif_send(buf,packet_len(0xc3),bl,AREA); #else - WBUFW(buf,0)=0x1d7; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=LOOK_BASE; - WBUFW(buf,7)=val; - WBUFW(buf,9)=0; - clif_send(buf,packet_len(0x1d7),bl,AREA); + WBUFW(buf,0)=0x1d7; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=LOOK_BASE; + WBUFW(buf,7)=val; + WBUFW(buf,9)=0; + clif_send(buf,packet_len(0x1d7),bl,AREA); #endif } //For the stupid cloth-dye bug. Resends the given view data to the area specified by bl. void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target) { - unsigned char buf[32]; + unsigned char buf[32]; #if PACKETVER < 4 - WBUFW(buf,0)=0xc3; - WBUFL(buf,2)=id; - WBUFB(buf,6)=type; - WBUFB(buf,7)=val; - clif_send(buf,packet_len(0xc3),bl,target); + WBUFW(buf,0)=0xc3; + WBUFL(buf,2)=id; + WBUFB(buf,6)=type; + WBUFB(buf,7)=val; + clif_send(buf,packet_len(0xc3),bl,target); #else - WBUFW(buf,0)=0x1d7; - WBUFL(buf,2)=id; - WBUFB(buf,6)=type; - WBUFW(buf,7)=val; - WBUFW(buf,9)=0; - clif_send(buf,packet_len(0x1d7),bl,target); + WBUFW(buf,0)=0x1d7; + WBUFL(buf,2)=id; + WBUFB(buf,6)=type; + WBUFW(buf,7)=val; + WBUFW(buf,9)=0; + clif_send(buf,packet_len(0x1d7),bl,target); #endif } @@ -3100,61 +3143,61 @@ void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_ta /// .W .W .W .W .W void clif_initialstatus(struct map_session_data *sd) { - int fd, mdef2; - unsigned char *buf; - - nullpo_retv(sd); - - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xbd)); - buf=WFIFOP(fd,0); - - WBUFW(buf,0)=0xbd; - WBUFW(buf,2)=min(sd->status.status_point, INT16_MAX); - WBUFB(buf,4)=min(sd->status.str, UINT8_MAX); - WBUFB(buf,5)=pc_need_status_point(sd,SP_STR,1); - WBUFB(buf,6)=min(sd->status.agi, UINT8_MAX); - WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI,1); - WBUFB(buf,8)=min(sd->status.vit, UINT8_MAX); - WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT,1); - WBUFB(buf,10)=min(sd->status.int_, UINT8_MAX); - WBUFB(buf,11)=pc_need_status_point(sd,SP_INT,1); - WBUFB(buf,12)=min(sd->status.dex, UINT8_MAX); - WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX,1); - WBUFB(buf,14)=min(sd->status.luk, UINT8_MAX); - WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK,1); - - WBUFW(buf,16) = pc_leftside_atk(sd); - WBUFW(buf,18) = pc_rightside_atk(sd); - WBUFW(buf,20) = pc_rightside_matk(sd); - WBUFW(buf,22) = pc_leftside_matk(sd); - WBUFW(buf,24) = pc_leftside_def(sd); - WBUFW(buf,26) = pc_rightside_def(sd); - WBUFW(buf,28) = pc_leftside_mdef(sd); - mdef2 = pc_rightside_mdef(sd); - WBUFW(buf,30) = + int fd, mdef2; + unsigned char *buf; + + nullpo_retv(sd); + + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xbd)); + buf=WFIFOP(fd,0); + + WBUFW(buf,0)=0xbd; + WBUFW(buf,2)=min(sd->status.status_point, INT16_MAX); + WBUFB(buf,4)=min(sd->status.str, UINT8_MAX); + WBUFB(buf,5)=pc_need_status_point(sd,SP_STR,1); + WBUFB(buf,6)=min(sd->status.agi, UINT8_MAX); + WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI,1); + WBUFB(buf,8)=min(sd->status.vit, UINT8_MAX); + WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT,1); + WBUFB(buf,10)=min(sd->status.int_, UINT8_MAX); + WBUFB(buf,11)=pc_need_status_point(sd,SP_INT,1); + WBUFB(buf,12)=min(sd->status.dex, UINT8_MAX); + WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX,1); + WBUFB(buf,14)=min(sd->status.luk, UINT8_MAX); + WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK,1); + + WBUFW(buf,16) = pc_leftside_atk(sd); + WBUFW(buf,18) = pc_rightside_atk(sd); + WBUFW(buf,20) = sd->battle_status.matk_max; + WBUFW(buf,22) = sd->battle_status.matk_min; + WBUFW(buf,24) = pc_leftside_def(sd); + WBUFW(buf,26) = pc_rightside_def(sd); + WBUFW(buf,28) = pc_leftside_mdef(sd); + mdef2 = pc_rightside_mdef(sd); + WBUFW(buf,30) = #ifndef RENEWAL - (mdef2 < 0) ? 0 : //Negative check for Frenzy'ed characters. + ( mdef2 < 0 ) ? 0 : //Negative check for Frenzy'ed characters. #endif - mdef2; - WBUFW(buf,32) = sd->battle_status.hit; - WBUFW(buf,34) = sd->battle_status.flee; - WBUFW(buf,36) = sd->battle_status.flee2/10; - WBUFW(buf,38) = sd->battle_status.cri/10; - WBUFW(buf,40) = sd->battle_status.amotion; // aspd - WBUFW(buf,42) = 0; // always 0 (plusASPD) + mdef2; + WBUFW(buf,32) = sd->battle_status.hit; + WBUFW(buf,34) = sd->battle_status.flee; + WBUFW(buf,36) = sd->battle_status.flee2/10; + WBUFW(buf,38) = sd->battle_status.cri/10; + WBUFW(buf,40) = sd->battle_status.amotion; // aspd + WBUFW(buf,42) = 0; // always 0 (plusASPD) - WFIFOSET(fd,packet_len(0xbd)); + WFIFOSET(fd,packet_len(0xbd)); - clif_updatestatus(sd,SP_STR); - clif_updatestatus(sd,SP_AGI); - clif_updatestatus(sd,SP_VIT); - clif_updatestatus(sd,SP_INT); - clif_updatestatus(sd,SP_DEX); - clif_updatestatus(sd,SP_LUK); + clif_updatestatus(sd,SP_STR); + clif_updatestatus(sd,SP_AGI); + clif_updatestatus(sd,SP_VIT); + clif_updatestatus(sd,SP_INT); + clif_updatestatus(sd,SP_DEX); + clif_updatestatus(sd,SP_LUK); - clif_updatestatus(sd,SP_ATTACKRANGE); - clif_updatestatus(sd,SP_ASPD); + clif_updatestatus(sd,SP_ATTACKRANGE); + clif_updatestatus(sd,SP_ASPD); } @@ -3162,17 +3205,17 @@ void clif_initialstatus(struct map_session_data *sd) /// 013c .W void clif_arrowequip(struct map_session_data *sd,int val) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - pc_stop_attack(sd); // [Valaris] + pc_stop_attack(sd); // [Valaris] - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x013c)); - WFIFOW(fd,0)=0x013c; - WFIFOW(fd,2)=val+2; //Item ID of the arrow - WFIFOSET(fd,packet_len(0x013c)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0x013c)); + WFIFOW(fd,0)=0x013c; + WFIFOW(fd,2)=val+2; //Item ID of the arrow + WFIFOSET(fd,packet_len(0x013c)); } @@ -3187,15 +3230,15 @@ void clif_arrowequip(struct map_session_data *sd,int val) /// NOT ninja => MsgStringTable[245]="Ammunition has been equipped." void clif_arrow_fail(struct map_session_data *sd,int type) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(0x013b)); - WFIFOW(fd,0)=0x013b; - WFIFOW(fd,2)=type; - WFIFOSET(fd,packet_len(0x013b)); + fd=sd->fd; + WFIFOHEAD(fd, packet_len(0x013b)); + WFIFOW(fd,0)=0x013b; + WFIFOW(fd,2)=type; + WFIFOSET(fd,packet_len(0x013b)); } @@ -3203,32 +3246,33 @@ void clif_arrow_fail(struct map_session_data *sd,int type) /// 01ad .W { .W }* void clif_arrow_create_list(struct map_session_data *sd) { - int i, c, j; - int fd; + int i, c, j; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd, MAX_SKILL_ARROW_DB*2+4); - WFIFOW(fd,0) = 0x1ad; - - for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) { - if (skill_arrow_db[i].nameid > 0 && - (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 && - !sd->status.inventory[j].equip && sd->status.inventory[j].identify) { - if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0) - WFIFOW(fd,c*2+4) = j; - else - WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid; - c++; - } - } - WFIFOW(fd,2) = c*2+4; - WFIFOSET(fd, WFIFOW(fd,2)); - if (c > 0) { - sd->menuskill_id = AC_MAKINGARROW; - sd->menuskill_val = c; - } + fd = sd->fd; + WFIFOHEAD(fd, MAX_SKILL_ARROW_DB*2+4); + WFIFOW(fd,0) = 0x1ad; + + for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) { + if (skill_arrow_db[i].nameid > 0 && + (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 && + !sd->status.inventory[j].equip && sd->status.inventory[j].identify) + { + if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0) + WFIFOW(fd,c*2+4) = j; + else + WFIFOW(fd,c*2+4) = skill_arrow_db[i].nameid; + c++; + } + } + WFIFOW(fd,2) = c*2+4; + WFIFOSET(fd, WFIFOW(fd,2)); + if (c > 0) { + sd->menuskill_id = AC_MAKINGARROW; + sd->menuskill_val = c; + } } @@ -3241,17 +3285,17 @@ void clif_arrow_create_list(struct map_session_data *sd) /// 1 = success void clif_statusupack(struct map_session_data *sd,int type,int ok,int val) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xbc)); - WFIFOW(fd,0)=0xbc; - WFIFOW(fd,2)=type; - WFIFOB(fd,4)=ok; - WFIFOB(fd,5)=cap_value(val,0,UINT8_MAX); - WFIFOSET(fd,packet_len(0xbc)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xbc)); + WFIFOW(fd,0)=0xbc; + WFIFOW(fd,2)=type; + WFIFOB(fd,4)=ok; + WFIFOB(fd,5)=cap_value(val,0,UINT8_MAX); + WFIFOSET(fd,packet_len(0xbc)); } @@ -3264,25 +3308,25 @@ void clif_statusupack(struct map_session_data *sd,int type,int ok,int val) /// 2 = failure due to low level void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xaa)); - WFIFOW(fd,0)=0xaa; - WFIFOW(fd,2)=n+2; - WFIFOW(fd,4)=pos; + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xaa)); + WFIFOW(fd,0)=0xaa; + WFIFOW(fd,2)=n+2; + WFIFOW(fd,4)=pos; #if PACKETVER < 20100629 - WFIFOB(fd,6)=ok; + WFIFOB(fd,6)=ok; #else - if (ok && sd->inventory_data[n]->equip&EQP_VISIBLE) - WFIFOW(fd,6)=sd->inventory_data[n]->look; - else - WFIFOW(fd,6)=0; - WFIFOB(fd,8)=ok; + if (ok && sd->inventory_data[n]->equip&EQP_VISIBLE) + WFIFOW(fd,6)=sd->inventory_data[n]->look; + else + WFIFOW(fd,6)=0; + WFIFOB(fd,8)=ok; #endif - WFIFOSET(fd,packet_len(0xaa)); + WFIFOSET(fd,packet_len(0xaa)); } @@ -3293,17 +3337,17 @@ void clif_equipitemack(struct map_session_data *sd,int n,int pos,int ok) /// 1 = success void clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xac)); - WFIFOW(fd,0)=0xac; - WFIFOW(fd,2)=n+2; - WFIFOW(fd,4)=pos; - WFIFOB(fd,6)=ok; - WFIFOSET(fd,packet_len(0xac)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xac)); + WFIFOW(fd,0)=0xac; + WFIFOW(fd,2)=n+2; + WFIFOW(fd,4)=pos; + WFIFOB(fd,6)=ok; + WFIFOSET(fd,packet_len(0xac)); } @@ -3320,94 +3364,94 @@ void clif_unequipitemack(struct map_session_data *sd,int n,int pos,int ok) /// 7 = base level up (super novice) /// 8 = job level up (super novice) /// 9 = base level up (taekwon) -void clif_misceffect(struct block_list *bl,int type) +void clif_misceffect(struct block_list* bl,int type) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x19b; - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = type; + WBUFW(buf,0) = 0x19b; + WBUFL(buf,2) = bl->id; + WBUFL(buf,6) = type; - clif_send(buf,packet_len(0x19b),bl,AREA); + clif_send(buf,packet_len(0x19b),bl,AREA); } /// Notifies clients in the area of a state change. /// 0119 .L .W .W .W .B (ZC_STATE_CHANGE) /// 0229 .L .W .W .L .B (ZC_STATE_CHANGE3) -void clif_changeoption(struct block_list *bl) +void clif_changeoption(struct block_list* bl) { - unsigned char buf[32]; - struct status_change *sc; - struct map_session_data *sd; + unsigned char buf[32]; + struct status_change *sc; + struct map_session_data* sd; - nullpo_retv(bl); - sc = status_get_sc(bl); - if (!sc) return; //How can an option change if there's no sc? - sd = BL_CAST(BL_PC, bl); + nullpo_retv(bl); + sc = status_get_sc(bl); + if (!sc) return; //How can an option change if there's no sc? + sd = BL_CAST(BL_PC, bl); #if PACKETVER >= 7 - WBUFW(buf,0) = 0x229; - WBUFL(buf,2) = bl->id; - WBUFW(buf,6) = sc->opt1; - WBUFW(buf,8) = sc->opt2; - WBUFL(buf,10) = sc->option; - WBUFB(buf,14) = (sd)? sd->status.karma : 0; - if (disguised(bl)) { - clif_send(buf,packet_len(0x229),bl,AREA_WOS); - WBUFL(buf,2) = -bl->id; - clif_send(buf,packet_len(0x229),bl,SELF); - WBUFL(buf,2) = bl->id; - WBUFL(buf,10) = OPTION_INVISIBLE; - clif_send(buf,packet_len(0x229),bl,SELF); - } else - clif_send(buf,packet_len(0x229),bl,AREA); + WBUFW(buf,0) = 0x229; + WBUFL(buf,2) = bl->id; + WBUFW(buf,6) = sc->opt1; + WBUFW(buf,8) = sc->opt2; + WBUFL(buf,10) = sc->option; + WBUFB(buf,14) = (sd)? sd->status.karma : 0; + if(disguised(bl)) { + clif_send(buf,packet_len(0x229),bl,AREA_WOS); + WBUFL(buf,2) = -bl->id; + clif_send(buf,packet_len(0x229),bl,SELF); + WBUFL(buf,2) = bl->id; + WBUFL(buf,10) = OPTION_INVISIBLE; + clif_send(buf,packet_len(0x229),bl,SELF); + } else + clif_send(buf,packet_len(0x229),bl,AREA); #else - WBUFW(buf,0) = 0x119; - WBUFL(buf,2) = bl->id; - WBUFW(buf,6) = sc->opt1; - WBUFW(buf,8) = sc->opt2; - WBUFW(buf,10) = sc->option; - WBUFB(buf,12) = (sd)? sd->status.karma : 0; - if (disguised(bl)) { - clif_send(buf,packet_len(0x119),bl,AREA_WOS); - WBUFL(buf,2) = -bl->id; - clif_send(buf,packet_len(0x119),bl,SELF); - WBUFL(buf,2) = bl->id; - WBUFW(buf,10) = OPTION_INVISIBLE; - clif_send(buf,packet_len(0x119),bl,SELF); - } else - clif_send(buf,packet_len(0x119),bl,AREA); + WBUFW(buf,0) = 0x119; + WBUFL(buf,2) = bl->id; + WBUFW(buf,6) = sc->opt1; + WBUFW(buf,8) = sc->opt2; + WBUFW(buf,10) = sc->option; + WBUFB(buf,12) = (sd)? sd->status.karma : 0; + if(disguised(bl)) { + clif_send(buf,packet_len(0x119),bl,AREA_WOS); + WBUFL(buf,2) = -bl->id; + clif_send(buf,packet_len(0x119),bl,SELF); + WBUFL(buf,2) = bl->id; + WBUFW(buf,10) = OPTION_INVISIBLE; + clif_send(buf,packet_len(0x119),bl,SELF); + } else + clif_send(buf,packet_len(0x119),bl,AREA); #endif } /// Displays status change effects on NPCs/monsters (ZC_NPC_SHOWEFST_UPDATE). /// 028a .L .L .L .L -void clif_changeoption2(struct block_list *bl) +void clif_changeoption2(struct block_list* bl) { - unsigned char buf[20]; - struct status_change *sc; + unsigned char buf[20]; + struct status_change *sc; - sc = status_get_sc(bl); - if (!sc) return; //How can an option change if there's no sc? + sc = status_get_sc(bl); + if (!sc) return; //How can an option change if there's no sc? - WBUFW(buf,0) = 0x28a; - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = sc->option; - WBUFL(buf,10) = clif_setlevel(bl); - WBUFL(buf,14) = sc->opt3; - if (disguised(bl)) { - clif_send(buf,packet_len(0x28a),bl,AREA_WOS); - WBUFL(buf,2) = -bl->id; - clif_send(buf,packet_len(0x28a),bl,SELF); - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = OPTION_INVISIBLE; - clif_send(buf,packet_len(0x28a),bl,SELF); - } else - clif_send(buf,packet_len(0x28a),bl,AREA); + WBUFW(buf,0) = 0x28a; + WBUFL(buf,2) = bl->id; + WBUFL(buf,6) = sc->option; + WBUFL(buf,10) = clif_setlevel(bl); + WBUFL(buf,14) = sc->opt3; + if(disguised(bl)) { + clif_send(buf,packet_len(0x28a),bl,AREA_WOS); + WBUFL(buf,2) = -bl->id; + clif_send(buf,packet_len(0x28a),bl,SELF); + WBUFL(buf,2) = bl->id; + WBUFL(buf,6) = OPTION_INVISIBLE; + clif_send(buf,packet_len(0x28a),bl,SELF); + } else + clif_send(buf,packet_len(0x28a),bl,AREA); } @@ -3416,40 +3460,41 @@ void clif_changeoption2(struct block_list *bl) /// 01c8 .W .W .L .W .B (ZC_USE_ITEM_ACK2) void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok) { - nullpo_retv(sd); - - if (!ok) { - int fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xa8)); - WFIFOW(fd,0)=0xa8; - WFIFOW(fd,2)=index+2; - WFIFOW(fd,4)=amount; - WFIFOB(fd,6)=ok; - WFIFOSET(fd,packet_len(0xa8)); - } else { + nullpo_retv(sd); + + if(!ok) { + int fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xa8)); + WFIFOW(fd,0)=0xa8; + WFIFOW(fd,2)=index+2; + WFIFOW(fd,4)=amount; + WFIFOB(fd,6)=ok; + WFIFOSET(fd,packet_len(0xa8)); + } + else { #if PACKETVER < 3 - int fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xa8)); - WFIFOW(fd,0)=0xa8; - WFIFOW(fd,2)=index+2; - WFIFOW(fd,4)=amount; - WFIFOB(fd,6)=ok; - WFIFOSET(fd,packet_len(0xa8)); + int fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xa8)); + WFIFOW(fd,0)=0xa8; + WFIFOW(fd,2)=index+2; + WFIFOW(fd,4)=amount; + WFIFOB(fd,6)=ok; + WFIFOSET(fd,packet_len(0xa8)); #else - unsigned char buf[32]; - - WBUFW(buf,0)=0x1c8; - WBUFW(buf,2)=index+2; - if (sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) - WBUFW(buf,4)=sd->inventory_data[index]->view_id; - else - WBUFW(buf,4)=sd->status.inventory[index].nameid; - WBUFL(buf,6)=sd->bl.id; - WBUFW(buf,10)=amount; - WBUFB(buf,12)=ok; - clif_send(buf,packet_len(0x1c8),&sd->bl,AREA); + unsigned char buf[32]; + + WBUFW(buf,0)=0x1c8; + WBUFW(buf,2)=index+2; + if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) + WBUFW(buf,4)=sd->inventory_data[index]->view_id; + else + WBUFW(buf,4)=sd->status.inventory[index].nameid; + WBUFL(buf,6)=sd->bl.id; + WBUFW(buf,10)=amount; + WBUFB(buf,12)=ok; + clif_send(buf,packet_len(0x1c8),&sd->bl,AREA); #endif - } + } } @@ -3459,17 +3504,17 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok) /// 0 = Room has been successfully created (opens chat room) /// 1 = Room limit exceeded /// 2 = Same room already exists -void clif_createchat(struct map_session_data *sd, int flag) +void clif_createchat(struct map_session_data* sd, int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xd6)); - WFIFOW(fd,0) = 0xd6; - WFIFOB(fd,2) = flag; - WFIFOSET(fd,packet_len(0xd6)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xd6)); + WFIFOW(fd,0) = 0xd6; + WFIFOB(fd,2) = flag; + WFIFOSET(fd,packet_len(0xd6)); } @@ -3480,34 +3525,34 @@ void clif_createchat(struct map_session_data *sd, int flag) /// 1 = public /// 2 = arena (npc waiting room) /// 3 = PK zone (non-clickable) -void clif_dispchat(struct chat_data *cd, int fd) -{ - unsigned char buf[128]; - uint8 type; - - if (cd == NULL || cd->owner == NULL) - return; - - type = (cd->owner->type == BL_PC) ? (cd->pub) ? 1 : 0 - : (cd->owner->type == BL_NPC) ? (cd->limit) ? 2 : 3 - : 1; - - WBUFW(buf, 0) = 0xd7; - WBUFW(buf, 2) = 17 + strlen(cd->title); - WBUFL(buf, 4) = cd->owner->id; - WBUFL(buf, 8) = cd->bl.id; - WBUFW(buf,12) = cd->limit; - WBUFW(buf,14) = (cd->owner->type == BL_NPC) ? cd->users+1 : cd->users; - WBUFB(buf,16) = type; - memcpy((char *)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated - - if (fd) { - WFIFOHEAD(fd,WBUFW(buf,2)); - memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2)); - WFIFOSET(fd,WBUFW(buf,2)); - } else { - clif_send(buf,WBUFW(buf,2),cd->owner,AREA_WOSC); - } +void clif_dispchat(struct chat_data* cd, int fd) +{ + unsigned char buf[128]; + uint8 type; + + if( cd == NULL || cd->owner == NULL ) + return; + + type = (cd->owner->type == BL_PC ) ? (cd->pub) ? 1 : 0 + : (cd->owner->type == BL_NPC) ? (cd->limit) ? 2 : 3 + : 1; + + WBUFW(buf, 0) = 0xd7; + WBUFW(buf, 2) = 17 + strlen(cd->title); + WBUFL(buf, 4) = cd->owner->id; + WBUFL(buf, 8) = cd->bl.id; + WBUFW(buf,12) = cd->limit; + WBUFW(buf,14) = (cd->owner->type == BL_NPC) ? cd->users+1 : cd->users; + WBUFB(buf,16) = type; + memcpy((char*)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated + + if( fd ) { + WFIFOHEAD(fd,WBUFW(buf,2)); + memcpy(WFIFOP(fd,0),buf,WBUFW(buf,2)); + WFIFOSET(fd,WBUFW(buf,2)); + } else { + clif_send(buf,WBUFW(buf,2),cd->owner,AREA_WOSC); + } } @@ -3518,28 +3563,28 @@ void clif_dispchat(struct chat_data *cd, int fd) /// 1 = public /// 2 = arena (npc waiting room) /// 3 = PK zone (non-clickable) -void clif_changechatstatus(struct chat_data *cd) +void clif_changechatstatus(struct chat_data* cd) { - unsigned char buf[128]; - uint8 type; + unsigned char buf[128]; + uint8 type; - if (cd == NULL || cd->usersd[0] == NULL) - return; + if( cd == NULL || cd->usersd[0] == NULL ) + return; - type = (cd->owner->type == BL_PC) ? (cd->pub) ? 1 : 0 - : (cd->owner->type == BL_NPC) ? (cd->limit) ? 2 : 3 - : 1; + type = (cd->owner->type == BL_PC ) ? (cd->pub) ? 1 : 0 + : (cd->owner->type == BL_NPC) ? (cd->limit) ? 2 : 3 + : 1; - WBUFW(buf, 0) = 0xdf; - WBUFW(buf, 2) = 17 + strlen(cd->title); - WBUFL(buf, 4) = cd->owner->id; - WBUFL(buf, 8) = cd->bl.id; - WBUFW(buf,12) = cd->limit; - WBUFW(buf,14) = (cd->owner->type == BL_NPC) ? cd->users+1 : cd->users; - WBUFB(buf,16) = type; - memcpy((char *)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated + WBUFW(buf, 0) = 0xdf; + WBUFW(buf, 2) = 17 + strlen(cd->title); + WBUFL(buf, 4) = cd->owner->id; + WBUFL(buf, 8) = cd->bl.id; + WBUFW(buf,12) = cd->limit; + WBUFW(buf,14) = (cd->owner->type == BL_NPC) ? cd->users+1 : cd->users; + WBUFB(buf,16) = type; + memcpy((char*)WBUFP(buf,17), cd->title, strlen(cd->title)); // not zero-terminated - clif_send(buf,WBUFW(buf,2),cd->owner,CHAT); + clif_send(buf,WBUFW(buf,2),cd->owner,CHAT); } @@ -3547,19 +3592,19 @@ void clif_changechatstatus(struct chat_data *cd) /// 00d8 .L void clif_clearchat(struct chat_data *cd,int fd) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(cd); + nullpo_retv(cd); - WBUFW(buf,0) = 0xd8; - WBUFL(buf,2) = cd->bl.id; - if (fd) { - WFIFOHEAD(fd,packet_len(0xd8)); - memcpy(WFIFOP(fd,0),buf,packet_len(0xd8)); - WFIFOSET(fd,packet_len(0xd8)); - } else { - clif_send(buf,packet_len(0xd8),cd->owner,AREA_WOSC); - } + WBUFW(buf,0) = 0xd8; + WBUFL(buf,2) = cd->bl.id; + if( fd ) { + WFIFOHEAD(fd,packet_len(0xd8)); + memcpy(WFIFOP(fd,0),buf,packet_len(0xd8)); + WFIFOSET(fd,packet_len(0xd8)); + } else { + clif_send(buf,packet_len(0xd8),cd->owner,AREA_WOSC); + } } @@ -3576,16 +3621,16 @@ void clif_clearchat(struct chat_data *cd,int fd) /// 7 = unsuitable job class void clif_joinchatfail(struct map_session_data *sd,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; + fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xda)); - WFIFOW(fd,0) = 0xda; - WFIFOB(fd,2) = flag; - WFIFOSET(fd,packet_len(0xda)); + WFIFOHEAD(fd,packet_len(0xda)); + WFIFOW(fd,0) = 0xda; + WFIFOB(fd,2) = flag; + WFIFOSET(fd,packet_len(0xda)); } @@ -3594,53 +3639,53 @@ void clif_joinchatfail(struct map_session_data *sd,int flag) /// role: /// 0 = owner (menu) /// 1 = normal -void clif_joinchatok(struct map_session_data *sd,struct chat_data *cd) -{ - int fd; - int i,t; - - nullpo_retv(sd); - nullpo_retv(cd); - - fd = sd->fd; - if (!session_isActive(fd)) - return; - t = (int)(cd->owner->type == BL_NPC); - WFIFOHEAD(fd, 8 + (28*(cd->users+t))); - WFIFOW(fd, 0) = 0xdb; - WFIFOW(fd, 2) = 8 + (28*(cd->users+t)); - WFIFOL(fd, 4) = cd->bl.id; - - if (cd->owner->type == BL_NPC) { - WFIFOL(fd, 30) = 1; - WFIFOL(fd, 8) = 0; - memcpy(WFIFOP(fd, 12), ((struct npc_data *)cd->owner)->name, NAME_LENGTH); - for (i = 0; i < cd->users; i++) { - WFIFOL(fd, 8+(i+1)*28) = 1; - memcpy(WFIFOP(fd, 8+(i+t)*28+4), cd->usersd[i]->status.name, NAME_LENGTH); - } - } else - for (i = 0; i < cd->users; i++) { - WFIFOL(fd, 8+i*28) = (i != 0 || cd->owner->type == BL_NPC); - memcpy(WFIFOP(fd, 8+(i+t)*28+4), cd->usersd[i]->status.name, NAME_LENGTH); - } - WFIFOSET(fd, WFIFOW(fd, 2)); +void clif_joinchatok(struct map_session_data *sd,struct chat_data* cd) +{ + int fd; + int i,t; + + nullpo_retv(sd); + nullpo_retv(cd); + + fd = sd->fd; + if (!session_isActive(fd)) + return; + t = (int)(cd->owner->type == BL_NPC); + WFIFOHEAD(fd, 8 + (28*(cd->users+t))); + WFIFOW(fd, 0) = 0xdb; + WFIFOW(fd, 2) = 8 + (28*(cd->users+t)); + WFIFOL(fd, 4) = cd->bl.id; + + if(cd->owner->type == BL_NPC){ + WFIFOL(fd, 30) = 1; + WFIFOL(fd, 8) = 0; + memcpy(WFIFOP(fd, 12), ((struct npc_data *)cd->owner)->name, NAME_LENGTH); + for (i = 0; i < cd->users; i++) { + WFIFOL(fd, 8+(i+1)*28) = 1; + memcpy(WFIFOP(fd, 8+(i+t)*28+4), cd->usersd[i]->status.name, NAME_LENGTH); + } + } else + for (i = 0; i < cd->users; i++) { + WFIFOL(fd, 8+i*28) = (i != 0 || cd->owner->type == BL_NPC); + memcpy(WFIFOP(fd, 8+(i+t)*28+4), cd->usersd[i]->status.name, NAME_LENGTH); + } + WFIFOSET(fd, WFIFOW(fd, 2)); } /// Notifies clients in a chat about a new member (ZC_MEMBER_NEWENTRY). /// 00dc .W .24B -void clif_addchat(struct chat_data *cd,struct map_session_data *sd) +void clif_addchat(struct chat_data* cd,struct map_session_data *sd) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(sd); - nullpo_retv(cd); + nullpo_retv(sd); + nullpo_retv(cd); - WBUFW(buf, 0) = 0xdc; - WBUFW(buf, 2) = cd->users; - memcpy(WBUFP(buf, 4),sd->status.name,NAME_LENGTH); - clif_send(buf,packet_len(0xdc),&sd->bl,CHAT_WOS); + WBUFW(buf, 0) = 0xdc; + WBUFW(buf, 2) = cd->users; + memcpy(WBUFP(buf, 4),sd->status.name,NAME_LENGTH); + clif_send(buf,packet_len(0xdc),&sd->bl,CHAT_WOS); } @@ -3649,22 +3694,22 @@ void clif_addchat(struct chat_data *cd,struct map_session_data *sd) /// role: /// 0 = owner (menu) /// 1 = normal -void clif_changechatowner(struct chat_data *cd, struct map_session_data *sd) +void clif_changechatowner(struct chat_data* cd, struct map_session_data* sd) { - unsigned char buf[64]; + unsigned char buf[64]; - nullpo_retv(sd); - nullpo_retv(cd); + nullpo_retv(sd); + nullpo_retv(cd); - WBUFW(buf, 0) = 0xe1; - WBUFL(buf, 2) = 1; - memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,NAME_LENGTH); + WBUFW(buf, 0) = 0xe1; + WBUFL(buf, 2) = 1; + memcpy(WBUFP(buf,6),cd->usersd[0]->status.name,NAME_LENGTH); - WBUFW(buf,30) = 0xe1; - WBUFL(buf,32) = 0; - memcpy(WBUFP(buf,36),sd->status.name,NAME_LENGTH); + WBUFW(buf,30) = 0xe1; + WBUFL(buf,32) = 0; + memcpy(WBUFP(buf,36),sd->status.name,NAME_LENGTH); - clif_send(buf,packet_len(0xe1)*2,&sd->bl,CHAT); + clif_send(buf,packet_len(0xe1)*2,&sd->bl,CHAT); } @@ -3673,44 +3718,44 @@ void clif_changechatowner(struct chat_data *cd, struct map_session_data *sd) /// flag: /// 0 = left /// 1 = kicked -void clif_leavechat(struct chat_data *cd, struct map_session_data *sd, bool flag) +void clif_leavechat(struct chat_data* cd, struct map_session_data* sd, bool flag) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(sd); - nullpo_retv(cd); + nullpo_retv(sd); + nullpo_retv(cd); - WBUFW(buf, 0) = 0xdd; - WBUFW(buf, 2) = cd->users-1; - memcpy(WBUFP(buf,4),sd->status.name,NAME_LENGTH); - WBUFB(buf,28) = flag; + WBUFW(buf, 0) = 0xdd; + WBUFW(buf, 2) = cd->users-1; + memcpy(WBUFP(buf,4),sd->status.name,NAME_LENGTH); + WBUFB(buf,28) = flag; - clif_send(buf,packet_len(0xdd),&sd->bl,CHAT); + clif_send(buf,packet_len(0xdd),&sd->bl,CHAT); } /// Opens a trade request window from char 'name'. /// 00e5 .24B (ZC_REQ_EXCHANGE_ITEM) /// 01f4 .24B .L .W (ZC_REQ_EXCHANGE_ITEM2) -void clif_traderequest(struct map_session_data *sd, const char *name) +void clif_traderequest(struct map_session_data* sd, const char* name) { - int fd = sd->fd; + int fd = sd->fd; #if PACKETVER < 6 - WFIFOHEAD(fd,packet_len(0xe5)); - WFIFOW(fd,0) = 0xe5; - safestrncpy((char *)WFIFOP(fd,2), name, NAME_LENGTH); - WFIFOSET(fd,packet_len(0xe5)); + WFIFOHEAD(fd,packet_len(0xe5)); + WFIFOW(fd,0) = 0xe5; + safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); + WFIFOSET(fd,packet_len(0xe5)); #else - struct map_session_data *tsd = map_id2sd(sd->trade_partner); - if (!tsd) return; - - WFIFOHEAD(fd,packet_len(0x1f4)); - WFIFOW(fd,0) = 0x1f4; - safestrncpy((char *)WFIFOP(fd,2), name, NAME_LENGTH); - WFIFOL(fd,26) = tsd->status.char_id; - WFIFOW(fd,30) = tsd->status.base_level; - WFIFOSET(fd,packet_len(0x1f4)); + struct map_session_data* tsd = map_id2sd(sd->trade_partner); + if( !tsd ) return; + + WFIFOHEAD(fd,packet_len(0x1f4)); + WFIFOW(fd,0) = 0x1f4; + safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); + WFIFOL(fd,26) = tsd->status.char_id; + WFIFOW(fd,30) = tsd->status.base_level; + WFIFOSET(fd,packet_len(0x1f4)); #endif } @@ -3725,85 +3770,88 @@ void clif_traderequest(struct map_session_data *sd, const char *name) /// 3 = Accept /// 4 = Cancel /// 5 = Busy -void clif_tradestart(struct map_session_data *sd, uint8 type) -{ - int fd = sd->fd; - struct map_session_data *tsd = map_id2sd(sd->trade_partner); - if (PACKETVER < 6 || !tsd) { - WFIFOHEAD(fd,packet_len(0xe7)); - WFIFOW(fd,0) = 0xe7; - WFIFOB(fd,2) = type; - WFIFOSET(fd,packet_len(0xe7)); - } else { - WFIFOHEAD(fd,packet_len(0x1f5)); - WFIFOW(fd,0) = 0x1f5; - WFIFOB(fd,2) = type; - WFIFOL(fd,3) = tsd->status.char_id; - WFIFOW(fd,7) = tsd->status.base_level; - WFIFOSET(fd,packet_len(0x1f5)); - } +void clif_tradestart(struct map_session_data* sd, uint8 type) +{ + int fd = sd->fd; + struct map_session_data* tsd = map_id2sd(sd->trade_partner); + if( PACKETVER < 6 || !tsd ) { + WFIFOHEAD(fd,packet_len(0xe7)); + WFIFOW(fd,0) = 0xe7; + WFIFOB(fd,2) = type; + WFIFOSET(fd,packet_len(0xe7)); + } else { + WFIFOHEAD(fd,packet_len(0x1f5)); + WFIFOW(fd,0) = 0x1f5; + WFIFOB(fd,2) = type; + WFIFOL(fd,3) = tsd->status.char_id; + WFIFOW(fd,7) = tsd->status.base_level; + WFIFOSET(fd,packet_len(0x1f5)); + } } /// Notifies the client about an item from other player in current trade. /// 00e9 .L .W .B .B .B .W .W .W .W (ZC_ADD_EXCHANGE_ITEM) /// 080f .W .B .L .B .B .B .W .W .W .W (ZC_ADD_EXCHANGE_ITEM2) -void clif_tradeadditem(struct map_session_data *sd, struct map_session_data *tsd, int index, int amount) +void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd, int index, int amount) { - int fd; - unsigned char *buf; + int fd; + unsigned char *buf; #if PACKETVER < 20100223 - const int cmd = 0xe9; + const int cmd = 0xe9; #else - const int cmd = 0x80f; + const int cmd = 0x80f; #endif - nullpo_retv(sd); - nullpo_retv(tsd); - - fd = tsd->fd; - buf = WFIFOP(fd,0); - WFIFOHEAD(fd,packet_len(cmd)); - WBUFW(buf,0) = cmd; - if (index == 0) { + nullpo_retv(sd); + nullpo_retv(tsd); + + fd = tsd->fd; + buf = WFIFOP(fd,0); + WFIFOHEAD(fd,packet_len(cmd)); + WBUFW(buf,0) = cmd; + if( index == 0 ) + { #if PACKETVER < 20100223 - WBUFL(buf,2) = amount; //amount - WBUFW(buf,6) = 0; // type id + WBUFL(buf,2) = amount; //amount + WBUFW(buf,6) = 0; // type id #else - WBUFW(buf,2) = 0; // type id - WBUFB(buf,4) = 0; // item type - WBUFL(buf,5) = amount; // amount - buf = WBUFP(buf,1); //Advance 1B + WBUFW(buf,2) = 0; // type id + WBUFB(buf,4) = 0; // item type + WBUFL(buf,5) = amount; // amount + buf = WBUFP(buf,1); //Advance 1B #endif - WBUFB(buf,8) = 0; //identify flag - WBUFB(buf,9) = 0; // attribute - WBUFB(buf,10)= 0; //refine - WBUFW(buf,11)= 0; //card (4w) - WBUFW(buf,13)= 0; //card (4w) - WBUFW(buf,15)= 0; //card (4w) - WBUFW(buf,17)= 0; //card (4w) - } else { - index -= 2; //index fix + WBUFB(buf,8) = 0; //identify flag + WBUFB(buf,9) = 0; // attribute + WBUFB(buf,10)= 0; //refine + WBUFW(buf,11)= 0; //card (4w) + WBUFW(buf,13)= 0; //card (4w) + WBUFW(buf,15)= 0; //card (4w) + WBUFW(buf,17)= 0; //card (4w) + } + else + { + index -= 2; //index fix #if PACKETVER < 20100223 - WBUFL(buf,2) = amount; //amount - if (sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) - WBUFW(buf,6) = sd->inventory_data[index]->view_id; - else - WBUFW(buf,6) = sd->status.inventory[index].nameid; // type id + WBUFL(buf,2) = amount; //amount + if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) + WBUFW(buf,6) = sd->inventory_data[index]->view_id; + else + WBUFW(buf,6) = sd->status.inventory[index].nameid; // type id #else - if (sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) - WBUFW(buf,2) = sd->inventory_data[index]->view_id; - else - WBUFW(buf,2) = sd->status.inventory[index].nameid; // type id - WBUFB(buf,4) = sd->inventory_data[index]->type; // item type - WBUFL(buf,5) = amount; // amount - buf = WBUFP(buf,1); //Advance 1B + if(sd->inventory_data[index] && sd->inventory_data[index]->view_id > 0) + WBUFW(buf,2) = sd->inventory_data[index]->view_id; + else + WBUFW(buf,2) = sd->status.inventory[index].nameid; // type id + WBUFB(buf,4) = sd->inventory_data[index]->type; // item type + WBUFL(buf,5) = amount; // amount + buf = WBUFP(buf,1); //Advance 1B #endif - WBUFB(buf,8) = sd->status.inventory[index].identify; //identify flag - WBUFB(buf,9) = sd->status.inventory[index].attribute; // attribute - WBUFB(buf,10)= sd->status.inventory[index].refine; //refine - clif_addcards(WBUFP(buf, 11), &sd->status.inventory[index]); - } - WFIFOSET(fd,packet_len(cmd)); + WBUFB(buf,8) = sd->status.inventory[index].identify; //identify flag + WBUFB(buf,9) = sd->status.inventory[index].attribute; // attribute + WBUFB(buf,10)= sd->status.inventory[index].refine; //refine + clif_addcards(WBUFP(buf, 11), &sd->status.inventory[index]); + } + WFIFOSET(fd,packet_len(cmd)); } @@ -3813,17 +3861,17 @@ void clif_tradeadditem(struct map_session_data *sd, struct map_session_data *tsd /// 0 = success /// 1 = overweight /// 2 = trade canceled -void clif_tradeitemok(struct map_session_data *sd, int index, int fail) +void clif_tradeitemok(struct map_session_data* sd, int index, int fail) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xea)); - WFIFOW(fd,0) = 0xea; - WFIFOW(fd,2) = index; - WFIFOB(fd,4) = fail; - WFIFOSET(fd,packet_len(0xea)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xea)); + WFIFOW(fd,0) = 0xea; + WFIFOW(fd,2) = index; + WFIFOB(fd,4) = fail; + WFIFOSET(fd,packet_len(0xea)); } @@ -3832,30 +3880,30 @@ void clif_tradeitemok(struct map_session_data *sd, int index, int fail) /// who: /// 0 = self /// 1 = other player -void clif_tradedeal_lock(struct map_session_data *sd, int fail) +void clif_tradedeal_lock(struct map_session_data* sd, int fail) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xec)); - WFIFOW(fd,0) = 0xec; - WFIFOB(fd,2) = fail; - WFIFOSET(fd,packet_len(0xec)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xec)); + WFIFOW(fd,0) = 0xec; + WFIFOB(fd,2) = fail; + WFIFOSET(fd,packet_len(0xec)); } /// Notifies the client about the trade being canceled (ZC_CANCEL_EXCHANGE_ITEM). /// 00ee -void clif_tradecancelled(struct map_session_data *sd) +void clif_tradecancelled(struct map_session_data* sd) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xee)); - WFIFOW(fd,0) = 0xee; - WFIFOSET(fd,packet_len(0xee)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xee)); + WFIFOW(fd,0) = 0xee; + WFIFOSET(fd,packet_len(0xee)); } @@ -3864,16 +3912,16 @@ void clif_tradecancelled(struct map_session_data *sd) /// result: /// 0 = success /// 1 = failure -void clif_tradecompleted(struct map_session_data *sd, int fail) +void clif_tradecompleted(struct map_session_data* sd, int fail) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xf0)); - WFIFOW(fd,0) = 0xf0; - WFIFOB(fd,2) = fail; - WFIFOSET(fd,packet_len(0xf0)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xf0)); + WFIFOW(fd,0) = 0xf0; + WFIFOB(fd,2) = fail; + WFIFOSET(fd,packet_len(0xf0)); } @@ -3881,231 +3929,235 @@ void clif_tradecompleted(struct map_session_data *sd, int fail) /// 00f1 /// NOTE: Unknown purpose. Items are not removed until the window is /// refreshed (ex. by putting another item in there). -void clif_tradeundo(struct map_session_data *sd) +void clif_tradeundo(struct map_session_data* sd) { - int fd = sd->fd; + int fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xf1)); - WFIFOW(fd,0) = 0xf1; - WFIFOSET(fd,packet_len(0xf1)); + WFIFOHEAD(fd,packet_len(0xf1)); + WFIFOW(fd,0) = 0xf1; + WFIFOSET(fd,packet_len(0xf1)); } /// Updates storage total amount (ZC_NOTIFY_STOREITEM_COUNTINFO). /// 00f2 .W .W -void clif_updatestorageamount(struct map_session_data *sd, int amount, int max_amount) +void clif_updatestorageamount(struct map_session_data* sd, int amount, int max_amount) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xf2)); - WFIFOW(fd,0) = 0xf2; - WFIFOW(fd,2) = amount; - WFIFOW(fd,4) = max_amount; - WFIFOSET(fd,packet_len(0xf2)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xf2)); + WFIFOW(fd,0) = 0xf2; + WFIFOW(fd,2) = amount; + WFIFOW(fd,4) = max_amount; + WFIFOSET(fd,packet_len(0xf2)); } /// Notifies the client of an item being added to the storage. /// 00f4 .W .L .W .B .B .B .W .W .W .W (ZC_ADD_ITEM_TO_STORE) /// 01c4 .W .L .W .B .B .B .B .W .W .W .W (ZC_ADD_ITEM_TO_STORE2) -void clif_storageitemadded(struct map_session_data *sd, struct item *i, int index, int amount) +void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount) { - int view,fd; + int view,fd; - nullpo_retv(sd); - nullpo_retv(i); - fd=sd->fd; - view = itemdb_viewid(i->nameid); + nullpo_retv(sd); + nullpo_retv(i); + fd=sd->fd; + view = itemdb_viewid(i->nameid); #if PACKETVER < 5 - WFIFOHEAD(fd,packet_len(0xf4)); - WFIFOW(fd, 0) = 0xf4; // Storage item added - WFIFOW(fd, 2) = index+1; // index - WFIFOL(fd, 4) = amount; // amount - WFIFOW(fd, 8) = (view > 0) ? view : i->nameid; // id - WFIFOB(fd,10) = i->identify; //identify flag - WFIFOB(fd,11) = i->attribute; // attribute - WFIFOB(fd,12) = i->refine; //refine - clif_addcards(WFIFOP(fd,13), i); - WFIFOSET(fd,packet_len(0xf4)); + WFIFOHEAD(fd,packet_len(0xf4)); + WFIFOW(fd, 0) = 0xf4; // Storage item added + WFIFOW(fd, 2) = index+1; // index + WFIFOL(fd, 4) = amount; // amount + WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id + WFIFOB(fd,10) = i->identify; //identify flag + WFIFOB(fd,11) = i->attribute; // attribute + WFIFOB(fd,12) = i->refine; //refine + clif_addcards(WFIFOP(fd,13), i); + WFIFOSET(fd,packet_len(0xf4)); #else - WFIFOHEAD(fd,packet_len(0x1c4)); - WFIFOW(fd, 0) = 0x1c4; // Storage item added - WFIFOW(fd, 2) = index+1; // index - WFIFOL(fd, 4) = amount; // amount - WFIFOW(fd, 8) = (view > 0) ? view : i->nameid; // id - WFIFOB(fd,10) = itemdb_type(i->nameid); //type - WFIFOB(fd,11) = i->identify; //identify flag - WFIFOB(fd,12) = i->attribute; // attribute - WFIFOB(fd,13) = i->refine; //refine - clif_addcards(WFIFOP(fd,14), i); - WFIFOSET(fd,packet_len(0x1c4)); + WFIFOHEAD(fd,packet_len(0x1c4)); + WFIFOW(fd, 0) = 0x1c4; // Storage item added + WFIFOW(fd, 2) = index+1; // index + WFIFOL(fd, 4) = amount; // amount + WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id + WFIFOB(fd,10) = itemdb_type(i->nameid); //type + WFIFOB(fd,11) = i->identify; //identify flag + WFIFOB(fd,12) = i->attribute; // attribute + WFIFOB(fd,13) = i->refine; //refine + clif_addcards(WFIFOP(fd,14), i); + WFIFOSET(fd,packet_len(0x1c4)); #endif } /// Notifies the client of an item being deleted from the storage (ZC_DELETE_ITEM_FROM_STORE). /// 00f6 .W .L -void clif_storageitemremoved(struct map_session_data *sd, int index, int amount) +void clif_storageitemremoved(struct map_session_data* sd, int index, int amount) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xf6)); - WFIFOW(fd,0)=0xf6; // Storage item removed - WFIFOW(fd,2)=index+1; - WFIFOL(fd,4)=amount; - WFIFOSET(fd,packet_len(0xf6)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xf6)); + WFIFOW(fd,0)=0xf6; // Storage item removed + WFIFOW(fd,2)=index+1; + WFIFOL(fd,4)=amount; + WFIFOSET(fd,packet_len(0xf6)); } /// Closes storage (ZC_CLOSE_STORE). /// 00f8 -void clif_storageclose(struct map_session_data *sd) +void clif_storageclose(struct map_session_data* sd) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xf8)); - WFIFOW(fd,0) = 0xf8; // Storage Closed - WFIFOSET(fd,packet_len(0xf8)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xf8)); + WFIFOW(fd,0) = 0xf8; // Storage Closed + WFIFOSET(fd,packet_len(0xf8)); } /*========================================== * Server tells 'sd' player client the abouts of 'dstsd' player *------------------------------------------*/ -static void clif_getareachar_pc(struct map_session_data *sd,struct map_session_data *dstsd) -{ - struct block_list *d_bl; - int i; - - if (dstsd->chatID) { - struct chat_data *cd = NULL; - if ((cd = (struct chat_data *)map_id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) - clif_dispchat(cd,sd->fd); - } else if (dstsd->state.vending) - clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd); - else if (dstsd->state.buyingstore) - clif_buyingstore_entry_single(sd, dstsd); - - if (dstsd->spiritball > 0) - clif_spiritball_single(sd->fd, dstsd); - for (i = 1; i < 5; i++) { - if (dstsd->talisman[i] > 0) - clif_talisman_single(sd->fd, dstsd, i); - } - if (dstsd->sc.option&OPTION_MOUNTING) { - //New Mounts are not complaint to the original method, so we gotta tell this guy that I'm mounting. - clif_status_load_single(sd->fd,dstsd->bl.id,SI_ALL_RIDING,2,1,0,0); - } +static void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* dstsd) +{ + struct block_list *d_bl; + int i; + + if( dstsd->chatID ) { + struct chat_data *cd = NULL; + if( (cd = (struct chat_data*)map_id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) + clif_dispchat(cd,sd->fd); + } else if( dstsd->state.vending ) + clif_showvendingboard(&dstsd->bl,dstsd->message,sd->fd); + else if( dstsd->state.buyingstore ) + clif_buyingstore_entry_single(sd, dstsd); + + if(dstsd->spiritball > 0) + clif_spiritball_single(sd->fd, dstsd); + for(i = 1; i < 5; i++){ + if( dstsd->talisman[i] > 0 ) + clif_talisman_single(sd->fd, dstsd, i); + } + if( dstsd->sc.option&OPTION_MOUNTING ) { + //New Mounts are not complaint to the original method, so we gotta tell this guy that I'm mounting. + clif_status_load_single(sd->fd,dstsd->bl.id,SI_ALL_RIDING,2,1,0,0); + } #ifdef NEW_CARTS - if (dstsd->sc.data[SC_PUSH_CART]) - clif_status_load_single(sd->fd, dstsd->bl.id, SI_ON_PUSH_CART, 2, dstsd->sc.data[SC_PUSH_CART]->val1, 0, 0); + if( dstsd->sc.data[SC_PUSH_CART] ) + clif_status_load_single(sd->fd, dstsd->bl.id, SI_ON_PUSH_CART, 2, dstsd->sc.data[SC_PUSH_CART]->val1, 0, 0); #endif - if ((sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting. - (sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround - pc_has_permission(sd, PC_PERM_VIEW_HPMETER) - ) - clif_hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp); - - // display link (sd - dstsd) to sd - ARR_FIND(0, 5, i, sd->devotion[i] == dstsd->bl.id); - if (i < 5) clif_devotion(&sd->bl, sd); - // display links (dstsd - devotees) to sd - ARR_FIND(0, 5, i, dstsd->devotion[i] > 0); - if (i < 5) clif_devotion(&dstsd->bl, sd); - // display link (dstsd - crusader) to sd - if (dstsd->sc.data[SC_DEVOTION] && (d_bl = map_id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL) - clif_devotion(d_bl, sd); -} - -void clif_getareachar_unit(struct map_session_data *sd,struct block_list *bl) -{ - uint8 buf[128]; - struct unit_data *ud; - struct view_data *vd; - int len; - - vd = status_get_viewdata(bl); - if (!vd || vd->class_ == INVISIBLE_CLASS) - return; - - /** - * Hide NPC from maya purple card. - **/ - if (bl->type == BL_NPC && !((TBL_NPC *)bl)->chat_id && (((TBL_NPC *)bl)->sc.option&OPTION_INVISIBLE)) - return; - - ud = unit_bl2ud(bl); - len = (ud && ud->walktimer != INVALID_TIMER) ? clif_set_unit_walking(bl,ud,buf) : clif_set_unit_idle(bl,buf,false); - clif_send(buf,len,&sd->bl,SELF); - - if (vd->cloth_color) - clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF); - - switch (bl->type) { - case BL_PC: { - TBL_PC *tsd = (TBL_PC *)bl; - clif_getareachar_pc(sd, tsd); - if (tsd->state.size==SZ_BIG) // tiny/big players [Valaris] - clif_specialeffect_single(bl,423,sd->fd); - else if (tsd->state.size==SZ_MEDIUM) - clif_specialeffect_single(bl,421,sd->fd); - if (tsd->bg_id && map[tsd->bl.m].flag.battleground) - clif_sendbgemblem_single(sd->fd,tsd); - if (tsd->sc.data[SC_CAMOUFLAGE]) - clif_status_load(bl,SI_CAMOUFLAGE,1); - } - break; - case BL_MER: // Devotion Effects - if (((TBL_MER *)bl)->devotion_flag) - clif_devotion(bl, sd); - break; - case BL_NPC: { - TBL_NPC *nd = (TBL_NPC *)bl; - if (nd->chat_id) - clif_dispchat((struct chat_data *)map_id2bl(nd->chat_id),sd->fd); - if (nd->size == SZ_BIG) - clif_specialeffect_single(bl,423,sd->fd); - else if (nd->size == SZ_MEDIUM) - clif_specialeffect_single(bl,421,sd->fd); - } - break; - case BL_MOB: { - TBL_MOB *md = (TBL_MOB *)bl; - if (md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris] - clif_specialeffect_single(bl,423,sd->fd); - else if (md->special_state.size==SZ_MEDIUM) - clif_specialeffect_single(bl,421,sd->fd); + if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting. + (sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround + pc_has_permission(sd, PC_PERM_VIEW_HPMETER) + ) + clif_hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp); + + // display link (sd - dstsd) to sd + ARR_FIND( 0, 5, i, sd->devotion[i] == dstsd->bl.id ); + if( i < 5 ) clif_devotion(&sd->bl, sd); + // display links (dstsd - devotees) to sd + ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 ); + if( i < 5 ) clif_devotion(&dstsd->bl, sd); + // display link (dstsd - crusader) to sd + if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map_id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) + clif_devotion(d_bl, sd); +} + +void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) +{ + uint8 buf[128]; + struct unit_data *ud; + struct view_data *vd; + int len; + + vd = status_get_viewdata(bl); + if (!vd || vd->class_ == INVISIBLE_CLASS) + return; + + /** + * Hide NPC from maya purple card. + **/ + if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)) + return; + + ud = unit_bl2ud(bl); + len = ( ud && ud->walktimer != INVALID_TIMER ) ? clif_set_unit_walking(bl,ud,buf) : clif_set_unit_idle(bl,buf,false); + clif_send(buf,len,&sd->bl,SELF); + + if (vd->cloth_color) + clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF); + + switch (bl->type) + { + case BL_PC: + { + TBL_PC* tsd = (TBL_PC*)bl; + clif_getareachar_pc(sd, tsd); + if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris] + clif_specialeffect_single(bl,423,sd->fd); + else if(tsd->state.size==SZ_MEDIUM) + clif_specialeffect_single(bl,421,sd->fd); + if( tsd->bg_id && map[tsd->bl.m].flag.battleground ) + clif_sendbgemblem_single(sd->fd,tsd); + if( tsd->sc.data[SC_CAMOUFLAGE] ) + clif_status_load(bl,SI_CAMOUFLAGE,1); + } + break; + case BL_MER: // Devotion Effects + if( ((TBL_MER*)bl)->devotion_flag ) + clif_devotion(bl, sd); + break; + case BL_NPC: + { + TBL_NPC* nd = (TBL_NPC*)bl; + if( nd->chat_id ) + clif_dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd); + if( nd->size == SZ_BIG ) + clif_specialeffect_single(bl,423,sd->fd); + else if( nd->size == SZ_MEDIUM ) + clif_specialeffect_single(bl,421,sd->fd); + } + break; + case BL_MOB: + { + TBL_MOB* md = (TBL_MOB*)bl; + if(md->special_state.size==SZ_BIG) // tiny/big mobs [Valaris] + clif_specialeffect_single(bl,423,sd->fd); + else if(md->special_state.size==SZ_MEDIUM) + clif_specialeffect_single(bl,421,sd->fd); #if PACKETVER >= 20120404 - if (!(md->status.mode&MD_BOSS)) { - int i; - for (i = 0; i < DAMAGELOG_SIZE; i++) // must show hp bar to all char who already hit the mob. - if (md->dmglog[i].id == sd->status.char_id) - clif_monster_hp_bar(md, sd->fd); - } + if( !(md->status.mode&MD_BOSS) ){ + int i; + for(i = 0; i < DAMAGELOG_SIZE; i++)// must show hp bar to all char who already hit the mob. + if( md->dmglog[i].id == sd->status.char_id ) + clif_monster_hp_bar(md, sd->fd); + } #endif - } - break; - case BL_PET: - if (vd->head_bottom) - clif_pet_equip(sd, (TBL_PET *)bl); // needed to display pet equip properly - break; - } + } + break; + case BL_PET: + if (vd->head_bottom) + clif_pet_equip(sd, (TBL_PET*)bl); // needed to display pet equip properly + break; + } } //Modifies the type of damage according to status changes [Skotlex] //Aegis data specifies that: 4 endure against single hit sources, 9 against multi-hit. static inline int clif_calc_delay(int type, int div, int damage, int delay) { - return (delay == 0 && damage > 0) ? (div > 1 ? 9 : 4) : type; + return ( delay == 0 && damage > 0 ) ? ( div > 1 ? 9 : 4 ) : type; } /*========================================== @@ -4113,19 +4165,20 @@ static inline int clif_calc_delay(int type, int div, int damage, int delay) *------------------------------------------*/ static int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int damage, int div_) { - if (type == 4 || type == 9 || damage <=0) - return 0; + if (type == 4 || type == 9 || damage <=0) + return 0; - if (bl->type == BL_PC) { - if (battle_config.pc_walk_delay_rate != 100) - delay = delay*battle_config.pc_walk_delay_rate/100; - } else if (battle_config.walk_delay_rate != 100) - delay = delay*battle_config.walk_delay_rate/100; + if (bl->type == BL_PC) { + if (battle_config.pc_walk_delay_rate != 100) + delay = delay*battle_config.pc_walk_delay_rate/100; + } else + if (battle_config.walk_delay_rate != 100) + delay = delay*battle_config.walk_delay_rate/100; - if (div_ > 1) //Multi-hit skills mean higher delays. - delay += battle_config.multihit_delay*(div_-1); + if (div_ > 1) //Multi-hit skills mean higher delays. + delay += battle_config.multihit_delay*(div_-1); - return delay>0?delay:1; //Return 1 to specify there should be no noticeable delay, but you should stop walking. + return delay>0?delay:1; //Return 1 to specify there should be no noticeable delay, but you should stop walking. } @@ -4146,138 +4199,138 @@ static int clif_calc_walkdelay(struct block_list *bl,int delay, int type, int da /// 10 = critical hit /// 11 = lucky dodge /// 12 = (touch skill?) -int clif_damage(struct block_list *src, struct block_list *dst, unsigned int tick, int sdelay, int ddelay, int damage, int div, int type, int damage2) +int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tick, int sdelay, int ddelay, int damage, int div, int type, int damage2) { - unsigned char buf[33]; - struct status_change *sc; + unsigned char buf[33]; + struct status_change *sc; #if PACKETVER < 20071113 - const int cmd = 0x8a; + const int cmd = 0x8a; #else - const int cmd = 0x2e1; + const int cmd = 0x2e1; #endif - nullpo_ret(src); - nullpo_ret(dst); - - type = clif_calc_delay(type,div,damage+damage2,ddelay); - sc = status_get_sc(dst); - if (sc && sc->count) { - if (sc->data[SC_HALLUCINATION]) { - if (damage) damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; - if (damage2) damage2 = damage2*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; - } - } - - WBUFW(buf,0)=cmd; - WBUFL(buf,2)=src->id; - WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=tick; - WBUFL(buf,14)=sdelay; - WBUFL(buf,18)=ddelay; + nullpo_ret(src); + nullpo_ret(dst); + + type = clif_calc_delay(type,div,damage+damage2,ddelay); + sc = status_get_sc(dst); + if(sc && sc->count) { + if(sc->data[SC_HALLUCINATION]) { + if(damage) damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; + if(damage2) damage2 = damage2*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; + } + } + + WBUFW(buf,0)=cmd; + WBUFL(buf,2)=src->id; + WBUFL(buf,6)=dst->id; + WBUFL(buf,10)=tick; + WBUFL(buf,14)=sdelay; + WBUFL(buf,18)=ddelay; #if PACKETVER < 20071113 - if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { - WBUFW(buf,22)=damage?div:0; - WBUFW(buf,27)=damage2?div:0; - } else { - WBUFW(buf,22)=min(damage, INT16_MAX); - WBUFW(buf,27)=damage2; - } - WBUFW(buf,24)=div; - WBUFB(buf,26)=type; + if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { + WBUFW(buf,22)=damage?div:0; + WBUFW(buf,27)=damage2?div:0; + } else { + WBUFW(buf,22)=min(damage, INT16_MAX); + WBUFW(buf,27)=damage2; + } + WBUFW(buf,24)=div; + WBUFB(buf,26)=type; #else - if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { - WBUFL(buf,22)=damage?div:0; - WBUFL(buf,29)=damage2?div:0; - } else { - WBUFL(buf,22)=damage; - WBUFL(buf,29)=damage2; - } - WBUFW(buf,26)=div; - WBUFB(buf,28)=type; + if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { + WBUFL(buf,22)=damage?div:0; + WBUFL(buf,29)=damage2?div:0; + } else { + WBUFL(buf,22)=damage; + WBUFL(buf,29)=damage2; + } + WBUFW(buf,26)=div; + WBUFB(buf,28)=type; #endif - if (disguised(dst)) { - clif_send(buf,packet_len(cmd),dst,AREA_WOS); - WBUFL(buf,6) = -dst->id; - clif_send(buf,packet_len(cmd),dst,SELF); - } else - clif_send(buf,packet_len(cmd),dst,AREA); - - if (disguised(src)) { - WBUFL(buf,2) = -src->id; - if (disguised(dst)) - WBUFL(buf,6) = dst->id; + if(disguised(dst)) { + clif_send(buf,packet_len(cmd),dst,AREA_WOS); + WBUFL(buf,6) = -dst->id; + clif_send(buf,packet_len(cmd),dst,SELF); + } else + clif_send(buf,packet_len(cmd),dst,AREA); + + if(disguised(src)) { + WBUFL(buf,2) = -src->id; + if (disguised(dst)) + WBUFL(buf,6) = dst->id; #if PACKETVER < 20071113 - if (damage > 0) WBUFW(buf,22) = -1; - if (damage2 > 0) WBUFW(buf,27) = -1; + if(damage > 0) WBUFW(buf,22) = -1; + if(damage2 > 0) WBUFW(buf,27) = -1; #else - if (damage > 0) WBUFL(buf,22) = -1; - if (damage2 > 0) WBUFL(buf,29) = -1; + if(damage > 0) WBUFL(buf,22) = -1; + if(damage2 > 0) WBUFL(buf,29) = -1; #endif - clif_send(buf,packet_len(cmd),src,SELF); - } + clif_send(buf,packet_len(cmd),src,SELF); + } - if (src == dst) { - unit_setdir(src,unit_getdir(src)); - } - //Return adjusted can't walk delay for further processing. - return clif_calc_walkdelay(dst,ddelay,type,damage+damage2,div); + if(src == dst) { + unit_setdir(src,unit_getdir(src)); + } + //Return adjusted can't walk delay for further processing. + return clif_calc_walkdelay(dst,ddelay,type,damage+damage2,div); } /*========================================== * src picks up dst *------------------------------------------*/ -void clif_takeitem(struct block_list *src, struct block_list *dst) +void clif_takeitem(struct block_list* src, struct block_list* dst) { - //clif_damage(src,dst,0,0,0,0,0,1,0); - unsigned char buf[32]; + //clif_damage(src,dst,0,0,0,0,0,1,0); + unsigned char buf[32]; - nullpo_retv(src); - nullpo_retv(dst); + nullpo_retv(src); + nullpo_retv(dst); - WBUFW(buf, 0) = 0x8a; - WBUFL(buf, 2) = src->id; - WBUFL(buf, 6) = dst->id; - WBUFB(buf,26) = 1; - clif_send(buf, packet_len(0x8a), src, AREA); + WBUFW(buf, 0) = 0x8a; + WBUFL(buf, 2) = src->id; + WBUFL(buf, 6) = dst->id; + WBUFB(buf,26) = 1; + clif_send(buf, packet_len(0x8a), src, AREA); } /*========================================== * inform clients in area that `bl` is sitting *------------------------------------------*/ -void clif_sitting(struct block_list *bl) +void clif_sitting(struct block_list* bl) { - unsigned char buf[32]; - nullpo_retv(bl); + unsigned char buf[32]; + nullpo_retv(bl); - WBUFW(buf, 0) = 0x8a; - WBUFL(buf, 2) = bl->id; - WBUFB(buf,26) = 2; - clif_send(buf, packet_len(0x8a), bl, AREA); + WBUFW(buf, 0) = 0x8a; + WBUFL(buf, 2) = bl->id; + WBUFB(buf,26) = 2; + clif_send(buf, packet_len(0x8a), bl, AREA); - if (disguised(bl)) { - WBUFL(buf, 2) = - bl->id; - clif_send(buf, packet_len(0x8a), bl, SELF); - } + if(disguised(bl)) { + WBUFL(buf, 2) = - bl->id; + clif_send(buf, packet_len(0x8a), bl, SELF); + } } /*========================================== * inform clients in area that `bl` is standing *------------------------------------------*/ -void clif_standing(struct block_list *bl) +void clif_standing(struct block_list* bl) { - unsigned char buf[32]; - nullpo_retv(bl); + unsigned char buf[32]; + nullpo_retv(bl); - WBUFW(buf, 0) = 0x8a; - WBUFL(buf, 2) = bl->id; - WBUFB(buf,26) = 3; - clif_send(buf, packet_len(0x8a), bl, AREA); + WBUFW(buf, 0) = 0x8a; + WBUFL(buf, 2) = bl->id; + WBUFB(buf,26) = 3; + clif_send(buf, packet_len(0x8a), bl, AREA); - if (disguised(bl)) { - WBUFL(buf, 2) = - bl->id; - clif_send(buf, packet_len(0x8a), bl, SELF); - } + if(disguised(bl)) { + WBUFL(buf, 2) = - bl->id; + clif_send(buf, packet_len(0x8a), bl, SELF); + } } @@ -4285,50 +4338,53 @@ void clif_standing(struct block_list *bl) /// 0192 .W .W .W .16B void clif_changemapcell(int fd, int m, int x, int y, int type, enum send_target target) { - unsigned char buf[32]; - - WBUFW(buf,0) = 0x192; - WBUFW(buf,2) = x; - WBUFW(buf,4) = y; - WBUFW(buf,6) = type; - mapindex_getmapname_ext(map[m].name,(char *)WBUFP(buf,8)); - - if (fd) { - WFIFOHEAD(fd,packet_len(0x192)); - memcpy(WFIFOP(fd,0), buf, packet_len(0x192)); - WFIFOSET(fd,packet_len(0x192)); - } else { - struct block_list dummy_bl; - dummy_bl.type = BL_NUL; - dummy_bl.x = x; - dummy_bl.y = y; - dummy_bl.m = m; - clif_send(buf,packet_len(0x192),&dummy_bl,target); - } + unsigned char buf[32]; + + WBUFW(buf,0) = 0x192; + WBUFW(buf,2) = x; + WBUFW(buf,4) = y; + WBUFW(buf,6) = type; + mapindex_getmapname_ext(map[m].name,(char*)WBUFP(buf,8)); + + if( fd ) + { + WFIFOHEAD(fd,packet_len(0x192)); + memcpy(WFIFOP(fd,0), buf, packet_len(0x192)); + WFIFOSET(fd,packet_len(0x192)); + } + else + { + struct block_list dummy_bl; + dummy_bl.type = BL_NUL; + dummy_bl.x = x; + dummy_bl.y = y; + dummy_bl.m = m; + clif_send(buf,packet_len(0x192),&dummy_bl,target); + } } /// Notifies the client about an item on floor (ZC_ITEM_ENTRY). /// 009d .L .W .B .W .W .W .B .B -void clif_getareachar_item(struct map_session_data *sd,struct flooritem_data *fitem) +void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fitem) { - int view,fd; - fd=sd->fd; + int view,fd; + fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x9d)); - WFIFOW(fd,0)=0x9d; - WFIFOL(fd,2)=fitem->bl.id; - if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) - WFIFOW(fd,6)=view; - else - WFIFOW(fd,6)=fitem->item_data.nameid; - WFIFOB(fd,8)=fitem->item_data.identify; - WFIFOW(fd,9)=fitem->bl.x; - WFIFOW(fd,11)=fitem->bl.y; - WFIFOW(fd,13)=fitem->item_data.amount; - WFIFOB(fd,15)=fitem->subx; - WFIFOB(fd,16)=fitem->suby; - WFIFOSET(fd,packet_len(0x9d)); + WFIFOHEAD(fd,packet_len(0x9d)); + WFIFOW(fd,0)=0x9d; + WFIFOL(fd,2)=fitem->bl.id; + if((view = itemdb_viewid(fitem->item_data.nameid)) > 0) + WFIFOW(fd,6)=view; + else + WFIFOW(fd,6)=fitem->item_data.nameid; + WFIFOB(fd,8)=fitem->item_data.identify; + WFIFOW(fd,9)=fitem->bl.x; + WFIFOW(fd,11)=fitem->bl.y; + WFIFOW(fd,13)=fitem->item_data.amount; + WFIFOB(fd,15)=fitem->subx; + WFIFOB(fd,16)=fitem->suby; + WFIFOSET(fd,packet_len(0x9d)); } @@ -4337,44 +4393,44 @@ void clif_getareachar_item(struct map_session_data *sd,struct flooritem_data *fi /// 01c9 .L .L .W .W .B .B .B .80B (ZC_SKILL_ENTRY2) static void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *unit) { - int fd = sd->fd; + int fd = sd->fd; - if (unit->group->state.guildaura) - return; + if( unit->group->state.guildaura ) + return; #if PACKETVER >= 3 - if (unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris] - WFIFOHEAD(fd,packet_len(0x1c9)); - WFIFOW(fd, 0)=0x1c9; - WFIFOL(fd, 2)=unit->bl.id; - WFIFOL(fd, 6)=unit->group->src_id; - WFIFOW(fd,10)=unit->bl.x; - WFIFOW(fd,12)=unit->bl.y; - WFIFOB(fd,14)=unit->group->unit_id; - WFIFOB(fd,15)=1; - WFIFOB(fd,16)=1; - safestrncpy((char *)WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE); - WFIFOSET(fd,packet_len(0x1c9)); - return; - } + if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris] + WFIFOHEAD(fd,packet_len(0x1c9)); + WFIFOW(fd, 0)=0x1c9; + WFIFOL(fd, 2)=unit->bl.id; + WFIFOL(fd, 6)=unit->group->src_id; + WFIFOW(fd,10)=unit->bl.x; + WFIFOW(fd,12)=unit->bl.y; + WFIFOB(fd,14)=unit->group->unit_id; + WFIFOB(fd,15)=1; + WFIFOB(fd,16)=1; + safestrncpy((char*)WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE); + WFIFOSET(fd,packet_len(0x1c9)); + return; + } #endif - WFIFOHEAD(fd,packet_len(0x11f)); - WFIFOW(fd, 0)=0x11f; - WFIFOL(fd, 2)=unit->bl.id; - WFIFOL(fd, 6)=unit->group->src_id; - WFIFOW(fd,10)=unit->bl.x; - WFIFOW(fd,12)=unit->bl.y; - if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP) - WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps. + WFIFOHEAD(fd,packet_len(0x11f)); + WFIFOW(fd, 0)=0x11f; + WFIFOL(fd, 2)=unit->bl.id; + WFIFOL(fd, 6)=unit->group->src_id; + WFIFOW(fd,10)=unit->bl.x; + WFIFOW(fd,12)=unit->bl.y; + if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP) + WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps. else if (skill_get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT)) - WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps. - else - WFIFOB(fd,14)=unit->group->unit_id; - WFIFOB(fd,15)=1; // ignored by client (always gets set to 1) - WFIFOSET(fd,packet_len(0x11f)); + WFIFOB(fd,14)=UNT_DUMMYSKILL; //Use invisible unit id for traps. + else + WFIFOB(fd,14)=unit->group->unit_id; + WFIFOB(fd,15)=1; // ignored by client (always gets set to 1) + WFIFOSET(fd,packet_len(0x11f)); - if (unit->group->skill_id == WZ_ICEWALL) - clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5,SELF); + if(unit->group->skill_id == WZ_ICEWALL) + clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5,SELF); } @@ -4383,15 +4439,15 @@ static void clif_getareachar_skillunit(struct map_session_data *sd, struct skill *------------------------------------------*/ static void clif_clearchar_skillunit(struct skill_unit *unit, int fd) { - nullpo_retv(unit); + nullpo_retv(unit); - WFIFOHEAD(fd,packet_len(0x120)); - WFIFOW(fd, 0)=0x120; - WFIFOL(fd, 2)=unit->bl.id; - WFIFOSET(fd,packet_len(0x120)); + WFIFOHEAD(fd,packet_len(0x120)); + WFIFOW(fd, 0)=0x120; + WFIFOL(fd, 2)=unit->bl.id; + WFIFOSET(fd,packet_len(0x120)); - if (unit->group && unit->group->skill_id == WZ_ICEWALL) - clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,SELF); + if(unit->group && unit->group->skill_id == WZ_ICEWALL) + clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2,SELF); } @@ -4399,59 +4455,59 @@ static void clif_clearchar_skillunit(struct skill_unit *unit, int fd) /// 0120 .L void clif_skill_delunit(struct skill_unit *unit) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(unit); + nullpo_retv(unit); - WBUFW(buf, 0)=0x120; - WBUFL(buf, 2)=unit->bl.id; - clif_send(buf,packet_len(0x120),&unit->bl,AREA); + WBUFW(buf, 0)=0x120; + WBUFL(buf, 2)=unit->bl.id; + clif_send(buf,packet_len(0x120),&unit->bl,AREA); } /// Sent when an object gets ankle-snared (ZC_SKILL_UPDATE). /// 01ac .L /// Only affects units with class [139,153] client-side. -void clif_skillunit_update(struct block_list *bl) +void clif_skillunit_update(struct block_list* bl) { - unsigned char buf[6]; - nullpo_retv(bl); + unsigned char buf[6]; + nullpo_retv(bl); - WBUFW(buf,0) = 0x1ac; - WBUFL(buf,2) = bl->id; + WBUFW(buf,0) = 0x1ac; + WBUFL(buf,2) = bl->id; - clif_send(buf,packet_len(0x1ac),bl,AREA); + clif_send(buf,packet_len(0x1ac),bl,AREA); } /*========================================== * *------------------------------------------*/ -static int clif_getareachar(struct block_list *bl,va_list ap) +static int clif_getareachar(struct block_list* bl,va_list ap) { - struct map_session_data *sd; + struct map_session_data *sd; - nullpo_ret(bl); + nullpo_ret(bl); - sd=va_arg(ap,struct map_session_data *); + sd=va_arg(ap,struct map_session_data*); - if (sd == NULL || !sd->fd) - return 0; + if (sd == NULL || !sd->fd) + return 0; - switch (bl->type) { - case BL_ITEM: - clif_getareachar_item(sd,(struct flooritem_data *) bl); - break; - case BL_SKILL: - clif_getareachar_skillunit(sd,(TBL_SKILL *)bl); - break; - default: - if (&sd->bl == bl) - break; - clif_getareachar_unit(sd,bl); - break; - } - return 0; + switch(bl->type){ + case BL_ITEM: + clif_getareachar_item(sd,(struct flooritem_data*) bl); + break; + case BL_SKILL: + clif_getareachar_skillunit(sd,(TBL_SKILL*)bl); + break; + default: + if(&sd->bl == bl) + break; + clif_getareachar_unit(sd,bl); + break; + } + return 0; } /*========================================== @@ -4459,54 +4515,54 @@ static int clif_getareachar(struct block_list *bl,va_list ap) *------------------------------------------*/ int clif_outsight(struct block_list *bl,va_list ap) { - struct block_list *tbl; - struct view_data *vd; - TBL_PC *sd, *tsd; - tbl=va_arg(ap,struct block_list *); - if (bl == tbl) return 0; - sd = BL_CAST(BL_PC, bl); - tsd = BL_CAST(BL_PC, tbl); - - if (tsd && tsd->fd) { - //tsd has lost sight of the bl object. - switch (bl->type) { - case BL_PC: - if (sd->vd.class_ != INVISIBLE_CLASS) - clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); - if (sd->chatID) { - struct chat_data *cd; - cd=(struct chat_data *)map_id2bl(sd->chatID); - if (cd->usersd[0]==sd) - clif_dispchat(cd,tsd->fd); - } - if (sd->state.vending) - clif_closevendingboard(bl,tsd->fd); - if (sd->state.buyingstore) - clif_buyingstore_disappear_entry_single(tsd, sd); - break; - case BL_ITEM: - clif_clearflooritem((struct flooritem_data *)bl,tsd->fd); - break; - case BL_SKILL: - clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd); - break; - case BL_NPC: - if (!(((TBL_NPC *)bl)->sc.option&OPTION_INVISIBLE)) - clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); - break; - default: - if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS) - clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); - break; - } - } - if (sd && sd->fd) { - //sd is watching tbl go out of view. - if (((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) && - !(tbl->type == BL_NPC && (((TBL_NPC *)tbl)->sc.option&OPTION_INVISIBLE))) - clif_clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd); - } - return 0; + struct block_list *tbl; + struct view_data *vd; + TBL_PC *sd, *tsd; + tbl=va_arg(ap,struct block_list*); + if(bl == tbl) return 0; + sd = BL_CAST(BL_PC, bl); + tsd = BL_CAST(BL_PC, tbl); + + if (tsd && tsd->fd) + { //tsd has lost sight of the bl object. + switch(bl->type){ + case BL_PC: + if (sd->vd.class_ != INVISIBLE_CLASS) + clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); + if(sd->chatID){ + struct chat_data *cd; + cd=(struct chat_data*)map_id2bl(sd->chatID); + if(cd->usersd[0]==sd) + clif_dispchat(cd,tsd->fd); + } + if( sd->state.vending ) + clif_closevendingboard(bl,tsd->fd); + if( sd->state.buyingstore ) + clif_buyingstore_disappear_entry_single(tsd, sd); + break; + case BL_ITEM: + clif_clearflooritem((struct flooritem_data*)bl,tsd->fd); + break; + case BL_SKILL: + clif_clearchar_skillunit((struct skill_unit *)bl,tsd->fd); + break; + case BL_NPC: + if( !(((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE) ) + clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); + break; + default: + if ((vd=status_get_viewdata(bl)) && vd->class_ != INVISIBLE_CLASS) + clif_clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); + break; + } + } + if (sd && sd->fd) + { //sd is watching tbl go out of view. + if (((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) && + !(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->sc.option&OPTION_INVISIBLE))) + clif_clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd); + } + return 0; } /*========================================== @@ -4514,34 +4570,34 @@ int clif_outsight(struct block_list *bl,va_list ap) *------------------------------------------*/ int clif_insight(struct block_list *bl,va_list ap) { - struct block_list *tbl; - TBL_PC *sd, *tsd; - tbl=va_arg(ap,struct block_list *); - - if (bl == tbl) return 0; - - sd = BL_CAST(BL_PC, bl); - tsd = BL_CAST(BL_PC, tbl); - - if (tsd && tsd->fd) { - //Tell tsd that bl entered into his view - switch (bl->type) { - case BL_ITEM: - clif_getareachar_item(tsd,(struct flooritem_data *)bl); - break; - case BL_SKILL: - clif_getareachar_skillunit(tsd,(TBL_SKILL *)bl); - break; - default: - clif_getareachar_unit(tsd,bl); - break; - } - } - if (sd && sd->fd) { - //Tell sd that tbl walked into his view - clif_getareachar_unit(sd,tbl); - } - return 0; + struct block_list *tbl; + TBL_PC *sd, *tsd; + tbl=va_arg(ap,struct block_list*); + + if (bl == tbl) return 0; + + sd = BL_CAST(BL_PC, bl); + tsd = BL_CAST(BL_PC, tbl); + + if (tsd && tsd->fd) + { //Tell tsd that bl entered into his view + switch(bl->type){ + case BL_ITEM: + clif_getareachar_item(tsd,(struct flooritem_data*)bl); + break; + case BL_SKILL: + clif_getareachar_skillunit(tsd,(TBL_SKILL*)bl); + break; + default: + clif_getareachar_unit(tsd,bl); + break; + } + } + if (sd && sd->fd) + { //Tell sd that tbl walked into his view + clif_getareachar_unit(sd,tbl); + } + return 0; } @@ -4549,45 +4605,49 @@ int clif_insight(struct block_list *bl,va_list ap) /// 010f .W { .W .L .W .W .W .24B .B }* void clif_skillinfoblock(struct map_session_data *sd) { - int fd; - int i,len,id; - - nullpo_retv(sd); - - fd=sd->fd; - if (!fd) return; - - WFIFOHEAD(fd, MAX_SKILL * 37 + 4); - WFIFOW(fd,0) = 0x10f; - for (i = 0, len = 4; i < MAX_SKILL; i++) { - if ((id = sd->status.skill[i].id) != 0) { - // workaround for bugreport:5348 - if (len + 37 > 8192) - break; - - WFIFOW(fd,len) = id; - WFIFOL(fd,len+2) = skill_get_inf(id); - WFIFOW(fd,len+6) = sd->status.skill[i].lv; - WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv); - WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv); - safestrncpy((char *)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH); - if (sd->status.skill[i].flag == SKILL_FLAG_PERMANENT) - WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_))? 1:0; - else - WFIFOB(fd,len+36) = 0; - len += 37; - } - } - WFIFOW(fd,2)=len; - WFIFOSET(fd,len); - - // workaround for bugreport:5348; send the remaining skills one by one to bypass packet size limit - for (; i < MAX_SKILL; i++) { - if ((id = sd->status.skill[i].id) != 0) { - clif_addskill(sd, id); - clif_skillinfo(sd, id, 0); - } - } + int fd; + int i,len,id; + + nullpo_retv(sd); + + fd=sd->fd; + if (!fd) return; + + WFIFOHEAD(fd, MAX_SKILL * 37 + 4); + WFIFOW(fd,0) = 0x10f; + for ( i = 0, len = 4; i < MAX_SKILL; i++) + { + if( (id = sd->status.skill[i].id) != 0 ) + { + // workaround for bugreport:5348 + if (len + 37 > 8192) + break; + + WFIFOW(fd,len) = id; + WFIFOL(fd,len+2) = skill_get_inf(id); + WFIFOW(fd,len+6) = sd->status.skill[i].lv; + WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv); + WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv); + safestrncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH); + if(sd->status.skill[i].flag == SKILL_FLAG_PERMANENT) + WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_))? 1:0; + else + WFIFOB(fd,len+36) = 0; + len += 37; + } + } + WFIFOW(fd,2)=len; + WFIFOSET(fd,len); + + // workaround for bugreport:5348; send the remaining skills one by one to bypass packet size limit + for ( ; i < MAX_SKILL; i++) + { + if( (id = sd->status.skill[i].id) != 0 ) + { + clif_addskill(sd, id); + clif_skillinfo(sd, id, 0); + } + } } /** * Server tells client 'sd' to add skill of id 'id' to it's skill tree (e.g. with Ice Falcion item) @@ -4597,29 +4657,29 @@ void clif_skillinfoblock(struct map_session_data *sd) /// 0111 .W .L .W .W .W .24B .B void clif_addskill(struct map_session_data *sd, int id) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - if (!fd) return; - - if (sd->status.skill[id].id <= 0) - return; - - WFIFOHEAD(fd, packet_len(0x111)); - WFIFOW(fd,0) = 0x111; - WFIFOW(fd,2) = id; - WFIFOL(fd,4) = skill_get_inf(id); - WFIFOW(fd,8) = sd->status.skill[id].lv; - WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[id].lv); - WFIFOW(fd,12)= skill_get_range2(&sd->bl, id,sd->status.skill[id].lv); - safestrncpy((char *)WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH); - if (sd->status.skill[id].flag == SKILL_FLAG_PERMANENT) - WFIFOB(fd,38) = (sd->status.skill[id].lv < skill_tree_get_max(id, sd->status.class_))? 1:0; - else - WFIFOB(fd,38) = 0; - WFIFOSET(fd,packet_len(0x111)); + fd = sd->fd; + if (!fd) return; + + if( sd->status.skill[id].id <= 0 ) + return; + + WFIFOHEAD(fd, packet_len(0x111)); + WFIFOW(fd,0) = 0x111; + WFIFOW(fd,2) = id; + WFIFOL(fd,4) = skill_get_inf(id); + WFIFOW(fd,8) = sd->status.skill[id].lv; + WFIFOW(fd,10) = skill_get_sp(id,sd->status.skill[id].lv); + WFIFOW(fd,12)= skill_get_range2(&sd->bl, id,sd->status.skill[id].lv); + safestrncpy((char*)WFIFOP(fd,14), skill_get_name(id), NAME_LENGTH); + if( sd->status.skill[id].flag == SKILL_FLAG_PERMANENT ) + WFIFOB(fd,38) = (sd->status.skill[id].lv < skill_tree_get_max(id, sd->status.class_))? 1:0; + else + WFIFOB(fd,38) = 0; + WFIFOSET(fd,packet_len(0x111)); } @@ -4628,18 +4688,18 @@ void clif_addskill(struct map_session_data *sd, int id) void clif_deleteskill(struct map_session_data *sd, int id) { #if PACKETVER >= 20081217 - int fd; + int fd; - nullpo_retv(sd); - fd = sd->fd; - if (!fd) return; + nullpo_retv(sd); + fd = sd->fd; + if( !fd ) return; - WFIFOHEAD(fd,packet_len(0x441)); - WFIFOW(fd,0) = 0x441; - WFIFOW(fd,2) = id; - WFIFOSET(fd,packet_len(0x441)); + WFIFOHEAD(fd,packet_len(0x441)); + WFIFOW(fd,0) = 0x441; + WFIFOW(fd,2) = id; + WFIFOSET(fd,packet_len(0x441)); #else - clif_skillinfoblock(sd); + clif_skillinfoblock(sd); #endif } @@ -4648,19 +4708,19 @@ void clif_deleteskill(struct map_session_data *sd, int id) /// 010e .W .W .W .W .B void clif_skillup(struct map_session_data *sd,int skill_num) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x10e)); - WFIFOW(fd,0) = 0x10e; - WFIFOW(fd,2) = skill_num; - WFIFOW(fd,4) = sd->status.skill[skill_num].lv; - WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv); - WFIFOW(fd,8) = skill_get_range2(&sd->bl,skill_num,sd->status.skill[skill_num].lv); - WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0; - WFIFOSET(fd,packet_len(0x10e)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x10e)); + WFIFOW(fd,0) = 0x10e; + WFIFOW(fd,2) = skill_num; + WFIFOW(fd,4) = sd->status.skill[skill_num].lv; + WFIFOW(fd,6) = skill_get_sp(skill_num,sd->status.skill[skill_num].lv); + WFIFOW(fd,8) = skill_get_range2(&sd->bl,skill_num,sd->status.skill[skill_num].lv); + WFIFOB(fd,10) = (sd->status.skill[skill_num].lv < skill_tree_get_max(sd->status.skill[skill_num].id, sd->status.class_)) ? 1 : 0; + WFIFOSET(fd,packet_len(0x10e)); } @@ -4668,20 +4728,20 @@ void clif_skillup(struct map_session_data *sd,int skill_num) /// 07e1 .W .L .W .W .W .B void clif_skillinfo(struct map_session_data *sd,int skill, int inf) { - const int fd = sd->fd; - - WFIFOHEAD(fd,packet_len(0x7e1)); - WFIFOW(fd,0) = 0x7e1; - WFIFOW(fd,2) = skill; - WFIFOL(fd,4) = inf?inf:skill_get_inf(skill); - WFIFOW(fd,8) = sd->status.skill[skill].lv; - WFIFOW(fd,10) = skill_get_sp(skill,sd->status.skill[skill].lv); - WFIFOW(fd,12) = skill_get_range2(&sd->bl,skill,sd->status.skill[skill].lv); - if (sd->status.skill[skill].flag == SKILL_FLAG_PERMANENT) - WFIFOB(fd,14) = (sd->status.skill[skill].lv < skill_tree_get_max(skill, sd->status.class_))? 1:0; - else - WFIFOB(fd,14) = 0; - WFIFOSET(fd,packet_len(0x7e1)); + const int fd = sd->fd; + + WFIFOHEAD(fd,packet_len(0x7e1)); + WFIFOW(fd,0) = 0x7e1; + WFIFOW(fd,2) = skill; + WFIFOL(fd,4) = inf?inf:skill_get_inf(skill); + WFIFOW(fd,8) = sd->status.skill[skill].lv; + WFIFOW(fd,10) = skill_get_sp(skill,sd->status.skill[skill].lv); + WFIFOW(fd,12) = skill_get_range2(&sd->bl,skill,sd->status.skill[skill].lv); + if( sd->status.skill[skill].flag == SKILL_FLAG_PERMANENT ) + WFIFOB(fd,14) = (sd->status.skill[skill].lv < skill_tree_get_max(skill, sd->status.class_))? 1:0; + else + WFIFOB(fd,14) = 0; + WFIFOSET(fd,packet_len(0x7e1)); } @@ -4700,47 +4760,47 @@ void clif_skillinfo(struct map_session_data *sd,int skill, int inf) /// is disposable: /// 0 = yellow chat text "[src name] will use skill [skill name]." /// 1 = no text -void clif_skillcasting(struct block_list *bl, int src_id, int dst_id, int dst_x, int dst_y, int skill_num, int property, int casttime) +void clif_skillcasting(struct block_list* bl, int src_id, int dst_id, int dst_x, int dst_y, int skill_num, int property, int casttime) { #if PACKETVER < 20091124 - const int cmd = 0x13e; + const int cmd = 0x13e; #else - const int cmd = 0x7fb; + const int cmd = 0x7fb; #endif - unsigned char buf[32]; - - WBUFW(buf,0) = cmd; - WBUFL(buf,2) = src_id; - WBUFL(buf,6) = dst_id; - WBUFW(buf,10) = dst_x; - WBUFW(buf,12) = dst_y; - WBUFW(buf,14) = skill_num; - WBUFL(buf,16) = property<0?0:property; //Avoid sending negatives as element [Skotlex] - WBUFL(buf,20) = casttime; + unsigned char buf[32]; + + WBUFW(buf,0) = cmd; + WBUFL(buf,2) = src_id; + WBUFL(buf,6) = dst_id; + WBUFW(buf,10) = dst_x; + WBUFW(buf,12) = dst_y; + WBUFW(buf,14) = skill_num; + WBUFL(buf,16) = property<0?0:property; //Avoid sending negatives as element [Skotlex] + WBUFL(buf,20) = casttime; #if PACKETVER >= 20091124 - WBUFB(buf,24) = 0; // isDisposable + WBUFB(buf,24) = 0; // isDisposable #endif - if (disguised(bl)) { - clif_send(buf,packet_len(cmd), bl, AREA_WOS); - WBUFL(buf,2) = -src_id; - clif_send(buf,packet_len(cmd), bl, SELF); - } else - clif_send(buf,packet_len(cmd), bl, AREA); + if (disguised(bl)) { + clif_send(buf,packet_len(cmd), bl, AREA_WOS); + WBUFL(buf,2) = -src_id; + clif_send(buf,packet_len(cmd), bl, SELF); + } else + clif_send(buf,packet_len(cmd), bl, AREA); } /// Notifies clients in area, that an object canceled casting (ZC_DISPEL). /// 01b9 .L -void clif_skillcastcancel(struct block_list *bl) +void clif_skillcastcancel(struct block_list* bl) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x1b9; - WBUFL(buf,2) = bl->id; - clif_send(buf,packet_len(0x1b9), bl, AREA); + WBUFW(buf,0) = 0x1b9; + WBUFL(buf,2) = bl->id; + clif_send(buf,packet_len(0x1b9), bl, AREA); } @@ -4769,35 +4829,35 @@ void clif_skillcastcancel(struct block_list *bl) /// suggesting this is an ACK packet for the UseSkill packets and should be sent on success too [FlavioJS] void clif_skill_fail(struct map_session_data *sd,int skill_id,enum useskill_fail_cause cause,int btype) { - int fd; + int fd; - if (!sd) { //Since this is the most common nullpo.... - ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id); - return; - } + if (!sd) { //Since this is the most common nullpo.... + ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id); + return; + } - fd=sd->fd; - if (!fd) return; + fd=sd->fd; + if (!fd) return; - if (battle_config.display_skill_fail&1) - return; //Disable all skill failed messages + if(battle_config.display_skill_fail&1) + return; //Disable all skill failed messages - if (cause==USESKILL_FAIL_SKILLINTERVAL && !sd->state.showdelay) - return; //Disable delay failed messages + if(cause==USESKILL_FAIL_SKILLINTERVAL && !sd->state.showdelay) + return; //Disable delay failed messages - if (skill_id == RG_SNATCHER && battle_config.display_skill_fail&4) - return; + if(skill_id == RG_SNATCHER && battle_config.display_skill_fail&4) + return; - if (skill_id == TF_POISON && battle_config.display_skill_fail&8) - return; + if(skill_id == TF_POISON && battle_config.display_skill_fail&8) + return; - WFIFOHEAD(fd,packet_len(0x110)); - WFIFOW(fd,0) = 0x110; - WFIFOW(fd,2) = skill_id; - WFIFOL(fd,4) = btype; - WFIFOB(fd,8) = 0;// success - WFIFOB(fd,9) = cause; - WFIFOSET(fd,packet_len(0x110)); + WFIFOHEAD(fd,packet_len(0x110)); + WFIFOW(fd,0) = 0x110; + WFIFOW(fd,2) = skill_id; + WFIFOL(fd,4) = btype; + WFIFOB(fd,8) = 0;// success + WFIFOB(fd,9) = cause; + WFIFOSET(fd,packet_len(0x110)); } @@ -4806,16 +4866,16 @@ void clif_skill_fail(struct map_session_data *sd,int skill_id,enum useskill_fail void clif_skill_cooldown(struct map_session_data *sd, int skillid, unsigned int tick) { #if PACKETVER>=20081112 - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x43d)); - WFIFOW(fd,0) = 0x43d; - WFIFOW(fd,2) = skillid; - WFIFOL(fd,4) = tick; - WFIFOSET(fd,packet_len(0x43d)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x43d)); + WFIFOW(fd,0) = 0x43d; + WFIFOW(fd,2) = skillid; + WFIFOL(fd,4) = tick; + WFIFOSET(fd,packet_len(0x43d)); #endif } @@ -4825,85 +4885,85 @@ void clif_skill_cooldown(struct map_session_data *sd, int skillid, unsigned int /// 01de .W .L .L .L .L .L .L .W
.W .B (ZC_NOTIFY_SKILL2) int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type) { - unsigned char buf[64]; - struct status_change *sc; + unsigned char buf[64]; + struct status_change *sc; - nullpo_ret(src); - nullpo_ret(dst); + nullpo_ret(src); + nullpo_ret(dst); - type = clif_calc_delay(type,div,damage,ddelay); - sc = status_get_sc(dst); - if (sc && sc->count) { - if (sc->data[SC_HALLUCINATION] && damage) - damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; - } + type = clif_calc_delay(type,div,damage,ddelay); + sc = status_get_sc(dst); + if(sc && sc->count) { + if(sc->data[SC_HALLUCINATION] && damage) + damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; + } #if PACKETVER < 3 - WBUFW(buf,0)=0x114; - WBUFW(buf,2)=skill_id; - WBUFL(buf,4)=src->id; - WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; - WBUFL(buf,16)=sdelay; - WBUFL(buf,20)=ddelay; - if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { - WBUFW(buf,24)=damage?div:0; - } else { - WBUFW(buf,24)=damage; - } - WBUFW(buf,26)=skill_lv; - WBUFW(buf,28)=div; - WBUFB(buf,30)=type; - if (disguised(dst)) { - clif_send(buf,packet_len(0x114),dst,AREA_WOS); - WBUFL(buf,8)=-dst->id; - clif_send(buf,packet_len(0x114),dst,SELF); - } else - clif_send(buf,packet_len(0x114),dst,AREA); - - if (disguised(src)) { - WBUFL(buf,4)=-src->id; - if (disguised(dst)) - WBUFL(buf,8)=dst->id; - if (damage > 0) - WBUFW(buf,24)=-1; - clif_send(buf,packet_len(0x114),src,SELF); - } + WBUFW(buf,0)=0x114; + WBUFW(buf,2)=skill_id; + WBUFL(buf,4)=src->id; + WBUFL(buf,8)=dst->id; + WBUFL(buf,12)=tick; + WBUFL(buf,16)=sdelay; + WBUFL(buf,20)=ddelay; + if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { + WBUFW(buf,24)=damage?div:0; + } else { + WBUFW(buf,24)=damage; + } + WBUFW(buf,26)=skill_lv; + WBUFW(buf,28)=div; + WBUFB(buf,30)=type; + if (disguised(dst)) { + clif_send(buf,packet_len(0x114),dst,AREA_WOS); + WBUFL(buf,8)=-dst->id; + clif_send(buf,packet_len(0x114),dst,SELF); + } else + clif_send(buf,packet_len(0x114),dst,AREA); + + if(disguised(src)) { + WBUFL(buf,4)=-src->id; + if (disguised(dst)) + WBUFL(buf,8)=dst->id; + if(damage > 0) + WBUFW(buf,24)=-1; + clif_send(buf,packet_len(0x114),src,SELF); + } #else - WBUFW(buf,0)=0x1de; - WBUFW(buf,2)=skill_id; - WBUFL(buf,4)=src->id; - WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; - WBUFL(buf,16)=sdelay; - WBUFL(buf,20)=ddelay; - if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { - WBUFL(buf,24)=damage?div:0; - } else { - WBUFL(buf,24)=damage; - } - WBUFW(buf,28)=skill_lv; - WBUFW(buf,30)=div; - WBUFB(buf,32)=type; - if (disguised(dst)) { - clif_send(buf,packet_len(0x1de),dst,AREA_WOS); - WBUFL(buf,8)=-dst->id; - clif_send(buf,packet_len(0x1de),dst,SELF); - } else - clif_send(buf,packet_len(0x1de),dst,AREA); - - if (disguised(src)) { - WBUFL(buf,4)=-src->id; - if (disguised(dst)) - WBUFL(buf,8)=dst->id; - if (damage > 0) - WBUFL(buf,24)=-1; - clif_send(buf,packet_len(0x1de),src,SELF); - } + WBUFW(buf,0)=0x1de; + WBUFW(buf,2)=skill_id; + WBUFL(buf,4)=src->id; + WBUFL(buf,8)=dst->id; + WBUFL(buf,12)=tick; + WBUFL(buf,16)=sdelay; + WBUFL(buf,20)=ddelay; + if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { + WBUFL(buf,24)=damage?div:0; + } else { + WBUFL(buf,24)=damage; + } + WBUFW(buf,28)=skill_lv; + WBUFW(buf,30)=div; + WBUFB(buf,32)=type; + if (disguised(dst)) { + clif_send(buf,packet_len(0x1de),dst,AREA_WOS); + WBUFL(buf,8)=-dst->id; + clif_send(buf,packet_len(0x1de),dst,SELF); + } else + clif_send(buf,packet_len(0x1de),dst,AREA); + + if(disguised(src)) { + WBUFL(buf,4)=-src->id; + if (disguised(dst)) + WBUFL(buf,8)=dst->id; + if(damage > 0) + WBUFL(buf,24)=-1; + clif_send(buf,packet_len(0x1de),src,SELF); + } #endif - //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex] - return clif_calc_walkdelay(dst,ddelay,type,damage,div); + //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex] + return clif_calc_walkdelay(dst,ddelay,type,damage,div); } @@ -4912,56 +4972,56 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,unsigned int /* int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned int tick,int sdelay,int ddelay,int damage,int div,int skill_id,int skill_lv,int type) { - unsigned char buf[64]; - struct status_change *sc; - - nullpo_ret(src); - nullpo_ret(dst); - - type = (type>0)?type:skill_get_hit(skill_id); - type = clif_calc_delay(type,div,damage,ddelay); - sc = status_get_sc(dst); - - if(sc && sc->count) { - if(sc->data[SC_HALLUCINATION] && damage) - damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; - } - - WBUFW(buf,0)=0x115; - WBUFW(buf,2)=skill_id; - WBUFL(buf,4)=src->id; - WBUFL(buf,8)=dst->id; - WBUFL(buf,12)=tick; - WBUFL(buf,16)=sdelay; - WBUFL(buf,20)=ddelay; - WBUFW(buf,24)=dst->x; - WBUFW(buf,26)=dst->y; - if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { - WBUFW(buf,28)=damage?div:0; - } else { - WBUFW(buf,28)=damage; - } - WBUFW(buf,30)=skill_lv; - WBUFW(buf,32)=div; - WBUFB(buf,34)=type; - clif_send(buf,packet_len(0x115),src,AREA); - if(disguised(src)) { - WBUFL(buf,4)=-src->id; - if(damage > 0) - WBUFW(buf,28)=-1; - clif_send(buf,packet_len(0x115),src,SELF); - } - if (disguised(dst)) { - WBUFL(buf,8)=-dst->id; - if (disguised(src)) - WBUFL(buf,4)=src->id; - else if(damage > 0) - WBUFW(buf,28)=-1; - clif_send(buf,packet_len(0x115),dst,SELF); - } - - //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex] - return clif_calc_walkdelay(dst,ddelay,type,damage,div); + unsigned char buf[64]; + struct status_change *sc; + + nullpo_ret(src); + nullpo_ret(dst); + + type = (type>0)?type:skill_get_hit(skill_id); + type = clif_calc_delay(type,div,damage,ddelay); + sc = status_get_sc(dst); + + if(sc && sc->count) { + if(sc->data[SC_HALLUCINATION] && damage) + damage = damage*(sc->data[SC_HALLUCINATION]->val2) + rnd()%100; + } + + WBUFW(buf,0)=0x115; + WBUFW(buf,2)=skill_id; + WBUFL(buf,4)=src->id; + WBUFL(buf,8)=dst->id; + WBUFL(buf,12)=tick; + WBUFL(buf,16)=sdelay; + WBUFL(buf,20)=ddelay; + WBUFW(buf,24)=dst->x; + WBUFW(buf,26)=dst->y; + if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) { + WBUFW(buf,28)=damage?div:0; + } else { + WBUFW(buf,28)=damage; + } + WBUFW(buf,30)=skill_lv; + WBUFW(buf,32)=div; + WBUFB(buf,34)=type; + clif_send(buf,packet_len(0x115),src,AREA); + if(disguised(src)) { + WBUFL(buf,4)=-src->id; + if(damage > 0) + WBUFW(buf,28)=-1; + clif_send(buf,packet_len(0x115),src,SELF); + } + if (disguised(dst)) { + WBUFL(buf,8)=-dst->id; + if (disguised(src)) + WBUFL(buf,4)=src->id; + else if(damage > 0) + WBUFW(buf,28)=-1; + clif_send(buf,packet_len(0x115),dst,SELF); + } + + //Because the damage delay must be synced with the client, here is where the can-walk tick must be updated. [Skotlex] + return clif_calc_walkdelay(dst,ddelay,type,damage,div); } */ @@ -4970,32 +5030,32 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,unsigned in /// 011a .W .W .L .L .B int clif_skill_nodamage(struct block_list *src,struct block_list *dst,int skill_id,int heal,int fail) { - unsigned char buf[32]; - - nullpo_ret(dst); - - WBUFW(buf,0)=0x11a; - WBUFW(buf,2)=skill_id; - WBUFW(buf,4)=min(heal, INT16_MAX); - WBUFL(buf,6)=dst->id; - WBUFL(buf,10)=src?src->id:0; - WBUFB(buf,14)=fail; - - if (disguised(dst)) { - clif_send(buf,packet_len(0x11a),dst,AREA_WOS); - WBUFL(buf,6)=-dst->id; - clif_send(buf,packet_len(0x11a),dst,SELF); - } else - clif_send(buf,packet_len(0x11a),dst,AREA); - - if (src && disguised(src)) { - WBUFL(buf,10)=-src->id; - if (disguised(dst)) - WBUFL(buf,6)=dst->id; - clif_send(buf,packet_len(0x11a),src,SELF); - } + unsigned char buf[32]; - return fail; + nullpo_ret(dst); + + WBUFW(buf,0)=0x11a; + WBUFW(buf,2)=skill_id; + WBUFW(buf,4)=min(heal, INT16_MAX); + WBUFL(buf,6)=dst->id; + WBUFL(buf,10)=src?src->id:0; + WBUFB(buf,14)=fail; + + if (disguised(dst)) { + clif_send(buf,packet_len(0x11a),dst,AREA_WOS); + WBUFL(buf,6)=-dst->id; + clif_send(buf,packet_len(0x11a),dst,SELF); + } else + clif_send(buf,packet_len(0x11a),dst,AREA); + + if(src && disguised(src)) { + WBUFL(buf,10)=-src->id; + if (disguised(dst)) + WBUFL(buf,6)=dst->id; + clif_send(buf,packet_len(0x11a),src,SELF); + } + + return fail; } @@ -5003,23 +5063,23 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,int skill_ /// 0117 .W .L .W .W .W .L void clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(src); + nullpo_retv(src); - WBUFW(buf,0)=0x117; - WBUFW(buf,2)=skill_id; - WBUFL(buf,4)=src->id; - WBUFW(buf,8)=val; - WBUFW(buf,10)=x; - WBUFW(buf,12)=y; - WBUFL(buf,14)=tick; - if (disguised(src)) { - clif_send(buf,packet_len(0x117),src,AREA_WOS); - WBUFL(buf,4)=-src->id; - clif_send(buf,packet_len(0x117),src,SELF); - } else - clif_send(buf,packet_len(0x117),src,AREA); + WBUFW(buf,0)=0x117; + WBUFW(buf,2)=skill_id; + WBUFL(buf,4)=src->id; + WBUFW(buf,8)=val; + WBUFW(buf,10)=x; + WBUFW(buf,12)=y; + WBUFL(buf,14)=tick; + if(disguised(src)) { + clif_send(buf,packet_len(0x117),src,AREA_WOS); + WBUFL(buf,4)=-src->id; + clif_send(buf,packet_len(0x117),src,SELF); + } else + clif_send(buf,packet_len(0x117),src,AREA); } @@ -5029,69 +5089,69 @@ void clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int //FIXME: this is just an AREA version of clif_getareachar_skillunit() void clif_skill_setunit(struct skill_unit *unit) { - unsigned char buf[128]; + unsigned char buf[128]; - nullpo_retv(unit); + nullpo_retv(unit); - if (unit->group->state.guildaura) - return; + if( unit->group->state.guildaura ) + return; #if PACKETVER >= 3 - if (unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris] - WBUFW(buf, 0)=0x1c9; - WBUFL(buf, 2)=unit->bl.id; - WBUFL(buf, 6)=unit->group->src_id; - WBUFW(buf,10)=unit->bl.x; - WBUFW(buf,12)=unit->bl.y; - WBUFB(buf,14)=unit->group->unit_id; - WBUFB(buf,15)=1; - WBUFB(buf,16)=1; - safestrncpy((char *)WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE); - clif_send(buf,packet_len(0x1c9),&unit->bl,AREA); - return; - } + if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris] + WBUFW(buf, 0)=0x1c9; + WBUFL(buf, 2)=unit->bl.id; + WBUFL(buf, 6)=unit->group->src_id; + WBUFW(buf,10)=unit->bl.x; + WBUFW(buf,12)=unit->bl.y; + WBUFB(buf,14)=unit->group->unit_id; + WBUFB(buf,15)=1; + WBUFB(buf,16)=1; + safestrncpy((char*)WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE); + clif_send(buf,packet_len(0x1c9),&unit->bl,AREA); + return; + } #endif - WBUFW(buf, 0)=0x11f; - WBUFL(buf, 2)=unit->bl.id; - WBUFL(buf, 6)=unit->group->src_id; - WBUFW(buf,10)=unit->bl.x; - WBUFW(buf,12)=unit->bl.y; - if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) - WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE; + WBUFW(buf, 0)=0x11f; + WBUFL(buf, 2)=unit->bl.id; + WBUFL(buf, 6)=unit->group->src_id; + WBUFW(buf,10)=unit->bl.x; + WBUFW(buf,12)=unit->bl.y; + if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) + WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE; else if (skill_get_unit_flag(unit->group->skill_id) & UF_RANGEDSINGLEUNIT && !(unit->val2 & UF_RANGEDSINGLEUNIT)) WBUFB(buf, 14) = UNT_DUMMYSKILL; // Only display the unit at center. - else - WBUFB(buf,14)=unit->group->unit_id; - WBUFB(buf,15)=1; // ignored by client (always gets set to 1) - clif_send(buf,packet_len(0x11f),&unit->bl,AREA); + else + WBUFB(buf,14)=unit->group->unit_id; + WBUFB(buf,15)=1; // ignored by client (always gets set to 1) + clif_send(buf,packet_len(0x11f),&unit->bl,AREA); } /// Presents a list of available warp destinations (ZC_WARPLIST). /// 011c .W { .16B }*4 -void clif_skill_warppoint(struct map_session_data *sd, short skill_num, short skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4) +void clif_skill_warppoint(struct map_session_data* sd, short skill_num, short skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4) { - int fd; - 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 == (unsigned short)-1) strcpy((char *)WFIFOP(fd,4), "Random"); - else // normal map name - 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; - if (skill_num == AL_WARP) - sd->menuskill_val = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here. - else - sd->menuskill_val = skill_lv; + int fd; + 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 == (unsigned short)-1) strcpy((char*)WFIFOP(fd,4), "Random"); + else // normal map name + 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; + if (skill_num == AL_WARP) + sd->menuskill_val = (sd->ud.skillx<<16)|sd->ud.skilly; //Store warp position here. + else + sd->menuskill_val = skill_lv; } @@ -5104,17 +5164,17 @@ void clif_skill_warppoint(struct map_session_data *sd, short skill_num, short sk /// /// @param sd Who receives the message /// @param type What message -void clif_skill_memomessage(struct map_session_data *sd, int type) +void clif_skill_memomessage(struct map_session_data* sd, int type) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x11e)); - WFIFOW(fd,0)=0x11e; - WFIFOB(fd,2)=type; - WFIFOSET(fd,packet_len(0x11e)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x11e)); + WFIFOW(fd,0)=0x11e; + WFIFOB(fd,2)=type; + WFIFOSET(fd,packet_len(0x11e)); } @@ -5128,15 +5188,15 @@ void clif_skill_memomessage(struct map_session_data *sd, int type) /// @param type What message void clif_skill_teleportmessage(struct map_session_data *sd, int type) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x189)); - WFIFOW(fd,0)=0x189; - WFIFOW(fd,2)=type; - WFIFOSET(fd,packet_len(0x189)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x189)); + WFIFOW(fd,0)=0x189; + WFIFOW(fd,2)=type; + WFIFOSET(fd,packet_len(0x189)); } @@ -5145,35 +5205,35 @@ void clif_skill_teleportmessage(struct map_session_data *sd, int type) /// .B .B .B .B .B .B .B .B .B void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) { - struct status_data *status; - unsigned char buf[64]; - int i;//, fix; + struct status_data *status; + unsigned char buf[64]; + int i;//, fix; - nullpo_retv(sd); - nullpo_retv(dst); + nullpo_retv(sd); + nullpo_retv(dst); - if (dst->type != BL_MOB) - return; + if( dst->type != BL_MOB ) + return; - status = status_get_status_data(dst); + status = status_get_status_data(dst); - WBUFW(buf, 0)=0x18c; - WBUFW(buf, 2)=status_get_class(dst); - WBUFW(buf, 4)=status_get_lv(dst); - WBUFW(buf, 6)=status->size; - WBUFL(buf, 8)=status->hp; - WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0) - +(battle_config.estimation_type&2?status->def2:0); - WBUFW(buf,14)=status->race; - WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0) - +(battle_config.estimation_type&2?status->mdef2:0); - WBUFW(buf,18)= status->def_ele; - for (i=0; i<9; i++) - WBUFB(buf,20+i)= (unsigned char)battle_attr_ratio(i+1,status->def_ele, status->ele_lv); - // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] - // WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,status->def_ele, status->ele_lv))<0?0:fix); + WBUFW(buf, 0)=0x18c; + WBUFW(buf, 2)=status_get_class(dst); + WBUFW(buf, 4)=status_get_lv(dst); + WBUFW(buf, 6)=status->size; + WBUFL(buf, 8)=status->hp; + WBUFW(buf,12)= (battle_config.estimation_type&1?status->def:0) + +(battle_config.estimation_type&2?status->def2:0); + WBUFW(buf,14)=status->race; + WBUFW(buf,16)= (battle_config.estimation_type&1?status->mdef:0) + +(battle_config.estimation_type&2?status->mdef2:0); + WBUFW(buf,18)= status->def_ele; + for(i=0;i<9;i++) + WBUFB(buf,20+i)= (unsigned char)battle_attr_ratio(i+1,status->def_ele, status->ele_lv); +// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] +// WBUFB(buf,20+i)= (unsigned char)((fix=battle_attr_ratio(i+1,status->def_ele, status->ele_lv))<0?0:fix); - clif_send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF); + clif_send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF); } @@ -5183,39 +5243,39 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) /// unused by the client void clif_skill_produce_mix_list(struct map_session_data *sd, int skillid , int trigger) { - int i,c,view,fd; - nullpo_retv(sd); - - if (sd->menuskill_id == skillid) - return; //Avoid resending the menu twice or more times... - if (skillid == GC_CREATENEWPOISON) - skillid = GC_RESEARCHNEWPOISON; - - fd=sd->fd; - WFIFOHEAD(fd, MAX_SKILL_PRODUCE_DB * 8 + 8); - WFIFOW(fd, 0)=0x18d; - - for (i=0,c=0; i 0 && skill_produce_db[i].req_skill == skillid) || skillid < 0) - ) { - if ((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0) - WFIFOW(fd,c*8+ 4)= view; - else - WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid; - WFIFOW(fd,c*8+ 6)= 0; - WFIFOW(fd,c*8+ 8)= 0; - WFIFOW(fd,c*8+10)= 0; - c++; - } - } - WFIFOW(fd, 2)=c*8+8; - WFIFOSET(fd,WFIFOW(fd,2)); - if (c > 0) { - sd->menuskill_id = skillid; - sd->menuskill_val = trigger; - return; - } + int i,c,view,fd; + nullpo_retv(sd); + + if(sd->menuskill_id == skillid) + return; //Avoid resending the menu twice or more times... + if( skillid == GC_CREATENEWPOISON ) + skillid = GC_RESEARCHNEWPOISON; + + fd=sd->fd; + WFIFOHEAD(fd, MAX_SKILL_PRODUCE_DB * 8 + 8); + WFIFOW(fd, 0)=0x18d; + + for(i=0,c=0;i 0 && skill_produce_db[i].req_skill == skillid ) || skillid < 0 ) + ){ + if((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0) + WFIFOW(fd,c*8+ 4)= view; + else + WFIFOW(fd,c*8+ 4)= skill_produce_db[i].nameid; + WFIFOW(fd,c*8+ 6)= 0; + WFIFOW(fd,c*8+ 8)= 0; + WFIFOW(fd,c*8+10)= 0; + c++; + } + } + WFIFOW(fd, 2)=c*8+8; + WFIFOSET(fd,WFIFOW(fd,2)); + if(c > 0) { + sd->menuskill_id = skillid; + sd->menuskill_val = trigger; + return; + } } @@ -5230,55 +5290,55 @@ void clif_skill_produce_mix_list(struct map_session_data *sd, int skillid , int /// 6 = GN_S_PHARMACY void clif_cooking_list(struct map_session_data *sd, int trigger, int skill_id, int qty, int list_type) { - int fd; - int i, c; - int view; - - nullpo_retv(sd); - fd = sd->fd; - - WFIFOHEAD(fd, 6 + 2 * MAX_SKILL_PRODUCE_DB); - WFIFOW(fd,0) = 0x25a; - WFIFOW(fd,4) = list_type; // list type - - c = 0; - for (i = 0; i < MAX_SKILL_PRODUCE_DB; i++) { - if (!skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger, qty)) - continue; - - if ((view = itemdb_viewid(skill_produce_db[i].nameid)) > 0) - WFIFOW(fd, 6 + 2 * c) = view; - else - WFIFOW(fd, 6 + 2 * c) = skill_produce_db[i].nameid; - - c++; - } - - if (skill_id == AM_PHARMACY) { // Only send it while Cooking else check for c. - WFIFOW(fd,2) = 6 + 2 * c; - WFIFOSET(fd,WFIFOW(fd,2)); - } - - if (c > 0) { - sd->menuskill_id = skill_id; - sd->menuskill_val = trigger; - if (skill_id != AM_PHARMACY) { - sd->menuskill_val2 = qty; // amount. - WFIFOW(fd,2) = 6 + 2 * c; - WFIFOSET(fd,WFIFOW(fd,2)); - } - } else { - clif_menuskill_clear(sd); - if (skill_id != AM_PHARMACY) { // AM_PHARMACY is used to Cooking. - // It fails. + int fd; + int i, c; + int view; + + nullpo_retv(sd); + fd = sd->fd; + + WFIFOHEAD(fd, 6 + 2 * MAX_SKILL_PRODUCE_DB); + WFIFOW(fd,0) = 0x25a; + WFIFOW(fd,4) = list_type; // list type + + c = 0; + for( i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ) { + if( !skill_can_produce_mix(sd,skill_produce_db[i].nameid,trigger, qty) ) + continue; + + if( (view = itemdb_viewid(skill_produce_db[i].nameid)) > 0 ) + WFIFOW(fd, 6 + 2 * c) = view; + else + WFIFOW(fd, 6 + 2 * c) = skill_produce_db[i].nameid; + + c++; + } + + if( skill_id == AM_PHARMACY ) { // Only send it while Cooking else check for c. + WFIFOW(fd,2) = 6 + 2 * c; + WFIFOSET(fd,WFIFOW(fd,2)); + } + + if( c > 0 ) { + sd->menuskill_id = skill_id; + sd->menuskill_val = trigger; + if( skill_id != AM_PHARMACY ) { + sd->menuskill_val2 = qty; // amount. + WFIFOW(fd,2) = 6 + 2 * c; + WFIFOSET(fd,WFIFOW(fd,2)); + } + } else { + clif_menuskill_clear(sd); + if( skill_id != AM_PHARMACY ) { // AM_PHARMACY is used to Cooking. + // It fails. #if PACKETVER >= 20090922 - clif_msg_skill(sd,skill_id,0x625); + clif_msg_skill(sd,skill_id,0x625); #else - WFIFOW(fd,2) = 6 + 2 * c; - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOW(fd,2) = 6 + 2 * c; + WFIFOSET(fd,WFIFOW(fd,2)); #endif - } - } + } + } } @@ -5287,162 +5347,161 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, int skill_id, i /// 043f .W .L .B .L { .L }*3 (ZC_MSG_STATE_CHANGE2) [used exclusively for starting statuses on pcs] void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3) { - unsigned char buf[32]; - struct map_session_data *sd; + unsigned char buf[32]; + struct map_session_data *sd; - if (type == SI_BLANK) //It shows nothing on the client... - return; + if (type == SI_BLANK) //It shows nothing on the client... + return; - nullpo_retv(bl); + nullpo_retv(bl); - sd = BL_CAST(BL_PC, bl); + sd = BL_CAST(BL_PC, bl); - if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client - return; + if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client + return; #if PACKETVER >= 20090121 - if (flag && battle_config.display_status_timers && sd) - WBUFW(buf,0)=0x43f; - else + if(flag && battle_config.display_status_timers && sd) + WBUFW(buf,0)=0x43f; + else #endif - WBUFW(buf,0)=0x196; - WBUFW(buf,2)=type; - WBUFL(buf,4)=bl->id; - WBUFB(buf,8)=flag; + WBUFW(buf,0)=0x196; + WBUFW(buf,2)=type; + WBUFL(buf,4)=bl->id; + WBUFB(buf,8)=flag; #if PACKETVER >= 20090121 - if (flag && battle_config.display_status_timers && sd) { - if (tick <= 0) - tick = 9999; // this is indeed what official servers do - - WBUFL(buf,9) = tick; - WBUFL(buf,13) = val1; - WBUFL(buf,17) = val2; - WBUFL(buf,21) = val3; - } + if(flag && battle_config.display_status_timers && sd) + { + if (tick <= 0) + tick = 9999; // this is indeed what official servers do + + WBUFL(buf,9) = tick; + WBUFL(buf,13) = val1; + WBUFL(buf,17) = val2; + WBUFL(buf,21) = val3; + } #endif - clif_send(buf,packet_len(WBUFW(buf,0)),bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA); + clif_send(buf,packet_len(WBUFW(buf,0)),bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA); } /// Send message (modified by [Yor]) (ZC_NOTIFY_PLAYERCHAT). /// 008e .W .?B -void clif_displaymessage(const int fd, const char *mes) -{ - nullpo_retv(mes); - - //Scrapped, as these are shared by disconnected players =X [Skotlex] - if (fd == 0) - ; - else { - char *message, *line; - - message = aStrdup(mes); - line = strtok(message, "\n"); - while (line != NULL) { - // Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client) - int len = strnlen(line, 255); - - if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line. - WFIFOHEAD(fd, 5 + len); - WFIFOW(fd,0) = 0x8e; - WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate - safestrncpy((char *)WFIFOP(fd,4), line, len + 1); - WFIFOSET(fd, 5 + len); - } - line = strtok(NULL, "\n"); - } - aFree(message); - } +void clif_displaymessage(const int fd, const char* mes) +{ + nullpo_retv(mes); + + //Scrapped, as these are shared by disconnected players =X [Skotlex] + if (fd == 0) + ; + else { + char *message, *line; + + message = aStrdup(mes); + line = strtok(message, "\n"); + while(line != NULL) { + // Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client) + int len = strnlen(line, 255); + + if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line. + WFIFOHEAD(fd, 5 + len); + WFIFOW(fd,0) = 0x8e; + WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate + safestrncpy(WFIFOP(fd,4), line, len + 1); + WFIFOSET(fd, 5 + len); + } + line = strtok(NULL, "\n"); + } + aFree(message); + } } /// Send broadcast message in yellow or blue without font formatting (ZC_BROADCAST). /// 009a .W .?B -void clif_broadcast(struct block_list *bl, const char *mes, int len, int type, enum send_target target) +void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, enum send_target target) { - int lp = type ? 4 : 0; - unsigned char *buf = (unsigned char *)aMalloc((4 + lp + len)*sizeof(unsigned char)); + int lp = type ? 4 : 0; + unsigned char *buf = (unsigned char*)aMalloc((4 + lp + len)*sizeof(unsigned char)); - WBUFW(buf,0) = 0x9a; - WBUFW(buf,2) = 4 + lp + len; - if (type == 0x10) // bc_blue - WBUFL(buf,4) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. - else if (type == 0x20) // bc_woe - WBUFL(buf,4) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. - memcpy(WBUFP(buf, 4 + lp), mes, len); - clif_send(buf, WBUFW(buf,2), bl, target); + WBUFW(buf,0) = 0x9a; + WBUFW(buf,2) = 4 + lp + len; + if (type == 0x10) // bc_blue + WBUFL(buf,4) = 0x65756c62; //If there's "blue" at the beginning of the message, game client will display it in blue instead of yellow. + else if (type == 0x20) // bc_woe + WBUFL(buf,4) = 0x73737373; //If there's "ssss", game client will recognize message as 'WoE broadcast'. + memcpy(WBUFP(buf, 4 + lp), mes, len); + clif_send(buf, WBUFW(buf,2), bl, target); - if (buf) - aFree(buf); + if (buf) + aFree(buf); } /*========================================== * Displays a message on a 'bl' to all it's nearby clients * Used by npc_globalmessage *------------------------------------------*/ -void clif_GlobalMessage(struct block_list *bl, const char *message) -{ - char buf[100]; - int len; - nullpo_retv(bl); +void clif_GlobalMessage(struct block_list* bl, const char* message) { + char buf[100]; + int len; + nullpo_retv(bl); - if (!message) - return; + if(!message) + return; - len = strlen(message)+1; + len = strlen(message)+1; - if (len > sizeof(buf)-8) { - ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%d).\n", message, len); - len = sizeof(buf)-8; - } + if( len > sizeof(buf)-8 ) { + ShowWarning("clif_GlobalMessage: Truncating too long message '%s' (len=%d).\n", message, len); + len = sizeof(buf)-8; + } - WBUFW(buf,0)=0x8d; - WBUFW(buf,2)=len+8; - WBUFL(buf,4)=bl->id; - safestrncpy((char *) WBUFP(buf,8),message,len); - clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT); + WBUFW(buf,0)=0x8d; + WBUFW(buf,2)=len+8; + WBUFL(buf,4)=bl->id; + safestrncpy((char *) WBUFP(buf,8),message,len); + clif_send((unsigned char *) buf,WBUFW(buf,2),bl,ALL_CLIENT); } /*========================================== * Send main chat message [LuzZza] *------------------------------------------*/ -void clif_MainChatMessage(const char *message) -{ - uint8 buf[200]; - int len; +void clif_MainChatMessage(const char* message) { + uint8 buf[200]; + int len; - if (!message) - return; + if(!message) + return; - len = strlen(message)+1; - if (len+8 > sizeof(buf)) { - ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message); - len = sizeof(buf)-8; - } - WBUFW(buf,0)=0x8d; - WBUFW(buf,2)=len+8; - WBUFL(buf,4)=0; - safestrncpy((char *) WBUFP(buf,8),message,len); - clif_send(buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT); + len = strlen(message)+1; + if (len+8 > sizeof(buf)) { + ShowDebug("clif_MainChatMessage: Received message too long (len %d): %s\n", len, message); + len = sizeof(buf)-8; + } + WBUFW(buf,0)=0x8d; + WBUFW(buf,2)=len+8; + WBUFL(buf,4)=0; + safestrncpy((char *) WBUFP(buf,8),message,len); + clif_send(buf,WBUFW(buf,2),NULL,CHAT_MAINCHAT); } /// Send broadcast message with font formatting (ZC_BROADCAST2). /// 01c3 .W .L .W .W .W .W .?B -void clif_broadcast2(struct block_list *bl, const char *mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target) +void clif_broadcast2(struct block_list* bl, const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target) { - unsigned char *buf = (unsigned char *)aMalloc((16 + len)*sizeof(unsigned char)); + unsigned char *buf = (unsigned char*)aMalloc((16 + len)*sizeof(unsigned char)); - WBUFW(buf,0) = 0x1c3; - WBUFW(buf,2) = len + 16; - WBUFL(buf,4) = fontColor; - WBUFW(buf,8) = fontType; - WBUFW(buf,10) = fontSize; - WBUFW(buf,12) = fontAlign; - WBUFW(buf,14) = fontY; - memcpy(WBUFP(buf,16), mes, len); - clif_send(buf, WBUFW(buf,2), bl, target); + WBUFW(buf,0) = 0x1c3; + WBUFW(buf,2) = len + 16; + WBUFL(buf,4) = fontColor; + WBUFW(buf,8) = fontType; + WBUFW(buf,10) = fontSize; + WBUFW(buf,12) = fontAlign; + WBUFW(buf,14) = fontY; + memcpy(WBUFP(buf,16), mes, len); + clif_send(buf, WBUFW(buf,2), bl, target); - if (buf) - aFree(buf); + if (buf) + aFree(buf); } @@ -5454,11 +5513,11 @@ void clif_broadcast2(struct block_list *bl, const char *mes, int len, unsigned l /// ? = ignored void clif_heal(int fd,int type,int val) { - WFIFOHEAD(fd,packet_len(0x13d)); - WFIFOW(fd,0)=0x13d; - WFIFOW(fd,2)=type; - WFIFOW(fd,4)=cap_value(val,0,INT16_MAX); - WFIFOSET(fd,packet_len(0x13d)); + WFIFOHEAD(fd,packet_len(0x13d)); + WFIFOW(fd,0)=0x13d; + WFIFOW(fd,2)=type; + WFIFOW(fd,4)=cap_value(val,0,INT16_MAX); + WFIFOSET(fd,packet_len(0x13d)); } @@ -5468,49 +5527,49 @@ void clif_heal(int fd,int type,int val) /// ignored void clif_resurrection(struct block_list *bl,int type) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0)=0x148; - WBUFL(buf,2)=bl->id; - WBUFW(buf,6)=0; + WBUFW(buf,0)=0x148; + WBUFL(buf,2)=bl->id; + WBUFW(buf,6)=0; - clif_send(buf,packet_len(0x148),bl,type==1 ? AREA : AREA_WOS); - if (disguised(bl)) - clif_spawn(bl); + clif_send(buf,packet_len(0x148),bl,type==1 ? AREA : AREA_WOS); + if (disguised(bl)) + clif_spawn(bl); } /// Sets the map property (ZC_NOTIFY_MAPPROPERTY). /// 0199 .W -void clif_map_property(struct map_session_data *sd, enum map_property property) +void clif_map_property(struct map_session_data* sd, enum map_property property) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x199)); - WFIFOW(fd,0)=0x199; - WFIFOW(fd,2)=property; - WFIFOSET(fd,packet_len(0x199)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x199)); + WFIFOW(fd,0)=0x199; + WFIFOW(fd,2)=property; + WFIFOSET(fd,packet_len(0x199)); } /// Set the map type (ZC_NOTIFY_MAPPROPERTY2). /// 01d6 .W -void clif_map_type(struct map_session_data *sd, enum map_type type) +void clif_map_type(struct map_session_data* sd, enum map_type type) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x1D6)); - WFIFOW(fd,0)=0x1D6; - WFIFOW(fd,2)=type; - WFIFOSET(fd,packet_len(0x1D6)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x1D6)); + WFIFOW(fd,0)=0x1D6; + WFIFOW(fd,2)=type; + WFIFOSET(fd,packet_len(0x1D6)); } @@ -5518,30 +5577,30 @@ void clif_map_type(struct map_session_data *sd, enum map_type type) /// 019a .L .L .L void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) { - if (type == 2) { - int fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x19a)); - WFIFOW(fd,0) = 0x19a; - WFIFOL(fd,2) = sd->bl.id; - WFIFOL(fd,6) = pvprank; - WFIFOL(fd,10) = pvpnum; - WFIFOSET(fd,packet_len(0x19a)); - } else { - unsigned char buf[32]; - WBUFW(buf,0) = 0x19a; - WBUFL(buf,2) = sd->bl.id; - if (sd->sc.option&(OPTION_HIDE|OPTION_CLOAK)) - WBUFL(buf,6) = UINT32_MAX; //On client displays as -- - else - WBUFL(buf,6) = pvprank; - WBUFL(buf,10) = pvpnum; - if (sd->sc.option&OPTION_INVISIBLE || sd->disguise) //Causes crashes when a 'mob' with pvp info dies. - clif_send(buf,packet_len(0x19a),&sd->bl,SELF); - else if (!type) - clif_send(buf,packet_len(0x19a),&sd->bl,AREA); - else - clif_send(buf,packet_len(0x19a),&sd->bl,ALL_SAMEMAP); - } + if(type == 2) { + int fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x19a)); + WFIFOW(fd,0) = 0x19a; + WFIFOL(fd,2) = sd->bl.id; + WFIFOL(fd,6) = pvprank; + WFIFOL(fd,10) = pvpnum; + WFIFOSET(fd,packet_len(0x19a)); + } else { + unsigned char buf[32]; + WBUFW(buf,0) = 0x19a; + WBUFL(buf,2) = sd->bl.id; + if(sd->sc.option&(OPTION_HIDE|OPTION_CLOAK)) + WBUFL(buf,6) = UINT32_MAX; //On client displays as -- + else + WBUFL(buf,6) = pvprank; + WBUFL(buf,10) = pvpnum; + if(sd->sc.option&OPTION_INVISIBLE || sd->disguise) //Causes crashes when a 'mob' with pvp info dies. + clif_send(buf,packet_len(0x19a),&sd->bl,SELF); + else if(!type) + clif_send(buf,packet_len(0x19a),&sd->bl,AREA); + else + clif_send(buf,packet_len(0x19a),&sd->bl,ALL_SAMEMAP); + } } @@ -5550,15 +5609,15 @@ void clif_pvpset(struct map_session_data *sd,int pvprank,int pvpnum,int type) *------------------------------------------*/ void clif_map_property_mapall(int map, enum map_property property) { - struct block_list bl; - unsigned char buf[16]; + struct block_list bl; + unsigned char buf[16]; - bl.id = 0; - bl.type = BL_NUL; - bl.m = map; - WBUFW(buf,0)=0x199; - WBUFW(buf,2)=property; - clif_send(buf,packet_len(0x199),&bl,ALL_SAMEMAP); + bl.id = 0; + bl.type = BL_NUL; + bl.m = map; + WBUFW(buf,0)=0x199; + WBUFW(buf,2)=property; + clif_send(buf,packet_len(0x199),&bl,ALL_SAMEMAP); } @@ -5570,12 +5629,12 @@ void clif_map_property_mapall(int map, enum map_property property) /// 2 = downgrade void clif_refine(int fd, int fail, int index, int val) { - WFIFOHEAD(fd,packet_len(0x188)); - WFIFOW(fd,0)=0x188; - WFIFOW(fd,2)=fail; - WFIFOW(fd,4)=index+2; - WFIFOW(fd,6)=val; - WFIFOSET(fd,packet_len(0x188)); + WFIFOHEAD(fd,packet_len(0x188)); + WFIFOW(fd,0)=0x188; + WFIFOW(fd,2)=fail; + WFIFOW(fd,4)=index+2; + WFIFOW(fd,6)=val; + WFIFOSET(fd,packet_len(0x188)); } @@ -5588,35 +5647,35 @@ void clif_refine(int fd, int fail, int index, int val) /// 3 = "you lack the item %s to upgrade the weapon" MsgStringTable[914] in rgb(255,200,200) void clif_upgrademessage(int fd, int result, int item_id) { - WFIFOHEAD(fd,packet_len(0x223)); - WFIFOW(fd,0)=0x223; - WFIFOL(fd,2)=result; - WFIFOW(fd,6)=item_id; - WFIFOSET(fd,packet_len(0x223)); + WFIFOHEAD(fd,packet_len(0x223)); + WFIFOW(fd,0)=0x223; + WFIFOL(fd,2)=result; + WFIFOW(fd,6)=item_id; + WFIFOSET(fd,packet_len(0x223)); } /// Whisper is transmitted to the destination player (ZC_WHISPER). /// 0097 .W .24B .?B /// 0097 .W .24B .L .?B (PACKETVER >= 20091104) -void clif_wis_message(int fd, const char *nick, const char *mes, int mes_len) +void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) { #if PACKETVER < 20091104 - WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4); - WFIFOW(fd,0) = 0x97; - WFIFOW(fd,2) = mes_len + NAME_LENGTH + 4; - safestrncpy((char *)WFIFOP(fd,4), nick, NAME_LENGTH); - safestrncpy((char *)WFIFOP(fd,28), mes, mes_len); - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4); + WFIFOW(fd,0) = 0x97; + WFIFOW(fd,2) = mes_len + NAME_LENGTH + 4; + safestrncpy((char*)WFIFOP(fd,4), nick, NAME_LENGTH); + safestrncpy((char*)WFIFOP(fd,28), mes, mes_len); + WFIFOSET(fd,WFIFOW(fd,2)); #else - WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8); - WFIFOW(fd,0) = 0x97; - WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8; - safestrncpy((char *)WFIFOP(fd,4), nick, NAME_LENGTH); - WFIFOL(fd,28) = 0; // isAdmin; if nonzero, also displays text above char - // TODO: WFIFOL(fd,28) = pc_get_group_level(ssd); - safestrncpy((char *)WFIFOP(fd,32), mes, mes_len); - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8); + WFIFOW(fd,0) = 0x97; + WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8; + safestrncpy((char*)WFIFOP(fd,4), nick, NAME_LENGTH); + WFIFOL(fd,28) = 0; // isAdmin; if nonzero, also displays text above char + // TODO: WFIFOL(fd,28) = pc_get_group_level(ssd); + safestrncpy((char*)WFIFOP(fd,32), mes, mes_len); + WFIFOSET(fd,WFIFOW(fd,2)); #endif } @@ -5630,22 +5689,22 @@ void clif_wis_message(int fd, const char *nick, const char *mes, int mes_len) /// 3 = everyone ignored by target void clif_wis_end(int fd, int flag) { - WFIFOHEAD(fd,packet_len(0x98)); - WFIFOW(fd,0) = 0x98; - WFIFOW(fd,2) = flag; - WFIFOSET(fd,packet_len(0x98)); + WFIFOHEAD(fd,packet_len(0x98)); + WFIFOW(fd,0) = 0x98; + WFIFOW(fd,2) = flag; + WFIFOSET(fd,packet_len(0x98)); } /// Returns character name requested by char_id (ZC_ACK_REQNAME_BYGID). /// 0194 .L .24B -void clif_solved_charname(int fd, int charid, const char *name) +void clif_solved_charname(int fd, int charid, const char* name) { - WFIFOHEAD(fd,packet_len(0x194)); - WFIFOW(fd,0)=0x194; - WFIFOL(fd,2)=charid; - safestrncpy((char *)WFIFOP(fd,6), name, NAME_LENGTH); - WFIFOSET(fd,packet_len(0x194)); + WFIFOHEAD(fd,packet_len(0x194)); + WFIFOW(fd,0)=0x194; + WFIFOL(fd,2)=charid; + safestrncpy((char*)WFIFOP(fd,6), name, NAME_LENGTH); + WFIFOSET(fd,packet_len(0x194)); } @@ -5653,48 +5712,48 @@ void clif_solved_charname(int fd, int charid, const char *name) /// 017b .W { .W }* void clif_use_card(struct map_session_data *sd,int idx) { - int i,c,ep; - int fd=sd->fd; + int i,c,ep; + int fd=sd->fd; - nullpo_retv(sd); - if (idx < 0 || idx >= MAX_INVENTORY) //Crash-fix from bad packets. - return; + nullpo_retv(sd); + if (idx < 0 || idx >= MAX_INVENTORY) //Crash-fix from bad packets. + return; - if (!sd->inventory_data[idx] || sd->inventory_data[idx]->type != IT_CARD) - return; //Avoid parsing invalid item indexes (no card/no item) + if (!sd->inventory_data[idx] || sd->inventory_data[idx]->type != IT_CARD) + return; //Avoid parsing invalid item indexes (no card/no item) - ep=sd->inventory_data[idx]->equip; - WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4); - WFIFOW(fd,0)=0x17b; + ep=sd->inventory_data[idx]->equip; + WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4); + WFIFOW(fd,0)=0x17b; - for (i=c=0; iinventory_data[i] == NULL) - continue; - if (sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR) - continue; - if (itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it - continue; + if(sd->inventory_data[i] == NULL) + continue; + if(sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR) + continue; + if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it + continue; - if (sd->status.inventory[i].identify==0) //Not identified - continue; + if(sd->status.inventory[i].identify==0 ) //Not identified + continue; - if ((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part. - continue; + if((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part. + continue; - if (sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_SHIELD) //Shield card won't go on left weapon. - continue; + if(sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_SHIELD) //Shield card won't go on left weapon. + continue; - ARR_FIND(0, sd->inventory_data[i]->slot, j, sd->status.inventory[i].card[j] == 0); - if (j == sd->inventory_data[i]->slot) // No room - continue; + ARR_FIND( 0, sd->inventory_data[i]->slot, j, sd->status.inventory[i].card[j] == 0 ); + if( j == sd->inventory_data[i]->slot ) // No room + continue; - WFIFOW(fd,4+c*2)=i+2; - c++; - } - WFIFOW(fd,2)=4+c*2; - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOW(fd,4+c*2)=i+2; + c++; + } + WFIFOW(fd,2)=4+c*2; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -5705,17 +5764,17 @@ void clif_use_card(struct map_session_data *sd,int idx) /// 1 = failure void clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x17d)); - WFIFOW(fd,0)=0x17d; - WFIFOW(fd,2)=idx_equip+2; - WFIFOW(fd,4)=idx_card+2; - WFIFOB(fd,6)=flag; - WFIFOSET(fd,packet_len(0x17d)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x17d)); + WFIFOW(fd,0)=0x17d; + WFIFOW(fd,2)=idx_equip+2; + WFIFOW(fd,4)=idx_card+2; + WFIFOB(fd,6)=flag; + WFIFOSET(fd,packet_len(0x17d)); } @@ -5723,27 +5782,27 @@ void clif_insert_card(struct map_session_data *sd,int idx_equip,int idx_card,int /// 0177 .W { .W }* void clif_item_identify_list(struct map_session_data *sd) { - int i,c; - int fd; + int i,c; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; + fd=sd->fd; - WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4); - WFIFOW(fd,0)=0x177; - for (i=c=0; istatus.inventory[i].nameid > 0 && !sd->status.inventory[i].identify) { - WFIFOW(fd,c*2+4)=i+2; - c++; - } - } - if (c > 0) { - WFIFOW(fd,2)=c*2+4; - WFIFOSET(fd,WFIFOW(fd,2)); - sd->menuskill_id = MC_IDENTIFY; - sd->menuskill_val = c; - } + WFIFOHEAD(fd,MAX_INVENTORY * 2 + 4); + WFIFOW(fd,0)=0x177; + for(i=c=0;istatus.inventory[i].nameid > 0 && !sd->status.inventory[i].identify){ + WFIFOW(fd,c*2+4)=i+2; + c++; + } + } + if(c > 0) { + WFIFOW(fd,2)=c*2+4; + WFIFOSET(fd,WFIFOW(fd,2)); + sd->menuskill_id = MC_IDENTIFY; + sd->menuskill_val = c; + } } @@ -5751,16 +5810,16 @@ void clif_item_identify_list(struct map_session_data *sd) /// 0179 .W .B void clif_item_identified(struct map_session_data *sd,int idx,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x179)); - WFIFOW(fd, 0)=0x179; - WFIFOW(fd, 2)=idx+2; - WFIFOB(fd, 4)=flag; - WFIFOSET(fd,packet_len(0x179)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x179)); + WFIFOW(fd, 0)=0x179; + WFIFOW(fd, 2)=idx+2; + WFIFOB(fd, 4)=flag; + WFIFOSET(fd,packet_len(0x179)); } @@ -5768,34 +5827,34 @@ void clif_item_identified(struct map_session_data *sd,int idx,int flag) /// 01fc .W { .W .W .B .W .W .W .W }* void clif_item_repair_list(struct map_session_data *sd,struct map_session_data *dstsd, int lv) { - int i,c; - int fd; - int nameid; - - nullpo_retv(sd); - nullpo_retv(dstsd); - - fd=sd->fd; - - WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4); - WFIFOW(fd,0)=0x1fc; - for (i=c=0; istatus.inventory[i].nameid) > 0 && dstsd->status.inventory[i].attribute!=0) { // && skill_can_repair(sd,nameid)){ - WFIFOW(fd,c*13+4) = i; - WFIFOW(fd,c*13+6) = nameid; - WFIFOB(fd,c*13+8) = dstsd->status.inventory[i].refine; - clif_addcards(WFIFOP(fd,c*13+9), &dstsd->status.inventory[i]); - c++; - } - } - if (c > 0) { - WFIFOW(fd,2)=c*13+4; - WFIFOSET(fd,WFIFOW(fd,2)); - sd->menuskill_id = BS_REPAIRWEAPON; - sd->menuskill_val = dstsd->bl.id; - sd->menuskill_val2 = lv; - } else - clif_skill_fail(sd,sd->ud.skillid,USESKILL_FAIL_LEVEL,0); + int i,c; + int fd; + int nameid; + + nullpo_retv(sd); + nullpo_retv(dstsd); + + fd=sd->fd; + + WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4); + WFIFOW(fd,0)=0x1fc; + for(i=c=0;istatus.inventory[i].nameid) > 0 && dstsd->status.inventory[i].attribute!=0){// && skill_can_repair(sd,nameid)){ + WFIFOW(fd,c*13+4) = i; + WFIFOW(fd,c*13+6) = nameid; + WFIFOB(fd,c*13+8) = dstsd->status.inventory[i].refine; + clif_addcards(WFIFOP(fd,c*13+9), &dstsd->status.inventory[i]); + c++; + } + } + if(c > 0) { + WFIFOW(fd,2)=c*13+4; + WFIFOSET(fd,WFIFOW(fd,2)); + sd->menuskill_id = BS_REPAIRWEAPON; + sd->menuskill_val = dstsd->bl.id; + sd->menuskill_val2 = lv; + }else + clif_skill_fail(sd,sd->ud.skillid,USESKILL_FAIL_LEVEL,0); } @@ -5808,32 +5867,32 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data * /// 1 = Item repair failure. void clif_item_repaireffect(struct map_session_data *sd,int idx,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; + fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x1fe)); - WFIFOW(fd, 0)=0x1fe; - WFIFOW(fd, 2)=idx+2; - WFIFOB(fd, 4)=flag; - WFIFOSET(fd,packet_len(0x1fe)); + WFIFOHEAD(fd,packet_len(0x1fe)); + WFIFOW(fd, 0)=0x1fe; + WFIFOW(fd, 2)=idx+2; + WFIFOB(fd, 4)=flag; + WFIFOSET(fd,packet_len(0x1fe)); } /// Displays a message, that an equipment got damaged (ZC_EQUIPITEM_DAMAGED). /// 02bb .W .L -void clif_item_damaged(struct map_session_data *sd, unsigned short position) +void clif_item_damaged(struct map_session_data* sd, unsigned short position) { - int fd = sd->fd; + int fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x2bb)); - WFIFOW(fd,0) = 0x2bb; - WFIFOW(fd,2) = position; - WFIFOL(fd,4) = sd->bl.id; // TODO: the packet seems to be sent to other people as well, probably party and/or guild. - WFIFOSET(fd,packet_len(0x2bb)); + WFIFOHEAD(fd,packet_len(0x2bb)); + WFIFOW(fd,0) = 0x2bb; + WFIFOW(fd,2) = position; + WFIFOL(fd,4) = sd->bl.id; // TODO: the packet seems to be sent to other people as well, probably party and/or guild. + WFIFOSET(fd,packet_len(0x2bb)); } @@ -5841,42 +5900,42 @@ void clif_item_damaged(struct map_session_data *sd, unsigned short position) /// 0221 .W { .W .W .B .W .W .W .W }* void clif_item_refine_list(struct map_session_data *sd) { - int i,c; - int fd; - int skilllv; - int wlv; - int refine_item[5]; - - nullpo_retv(sd); - - skilllv = pc_checkskill(sd,WS_WEAPONREFINE); - - fd=sd->fd; - - refine_item[0] = -1; - refine_item[1] = pc_search_inventory(sd,1010); - refine_item[2] = pc_search_inventory(sd,1011); - refine_item[3] = refine_item[4] = pc_search_inventory(sd,984); - - WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4); - WFIFOW(fd,0)=0x221; - for (i=c=0; istatus.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skilllv && - sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 && - refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&EQP_ARMS)) { - WFIFOW(fd,c*13+ 4)=i+2; - WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid; - WFIFOB(fd,c*13+ 8)=sd->status.inventory[i].refine; - clif_addcards(WFIFOP(fd,c*13+9), &sd->status.inventory[i]); - c++; - } - } - WFIFOW(fd,2)=c*13+4; - WFIFOSET(fd,WFIFOW(fd,2)); - if (c > 0) { - sd->menuskill_id = WS_WEAPONREFINE; - sd->menuskill_val = skilllv; - } + int i,c; + int fd; + int skilllv; + int wlv; + int refine_item[5]; + + nullpo_retv(sd); + + skilllv = pc_checkskill(sd,WS_WEAPONREFINE); + + fd=sd->fd; + + refine_item[0] = -1; + refine_item[1] = pc_search_inventory(sd,1010); + refine_item[2] = pc_search_inventory(sd,1011); + refine_item[3] = refine_item[4] = pc_search_inventory(sd,984); + + WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4); + WFIFOW(fd,0)=0x221; + for(i=c=0;istatus.inventory[i].nameid > 0 && sd->status.inventory[i].refine < skilllv && + sd->status.inventory[i].identify && (wlv=itemdb_wlv(sd->status.inventory[i].nameid)) >=1 && + refine_item[wlv]!=-1 && !(sd->status.inventory[i].equip&EQP_ARMS)){ + WFIFOW(fd,c*13+ 4)=i+2; + WFIFOW(fd,c*13+ 6)=sd->status.inventory[i].nameid; + WFIFOB(fd,c*13+ 8)=sd->status.inventory[i].refine; + clif_addcards(WFIFOP(fd,c*13+9), &sd->status.inventory[i]); + c++; + } + } + WFIFOW(fd,2)=c*13+4; + WFIFOSET(fd,WFIFOW(fd,2)); + if (c > 0) { + sd->menuskill_id = WS_WEAPONREFINE; + sd->menuskill_val = skilllv; + } } @@ -5884,22 +5943,22 @@ void clif_item_refine_list(struct map_session_data *sd) /// 0147 .W .L .W .W .W .24B .B void clif_item_skill(struct map_session_data *sd,int skillid,int skilllv) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x147)); - WFIFOW(fd, 0)=0x147; - WFIFOW(fd, 2)=skillid; - WFIFOW(fd, 4)=skill_get_inf(skillid); - WFIFOW(fd, 6)=0; - WFIFOW(fd, 8)=skilllv; - WFIFOW(fd,10)=skill_get_sp(skillid,skilllv); - WFIFOW(fd,12)=skill_get_range2(&sd->bl, skillid,skilllv); - safestrncpy((char *)WFIFOP(fd,14),skill_get_name(skillid),NAME_LENGTH); - WFIFOB(fd,38)=0; - WFIFOSET(fd,packet_len(0x147)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x147)); + WFIFOW(fd, 0)=0x147; + WFIFOW(fd, 2)=skillid; + WFIFOW(fd, 4)=skill_get_inf(skillid); + WFIFOW(fd, 6)=0; + WFIFOW(fd, 8)=skilllv; + WFIFOW(fd,10)=skill_get_sp(skillid,skilllv); + WFIFOW(fd,12)=skill_get_range2(&sd->bl, skillid,skilllv); + safestrncpy((char*)WFIFOP(fd,14),skill_get_name(skillid),NAME_LENGTH); + WFIFOB(fd,38)=0; + WFIFOSET(fd,packet_len(0x147)); } @@ -5908,46 +5967,46 @@ void clif_item_skill(struct map_session_data *sd,int skillid,int skilllv) /// 01c5 .W .L .W .B .B .B .B .W .W .W .W (ZC_ADD_ITEM_TO_CART2) void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail) { - int view,fd; - unsigned char *buf; + int view,fd; + unsigned char *buf; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - if (n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0) - return; + fd=sd->fd; + if(n<0 || n>=MAX_CART || sd->status.cart[n].nameid<=0) + return; #if PACKETVER < 5 - WFIFOHEAD(fd,packet_len(0x124)); - buf=WFIFOP(fd,0); - WBUFW(buf,0)=0x124; - WBUFW(buf,2)=n+2; - WBUFL(buf,4)=amount; - if ((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0) - WBUFW(buf,8)=view; - else - WBUFW(buf,8)=sd->status.cart[n].nameid; - WBUFB(buf,10)=sd->status.cart[n].identify; - WBUFB(buf,11)=sd->status.cart[n].attribute; - WBUFB(buf,12)=sd->status.cart[n].refine; - clif_addcards(WBUFP(buf,13), &sd->status.cart[n]); - WFIFOSET(fd,packet_len(0x124)); + WFIFOHEAD(fd,packet_len(0x124)); + buf=WFIFOP(fd,0); + WBUFW(buf,0)=0x124; + WBUFW(buf,2)=n+2; + WBUFL(buf,4)=amount; + if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0) + WBUFW(buf,8)=view; + else + WBUFW(buf,8)=sd->status.cart[n].nameid; + WBUFB(buf,10)=sd->status.cart[n].identify; + WBUFB(buf,11)=sd->status.cart[n].attribute; + WBUFB(buf,12)=sd->status.cart[n].refine; + clif_addcards(WBUFP(buf,13), &sd->status.cart[n]); + WFIFOSET(fd,packet_len(0x124)); #else - WFIFOHEAD(fd,packet_len(0x1c5)); - buf=WFIFOP(fd,0); - WBUFW(buf,0)=0x1c5; - WBUFW(buf,2)=n+2; - WBUFL(buf,4)=amount; - if ((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0) - WBUFW(buf,8)=view; - else - WBUFW(buf,8)=sd->status.cart[n].nameid; - WBUFB(buf,10)=itemdb_type(sd->status.cart[n].nameid); - WBUFB(buf,11)=sd->status.cart[n].identify; - WBUFB(buf,12)=sd->status.cart[n].attribute; - WBUFB(buf,13)=sd->status.cart[n].refine; - clif_addcards(WBUFP(buf,14), &sd->status.cart[n]); - WFIFOSET(fd,packet_len(0x1c5)); + WFIFOHEAD(fd,packet_len(0x1c5)); + buf=WFIFOP(fd,0); + WBUFW(buf,0)=0x1c5; + WBUFW(buf,2)=n+2; + WBUFL(buf,4)=amount; + if((view = itemdb_viewid(sd->status.cart[n].nameid)) > 0) + WBUFW(buf,8)=view; + else + WBUFW(buf,8)=sd->status.cart[n].nameid; + WBUFB(buf,10)=itemdb_type(sd->status.cart[n].nameid); + WBUFB(buf,11)=sd->status.cart[n].identify; + WBUFB(buf,12)=sd->status.cart[n].attribute; + WBUFB(buf,13)=sd->status.cart[n].refine; + clif_addcards(WBUFP(buf,14), &sd->status.cart[n]); + WFIFOSET(fd,packet_len(0x1c5)); #endif } @@ -5956,17 +6015,17 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail) /// 0125 .W .L void clif_cart_delitem(struct map_session_data *sd,int n,int amount) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; + fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x125)); - WFIFOW(fd,0)=0x125; - WFIFOW(fd,2)=n+2; - WFIFOL(fd,4)=amount; - WFIFOSET(fd,packet_len(0x125)); + WFIFOHEAD(fd,packet_len(0x125)); + WFIFOW(fd,0)=0x125; + WFIFOW(fd,2)=n+2; + WFIFOL(fd,4)=amount; + WFIFOSET(fd,packet_len(0x125)); } @@ -5974,107 +6033,108 @@ void clif_cart_delitem(struct map_session_data *sd,int n,int amount) /// 012d .W /// num: /// number of allowed item slots -void clif_openvendingreq(struct map_session_data *sd, int num) +void clif_openvendingreq(struct map_session_data* sd, int num) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x12d)); - WFIFOW(fd,0) = 0x12d; - WFIFOW(fd,2) = num; - WFIFOSET(fd,packet_len(0x12d)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x12d)); + WFIFOW(fd,0) = 0x12d; + WFIFOW(fd,2) = num; + WFIFOSET(fd,packet_len(0x12d)); } /// Displays a vending board to target/area (ZC_STORE_ENTRY). /// 0131 .L .80B -void clif_showvendingboard(struct block_list *bl, const char *message, int fd) +void clif_showvendingboard(struct block_list* bl, const char* message, int fd) { - unsigned char buf[128]; + unsigned char buf[128]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x131; - WBUFL(buf,2) = bl->id; - safestrncpy((char *)WBUFP(buf,6), message, 80); + WBUFW(buf,0) = 0x131; + WBUFL(buf,2) = bl->id; + safestrncpy((char*)WBUFP(buf,6), message, 80); - if (fd) { - WFIFOHEAD(fd,packet_len(0x131)); - memcpy(WFIFOP(fd,0),buf,packet_len(0x131)); - WFIFOSET(fd,packet_len(0x131)); - } else { - clif_send(buf,packet_len(0x131),bl,AREA_WOS); - } + if( fd ) { + WFIFOHEAD(fd,packet_len(0x131)); + memcpy(WFIFOP(fd,0),buf,packet_len(0x131)); + WFIFOSET(fd,packet_len(0x131)); + } else { + clif_send(buf,packet_len(0x131),bl,AREA_WOS); + } } /// Removes a vending board from screen (ZC_DISAPPEAR_ENTRY). /// 0132 .L -void clif_closevendingboard(struct block_list *bl, int fd) +void clif_closevendingboard(struct block_list* bl, int fd) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x132; - WBUFL(buf,2) = bl->id; - if (fd) { - WFIFOHEAD(fd,packet_len(0x132)); - memcpy(WFIFOP(fd,0),buf,packet_len(0x132)); - WFIFOSET(fd,packet_len(0x132)); - } else { - clif_send(buf,packet_len(0x132),bl,AREA_WOS); - } + WBUFW(buf,0) = 0x132; + WBUFL(buf,2) = bl->id; + if( fd ) { + WFIFOHEAD(fd,packet_len(0x132)); + memcpy(WFIFOP(fd,0),buf,packet_len(0x132)); + WFIFOSET(fd,packet_len(0x132)); + } else { + clif_send(buf,packet_len(0x132),bl,AREA_WOS); + } } /// Sends a list of items in a shop. /// R 0133 .W .L { .L .W .W .B .W .B .B .B .W .W .W .W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC) /// R 0800 .W .L .L { .L .W .W .B .W .B .B .B .W .W .W .W }* (ZC_PC_PURCHASE_ITEMLIST_FROMMC2) -void clif_vendinglist(struct map_session_data *sd, int id, struct s_vending *vending) +void clif_vendinglist(struct map_session_data* sd, int id, struct s_vending* vending) { - int i,fd; - int count; - struct map_session_data *vsd; + int i,fd; + int count; + struct map_session_data* vsd; #if PACKETVER < 20100105 - const int cmd = 0x133; - const int offset = 8; + const int cmd = 0x133; + const int offset = 8; #else - const int cmd = 0x800; - const int offset = 12; + const int cmd = 0x800; + const int offset = 12; #endif - nullpo_retv(sd); - nullpo_retv(vending); - nullpo_retv(vsd=map_id2sd(id)); + nullpo_retv(sd); + nullpo_retv(vending); + nullpo_retv(vsd=map_id2sd(id)); - fd = sd->fd; - count = vsd->vend_num; + fd = sd->fd; + count = vsd->vend_num; - WFIFOHEAD(fd, offset+count*22); - WFIFOW(fd,0) = cmd; - WFIFOW(fd,2) = offset+count*22; - WFIFOL(fd,4) = id; + WFIFOHEAD(fd, offset+count*22); + WFIFOW(fd,0) = cmd; + WFIFOW(fd,2) = offset+count*22; + WFIFOL(fd,4) = id; #if PACKETVER >= 20100105 - WFIFOL(fd,8) = vsd->vender_id; + WFIFOL(fd,8) = vsd->vender_id; #endif - for (i = 0; i < count; i++) { - int index = vending[i].index; - struct item_data *data = itemdb_search(vsd->status.cart[index].nameid); - WFIFOL(fd,offset+ 0+i*22) = vending[i].value; - WFIFOW(fd,offset+ 4+i*22) = vending[i].amount; - WFIFOW(fd,offset+ 6+i*22) = vending[i].index + 2; - WFIFOB(fd,offset+ 8+i*22) = itemtype(data->type); - WFIFOW(fd,offset+ 9+i*22) = (data->view_id > 0) ? data->view_id : vsd->status.cart[index].nameid; - WFIFOB(fd,offset+11+i*22) = vsd->status.cart[index].identify; - WFIFOB(fd,offset+12+i*22) = vsd->status.cart[index].attribute; - WFIFOB(fd,offset+13+i*22) = vsd->status.cart[index].refine; - clif_addcards(WFIFOP(fd,offset+14+i*22), &vsd->status.cart[index]); - } - WFIFOSET(fd,WFIFOW(fd,2)); + for( i = 0; i < count; i++ ) + { + int index = vending[i].index; + struct item_data* data = itemdb_search(vsd->status.cart[index].nameid); + WFIFOL(fd,offset+ 0+i*22) = vending[i].value; + WFIFOW(fd,offset+ 4+i*22) = vending[i].amount; + WFIFOW(fd,offset+ 6+i*22) = vending[i].index + 2; + WFIFOB(fd,offset+ 8+i*22) = itemtype(data->type); + WFIFOW(fd,offset+ 9+i*22) = ( data->view_id > 0 ) ? data->view_id : vsd->status.cart[index].nameid; + WFIFOB(fd,offset+11+i*22) = vsd->status.cart[index].identify; + WFIFOB(fd,offset+12+i*22) = vsd->status.cart[index].attribute; + WFIFOB(fd,offset+13+i*22) = vsd->status.cart[index].refine; + clif_addcards(WFIFOP(fd,offset+14+i*22), &vsd->status.cart[index]); + } + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -6088,69 +6148,70 @@ void clif_vendinglist(struct map_session_data *sd, int id, struct s_vending *ven /// 5 = "cannot use an npc shop while in a trade" /// 6 = Because the store information was incorrect the item was not purchased. /// 7 = No sales information. -void clif_buyvending(struct map_session_data *sd, int index, int amount, int fail) +void clif_buyvending(struct map_session_data* sd, int index, int amount, int fail) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x135)); - WFIFOW(fd,0) = 0x135; - WFIFOW(fd,2) = index+2; - WFIFOW(fd,4) = amount; - WFIFOB(fd,6) = fail; - WFIFOSET(fd,packet_len(0x135)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x135)); + WFIFOW(fd,0) = 0x135; + WFIFOW(fd,2) = index+2; + WFIFOW(fd,4) = amount; + WFIFOB(fd,6) = fail; + WFIFOSET(fd,packet_len(0x135)); } /// Shop creation success (ZC_PC_PURCHASE_MYITEMLIST). /// 0136 .W .L { .L .W .W .B .W .B .B .B .W .W .W .W }* -void clif_openvending(struct map_session_data *sd, int id, struct s_vending *vending) -{ - int i,fd; - int count; - - nullpo_retv(sd); - - fd = sd->fd; - count = sd->vend_num; - - WFIFOHEAD(fd, 8+count*22); - WFIFOW(fd,0) = 0x136; - WFIFOW(fd,2) = 8+count*22; - WFIFOL(fd,4) = id; - for (i = 0; i < count; i++) { - int index = vending[i].index; - struct item_data *data = itemdb_search(sd->status.cart[index].nameid); - WFIFOL(fd, 8+i*22) = vending[i].value; - WFIFOW(fd,12+i*22) = vending[i].index + 2; - WFIFOW(fd,14+i*22) = vending[i].amount; - WFIFOB(fd,16+i*22) = itemtype(data->type); - WFIFOW(fd,17+i*22) = (data->view_id > 0) ? data->view_id : sd->status.cart[index].nameid; - WFIFOB(fd,19+i*22) = sd->status.cart[index].identify; - WFIFOB(fd,20+i*22) = sd->status.cart[index].attribute; - WFIFOB(fd,21+i*22) = sd->status.cart[index].refine; - clif_addcards(WFIFOP(fd,22+i*22), &sd->status.cart[index]); - } - WFIFOSET(fd,WFIFOW(fd,2)); +void clif_openvending(struct map_session_data* sd, int id, struct s_vending* vending) +{ + int i,fd; + int count; + + nullpo_retv(sd); + + fd = sd->fd; + count = sd->vend_num; + + WFIFOHEAD(fd, 8+count*22); + WFIFOW(fd,0) = 0x136; + WFIFOW(fd,2) = 8+count*22; + WFIFOL(fd,4) = id; + for( i = 0; i < count; i++ ) + { + int index = vending[i].index; + struct item_data* data = itemdb_search(sd->status.cart[index].nameid); + WFIFOL(fd, 8+i*22) = vending[i].value; + WFIFOW(fd,12+i*22) = vending[i].index + 2; + WFIFOW(fd,14+i*22) = vending[i].amount; + WFIFOB(fd,16+i*22) = itemtype(data->type); + WFIFOW(fd,17+i*22) = ( data->view_id > 0 ) ? data->view_id : sd->status.cart[index].nameid; + WFIFOB(fd,19+i*22) = sd->status.cart[index].identify; + WFIFOB(fd,20+i*22) = sd->status.cart[index].attribute; + WFIFOB(fd,21+i*22) = sd->status.cart[index].refine; + clif_addcards(WFIFOP(fd,22+i*22), &sd->status.cart[index]); + } + WFIFOSET(fd,WFIFOW(fd,2)); } /// Inform merchant that someone has bought an item (ZC_DELETEITEM_FROM_MCSTORE). /// 0137 .W .W -void clif_vendingreport(struct map_session_data *sd, int index, int amount) +void clif_vendingreport(struct map_session_data* sd, int index, int amount) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x137)); - WFIFOW(fd,0) = 0x137; - WFIFOW(fd,2) = index+2; - WFIFOW(fd,4) = amount; - WFIFOSET(fd,packet_len(0x137)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x137)); + WFIFOW(fd,0) = 0x137; + WFIFOW(fd,2) = index+2; + WFIFOW(fd,4) = amount; + WFIFOSET(fd,packet_len(0x137)); } @@ -6164,15 +6225,15 @@ void clif_vendingreport(struct map_session_data *sd, int index, int amount) /// ? = nothing void clif_party_created(struct map_session_data *sd,int result) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xfa)); - WFIFOW(fd,0)=0xfa; - WFIFOB(fd,2)=result; - WFIFOSET(fd,packet_len(0xfa)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xfa)); + WFIFOW(fd,0)=0xfa; + WFIFOB(fd,2)=result; + WFIFOSET(fd,packet_len(0xfa)); } @@ -6187,29 +6248,29 @@ void clif_party_created(struct map_session_data *sd,int result) /// 1 = disconnected void clif_party_member_info(struct party_data *p, struct map_session_data *sd) { - unsigned char buf[81]; - int i; + unsigned char buf[81]; + int i; - if (!sd) { //Pick any party member (this call is used when changing item share rules) - ARR_FIND(0, MAX_PARTY, i, p->data[i].sd != 0); - } else { - ARR_FIND(0, MAX_PARTY, i, p->data[i].sd == sd); - } - if (i >= MAX_PARTY) return; //Should never happen... - sd = p->data[i].sd; + if (!sd) { //Pick any party member (this call is used when changing item share rules) + ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd != 0 ); + } else { + ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd == sd ); + } + if (i >= MAX_PARTY) return; //Should never happen... + sd = p->data[i].sd; - WBUFW(buf, 0) = 0x1e9; - WBUFL(buf, 2) = sd->status.account_id; - WBUFL(buf, 6) = (p->party.member[i].leader)?0:1; - WBUFW(buf,10) = sd->bl.x; - WBUFW(buf,12) = sd->bl.y; - WBUFB(buf,14) = (p->party.member[i].online)?0:1; - memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH); - memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH); - mapindex_getmapname_ext(map[sd->bl.m].name, (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); + WBUFW(buf, 0) = 0x1e9; + WBUFL(buf, 2) = sd->status.account_id; + WBUFL(buf, 6) = (p->party.member[i].leader)?0:1; + WBUFW(buf,10) = sd->bl.x; + WBUFW(buf,12) = sd->bl.y; + WBUFB(buf,14) = (p->party.member[i].online)?0:1; + memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH); + memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH); + mapindex_getmapname_ext(map[sd->bl.m].name, (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); } @@ -6221,36 +6282,37 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd) /// state: /// 0 = connected /// 1 = disconnected -void clif_party_info(struct party_data *p, struct map_session_data *sd) +void 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_EXT+1+1)*MAX_PARTY]; - struct map_session_data *party_sd = NULL; - int i, c; + 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; - nullpo_retv(p); + nullpo_retv(p); - 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; + 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 (party_sd == NULL) party_sd = p->data[i].sd; + if(party_sd == NULL) party_sd = p->data[i].sd; - WBUFL(buf,28+c*46) = m->account_id; - memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH); - 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++; - } - WBUFW(buf,2) = 28+c*46; + WBUFL(buf,28+c*46) = m->account_id; + memcpy(WBUFP(buf,28+c*46+4), m->name, NAME_LENGTH); + 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++; + } + WBUFW(buf,2) = 28+c*46; - if (sd) { // send only to self - clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); - } else if (party_sd) { // send to whole party - clif_send(buf, WBUFW(buf,2), &party_sd->bl, PARTY); - } + if(sd) { // send only to self + clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); + } else if (party_sd) { // send to whole party + clif_send(buf, WBUFW(buf,2), &party_sd->bl, PARTY); + } } @@ -6259,16 +6321,16 @@ void clif_party_info(struct party_data *p, struct map_session_data *sd) /// flag: /// 0 = allow party invites /// 1 = auto-deny party invites -void clif_partyinvitationstate(struct map_session_data *sd) +void clif_partyinvitationstate(struct map_session_data* sd) { - int fd; - nullpo_retv(sd); - fd = sd->fd; + int fd; + nullpo_retv(sd); + fd = sd->fd; - WFIFOHEAD(fd, packet_len(0x2c9)); - WFIFOW(fd, 0) = 0x2c9; - WFIFOB(fd, 2) = 0; // not implemented - WFIFOSET(fd, packet_len(0x2c9)); + WFIFOHEAD(fd, packet_len(0x2c9)); + WFIFOW(fd, 0) = 0x2c9; + WFIFOB(fd, 2) = 0; // not implemented + WFIFOSET(fd, packet_len(0x2c9)); } @@ -6278,26 +6340,26 @@ void clif_partyinvitationstate(struct map_session_data *sd) void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd) { #if PACKETVER < 20070821 - const int cmd = 0xfe; + const int cmd = 0xfe; #else - const int cmd = 0x2c6; + const int cmd = 0x2c6; #endif - int fd; - struct party_data *p; + int fd; + struct party_data *p; - nullpo_retv(sd); - nullpo_retv(tsd); + nullpo_retv(sd); + nullpo_retv(tsd); - fd=tsd->fd; + fd=tsd->fd; - if ((p=party_search(sd->status.party_id))==NULL) - return; + if( (p=party_search(sd->status.party_id))==NULL ) + return; - WFIFOHEAD(fd,packet_len(cmd)); - WFIFOW(fd,0)=cmd; - WFIFOL(fd,2)=sd->status.party_id; - memcpy(WFIFOP(fd,6),p->party.name,NAME_LENGTH); - WFIFOSET(fd,packet_len(cmd)); + WFIFOHEAD(fd,packet_len(cmd)); + WFIFOW(fd,0)=cmd; + WFIFOL(fd,2)=sd->status.party_id; + memcpy(WFIFOP(fd,6),p->party.name,NAME_LENGTH); + WFIFOSET(fd,packet_len(cmd)); } @@ -6313,31 +6375,31 @@ void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd) /// result=7 : char is not online or doesn't exist -> MsgStringTable[71] (since 20070904) /// result=8 : (%s) TODO instance related? -> MsgStringTable[1388] (since 20080527) /// return=9 : TODO map prohibits party joining? -> MsgStringTable[1871] (since 20110205) -void clif_party_inviteack(struct map_session_data *sd, const char *nick, int result) +void clif_party_inviteack(struct map_session_data* sd, const char* nick, int result) { - int fd; - nullpo_retv(sd); - fd=sd->fd; + int fd; + nullpo_retv(sd); + fd=sd->fd; #if PACKETVER < 20070904 - if (result == 7) { - clif_displaymessage(fd, msg_txt(3)); - return; - } + if( result == 7 ) { + clif_displaymessage(fd, msg_txt(3)); + return; + } #endif #if PACKETVER < 20070821 - WFIFOHEAD(fd,packet_len(0xfd)); - WFIFOW(fd,0) = 0xfd; - safestrncpy((char *)WFIFOP(fd,2),nick,NAME_LENGTH); - WFIFOB(fd,26) = result; - WFIFOSET(fd,packet_len(0xfd)); + WFIFOHEAD(fd,packet_len(0xfd)); + WFIFOW(fd,0) = 0xfd; + safestrncpy((char*)WFIFOP(fd,2),nick,NAME_LENGTH); + WFIFOB(fd,26) = result; + WFIFOSET(fd,packet_len(0xfd)); #else - WFIFOHEAD(fd,packet_len(0x2c5)); - WFIFOW(fd,0) = 0x2c5; - safestrncpy((char *)WFIFOP(fd,2),nick,NAME_LENGTH); - WFIFOL(fd,26) = result; - WFIFOSET(fd,packet_len(0x2c5)); + WFIFOHEAD(fd,packet_len(0x2c5)); + WFIFOW(fd,0) = 0x2c5; + safestrncpy((char*)WFIFOP(fd,2),nick,NAME_LENGTH); + WFIFOL(fd,26) = result; + WFIFOSET(fd,packet_len(0x2c5)); #endif } @@ -6355,32 +6417,32 @@ void clif_party_inviteack(struct map_session_data *sd, const char *nick, int res /// 1 = send to sd void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag) { - unsigned char buf[16]; + unsigned char buf[16]; #if PACKETVER < 20090603 - const int cmd = 0x101; + const int cmd = 0x101; #else - const int cmd = 0x7d8; + const int cmd = 0x7d8; #endif - nullpo_retv(p); - - if (!sd && flag==0) { - int i; - for (i=0; idata[i].sd; i++); - if (i < MAX_PARTY) - sd = p->data[i].sd; - } - if (!sd) return; - WBUFW(buf,0)=cmd; - WBUFL(buf,2)=((flag&0x01)?2:p->party.exp); + nullpo_retv(p); + + if(!sd && flag==0){ + int i; + for(i=0;idata[i].sd;i++); + if (i < MAX_PARTY) + sd = p->data[i].sd; + } + if(!sd) return; + WBUFW(buf,0)=cmd; + WBUFL(buf,2)=((flag&0x01)?2:p->party.exp); #if PACKETVER >= 20090603 - WBUFB(buf,6)=(p->party.item&1)?1:0; - WBUFB(buf,7)=(p->party.item&2)?1:0; + WBUFB(buf,6)=(p->party.item&1)?1:0; + WBUFB(buf,7)=(p->party.item&2)?1:0; #endif - if (flag==0) - clif_send(buf,packet_len(cmd),&sd->bl,PARTY); - else - clif_send(buf,packet_len(cmd),&sd->bl,SELF); + if(flag==0) + clif_send(buf,packet_len(cmd),&sd->bl,PARTY); + else + clif_send(buf,packet_len(cmd),&sd->bl,SELF); } @@ -6390,57 +6452,59 @@ void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag /// 1 = expel /// 2 = cannot leave party on this map /// 3 = cannot expel from party on this map -void clif_party_withdraw(struct party_data *p, struct map_session_data *sd, int account_id, const char *name, int flag) +void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag) { - unsigned char buf[64]; - int i; + unsigned char buf[64]; + int i; - nullpo_retv(p); + nullpo_retv(p); - if (!sd && (flag&0xf0)==0) { - for (i=0; idata[i].sd; i++); - if (i < MAX_PARTY) - sd = p->data[i].sd; - } + if(!sd && (flag&0xf0)==0) + { + for(i=0;idata[i].sd;i++); + if (i < MAX_PARTY) + sd = p->data[i].sd; + } - if (!sd) return; + if(!sd) return; - WBUFW(buf,0)=0x105; - WBUFL(buf,2)=account_id; - memcpy(WBUFP(buf,6),name,NAME_LENGTH); - WBUFB(buf,30)=flag&0x0f; - if ((flag&0xf0)==0) - clif_send(buf,packet_len(0x105),&sd->bl,PARTY); - else - clif_send(buf,packet_len(0x105),&sd->bl,SELF); + WBUFW(buf,0)=0x105; + WBUFL(buf,2)=account_id; + memcpy(WBUFP(buf,6),name,NAME_LENGTH); + WBUFB(buf,30)=flag&0x0f; + if((flag&0xf0)==0) + clif_send(buf,packet_len(0x105),&sd->bl,PARTY); + else + clif_send(buf,packet_len(0x105),&sd->bl,SELF); } /// Party chat message (ZC_NOTIFY_CHAT_PARTY). /// 0109 .W .L .?B -void clif_party_message(struct party_data *p, int account_id, const char *mes, int len) +void clif_party_message(struct party_data* p, int account_id, const char* mes, int len) { - struct map_session_data *sd; - int i; + struct map_session_data *sd; + int i; - nullpo_retv(p); + nullpo_retv(p); - for (i=0; i < MAX_PARTY && !p->data[i].sd; i++); - if (i < MAX_PARTY) { - unsigned char buf[1024]; + for(i=0; i < MAX_PARTY && !p->data[i].sd;i++); + if(i < MAX_PARTY){ + unsigned char buf[1024]; - if (len > sizeof(buf)-8) { - ShowWarning("clif_party_message: Truncated message '%s' (len=%d, max=%d, party_id=%d).\n", mes, len, sizeof(buf)-8, p->party.party_id); - len = sizeof(buf)-8; - } + if( len > sizeof(buf)-8 ) + { + ShowWarning("clif_party_message: Truncated message '%s' (len=%d, max=%d, party_id=%d).\n", mes, len, sizeof(buf)-8, p->party.party_id); + len = sizeof(buf)-8; + } - sd = p->data[i].sd; - WBUFW(buf,0)=0x109; - WBUFW(buf,2)=len+8; - WBUFL(buf,4)=account_id; - safestrncpy((char *)WBUFP(buf,8), mes, len); - clif_send(buf,len+8,&sd->bl,PARTY); - } + sd = p->data[i].sd; + WBUFW(buf,0)=0x109; + WBUFW(buf,2)=len+8; + WBUFL(buf,4)=account_id; + safestrncpy(WBUFP(buf,8), mes, len); + clif_send(buf,len+8,&sd->bl,PARTY); + } } @@ -6448,15 +6512,15 @@ void clif_party_message(struct party_data *p, int account_id, const char *mes, i /// 0107 .L .W .W void clif_party_xy(struct map_session_data *sd) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0)=0x107; - WBUFL(buf,2)=sd->status.account_id; - WBUFW(buf,6)=sd->bl.x; - WBUFW(buf,8)=sd->bl.y; - clif_send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS); + WBUFW(buf,0)=0x107; + WBUFL(buf,2)=sd->status.account_id; + WBUFW(buf,6)=sd->bl.x; + WBUFW(buf,8)=sd->bl.y; + clif_send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS); } @@ -6465,12 +6529,12 @@ void clif_party_xy(struct map_session_data *sd) *------------------------------------------*/ void clif_party_xy_single(int fd, struct map_session_data *sd) { - WFIFOHEAD(fd,packet_len(0x107)); - WFIFOW(fd,0)=0x107; - WFIFOL(fd,2)=sd->status.account_id; - WFIFOW(fd,6)=sd->bl.x; - WFIFOW(fd,8)=sd->bl.y; - WFIFOSET(fd,packet_len(0x107)); + WFIFOHEAD(fd,packet_len(0x107)); + WFIFOW(fd,0)=0x107; + WFIFOL(fd,2)=sd->status.account_id; + WFIFOW(fd,6)=sd->bl.x; + WFIFOW(fd,8)=sd->bl.y; + WFIFOSET(fd,packet_len(0x107)); } @@ -6479,30 +6543,30 @@ void clif_party_xy_single(int fd, struct map_session_data *sd) /// 080e .L .L .L (ZC_NOTIFY_HP_TO_GROUPM_R2) void clif_party_hp(struct map_session_data *sd) { - unsigned char buf[16]; + unsigned char buf[16]; #if PACKETVER < 20100126 - const int cmd = 0x106; + const int cmd = 0x106; #else - const int cmd = 0x80e; + const int cmd = 0x80e; #endif - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0)=cmd; - WBUFL(buf,2)=sd->status.account_id; + WBUFW(buf,0)=cmd; + WBUFL(buf,2)=sd->status.account_id; #if PACKETVER < 20100126 - if (sd->battle_status.max_hp > INT16_MAX) { //To correctly display the %hp bar. [Skotlex] - WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100); - WBUFW(buf,8) = 100; - } else { - WBUFW(buf,6) = sd->battle_status.hp; - WBUFW(buf,8) = sd->battle_status.max_hp; - } + if (sd->battle_status.max_hp > INT16_MAX) { //To correctly display the %hp bar. [Skotlex] + WBUFW(buf,6) = sd->battle_status.hp/(sd->battle_status.max_hp/100); + WBUFW(buf,8) = 100; + } else { + WBUFW(buf,6) = sd->battle_status.hp; + WBUFW(buf,8) = sd->battle_status.max_hp; + } #else - WBUFL(buf,6) = sd->battle_status.hp; - WBUFL(buf,10) = sd->battle_status.max_hp; + WBUFL(buf,6) = sd->battle_status.hp; + WBUFL(buf,10) = sd->battle_status.max_hp; #endif - clif_send(buf,packet_len(cmd),&sd->bl,PARTY_AREA_WOS); + clif_send(buf,packet_len(cmd),&sd->bl,PARTY_AREA_WOS); } @@ -6512,48 +6576,48 @@ void clif_party_hp(struct map_session_data *sd) void clif_hpmeter_single(int fd, int id, unsigned int hp, unsigned int maxhp) { #if PACKETVER < 20100126 - const int cmd = 0x106; + const int cmd = 0x106; #else - const int cmd = 0x80e; + const int cmd = 0x80e; #endif - WFIFOHEAD(fd,packet_len(cmd)); - WFIFOW(fd,0) = cmd; - WFIFOL(fd,2) = id; + WFIFOHEAD(fd,packet_len(cmd)); + WFIFOW(fd,0) = cmd; + WFIFOL(fd,2) = id; #if PACKETVER < 20100126 - if (maxhp > INT16_MAX) { - // To correctly display the %hp bar. [Skotlex] - WFIFOW(fd,6) = hp/(maxhp/100); - WFIFOW(fd,8) = 100; - } else { - WFIFOW(fd,6) = hp; - WFIFOW(fd,8) = maxhp; - } + if( maxhp > INT16_MAX ) + {// To correctly display the %hp bar. [Skotlex] + WFIFOW(fd,6) = hp/(maxhp/100); + WFIFOW(fd,8) = 100; + } else { + WFIFOW(fd,6) = hp; + WFIFOW(fd,8) = maxhp; + } #else - WFIFOL(fd,6) = hp; - WFIFOL(fd,10) = maxhp; + WFIFOL(fd,6) = hp; + WFIFOL(fd,10) = maxhp; #endif - WFIFOSET(fd, packet_len(cmd)); + WFIFOSET(fd, packet_len(cmd)); } /// Notifies the client, that it's attack target is too far (ZC_ATTACK_FAILURE_FOR_DISTANCE). /// 0139 .L .W .W .W .W .W void clif_movetoattack(struct map_session_data *sd,struct block_list *bl) { - int fd; + int fd; - nullpo_retv(sd); - nullpo_retv(bl); + nullpo_retv(sd); + nullpo_retv(bl); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x139)); - WFIFOW(fd, 0)=0x139; - WFIFOL(fd, 2)=bl->id; - WFIFOW(fd, 6)=bl->x; - WFIFOW(fd, 8)=bl->y; - WFIFOW(fd,10)=sd->bl.x; - WFIFOW(fd,12)=sd->bl.y; - WFIFOW(fd,14)=sd->battle_status.rhw.range; - WFIFOSET(fd,packet_len(0x139)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x139)); + WFIFOW(fd, 0)=0x139; + WFIFOL(fd, 2)=bl->id; + WFIFOW(fd, 6)=bl->x; + WFIFOW(fd, 8)=bl->y; + WFIFOW(fd,10)=sd->bl.x; + WFIFOW(fd,12)=sd->bl.y; + WFIFOW(fd,14)=sd->battle_status.rhw.range; + WFIFOSET(fd,packet_len(0x139)); } @@ -6564,22 +6628,22 @@ void clif_movetoattack(struct map_session_data *sd,struct block_list *bl) /// 1 = failure /// 2 = success (alchemist) /// 3 = failure (alchemist) -void clif_produceeffect(struct map_session_data *sd,int flag,int nameid) +void clif_produceeffect(struct map_session_data* sd,int flag,int nameid) { - int view,fd; + int view,fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - clif_solved_charname(fd, sd->status.char_id, sd->status.name); - WFIFOHEAD(fd,packet_len(0x18f)); - WFIFOW(fd, 0)=0x18f; - WFIFOW(fd, 2)=flag; - if ((view = itemdb_viewid(nameid)) > 0) - WFIFOW(fd, 4)=view; - else - WFIFOW(fd, 4)=nameid; - WFIFOSET(fd,packet_len(0x18f)); + fd = sd->fd; + clif_solved_charname(fd, sd->status.char_id, sd->status.name); + WFIFOHEAD(fd,packet_len(0x18f)); + WFIFOW(fd, 0)=0x18f; + WFIFOW(fd, 2)=flag; + if((view = itemdb_viewid(nameid)) > 0) + WFIFOW(fd, 4)=view; + else + WFIFOW(fd, 4)=nameid; + WFIFOSET(fd,packet_len(0x18f)); } @@ -6587,14 +6651,14 @@ void clif_produceeffect(struct map_session_data *sd,int flag,int nameid) /// 019e void clif_catch_process(struct map_session_data *sd) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x19e)); - WFIFOW(fd,0)=0x19e; - WFIFOSET(fd,packet_len(0x19e)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x19e)); + WFIFOW(fd,0)=0x19e; + WFIFOSET(fd,packet_len(0x19e)); } @@ -6604,15 +6668,15 @@ void clif_catch_process(struct map_session_data *sd) /// 1 = success void clif_pet_roulette(struct map_session_data *sd,int data) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x1a0)); - WFIFOW(fd,0)=0x1a0; - WFIFOB(fd,2)=data; - WFIFOSET(fd,packet_len(0x1a0)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x1a0)); + WFIFOW(fd,0)=0x1a0; + WFIFOB(fd,2)=data; + WFIFOSET(fd,packet_len(0x1a0)); } @@ -6620,31 +6684,31 @@ void clif_pet_roulette(struct map_session_data *sd,int data) /// 01a6 .W { .W }* void clif_sendegg(struct map_session_data *sd) { - int i,n=0,fd; + int i,n=0,fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m)) { - //Disable pet hatching in GvG grounds during Guild Wars [Skotlex] - clif_displaymessage(fd, msg_txt(666)); - return; - } - WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4); - WFIFOW(fd,0)=0x1a6; - for (i=0,n=0; istatus.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL || - sd->inventory_data[i]->type!=IT_PETEGG || - sd->status.inventory[i].amount<=0) - continue; - WFIFOW(fd,n*2+4)=i+2; - n++; - } - WFIFOW(fd,2)=4+n*2; - WFIFOSET(fd,WFIFOW(fd,2)); + fd=sd->fd; + if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m)) + { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex] + clif_displaymessage(fd, msg_txt(666)); + return; + } + WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4); + WFIFOW(fd,0)=0x1a6; + for(i=0,n=0;istatus.inventory[i].nameid<=0 || sd->inventory_data[i] == NULL || + sd->inventory_data[i]->type!=IT_PETEGG || + sd->status.inventory[i].amount<=0) + continue; + WFIFOW(fd,n*2+4)=i+2; + n++; + } + WFIFOW(fd,2)=4+n*2; + WFIFOSET(fd,WFIFOW(fd,2)); - sd->menuskill_id = SA_TAMINGMONSTER; - sd->menuskill_val = -1; + sd->menuskill_id = SA_TAMINGMONSTER; + sd->menuskill_val = -1; } @@ -6659,19 +6723,19 @@ void clif_sendegg(struct map_session_data *sd) /// 5 = hairstyle /// /// If sd is null, the update is sent to nearby objects, otherwise it is sent only to that player. -void clif_send_petdata(struct map_session_data *sd, struct pet_data *pd, int type, int param) +void clif_send_petdata(struct map_session_data* sd, struct pet_data* pd, int type, int param) { - uint8 buf[16]; - nullpo_retv(pd); + uint8 buf[16]; + nullpo_retv(pd); - WBUFW(buf,0) = 0x1a4; - WBUFB(buf,2) = type; - WBUFL(buf,3) = pd->bl.id; - WBUFL(buf,7) = param; - if (sd) - clif_send(buf, packet_len(0x1a4), &sd->bl, SELF); - else - clif_send(buf, packet_len(0x1a4), &pd->bl, AREA); + WBUFW(buf,0) = 0x1a4; + WBUFB(buf,2) = type; + WBUFL(buf,3) = pd->bl.id; + WBUFL(buf,7) = param; + if (sd) + clif_send(buf, packet_len(0x1a4), &sd->bl, SELF); + else + clif_send(buf, packet_len(0x1a4), &pd->bl, AREA); } @@ -6679,26 +6743,26 @@ void clif_send_petdata(struct map_session_data *sd, struct pet_data *pd, int typ /// 01a2 .24B .B .W .W .W .W .W void clif_send_petstatus(struct map_session_data *sd) { - int fd; - struct s_pet *pet; - - nullpo_retv(sd); - nullpo_retv(sd->pd); - - fd=sd->fd; - pet = &sd->pd->pet; - WFIFOHEAD(fd,packet_len(0x1a2)); - WFIFOW(fd,0)=0x1a2; - memcpy(WFIFOP(fd,2),pet->name,NAME_LENGTH); - WFIFOB(fd,26)=battle_config.pet_rename?0:pet->rename_flag; - WFIFOW(fd,27)=pet->level; - WFIFOW(fd,29)=pet->hungry; - WFIFOW(fd,31)=pet->intimate; - WFIFOW(fd,33)=pet->equip; + int fd; + struct s_pet *pet; + + nullpo_retv(sd); + nullpo_retv(sd->pd); + + fd=sd->fd; + pet = &sd->pd->pet; + WFIFOHEAD(fd,packet_len(0x1a2)); + WFIFOW(fd,0)=0x1a2; + memcpy(WFIFOP(fd,2),pet->name,NAME_LENGTH); + WFIFOB(fd,26)=battle_config.pet_rename?0:pet->rename_flag; + WFIFOW(fd,27)=pet->level; + WFIFOW(fd,29)=pet->hungry; + WFIFOW(fd,31)=pet->intimate; + WFIFOW(fd,33)=pet->equip; #if PACKETVER >= 20081126 - WFIFOW(fd,35)=pet->class_; + WFIFOW(fd,35)=pet->class_; #endif - WFIFOSET(fd,packet_len(0x1a2)); + WFIFOSET(fd,packet_len(0x1a2)); } @@ -6708,26 +6772,26 @@ void clif_send_petstatus(struct map_session_data *sd) /// @see CZ_PET_ACT. void clif_pet_emotion(struct pet_data *pd,int param) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(pd); + nullpo_retv(pd); - memset(buf,0,packet_len(0x1aa)); + memset(buf,0,packet_len(0x1aa)); - WBUFW(buf,0)=0x1aa; - WBUFL(buf,2)=pd->bl.id; - if (param >= 100 && pd->petDB->talk_convert_class) { - if (pd->petDB->talk_convert_class < 0) - return; - else if (pd->petDB->talk_convert_class > 0) { - // replace mob_id component of talk/act data - param -= (pd->pet.class_ - 100)*100; - param += (pd->petDB->talk_convert_class - 100)*100; - } - } - WBUFL(buf,6)=param; + WBUFW(buf,0)=0x1aa; + WBUFL(buf,2)=pd->bl.id; + if(param >= 100 && pd->petDB->talk_convert_class) { + if(pd->petDB->talk_convert_class < 0) + return; + else if(pd->petDB->talk_convert_class > 0) { + // replace mob_id component of talk/act data + param -= (pd->pet.class_ - 100)*100; + param += (pd->petDB->talk_convert_class - 100)*100; + } + } + WBUFL(buf,6)=param; - clif_send(buf,packet_len(0x1aa),&pd->bl,AREA); + clif_send(buf,packet_len(0x1aa),&pd->bl,AREA); } @@ -6738,16 +6802,16 @@ void clif_pet_emotion(struct pet_data *pd,int param) /// 1 = success void clif_pet_food(struct map_session_data *sd,int foodid,int fail) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x1a3)); - WFIFOW(fd,0)=0x1a3; - WFIFOB(fd,2)=fail; - WFIFOW(fd,3)=foodid; - WFIFOSET(fd,packet_len(0x1a3)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x1a3)); + WFIFOW(fd,0)=0x1a3; + WFIFOB(fd,2)=fail; + WFIFOW(fd,3)=foodid; + WFIFOSET(fd,packet_len(0x1a3)); } @@ -6755,46 +6819,46 @@ void clif_pet_food(struct map_session_data *sd,int foodid,int fail) /// 01cd { .L }*7 void clif_autospell(struct map_session_data *sd,int skilllv) { - int fd; - - nullpo_retv(sd); - - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x1cd)); - WFIFOW(fd, 0)=0x1cd; - - if (skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0) - WFIFOL(fd,2)= MG_NAPALMBEAT; - else - WFIFOL(fd,2)= 0x00000000; - if (skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0) - WFIFOL(fd,6)= MG_COLDBOLT; - else - WFIFOL(fd,6)= 0x00000000; - if (skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0) - WFIFOL(fd,10)= MG_FIREBOLT; - else - WFIFOL(fd,10)= 0x00000000; - if (skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0) - WFIFOL(fd,14)= MG_LIGHTNINGBOLT; - else - WFIFOL(fd,14)= 0x00000000; - if (skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0) - WFIFOL(fd,18)= MG_SOULSTRIKE; - else - WFIFOL(fd,18)= 0x00000000; - if (skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0) - WFIFOL(fd,22)= MG_FIREBALL; - else - WFIFOL(fd,22)= 0x00000000; - if (skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0) - WFIFOL(fd,26)= MG_FROSTDIVER; - else - WFIFOL(fd,26)= 0x00000000; - - WFIFOSET(fd,packet_len(0x1cd)); - sd->menuskill_id = SA_AUTOSPELL; - sd->menuskill_val = skilllv; + int fd; + + nullpo_retv(sd); + + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x1cd)); + WFIFOW(fd, 0)=0x1cd; + + if(skilllv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0) + WFIFOL(fd,2)= MG_NAPALMBEAT; + else + WFIFOL(fd,2)= 0x00000000; + if(skilllv>1 && pc_checkskill(sd,MG_COLDBOLT)>0) + WFIFOL(fd,6)= MG_COLDBOLT; + else + WFIFOL(fd,6)= 0x00000000; + if(skilllv>1 && pc_checkskill(sd,MG_FIREBOLT)>0) + WFIFOL(fd,10)= MG_FIREBOLT; + else + WFIFOL(fd,10)= 0x00000000; + if(skilllv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0) + WFIFOL(fd,14)= MG_LIGHTNINGBOLT; + else + WFIFOL(fd,14)= 0x00000000; + if(skilllv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0) + WFIFOL(fd,18)= MG_SOULSTRIKE; + else + WFIFOL(fd,18)= 0x00000000; + if(skilllv>7 && pc_checkskill(sd,MG_FIREBALL)>0) + WFIFOL(fd,22)= MG_FIREBALL; + else + WFIFOL(fd,22)= 0x00000000; + if(skilllv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0) + WFIFOL(fd,26)= MG_FROSTDIVER; + else + WFIFOL(fd,26)= 0x00000000; + + WFIFOSET(fd,packet_len(0x1cd)); + sd->menuskill_id = SA_AUTOSPELL; + sd->menuskill_val = skilllv; } @@ -6802,34 +6866,37 @@ void clif_autospell(struct map_session_data *sd,int skilllv) /// 01cf .L { .L }*5 .W void clif_devotion(struct block_list *src, struct map_session_data *tsd) { - unsigned char buf[56]; - int i; + unsigned char buf[56]; + int i; - nullpo_retv(src); - memset(buf,0,packet_len(0x1cf)); + nullpo_retv(src); + memset(buf,0,packet_len(0x1cf)); - WBUFW(buf,0) = 0x1cf; - WBUFL(buf,2) = src->id; - if (src->type == BL_MER) { - struct mercenary_data *md = BL_CAST(BL_MER,src); - if (md && md->master && md->devotion_flag) - WBUFL(buf,6) = md->master->bl.id; + WBUFW(buf,0) = 0x1cf; + WBUFL(buf,2) = src->id; + if( src->type == BL_MER ) + { + struct mercenary_data *md = BL_CAST(BL_MER,src); + if( md && md->master && md->devotion_flag ) + WBUFL(buf,6) = md->master->bl.id; - WBUFW(buf,26) = skill_get_range2(src, ML_DEVOTION, mercenary_checkskill(md, ML_DEVOTION)); - } else { - struct map_session_data *sd = BL_CAST(BL_PC,src); - if (sd == NULL) - return; + WBUFW(buf,26) = skill_get_range2(src, ML_DEVOTION, mercenary_checkskill(md, ML_DEVOTION)); + } + else + { + struct map_session_data *sd = BL_CAST(BL_PC,src); + if( sd == NULL ) + return; - for (i = 0; i < 5; i++) - WBUFL(buf,6+4*i) = sd->devotion[i]; - WBUFW(buf,26) = skill_get_range2(src, CR_DEVOTION, pc_checkskill(sd, CR_DEVOTION)); - } + for( i = 0; i < 5; i++ ) + WBUFL(buf,6+4*i) = sd->devotion[i]; + WBUFW(buf,26) = skill_get_range2(src, CR_DEVOTION, pc_checkskill(sd, CR_DEVOTION)); + } - if (tsd) - clif_send(buf, packet_len(0x1cf), &tsd->bl, SELF); - else - clif_send(buf, packet_len(0x1cf), src, AREA); + if( tsd ) + clif_send(buf, packet_len(0x1cf), &tsd->bl, SELF); + else + clif_send(buf, packet_len(0x1cf), src, AREA); } /*========================================== @@ -6838,8 +6905,7 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd) * 01d0 .L .W (ZC_SPIRITS) * 01e1 .L .W (ZC_SPIRITS2) *------------------------------------------*/ -void clif_spiritball(struct block_list *bl) -{ +void clif_spiritball(struct block_list *bl) { unsigned char buf[16]; TBL_PC *sd = BL_CAST(BL_PC,bl); TBL_HOM *hd = BL_CAST(BL_HOM,bl); @@ -6848,14 +6914,10 @@ void clif_spiritball(struct block_list *bl) WBUFW(buf, 0) = 0x1d0; WBUFL(buf, 2) = bl->id; - WBUFW(buf, 6) = 0; //init to 0 - switch (bl->type) { - case BL_PC: - WBUFW(buf, 6) = sd->spiritball; - break; - case BL_HOM: - WBUFW(buf, 6) = hd->spiritball; - break; + WBUFW(buf, 6) = 0; //init to 0 + switch(bl->type){ + case BL_PC: WBUFW(buf, 6) = sd->spiritball; break; + case BL_HOM: WBUFW(buf, 6) = hd->spiritball; break; } clif_send(buf, packet_len(0x1d0), bl, AREA); } @@ -6865,14 +6927,14 @@ void clif_spiritball(struct block_list *bl) /// 01d2 .L .L void clif_combo_delay(struct block_list *bl,int wait) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0)=0x1d2; - WBUFL(buf,2)=bl->id; - WBUFL(buf,6)=wait; - clif_send(buf,packet_len(0x1d2),bl,AREA); + WBUFW(buf,0)=0x1d2; + WBUFL(buf,2)=bl->id; + WBUFL(buf,6)=wait; + clif_send(buf,packet_len(0x1d2),bl,AREA); } @@ -6883,16 +6945,16 @@ void clif_combo_delay(struct block_list *bl,int wait) /// 1 = active void clif_bladestop(struct block_list *src, int dst_id, int active) { - unsigned char buf[32]; + unsigned char buf[32]; - nullpo_retv(src); + nullpo_retv(src); - WBUFW(buf,0)=0x1d1; - WBUFL(buf,2)=src->id; - WBUFL(buf,6)=dst_id; - WBUFL(buf,10)=active; + WBUFW(buf,0)=0x1d1; + WBUFL(buf,2)=src->id; + WBUFL(buf,6)=dst_id; + WBUFL(buf,10)=active; - clif_send(buf,packet_len(0x1d1),src,AREA); + clif_send(buf,packet_len(0x1d1),src,AREA); } @@ -6900,13 +6962,13 @@ void clif_bladestop(struct block_list *src, int dst_id, int active) /// 010c .L void clif_mvp_effect(struct map_session_data *sd) { - unsigned char buf[16]; + unsigned char buf[16]; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0)=0x10c; - WBUFL(buf,2)=sd->bl.id; - clif_send(buf,packet_len(0x10c),&sd->bl,AREA); + WBUFW(buf,0)=0x10c; + WBUFL(buf,2)=sd->bl.id; + clif_send(buf,packet_len(0x10c),&sd->bl,AREA); } @@ -6914,18 +6976,18 @@ void clif_mvp_effect(struct map_session_data *sd) /// 010a .W void clif_mvp_item(struct map_session_data *sd,int nameid) { - int view,fd; + int view,fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x10a)); - WFIFOW(fd,0)=0x10a; - if ((view = itemdb_viewid(nameid)) > 0) - WFIFOW(fd,2)=view; - else - WFIFOW(fd,2)=nameid; - WFIFOSET(fd,packet_len(0x10a)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x10a)); + WFIFOW(fd,0)=0x10a; + if((view = itemdb_viewid(nameid)) > 0) + WFIFOW(fd,2)=view; + else + WFIFOW(fd,2)=nameid; + WFIFOSET(fd,packet_len(0x10a)); } @@ -6933,15 +6995,15 @@ void clif_mvp_item(struct map_session_data *sd,int nameid) /// 010b .L void clif_mvp_exp(struct map_session_data *sd, unsigned int exp) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x10b)); - WFIFOW(fd,0)=0x10b; - WFIFOL(fd,2)=cap_value(exp,0,INT32_MAX); - WFIFOSET(fd,packet_len(0x10b)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x10b)); + WFIFOW(fd,0)=0x10b; + WFIFOL(fd,2)=cap_value(exp,0,INT32_MAX); + WFIFOSET(fd,packet_len(0x10b)); } @@ -6950,13 +7012,13 @@ void clif_mvp_exp(struct map_session_data *sd, unsigned int exp) /// /// "You are the MVP, but cannot obtain the reward because /// you are overweight." -void clif_mvp_noitem(struct map_session_data *sd) +void clif_mvp_noitem(struct map_session_data* sd) { - int fd = sd->fd; + int fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x10d)); - WFIFOW(fd,0) = 0x10d; - WFIFOSET(fd,packet_len(0x10d)); + WFIFOHEAD(fd,packet_len(0x10d)); + WFIFOW(fd,0) = 0x10d; + WFIFOSET(fd,packet_len(0x10d)); } @@ -6969,15 +7031,15 @@ void clif_mvp_noitem(struct map_session_data *sd) /// 3 = "You need the neccessary item to create a Guild." void clif_guild_created(struct map_session_data *sd,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x167)); - WFIFOW(fd,0)=0x167; - WFIFOB(fd,2)=flag; - WFIFOSET(fd,packet_len(0x167)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x167)); + WFIFOW(fd,0)=0x167; + WFIFOB(fd,2)=flag; + WFIFOSET(fd,packet_len(0x167)); } @@ -6988,21 +7050,21 @@ void clif_guild_created(struct map_session_data *sd,int flag) /// &0x10 = allow expel void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g) { - int ps,fd; - nullpo_retv(sd); - nullpo_retv(g); + int ps,fd; + nullpo_retv(sd); + nullpo_retv(g); - fd=sd->fd; - ps=guild_getposition(g,sd); - WFIFOHEAD(fd,packet_len(0x16c)); - WFIFOW(fd,0)=0x16c; - WFIFOL(fd,2)=g->guild_id; - WFIFOL(fd,6)=g->emblem_id; - WFIFOL(fd,10)=g->position[ps].mode; - WFIFOB(fd,14)=(bool)(sd->state.gmaster_flag==g); - WFIFOL(fd,15)=0; // InterSID (unknown purpose) - memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH); - WFIFOSET(fd,packet_len(0x16c)); + fd=sd->fd; + ps=guild_getposition(g,sd); + WFIFOHEAD(fd,packet_len(0x16c)); + WFIFOW(fd,0)=0x16c; + WFIFOL(fd,2)=g->guild_id; + WFIFOL(fd,6)=g->emblem_id; + WFIFOL(fd,10)=g->position[ps].mode; + WFIFOB(fd,14)=(bool)(sd->state.gmaster_flag==g); + WFIFOL(fd,15)=0; // InterSID (unknown purpose) + memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH); + WFIFOSET(fd,packet_len(0x16c)); } @@ -7014,27 +7076,30 @@ void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g) /// 1 = online void clif_guild_memberlogin_notice(struct guild *g,int idx,int flag) { - unsigned char buf[64]; - struct map_session_data *sd; - - nullpo_retv(g); - - WBUFW(buf, 0)=0x1f2; - WBUFL(buf, 2)=g->member[idx].account_id; - WBUFL(buf, 6)=g->member[idx].char_id; - WBUFL(buf,10)=flag; - - if ((sd = g->member[idx].sd) != NULL) { - WBUFW(buf,14) = sd->status.sex; - WBUFW(buf,16) = sd->status.hair; - WBUFW(buf,18) = sd->status.hair_color; - clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD_WOS); - } else if ((sd = guild_getavailablesd(g)) != NULL) { - WBUFW(buf,14) = 0; - WBUFW(buf,16) = 0; - WBUFW(buf,18) = 0; - clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD); - } + unsigned char buf[64]; + struct map_session_data* sd; + + nullpo_retv(g); + + WBUFW(buf, 0)=0x1f2; + WBUFL(buf, 2)=g->member[idx].account_id; + WBUFL(buf, 6)=g->member[idx].char_id; + WBUFL(buf,10)=flag; + + if( ( sd = g->member[idx].sd ) != NULL ) + { + WBUFW(buf,14) = sd->status.sex; + WBUFW(buf,16) = sd->status.hair; + WBUFW(buf,18) = sd->status.hair_color; + clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD_WOS); + } + else if( ( sd = guild_getavailablesd(g) ) != NULL ) + { + WBUFW(buf,14) = 0; + WBUFW(buf,16) = 0; + WBUFW(buf,18) = 0; + clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD); + } } // Function `clif_guild_memberlogin_notice` sends info about @@ -7048,31 +7113,31 @@ void clif_guild_memberlogin_notice(struct guild *g,int idx,int flag) // to economize traffic. [LuzZza] void clif_guild_send_onlineinfo(struct map_session_data *sd) { - struct guild *g; - unsigned char buf[14*128]; - int i, count=0, p_len; + struct guild *g; + unsigned char buf[14*128]; + int i, count=0, p_len; - nullpo_retv(sd); + nullpo_retv(sd); - p_len = packet_len(0x16d); + p_len = packet_len(0x16d); - if (!(g = guild_search(sd->status.guild_id))) - return; + if(!(g = guild_search(sd->status.guild_id))) + return; - for (i=0; imax_member; i++) { + for(i=0; imax_member; i++) { - if (g->member[i].account_id > 0 && - g->member[i].account_id != sd->status.account_id) { + if(g->member[i].account_id > 0 && + g->member[i].account_id != sd->status.account_id) { - WBUFW(buf,count*p_len) = 0x16d; - WBUFL(buf,count*p_len+2) = g->member[i].account_id; - WBUFL(buf,count*p_len+6) = g->member[i].char_id; - WBUFL(buf,count*p_len+10) = g->member[i].online; - count++; - } - } + WBUFW(buf,count*p_len) = 0x16d; + WBUFL(buf,count*p_len+2) = g->member[i].account_id; + WBUFL(buf,count*p_len+6) = g->member[i].char_id; + WBUFL(buf,count*p_len+10) = g->member[i].online; + count++; + } + } - clif_send(buf, p_len*count, &sd->bl, SELF); + clif_send(buf, p_len*count, &sd->bl, SELF); } @@ -7088,52 +7153,51 @@ void clif_guild_send_onlineinfo(struct map_session_data *sd) /// &0x80 = Notice void clif_guild_masterormember(struct map_session_data *sd) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x14e)); - WFIFOW(fd,0) = 0x14e; - WFIFOL(fd,2) = (sd->state.gmaster_flag) ? 0xd7 : 0x57; - WFIFOSET(fd,packet_len(0x14e)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x14e)); + WFIFOW(fd,0) = 0x14e; + WFIFOL(fd,2) = (sd->state.gmaster_flag) ? 0xd7 : 0x57; + WFIFOSET(fd,packet_len(0x14e)); } /// Guild basic information (Territories [Valaris]) /// 0150 .L .L .L .L .L .L .L .L .L .L .24B .24B .16B (ZC_GUILD_INFO) /// 01b6 .L .L .L .L .L .L .L .L .L .L .24B .24B .16B .L (ZC_GUILD_INFO2) -void clif_guild_basicinfo(struct map_session_data *sd) -{ - int fd; - struct guild *g; +void clif_guild_basicinfo(struct map_session_data *sd) { + int fd; + struct guild *g; - nullpo_retv(sd); - fd = sd->fd; + nullpo_retv(sd); + fd = sd->fd; - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; - WFIFOHEAD(fd,packet_len(0x1b6)); - WFIFOW(fd, 0)=0x1b6;//0x150; - WFIFOL(fd, 2)=g->guild_id; - WFIFOL(fd, 6)=g->guild_lv; - WFIFOL(fd,10)=g->connect_member; - WFIFOL(fd,14)=g->max_member; - WFIFOL(fd,18)=g->average_lv; - WFIFOL(fd,22)=(uint32)cap_value(g->exp,0,INT32_MAX); - WFIFOL(fd,26)=g->next_exp; - WFIFOL(fd,30)=0; // Tax Points - WFIFOL(fd,34)=0; // Honor: (left) Vulgar [-100,100] Famed (right) - WFIFOL(fd,38)=0; // Virtue: (down) Wicked [-100,100] Righteous (up) - WFIFOL(fd,42)=g->emblem_id; - memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH); - memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH); + WFIFOHEAD(fd,packet_len(0x1b6)); + WFIFOW(fd, 0)=0x1b6;//0x150; + WFIFOL(fd, 2)=g->guild_id; + WFIFOL(fd, 6)=g->guild_lv; + WFIFOL(fd,10)=g->connect_member; + WFIFOL(fd,14)=g->max_member; + WFIFOL(fd,18)=g->average_lv; + WFIFOL(fd,22)=(uint32)cap_value(g->exp,0,INT32_MAX); + WFIFOL(fd,26)=g->next_exp; + WFIFOL(fd,30)=0; // Tax Points + WFIFOL(fd,34)=0; // Honor: (left) Vulgar [-100,100] Famed (right) + WFIFOL(fd,38)=0; // Virtue: (down) Wicked [-100,100] Righteous (up) + WFIFOL(fd,42)=g->emblem_id; + memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH); + memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH); - safestrncpy((char *)WFIFOP(fd,94),msg_txt(300+guild_checkcastles(g)),16); // "'N' castles" - WFIFOL(fd,110) = 0; // zeny + safestrncpy((char*)WFIFOP(fd,94),msg_txt(300+guild_checkcastles(g)),16); // "'N' castles" + WFIFOL(fd,110) = 0; // zeny - WFIFOSET(fd,packet_len(0x1b6)); + WFIFOSET(fd,packet_len(0x1b6)); } @@ -7141,27 +7205,27 @@ void clif_guild_basicinfo(struct map_session_data *sd) /// 014c .W { .L .L .24B }* void clif_guild_allianceinfo(struct map_session_data *sd) { - int fd,i,c; - struct guild *g; + int fd,i,c; + struct guild *g; - nullpo_retv(sd); - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; - - fd = sd->fd; - WFIFOHEAD(fd, MAX_GUILDALLIANCE * 32 + 4); - WFIFOW(fd, 0)=0x14c; - for (i=c=0; ialliance[i]; - if (a->guild_id>0) { - WFIFOL(fd,c*32+4)=a->opposition; - WFIFOL(fd,c*32+8)=a->guild_id; - memcpy(WFIFOP(fd,c*32+12),a->name,NAME_LENGTH); - c++; - } - } - WFIFOW(fd, 2)=c*32+4; - WFIFOSET(fd,WFIFOW(fd,2)); + nullpo_retv(sd); + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; + + fd = sd->fd; + WFIFOHEAD(fd, MAX_GUILDALLIANCE * 32 + 4); + WFIFOW(fd, 0)=0x14c; + for(i=c=0;ialliance[i]; + if(a->guild_id>0){ + WFIFOL(fd,c*32+4)=a->opposition; + WFIFOL(fd,c*32+8)=a->guild_id; + memcpy(WFIFOP(fd,c*32+12),a->name,NAME_LENGTH); + c++; + } + } + WFIFOW(fd, 2)=c*32+4; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -7174,38 +7238,38 @@ void clif_guild_allianceinfo(struct map_session_data *sd) /// probably member's self-introduction (unused, no client UI/packets for editing it) void clif_guild_memberlist(struct map_session_data *sd) { - int fd; - int i,c; - struct guild *g; - nullpo_retv(sd); - - if ((fd = sd->fd) == 0) - return; - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; - - WFIFOHEAD(fd, g->max_member * 104 + 4); - WFIFOW(fd, 0)=0x154; - for (i=0,c=0; imax_member; i++) { - struct guild_member *m=&g->member[i]; - if (m->account_id==0) - continue; - WFIFOL(fd,c*104+ 4)=m->account_id; - WFIFOL(fd,c*104+ 8)=m->char_id; - WFIFOW(fd,c*104+12)=m->hair; - WFIFOW(fd,c*104+14)=m->hair_color; - WFIFOW(fd,c*104+16)=m->gender; - WFIFOW(fd,c*104+18)=m->class_; - WFIFOW(fd,c*104+20)=m->lv; - WFIFOL(fd,c*104+22)=(int)cap_value(m->exp,0,INT32_MAX); - WFIFOL(fd,c*104+26)=m->online; - WFIFOL(fd,c*104+30)=m->position; - memset(WFIFOP(fd,c*104+34),0,50); //[Ind] - This is displayed in the 'note' column but being you can't edit it it's sent empty. - memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH); - c++; - } - WFIFOW(fd, 2)=c*104+4; - WFIFOSET(fd,WFIFOW(fd,2)); + int fd; + int i,c; + struct guild *g; + nullpo_retv(sd); + + if( (fd = sd->fd) == 0 ) + return; + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; + + WFIFOHEAD(fd, g->max_member * 104 + 4); + WFIFOW(fd, 0)=0x154; + for(i=0,c=0;imax_member;i++){ + struct guild_member *m=&g->member[i]; + if(m->account_id==0) + continue; + WFIFOL(fd,c*104+ 4)=m->account_id; + WFIFOL(fd,c*104+ 8)=m->char_id; + WFIFOW(fd,c*104+12)=m->hair; + WFIFOW(fd,c*104+14)=m->hair_color; + WFIFOW(fd,c*104+16)=m->gender; + WFIFOW(fd,c*104+18)=m->class_; + WFIFOW(fd,c*104+20)=m->lv; + WFIFOL(fd,c*104+22)=(int)cap_value(m->exp,0,INT32_MAX); + WFIFOL(fd,c*104+26)=m->online; + WFIFOL(fd,c*104+30)=m->position; + memset(WFIFOP(fd,c*104+34),0,50); //[Ind] - This is displayed in the 'note' column but being you can't edit it it's sent empty. + memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH); + c++; + } + WFIFOW(fd, 2)=c*104+4; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -7213,22 +7277,22 @@ void clif_guild_memberlist(struct map_session_data *sd) /// 0166 .W { .L .24B }* void clif_guild_positionnamelist(struct map_session_data *sd) { - int i,fd; - struct guild *g; + int i,fd; + struct guild *g; - nullpo_retv(sd); - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; - - fd = sd->fd; - WFIFOHEAD(fd, MAX_GUILDPOSITION * 28 + 4); - WFIFOW(fd, 0)=0x166; - for (i=0; iposition[i].name,NAME_LENGTH); - } - WFIFOW(fd,2)=i*28+4; - WFIFOSET(fd,WFIFOW(fd,2)); + nullpo_retv(sd); + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; + + fd = sd->fd; + WFIFOHEAD(fd, MAX_GUILDPOSITION * 28 + 4); + WFIFOW(fd, 0)=0x166; + for(i=0;iposition[i].name,NAME_LENGTH); + } + WFIFOW(fd,2)=i*28+4; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -7241,25 +7305,25 @@ void clif_guild_positionnamelist(struct map_session_data *sd) /// TODO void clif_guild_positioninfolist(struct map_session_data *sd) { - int i,fd; - struct guild *g; + int i,fd; + struct guild *g; - nullpo_retv(sd); - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; - - fd = sd->fd; - WFIFOHEAD(fd, MAX_GUILDPOSITION * 16 + 4); - WFIFOW(fd, 0)=0x160; - for (i=0; iposition[i]; - WFIFOL(fd,i*16+ 4)=i; - WFIFOL(fd,i*16+ 8)=p->mode; - WFIFOL(fd,i*16+12)=i; - WFIFOL(fd,i*16+16)=p->exp_mode; - } - WFIFOW(fd, 2)=i*16+4; - WFIFOSET(fd,WFIFOW(fd,2)); + nullpo_retv(sd); + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; + + fd = sd->fd; + WFIFOHEAD(fd, MAX_GUILDPOSITION * 16 + 4); + WFIFOW(fd, 0)=0x160; + for(i=0;iposition[i]; + WFIFOL(fd,i*16+ 4)=i; + WFIFOL(fd,i*16+ 8)=p->mode; + WFIFOL(fd,i*16+12)=i; + WFIFOL(fd,i*16+16)=p->exp_mode; + } + WFIFOW(fd, 2)=i*16+4; + WFIFOSET(fd,WFIFOW(fd,2)); } @@ -7272,25 +7336,25 @@ void clif_guild_positioninfolist(struct map_session_data *sd) /// TODO void clif_guild_positionchanged(struct guild *g,int idx) { - // FIXME: This packet is intended to update the clients after a - // commit of position info changes, not sending one packet per - // position. - struct map_session_data *sd; - unsigned char buf[128]; + // FIXME: This packet is intended to update the clients after a + // commit of position info changes, not sending one packet per + // position. + struct map_session_data *sd; + unsigned char buf[128]; - nullpo_retv(g); + nullpo_retv(g); - WBUFW(buf, 0)=0x174; - WBUFW(buf, 2)=44; // packet len - // GUILD_REG_POSITION_INFO{ - WBUFL(buf, 4)=idx; - WBUFL(buf, 8)=g->position[idx].mode; - WBUFL(buf,12)=idx; - WBUFL(buf,16)=g->position[idx].exp_mode; - memcpy(WBUFP(buf,20),g->position[idx].name,NAME_LENGTH); - // }* - if ((sd=guild_getavailablesd(g))!=NULL) - clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD); + WBUFW(buf, 0)=0x174; + WBUFW(buf, 2)=44; // packet len + // GUILD_REG_POSITION_INFO{ + WBUFL(buf, 4)=idx; + WBUFL(buf, 8)=g->position[idx].mode; + WBUFL(buf,12)=idx; + WBUFL(buf,16)=g->position[idx].exp_mode; + memcpy(WBUFP(buf,20),g->position[idx].name,NAME_LENGTH); + // }* + if( (sd=guild_getavailablesd(g))!=NULL ) + clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD); } @@ -7298,23 +7362,23 @@ void clif_guild_positionchanged(struct guild *g,int idx) /// 0156 .W { .L .L .L }* void clif_guild_memberpositionchanged(struct guild *g,int idx) { - // FIXME: This packet is intended to update the clients after a - // commit of member position assignment changes, not sending one - // packet per position. - struct map_session_data *sd; - unsigned char buf[64]; + // FIXME: This packet is intended to update the clients after a + // commit of member position assignment changes, not sending one + // packet per position. + struct map_session_data *sd; + unsigned char buf[64]; - nullpo_retv(g); + nullpo_retv(g); - WBUFW(buf, 0)=0x156; - WBUFW(buf, 2)=16; // packet len - // MEMBER_POSITION_INFO{ - WBUFL(buf, 4)=g->member[idx].account_id; - WBUFL(buf, 8)=g->member[idx].char_id; - WBUFL(buf,12)=g->member[idx].position; - // }* - if ((sd=guild_getavailablesd(g))!=NULL) - clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD); + WBUFW(buf, 0)=0x156; + WBUFW(buf, 2)=16; // packet len + // MEMBER_POSITION_INFO{ + WBUFL(buf, 4)=g->member[idx].account_id; + WBUFL(buf, 8)=g->member[idx].char_id; + WBUFL(buf,12)=g->member[idx].position; + // }* + if( (sd=guild_getavailablesd(g))!=NULL ) + clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD); } @@ -7322,99 +7386,101 @@ void clif_guild_memberpositionchanged(struct guild *g,int idx) /// 0152 .W .L .L .?B void clif_guild_emblem(struct map_session_data *sd,struct guild *g) { - int fd; - nullpo_retv(sd); - nullpo_retv(g); + int fd; + nullpo_retv(sd); + nullpo_retv(g); - fd = sd->fd; - if (g->emblem_len <= 0) - return; + fd = sd->fd; + if( g->emblem_len <= 0 ) + return; - WFIFOHEAD(fd,g->emblem_len+12); - WFIFOW(fd,0)=0x152; - WFIFOW(fd,2)=g->emblem_len+12; - WFIFOL(fd,4)=g->guild_id; - WFIFOL(fd,8)=g->emblem_id; - memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len); - WFIFOSET(fd,WFIFOW(fd,2)); + WFIFOHEAD(fd,g->emblem_len+12); + WFIFOW(fd,0)=0x152; + WFIFOW(fd,2)=g->emblem_len+12; + WFIFOL(fd,4)=g->guild_id; + WFIFOL(fd,8)=g->emblem_id; + memcpy(WFIFOP(fd,12),g->emblem_data,g->emblem_len); + WFIFOSET(fd,WFIFOW(fd,2)); } /// Sends update of the guild id/emblem id to everyone in the area (ZC_CHANGE_GUILD). /// 01b4 .L .L .W -void clif_guild_emblem_area(struct block_list *bl) +void clif_guild_emblem_area(struct block_list* bl) { - uint8 buf[12]; + uint8 buf[12]; - nullpo_retv(bl); + nullpo_retv(bl); - // TODO this packet doesn't force the update of ui components that have the emblem visible - // (emblem in the flag npcs and emblem over the head in agit maps) [FlavioJS] - WBUFW(buf,0) = 0x1b4; - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = status_get_guild_id(bl); - WBUFW(buf,10) = status_get_emblem_id(bl); - clif_send(buf, 12, bl, AREA_WOS); + // TODO this packet doesn't force the update of ui components that have the emblem visible + // (emblem in the flag npcs and emblem over the head in agit maps) [FlavioJS] + WBUFW(buf,0) = 0x1b4; + WBUFL(buf,2) = bl->id; + WBUFL(buf,6) = status_get_guild_id(bl); + WBUFW(buf,10) = status_get_emblem_id(bl); + clif_send(buf, 12, bl, AREA_WOS); } /// Sends guild skills (ZC_GUILD_SKILLINFO). /// 0162 .W .W { .W .L .W .W .W .24B .B }* -void clif_guild_skillinfo(struct map_session_data *sd) -{ - int fd; - struct guild *g; - int i,c; - - nullpo_retv(sd); - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; - - fd = sd->fd; - WFIFOHEAD(fd, 6 + MAX_GUILDSKILL*37); - WFIFOW(fd,0) = 0x0162; - WFIFOW(fd,4) = g->skill_point; - for (i = 0, c = 0; i < MAX_GUILDSKILL; i++) { - if (g->skill[i].id > 0 && guild_check_skill_require(g, g->skill[i].id)) { - int id = g->skill[i].id; - int p = 6 + c*37; - WFIFOW(fd,p+0) = id; - WFIFOL(fd,p+2) = skill_get_inf(id); - WFIFOW(fd,p+6) = g->skill[i].lv; - WFIFOW(fd,p+8) = skill_get_sp(id, g->skill[i].lv); - WFIFOW(fd,p+10) = skill_get_range(id, g->skill[i].lv); - safestrncpy((char *)WFIFOP(fd,p+12), skill_get_name(id), NAME_LENGTH); - WFIFOB(fd,p+36)= (g->skill[i].lv < guild_skill_get_max(id) && sd == g->member[0].sd) ? 1 : 0; - c++; - } - } - WFIFOW(fd,2) = 6 + c*37; - WFIFOSET(fd,WFIFOW(fd,2)); +void clif_guild_skillinfo(struct map_session_data* sd) +{ + int fd; + struct guild* g; + int i,c; + + nullpo_retv(sd); + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; + + fd = sd->fd; + WFIFOHEAD(fd, 6 + MAX_GUILDSKILL*37); + WFIFOW(fd,0) = 0x0162; + WFIFOW(fd,4) = g->skill_point; + for(i = 0, c = 0; i < MAX_GUILDSKILL; i++) + { + if(g->skill[i].id > 0 && guild_check_skill_require(g, g->skill[i].id)) + { + int id = g->skill[i].id; + int p = 6 + c*37; + WFIFOW(fd,p+0) = id; + WFIFOL(fd,p+2) = skill_get_inf(id); + WFIFOW(fd,p+6) = g->skill[i].lv; + WFIFOW(fd,p+8) = skill_get_sp(id, g->skill[i].lv); + WFIFOW(fd,p+10) = skill_get_range(id, g->skill[i].lv); + safestrncpy((char*)WFIFOP(fd,p+12), skill_get_name(id), NAME_LENGTH); + WFIFOB(fd,p+36)= (g->skill[i].lv < guild_skill_get_max(id) && sd == g->member[0].sd) ? 1 : 0; + c++; + } + } + WFIFOW(fd,2) = 6 + c*37; + WFIFOSET(fd,WFIFOW(fd,2)); } /// Sends guild notice to client (ZC_GUILD_NOTICE). /// 016f .60B .120B -void clif_guild_notice(struct map_session_data *sd, struct guild *g) +void clif_guild_notice(struct map_session_data* sd, struct guild* g) { - int fd; + int fd; - nullpo_retv(sd); - nullpo_retv(g); + nullpo_retv(sd); + nullpo_retv(g); - fd = sd->fd; + fd = sd->fd; - if (!session_isActive(fd)) - return; + if ( !session_isActive(fd) ) + return; - if (g->mes1[0] == '\0' && g->mes2[0] == '\0') - return; + if(g->mes1[0] == '\0' && g->mes2[0] == '\0') + return; - WFIFOHEAD(fd,packet_len(0x16f)); - WFIFOW(fd,0) = 0x16f; - memcpy(WFIFOP(fd,2), g->mes1, MAX_GUILDMES1); - memcpy(WFIFOP(fd,62), g->mes2, MAX_GUILDMES2); - WFIFOSET(fd,packet_len(0x16f)); + WFIFOHEAD(fd,packet_len(0x16f)); + WFIFOW(fd,0) = 0x16f; + memcpy(WFIFOP(fd,2), g->mes1, MAX_GUILDMES1); + memcpy(WFIFOP(fd,62), g->mes2, MAX_GUILDMES2); + WFIFOSET(fd,packet_len(0x16f)); } @@ -7422,17 +7488,17 @@ void clif_guild_notice(struct map_session_data *sd, struct guild *g) /// 016a .L .24B void clif_guild_invite(struct map_session_data *sd,struct guild *g) { - int fd; + int fd; - nullpo_retv(sd); - nullpo_retv(g); + nullpo_retv(sd); + nullpo_retv(g); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x16a)); - WFIFOW(fd,0)=0x16a; - WFIFOL(fd,2)=g->guild_id; - memcpy(WFIFOP(fd,6),g->name,NAME_LENGTH); - WFIFOSET(fd,packet_len(0x16a)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x16a)); + WFIFOW(fd,0)=0x16a; + WFIFOL(fd,2)=g->guild_id; + memcpy(WFIFOP(fd,6),g->name,NAME_LENGTH); + WFIFOSET(fd,packet_len(0x16a)); } @@ -7445,15 +7511,15 @@ void clif_guild_invite(struct map_session_data *sd,struct guild *g) /// 3 = Guild full. void clif_guild_inviteack(struct map_session_data *sd,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x169)); - WFIFOW(fd,0)=0x169; - WFIFOB(fd,2)=flag; - WFIFOSET(fd,packet_len(0x169)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x169)); + WFIFOW(fd,0)=0x169; + WFIFOB(fd,2)=flag; + WFIFOSET(fd,packet_len(0x169)); } @@ -7461,104 +7527,108 @@ void clif_guild_inviteack(struct map_session_data *sd,int flag) /// 015a .24B .40B void clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes) { - unsigned char buf[128]; + unsigned char buf[128]; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf, 0)=0x15a; - memcpy(WBUFP(buf, 2),name,NAME_LENGTH); - memcpy(WBUFP(buf,26),mes,40); - clif_send(buf,packet_len(0x15a),&sd->bl,GUILD_NOBG); + WBUFW(buf, 0)=0x15a; + memcpy(WBUFP(buf, 2),name,NAME_LENGTH); + memcpy(WBUFP(buf,26),mes,40); + clif_send(buf,packet_len(0x15a),&sd->bl,GUILD_NOBG); } /// Notifies clients of a guild of an expelled member. /// 015c .24B .40B .24B (ZC_ACK_BAN_GUILD) /// 0839 .24B .40B (ZC_ACK_BAN_GUILD_SSO) -void clif_guild_expulsion(struct map_session_data *sd, const char *name, const char *mes, int account_id) +void clif_guild_expulsion(struct map_session_data* sd, const char* name, const char* mes, int account_id) { - unsigned char buf[128]; + unsigned char buf[128]; #if PACKETVER < 20100803 - const unsigned short cmd = 0x15c; + const unsigned short cmd = 0x15c; #else - const unsigned short cmd = 0x839; + const unsigned short cmd = 0x839; #endif - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0) = cmd; - safestrncpy((char *)WBUFP(buf,2), name, NAME_LENGTH); - safestrncpy((char *)WBUFP(buf,26), mes, 40); + WBUFW(buf,0) = cmd; + safestrncpy((char*)WBUFP(buf,2), name, NAME_LENGTH); + safestrncpy((char*)WBUFP(buf,26), mes, 40); #if PACKETVER < 20100803 - memset(WBUFP(buf,66), 0, NAME_LENGTH); // account name (not used for security reasons) + memset(WBUFP(buf,66), 0, NAME_LENGTH); // account name (not used for security reasons) #endif - clif_send(buf, packet_len(cmd), &sd->bl, GUILD_NOBG); + clif_send(buf, packet_len(cmd), &sd->bl, GUILD_NOBG); } /// Guild expulsion list (ZC_BAN_LIST). /// 0163 .W { .24B .24B .40B }* /// 0163 .W { .24B .40B }* (PACKETVER >= 20100803) -void clif_guild_expulsionlist(struct map_session_data *sd) +void clif_guild_expulsionlist(struct map_session_data* sd) { #if PACKETVER < 20100803 - const int offset = NAME_LENGTH*2+40; + const int offset = NAME_LENGTH*2+40; #else - const int offset = NAME_LENGTH+40; + const int offset = NAME_LENGTH+40; #endif - int fd, i, c = 0; - struct guild *g; + int fd, i, c = 0; + struct guild* g; - nullpo_retv(sd); + nullpo_retv(sd); - if ((g = guild_search(sd->status.guild_id)) == NULL) - return; + if( (g = guild_search(sd->status.guild_id)) == NULL ) + return; - fd = sd->fd; + fd = sd->fd; - WFIFOHEAD(fd,4 + MAX_GUILDEXPULSION * offset); - WFIFOW(fd,0) = 0x163; + WFIFOHEAD(fd,4 + MAX_GUILDEXPULSION * offset); + WFIFOW(fd,0) = 0x163; - for (i = 0; i < MAX_GUILDEXPULSION; i++) { - struct guild_expulsion *e = &g->expulsion[i]; + for( i = 0; i < MAX_GUILDEXPULSION; i++ ) + { + struct guild_expulsion* e = &g->expulsion[i]; - if (e->account_id > 0) { - memcpy(WFIFOP(fd,4 + c*offset), e->name, NAME_LENGTH); + if( e->account_id > 0 ) + { + memcpy(WFIFOP(fd,4 + c*offset), e->name, NAME_LENGTH); #if PACKETVER < 20100803 - memset(WFIFOP(fd,4 + c*offset+24), 0, NAME_LENGTH); // account name (not used for security reasons) - memcpy(WFIFOP(fd,4 + c*offset+48), e->mes, 40); + memset(WFIFOP(fd,4 + c*offset+24), 0, NAME_LENGTH); // account name (not used for security reasons) + memcpy(WFIFOP(fd,4 + c*offset+48), e->mes, 40); #else - memcpy(WFIFOP(fd,4 + c*offset+24), e->mes, 40); + memcpy(WFIFOP(fd,4 + c*offset+24), e->mes, 40); #endif - c++; - } - } - WFIFOW(fd,2) = 4 + c*offset; - WFIFOSET(fd,WFIFOW(fd,2)); + c++; + } + } + WFIFOW(fd,2) = 4 + c*offset; + WFIFOSET(fd,WFIFOW(fd,2)); } /// Guild chat message (ZC_GUILD_CHAT). /// 017f .W .?B void clif_guild_message(struct guild *g,int account_id,const char *mes,int len) -{ - // TODO: account_id is not used, candidate for deletion? [Ai4rei] - struct map_session_data *sd; - uint8 buf[256]; +{// TODO: account_id is not used, candidate for deletion? [Ai4rei] + struct map_session_data *sd; + uint8 buf[256]; - if (len == 0) { - return; - } else if (len > sizeof(buf)-5) { - ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%d, guild_id=%d).\n", mes, len, sizeof(buf)-5, g->guild_id); - len = sizeof(buf)-5; - } + if( len == 0 ) + { + return; + } + else if( len > sizeof(buf)-5 ) + { + ShowWarning("clif_guild_message: Truncated message '%s' (len=%d, max=%d, guild_id=%d).\n", mes, len, sizeof(buf)-5, g->guild_id); + len = sizeof(buf)-5; + } - WBUFW(buf, 0) = 0x17f; - WBUFW(buf, 2) = len + 5; - safestrncpy((char *)WBUFP(buf,4), mes, len+1); + WBUFW(buf, 0) = 0x17f; + WBUFW(buf, 2) = len + 5; + safestrncpy((char*)WBUFP(buf,4), mes, len+1); - if ((sd = guild_getavailablesd(g)) != NULL) - clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD_NOBG); + if ((sd = guild_getavailablesd(g)) != NULL) + clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD_NOBG); } @@ -7566,22 +7636,21 @@ void clif_guild_message(struct guild *g,int account_id,const char *mes,int len) * Server tells client 'sd' that his guild skill 'skill_num' gone to level 'lv' *------------------------------------------*/ int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv) -{ - // TODO: Merge with clif_skillup (same packet). - int fd; +{// TODO: Merge with clif_skillup (same packet). + int fd; - nullpo_ret(sd); + nullpo_ret(sd); - fd=sd->fd; - WFIFOHEAD(fd,11); - WFIFOW(fd,0) = 0x10e; - WFIFOW(fd,2) = skill_num; - WFIFOW(fd,4) = lv; - WFIFOW(fd,6) = skill_get_sp(skill_num,lv); - WFIFOW(fd,8) = skill_get_range(skill_num,lv); - WFIFOB(fd,10) = 1; - WFIFOSET(fd,11); - return 0; + fd=sd->fd; + WFIFOHEAD(fd,11); + WFIFOW(fd,0) = 0x10e; + WFIFOW(fd,2) = skill_num; + WFIFOW(fd,4) = lv; + WFIFOW(fd,6) = skill_get_sp(skill_num,lv); + WFIFOW(fd,8) = skill_get_range(skill_num,lv); + WFIFOB(fd,10) = 1; + WFIFOSET(fd,11); + return 0; } @@ -7589,16 +7658,16 @@ int clif_guild_skillup(struct map_session_data *sd,int skill_num,int lv) /// 0171 .L .24B void clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x171)); - WFIFOW(fd,0)=0x171; - WFIFOL(fd,2)=account_id; - memcpy(WFIFOP(fd,6),name,NAME_LENGTH); - WFIFOSET(fd,packet_len(0x171)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x171)); + WFIFOW(fd,0)=0x171; + WFIFOL(fd,2)=account_id; + memcpy(WFIFOP(fd,6),name,NAME_LENGTH); + WFIFOSET(fd,packet_len(0x171)); } @@ -7613,15 +7682,15 @@ void clif_guild_reqalliance(struct map_session_data *sd,int account_id,const cha /// 5 = Alliances are disabled. void clif_guild_allianceack(struct map_session_data *sd,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x173)); - WFIFOW(fd,0)=0x173; - WFIFOL(fd,2)=flag; - WFIFOSET(fd,packet_len(0x173)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x173)); + WFIFOW(fd,0)=0x173; + WFIFOL(fd,2)=flag; + WFIFOSET(fd,packet_len(0x173)); } @@ -7632,18 +7701,18 @@ void clif_guild_allianceack(struct map_session_data *sd,int flag) /// 1 = Enemy void clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - if (fd <= 0) - return; - WFIFOHEAD(fd,packet_len(0x184)); - WFIFOW(fd,0)=0x184; - WFIFOL(fd,2)=guild_id; - WFIFOL(fd,6)=flag; - WFIFOSET(fd,packet_len(0x184)); + fd = sd->fd; + if (fd <= 0) + return; + WFIFOHEAD(fd,packet_len(0x184)); + WFIFOW(fd,0)=0x184; + WFIFOL(fd,2)=guild_id; + WFIFOL(fd,6)=flag; + WFIFOSET(fd,packet_len(0x184)); } @@ -7656,15 +7725,15 @@ void clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag) /// 3 = Antagonists are disabled. void clif_guild_oppositionack(struct map_session_data *sd,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x181)); - WFIFOW(fd,0)=0x181; - WFIFOB(fd,2)=flag; - WFIFOSET(fd,packet_len(0x181)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x181)); + WFIFOW(fd,0)=0x181; + WFIFOB(fd,2)=flag; + WFIFOSET(fd,packet_len(0x181)); } @@ -7673,12 +7742,12 @@ void clif_guild_oppositionack(struct map_session_data *sd,int flag) /* void clif_guild_allianceadded(struct guild *g,int idx) { - unsigned char buf[64]; - WBUFW(buf,0)=0x185; - WBUFL(buf,2)=g->alliance[idx].opposition; - WBUFL(buf,6)=g->alliance[idx].guild_id; - memcpy(WBUFP(buf,10),g->alliance[idx].name,NAME_LENGTH); - clif_send(buf,packet_len(0x185),guild_getavailablesd(g),GUILD); + unsigned char buf[64]; + WBUFW(buf,0)=0x185; + WBUFL(buf,2)=g->alliance[idx].opposition; + WBUFL(buf,6)=g->alliance[idx].guild_id; + memcpy(WBUFP(buf,10),g->alliance[idx].name,NAME_LENGTH); + clif_send(buf,packet_len(0x185),guild_getavailablesd(g),GUILD); } */ @@ -7690,15 +7759,15 @@ void clif_guild_allianceadded(struct guild *g,int idx) /// 2 = there are still members in the guild void clif_guild_broken(struct map_session_data *sd,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x15e)); - WFIFOW(fd,0)=0x15e; - WFIFOL(fd,2)=flag; - WFIFOSET(fd,packet_len(0x15e)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x15e)); + WFIFOW(fd,0)=0x15e; + WFIFOL(fd,2)=flag; + WFIFOSET(fd,packet_len(0x15e)); } @@ -7708,28 +7777,28 @@ void clif_guild_broken(struct map_session_data *sd,int flag) /// enum emotion_type void clif_emotion(struct block_list *bl,int type) { - unsigned char buf[8]; + unsigned char buf[8]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0)=0xc0; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=type; - clif_send(buf,packet_len(0xc0),bl,AREA); + WBUFW(buf,0)=0xc0; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=type; + clif_send(buf,packet_len(0xc0),bl,AREA); } /// Displays the contents of a talkiebox trap (ZC_TALKBOX_CHATCONTENTS). /// 0191 .L .80B -void clif_talkiebox(struct block_list *bl, const char *talkie) +void clif_talkiebox(struct block_list* bl, const char* talkie) { - unsigned char buf[MESSAGE_SIZE+6]; - nullpo_retv(bl); + unsigned char buf[MESSAGE_SIZE+6]; + nullpo_retv(bl); - WBUFW(buf,0) = 0x191; - WBUFL(buf,2) = bl->id; - safestrncpy((char *)WBUFP(buf,6),talkie,MESSAGE_SIZE); - clif_send(buf,packet_len(0x191),bl,AREA); + WBUFW(buf,0) = 0x191; + WBUFL(buf,2) = bl->id; + safestrncpy((char*)WBUFP(buf,6),talkie,MESSAGE_SIZE); + clif_send(buf,packet_len(0x191),bl,AREA); } @@ -7737,13 +7806,13 @@ void clif_talkiebox(struct block_list *bl, const char *talkie) /// 01ea .L void clif_wedding_effect(struct block_list *bl) { - unsigned char buf[6]; + unsigned char buf[6]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x1ea; - WBUFL(buf,2) = bl->id; - clif_send(buf, packet_len(0x1ea), bl, AREA); + WBUFW(buf,0) = 0x1ea; + WBUFL(buf,2) = bl->id; + clif_send(buf, packet_len(0x1ea), bl, AREA); } @@ -7751,25 +7820,30 @@ void clif_wedding_effect(struct block_list *bl) /// 01e6 .24B void clif_callpartner(struct map_session_data *sd) { - unsigned char buf[26]; - const char *p; + unsigned char buf[26]; + const char *p; - nullpo_retv(sd); + nullpo_retv(sd); - WBUFW(buf,0) = 0x1e6; + WBUFW(buf,0) = 0x1e6; - if (sd->status.partner_id) { - if ((p = map_charid2nick(sd->status.partner_id)) != NULL) { - memcpy(WBUFP(buf,2), p, NAME_LENGTH); - } else { - WBUFB(buf,2) = 0; - } - } else { - // Send zero-length name if no partner, to initialize the client buffer. - WBUFB(buf,2) = 0; - } + if( sd->status.partner_id ) + { + if( ( p = map_charid2nick(sd->status.partner_id) ) != NULL ) + { + memcpy(WBUFP(buf,2), p, NAME_LENGTH); + } + else + { + WBUFB(buf,2) = 0; + } + } + else + {// Send zero-length name if no partner, to initialize the client buffer. + WBUFB(buf,2) = 0; + } - clif_send(buf, packet_len(0x1e6), &sd->bl, AREA); + clif_send(buf, packet_len(0x1e6), &sd->bl, AREA); } @@ -7779,29 +7853,29 @@ void clif_callpartner(struct map_session_data *sd) /* void clif_marriage_process(struct map_session_data *sd) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x1e4)); - WFIFOW(fd,0)=0x1e4; - WFIFOSET(fd,packet_len(0x1e4)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x1e4)); + WFIFOW(fd,0)=0x1e4; + WFIFOSET(fd,packet_len(0x1e4)); } */ /// Notice of divorce (ZC_DIVORCE). /// 0205 .24B -void clif_divorced(struct map_session_data *sd, const char *name) +void clif_divorced(struct map_session_data* sd, const char* name) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x205)); - WFIFOW(fd,0)=0x205; - memcpy(WFIFOP(fd,2), name, NAME_LENGTH); - WFIFOSET(fd, packet_len(0x205)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x205)); + WFIFOW(fd,0)=0x205; + memcpy(WFIFOP(fd,2), name, NAME_LENGTH); + WFIFOSET(fd, packet_len(0x205)); } @@ -7811,14 +7885,14 @@ void clif_divorced(struct map_session_data *sd, const char *name) /* void clif_marriage_proposal(int fd, struct map_session_data *sd, struct map_session_data* ssd) { - nullpo_retv(sd); + nullpo_retv(sd); - WFIFOHEAD(fd,packet_len(0x1e2)); - WFIFOW(fd,0) = 0x1e2; - WFIFOL(fd,2) = ssd->status.account_id; - WFIFOL(fd,6) = ssd->status.char_id; - safestrncpy((char*)WFIFOP(fd,10), ssd->status.name, NAME_LENGTH); - WFIFOSET(fd, packet_len(0x1e2)); + WFIFOHEAD(fd,packet_len(0x1e2)); + WFIFOW(fd,0) = 0x1e2; + WFIFOL(fd,2) = ssd->status.account_id; + WFIFOL(fd,6) = ssd->status.char_id; + safestrncpy((char*)WFIFOP(fd,10), ssd->status.name, NAME_LENGTH); + WFIFOSET(fd, packet_len(0x1e2)); } */ @@ -7828,27 +7902,30 @@ void clif_marriage_proposal(int fd, struct map_session_data *sd, struct map_sess *------------------------------------------*/ void clif_disp_onlyself(struct map_session_data *sd, const char *mes, int len) { - clif_disp_message(&sd->bl, mes, len, SELF); + clif_disp_message(&sd->bl, mes, len, SELF); } /*========================================== * Displays a message using the guild-chat colors to the specified targets. [Skotlex] *------------------------------------------*/ -void clif_disp_message(struct block_list *src, const char *mes, int len, enum send_target target) +void clif_disp_message(struct block_list* src, const char* mes, int len, enum send_target target) { - unsigned char buf[256]; + unsigned char buf[256]; - if (len == 0) { - return; - } else if (len > sizeof(buf)-5) { - ShowWarning("clif_disp_message: Truncated message '%s' (len=%d, max=%d, aid=%d).\n", mes, len, sizeof(buf)-5, src->id); - len = sizeof(buf)-5; - } + if( len == 0 ) + { + return; + } + else if( len > sizeof(buf)-5 ) + { + ShowWarning("clif_disp_message: Truncated message '%s' (len=%d, max=%d, aid=%d).\n", mes, len, sizeof(buf)-5, src->id); + len = sizeof(buf)-5; + } - WBUFW(buf, 0) = 0x17f; - WBUFW(buf, 2) = len + 5; - safestrncpy((char *)WBUFP(buf,4), mes, len+1); - clif_send(buf, WBUFW(buf,2), src, target); + WBUFW(buf, 0) = 0x17f; + WBUFW(buf, 2) = len + 5; + safestrncpy((char*)WBUFP(buf,4), mes, len+1); + clif_send(buf, WBUFW(buf,2), src, target); } @@ -7860,29 +7937,29 @@ void clif_disp_message(struct block_list *src, const char *mes, int len, enum se /// 1 = success void clif_GM_kickack(struct map_session_data *sd, int id) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0xcd)); - WFIFOW(fd,0) = 0xcd; - WFIFOB(fd,2) = id; // FIXME: this is not account id - WFIFOSET(fd, packet_len(0xcd)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0xcd)); + WFIFOW(fd,0) = 0xcd; + WFIFOB(fd,2) = id; // FIXME: this is not account id + WFIFOSET(fd, packet_len(0xcd)); } void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) { - int fd = tsd->fd; + int fd = tsd->fd; - if (fd > 0) - clif_authfail_fd(fd, 15); - else - map_quit(tsd); + if( fd > 0 ) + clif_authfail_fd(fd, 15); + else + map_quit(tsd); - if (sd) - clif_GM_kickack(sd,tsd->status.account_id); + if( sd ) + clif_GM_kickack(sd,tsd->status.account_id); } @@ -7895,16 +7972,16 @@ void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) /// 3 = "Chat Block has been applied by GM due to your ill-mannerous action." /// 4 = "Automated Chat Block has been applied due to Anti-Spam System." /// 5 = "You got a good point from %s." -void clif_manner_message(struct map_session_data *sd, uint32 type) +void clif_manner_message(struct map_session_data* sd, uint32 type) { - int fd; - nullpo_retv(sd); + int fd; + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x14a)); - WFIFOW(fd,0) = 0x14a; - WFIFOL(fd,2) = type; - WFIFOSET(fd, packet_len(0x14a)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x14a)); + WFIFOW(fd,0) = 0x14a; + WFIFOL(fd,2) = type; + WFIFOSET(fd, packet_len(0x14a)); } @@ -7913,18 +7990,18 @@ void clif_manner_message(struct map_session_data *sd, uint32 type) /// type: /// 0 = positive (unmute) /// 1 = negative (mute) -void clif_GM_silence(struct map_session_data *sd, struct map_session_data *tsd, uint8 type) +void clif_GM_silence(struct map_session_data* sd, struct map_session_data* tsd, uint8 type) { - int fd; - nullpo_retv(sd); - nullpo_retv(tsd); + int fd; + nullpo_retv(sd); + nullpo_retv(tsd); - fd = tsd->fd; - WFIFOHEAD(fd,packet_len(0x14b)); - WFIFOW(fd,0) = 0x14b; - WFIFOB(fd,2) = type; - safestrncpy((char *)WFIFOP(fd,3), sd->status.name, NAME_LENGTH); - WFIFOSET(fd, packet_len(0x14b)); + fd = tsd->fd; + WFIFOHEAD(fd,packet_len(0x14b)); + WFIFOW(fd,0) = 0x14b; + WFIFOB(fd,2) = type; + safestrncpy((char*)WFIFOP(fd,3), sd->status.name, NAME_LENGTH); + WFIFOSET(fd, packet_len(0x14b)); } @@ -7939,16 +8016,16 @@ void clif_GM_silence(struct map_session_data *sd, struct map_session_data *tsd, /// 2 = too many blocks void clif_wisexin(struct map_session_data *sd,int type,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xd1)); - WFIFOW(fd,0)=0xd1; - WFIFOB(fd,2)=type; - WFIFOB(fd,3)=flag; - WFIFOSET(fd,packet_len(0xd1)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xd1)); + WFIFOW(fd,0)=0xd1; + WFIFOB(fd,2)=type; + WFIFOB(fd,3)=flag; + WFIFOSET(fd,packet_len(0xd1)); } /// Notifies the client about the result of a request to allow/deny whispers from anyone (ZC_SETTING_WHISPER_STATE). @@ -7961,32 +8038,32 @@ void clif_wisexin(struct map_session_data *sd,int type,int flag) /// 1 = failure void clif_wisall(struct map_session_data *sd,int type,int flag) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd,packet_len(0xd2)); - WFIFOW(fd,0)=0xd2; - WFIFOB(fd,2)=type; - WFIFOB(fd,3)=flag; - WFIFOSET(fd,packet_len(0xd2)); + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0xd2)); + WFIFOW(fd,0)=0xd2; + WFIFOB(fd,2)=type; + WFIFOB(fd,3)=flag; + WFIFOSET(fd,packet_len(0xd2)); } /// Play a BGM! [Rikter/Yommy] (ZC_PLAY_NPC_BGM). /// 07fe .24B -void clif_playBGM(struct map_session_data *sd, const char *name) +void clif_playBGM(struct map_session_data* sd, const char* name) { - int fd; + int fd; - nullpo_retv(sd); + nullpo_retv(sd); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x7fe)); - WFIFOW(fd,0) = 0x7fe; - safestrncpy((char *)WFIFOP(fd,2), name, NAME_LENGTH); - WFIFOSET(fd,packet_len(0x7fe)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x7fe)); + WFIFOW(fd,0) = 0x7fe; + safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); + WFIFOSET(fd,packet_len(0x7fe)); } @@ -8003,35 +8080,35 @@ void clif_playBGM(struct map_session_data *sd, const char *name) /// npc id: /// The accustic direction of the sound is determined by the /// relative position of the NPC to the player (3D sound). -void clif_soundeffect(struct map_session_data *sd, struct block_list *bl, const char *name, int type) +void clif_soundeffect(struct map_session_data* sd, struct block_list* bl, const char* name, int type) { - int fd; + int fd; - nullpo_retv(sd); - nullpo_retv(bl); + nullpo_retv(sd); + nullpo_retv(bl); - fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x1d3)); - WFIFOW(fd,0) = 0x1d3; - safestrncpy((char *)WFIFOP(fd,2), name, NAME_LENGTH); - WFIFOB(fd,26) = type; - WFIFOL(fd,27) = 0; - WFIFOL(fd,31) = bl->id; - WFIFOSET(fd,packet_len(0x1d3)); + fd = sd->fd; + WFIFOHEAD(fd,packet_len(0x1d3)); + WFIFOW(fd,0) = 0x1d3; + safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); + WFIFOB(fd,26) = type; + WFIFOL(fd,27) = 0; + WFIFOL(fd,31) = bl->id; + WFIFOSET(fd,packet_len(0x1d3)); } -void clif_soundeffectall(struct block_list *bl, const char *name, int type, enum send_target coverage) +void clif_soundeffectall(struct block_list* bl, const char* name, int type, enum send_target coverage) { - unsigned char buf[40]; + unsigned char buf[40]; - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf,0) = 0x1d3; - safestrncpy((char *)WBUFP(buf,2), name, NAME_LENGTH); - WBUFB(buf,26) = type; - WBUFL(buf,27) = 0; - WBUFL(buf,31) = bl->id; - clif_send(buf, packet_len(0x1d3), bl, coverage); + WBUFW(buf,0) = 0x1d3; + safestrncpy((char*)WBUFP(buf,2), name, NAME_LENGTH); + WBUFB(buf,26) = type; + WBUFL(buf,27) = 0; + WBUFL(buf,31) = bl->id; + clif_send(buf, packet_len(0x1d3), bl, coverage); } @@ -8039,33 +8116,33 @@ void clif_soundeffectall(struct block_list *bl, const char *name, int type, enum /// 01f3 .L .L /// effect id: /// @see doc/effect_list.txt -void clif_specialeffect(struct block_list *bl, int type, enum send_target target) +void clif_specialeffect(struct block_list* bl, int type, enum send_target target) { - unsigned char buf[24]; + unsigned char buf[24]; - nullpo_retv(bl); + nullpo_retv(bl); - memset(buf, 0, packet_len(0x1f3)); + memset(buf, 0, packet_len(0x1f3)); - WBUFW(buf,0) = 0x1f3; - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = type; + WBUFW(buf,0) = 0x1f3; + WBUFL(buf,2) = bl->id; + WBUFL(buf,6) = type; - clif_send(buf, packet_len(0x1f3), bl, target); + clif_send(buf, packet_len(0x1f3), bl, target); - if (disguised(bl)) { - WBUFL(buf,2) = -bl->id; - clif_send(buf, packet_len(0x1f3), bl, SELF); - } + if (disguised(bl)) { + WBUFL(buf,2) = -bl->id; + clif_send(buf, packet_len(0x1f3), bl, SELF); + } } -void clif_specialeffect_single(struct block_list *bl, int type, int fd) +void clif_specialeffect_single(struct block_list* bl, int type, int fd) { - WFIFOHEAD(fd,10); - WFIFOW(fd,0) = 0x1f3; - WFIFOL(fd,2) = bl->id; - WFIFOL(fd,6) = type; - WFIFOSET(fd,10); + WFIFOHEAD(fd,10); + WFIFOW(fd,0) = 0x1f3; + WFIFOL(fd,2) = bl->id; + WFIFOL(fd,6) = type; + WFIFOSET(fd,10); } @@ -8075,317 +8152,332 @@ void clif_specialeffect_single(struct block_list *bl, int type, int fd) /// @see doc/effect_list.txt /// num data: /// effect-dependent value -void clif_specialeffect_value(struct block_list *bl, int effect_id, int num, send_target target) +void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, send_target target) { - uint8 buf[14]; + uint8 buf[14]; - WBUFW(buf,0) = 0x284; - WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = effect_id; - WBUFL(buf,10) = num; + WBUFW(buf,0) = 0x284; + WBUFL(buf,2) = bl->id; + WBUFL(buf,6) = effect_id; + WBUFL(buf,10) = num; - clif_send(buf, packet_len(0x284), bl, target); + clif_send(buf, packet_len(0x284), bl, target); - if (disguised(bl)) { - WBUFL(buf,2) = -bl->id; - clif_send(buf, packet_len(0x284), bl, SELF); - } + if( disguised(bl) ) + { + WBUFL(buf,2) = -bl->id; + clif_send(buf, packet_len(0x284), bl, SELF); + } } // Modification of clif_messagecolor to send colored messages to players to chat log only (doesn't display overhead) /// 02c1 .W .L .L .?B -int clif_colormes(struct map_session_data *sd, enum clif_colors color, const char *msg) -{ - unsigned short msg_len = strlen(msg) + 1; +int clif_colormes(struct map_session_data * sd, enum clif_colors color, const char* msg) { + unsigned short msg_len = strlen(msg) + 1; - WFIFOHEAD(sd->fd,msg_len + 12); - WFIFOW(sd->fd,0) = 0x2C1; - WFIFOW(sd->fd,2) = msg_len + 12; - WFIFOL(sd->fd,4) = 0; - WFIFOL(sd->fd,8) = color_table[color]; - safestrncpy((char *)WFIFOP(sd->fd,12), msg, msg_len); - clif_send(WFIFOP(sd->fd,0), WFIFOW(sd->fd,2), &sd->bl, SELF); + WFIFOHEAD(sd->fd,msg_len + 12); + WFIFOW(sd->fd,0) = 0x2C1; + WFIFOW(sd->fd,2) = msg_len + 12; + WFIFOL(sd->fd,4) = 0; + WFIFOL(sd->fd,8) = color_table[color]; + safestrncpy((char*)WFIFOP(sd->fd,12), msg, msg_len); + clif_send(WFIFOP(sd->fd,0), WFIFOW(sd->fd,2), &sd->bl, SELF); - return 0; + return 0; } /// Monster/NPC color chat [SnakeDrak] (ZC_NPC_CHAT). /// 02c1 .W .L .L .?B -void clif_messagecolor(struct block_list *bl, unsigned long color, const char *msg) -{ - unsigned short msg_len = strlen(msg) + 1; - uint8 buf[256]; - color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR +void clif_messagecolor(struct block_list* bl, unsigned long color, const char* msg) { + unsigned short msg_len = strlen(msg) + 1; + uint8 buf[256]; + color = (color & 0x0000FF) << 16 | (color & 0x00FF00) | (color & 0xFF0000) >> 16; // RGB to BGR - nullpo_retv(bl); + nullpo_retv(bl); - if (msg_len > sizeof(buf)-12) { - ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%u).\n", msg, msg_len); - msg_len = sizeof(buf)-12; - } + if( msg_len > sizeof(buf)-12 ) + { + ShowWarning("clif_messagecolor: Truncating too long message '%s' (len=%u).\n", msg, msg_len); + msg_len = sizeof(buf)-12; + } - WBUFW(buf,0) = 0x2C1; - WBUFW(buf,2) = msg_len + 12; - WBUFL(buf,4) = bl->id; - WBUFL(buf,8) = color; - memcpy(WBUFP(buf,12), msg, msg_len); + WBUFW(buf,0) = 0x2C1; + WBUFW(buf,2) = msg_len + 12; + WBUFL(buf,4) = bl->id; + WBUFL(buf,8) = color; + memcpy(WBUFP(buf,12), msg, msg_len); - clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); + clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); } /// Public chat message [Valaris] (ZC_NOTIFY_CHAT). /// 008d .W .L .?B -void clif_message(struct block_list *bl, const char *msg) -{ - unsigned short msg_len = strlen(msg) + 1; - uint8 buf[256]; - nullpo_retv(bl); +void clif_message(struct block_list* bl, const char* msg) { + unsigned short msg_len = strlen(msg) + 1; + uint8 buf[256]; + nullpo_retv(bl); - if (msg_len > sizeof(buf)-8) { - ShowWarning("clif_message: Truncating too long message '%s' (len=%u).\n", msg, msg_len); - msg_len = sizeof(buf)-8; - } + if( msg_len > sizeof(buf)-8 ) { + ShowWarning("clif_message: Truncating too long message '%s' (len=%u).\n", msg, msg_len); + msg_len = sizeof(buf)-8; + } - WBUFW(buf,0) = 0x8d; - WBUFW(buf,2) = msg_len + 8; - WBUFL(buf,4) = bl->id; - safestrncpy((char *)WBUFP(buf,8), msg, msg_len); + WBUFW(buf,0) = 0x8d; + WBUFW(buf,2) = msg_len + 8; + WBUFL(buf,4) = bl->id; + safestrncpy((char*)WBUFP(buf,8), msg, msg_len); - clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); + clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); } // refresh the client's screen, getting rid of any effects void clif_refresh(struct map_session_data *sd) { - int i; - nullpo_retv(sd); - - clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y); - clif_inventorylist(sd); - if (pc_iscarton(sd)) { - clif_cartlist(sd); - clif_updatestatus(sd,SP_CARTINFO); - } - clif_updatestatus(sd,SP_WEIGHT); - clif_updatestatus(sd,SP_MAXWEIGHT); - clif_updatestatus(sd,SP_STR); - clif_updatestatus(sd,SP_AGI); - clif_updatestatus(sd,SP_VIT); - clif_updatestatus(sd,SP_INT); - clif_updatestatus(sd,SP_DEX); - clif_updatestatus(sd,SP_LUK); - if (sd->spiritball) - clif_spiritball_single(sd->fd, sd); - for (i = 1; i < 5; i++) { - if (sd->talisman[i] > 0) - clif_talisman_single(sd->fd, sd, i); - } - if (sd->vd.cloth_color) - clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF); - if (merc_is_hom_active(sd->hd)) - clif_send_homdata(sd,SP_ACK,0); - if (sd->md) { - clif_mercenary_info(sd); - clif_mercenary_skillblock(sd); - } - if (sd->ed) - clif_elemental_info(sd); - map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); - clif_weather_check(sd); - if (sd->chatID) - chat_leavechat(sd,0); - if (sd->state.vending) - clif_openvending(sd, sd->bl.id, sd->vending); - if (pc_issit(sd)) - clif_sitting(&sd->bl); // FIXME: just send to self, not area - if (pc_isdead(sd)) // When you refresh, resend the death packet. - clif_clearunit_single(sd->bl.id,CLR_DEAD,sd->fd); - else - clif_changed_dir(&sd->bl, SELF); - - // unlike vending, resuming buyingstore crashes the client. - buyingstore_close(sd); - - mail_clear(sd); + int i; + nullpo_retv(sd); + + clif_changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y); + clif_inventorylist(sd); + if(pc_iscarton(sd)) { + clif_cartlist(sd); + clif_updatestatus(sd,SP_CARTINFO); + } + clif_updatestatus(sd,SP_WEIGHT); + clif_updatestatus(sd,SP_MAXWEIGHT); + clif_updatestatus(sd,SP_STR); + clif_updatestatus(sd,SP_AGI); + clif_updatestatus(sd,SP_VIT); + clif_updatestatus(sd,SP_INT); + clif_updatestatus(sd,SP_DEX); + clif_updatestatus(sd,SP_LUK); + if (sd->spiritball) + clif_spiritball_single(sd->fd, sd); + for(i = 1; i < 5; i++){ + if( sd->talisman[i] > 0 ) + clif_talisman_single(sd->fd, sd, i); + } + if (sd->vd.cloth_color) + clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF); + if(merc_is_hom_active(sd->hd)) + clif_send_homdata(sd,SP_ACK,0); + if( sd->md ) { + clif_mercenary_info(sd); + clif_mercenary_skillblock(sd); + } + if( sd->ed ) + clif_elemental_info(sd); + map_foreachinrange(clif_getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); + clif_weather_check(sd); + if( sd->chatID ) + chat_leavechat(sd,0); + if( sd->state.vending ) + clif_openvending(sd, sd->bl.id, sd->vending); + if( pc_issit(sd) ) + clif_sitting(&sd->bl); // FIXME: just send to self, not area + if( pc_isdead(sd) ) // When you refresh, resend the death packet. + clif_clearunit_single(sd->bl.id,CLR_DEAD,sd->fd); + else + clif_changed_dir(&sd->bl, SELF); + + // unlike vending, resuming buyingstore crashes the client. + buyingstore_close(sd); + + mail_clear(sd); } /// Updates the object's (bl) name on client. /// 0095 .L .24B (ZC_ACK_REQNAME) /// 0195 .L .24B .24B .24B .24B (ZC_ACK_REQNAMEALL) -void clif_charnameack(int fd, struct block_list *bl) -{ - unsigned char buf[103]; - int cmd = 0x95, i, ps = -1; - - nullpo_retv(bl); - - WBUFW(buf,0) = cmd; - WBUFL(buf,2) = bl->id; - - switch (bl->type) { - case BL_PC: { - struct map_session_data *ssd = (struct map_session_data *)bl; - struct party_data *p = NULL; - struct guild *g = NULL; - - //Requesting your own "shadow" name. [Skotlex] - if (ssd->fd == fd && ssd->disguise) - WBUFL(buf,2) = -bl->id; - - if (ssd->fakename[0]) { - WBUFW(buf, 0) = cmd = 0x195; - memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH); - WBUFB(buf,30) = WBUFB(buf,54) = WBUFB(buf,78) = 0; - break; - } - memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH); - - if (ssd->status.party_id) { - p = party_search(ssd->status.party_id); - } - if (ssd->status.guild_id) { - if ((g = guild_search(ssd->status.guild_id)) != NULL) { - ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id); - if (i < g->max_member) ps = g->member[i].position; - } - } - - if (!battle_config.display_party_name && g == NULL) { - // do not display party unless the player is also in a guild - p = NULL; - } - - if (p == NULL && g == NULL) - break; - - WBUFW(buf, 0) = cmd = 0x195; - if (p) - memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH); - else - WBUFB(buf,30) = 0; - - if (g && ps >= 0 && ps < MAX_GUILDPOSITION) { - memcpy(WBUFP(buf,54), g->name,NAME_LENGTH); - memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH); - } else { //Assume no guild. - WBUFB(buf,54) = 0; - WBUFB(buf,78) = 0; - } - } - break; - //[blackhole89] - case BL_HOM: - memcpy(WBUFP(buf,6), ((TBL_HOM *)bl)->homunculus.name, NAME_LENGTH); - break; - case BL_MER: - memcpy(WBUFP(buf,6), ((TBL_MER *)bl)->db->name, NAME_LENGTH); - break; - case BL_PET: - memcpy(WBUFP(buf,6), ((TBL_PET *)bl)->pet.name, NAME_LENGTH); - break; - case BL_NPC: - memcpy(WBUFP(buf,6), ((TBL_NPC *)bl)->name, NAME_LENGTH); - break; - case BL_MOB: { - struct mob_data *md = (struct mob_data *)bl; - nullpo_retv(md); - - memcpy(WBUFP(buf,6), md->name, NAME_LENGTH); - if (md->guardian_data && md->guardian_data->guild_id) { - WBUFW(buf, 0) = cmd = 0x195; - WBUFB(buf,30) = 0; - memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH); - memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH); - } else if (battle_config.show_mob_info) { - char mobhp[50], *str_p = mobhp; - WBUFW(buf, 0) = cmd = 0x195; - if (battle_config.show_mob_info&4) - str_p += sprintf(str_p, "Lv. %d | ", md->level); - if (battle_config.show_mob_info&1) - str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp); - if (battle_config.show_mob_info&2) - str_p += sprintf(str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp)); - //Even thought mobhp ain't a name, we send it as one so the client - //can parse it. [Skotlex] - if (str_p != mobhp) { - *(str_p-3) = '\0'; //Remove trailing space + pipe. - memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH); - WBUFB(buf,54) = 0; - WBUFB(buf,78) = 0; - } - } - } - break; - case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex] - // memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH); - // break; - return; - case BL_ELEM: - memcpy(WBUFP(buf,6), ((TBL_ELEM *)bl)->db->name, NAME_LENGTH); - break; - default: - ShowError("clif_charnameack: bad type %d(%d)\n", bl->type, bl->id); - return; - } - - // if no receipient specified just update nearby clients - if (fd == 0) - clif_send(buf, packet_len(cmd), bl, AREA); - else { - WFIFOHEAD(fd, packet_len(cmd)); - memcpy(WFIFOP(fd, 0), buf, packet_len(cmd)); - WFIFOSET(fd, packet_len(cmd)); - } +void clif_charnameack (int fd, struct block_list *bl) +{ + unsigned char buf[103]; + int cmd = 0x95, i, ps = -1; + + nullpo_retv(bl); + + WBUFW(buf,0) = cmd; + WBUFL(buf,2) = bl->id; + + switch( bl->type ) + { + case BL_PC: + { + struct map_session_data *ssd = (struct map_session_data *)bl; + struct party_data *p = NULL; + struct guild *g = NULL; + + //Requesting your own "shadow" name. [Skotlex] + if (ssd->fd == fd && ssd->disguise) + WBUFL(buf,2) = -bl->id; + + if( ssd->fakename[0] ) + { + WBUFW(buf, 0) = cmd = 0x195; + memcpy(WBUFP(buf,6), ssd->fakename, NAME_LENGTH); + WBUFB(buf,30) = WBUFB(buf,54) = WBUFB(buf,78) = 0; + break; + } + memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH); + + if( ssd->status.party_id ) + { + p = party_search(ssd->status.party_id); + } + if( ssd->status.guild_id ) + { + if( ( g = guild_search(ssd->status.guild_id) ) != NULL ) + { + ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id); + if( i < g->max_member ) ps = g->member[i].position; + } + } + + if( !battle_config.display_party_name && g == NULL ) + {// do not display party unless the player is also in a guild + p = NULL; + } + + if (p == NULL && g == NULL) + break; + + WBUFW(buf, 0) = cmd = 0x195; + if (p) + memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH); + else + WBUFB(buf,30) = 0; + + if (g && ps >= 0 && ps < MAX_GUILDPOSITION) + { + memcpy(WBUFP(buf,54), g->name,NAME_LENGTH); + memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH); + } else { //Assume no guild. + WBUFB(buf,54) = 0; + WBUFB(buf,78) = 0; + } + } + break; + //[blackhole89] + case BL_HOM: + memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH); + break; + case BL_MER: + memcpy(WBUFP(buf,6), ((TBL_MER*)bl)->db->name, NAME_LENGTH); + break; + case BL_PET: + memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH); + break; + case BL_NPC: + memcpy(WBUFP(buf,6), ((TBL_NPC*)bl)->name, NAME_LENGTH); + break; + case BL_MOB: + { + struct mob_data *md = (struct mob_data *)bl; + nullpo_retv(md); + + memcpy(WBUFP(buf,6), md->name, NAME_LENGTH); + if( md->guardian_data && md->guardian_data->guild_id ) + { + WBUFW(buf, 0) = cmd = 0x195; + WBUFB(buf,30) = 0; + memcpy(WBUFP(buf,54), md->guardian_data->guild_name, NAME_LENGTH); + memcpy(WBUFP(buf,78), md->guardian_data->castle->castle_name, NAME_LENGTH); + } + else if( battle_config.show_mob_info ) + { + char mobhp[50], *str_p = mobhp; + WBUFW(buf, 0) = cmd = 0x195; + if( battle_config.show_mob_info&4 ) + str_p += sprintf(str_p, "Lv. %d | ", md->level); + if( battle_config.show_mob_info&1 ) + str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp); + if( battle_config.show_mob_info&2 ) + str_p += sprintf(str_p, "HP: %d%% | ", get_percentage(md->status.hp, md->status.max_hp)); + //Even thought mobhp ain't a name, we send it as one so the client + //can parse it. [Skotlex] + if( str_p != mobhp ) + { + *(str_p-3) = '\0'; //Remove trailing space + pipe. + memcpy(WBUFP(buf,30), mobhp, NAME_LENGTH); + WBUFB(buf,54) = 0; + WBUFB(buf,78) = 0; + } + } + } + break; + case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex] +// memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH); +// break; + return; + case BL_ELEM: + memcpy(WBUFP(buf,6), ((TBL_ELEM*)bl)->db->name, NAME_LENGTH); + break; + default: + ShowError("clif_charnameack: bad type %d(%d)\n", bl->type, bl->id); + return; + } + + // if no receipient specified just update nearby clients + if (fd == 0) + clif_send(buf, packet_len(cmd), bl, AREA); + else { + WFIFOHEAD(fd, packet_len(cmd)); + memcpy(WFIFOP(fd, 0), buf, packet_len(cmd)); + WFIFOSET(fd, packet_len(cmd)); + } } //Used to update when a char leaves a party/guild. [Skotlex] //Needed because when you send a 0x95 packet, the client will not remove the cached party/guild info that is not sent. -void clif_charnameupdate(struct map_session_data *ssd) +void clif_charnameupdate (struct map_session_data *ssd) { - unsigned char buf[103]; - int cmd = 0x195, ps = -1, i; - struct party_data *p = NULL; - struct guild *g = NULL; + unsigned char buf[103]; + int cmd = 0x195, ps = -1, i; + struct party_data *p = NULL; + struct guild *g = NULL; - nullpo_retv(ssd); + nullpo_retv(ssd); - if (ssd->fakename[0]) - return; //No need to update as the party/guild was not displayed anyway. + if( ssd->fakename[0] ) + return; //No need to update as the party/guild was not displayed anyway. - WBUFW(buf,0) = cmd; - WBUFL(buf,2) = ssd->bl.id; + WBUFW(buf,0) = cmd; + WBUFL(buf,2) = ssd->bl.id; - memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH); + memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH); - if (!battle_config.display_party_name) { - if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL) - p = party_search(ssd->status.party_id); - } else { - if (ssd->status.party_id > 0) - p = party_search(ssd->status.party_id); - } + if (!battle_config.display_party_name) { + if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL) + p = party_search(ssd->status.party_id); + }else{ + if (ssd->status.party_id > 0) + p = party_search(ssd->status.party_id); + } - if (ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL) { - ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id); - if (i < g->max_member) ps = g->member[i].position; - } + if( ssd->status.guild_id > 0 && (g = guild_search(ssd->status.guild_id)) != NULL ) + { + ARR_FIND(0, g->max_member, i, g->member[i].account_id == ssd->status.account_id && g->member[i].char_id == ssd->status.char_id); + if( i < g->max_member ) ps = g->member[i].position; + } - if (p) - memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH); - else - WBUFB(buf,30) = 0; - - if (g && ps >= 0 && ps < MAX_GUILDPOSITION) { - memcpy(WBUFP(buf,54), g->name,NAME_LENGTH); - memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH); - } else { - WBUFB(buf,54) = 0; - WBUFB(buf,78) = 0; - } + if( p ) + memcpy(WBUFP(buf,30), p->party.name, NAME_LENGTH); + else + WBUFB(buf,30) = 0; - // Update nearby clients - clif_send(buf, packet_len(cmd), &ssd->bl, AREA); + if( g && ps >= 0 && ps < MAX_GUILDPOSITION ) + { + memcpy(WBUFP(buf,54), g->name,NAME_LENGTH); + memcpy(WBUFP(buf,78), g->position[ps].name, NAME_LENGTH); + } + else + { + WBUFB(buf,54) = 0; + WBUFB(buf,78) = 0; + } + + // Update nearby clients + clif_send(buf, packet_len(cmd), &ssd->bl, AREA); } @@ -8397,46 +8489,47 @@ void clif_charnameupdate(struct map_session_data *ssd) /// stays that way. void clif_slide(struct block_list *bl, int x, int y) { - unsigned char buf[10]; - nullpo_retv(bl); + unsigned char buf[10]; + nullpo_retv(bl); - WBUFW(buf, 0) = 0x01ff; - WBUFL(buf, 2) = bl->id; - WBUFW(buf, 6) = x; - WBUFW(buf, 8) = y; - clif_send(buf, packet_len(0x1ff), bl, AREA); + WBUFW(buf, 0) = 0x01ff; + WBUFL(buf, 2) = bl->id; + WBUFW(buf, 6) = x; + WBUFW(buf, 8) = y; + clif_send(buf, packet_len(0x1ff), bl, AREA); - if (disguised(bl)) { - WBUFL(buf,2) = -bl->id; - clif_send(buf, packet_len(0x1ff), bl, SELF); - } + if( disguised(bl) ) + { + WBUFL(buf,2) = -bl->id; + clif_send(buf, packet_len(0x1ff), bl, SELF); + } } /*------------------------------------------ * @me command by lordalfa, rewritten implementation by Skotlex *------------------------------------------*/ -void clif_disp_overhead(struct map_session_data *sd, const char *mes) +void clif_disp_overhead(struct map_session_data *sd, const char* mes) { - unsigned char buf[256]; //This should be more than sufficient, the theorical max is CHAT_SIZE + 8 (pads and extra inserted crap) - int len_mes = strlen(mes)+1; //Account for \0 + unsigned char buf[256]; //This should be more than sufficient, the theorical max is CHAT_SIZE + 8 (pads and extra inserted crap) + int len_mes = strlen(mes)+1; //Account for \0 - if (len_mes > sizeof(buf)-8) { - ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes); - len_mes = sizeof(buf)-8; //Trunk it to avoid problems. - } - // send message to others - WBUFW(buf,0) = 0x8d; - WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id) - WBUFL(buf,4) = sd->bl.id; - safestrncpy((char *)WBUFP(buf,8), mes, len_mes); - clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC); + if (len_mes > sizeof(buf)-8) { + ShowError("clif_disp_overhead: Message too long (length %d)\n", len_mes); + len_mes = sizeof(buf)-8; //Trunk it to avoid problems. + } + // send message to others + WBUFW(buf,0) = 0x8d; + WBUFW(buf,2) = len_mes + 8; // len of message + 8 (command+len+id) + WBUFL(buf,4) = sd->bl.id; + safestrncpy((char*)WBUFP(buf,8), mes, len_mes); + clif_send(buf, WBUFW(buf,2), &sd->bl, AREA_CHAT_WOC); - // send back message to the speaker - WBUFW(buf,0) = 0x8e; - WBUFW(buf, 2) = len_mes + 4; - safestrncpy((char *)WBUFP(buf,4), mes, len_mes); - clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); + // send back message to the speaker + WBUFW(buf,0) = 0x8e; + WBUFW(buf, 2) = len_mes + 4; + safestrncpy((char*)WBUFP(buf,4), mes, len_mes); + clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); } /*========================== @@ -8445,13 +8538,13 @@ void clif_disp_overhead(struct map_session_data *sd, const char *mes) *--------------------------*/ void clif_party_xy_remove(struct map_session_data *sd) { - unsigned char buf[16]; - nullpo_retv(sd); - WBUFW(buf,0)=0x107; - WBUFL(buf,2)=sd->status.account_id; - WBUFW(buf,6)=-1; - WBUFW(buf,8)=-1; - clif_send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS); + unsigned char buf[16]; + nullpo_retv(sd); + WBUFW(buf,0)=0x107; + WBUFL(buf,2)=sd->status.account_id; + WBUFW(buf,6)=-1; + WBUFW(buf,8)=-1; + clif_send(buf,packet_len(0x107),&sd->bl,PARTY_SAMEMAP_WOS); } @@ -8472,11 +8565,11 @@ void clif_party_xy_remove(struct map_session_data *sd) /// ? = nothing void clif_gospel_info(struct map_session_data *sd, int type) { - int fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x215)); - WFIFOW(fd,0)=0x215; - WFIFOL(fd,2)=type; - WFIFOSET(fd, packet_len(0x215)); + int fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x215)); + WFIFOW(fd,0)=0x215; + WFIFOL(fd,2)=type; + WFIFOSET(fd, packet_len(0x215)); } @@ -8509,29 +8602,29 @@ void clif_gospel_info(struct map_session_data *sd, int type) /// 22 = [Collector Rank] Target Item : /// 30 = [Sun, Moon and Stars Angel] Designed places and monsters have been reset. /// 40 = Target HP : -void clif_starskill(struct map_session_data *sd, const char *mapname, int monster_id, unsigned char star, unsigned char result) +void clif_starskill(struct map_session_data* sd, const char* mapname, int monster_id, unsigned char star, unsigned char result) { - int fd = sd->fd; + int fd = sd->fd; - WFIFOHEAD(fd,packet_len(0x20e)); - WFIFOW(fd,0) = 0x20e; - safestrncpy((char *)WFIFOP(fd,2), mapname, NAME_LENGTH); - WFIFOL(fd,26) = monster_id; - WFIFOB(fd,30) = star; - WFIFOB(fd,31) = result; - WFIFOSET(fd,packet_len(0x20e)); + WFIFOHEAD(fd,packet_len(0x20e)); + WFIFOW(fd,0) = 0x20e; + safestrncpy((char*)WFIFOP(fd,2), mapname, NAME_LENGTH); + WFIFOL(fd,26) = monster_id; + WFIFOB(fd,30) = star; + WFIFOB(fd,31) = result; + WFIFOSET(fd,packet_len(0x20e)); } /*========================================== * 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) { - char mapname[MAP_NAME_LENGTH_EXT]; + char mapname[MAP_NAME_LENGTH_EXT]; - mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname); - clif_starskill(sd, mapname, 0, feel_level, type ? 1 : 0); + mapindex_getmapname_ext(mapindex_id2name(sd->feel_map[feel_level].index), mapname); + clif_starskill(sd, mapname, 0, feel_level, type ? 1 : 0); } /*========================================== @@ -8540,13 +8633,18 @@ void clif_feel_info(struct map_session_data *sd, unsigned char feel_level, unsig *------------------------------------------*/ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type) { - if (pcdb_checkid(class_)) { - clif_starskill(sd, job_name(class_), class_, hate_level, type ? 10 : 11); - } else if (mobdb_checkid(class_)) { - clif_starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11); - } else { - ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (unsigned int)hate_level, (unsigned int)type); - } + if( pcdb_checkid(class_) ) + { + clif_starskill(sd, job_name(class_), class_, hate_level, type ? 10 : 11); + } + else if( mobdb_checkid(class_) ) + { + clif_starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11); + } + else + { + ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (unsigned int)hate_level, (unsigned int)type); + } } /*========================================== @@ -8554,7 +8652,7 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl *------------------------------------------*/ void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress) { - clif_starskill(sd, mob_db(mob_id)->jname, mob_id, progress, 20); + clif_starskill(sd, mob_db(mob_id)->jname, mob_id, progress, 20); } /*========================================== @@ -8562,7 +8660,7 @@ void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char pr *------------------------------------------*/ void clif_feel_hate_reset(struct map_session_data *sd) { - clif_starskill(sd, "", 0, 0, 30); + clif_starskill(sd, "", 0, 0, 30); } @@ -8573,17 +8671,17 @@ void clif_feel_hate_reset(struct map_session_data *sd) /// value: /// 0 = disabled /// 1 = enabled -void clif_equiptickack(struct map_session_data *sd, int flag) +void clif_equiptickack(struct map_session_data* sd, int flag) { - int fd; - nullpo_retv(sd); - fd = sd->fd; + int fd; + nullpo_retv(sd); + fd = sd->fd; - WFIFOHEAD(fd, packet_len(0x2d9)); - WFIFOW(fd, 0) = 0x2d9; - WFIFOL(fd, 2) = 0; - WFIFOL(fd, 6) = flag; - WFIFOSET(fd, packet_len(0x2d9)); + WFIFOHEAD(fd, packet_len(0x2d9)); + WFIFOW(fd, 0) = 0x2d9; + WFIFOL(fd, 2) = 0; + WFIFOL(fd, 6) = flag; + WFIFOSET(fd, packet_len(0x2d9)); } @@ -8592,16 +8690,16 @@ void clif_equiptickack(struct map_session_data *sd, int flag) /// open equip window: /// 0 = disabled /// 1 = enabled -void clif_equipcheckbox(struct map_session_data *sd) +void clif_equipcheckbox(struct map_session_data* sd) { - int fd; - nullpo_retv(sd); - fd = sd->fd; + int fd; + nullpo_retv(sd); + fd = sd->fd; - WFIFOHEAD(fd, packet_len(0x2da)); - WFIFOW(fd, 0) = 0x2da; - WFIFOB(fd, 2) = (sd->status.show_equip ? 1 : 0); - WFIFOSET(fd, packet_len(0x2da)); + WFIFOHEAD(fd, packet_len(0x2da)); + WFIFOW(fd, 0) = 0x2da; + WFIFOB(fd, 2) = (sd->status.show_equip ? 1 : 0); + WFIFOSET(fd, packet_len(0x2da)); } @@ -8610,97 +8708,98 @@ void clif_equipcheckbox(struct map_session_data *sd) /// 02d7 .W .24B .W .W .W .W .W .W .W .B {equip item}.28B* (ZC_EQUIPWIN_MICROSCOPE, PACKETVER >= 20100629) /// 0859 .W .24B .W .W .W .W .W .W .W .B {equip item}.28B* (ZC_EQUIPWIN_MICROSCOPE2, PACKETVER >= 20101124) /// 0859 .W .24B .W .W .W .W .W .W .W .W .B {equip item}.28B* (ZC_EQUIPWIN_MICROSCOPE2, PACKETVER >= 20110111) -void clif_viewequip_ack(struct map_session_data *sd, struct map_session_data *tsd) +void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* tsd) { - uint8 *buf; - int i, n, fd, offset = 0; + uint8* buf; + int i, n, fd, offset = 0; #if PACKETVER < 20100629 - const int s = 26; + const int s = 26; #else - const int s = 28; + const int s = 28; #endif - nullpo_retv(sd); - nullpo_retv(tsd); - fd = sd->fd; + nullpo_retv(sd); + nullpo_retv(tsd); + fd = sd->fd; - WFIFOHEAD(fd, MAX_INVENTORY * s + 43); - buf = WFIFOP(fd,0); + WFIFOHEAD(fd, MAX_INVENTORY * s + 43); + buf = WFIFOP(fd,0); #if PACKETVER < 20101124 - WBUFW(buf, 0) = 0x2d7; + WBUFW(buf, 0) = 0x2d7; #else - WBUFW(buf, 0) = 0x859; + WBUFW(buf, 0) = 0x859; #endif - safestrncpy((char *)WBUFP(buf, 4), tsd->status.name, NAME_LENGTH); - WBUFW(buf,28) = tsd->status.class_; - WBUFW(buf,30) = tsd->vd.hair_style; - WBUFW(buf,32) = tsd->vd.head_bottom; - WBUFW(buf,34) = tsd->vd.head_mid; - WBUFW(buf,36) = tsd->vd.head_top; + safestrncpy((char*)WBUFP(buf, 4), tsd->status.name, NAME_LENGTH); + WBUFW(buf,28) = tsd->status.class_; + WBUFW(buf,30) = tsd->vd.hair_style; + WBUFW(buf,32) = tsd->vd.head_bottom; + WBUFW(buf,34) = tsd->vd.head_mid; + WBUFW(buf,36) = tsd->vd.head_top; #if PACKETVER >= 20110111 - WBUFW(buf,38) = tsd->vd.robe; - offset+= 2; - buf = WBUFP(buf,2); + WBUFW(buf,38) = tsd->vd.robe; + offset+= 2; + buf = WBUFP(buf,2); #endif - WBUFW(buf,38) = tsd->vd.hair_color; - WBUFW(buf,40) = tsd->vd.cloth_color; - WBUFB(buf,42) = tsd->vd.sex; - - for (i=0,n=0; i < MAX_INVENTORY; i++) { - if (tsd->status.inventory[i].nameid <= 0 || tsd->inventory_data[i] == NULL) // Item doesn't exist - continue; - if (!itemdb_isequip2(tsd->inventory_data[i])) // Is not equippable - continue; - - // Inventory position - WBUFW(buf, n*s+43) = i + 2; - // Add refine, identify flag, element, etc. - clif_item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc_equippoint(tsd, i)); - // Add cards - clif_addcards(WBUFP(buf, n*s+55), &tsd->status.inventory[i]); - // Expiration date stuff, if all of those are set to 0 then the client doesn't show anything related (6 bytes) - WBUFL(buf, n*s+63) = tsd->status.inventory[i].expire_time; - WBUFW(buf, n*s+67) = 0; + WBUFW(buf,38) = tsd->vd.hair_color; + WBUFW(buf,40) = tsd->vd.cloth_color; + WBUFB(buf,42) = tsd->vd.sex; + + for(i=0,n=0; i < MAX_INVENTORY; i++) + { + if (tsd->status.inventory[i].nameid <= 0 || tsd->inventory_data[i] == NULL) // Item doesn't exist + continue; + if (!itemdb_isequip2(tsd->inventory_data[i])) // Is not equippable + continue; + + // Inventory position + WBUFW(buf, n*s+43) = i + 2; + // Add refine, identify flag, element, etc. + clif_item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc_equippoint(tsd, i)); + // Add cards + clif_addcards(WBUFP(buf, n*s+55), &tsd->status.inventory[i]); + // Expiration date stuff, if all of those are set to 0 then the client doesn't show anything related (6 bytes) + WBUFL(buf, n*s+63) = tsd->status.inventory[i].expire_time; + WBUFW(buf, n*s+67) = 0; #if PACKETVER >= 20100629 - if (tsd->inventory_data[i]->equip&EQP_VISIBLE) - WBUFW(buf, n*s+69) = tsd->inventory_data[i]->look; - else - WBUFW(buf, n*s+69) = 0; + if (tsd->inventory_data[i]->equip&EQP_VISIBLE) + WBUFW(buf, n*s+69) = tsd->inventory_data[i]->look; + else + WBUFW(buf, n*s+69) = 0; #endif - n++; - } + n++; + } - WFIFOW(fd, 2) = 43+offset+n*s; // Set length - WFIFOSET(fd, WFIFOW(fd, 2)); + WFIFOW(fd, 2) = 43+offset+n*s; // Set length + WFIFOSET(fd, WFIFOW(fd, 2)); } /// Display msgstringtable.txt string (ZC_MSG). /// 0291 .W -void clif_msg(struct map_session_data *sd, unsigned short id) +void clif_msg(struct map_session_data* sd, unsigned short id) { - int fd; - nullpo_retv(sd); - fd = sd->fd; + int fd; + nullpo_retv(sd); + fd = sd->fd; - WFIFOHEAD(fd, packet_len(0x291)); - WFIFOW(fd, 0) = 0x291; - WFIFOW(fd, 2) = id; // zero-based msgstringtable.txt index - WFIFOSET(fd, packet_len(0x291)); + WFIFOHEAD(fd, packet_len(0x291)); + WFIFOW(fd, 0) = 0x291; + WFIFOW(fd, 2) = id; // zero-based msgstringtable.txt index + WFIFOSET(fd, packet_len(0x291)); } /// Display msgstringtable.txt string and fill in a valid for %d format (ZC_MSG_VALUE). /// 0x7e2 .W .L -void clif_msg_value(struct map_session_data *sd, unsigned short id, int value) +void clif_msg_value(struct map_session_data* sd, unsigned short id, int value) { - int fd = sd->fd; + int fd = sd->fd; - WFIFOHEAD(fd, packet_len(0x7e2)); - WFIFOW(fd,0) = 0x7e2; - WFIFOW(fd,2) = id; - WFIFOL(fd,4) = value; - WFIFOSET(fd, packet_len(0x7e2)); + WFIFOHEAD(fd, packet_len(0x7e2)); + WFIFOW(fd,0) = 0x7e2; + WFIFOW(fd,2) = id; + WFIFOL(fd,4) = value; + WFIFOSET(fd, packet_len(0x7e2)); } @@ -8709,22 +8808,22 @@ void clif_msg_value(struct map_session_data *sd, unsigned short id, int value) /// /// NOTE: Message has following format and is printed in color 0xCDCDFF (purple): /// "[SkillName] Message" -void clif_msg_skill(struct map_session_data *sd, unsigned short skill_id, int msg_id) +void clif_msg_skill(struct map_session_data* sd, unsigned short skill_id, int msg_id) { - int fd = sd->fd; + int fd = sd->fd; - WFIFOHEAD(fd, packet_len(0x7e6)); - WFIFOW(fd,0) = 0x7e6; - WFIFOW(fd,2) = skill_id; - WFIFOL(fd,4) = msg_id; - WFIFOSET(fd, packet_len(0x7e6)); + WFIFOHEAD(fd, packet_len(0x7e6)); + WFIFOW(fd,0) = 0x7e6; + WFIFOW(fd,2) = skill_id; + WFIFOL(fd,4) = msg_id; + WFIFOSET(fd, packet_len(0x7e6)); } /// View player equip request denied -void clif_viewequip_fail(struct map_session_data *sd) +void clif_viewequip_fail(struct map_session_data* sd) { - clif_msg(sd, 0x54d); + clif_msg(sd, 0x54d); } @@ -8732,92 +8831,95 @@ void clif_viewequip_fail(struct map_session_data *sd) /// Returns true if the packet was parsed successfully. /// Formats: 0 - .w .w ( : ).?B 00 /// 1 - .w .w .24B .?B 00 -static bool clif_process_message(struct map_session_data *sd, int format, char **name_, int *namelen_, char **message_, int *messagelen_) -{ - char *text, *name, *message; - unsigned int packetlen, textlen, namelen, messagelen; - int fd = sd->fd; - - *name_ = NULL; - *namelen_ = 0; - *message_ = NULL; - *messagelen_ = 0; - - packetlen = RFIFOW(fd,2); - // basic structure checks - if (packetlen < 4 + 1) { - // 4-byte header and at least an empty string is expected - ShowWarning("clif_process_message: Received malformed packet from player '%s' (no message data)!\n", sd->status.name); - return false; - } - - text = (char *)RFIFOP(fd,4); - textlen = packetlen - 4; - - // process part of the packet - if (format == 0) { - // name and message are separated by ' : ' - // validate name - name = text; - namelen = strnlen(sd->status.name, NAME_LENGTH-1); // name length (w/o zero byte) - - if (strncmp(name, sd->status.name, namelen) || // the text must start with the speaker's name - name[namelen] != ' ' || name[namelen+1] != ':' || name[namelen+2] != ' ') { // followed by ' : ' - //Hacked message, or infamous "client desynch" issue where they pick one char while loading another. - ShowWarning("clif_process_message: Player '%s' sent a message using an incorrect name! Forcing a relog...\n", sd->status.name); - set_eof(fd); // Just kick them out to correct it. - return false; - } - - message = name + namelen + 3; - messagelen = textlen - namelen - 3; // this should be the message length (w/ zero byte included) - } else { - // name has fixed width - if (textlen < NAME_LENGTH + 1) { - ShowWarning("clif_process_message: Received malformed packet from player '%s' (packet length is incorrect)!\n", sd->status.name); - return false; - } - - // validate name - name = text; - namelen = strnlen(name, NAME_LENGTH-1); // name length (w/o zero byte) - - if (name[namelen] != '\0') { - // only restriction is that the name must be zero-terminated - ShowWarning("clif_process_message: Player '%s' sent an unterminated name!\n", sd->status.name); - return false; - } - - message = name + NAME_LENGTH; - messagelen = textlen - NAME_LENGTH; // this should be the message length (w/ zero byte included) - } - - if (messagelen != strnlen(message, messagelen)+1) { - // the declared length must match real length - ShowWarning("clif_process_message: Received malformed packet from player '%s' (length is incorrect)!\n", sd->status.name); - return false; - } - // verify part of the packet - if (message[messagelen-1] != '\0') { - // message must be zero-terminated - ShowWarning("clif_process_message: Player '%s' sent an unterminated message string!\n", sd->status.name); - return false; - } - if (messagelen > CHAT_SIZE_MAX-1) { - // messages mustn't be too long - // Normally you can only enter CHATBOX_SIZE-1 letters into the chat box, but Frost Joke / Dazzler's text can be longer. - // Also, the physical size of strings that use multibyte encoding can go multiple times over the chatbox capacity. - // Neither the official client nor server place any restriction on the length of the data in the packet, - // but we'll only allow reasonably long strings here. This also makes sure that they fit into the `chatlog` table. - ShowWarning("clif_process_message: Player '%s' sent a message too long ('%.*s')!\n", sd->status.name, CHAT_SIZE_MAX-1, message); - return false; - } - - *name_ = name; - *namelen_ = namelen; - *message_ = message; - *messagelen_ = messagelen; - return true; +static bool clif_process_message(struct map_session_data* sd, int format, char** name_, int* namelen_, char** message_, int* messagelen_) +{ + char *text, *name, *message; + unsigned int packetlen, textlen, namelen, messagelen; + int fd = sd->fd; + + *name_ = NULL; + *namelen_ = 0; + *message_ = NULL; + *messagelen_ = 0; + + packetlen = RFIFOW(fd,2); + // basic structure checks + if( packetlen < 4 + 1 ) + { // 4-byte header and at least an empty string is expected + ShowWarning("clif_process_message: Received malformed packet from player '%s' (no message data)!\n", sd->status.name); + return false; + } + + text = (char*)RFIFOP(fd,4); + textlen = packetlen - 4; + + // process part of the packet + if( format == 0 ) + {// name and message are separated by ' : ' + // validate name + name = text; + namelen = strnlen(sd->status.name, NAME_LENGTH-1); // name length (w/o zero byte) + + if( strncmp(name, sd->status.name, namelen) || // the text must start with the speaker's name + name[namelen] != ' ' || name[namelen+1] != ':' || name[namelen+2] != ' ' ) // followed by ' : ' + { + //Hacked message, or infamous "client desynch" issue where they pick one char while loading another. + ShowWarning("clif_process_message: Player '%s' sent a message using an incorrect name! Forcing a relog...\n", sd->status.name); + set_eof(fd); // Just kick them out to correct it. + return false; + } + + message = name + namelen + 3; + messagelen = textlen - namelen - 3; // this should be the message length (w/ zero byte included) + } + else + {// name has fixed width + if( textlen < NAME_LENGTH + 1 ) + { + ShowWarning("clif_process_message: Received malformed packet from player '%s' (packet length is incorrect)!\n", sd->status.name); + return false; + } + + // validate name + name = text; + namelen = strnlen(name, NAME_LENGTH-1); // name length (w/o zero byte) + + if( name[namelen] != '\0' ) + { // only restriction is that the name must be zero-terminated + ShowWarning("clif_process_message: Player '%s' sent an unterminated name!\n", sd->status.name); + return false; + } + + message = name + NAME_LENGTH; + messagelen = textlen - NAME_LENGTH; // this should be the message length (w/ zero byte included) + } + + if( messagelen != strnlen(message, messagelen)+1 ) + { // the declared length must match real length + ShowWarning("clif_process_message: Received malformed packet from player '%s' (length is incorrect)!\n", sd->status.name); + return false; + } + // verify part of the packet + if( message[messagelen-1] != '\0' ) + { // message must be zero-terminated + ShowWarning("clif_process_message: Player '%s' sent an unterminated message string!\n", sd->status.name); + return false; + } + if( messagelen > CHAT_SIZE_MAX-1 ) + { // messages mustn't be too long + // Normally you can only enter CHATBOX_SIZE-1 letters into the chat box, but Frost Joke / Dazzler's text can be longer. + // Also, the physical size of strings that use multibyte encoding can go multiple times over the chatbox capacity. + // Neither the official client nor server place any restriction on the length of the data in the packet, + // but we'll only allow reasonably long strings here. This also makes sure that they fit into the `chatlog` table. + ShowWarning("clif_process_message: Player '%s' sent a message too long ('%.*s')!\n", sd->status.name, CHAT_SIZE_MAX-1, message); + return false; + } + + *name_ = name; + *namelen_ = namelen; + *message_ = message; + *messagelen_ = messagelen; + return true; } // --------------------- @@ -8835,62 +8937,62 @@ static bool clif_process_message(struct map_session_data *sd, int format, char * // Only the first 'invalid' error that appears is used. static int clif_guess_PacketVer(int fd, int get_previous, int *error) { - static int err = 1; - static int packet_ver = -1; - int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex + static int err = 1; + static int packet_ver = -1; + int cmd, packet_len, value; //Value is used to temporarily store account/char_id/sex - if (get_previous) { - //For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex] - if (error) - *error = err; - return packet_ver; - } + if (get_previous) + {//For quick reruns, since the normal code flow is to fetch this once to identify the packet version, then again in the wanttoconnect function. [Skotlex] + if( error ) + *error = err; + return packet_ver; + } - //By default, start searching on the default one. - err = 1; - packet_ver = clif_config.packet_db_ver; - cmd = RFIFOW(fd,0); - packet_len = RFIFOREST(fd); + //By default, start searching on the default one. + err = 1; + packet_ver = clif_config.packet_db_ver; + cmd = RFIFOW(fd,0); + packet_len = RFIFOREST(fd); #define SET_ERROR(n) \ - if( err == 1 )\ - err = n;\ - //define SET_ERROR - - // FIXME: If the packet is not received at once, this will FAIL. - // Figure out, when it happens, that only part of the packet is - // received, or fix the function to be able to deal with that - // case. + if( err == 1 )\ + err = n;\ +//define SET_ERROR + + // FIXME: If the packet is not received at once, this will FAIL. + // Figure out, when it happens, that only part of the packet is + // received, or fix the function to be able to deal with that + // case. #define CHECK_PACKET_VER() \ - if( cmd != clif_config.connect_cmd[packet_ver] || packet_len != packet_db[packet_ver][cmd].len )\ - ;/* not wanttoconnection or wrong length */\ - else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < START_ACCOUNT_NUM || value > END_ACCOUNT_NUM )\ - { SET_ERROR(2); }/* invalid account_id */\ - else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) <= 0 )\ - { SET_ERROR(3); }/* invalid char_id */\ - /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) - don't care about login_id1 */\ - /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]) - don't care about client_tick */\ - else if( (value=(int)RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) != 0 && value != 1 )\ - { SET_ERROR(6); }/* invalid sex */\ - else\ - {\ - err = 0;\ - if( error )\ - *error = 0;\ - return packet_ver;\ - }\ - //define CHECK_PACKET_VER - - CHECK_PACKET_VER();//Default packet version found. - - for (packet_ver = MAX_PACKET_VER; packet_ver > 0; packet_ver--) { - //Start guessing the version, giving priority to the newer ones. [Skotlex] - CHECK_PACKET_VER(); - } - if (error) - *error = err; - packet_ver = -1; - return -1; + if( cmd != clif_config.connect_cmd[packet_ver] || packet_len != packet_db[packet_ver][cmd].len )\ + ;/* not wanttoconnection or wrong length */\ + else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[0])) < START_ACCOUNT_NUM || value > END_ACCOUNT_NUM )\ + { SET_ERROR(2); }/* invalid account_id */\ + else if( (value=(int)RFIFOL(fd, packet_db[packet_ver][cmd].pos[1])) <= 0 )\ + { SET_ERROR(3); }/* invalid char_id */\ + /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]) - don't care about login_id1 */\ + /* RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]) - don't care about client_tick */\ + else if( (value=(int)RFIFOB(fd, packet_db[packet_ver][cmd].pos[4])) != 0 && value != 1 )\ + { SET_ERROR(6); }/* invalid sex */\ + else\ + {\ + err = 0;\ + if( error )\ + *error = 0;\ + return packet_ver;\ + }\ +//define CHECK_PACKET_VER + + CHECK_PACKET_VER();//Default packet version found. + + for (packet_ver = MAX_PACKET_VER; packet_ver > 0; packet_ver--) + { //Start guessing the version, giving priority to the newer ones. [Skotlex] + CHECK_PACKET_VER(); + } + if( error ) + *error = err; + packet_ver = -1; + return -1; #undef SET_ERROR #undef CHECK_PACKET_VER } @@ -8905,86 +9007,87 @@ static int clif_guess_PacketVer(int fd, int get_previous, int *error) /// 0072 .L .L .L .L .B (CZ_ENTER) /// 0436 .L .L .L .L .B (CZ_ENTER2) /// There are various variants of this packet, some of them have padding between fields. -void clif_parse_WantToConnection(int fd, TBL_PC *sd) -{ - struct block_list *bl; - struct auth_node *node; - int cmd, account_id, char_id, login_id1, sex; - unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex] - int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) - - if (sd) { - ShowError("clif_parse_WantToConnection : invalid request (character already logged in)\n"); - return; - } - - // Only valid packet version get here - packet_ver = clif_guess_PacketVer(fd, 1, NULL); - - cmd = RFIFOW(fd,0); - account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]); - char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]); - login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]); - client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]); - sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]); - - if (packet_ver < 5 || // reject really old client versions - (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04 - (packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0)) { // version not allowed - // packet version rejected - ShowInfo("Rejected connection attempt, forbidden packet version (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"', Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%s"CL_RESET"').\n", account_id, char_id, packet_ver, ip2str(session[fd]->client_addr, NULL)); - WFIFOHEAD(fd,packet_len(0x6a)); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = 5; // Your Game's EXE file is not the latest version - WFIFOSET(fd,packet_len(0x6a)); - set_eof(fd); - return; - } - - if (runflag != MAPSERVER_ST_RUNNING) { - // not allowed - clif_authfail_fd(fd,1);// server closed - return; - } - - //Check for double login. - bl = map_id2bl(account_id); - if (bl && bl->type != BL_PC) { - ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id); - WFIFOHEAD(fd,packet_len(0x6a)); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = 3; // Rejected by server - WFIFOSET(fd,packet_len(0x6a)); - set_eof(fd); - return; - } - - if (bl || - ((node=chrif_search(account_id)) && //An already existing node is valid only if it is for this login. - !(node->account_id == account_id && node->char_id == char_id && node->state == ST_LOGIN))) { - clif_authfail_fd(fd, 8); //Still recognizes last connection - return; - } - - CREATE(sd, TBL_PC, 1); - sd->fd = fd; - sd->packet_ver = packet_ver; - session[fd]->session_data = sd; - - pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd); +void clif_parse_WantToConnection(int fd, TBL_PC* sd) +{ + struct block_list* bl; + struct auth_node* node; + int cmd, account_id, char_id, login_id1, sex; + unsigned int client_tick; //The client tick is a tick, therefore it needs be unsigned. [Skotlex] + int packet_ver; // 5: old, 6: 7july04, 7: 13july04, 8: 26july04, 9: 9aug04/16aug04/17aug04, 10: 6sept04, 11: 21sept04, 12: 18oct04, 13: 25oct04 (by [Yor]) + + if (sd) { + ShowError("clif_parse_WantToConnection : invalid request (character already logged in)\n"); + return; + } + + // Only valid packet version get here + packet_ver = clif_guess_PacketVer(fd, 1, NULL); + + cmd = RFIFOW(fd,0); + account_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[0]); + char_id = RFIFOL(fd, packet_db[packet_ver][cmd].pos[1]); + login_id1 = RFIFOL(fd, packet_db[packet_ver][cmd].pos[2]); + client_tick = RFIFOL(fd, packet_db[packet_ver][cmd].pos[3]); + sex = RFIFOB(fd, packet_db[packet_ver][cmd].pos[4]); + + if( packet_ver < 5 || // reject really old client versions + (packet_ver <= 9 && (battle_config.packet_ver_flag & 1) == 0) || // older than 6sept04 + (packet_ver > 9 && (battle_config.packet_ver_flag & 1<<(packet_ver-9)) == 0)) // version not allowed + {// packet version rejected + ShowInfo("Rejected connection attempt, forbidden packet version (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"', Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%s"CL_RESET"').\n", account_id, char_id, packet_ver, ip2str(session[fd]->client_addr, NULL)); + WFIFOHEAD(fd,packet_len(0x6a)); + WFIFOW(fd,0) = 0x6a; + WFIFOB(fd,2) = 5; // Your Game's EXE file is not the latest version + WFIFOSET(fd,packet_len(0x6a)); + set_eof(fd); + return; + } + + if( runflag != MAPSERVER_ST_RUNNING ) + {// not allowed + clif_authfail_fd(fd,1);// server closed + return; + } + + //Check for double login. + bl = map_id2bl(account_id); + if(bl && bl->type != BL_PC) { + ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id); + WFIFOHEAD(fd,packet_len(0x6a)); + WFIFOW(fd,0) = 0x6a; + WFIFOB(fd,2) = 3; // Rejected by server + WFIFOSET(fd,packet_len(0x6a)); + set_eof(fd); + return; + } + + if (bl || + ((node=chrif_search(account_id)) && //An already existing node is valid only if it is for this login. + !(node->account_id == account_id && node->char_id == char_id && node->state == ST_LOGIN))) + { + clif_authfail_fd(fd, 8); //Still recognizes last connection + return; + } + + CREATE(sd, TBL_PC, 1); + sd->fd = fd; + sd->packet_ver = packet_ver; + session[fd]->session_data = sd; + + pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd); #if PACKETVER < 20070521 - WFIFOHEAD(fd,4); - WFIFOL(fd,0) = sd->bl.id; - WFIFOSET(fd,4); + WFIFOHEAD(fd,4); + WFIFOL(fd,0) = sd->bl.id; + WFIFOSET(fd,4); #else - WFIFOHEAD(fd,packet_len(0x283)); - WFIFOW(fd,0) = 0x283; - WFIFOL(fd,2) = sd->bl.id; - WFIFOSET(fd,packet_len(0x283)); + WFIFOHEAD(fd,packet_len(0x283)); + WFIFOW(fd,0) = 0x283; + WFIFOL(fd,2) = sd->bl.id; + WFIFOSET(fd,packet_len(0x283)); #endif - chrif_authreq(sd); + chrif_authreq(sd); } @@ -8992,325 +9095,332 @@ void clif_parse_WantToConnection(int fd, TBL_PC *sd) /// 007d void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { - if (sd->bl.prev != NULL) - return; + if(sd->bl.prev != NULL) + return; - if (!sd->state.active) { - //Character loading is not complete yet! - //Let pc_reg_received reinvoke this when ready. - sd->state.connect_new = 0; - return; - } + if (!sd->state.active) + { //Character loading is not complete yet! + //Let pc_reg_received reinvoke this when ready. + sd->state.connect_new = 0; + return; + } - if (sd->state.rewarp) { - //Rewarp player. - sd->state.rewarp = 0; - clif_changemap(sd, sd->mapindex, sd->bl.x, sd->bl.y); - return; - } + if (sd->state.rewarp) + { //Rewarp player. + sd->state.rewarp = 0; + clif_changemap(sd, sd->mapindex, sd->bl.x, sd->bl.y); + return; + } - sd->state.warping = 0; + sd->state.warping = 0; - // look + // look #if PACKETVER < 4 - clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); - clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); #else - clif_changelook(&sd->bl,LOOK_WEAPON,0); + clif_changelook(&sd->bl,LOOK_WEAPON,0); #endif - if (sd->vd.cloth_color) - clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF); - - // item - clif_inventorylist(sd); // inventory list first, otherwise deleted items in pc_checkitem show up as 'unknown item' - pc_checkitem(sd); - - // cart - if (pc_iscarton(sd)) { - clif_cartlist(sd); - clif_updatestatus(sd,SP_CARTINFO); - } - - // weight - clif_updatestatus(sd,SP_WEIGHT); - clif_updatestatus(sd,SP_MAXWEIGHT); - - // guild - // (needs to go before clif_spawn() to show guild emblems correctly) - if (sd->status.guild_id) - guild_send_memberinfoshort(sd,1); - - if (battle_config.pc_invincible_time > 0) { - if (map_flag_gvg(sd->bl.m)) - pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1); - else - pc_setinvincibletimer(sd,battle_config.pc_invincible_time); - } - - if (map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs) - map_spawnmobs(sd->bl.m); - if (!(sd->sc.option&OPTION_INVISIBLE)) { - // increment the number of pvp players on the map - map[sd->bl.m].users_pvp++; - } - if (map[sd->bl.m].instance_id) { - instance[map[sd->bl.m].instance_id].users++; - instance_check_idle(map[sd->bl.m].instance_id); - } - sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] - - // reset the callshop flag if the player changes map - sd->state.callshop = 0; - - map_addblock(&sd->bl); - clif_spawn(&sd->bl); - - // Party - // (needs to go after clif_spawn() to show hp bars correctly) - if (sd->status.party_id) { - party_send_movemap(sd); - clif_party_hp(sd); // Show hp after displacement [LuzZza] - } - - if (sd->bg_id) clif_bg_hp(sd); // BattleGround System - - if (map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { - if (!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] - if (!map[sd->bl.m].flag.pvp_nocalcrank) - sd->pvp_timer = add_timer(gettick()+200, pc_calc_pvprank_timer, sd->bl.id, 0); - sd->pvp_rank = 0; - sd->pvp_lastusers = 0; - sd->pvp_point = 5; - sd->pvp_won = 0; - sd->pvp_lost = 0; - } - clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); - } else - // set flag, if it's a duel [LuzZza] - if (sd->duel_group) - clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); - - if (map[sd->bl.m].flag.gvg_dungeon) - clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here. - - if (map_flag_gvg(sd->bl.m)) - clif_map_property(sd, MAPPROPERTY_AGITZONE); - - // info about nearby objects - // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) - map_foreachinarea(clif_getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); - - // pet - if (sd->pd) { - if (battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m)) { - //Return the pet to egg. [Skotlex] - clif_displaymessage(sd->fd, msg_txt(666)); - pet_menu(sd, 3); //Option 3 is return to egg. - } else { - map_addblock(&sd->pd->bl); - clif_spawn(&sd->pd->bl); - clif_send_petdata(sd,sd->pd,0,0); - clif_send_petstatus(sd); - // skill_unit_move(&sd->pd->bl,gettick(),1); - } - } - - //homunculus [blackhole89] - if (merc_is_hom_active(sd->hd)) { - map_addblock(&sd->hd->bl); - clif_spawn(&sd->hd->bl); - clif_send_homdata(sd,SP_ACK,0); - clif_hominfo(sd,sd->hd,1); - clif_hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice - clif_homskillinfoblock(sd); - if (battle_config.hom_setting&0x8) - status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change - if (!(battle_config.hom_setting&0x2)) - skill_unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately - } - - if (sd->md) { - map_addblock(&sd->md->bl); - clif_spawn(&sd->md->bl); - clif_mercenary_info(sd); - clif_mercenary_skillblock(sd); - status_calc_bl(&sd->md->bl, SCB_SPEED); //Mercenary mimic their master's speed on each map change - } - - if (sd->ed) { - map_addblock(&sd->ed->bl); - clif_spawn(&sd->ed->bl); - clif_elemental_info(sd); - clif_elemental_updatestatus(sd,SP_HP); - clif_hpmeter_single(sd->fd,sd->ed->bl.id,sd->ed->battle_status.hp,sd->ed->battle_status.matk_max); - clif_elemental_updatestatus(sd,SP_SP); - status_calc_bl(&sd->ed->bl, SCB_SPEED); //Elemental mimic their master's speed on each map change - } - - if (sd->state.connect_new) { - int lv; - sd->state.connect_new = 0; - clif_skillinfoblock(sd); - clif_hotkeys_send(sd); - clif_updatestatus(sd,SP_BASEEXP); - clif_updatestatus(sd,SP_NEXTBASEEXP); - clif_updatestatus(sd,SP_JOBEXP); - clif_updatestatus(sd,SP_NEXTJOBEXP); - clif_updatestatus(sd,SP_SKILLPOINT); - clif_initialstatus(sd); - - if (sd->sc.option&OPTION_FALCON) - clif_status_load(&sd->bl, SI_FALCON, 1); - - if (sd->sc.option&OPTION_RIDING) - clif_status_load(&sd->bl, SI_RIDING, 1); - else if (sd->sc.option&OPTION_WUGRIDER) - clif_status_load(&sd->bl, SI_WUGRIDER, 1); - - if (sd->status.manner < 0) - sc_start(&sd->bl,SC_NOCHAT,100,0,0); - - //Auron reported that This skill only triggers when you logon on the map o.O [Skotlex] - if ((lv = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) { - if (sd->bl.m == sd->feel_map[0].m - || sd->bl.m == sd->feel_map[1].m - || sd->bl.m == sd->feel_map[2].m) - sc_start(&sd->bl, SC_KNOWLEDGE, 100, lv, skill_get_time(SG_KNOWLEDGE, lv)); - } - - if (sd->pd && sd->pd->pet.intimate > 900) - clif_pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd)); - - if (merc_is_hom_active(sd->hd)) - merc_hom_init_timers(sd->hd); - - if (night_flag && map[sd->bl.m].flag.nightenabled) { - sd->state.night = 1; - clif_status_load(&sd->bl, SI_NIGHT, 1); - } - - // Notify everyone that this char logged in [Skotlex]. - map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); - - //Login Event - npc_script_event(sd, NPCE_LOGIN); - } else { - //For some reason the client "loses" these on warp/map-change. - clif_updatestatus(sd,SP_STR); - clif_updatestatus(sd,SP_AGI); - clif_updatestatus(sd,SP_VIT); - clif_updatestatus(sd,SP_INT); - clif_updatestatus(sd,SP_DEX); - clif_updatestatus(sd,SP_LUK); - - // abort currently running script - sd->state.using_fake_npc = 0; - sd->state.menu_or_input = 0; - sd->npc_menu = 0; - - if (sd->npc_id) - npc_event_dequeue(sd); - } - - if (sd->state.changemap) { - // restore information that gets lost on map-change + if(sd->vd.cloth_color) + clif_refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF); + + // item + clif_inventorylist(sd); // inventory list first, otherwise deleted items in pc_checkitem show up as 'unknown item' + pc_checkitem(sd); + + // cart + if(pc_iscarton(sd)) { + clif_cartlist(sd); + clif_updatestatus(sd,SP_CARTINFO); + } + + // weight + clif_updatestatus(sd,SP_WEIGHT); + clif_updatestatus(sd,SP_MAXWEIGHT); + + // guild + // (needs to go before clif_spawn() to show guild emblems correctly) + if(sd->status.guild_id) + guild_send_memberinfoshort(sd,1); + + if(battle_config.pc_invincible_time > 0) { + if(map_flag_gvg(sd->bl.m)) + pc_setinvincibletimer(sd,battle_config.pc_invincible_time<<1); + else + pc_setinvincibletimer(sd,battle_config.pc_invincible_time); + } + + if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) + map_spawnmobs(sd->bl.m); + if( !(sd->sc.option&OPTION_INVISIBLE) ) + {// increment the number of pvp players on the map + map[sd->bl.m].users_pvp++; + } + if( map[sd->bl.m].instance_id ) + { + instance[map[sd->bl.m].instance_id].users++; + instance_check_idle(map[sd->bl.m].instance_id); + } + sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] + + // reset the callshop flag if the player changes map + sd->state.callshop = 0; + + map_addblock(&sd->bl); + clif_spawn(&sd->bl); + + // Party + // (needs to go after clif_spawn() to show hp bars correctly) + if(sd->status.party_id) { + party_send_movemap(sd); + clif_party_hp(sd); // Show hp after displacement [LuzZza] + } + + if( sd->bg_id ) clif_bg_hp(sd); // BattleGround System + + if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { + if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] + if (!map[sd->bl.m].flag.pvp_nocalcrank) + sd->pvp_timer = add_timer(gettick()+200, pc_calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_rank = 0; + sd->pvp_lastusers = 0; + sd->pvp_point = 5; + sd->pvp_won = 0; + sd->pvp_lost = 0; + } + clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); + } else + // set flag, if it's a duel [LuzZza] + if(sd->duel_group) + clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); + + if (map[sd->bl.m].flag.gvg_dungeon) + clif_map_property(sd, MAPPROPERTY_FREEPVPZONE); //TODO: Figure out the real packet to send here. + + if( map_flag_gvg(sd->bl.m) ) + clif_map_property(sd, MAPPROPERTY_AGITZONE); + + // info about nearby objects + // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) + map_foreachinarea(clif_getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); + + // pet + if( sd->pd ) + { + if( battle_config.pet_no_gvg && map_flag_gvg(sd->bl.m) ) + { //Return the pet to egg. [Skotlex] + clif_displaymessage(sd->fd, msg_txt(666)); + pet_menu(sd, 3); //Option 3 is return to egg. + } + else + { + map_addblock(&sd->pd->bl); + clif_spawn(&sd->pd->bl); + clif_send_petdata(sd,sd->pd,0,0); + clif_send_petstatus(sd); +// skill_unit_move(&sd->pd->bl,gettick(),1); + } + } + + //homunculus [blackhole89] + if( merc_is_hom_active(sd->hd) ) + { + map_addblock(&sd->hd->bl); + clif_spawn(&sd->hd->bl); + clif_send_homdata(sd,SP_ACK,0); + clif_hominfo(sd,sd->hd,1); + clif_hominfo(sd,sd->hd,0); //for some reason, at least older clients want this sent twice + clif_homskillinfoblock(sd); + if( battle_config.hom_setting&0x8 ) + status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change + if( !(battle_config.hom_setting&0x2) ) + skill_unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately + } + + if( sd->md ) { + map_addblock(&sd->md->bl); + clif_spawn(&sd->md->bl); + clif_mercenary_info(sd); + clif_mercenary_skillblock(sd); + } + + if( sd->ed ) { + map_addblock(&sd->ed->bl); + clif_spawn(&sd->ed->bl); + clif_elemental_info(sd); + clif_elemental_updatestatus(sd,SP_HP); + clif_hpmeter_single(sd->fd,sd->ed->bl.id,sd->ed->battle_status.hp,sd->ed->battle_status.matk_max); + clif_elemental_updatestatus(sd,SP_SP); + } + + if(sd->state.connect_new) { + int lv; + sd->state.connect_new = 0; + clif_skillinfoblock(sd); + clif_hotkeys_send(sd); + clif_updatestatus(sd,SP_BASEEXP); + clif_updatestatus(sd,SP_NEXTBASEEXP); + clif_updatestatus(sd,SP_JOBEXP); + clif_updatestatus(sd,SP_NEXTJOBEXP); + clif_updatestatus(sd,SP_SKILLPOINT); + clif_initialstatus(sd); + + if (sd->sc.option&OPTION_FALCON) + clif_status_load(&sd->bl, SI_FALCON, 1); + + if (sd->sc.option&OPTION_RIDING) + clif_status_load(&sd->bl, SI_RIDING, 1); + else if (sd->sc.option&OPTION_WUGRIDER) + clif_status_load(&sd->bl, SI_WUGRIDER, 1); + + if(sd->status.manner < 0) + sc_start(&sd->bl,SC_NOCHAT,100,0,0); + + //Auron reported that This skill only triggers when you logon on the map o.O [Skotlex] + if ((lv = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) { + if(sd->bl.m == sd->feel_map[0].m + || sd->bl.m == sd->feel_map[1].m + || sd->bl.m == sd->feel_map[2].m) + sc_start(&sd->bl, SC_KNOWLEDGE, 100, lv, skill_get_time(SG_KNOWLEDGE, lv)); + } + + if(sd->pd && sd->pd->pet.intimate > 900) + clif_pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd)); + + if(merc_is_hom_active(sd->hd)) + merc_hom_init_timers(sd->hd); + + if (night_flag && map[sd->bl.m].flag.nightenabled) { + sd->state.night = 1; + clif_status_load(&sd->bl, SI_NIGHT, 1); + } + + // Notify everyone that this char logged in [Skotlex]. + map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); + + //Login Event + npc_script_event(sd, NPCE_LOGIN); + } else { + //For some reason the client "loses" these on warp/map-change. + clif_updatestatus(sd,SP_STR); + clif_updatestatus(sd,SP_AGI); + clif_updatestatus(sd,SP_VIT); + clif_updatestatus(sd,SP_INT); + clif_updatestatus(sd,SP_DEX); + clif_updatestatus(sd,SP_LUK); + + // abort currently running script + sd->state.using_fake_npc = 0; + sd->state.menu_or_input = 0; + sd->npc_menu = 0; + + if(sd->npc_id) + npc_event_dequeue(sd); + } + + if( sd->state.changemap ) + {// restore information that gets lost on map-change #if PACKETVER >= 20070918 - clif_partyinvitationstate(sd); - clif_equipcheckbox(sd); + clif_partyinvitationstate(sd); + clif_equipcheckbox(sd); #endif - if ((battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) && - (map_flag_gvg(sd->state.pmap) || map_flag_gvg(sd->bl.m) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground)) - status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - - if (night_flag && map[sd->bl.m].flag.nightenabled) { - //Display night. - if (!sd->state.night) { - sd->state.night = 1; - clif_status_load(&sd->bl, SI_NIGHT, 1); - } - } else if (sd->state.night) { - //Clear night display. - sd->state.night = 0; - clif_status_load(&sd->bl, SI_NIGHT, 0); - } - - if (map[sd->bl.m].flag.battleground) { - clif_map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode - if (map[sd->bl.m].flag.battleground == 2) - clif_bg_updatescore_single(sd); - } - - if (map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m)) { - char output[128]; - sprintf(output, "[ Kill Steal Protection Disable. KS is allowed in this map ]"); - clif_broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF); - } - - map_iwall_get(sd); // Updates Walls Info on this Map to Client - sd->state.changemap = false; - } - - mail_clear(sd); - - /* Guild Aura Init */ - if (sd->state.gmaster_flag) { - guild_guildaura_refresh(sd,GD_LEADERSHIP,guild_checkskill(sd->state.gmaster_flag,GD_LEADERSHIP)); - guild_guildaura_refresh(sd,GD_GLORYWOUNDS,guild_checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS)); - guild_guildaura_refresh(sd,GD_SOULCOLD,guild_checkskill(sd->state.gmaster_flag,GD_SOULCOLD)); - guild_guildaura_refresh(sd,GD_HAWKEYES,guild_checkskill(sd->state.gmaster_flag,GD_HAWKEYES)); - } - - if (sd->state.vending) { /* show we have a vending */ - clif_openvending(sd,sd->bl.id,sd->vending); - clif_showvendingboard(&sd->bl,sd->message,0); - } - - if (map[sd->bl.m].flag.loadevent) // Lance - npc_script_event(sd, NPCE_LOADMAP); - - if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) - clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka] - - if (sd->sc.opt2) //Client loses these on warp. - clif_changeoption(&sd->bl); - - clif_weather_check(sd); - - // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first) - if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) - npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); - else - sd->areanpc_id = 0; - - /* it broke at some point (e.g. during a crash), so we make it visibly dead again. */ - if (!sd->status.hp && !pc_isdead(sd) && status_isdead(&sd->bl)) - pc_setdead(sd); - - // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris] - if (pc_isdead(sd)) - clif_clearunit_area(&sd->bl, CLR_DEAD); - else { - skill_usave_trigger(sd); - clif_changed_dir(&sd->bl, SELF); - } - - // Trigger skill effects if you appear standing on them - if (!battle_config.pc_invincible_time) - skill_unit_move(&sd->bl,gettick(),1); + if( (battle_config.bg_flee_penalty != 100 || battle_config.gvg_flee_penalty != 100) && + (map_flag_gvg(sd->state.pmap) || map_flag_gvg(sd->bl.m) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground) ) + status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty + + if( night_flag && map[sd->bl.m].flag.nightenabled ) + { //Display night. + if( !sd->state.night ) + { + sd->state.night = 1; + clif_status_load(&sd->bl, SI_NIGHT, 1); + } + } + else if( sd->state.night ) + { //Clear night display. + sd->state.night = 0; + clif_status_load(&sd->bl, SI_NIGHT, 0); + } + + if( map[sd->bl.m].flag.battleground ) + { + clif_map_type(sd, MAPTYPE_BATTLEFIELD); // Battleground Mode + if( map[sd->bl.m].flag.battleground == 2 ) + clif_bg_updatescore_single(sd); + } + + if( map[sd->bl.m].flag.allowks && !map_flag_ks(sd->bl.m) ) + { + char output[128]; + sprintf(output, "[ Kill Steal Protection Disable. KS is allowed in this map ]"); + clif_broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF); + } + + map_iwall_get(sd); // Updates Walls Info on this Map to Client + sd->state.changemap = false; + } + + mail_clear(sd); + + /* Guild Aura Init */ + if( sd->state.gmaster_flag ) { + guild_guildaura_refresh(sd,GD_LEADERSHIP,guild_checkskill(sd->state.gmaster_flag,GD_LEADERSHIP)); + guild_guildaura_refresh(sd,GD_GLORYWOUNDS,guild_checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS)); + guild_guildaura_refresh(sd,GD_SOULCOLD,guild_checkskill(sd->state.gmaster_flag,GD_SOULCOLD)); + guild_guildaura_refresh(sd,GD_HAWKEYES,guild_checkskill(sd->state.gmaster_flag,GD_HAWKEYES)); + } + + if( sd->state.vending ) { /* show we have a vending */ + clif_openvending(sd,sd->bl.id,sd->vending); + clif_showvendingboard(&sd->bl,sd->message,0); + } + + if(map[sd->bl.m].flag.loadevent) // Lance + npc_script_event(sd, NPCE_LOADMAP); + + if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) + clif_status_load(&sd->bl, SI_DEVIL, 1); //blindness [Komurka] + + if (sd->sc.opt2) //Client loses these on warp. + clif_changeoption(&sd->bl); + + clif_weather_check(sd); + + // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first) + if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) + npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); + else + sd->areanpc_id = 0; + + /* it broke at some point (e.g. during a crash), so we make it visibly dead again. */ + if( !sd->status.hp && !pc_isdead(sd) && status_isdead(&sd->bl) ) + pc_setdead(sd); + + // If player is dead, and is spawned (such as @refresh) send death packet. [Valaris] + if(pc_isdead(sd)) + clif_clearunit_area(&sd->bl, CLR_DEAD); + else { + skill_usave_trigger(sd); + clif_changed_dir(&sd->bl, SELF); + } + +// Trigger skill effects if you appear standing on them + if(!battle_config.pc_invincible_time) + skill_unit_move(&sd->bl,gettick(),1); } /// Server's tick (ZC_NOTIFY_TIME). /// 007f