viewing paste clif.c patch for 2012 clients | Athena

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
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 <name id>.W <amount>.W
/// 0288 <name id>.W <amount>.W <kafra points>.L (PACKETVER >= 20070711)
/// 0288 <packet len>.W <kafra points>.L <count>.W { <amount>.W <name id>.W }.4B*count (PACKETVER >= 20100803)
/// 0848 <packet len>.W <count>.W <packet len>.W <kafra points>.L <count>.W { <amount>.W <name id>.W <tab>.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
Viewed 1260 times, submitted by Guest.