Converted cash shop database to YAML (#6299)
Co-authored-by: Atemo <Atemo@users.noreply.github.com> Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
114
src/map/clif.cpp
114
src/map/clif.cpp
@@ -17000,26 +17000,46 @@ void clif_parse_cashshop_close( int fd, map_session_data* sd ){
|
||||
//0846 <tabid>.W (CZ_REQ_SE_CASH_TAB_CODE))
|
||||
//08c0 <len>.W <openIdentity>.L <itemcount>.W (ZC_ACK_SE_CASH_ITEM_LIST2)
|
||||
void clif_parse_CashShopReqTab(int fd, map_session_data *sd) {
|
||||
#if PACKETVER_MAIN_NUM >= 20100824 || PACKETVER_RE_NUM >= 20100824 || defined(PACKETVER_ZERO)
|
||||
struct PACKET_CZ_REQ_SE_CASH_TAB_CODE* p_in = (struct PACKET_CZ_REQ_SE_CASH_TAB_CODE*)RFIFOP( fd, 0 );
|
||||
|
||||
// TODO: most likely wrong answer packet. Most likely HEADER_ZC_ACK_SE_CASH_ITEM_LIST (0x847) would be correct [Lemongrass]
|
||||
// [4144] packet exists only in 2011 and was dropped after
|
||||
#if PACKETVER >= 20110222 && PACKETVER < 20120000
|
||||
short tab = RFIFOW(fd, packet_db[RFIFOW(fd,0)].pos[0]);
|
||||
int j;
|
||||
std::shared_ptr<s_cash_item_tab> tab = cash_shop_db.find( static_cast<e_cash_shop_tab>( p_in->tab ) );
|
||||
|
||||
if( tab < 0 || tab >= CASHSHOP_TAB_MAX )
|
||||
if( tab == nullptr ){
|
||||
return;
|
||||
|
||||
WFIFOHEAD(fd, 10 + ( cash_shop_items[tab].count * 6 ) );
|
||||
WFIFOW(fd, 0) = 0x8c0;
|
||||
WFIFOW(fd, 2) = 10 + ( cash_shop_items[tab].count * 6 );
|
||||
WFIFOL(fd, 4) = tab;
|
||||
WFIFOW(fd, 8) = cash_shop_items[tab].count;
|
||||
|
||||
for( j = 0; j < cash_shop_items[tab].count; j++ ) {
|
||||
WFIFOW(fd, 10 + ( 6 * j ) ) = client_nameid( cash_shop_items[tab].item[j]->nameid );
|
||||
WFIFOL(fd, 12 + ( 6 * j ) ) = cash_shop_items[tab].item[j]->price;
|
||||
}
|
||||
|
||||
WFIFOSET(fd, 10 + ( cash_shop_items[tab].count * 6 ));
|
||||
// Skip empty tabs, the client only expects filled ones
|
||||
if( tab->items.empty() ){
|
||||
return;
|
||||
}
|
||||
|
||||
#if !(PACKETVER_SUPPORTS_SALES)
|
||||
if( tab->tab == CASHSHOP_TAB_SALE ){
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct PACKET_ZC_ACK_SE_CASH_ITEM_LIST2* p = (struct PACKET_ZC_ACK_SE_CASH_ITEM_LIST2*)packet_buffer;
|
||||
|
||||
p->packetType = HEADER_ZC_ACK_SE_CASH_ITEM_LIST2;
|
||||
p->packetLength = sizeof( struct PACKET_ZC_ACK_SE_CASH_ITEM_LIST2 );
|
||||
p->tab = tab->tab;
|
||||
p->count = 0;
|
||||
|
||||
for( std::shared_ptr<s_cash_item> item : tab->items ){
|
||||
p->items[p->count].itemId = client_nameid( item->nameid );
|
||||
p->items[p->count].price = item->price;
|
||||
|
||||
p->packetLength += sizeof( struct PACKET_ZC_ACK_SE_CASH_ITEM_LIST2_sub );
|
||||
p->count++;
|
||||
}
|
||||
|
||||
clif_send( p, p->packetLength, &sd->bl, SELF );
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -17027,44 +17047,46 @@ void clif_parse_CashShopReqTab(int fd, map_session_data *sd) {
|
||||
void clif_cashshop_list( map_session_data* sd ){
|
||||
nullpo_retv( sd );
|
||||
|
||||
int fd = sd->fd;
|
||||
for( const auto& pair : cash_shop_db ){
|
||||
std::shared_ptr<s_cash_item_tab> tab = pair.second;
|
||||
|
||||
if( !session_isActive( fd ) ){
|
||||
return;
|
||||
}
|
||||
|
||||
for( int tab = CASHSHOP_TAB_NEW; tab < CASHSHOP_TAB_MAX; tab++ ){
|
||||
// Skip empty tabs, the client only expects filled ones
|
||||
if( cash_shop_items[tab].count == 0 ){
|
||||
if( tab->items.empty() ){
|
||||
continue;
|
||||
}
|
||||
|
||||
int len = sizeof( struct PACKET_ZC_ACK_SCHEDULER_CASHITEM ) + ( cash_shop_items[tab].count * sizeof( struct PACKET_ZC_ACK_SCHEDULER_CASHITEM_sub ) );
|
||||
WFIFOHEAD( fd, len );
|
||||
struct PACKET_ZC_ACK_SCHEDULER_CASHITEM *p = (struct PACKET_ZC_ACK_SCHEDULER_CASHITEM *)WFIFOP( fd, 0 );
|
||||
#if !(PACKETVER_SUPPORTS_SALES)
|
||||
if( tab->tab == CASHSHOP_TAB_SALE ){
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
p->packetType = 0x8ca;
|
||||
p->packetLength = len;
|
||||
p->count = cash_shop_items[tab].count;
|
||||
p->tabNum = tab;
|
||||
struct PACKET_ZC_ACK_SCHEDULER_CASHITEM *p = (struct PACKET_ZC_ACK_SCHEDULER_CASHITEM *)packet_buffer;
|
||||
|
||||
for( int i = 0; i < cash_shop_items[tab].count; i++ ){
|
||||
p->items[i].itemId = client_nameid( cash_shop_items[tab].item[i]->nameid );
|
||||
p->items[i].price = cash_shop_items[tab].item[i]->price;
|
||||
p->packetType = HEADER_ZC_ACK_SCHEDULER_CASHITEM;
|
||||
p->count = 0;
|
||||
p->tabNum = tab->tab;
|
||||
|
||||
for( std::shared_ptr<s_cash_item> item : tab->items ){
|
||||
p->items[p->count].itemId = client_nameid( item->nameid );
|
||||
p->items[p->count].price = item->price;
|
||||
#ifdef ENABLE_CASHSHOP_PREVIEW_PATCH
|
||||
struct item_data* id = itemdb_search( cash_shop_items[tab].item[i]->nameid );
|
||||
struct item_data* id = itemdb_search( item->nameid );
|
||||
|
||||
if( id == nullptr ){
|
||||
p->items[i].location = 0;
|
||||
p->items[i].viewSprite = 0;
|
||||
p->items[p->count].location = 0;
|
||||
p->items[p->count].viewSprite = 0;
|
||||
}else{
|
||||
p->items[i].location = pc_equippoint_sub( sd, id );
|
||||
p->items[i].viewSprite = id->look;
|
||||
p->items[p->count].location = pc_equippoint_sub( sd, id );
|
||||
p->items[p->count].viewSprite = id->look;
|
||||
}
|
||||
#endif
|
||||
p->count++;
|
||||
}
|
||||
|
||||
WFIFOSET( fd, len );
|
||||
p->packetLength = sizeof( struct PACKET_ZC_ACK_SCHEDULER_CASHITEM ) + p->count * sizeof( struct PACKET_ZC_ACK_SCHEDULER_CASHITEM_sub );
|
||||
|
||||
clif_send( p, p->packetLength, &sd->bl, SELF );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21178,7 +21200,7 @@ void clif_parse_sale_close(int fd, map_session_data* sd) {
|
||||
|
||||
/// Reply to a item search request for item sale administration.
|
||||
/// 09ad <result>.W <item id>.W <price>.L (ZC_ACK_CASH_BARGAIN_SALE_ITEM_INFO)
|
||||
void clif_sale_search_reply( map_session_data* sd, struct cash_item_data* item ){
|
||||
void clif_sale_search_reply( map_session_data* sd, std::shared_ptr<s_cash_item> item ){
|
||||
#if PACKETVER_SUPPORTS_SALES
|
||||
struct PACKET_ZC_ACK_CASH_BARGAIN_SALE_ITEM_INFO p;
|
||||
|
||||
@@ -21218,19 +21240,13 @@ void clif_parse_sale_search( int fd, map_session_data* sd ){
|
||||
|
||||
std::shared_ptr<item_data> id = item_db.searchname( item_name );
|
||||
|
||||
if( id ){
|
||||
int i;
|
||||
|
||||
for( i = 0; i < cash_shop_items[CASHSHOP_TAB_SALE].count; i++ ){
|
||||
if( cash_shop_items[CASHSHOP_TAB_SALE].item[i]->nameid == id->nameid ){
|
||||
clif_sale_search_reply( sd, cash_shop_items[CASHSHOP_TAB_SALE].item[i] );
|
||||
return;
|
||||
}
|
||||
}
|
||||
// not found
|
||||
if( id == nullptr ){
|
||||
clif_sale_search_reply( sd, nullptr );
|
||||
return;
|
||||
}
|
||||
|
||||
// not found
|
||||
clif_sale_search_reply( sd, NULL );
|
||||
clif_sale_search_reply( sd, cash_shop_db.findItemInTab( CASHSHOP_TAB_SALE, id->nameid ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user