- Fixed some bugs on auction.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12318 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
zephyrus 2008-03-07 20:38:33 +00:00
parent 8371e84434
commit 62c41846f0
5 changed files with 21 additions and 17 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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"},

View File

@ -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;

View File

@ -11,6 +11,7 @@ struct guild_position;
struct s_pet;
struct s_homunculus;
struct mail_message;
struct auction_data;
int intif_parse(int fd);