diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 181 |
1 files changed, 108 insertions, 73 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 887fa9d64..8ab6e71a4 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -451,8 +451,8 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; case AREA_CHAT_WOC: nullpo_retr(true, bl); - 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); + map->foreachinarea(clif->send_sub, bl->m, bl->x-CHAT_AREA_SIZE, bl->y-CHAT_AREA_SIZE, + bl->x+CHAT_AREA_SIZE, bl->y+CHAT_AREA_SIZE, BL_PC, buf, len, bl, AREA_WOC); break; case CHAT: @@ -677,7 +677,8 @@ void clif_authok(struct map_session_data *sd) #if PACKETVER >= 20080102 p.font = sd->status.font; #endif -#if PACKETVER >= 20141016 +// Some clients smaller than 20160330 cant be tested [4144] +#if PACKETVER >= 20141016 && PACKETVER < 20160330 p.sex = sd->status.sex; #endif clif->send(&p,sizeof(p),&sd->bl,SELF); @@ -1077,15 +1078,21 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu #endif #if PACKETVER >= 20150513 p.body = vd->body_style; +#endif +/* Might be earlier, this is when the named item bug began */ +#if PACKETVER >= 20131223 safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH); #endif - clif->send(&p,sizeof(p),tsd?&tsd->bl:bl,target); if (clif->isdisguised(bl)) { #if PACKETVER >= 20091103 p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE +#if PACKETVER >= 20131223 + p.AID = -bl->id; +#else p.GID = -bl->id; +#endif #else p.GID = -bl->id; #endif @@ -1220,6 +1227,9 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { #endif #if PACKETVER >= 20150513 p.body = vd->body_style; +#endif +/* Might be earlier, this is when the named item bug began */ +#if PACKETVER >= 20131223 safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH); #endif if (clif->isdisguised(bl)) { @@ -1228,7 +1238,11 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { clif->send(&p,sizeof(p),bl,target); #if PACKETVER >= 20091103 p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE +#if PACKETVER >= 20131223 + p.AID = -bl->id; +#else p.GID = -bl->id; +#endif #else p.GID = -bl->id; #endif @@ -1262,7 +1276,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, #endif #if PACKETVER >= 20131223 p.AID = bl->id; - p.GID = (tsd) ? tsd->status.char_id : 0; // CCODE + p.GID = (sd) ? sd->status.char_id : 0; // CCODE #else p.GID = bl->id; #endif @@ -1312,6 +1326,9 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, #endif #if PACKETVER >= 20150513 p.body = vd->body_style; +#endif +/* Might be earlier, this is when the named item bug began */ +#if PACKETVER >= 20131223 safestrncpy(p.name, clif->get_bl_name(bl), NAME_LENGTH); #endif @@ -1320,7 +1337,11 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, if (clif->isdisguised(bl)) { #if PACKETVER >= 20091103 p.objecttype = pc->db_checkid(status->get_viewdata(bl)->class) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE +#if PACKETVER >= 20131223 + p.AID = -bl->id; +#else p.GID = -bl->id; +#endif #else p.GID = -bl->id; #endif @@ -1332,7 +1353,7 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, /// 01b0 <id>.L <type>.B <value>.L /// type: /// unused -void clif_class_change(struct block_list *bl, int class_, int type) +void clif_class_change(struct block_list *bl, int class_, int type, struct map_session_data *sd) { nullpo_retv(bl); @@ -1343,7 +1364,11 @@ void clif_class_change(struct block_list *bl, int class_, int type) WBUFL(buf,2)=bl->id; WBUFB(buf,6)=type; WBUFL(buf,7)=class_; - clif->send(buf,packet_len(0x1b0),bl,AREA); + + if (sd == NULL) + clif->send(buf, packet_len(0x1b0), bl, AREA); + else + clif->send(buf, packet_len(0x1b0), &sd->bl, SELF); } } @@ -2378,23 +2403,37 @@ void clif_addcards2(unsigned short *cards, struct item* item) { } /** - * Fills in RandomOptions(Bonuses) of items into the buffer + * Fills in ItemOptions(Bonuses) of items into the buffer * - * Dummy datais used since this feature isn't supported yet (ITEM_RDM_OPT). - * A maximum of 5 random options can be supported. + * A maximum of 5 item options can be supported. * * @param buf[in,out] The buffer to write to. The pointer must be valid and initialized. * @param item[in] The source item. */ -void clif_add_random_options(unsigned char* buf, struct item* item) -{ - int i; - nullpo_retv(buf); - for (i = 0; i < 5; i++){ - WBUFW(buf,i*5+0) = 0; // OptIndex - WBUFW(buf,i*5+2) = 0; // Value - WBUFB(buf,i*5+4) = 0; // Param1 + int clif_add_item_options(struct ItemOptions *buf, const struct item *it) +{ + int i = 0, j = 0, total_options = 0; + + nullpo_ret(buf); + + // Append the buffer with existing options first. + for (i = 0; i < MAX_ITEM_OPTIONS; i++) { + if (it->option[i].index) { + WBUFW(buf, j * 5 + 0) = it->option[i].index; // OptIndex + WBUFW(buf, j * 5 + 2) = it->option[i].value; // Value + WBUFB(buf, j * 5 + 4) = it->option[i].param; // Param1 + total_options++; + j++; + } + } + // Append the remaining buffer with no values; + for (; j < MAX_ITEM_OPTIONS || j < 5; j++) { + WBUFW(buf, j * 5 + 0) = 0; + WBUFW(buf, j * 5 + 2) = 0; + WBUFB(buf, j * 5 + 4) = 0; } + + return total_options; } /// Notifies the client, about a received inventory item or the result of a pick-up request. @@ -2418,9 +2457,6 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { p.count = amount; if( !fail ) { -#if PACKETVER >= 20150226 - int i; -#endif if( n < 0 || n >= MAX_INVENTORY || sd->status.inventory[n].nameid <=0 || sd->inventory_data[n] == NULL ) return; @@ -2445,11 +2481,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { p.bindOnEquipType = sd->status.inventory[n].bound && !itemdb->isstackable2(sd->inventory_data[n]) ? 2 : sd->inventory_data[n]->flag.bindonequip ? 1 : 0; #endif #if PACKETVER >= 20150226 - for (i=0; i<5; i++){ - p.option_data[i].index = 0; - p.option_data[i].value = 0; - p.option_data[i].param = 0; - } + clif->add_item_options(&p.option_data[0], &sd->status.inventory[n]); #endif } p.result = (unsigned char)fail; @@ -2522,41 +2554,39 @@ void clif_item_sub(unsigned char *buf, int n, struct item *i, struct item_data * } -void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct item_data *id, int eqp_pos) { -#if PACKETVER >= 20150226 - int j; -#endif +void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *it, struct item_data *id, int eqp_pos) +{ nullpo_retv(p); - nullpo_retv(i); + nullpo_retv(it); nullpo_retv(id); p->index = idx; if (id->view_id > 0) p->ITID = id->view_id; else - p->ITID = i->nameid; + p->ITID = it->nameid; p->type = itemtype(id->type); #if PACKETVER < 20120925 - p->IsIdentified = i->identify ? 1 : 0; + p->IsIdentified = it->identify ? 1 : 0; #endif p->location = eqp_pos; - p->WearState = i->equip; + p->WearState = it->equip; #if PACKETVER < 20120925 - p->IsDamaged = (i->attribute & ATTR_BROKEN) != 0 ? 1 : 0; + p->IsDamaged = (it->attribute & ATTR_BROKEN) != 0 ? 1 : 0; #endif - p->RefiningLevel = i->refine; + p->RefiningLevel = it->refine; - clif->addcards2(&p->slot.card[0], i); + clif->addcards2(&p->slot.card[0], it); #if PACKETVER >= 20071002 - p->HireExpireDate = i->expire_time; + p->HireExpireDate = it->expire_time; #endif #if PACKETVER >= 20080102 - p->bindOnEquipType = i->bound ? 2 : id->flag.bindonequip ? 1 : 0; + p->bindOnEquipType = it->bound ? 2 : id->flag.bindonequip ? 1 : 0; #endif #if PACKETVER >= 20100629 @@ -2564,19 +2594,14 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct #endif #if PACKETVER >= 20120925 - p->Flag.IsIdentified = i->identify ? 1 : 0; - p->Flag.IsDamaged = (i->attribute & ATTR_BROKEN) != 0 ? 1 : 0; - p->Flag.PlaceETCTab = i->favorite ? 1 : 0; + p->Flag.IsIdentified = it->identify ? 1 : 0; + p->Flag.IsDamaged = (it->attribute & ATTR_BROKEN) != 0 ? 1 : 0; + p->Flag.PlaceETCTab = it->favorite ? 1 : 0; p->Flag.SpareBits = 0; #endif #if PACKETVER >= 20150226 - p->option_count = 0; - for (j=0; j<5; j++){ - p->option_data[j].index = 0; - p->option_data[j].value = 0; - p->option_data[j].param = 0; - } + p->option_count = clif->add_item_options(p->option_data, it); #endif } @@ -3992,7 +4017,7 @@ void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd WBUFW(buf,15)= 0; //card (4w) WBUFW(buf,17)= 0; //card (4w) #if PACKETVER >= 20150226 - clif->add_random_options(WBUFP(buf, 19), &sd->status.inventory[index]); + clif->add_item_options(WBUFP(buf, 19), &sd->status.inventory[index]); #endif } else @@ -4018,7 +4043,7 @@ void clif_tradeadditem(struct map_session_data* sd, struct map_session_data* tsd WBUFB(buf,10)= sd->status.inventory[index].refine; //refine clif->addcards(WBUFP(buf, 11), &sd->status.inventory[index]); #if PACKETVER >= 20150226 - clif->add_random_options(WBUFP(buf, 19), &sd->status.inventory[index]); + clif->add_item_options(WBUFP(buf, 19), &sd->status.inventory[index]); #endif } WFIFOSET(fd,packet_len(tradeaddType)); @@ -4149,7 +4174,7 @@ void clif_storageitemadded(struct map_session_data* sd, struct item* i, int inde WFIFOB(fd,12+offset) = i->refine; //refine clif->addcards(WFIFOP(fd,13+offset), i); #if PACKETVER >= 20150226 - clif->add_random_options(WFIFOP(fd,21+offset), i); + clif->add_item_options(WFIFOP(fd,21+offset), i); #endif WFIFOSET(fd,packet_len(storageaddType)); } @@ -6223,7 +6248,7 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail) WBUFB(buf,12+offset)=sd->status.cart[n].refine; clif->addcards(WBUFP(buf,13+offset), &sd->status.cart[n]); #if PACKETVER >= 20150226 - clif->add_random_options(WBUFP(buf,21+offset), &sd->status.cart[n]); + clif->add_item_options(WBUFP(buf,21+offset), &sd->status.cart[n]); #endif WFIFOSET(fd,packet_len(cartaddType)); } @@ -6351,7 +6376,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven WFIFOB(fd,offset+13+i*item_length) = vsd->status.cart[index].refine; clif->addcards(WFIFOP(fd,offset+14+i*item_length), &vsd->status.cart[index]); #if PACKETVER >= 20150226 - clif->add_random_options(WFIFOP(fd,offset+22+i*item_length), &vsd->status.cart[index]); + clif->add_item_options(WFIFOP(fd,offset+22+i*item_length), &vsd->status.cart[index]); #endif } WFIFOSET(fd,WFIFOW(fd,2)); @@ -6417,7 +6442,7 @@ void clif_openvending(struct map_session_data* sd, int id, struct s_vending* ven WFIFOB(fd,21+i*item_length) = sd->status.cart[index].refine; clif->addcards(WFIFOP(fd,22+i*item_length), &sd->status.cart[index]); #if PACKETVER >= 20150226 - clif->add_random_options(WFIFOP(fd,30+22+i*item_length), &sd->status.cart[index]); + clif->add_item_options(WFIFOP(fd,30+22+i*item_length), &sd->status.cart[index]); #endif } WFIFOSET(fd,WFIFOW(fd,2)); @@ -7232,6 +7257,13 @@ void clif_mvp_item(struct map_session_data *sd,int nameid) /// 010b <exp>.L void clif_mvp_exp(struct map_session_data *sd, unsigned int exp) { +#if PACKETVER >= 20131223 // Kro removed this packet [Napster] + if (battle_config.mvp_exp_reward_message) { + char e_msg[CHAT_SIZE_MAX]; + sprintf(e_msg, msg_txt(855), exp); + clif->messagecolor_self(sd->fd, COLOR_CYAN, e_msg); // Congratulations! You are the MVP! Your reward EXP Points are %u !! + } +#else int fd; nullpo_retv(sd); @@ -7241,6 +7273,7 @@ void clif_mvp_exp(struct map_session_data *sd, unsigned int exp) WFIFOW(fd,0)=0x10b; WFIFOL(fd,2)=cap_value(exp,0,INT32_MAX); WFIFOSET(fd,packet_len(0x10b)); +#endif } /// Dropped MVP item reward message (ZC_THROW_MVPITEM). @@ -10992,39 +11025,36 @@ void clif_parse_RemoveOption(int fd,struct map_session_data *sd) void clif_parse_ChangeCart(int fd,struct map_session_data *sd) __attribute__((nonnull (2))); /// Request to change cart's visual look (CZ_REQ_CHANGECART). /// 01af <num>.W -void clif_parse_ChangeCart(int fd,struct map_session_data *sd) +void clif_parse_ChangeCart(int fd, struct map_session_data *sd) {// TODO: State tracking? int type; - if( pc->checkskill(sd, MC_CHANGECART) < 1 ) + if (pc->checkskill(sd, MC_CHANGECART) == 0) return; #ifdef RENEWAL - if( sd->npc_id || sd->state.workinprogress&1 ){ + if (sd->npc_id || sd->state.workinprogress&1) { clif->msgtable(sd, MSG_NPC_WORK_IN_PROGRESS); return; } #endif - type = RFIFOW(fd,2); + type = RFIFOW(fd, 2); + + if ( #ifdef NEW_CARTS - if( (type == 9 && sd->status.base_level > 131) || - (type == 8 && sd->status.base_level > 121) || - (type == 7 && sd->status.base_level > 111) || - (type == 6 && sd->status.base_level > 101) || + (type == 9 && sd->status.base_level > 130) || + (type == 8 && sd->status.base_level > 120) || + (type == 7 && sd->status.base_level > 110) || + (type == 6 && sd->status.base_level > 100) || +#endif (type == 5 && sd->status.base_level > 90) || (type == 4 && sd->status.base_level > 80) || (type == 3 && sd->status.base_level > 65) || (type == 2 && sd->status.base_level > 40) || (type == 1)) -#else - if( (type == 5 && sd->status.base_level > 90) || - (type == 4 && sd->status.base_level > 80) || - (type == 3 && sd->status.base_level > 65) || - (type == 2 && sd->status.base_level > 40) || - (type == 1)) -#endif - pc->setcart(sd,type); + + pc->setcart(sd, type); } /// Request to select cart's visual look for new cart design (CZ_SELECTCART). @@ -11594,7 +11624,12 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) __attribute_ /// 01d5 <packet len>.W <npc id>.L <string>.?B void clif_parse_NpcStringInput(int fd, struct map_session_data* sd) { - int message_len = RFIFOW(fd,2)-8; +// [4144] can't confirm exact client version. At least >= correct for 20150513 +#if PACKETVER >= 20151029 + int message_len = RFIFOW(fd, 2) - 7; +#else + int message_len = RFIFOW(fd, 2) - 8; +#endif int npcid = RFIFOL(fd,4); const char *message = RFIFOP(fd,8); @@ -16201,7 +16236,7 @@ void clif_bg_hp(struct map_session_data *sd) { unsigned char buf[34]; -// packet version can be wrong, because inconsistend data in other servers. +// packet version can be wrong, because inconsistend data in other servers. From packets table it start from 20140312 [4144] #if PACKETVER < 20140613 const int cmd = 0x2e0; nullpo_retv(sd); @@ -20092,7 +20127,7 @@ void clif_defaults(void) { clif->pNPCMarketClosed = clif_parse_NPCMarketClosed; clif->pNPCMarketPurchase = clif_parse_NPCMarketPurchase; /* */ - clif->add_random_options = clif_add_random_options; + clif->add_item_options = clif_add_item_options; clif->pHotkeyRowShift = clif_parse_HotkeyRowShift; clif->dressroom_open = clif_dressroom_open; clif->pOneClick_ItemIdentify = clif_parse_OneClick_ItemIdentify; |