From 9ccdfe9d17c01e2b0cf4f23da19a9fe7ad3e8b9c Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Thu, 20 Jan 2022 14:51:23 +0100 Subject: [PATCH] Fixed a display problem in refine UI (#6535) Fixes #6528 Thanks to @idk-whoami, @zdurexz @secretdataz --- src/map/clif.cpp | 51 ++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 0ae1f47ce4..f864f8c1e5 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -22115,45 +22115,36 @@ void clif_refineui_info( struct map_session_data* sd, uint16 index ){ return; } - std::shared_ptr info = refine_db.findLevelInfo( *id, *item ); - - // No refine possible - if( info == nullptr ){ - return; - } - - // No possibilities were found - if( info->costs.empty() ){ - return; - } - - uint16 length = (uint16)( sizeof( struct PACKET_ZC_REFINE_ADD_ITEM ) + REFINE_COST_MAX * sizeof( struct PACKET_ZC_REFINE_ADD_ITEM_SUB ) ); - - // Preallocate the size - WFIFOHEAD( fd, length ); - - struct PACKET_ZC_REFINE_ADD_ITEM* p = (struct PACKET_ZC_REFINE_ADD_ITEM*)WFIFOP( fd, 0 ); + struct PACKET_ZC_REFINE_ADD_ITEM* p = (struct PACKET_ZC_REFINE_ADD_ITEM*)packet_buffer; p->packetType = HEADER_ZC_REFINE_ADD_ITEM; + p->packtLength = sizeof( struct PACKET_ZC_REFINE_ADD_ITEM ); p->itemIndex = client_index( index ); - p->blacksmithBlessing = (uint8)info->blessing_amount; - uint16 count = 0; + std::shared_ptr info = refine_db.findLevelInfo( *id, *item ); - for( uint16 i = REFINE_COST_NORMAL; i < REFINE_COST_MAX; i++ ){ - std::shared_ptr cost = util::umap_find( info->costs, i ); + // No possibilities were found + if( info == nullptr ){ + p->blacksmithBlessing = 0; + }else{ + p->blacksmithBlessing = (uint8)info->blessing_amount; - if( cost != nullptr ){ - p->req[count].itemId = client_nameid( cost->nameid ); - p->req[count].chance = (uint8)( cost->chance / 100 ); - p->req[count].zeny = cost->zeny; - count++; + uint16 count = 0; + + for( uint16 i = REFINE_COST_NORMAL; i < REFINE_COST_MAX; i++ ){ + std::shared_ptr cost = util::umap_find( info->costs, i ); + + if( cost != nullptr ){ + p->req[count].itemId = client_nameid( cost->nameid ); + p->req[count].chance = (uint8)( cost->chance / 100 ); + p->req[count].zeny = cost->zeny; + p->packtLength += sizeof( struct PACKET_ZC_REFINE_ADD_ITEM_SUB ); + count++; + } } } - p->packtLength = (uint16)( sizeof( struct PACKET_ZC_REFINE_ADD_ITEM ) + count * sizeof( struct PACKET_ZC_REFINE_ADD_ITEM_SUB ) ); - - WFIFOSET( fd, p->packtLength ); + clif_send( p, p->packtLength, &sd->bl, SELF ); #endif }