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_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 }
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 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; }