void clif_cashshop_ack(struct map_session_data* sd, int error) { int fd = sd->fd; WFIFOHEAD(fd, packet_len(0x289)); WFIFOW(fd,0) = 0x289; WFIFOL(fd,2) = sd->cashPoints; #if PACKETVER < 20070711 WFIFOW(fd,6) = TOW(error); #else WFIFOL(fd,6) = sd->kafraPoints; WFIFOW(fd,10) = TOW(error); #endif WFIFOSET(fd, packet_len(0x289)); } #if PACKETVER >= 20120410 void clif_parse_cashshop_buy( int fd, struct map_session_data *sd ){ struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; uint16 length = RFIFOW( fd, info->pos[0] ); uint16 count = RFIFOW( fd, info->pos[1] ); if( length < 10 || length < ( 10 + count * 6 ) ){ return; } cashshop_buylist( sd, RFIFOL( fd, info->pos[2] ), count, (uint16 *)RFIFOP( fd, info->pos[3] ) ); } #endif void clif_cashshop_result( struct map_session_data *sd, uint16 item_id, uint16 result ){ WFIFOHEAD( sd->fd, 16 ); WFIFOW( sd->fd, 0 ) = 0x849; WFIFOL( sd->fd, 2 ) = item_id; WFIFOW( sd->fd, 6 ) = result; WFIFOL( sd->fd, 8 ) = sd->cashPoints; WFIFOL( sd->fd, 12 ) = sd->kafraPoints; WFIFOSET( sd->fd, 16 ); } // TODO: find a more accurate date for this - Brynner #if PACKETVER < 20120410 /// Request to buy item(s) from cash shop (CZ_PC_BUY_CASH_POINT_ITEM). /// 0288 .W .W /// 0288 .W .W .L (PACKETVER >= 20070711) /// 0288 .W .L .W { .W .W }.4B*count (PACKETVER >= 20100803) /// 0848 .W .W .W .L .W { .W .W .W }.6B*count (PACKETVER >= 20130000) void clif_parse_cashshop_buy(int fd, struct map_session_data *sd){ int fail = 0; struct s_packet_db* info; int cmd = RFIFOW(fd,0); nullpo_retv(sd); info = &packet_db[sd->packet_ver][cmd]; if( sd->state.trading || !sd->npc_shopid ) fail = 1; else { #if PACKETVER < 20101116 short nameid = RFIFOW(fd,info->pos[0]); short amount = RFIFOW(fd,info->pos[1]); int points = RFIFOL(fd,info->pos[2]); fail = npc_cashshop_buy(sd, nameid, amount, points); clif_cashshop_ack(sd,fail); #else int s_itl = (cmd==0x848)?10:4; //item _list size (depend on cmd even for 2013+) int len = RFIFOW(fd,info->pos[0]); int points = RFIFOL(fd,info->pos[1]); int count = RFIFOW(fd,info->pos[2]); unsigned short* item_list = (unsigned short*)RFIFOP(fd,info->pos[3]); if( len < 10 || len != 10 + count * s_itl){ ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * s_itl); return; } if(cmd==0x848){ cashshop_buylist( sd, points, count, item_list); } else { fail = npc_cashshop_buylist(sd,points,count,item_list); } #endif } clif_cashshop_ack(sd,fail); } #endif