Initial release of item package selection (#7239)

Thanks to @aleos89 and @Atemo

Co-authored-by: Atemo <capucrath@gmail.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
Lemongrass3110
2022-09-12 22:06:04 +02:00
committed by GitHub
parent 421e49e1c4
commit 38b8d5a994
20 changed files with 1680 additions and 19 deletions

View File

@@ -23856,7 +23856,7 @@ void clif_parse_enchantgrade_close( int fd, struct map_session_data* sd ){
}
void clif_reputation_type( struct map_session_data& sd, int64 type, int64 points ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_ZC_REPUTE_INFO* p = (struct PACKET_ZC_REPUTE_INFO*)packet_buffer;
p->packetType = HEADER_ZC_REPUTE_INFO;
@@ -23873,7 +23873,7 @@ void clif_reputation_type( struct map_session_data& sd, int64 type, int64 points
}
void clif_reputation_list( struct map_session_data& sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_ZC_REPUTE_INFO* p = (struct PACKET_ZC_REPUTE_INFO*)packet_buffer;
p->packetType = HEADER_ZC_REPUTE_INFO;
@@ -23898,7 +23898,7 @@ void clif_reputation_list( struct map_session_data& sd ){
}
void clif_item_reform_open( struct map_session_data& sd, t_itemid item ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_ZC_OPEN_REFORM_UI p = {};
p.packetType = HEADER_ZC_OPEN_REFORM_UI;
@@ -23911,13 +23911,13 @@ void clif_item_reform_open( struct map_session_data& sd, t_itemid item ){
}
void clif_parse_item_reform_close( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
sd->state.item_reform = 0;
#endif
}
void clif_item_reform_result( struct map_session_data& sd, uint16 index, uint8 result ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_ZC_ITEM_REFORM_ACK p = {};
p.packetType = HEADER_ZC_ITEM_REFORM_ACK;
@@ -23934,7 +23934,7 @@ void clif_item_reform_result( struct map_session_data& sd, uint16 index, uint8 r
}
void clif_parse_item_reform_start( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
// Not opened
if( sd->state.item_reform == 0 ){
return;
@@ -24088,7 +24088,7 @@ void clif_parse_item_reform_start( int fd, struct map_session_data* sd ){
}
void clif_enchantwindow_open( struct map_session_data& sd, uint64 clientLuaIndex ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
// Hardcoded clientside check
if( sd.weight > ( ( sd.max_weight * 70 ) / 100 ) ){
clif_msg_color( &sd, C_ENCHANT_OVERWEIGHT, color_table[COLOR_RED] );
@@ -24110,7 +24110,7 @@ void clif_enchantwindow_open( struct map_session_data& sd, uint64 clientLuaIndex
}
void clif_enchantwindow_result( struct map_session_data& sd, bool success, t_itemid enchant = 0 ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_ZC_RESPONSE_ENCHANT p = {};
p.packetType = HEADER_ZC_RESPONSE_ENCHANT;
@@ -24164,7 +24164,7 @@ bool clif_parse_enchant_basecheck( struct item& selected_item, std::shared_ptr<s
}
void clif_parse_enchantwindow_general( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_CZ_REQUEST_RANDOM_ENCHANT *p = (struct PACKET_CZ_REQUEST_RANDOM_ENCHANT*)RFIFOP( fd, 0 );
if( sd->state.item_enchant_index != p->clientLuaIndex ){
@@ -24293,7 +24293,7 @@ void clif_parse_enchantwindow_general( int fd, struct map_session_data* sd ){
}
void clif_parse_enchantwindow_perfect( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_CZ_REQUEST_PERFECT_ENCHANT *p = (struct PACKET_CZ_REQUEST_PERFECT_ENCHANT*)RFIFOP( fd, 0 );
if( sd->state.item_enchant_index != p->clientLuaIndex ){
@@ -24393,7 +24393,7 @@ void clif_parse_enchantwindow_perfect( int fd, struct map_session_data* sd ){
}
void clif_parse_enchantwindow_upgrade( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_CZ_REQUEST_UPGRADE_ENCHANT *p = (struct PACKET_CZ_REQUEST_UPGRADE_ENCHANT*)RFIFOP( fd, 0 );
if( sd->state.item_enchant_index != p->clientLuaIndex ){
@@ -24490,7 +24490,7 @@ void clif_parse_enchantwindow_upgrade( int fd, struct map_session_data* sd ){
}
void clif_parse_enchantwindow_reset( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
struct PACKET_CZ_REQUEST_RESET_ENCHANT *p = (struct PACKET_CZ_REQUEST_RESET_ENCHANT*)RFIFOP( fd, 0 );
if( sd->state.item_enchant_index != p->clientLuaIndex ){
@@ -24608,11 +24608,91 @@ void clif_parse_enchantwindow_reset( int fd, struct map_session_data* sd ){
}
void clif_parse_enchantwindow_close( int fd, struct map_session_data* sd ){
#if PACKETVER_RE_NUM >= 20211103
#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
sd->state.item_enchant_index = 0;
#endif
}
void clif_parse_itempackage_select( int fd, struct map_session_data* sd ){
#if PACKETVER_MAIN_NUM >= 20220216 || PACKETVER_ZERO_NUM >= 20220316
struct PACKET_CZ_USE_PACKAGEITEM* p = (struct PACKET_CZ_USE_PACKAGEITEM*)RFIFOP( fd, 0 );
if( p->AID != sd->status.account_id ){
return;
}
uint16 index = server_index( p->index );
if( index >= MAX_INVENTORY ){
return;
}
if( sd->inventory_data[index] == nullptr ){
return;
}
if( sd->inventory_data[index]->nameid != p->itemID ){
return;
}
if( sd->inventory_data[index]->elv > sd->status.base_level ){
return;
}
std::shared_ptr<s_item_package> package = item_package_db.find( p->itemID );
if( package == nullptr ){
return;
}
std::shared_ptr<s_item_package_group> group = util::umap_find( package->groups, p->BoxIndex );
if( group == nullptr ){
return;
}
if( pc_delitem( sd, index, 1, 0, 0, LOG_TYPE_PACKAGE ) != 0 ){
return;
}
for( const auto& entry : group->items ){
struct item item = {};
item.nameid = entry.second->item_id;
item.identify = 1;
item.refine = (char)entry.second->refine;
if( entry.second->rentalhours ){
item.expire_time = (uint32)( time( nullptr ) + entry.second->rentalhours * 3600 );
}
// Check if it is a pet egg
std::shared_ptr<s_pet_db> pet = pet_db_search( item.nameid, PET_EGG );
if( pet != nullptr ){
for( int i = 0; i < entry.second->amount; i++ ){
pet_create_egg( sd, item.nameid );
}
}else if( entry.second->amount > 1 && ( !itemdb_isstackable( item.nameid ) || item.expire_time > 0 ) ){
for( int i = 0; i < entry.second->amount; i++ ){
// New random options on each iteration
if( entry.second->randomOptionGroup != nullptr ){
entry.second->randomOptionGroup->apply( item );
}
pc_additem( sd, &item, 1, LOG_TYPE_PACKAGE );
}
}else{
if( entry.second->randomOptionGroup != nullptr ){
entry.second->randomOptionGroup->apply( item );
}
pc_additem( sd, &item, entry.second->amount, LOG_TYPE_PACKAGE );
}
}
#endif
}
/*==========================================
* Main client packet processing function
*------------------------------------------*/