summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-07 20:38:33 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-07 20:38:33 +0000
commitb2aec3fdf96913c1ebe69957d7c8d556988e6af2 (patch)
tree092c9193ace099c13eaea28af418fcfadcb1cdff
parent6b93f724139c3ab1e74c68ce79a79ecb525848f8 (diff)
downloadhercules-b2aec3fdf96913c1ebe69957d7c8d556988e6af2.tar.gz
hercules-b2aec3fdf96913c1ebe69957d7c8d556988e6af2.tar.bz2
hercules-b2aec3fdf96913c1ebe69957d7c8d556988e6af2.tar.xz
hercules-b2aec3fdf96913c1ebe69957d7c8d556988e6af2.zip
- Fixed some bugs on auction.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12318 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--db/packet_db.txt2
-rw-r--r--src/char_sql/int_auction.c14
-rw-r--r--src/map/clif.c19
-rw-r--r--src/map/intif.c2
-rw-r--r--src/map/intif.h1
5 files changed, 21 insertions, 17 deletions
diff --git a/db/packet_db.txt b/db/packet_db.txt
index a8a33c676..103795d25 100644
--- a/db/packet_db.txt
+++ b/db/packet_db.txt
@@ -765,7 +765,7 @@ packet_ver: 18
0x0248,68
0x0249,3
0x024a,70
-0x024b,4,auctionregisterwindow,0
+0x024b,4,auctioncancelreg,0
0x024c,8,auctionsetitem,0
0x024d,14
0x024e,6
diff --git a/src/char_sql/int_auction.c b/src/char_sql/int_auction.c
index f8adfddd2..dc915e8c1 100644
--- a/src/char_sql/int_auction.c
+++ b/src/char_sql/int_auction.c
@@ -81,7 +81,7 @@ void auction_save(struct auction_data *auction)
StringBuf_Destroy(&buf);
}
-static bool auction_create(struct auction_data *auction)
+unsigned int auction_create(struct auction_data *auction)
{
int j;
@@ -121,7 +121,7 @@ static bool auction_create(struct auction_data *auction)
auction->auction_id = (unsigned int)SqlStmt_LastInsertId(stmt);
auction->auction_end_timer = add_timer( gettick() + tick , auction_end_timer, auction->auction_id, 0);
- ShowInfo("New Auction Created: id %u | time left %d ms | Created by %s.\n", auction->auction_id, tick, auction->seller_name);
+ ShowInfo("New Auction %u | time left %d ms | By %s.\n", auction->auction_id, tick, auction->seller_name);
CREATE(auction_, struct auction_data, 1);
memcpy(auction_, auction, sizeof(struct auction_data));
@@ -131,7 +131,7 @@ static bool auction_create(struct auction_data *auction)
SqlStmt_Free(stmt);
StringBuf_Destroy(&buf);
- return (auction->auction_id > 0);
+ return auction->auction_id;
}
static int auction_end_timer(int tid, unsigned int tick, int id, int data)
@@ -302,8 +302,8 @@ static void mapif_parse_Auction_requestlist(int fd)
(type == 1 && auction->type != IT_WEAPON) ||
(type == 2 && auction->type != IT_CARD) ||
(type == 3 && auction->type != IT_ETC) ||
- (type == 4 && auction->price > price) ||
- (type == 5 && strstr(auction->item_name, searchtext)) ||
+ (type == 4 && !strstr(auction->item_name, searchtext)) ||
+ (type == 5 && auction->price > price) ||
(type == 6 && auction->seller_id != char_id) ||
(type == 7 && auction->buyer_id != char_id) )
continue;
@@ -320,7 +320,7 @@ static void mapif_Auction_register(int fd, struct auction_data *auction)
{
int len = sizeof(struct auction_data) + 4;
- WFIFOHEAD(fd, len);
+ WFIFOHEAD(fd,len);
WFIFOW(fd,0) = 0x3851;
WFIFOW(fd,2) = len;
memcpy(WFIFOP(fd,4), auction, sizeof(struct auction_data));
@@ -335,7 +335,7 @@ static void mapif_parse_Auction_register(int fd)
memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
if( auction_count(auction.seller_id, false) < 5 )
- auction_create(&auction);
+ auction.auction_id = auction_create(&auction);
mapif_Auction_register(fd, &auction);
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 694e6d987..6470ebb86 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11769,12 +11769,11 @@ static void clif_Auction_setitem(int fd, int index, bool fail)
WFIFOSET(fd,packet_len(0x256));
}
-void clif_parse_Auction_registerwindow(int fd, struct map_session_data *sd)
+void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd)
{
- // RFIFOW(fd,2):
- // = 0 means player opened the register window
- // = 1 means player press the Cancel button, in that window.
- // But... if player just enter the register window and press X to close, no packet is send.
+ if( sd->auction.amount > 0 )
+ clif_additem(sd, sd->auction.index, sd->auction.amount, 0);
+
sd->auction.amount = 0;
}
@@ -11787,7 +11786,7 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
if( sd->auction.amount > 0 )
sd->auction.amount = 0;
- if( idx < 0 || idx > MAX_INVENTORY )
+ if( idx < 0 || idx >= MAX_INVENTORY )
{
ShowWarning("Character %s trying to set invalid item index in auctions.\n", sd->status.name);
return;
@@ -11813,7 +11812,7 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
sd->auction.index = idx;
sd->auction.amount = amount;
- clif_Auction_setitem(fd, idx, false);
+ clif_Auction_setitem(fd, idx + 2, false);
}
// 0 = You have failed to bid into the auction
@@ -11921,6 +11920,8 @@ void clif_parse_Auction_search(int fd, struct map_session_data* sd)
char search_text[NAME_LENGTH];
short type = RFIFOW(fd,2);
int price = RFIFOL(fd,4);
+
+ clif_parse_Auction_cancelreg(fd, sd);
safestrncpy(search_text, (char*)RFIFOP(fd,8), NAME_LENGTH);
intif_Auction_requestlist(sd->status.char_id, type, price, search_text);
@@ -11931,6 +11932,8 @@ void clif_parse_Auction_buysell(int fd, struct map_session_data* sd)
short type = RFIFOW(fd,2) + 6;
char search_text[NAME_LENGTH];
+ clif_parse_Auction_cancelreg(fd, sd);
+
memset(&search_text, '\0', NAME_LENGTH);
intif_Auction_requestlist(sd->status.char_id, type, 0, search_text);
}
@@ -12469,7 +12472,7 @@ static int packetdb_readdb(void)
{clif_parse_Auction_search,"auctionsearch"},
{clif_parse_Auction_buysell,"auctionbuysell"},
{clif_parse_Auction_setitem,"auctionsetitem"},
- {clif_parse_Auction_registerwindow,"auctionregisterwindow"},
+ {clif_parse_Auction_cancelreg,"auctioncancelreg"},
{clif_parse_Auction_register,"auctionregister"},
#endif
{clif_parse_cashshop_buy,"cashshopbuy"},
diff --git a/src/map/intif.c b/src/map/intif.c
index 6bf6f4ef8..a9fba59e9 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1732,7 +1732,7 @@ static void intif_parse_Auction_register(int fd)
return;
}
- memcpy(&auction, WFIFOP(fd,4), sizeof(struct auction_data));
+ memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
if( (sd = map_charid2sd(auction.seller_id)) == NULL )
return;
diff --git a/src/map/intif.h b/src/map/intif.h
index 8628e752b..8f3cd1d9a 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -11,6 +11,7 @@ struct guild_position;
struct s_pet;
struct s_homunculus;
struct mail_message;
+struct auction_data;
int intif_parse(int fd);