summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-08 15:52:15 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-08 15:52:15 +0000
commit4c8554d9bb073eccfde7525f2ad33d9de9f0b7f1 (patch)
tree8513a1c9783fd8a95db68ebf8a862491d5e0a528 /src/char_sql
parent67264ee2c1e40690401ddc1d3f509f21b3281735 (diff)
downloadhercules-4c8554d9bb073eccfde7525f2ad33d9de9f0b7f1.tar.gz
hercules-4c8554d9bb073eccfde7525f2ad33d9de9f0b7f1.tar.bz2
hercules-4c8554d9bb073eccfde7525f2ad33d9de9f0b7f1.tar.xz
hercules-4c8554d9bb073eccfde7525f2ad33d9de9f0b7f1.zip
- Added support for Auction Close and Cancel.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12323 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/int_auction.c106
-rw-r--r--src/char_sql/inter.c2
2 files changed, 107 insertions, 1 deletions
diff --git a/src/char_sql/int_auction.c b/src/char_sql/int_auction.c
index 1495afc1e..e40098556 100644
--- a/src/char_sql/int_auction.c
+++ b/src/char_sql/int_auction.c
@@ -341,6 +341,110 @@ static void mapif_parse_Auction_register(int fd)
mapif_Auction_register(fd, &auction);
}
+static void mapif_Auction_cancel(int fd, int char_id, unsigned char result)
+{
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x3852;
+ WFIFOL(fd,8) = char_id;
+ WFIFOB(fd,6) = result;
+ WFIFOSET(fd,7);
+}
+
+static void mapif_parse_Auction_cancel(int fd)
+{
+ int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6);
+ struct auction_data *auction;
+ struct mail_message msg;
+
+ 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;
+ }
+
+ memset(&msg, 0, sizeof(struct mail_message));
+ safestrncpy(msg.send_name, "Auction Manager", NAME_LENGTH);
+ msg.dest_id = auction->seller_id;
+ safestrncpy(msg.dest_name, auction->seller_name, NAME_LENGTH);
+ msg.timestamp = (int)calc_times();
+ safestrncpy(msg.title, "Auction", MAIL_TITLE_LENGTH);
+ safestrncpy(msg.body, "Auction canceled.", MAIL_BODY_LENGTH);
+
+ memcpy(&msg.item, &auction->item, sizeof(struct item));
+
+ mail_savemessage(&msg);
+ mapif_Mail_new(&msg);
+
+ auction_delete(auction);
+ mapif_Auction_cancel(fd, char_id, 0); // The auction has been canceled
+}
+
+static void mapif_Auction_close(int fd, int char_id, unsigned char result)
+{
+ WFIFOHEAD(fd,7);
+ WFIFOW(fd,0) = 0x3853;
+ WFIFOL(fd,8) = char_id;
+ WFIFOB(fd,6) = result;
+ WFIFOSET(fd,7);
+}
+
+static void mapif_parse_Auction_close(int fd)
+{
+ int char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6);
+ struct auction_data *auction;
+ struct mail_message msg;
+
+ if( (auction = (struct auction_data *)idb_get(auction_db_, auction_id)) == NULL )
+ {
+ mapif_Auction_cancel(fd, char_id, 2); // Bid Number is Incorrect
+ return;
+ }
+
+ if( auction->buyer_id == 0 )
+ {
+ mapif_Auction_cancel(fd, char_id, 1); // You cannot end the auction
+ return;
+ }
+
+ // Send Money to Seller
+ memset(&msg, 0, sizeof(struct mail_message));
+ safestrncpy(msg.send_name, "Auction Manager", NAME_LENGTH);
+ msg.dest_id = auction->seller_id;
+ safestrncpy(msg.dest_name, auction->seller_name, NAME_LENGTH);
+ msg.timestamp = (int)calc_times();
+ safestrncpy(msg.title, "Auction", MAIL_TITLE_LENGTH);
+ safestrncpy(msg.body, "Auction closed.", MAIL_BODY_LENGTH);
+ msg.zeny = auction->price; // Current Bid
+ mail_savemessage(&msg);
+ mapif_Mail_new(&msg);
+
+ // Send Item to Buyer
+ memset(&msg, 0, sizeof(struct mail_message));
+ safestrncpy(msg.send_name, "Auction Manager", NAME_LENGTH);
+ msg.dest_id = auction->buyer_id;
+ safestrncpy(msg.dest_name, auction->buyer_name, NAME_LENGTH);
+ msg.timestamp = (int)calc_times();
+ safestrncpy(msg.title, "Auction", MAIL_TITLE_LENGTH);
+ safestrncpy(msg.body, "Auction winner.", MAIL_BODY_LENGTH);
+ memcpy(&msg.item, &auction->item, sizeof(struct item));
+ mail_savemessage(&msg);
+ mapif_Mail_new(&msg);
+
+ mapif_Auction_cancel(fd, char_id, 0); // You have ended the auction
+}
+
/*==========================================
* Packets From Map Server
*------------------------------------------*/
@@ -350,6 +454,8 @@ int inter_auction_parse_frommap(int fd)
{
case 0x3050: mapif_parse_Auction_requestlist(fd); break;
case 0x3051: mapif_parse_Auction_register(fd); break;
+ case 0x3052: mapif_parse_Auction_cancel(fd); break;
+ case 0x3053: mapif_parse_Auction_close(fd); break;
default:
return 0;
}
diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c
index 451ffb6b7..2271fe586 100644
--- a/src/char_sql/inter.c
+++ b/src/char_sql/inter.c
@@ -55,7 +55,7 @@ int inter_recv_packet_length[] = {
-1, 6,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020-
-1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1, // 3030-
5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040-
- -1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus]
+ -1,-1,10,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus]
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070-
48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080-