summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-08 20:11:28 +0000
committerzephyrus <zephyrus@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-03-08 20:11:28 +0000
commit603dc60466a7067ecb68384185cb1c20aaea7366 (patch)
treeb8e75ab3e5b7fe481571738ad7454262607d403f /src/map
parent1f4883d1f4fb65260691692879a795992fdbcf88 (diff)
downloadhercules-603dc60466a7067ecb68384185cb1c20aaea7366.tar.gz
hercules-603dc60466a7067ecb68384185cb1c20aaea7366.tar.bz2
hercules-603dc60466a7067ecb68384185cb1c20aaea7366.tar.xz
hercules-603dc60466a7067ecb68384185cb1c20aaea7366.zip
- Auction System implementation completed.
- As mail system, this will need a "mapflag" or something to only allow auctions on some maps. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12325 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c39
-rw-r--r--src/map/clif.h3
-rw-r--r--src/map/intif.c70
-rw-r--r--src/map/intif.h3
-rw-r--r--src/map/script.c15
5 files changed, 112 insertions, 18 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 2e0591c99..c4b0134a9 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11716,7 +11716,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
* AUCTION SYSTEM
* By Zephyrus
*==========================================*/
-void clif_Auction_results(struct map_session_data *sd, short count, unsigned char *buf)
+void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf)
{
int i, fd = sd->fd, len = sizeof(struct auction_data);
struct auction_data auction;
@@ -11726,7 +11726,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, unsigned cha
WFIFOHEAD(fd,20);
WFIFOW(fd,0) = 0x252;
WFIFOW(fd,2) = 12 + (count * 83);
- WFIFOL(fd,4) = 1; // ??
+ WFIFOL(fd,4) = pages;
WFIFOL(fd,8) = count;
for( i = 0; i < count; i++ )
@@ -11915,7 +11915,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd)
clif_Auction_message(fd, 4); // No Char Server? lets say something to the client
else
{
- pc_delitem(sd, sd->auction.index, sd->auction.amount, 0);
+ pc_delitem(sd, sd->auction.index, sd->auction.amount, 1);
sd->auction.amount = 0;
pc_payzeny(sd, auction.hours * battle_config.auction_feeperhour);
}
@@ -11935,32 +11935,45 @@ void clif_parse_Auction_close(int fd, struct map_session_data *sd)
intif_Auction_close(sd->status.char_id, auction_id);
}
+void clif_parse_Auction_bid(int fd, struct map_session_data *sd)
+{
+ unsigned int auction_id = RFIFOL(fd,2);
+ int bid = RFIFOL(fd,6);
+
+ if( bid <= 0 )
+ clif_Auction_message(fd, 0); // You have failed to bid into the auction
+ else if( bid > sd->status.zeny )
+ clif_Auction_message(fd, 8); // You do not have enough zeny
+ else
+ {
+ pc_payzeny(sd, bid);
+ intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid);
+ }
+}
+
/*------------------------------------------
* Auction Search
- * S 0251 <search type>.w <search price>.l <search text>.24B <01>.w
+ * S 0251 <search type>.w <search price>.l <search text>.24B <page number>.w
* Search Type: 0 Armor 1 Weapon 2 Card 3 Misc 4 By Text 5 By Price 6 Sell 7 Buy
*------------------------------------------*/
void clif_parse_Auction_search(int fd, struct map_session_data* sd)
{
char search_text[NAME_LENGTH];
- short type = RFIFOW(fd,2);
+ short type = RFIFOW(fd,2), page = RFIFOW(fd,32);
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);
+ intif_Auction_requestlist(sd->status.char_id, type, price, search_text, page);
}
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);
+ intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1);
}
#endif
@@ -12023,6 +12036,9 @@ void clif_Auction_openwindow(struct map_session_data *sd)
{
int fd = sd->fd;
+ if( sd->state.storage_flag || sd->vender_id || sd->state.trading )
+ return;
+
WFIFOHEAD(fd,12);
WFIFOW(fd,0) = 0x25f;
WFIFOL(fd,2) = 0;
@@ -12499,6 +12515,9 @@ static int packetdb_readdb(void)
{clif_parse_Auction_setitem,"auctionsetitem"},
{clif_parse_Auction_cancelreg,"auctioncancelreg"},
{clif_parse_Auction_register,"auctionregister"},
+ {clif_parse_Auction_cancel,"auctioncancel"},
+ {clif_parse_Auction_close,"auctionclose"},
+ {clif_parse_Auction_bid,"auctionbid"},
#endif
{clif_parse_cashshop_buy,"cashshopbuy"},
{clif_parse_ViewPlayerEquip,"viewplayerequip"},
diff --git a/src/map/clif.h b/src/map/clif.h
index 9be840d72..58c088dad 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -409,9 +409,10 @@ void clif_Mail_new(int fd, int mail_id, const char *sender, const char *title);
void clif_Mail_refreshinbox(struct map_session_data *sd);
void clif_Mail_getattachment(int fd, uint8 flag);
// AUCTION SYSTEM
-void clif_Auction_results(struct map_session_data *sd, short count, unsigned char *buf);
+void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf);
void clif_Auction_message(int fd, unsigned char flag);
void clif_Auction_close(int fd, unsigned char flag);
+void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd);
#endif
void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd);
diff --git a/src/map/intif.c b/src/map/intif.c
index ff18aecba..684353395 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -35,7 +35,7 @@ static const int packet_len_table[]={
39,-1,15,15, 14,19, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3820
10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, //0x3830
9, 9,-1,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840
- -1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus]
+ -1,-1, 7, 7, 7,11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus]
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880
@@ -1675,9 +1675,9 @@ static void intif_parse_Mail_new(int fd)
* AUCTION SYSTEM
* By Zephyrus
*==========================================*/
-int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext)
+int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page)
{
- int len = NAME_LENGTH + 14;
+ int len = NAME_LENGTH + 16;
if( CheckForCharServer() )
return 0;
@@ -1688,7 +1688,8 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
WFIFOL(inter_fd,4) = char_id;
WFIFOW(inter_fd,8) = type;
WFIFOL(inter_fd,10) = price;
- memcpy(WFIFOP(inter_fd,14), searchtext, NAME_LENGTH);
+ WFIFOW(inter_fd,14) = page;
+ memcpy(WFIFOP(inter_fd,16), searchtext, NAME_LENGTH);
WFIFOSET(inter_fd,len);
return 0;
@@ -1697,12 +1698,12 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se
static void intif_parse_Auction_results(int fd)
{
struct map_session_data *sd = map_charid2sd(RFIFOL(fd,4));
- short count = (RFIFOW(fd,2) - 8) / sizeof(struct auction_data);
+ short count = RFIFOW(fd,8), pages = RFIFOW(fd,10);
if( sd == NULL )
return;
- clif_Auction_results(sd, count, (char *)RFIFOP(fd,8));
+ clif_Auction_results(sd, count, pages, (char *)RFIFOP(fd,12));
}
int intif_Auction_register(struct auction_data *auction)
@@ -1800,6 +1801,61 @@ static void intif_parse_Auction_close(int fd)
return;
clif_Auction_close(sd->fd, result);
+ if( result == 0 )
+ {
+ clif_parse_Auction_cancelreg(fd, sd);
+ intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1);
+ }
+}
+
+int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid)
+{
+ int len = 16 + NAME_LENGTH;
+
+ if( CheckForCharServer() )
+ return 0;
+
+ WFIFOHEAD(inter_fd,len);
+ WFIFOW(inter_fd,0) = 0x3055;
+ WFIFOW(inter_fd,2) = len;
+ WFIFOL(inter_fd,4) = char_id;
+ WFIFOL(inter_fd,8) = auction_id;
+ WFIFOL(inter_fd,12) = bid;
+ memcpy(WFIFOP(inter_fd,16), name, NAME_LENGTH);
+ WFIFOSET(inter_fd,len);
+
+ return 0;
+}
+
+static void intif_parse_Auction_bid(int fd)
+{
+ struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ int bid = RFIFOL(fd,6);
+ unsigned char result = RFIFOB(fd,10);
+
+ if( sd == NULL )
+ return;
+
+ clif_Auction_message(sd->fd, result);
+ if( bid > 0 )
+ pc_getzeny(sd, bid);
+ if( result == 1 )
+ { // To update the list, display your buy list
+ clif_parse_Auction_cancelreg(fd, sd);
+ intif_Auction_requestlist(sd->status.char_id, 7, 0, "", 1);
+ }
+}
+
+// Used to send 'You have won the auction' and 'You failed to won the auction' messages
+static void intif_parse_Auction_message(int fd)
+{
+ struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
+ unsigned char result = RFIFOB(fd,6);
+
+ if( sd == NULL )
+ return;
+
+ clif_Auction_message(sd->fd, result);
}
#endif
@@ -1885,6 +1941,8 @@ int intif_parse(int fd)
case 0x3851: intif_parse_Auction_register(fd); break;
case 0x3852: intif_parse_Auction_cancel(fd); break;
case 0x3853: intif_parse_Auction_close(fd); break;
+ case 0x3854: intif_parse_Auction_message(fd); break;
+ case 0x3855: intif_parse_Auction_bid(fd); break;
#endif
case 0x3880: intif_parse_CreatePet(fd); break;
case 0x3881: intif_parse_RecvPetData(fd); break;
diff --git a/src/map/intif.h b/src/map/intif.h
index 743057fb4..a713be7ea 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -84,10 +84,11 @@ int intif_Mail_delete(int char_id, int mail_id);
int intif_Mail_return(int char_id, int mail_id);
int intif_Mail_send(int account_id, struct mail_message *msg);
// AUCTION SYSTEM
-int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext);
+int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page);
int intif_Auction_register(struct auction_data *auction);
int intif_Auction_cancel(int char_id, unsigned int auction_id);
int intif_Auction_close(int char_id, unsigned int auction_id);
+int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid);
#endif
int CheckForCharServer(void);
diff --git a/src/map/script.c b/src/map/script.c
index ee5bbbdc5..36c29e8d5 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -13016,6 +13016,20 @@ BUILDIN_FUNC(openmail)
return 0;
}
+BUILDIN_FUNC(openauction)
+{
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 0;
+
+#ifndef TXT_ONLY
+ clif_Auction_openwindow(sd);
+#endif
+ return 0;
+}
+
/// Modifies flags of cells in the specified area.
///
/// setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>;
@@ -13386,6 +13400,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(checkvending,"*"),
BUILDIN_DEF(checkchatting,"*"),
BUILDIN_DEF(openmail,""),
+ BUILDIN_DEF(openauction,""),
BUILDIN_DEF(setcell,"siiiiii"),
{NULL,NULL,NULL},
};