void mapif_parse_Auction_close(int fd) { uint32 char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) { mapif_Auction_close(fd, char_id, 2); // Bid Number is Incorrect return; } if( auction->seller_id != char_id ) { mapif_Auction_close(fd, char_id, 1); // You cannot end the auction return; } if( auction->buyer_id == 0 ) { mapif_Auction_close(fd, char_id, 1); // You cannot end the auction return; } // Send Money to Seller mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(206), auction->price, NULL, 0); // Send Item to Buyer mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(207), 0, &auction->item, 1); mapif_Auction_message(auction->buyer_id, 6); // You have won the auction auction_delete(auction); mapif_Auction_close(fd, char_id, 0); // You have ended the auction }
static void mapif_parse_Auction_close(int fd) { int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) { mapif_Auction_close(fd, char_id, 2); // Bid Number is Incorrect return; } if( auction->seller_id != char_id ) { mapif_Auction_close(fd, char_id, 1); // You cannot end the auction return; } if( auction->buyer_id == 0 ) { mapif_Auction_close(fd, char_id, 1); // You cannot end the auction return; } // Send Money to Seller mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction closed.", auction->price, NULL); // Send Item to Buyer mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Auction winner.", 0, &auction->item); mapif_Auction_message(auction->buyer_id, 6); // You have won the auction auction_delete(auction); mapif_Auction_close(fd, char_id, 0); // You have ended the auction }
static void mapif_parse_Auction_bid(int fd) { int char_id = RFIFOL(fd,4), bid = RFIFOL(fd,12); unsigned int auction_id = RFIFOL(fd,8); struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL || auction->price >= bid || auction->seller_id == char_id ) { mapif_Auction_bid(fd, char_id, bid, 0); // You have failed to bid in the auction return; } if( auction_count(char_id, true) > 4 && bid < auction->buynow && auction->buyer_id != char_id ) { mapif_Auction_bid(fd, char_id, bid, 9); // You cannot place more than 5 bids at a time return; } if( auction->buyer_id > 0 ) { // Send Money back to the previous Buyer if( auction->buyer_id != char_id ) { mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Someone has placed a higher bid.", auction->price, NULL); mapif_Auction_message(auction->buyer_id, 7); // You have failed to win the auction } else mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have placed a higher bid.", auction->price, NULL); } auction->buyer_id = char_id; safestrncpy(auction->buyer_name, (char*)RFIFOP(fd,16), NAME_LENGTH); auction->price = bid; if( bid >= auction->buynow ) { // Automatic won the auction mapif_Auction_bid(fd, char_id, bid - auction->buynow, 1); // You have successfully bid in the auction mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "You have won the auction.", 0, &auction->item); mapif_Auction_message(char_id, 6); // You have won the auction mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->buynow, NULL); auction_delete(auction); return; } auction_save(auction); mapif_Auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction }
void mapif_parse_Auction_bid(int fd) { uint32 char_id = RFIFOL(fd,4), auction_id = RFIFOL(fd,8); int bid = RFIFOL(fd,12); struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL || auction->price >= bid || auction->seller_id == char_id ) { mapif_Auction_bid(fd, char_id, bid, 0); // You have failed to bid in the auction return; } if( auction_count(char_id, true) > 4 && bid < auction->buynow && auction->buyer_id != char_id ) { mapif_Auction_bid(fd, char_id, bid, 9); // You cannot place more than 5 bids at a time return; } if( auction->buyer_id > 0 ) { // Send Money back to the previous Buyer if( auction->buyer_id != char_id ) { mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(208), auction->price, NULL, 0); mapif_Auction_message(auction->buyer_id, 7); // You have failed to win the auction } else mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(209), auction->price, NULL, 0); } auction->buyer_id = char_id; safestrncpy(auction->buyer_name, RFIFOCP(fd,16), NAME_LENGTH); auction->price = bid; if( bid >= auction->buynow ) { // Automatic won the auction mapif_Auction_bid(fd, char_id, bid - auction->buynow, 1); // You have successfully bid in the auction mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(210), 0, &auction->item, 1); mapif_Auction_message(char_id, 6); // You have won the auction mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(211), auction->buynow, NULL, 0); auction_delete(auction); return; } auction_save(auction); mapif_Auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction }
static void mapif_parse_Auction_cancel(int fd) { int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6); struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL ) { mapif_Auction_cancel(fd, char_id, 1); // Bid Number is Incorrect return; } if( auction->seller_id != char_id ) { mapif_Auction_cancel(fd, char_id, 2); // You cannot end the auction return; } if( auction->buyer_id > 0 ) { mapif_Auction_cancel(fd, char_id, 3); // An auction with at least one bidder cannot be canceled return; } mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Auction canceled.", 0, &auction->item); auction_delete(auction); mapif_Auction_cancel(fd, char_id, 0); // The auction has been canceled }
/** * Request of the map-server that a player claimed his achievement rewards. * @see inter_parse_frommap */ int mapif_parse_achievement_reward(int fd){ time_t current = time(NULL); uint32 char_id = RFIFOL(fd, 2); int32 achievement_id = RFIFOL(fd, 6); if( Sql_Query( sql_handle, "UPDATE `%s` SET `rewarded` = FROM_UNIXTIME('%u') WHERE `char_id`='%u' AND `id` = '%d' AND `completed` IS NOT NULL AND `rewarded` IS NULL", schema_config.achievement_table, (uint32)current, char_id, achievement_id ) == SQL_ERROR || Sql_NumRowsAffected(sql_handle) <= 0 ){ current = 0; }else if( RFIFOW(fd,10) > 0 ){ // Do not send a mail if no item reward char mail_sender[NAME_LENGTH]; char mail_receiver[NAME_LENGTH]; char mail_title[MAIL_TITLE_LENGTH]; char mail_text[MAIL_BODY_LENGTH]; struct item item; memset(&item, 0, sizeof(struct item)); item.nameid = RFIFOW(fd, 10); item.amount = RFIFOL(fd, 12); item.identify = 1; safesnprintf(mail_sender, NAME_LENGTH, char_msg_txt(227)); // 227: GM safestrncpy(mail_receiver, RFIFOCP(fd,16), NAME_LENGTH); safesnprintf(mail_title, MAIL_TITLE_LENGTH, char_msg_txt(228)); // 228: Achievement Reward Mail safesnprintf(mail_text, MAIL_BODY_LENGTH, char_msg_txt(229), RFIFOCP(fd,16+NAME_LENGTH) ); // 229: [%s] Achievement Reward. if( !mail_sendmail(0, mail_sender, char_id, mail_receiver, mail_title, mail_text, 0, &item, 1) ){ current = 0; } } mapif_achievement_reward(fd, char_id, achievement_id, current); return 0; }
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) { struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) { if( auction->buyer_id ) { mail_sendmail(0, "Auction Manager", auction->buyer_id, auction->buyer_name, "Auction", "Thanks, you won the auction!.", 0, &auction->item); mapif_Auction_message(auction->buyer_id, 6); // You have won the auction mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "Payment for your auction!.", auction->price, NULL); } else mail_sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item); ShowInfo("Auction End: id %u.\n", auction->auction_id); auction->auction_end_timer = INVALID_TIMER; auction_delete(auction); } return 0; }
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data) { struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL ) { if( auction->buyer_id ) { mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(202), 0, &auction->item); mapif_Auction_message(auction->buyer_id, 6); // You have won the auction mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(203), auction->price, NULL); } else mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(204), 0, &auction->item); ShowInfo("Auction End: id %u.\n", auction->auction_id); auction->auction_end_timer = INVALID_TIMER; auction_delete(auction); } return 0; }