Fixed RODEX's retrieve all feature (#5842)

Thanks to @limitro
This commit is contained in:
Lemongrass3110 2021-04-11 02:27:17 +02:00 committed by GitHub
parent 1a8cfbffc0
commit f77cb8a37b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 14 deletions

View File

@ -16091,10 +16091,13 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
}
if( attachment&MAIL_ATT_ZENY ){
if( msg->zeny + sd->status.zeny > MAX_ZENY ){
if( ( msg->zeny + sd->status.zeny + sd->mail.pending_zeny ) > MAX_ZENY ){
clif_mail_getattachment(sd, msg, 1, MAIL_ATT_ZENY); //too many zeny
return;
}else{
// Store the pending zeny (required for the "retrieve all" feature)
sd->mail.pending_zeny += msg->zeny;
// To make sure another request fails
msg->zeny = 0;
}
@ -16125,7 +16128,7 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
}
}
if( ( totalweight + sd->weight ) > sd->max_weight ){
if( ( totalweight + sd->weight + sd->mail.pending_weight ) > sd->max_weight ){
clif_mail_getattachment(sd, msg, 2, MAIL_ATT_ITEM);
return;
}else if( pc_inventoryblank(sd) < new_ ){
@ -16135,6 +16138,9 @@ void clif_parse_Mail_getattach( int fd, struct map_session_data *sd ){
// To make sure another request fails
memset(msg->item, 0, MAIL_MAX_ITEM*sizeof(struct item));
// Store the pending weight (required for the "retrieve all" feature)
sd->mail.pending_weight += totalweight;
}
intif_mail_getattach(sd,msg, (enum mail_attachment_type)attachment);

View File

@ -290,23 +290,44 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i
for( i = 0; i < MAIL_MAX_ITEM; i++ ){
if( item->nameid > 0 && item->amount > 0 ){
// If no card or special card id is set
if( item[i].card[0] == 0 ){
// Check if it is a pet egg
std::shared_ptr<s_pet_db> pet = pet_db_search( item[i].nameid, PET_EGG );
struct item_data* id = itemdb_search( item->nameid );
// If it is a pet egg and the card data does not contain a pet id (see if clause above)
if( pet != nullptr ){
// Create a new pet
pet_create_egg( sd, item[i].nameid );
// Item does not exist (anymore?)
if( id == nullptr ){
continue;
}
// Reduce the pending weight
sd->mail.pending_weight -= ( id->weight * item[i].amount );
// Check if it is a pet egg
std::shared_ptr<s_pet_db> pet = pet_db_search( item[i].nameid, PET_EGG );
// If it is a pet egg and the card data does not contain a pet id or other special ids are set
if( pet != nullptr && item[i].card[0] == 0 ){
// Create a new pet
if( pet_create_egg( sd, item[i].nameid ) ){
item_received = true;
continue;
}else{
// Do not send receive packet so that the mail is still displayed with item attachment
item_received = false;
// Additionally stop the processing
break;
}
}else{
// Add the item normally
if( pc_additem( sd, &item[i], item[i].amount, LOG_TYPE_MAIL ) == ADDITEM_SUCCESS ){
item_received = true;
}else{
// Do not send receive packet so that the mail is still displayed with item attachment
item_received = false;
// Additionally stop the processing
break;
}
}
// Add the item normally
pc_additem( sd, &item[i], item[i].amount, LOG_TYPE_MAIL );
item_received = true;
// Make sure no requests are possible anymore
item->amount = 0;
}
}
@ -316,6 +337,10 @@ void mail_getattachment(struct map_session_data* sd, struct mail_message* msg, i
// Zeny receive
if( zeny > 0 ){
// Reduce the pending zeny
sd->mail.pending_zeny -= zeny;
// Add the zeny
pc_getzeny(sd, zeny,LOG_TYPE_MAIL, NULL);
clif_mail_getattachment( sd, msg, 0, MAIL_ATT_ZENY );
}

View File

@ -1683,6 +1683,8 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
sd->avail_quests = 0;
sd->save_quest = false;
sd->count_rewarp = 0;
sd->mail.pending_weight = 0;
sd->mail.pending_zeny = 0;
sd->regs.vars = i64db_alloc(DB_OPT_BASE);
sd->regs.arrays = NULL;

View File

@ -662,6 +662,8 @@ struct map_session_data {
int zeny;
struct mail_data inbox;
bool changed; // if true, should sync with charserver on next mailbox request
uint32 pending_weight;
uint32 pending_zeny;
} mail;
//Quest log system