summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c2
-rw-r--r--src/map/battle.h2
-rw-r--r--src/map/clif.c217
-rw-r--r--src/map/clif.h5
-rw-r--r--src/map/intif.c56
-rw-r--r--src/map/intif.h3
-rw-r--r--src/map/itemdb.h17
-rw-r--r--src/map/mail.c1
-rw-r--r--src/map/map.h5
9 files changed, 287 insertions, 21 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index fc88611dd..3c467ff2e 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3652,6 +3652,8 @@ static const struct _battle_data {
{ "idle_no_autoloot", &battle_config.idle_no_autoloot, 0, 0, INT_MAX, },
{ "max_guild_alliance", &battle_config.max_guild_alliance, 3, 1, 3, },
{ "ksprotection", &battle_config.ksprotection, 5000, 0, INT_MAX, },
+ { "auction_feeperhour", &battle_config.auction_feeperhour, 12000, 0, INT_MAX, },
+ { "auction_maximumprice", &battle_config.auction_maximumprice, 500000000, 0, MAX_ZENY, },
};
diff --git a/src/map/battle.h b/src/map/battle.h
index 738f1c388..042b83cda 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -444,6 +444,8 @@ extern struct Battle_Config
int idle_no_autoloot;
int max_guild_alliance;
int ksprotection;
+ int auction_feeperhour;
+ int auction_maximumprice;
} battle_config;
void do_init_battle(void);
diff --git a/src/map/clif.c b/src/map/clif.c
index c815fd7b3..3088b040b 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11711,6 +11711,218 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
sd->cansendmail_tick = gettick() + 1000; // 1 Second flood Protection
}
+/*==========================================
+ * AUCTION SYSTEM
+ * By Zephyrus
+ *==========================================*/
+void clif_Auction_results(struct map_session_data *sd, short count, unsigned char *buf)
+{
+ int i, fd = sd->fd, len = sizeof(struct auction_data);
+ struct auction_data auction;
+ struct item_data *item;
+ int k;
+
+ WFIFOHEAD(fd,20);
+ WFIFOW(fd,0) = 0x252;
+ WFIFOW(fd,2) = 12 + (count * 83);
+ WFIFOL(fd,4) = 1; // ??
+ WFIFOL(fd,8) = count;
+
+ for( i = 0; i < count; i++ )
+ {
+ memcpy(&auction, RBUFP(buf,i * len), len);
+ k = 12 + (i * 83);
+
+ WFIFOL(fd,k) = auction.auction_id;
+ safestrncpy(WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH);
+
+ if( (item = itemdb_search(auction.item.nameid)) != NULL && item->view_id > 0 )
+ WFIFOW(fd,28+k) = item->view_id;
+ else
+ WFIFOW(fd,28+k) = auction.item.nameid;
+
+ WFIFOW(fd,30+k) = auction.type;
+ WFIFOW(fd,32+k) = 0; // ??
+ WFIFOW(fd,34+k) = auction.item.amount; // Allways 1
+ WFIFOB(fd,36+k) = auction.item.identify;
+ WFIFOB(fd,37+k) = auction.item.attribute;
+ WFIFOB(fd,38+k) = auction.item.refine;
+ WFIFOW(fd,39+k) = auction.item.card[0];
+ WFIFOW(fd,41+k) = auction.item.card[1];
+ WFIFOW(fd,43+k) = auction.item.card[2];
+ WFIFOW(fd,45+k) = auction.item.card[3];
+ WFIFOL(fd,47+k) = auction.price;
+ WFIFOL(fd,51+k) = auction.buynow;
+ safestrncpy(WFIFOP(fd,55+k), auction.buyer_name, NAME_LENGTH);
+ WFIFOL(fd,79+k) = auction.timestamp;
+ }
+ WFIFOSET(fd, 12 + (count * 83));
+}
+
+static void clif_Auction_setitem(int fd, int index, bool fail)
+{
+ WFIFOHEAD(fd,packet_len(0x256));
+ WFIFOW(fd,0) = 0x256;
+ WFIFOW(fd,2) = index;
+ WFIFOB(fd,4) = fail;
+ WFIFOSET(fd,packet_len(0x256));
+}
+
+void clif_parse_Auction_registerwindow(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.
+ sd->auction.amount = 0;
+}
+
+void clif_parse_Auction_setitem(int fd, struct map_session_data *sd)
+{
+ int idx = RFIFOW(fd,2) - 2;
+ int amount = RFIFOL(fd,4); // Allways 1
+ struct item_data *item;
+
+ if( sd->auction.amount > 0 )
+ sd->auction.amount = 0;
+
+ if( idx < 0 || idx > MAX_INVENTORY )
+ {
+ ShowWarning("Character %s trying to set invalid item index in auctions.\n", sd->status.name);
+ return;
+ }
+
+ if( amount != 1 || amount < 0 || amount > sd->status.inventory[idx].amount )
+ { // By client, amount is allways set to 1. Maybe this is a future implementation.
+ ShowWarning("Character %s trying to set invalid amount in auctions.\n", sd->status.name);
+ return;
+ }
+
+ if( (item = itemdb_search(sd->status.inventory[idx].nameid)) != NULL && !(item->type == IT_ARMOR || item->type == IT_PETARMOR || item->type == IT_WEAPON || item->type == IT_CARD || item->type == IT_ETC) )
+ { // Consumible or pets are not allowed
+ clif_Auction_setitem(sd->fd, idx, true);
+ return;
+ }
+
+ if( !pc_candrop(sd, &sd->status.inventory[idx]) || !sd->status.inventory[idx].identify )
+ { // Quest Item or something else
+ clif_Auction_setitem(sd->fd, idx, true);
+ return;
+ }
+
+ sd->auction.index = idx;
+ sd->auction.amount = amount;
+ clif_Auction_setitem(fd, idx, false);
+}
+
+// 0 = You have failed to bid into the auction
+// 1 = You have successfully bid in the auction
+// 2 = The auction has been canceled
+// 3 = An auction with at least one bidder cannot be canceled
+// 4 = You cannot register more than 5 items in an auction at a time
+// 5 = You do not have enough Zeny to pay the Auction Fee
+// 6 = You have won the auction
+// 7 = You have failed to win the auction
+// 8 = You do not have enough Zeny
+// 9 = You cannot place more than 5 bids at a time
+
+static void clif_Auction_message(int fd, unsigned char flag)
+{
+ WFIFOHEAD(fd,3);
+ WFIFOW(fd,0) = 0x250;
+ WFIFOB(fd,2) = flag;
+ WFIFOSET(fd,3);
+}
+
+void clif_parse_Auction_register(int fd, struct map_session_data *sd)
+{
+ struct auction_data auction;
+ struct item_data *item;
+
+ auction.price = RFIFOL(fd,2);
+ auction.buynow = RFIFOL(fd,6);
+ auction.hours = RFIFOW(fd,10);
+
+ // Invalid Situations...
+ if( sd->auction.amount < 1 )
+ {
+ ShowWarning("Character %s trying to register auction without item.\n", sd->status.name);
+ return;
+ }
+
+ if( auction.price >= auction.buynow )
+ {
+ ShowWarning("Character %s trying to alter auction prices.\n", sd->status.name);
+ return;
+ }
+
+ if( auction.hours < 1 || auction.hours > 48 )
+ {
+ ShowWarning("Character %s trying to enter an invalid time for auction.\n", sd->status.name);
+ return;
+ }
+
+ // Auction checks...
+ if( sd->status.zeny < (auction.hours * battle_config.auction_feeperhour) )
+ {
+ clif_Auction_message(fd, 5); // You do not have enough zeny to pay the Auction Fee.
+ return;
+ }
+
+ if( auction.buynow > battle_config.auction_maximumprice )
+ { // Zeny Limits
+ auction.buynow = battle_config.auction_maximumprice;
+ if( auction.price >= auction.buynow )
+ auction.price = auction.buynow - 1;
+ }
+
+ auction.seller_id = sd->status.char_id;
+ safestrncpy(auction.seller_name, sd->status.name, NAME_LENGTH);
+ auction.buyer_id = 0;
+ memset(&auction.buyer_name, '\0', NAME_LENGTH);
+
+ if( sd->status.inventory[sd->auction.index].nameid == 0 || sd->status.inventory[sd->auction.index].amount < sd->auction.amount )
+ {
+ clif_Auction_message(fd, 2); // The auction has been canceled
+ return;
+ }
+
+ if( (item = itemdb_search(sd->status.inventory[sd->auction.index].nameid)) == NULL )
+ { // Just in case
+ clif_Auction_message(fd, 2); // The auction has been canceled
+ return;
+ }
+
+ sd->status.zeny -= (auction.hours * battle_config.auction_feeperhour);
+ clif_updatestatus(sd, SP_ZENY);
+
+ safestrncpy(auction.item_name, item->jname, ITEM_NAME_LENGTH);
+ auction.type = item->type;
+ memcpy(&auction.item, &sd->status.inventory[sd->auction.index], sizeof(struct item));
+ auction.item.amount = 1;
+ auction.item.identify = 1;
+
+ pc_delitem(sd, sd->auction.index, sd->auction.amount, 0);
+ sd->auction.amount = 0;
+
+ auction.timestamp = (int)mail_calctimes() + (auction.hours * 3600);
+ intif_Auction_register(sd->status.account_id, &auction);
+}
+
+/*------------------------------------------
+ * Auction Search
+ * S 0251 <search type>.w <search price>.l <search text>.24B <01>.w
+ *------------------------------------------*/
+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);
+
+ safestrncpy(search_text, (char*)RFIFOP(fd,8), NAME_LENGTH);
+ intif_Auction_requestlist(sd->status.account_id, type, price, search_text);
+}
+
#endif
/*==========================================
@@ -12241,6 +12453,11 @@ static int packetdb_readdb(void)
{clif_parse_Mail_setattach,"mailsetattach"},
{clif_parse_Mail_winopen,"mailwinopen"},
{clif_parse_Mail_send,"mailsend"},
+ // AUCTION SYSTEM
+ {clif_parse_Auction_search,"auctionsearch"},
+ {clif_parse_Auction_setitem,"auctionsetitem"},
+ {clif_parse_Auction_registerwindow,"auctionregisterwindow"},
+ {clif_parse_Auction_register,"auctionregister"},
#endif
{clif_parse_cashshop_buy,"cashshopbuy"},
{clif_parse_ViewPlayerEquip,"viewplayerequip"},
diff --git a/src/map/clif.h b/src/map/clif.h
index d8714554d..aed08946b 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -123,7 +123,7 @@ int clif_scriptinput(struct map_session_data*,int); //self
int clif_scriptinputstr(struct map_session_data *sd,int npcid); // self
int clif_cutin(struct map_session_data* sd, const char* image, int type); //self
int clif_viewpoint(struct map_session_data*,int,int,int,int,int,int); //self
-int clif_additem(struct map_session_data*,int,int,int); //self
+int clif_additem(struct map_session_data *sd, int n, int amount, int fail); // self
int clif_delitem(struct map_session_data*,int,int); //self
int clif_updatestatus(struct map_session_data*,int); //self
int clif_changestatus(struct block_list*,int,int); //area
@@ -301,7 +301,6 @@ int clif_guild_allianceinfo(struct map_session_data *sd);
int clif_guild_memberlist(struct map_session_data *sd);
int clif_guild_skillinfo(struct map_session_data *sd);
int clif_guild_send_onlineinfo(struct map_session_data *sd); //[LuzZza]
-int clif_guild_masterormember(struct map_session_data *sd);
int clif_guild_memberlogin_notice(struct guild *g,int idx,int flag);
int clif_guild_invite(struct map_session_data *sd,struct guild *g);
int clif_guild_inviteack(struct map_session_data *sd,int flag);
@@ -409,6 +408,8 @@ void clif_Mail_send(int fd, bool fail);
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);
#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 b15987018..fe73d46bb 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1671,6 +1671,57 @@ static void intif_parse_Mail_new(int fd)
clif_Mail_new(sd->fd, mail_id, sender_name, title);
}
+/*==========================================
+ * AUCTION SYSTEM
+ * By Zephyrus
+ *==========================================*/
+int intif_Auction_requestlist(int account_id, short type, int price, const char* searchtext)
+{
+ int len = NAME_LENGTH + 14;
+
+ if( CheckForCharServer() )
+ return 0;
+
+ WFIFOHEAD(inter_fd,len);
+ WFIFOW(inter_fd,0) = 0x3050;
+ WFIFOW(inter_fd,2) = len;
+ WFIFOL(inter_fd,4) = account_id;
+ WFIFOW(inter_fd,8) = type;
+ WFIFOL(inter_fd,10) = price;
+ memcpy(WFIFOP(inter_fd,14), searchtext, NAME_LENGTH);
+ WFIFOSET(inter_fd,len);
+
+ return 0;
+}
+
+static void intif_parse_Auction_results(int fd)
+{
+ struct map_session_data *sd = map_id2sd(RFIFOL(fd,4));
+ short count = (RFIFOW(fd,2) - 8) / sizeof(struct auction_data);
+
+ if( sd == NULL )
+ return;
+
+ clif_Auction_results(sd, count, (char *)RFIFOP(fd,8));
+}
+
+int intif_Auction_register(int account_id, struct auction_data *auction)
+{
+ int len = sizeof(struct auction_data) + 8;
+
+ if( CheckForCharServer() )
+ return 0;
+
+ WFIFOHEAD(inter_fd,len);
+ WFIFOW(inter_fd,0) = 0x3051;
+ WFIFOW(inter_fd,2) = len;
+ WFIFOL(inter_fd,4) = account_id;
+ memcpy(WFIFOP(inter_fd,8), auction, sizeof(struct auction_data));
+ WFIFOSET(inter_fd,len);
+
+ return 0;
+}
+
#endif
//-----------------------------------------------------------------
@@ -1741,16 +1792,17 @@ int intif_parse(int fd)
case 0x3841: intif_parse_GuildCastleDataSave(fd); break;
case 0x3842: intif_parse_GuildCastleAllDataLoad(fd); break;
case 0x3843: intif_parse_GuildMasterChanged(fd); break;
-// Mail System
#ifndef TXT_ONLY
+// Mail System
case 0x3848: intif_parse_Mail_inboxreceived(fd); break;
case 0x3849: intif_parse_Mail_new(fd); break;
case 0x384a: intif_parse_Mail_getattach(fd); break;
case 0x384b: intif_parse_Mail_delete(fd); break;
case 0x384c: intif_parse_Mail_return(fd); break;
case 0x384d: intif_parse_Mail_send(fd); break;
+// Auction System
+ case 0x3850: intif_parse_Auction_results(fd); break;
#endif
-// End of Mail System
case 0x3880: intif_parse_CreatePet(fd); break;
case 0x3881: intif_parse_RecvPetData(fd); break;
case 0x3882: intif_parse_SavePetOk(fd); break;
diff --git a/src/map/intif.h b/src/map/intif.h
index 4adfc0a6b..d2e3ca4f8 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -82,6 +82,9 @@ int intif_Mail_getattach(int char_id, int mail_id);
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 account_id, short type, int price, const char* searchtext);
+int intif_Auction_register(int account_id, struct auction_data *auction);
#endif
int CheckForCharServer(void);
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 865ceaf9d..6be49f3e9 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -17,23 +17,6 @@
#define ITEMID_TRAP 1065
-
-enum item_types {
- IT_HEALING = 0,
- IT_UNKNOWN, //1
- IT_USABLE, //2
- IT_ETC, //3
- IT_WEAPON, //4
- IT_ARMOR, //5
- IT_CARD, //6
- IT_PETEGG, //7
- IT_PETARMOR,//8
- IT_UNKNOWN2,//9
- IT_AMMO, //10
- IT_DELAYCONSUME,//11
- IT_MAX
-};
-
//The only item group required by the code to be known. See const.txt for the full list.
#define IG_FINDINGORE 6
#define IG_POTION 37
diff --git a/src/map/mail.c b/src/map/mail.c
index b2a4697e5..0f03ddd5c 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -28,6 +28,7 @@ void mail_clear(struct map_session_data *sd)
sd->mail.index = 0;
sd->mail.amount = 0;
sd->mail.zeny = 0;
+ sd->auction.amount = 0;
return;
}
diff --git a/src/map/map.h b/src/map/map.h
index 687b89731..8ded26f9d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -784,6 +784,11 @@ struct map_session_data {
int cashPoints, kafraPoints;
+ // Auction System [Zephyrus]
+ struct {
+ int index, amount;
+ } auction;
+
// Mail System [Zephyrus]
struct {
short nameid;