summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-06-15 05:00:04 -0300
committershennetsind <ind@henn.et>2013-06-15 05:00:04 -0300
commitcf78bebc95e3387cf7fbe0720825bacb95c1b61a (patch)
treee895ec5f3f9baa111476af18607ec292f06d9df6
parent1dd4882c00b82d9a2f138211dbc2c8c542e2af88 (diff)
parentde3f4423058405636c76e05cd87a6eae0bfa7707 (diff)
downloadhercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.tar.gz
hercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.tar.bz2
hercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.tar.xz
hercules-cf78bebc95e3387cf7fbe0720825bacb95c1b61a.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
-rw-r--r--src/common/mmo.h7
-rw-r--r--src/config/const.h7
-rw-r--r--src/map/atcommand.c27
-rw-r--r--src/map/clif.c44
-rw-r--r--src/map/intif.c4
-rw-r--r--src/map/mail.c21
-rw-r--r--src/map/mail.h22
-rw-r--r--src/map/pc.c3
-rw-r--r--src/map/script.c5
-rw-r--r--src/map/trade.c35
-rw-r--r--src/map/trade.h21
-rw-r--r--src/map/unit.c2
12 files changed, 134 insertions, 64 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index eaffdf7df..8643d2b54 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -54,6 +54,13 @@
// Comment the following line if your client is NOT ragexeRE (required because of conflicting packets in ragexe vs ragexeRE).
#define PACKETVER_RE
+// Client support for experimental RagexeRE UI present in 2012-04-10 and 2012-04-18
+#ifdef PACKETVER_RE
+#if (PACKETVER == 20120410) || (PACKETVER == 20120418)
+ #define PARTY_RECRUIT
+#endif
+#endif
+
// Comment the following line to disable sc_data saving. [Skotlex]
#define ENABLE_SC_SAVING
diff --git a/src/config/const.h b/src/config/const.h
index f4a2821f8..d8e397b1e 100644
--- a/src/config/const.h
+++ b/src/config/const.h
@@ -92,12 +92,7 @@
#else
#define MAX_CARTS 5
#endif
-/* Client Supports Party Recruit or Party Booking? */
-#ifdef PACKETVER_RE
-#if (PACKETVER == 20120410) || (PACKETVER == 20120418)
- #define PARTY_RECRUIT
-#endif
-#endif
+
// Renewal variable cast time reduction
#ifdef RENEWAL_CAST
#define VARCAST_REDUCTION(val){ \
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d9810e77c..b6a9e42ee 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3718,10 +3718,33 @@ ACMD(reloadpcdb)
*------------------------------------------*/
ACMD(reloadscript)
{
+ struct s_mapiterator* iter;
+ struct map_session_data* pl_sd;
+
nullpo_retr(-1, sd);
//atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." );
//atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" );
+ iter = mapit_getallusers();
+ for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) {
+ if (pl_sd->npc_id || pl_sd->npc_shopid) {
+ if (pl_sd->state.using_fake_npc) {
+ clif->clearunit_single(pl_sd->npc_id, CLR_OUTSIGHT, pl_sd->fd);
+ pl_sd->state.using_fake_npc = 0;
+ }
+ if (pl_sd->state.menu_or_input)
+ pl_sd->state.menu_or_input = 0;
+ if (pl_sd->npc_menu)
+ pl_sd->npc_menu = 0;
+
+ pl_sd->npc_id = 0;
+ pl_sd->npc_shopid = 0;
+ if (pl_sd->st && pl_sd->st->state != END)
+ pl_sd->st->state = END;
+ }
+ }
+ mapit->free(iter);
+
flush_fifos();
iMap->reloadnpc(true); // reload config files seeking for npcs
script_reload();
@@ -6397,7 +6420,7 @@ ACMD(trade)
return false;
}
- trade_traderequest(sd, pl_sd);
+ trade->request(sd, pl_sd);
return true;
}
@@ -6601,7 +6624,7 @@ ACMD(misceffect) {
ACMD(mail)
{
nullpo_ret(sd);
- mail_openmail(sd);
+ mail->openmail(sd);
return true;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 2feb6f4bf..e8de09d70 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8560,7 +8560,7 @@ void clif_refresh(struct map_session_data *sd)
// unlike vending, resuming buyingstore crashes the client.
buyingstore->close(sd);
- mail_clear(sd);
+ mail->clear(sd);
if( disguised(&sd->bl) ) {/* refresh-da */
short disguise = sd->disguise;
@@ -9601,7 +9601,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
}
}
- mail_clear(sd);
+ mail->clear(sd);
clif->maptypeproperty2(&sd->bl,SELF);
@@ -11041,7 +11041,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
return;
}
- trade_traderequest(sd,t_sd);
+ trade->request(sd,t_sd);
}
@@ -11052,7 +11052,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd)
/// 4 = rejected
void clif_parse_TradeAck(int fd,struct map_session_data *sd)
{
- trade_tradeack(sd,RFIFOB(fd,2));
+ trade->ack(sd,RFIFOB(fd,2));
}
@@ -11064,9 +11064,9 @@ void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
int amount = RFIFOL(fd,4);
if( index == 0 )
- trade_tradeaddzeny(sd, amount);
+ trade->addzeny(sd, amount);
else
- trade_tradeadditem(sd, index, (short)amount);
+ trade->additem(sd, index, (short)amount);
}
@@ -11074,7 +11074,7 @@ void clif_parse_TradeAddItem(int fd,struct map_session_data *sd)
/// 00eb
void clif_parse_TradeOk(int fd,struct map_session_data *sd)
{
- trade_tradeok(sd);
+ trade->ok(sd);
}
@@ -11082,7 +11082,7 @@ void clif_parse_TradeOk(int fd,struct map_session_data *sd)
/// 00ed
void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
}
@@ -11090,7 +11090,7 @@ void clif_parse_TradeCancel(int fd,struct map_session_data *sd)
/// 00ef
void clif_parse_TradeCommit(int fd,struct map_session_data *sd)
{
- trade_tradecommit(sd);
+ trade->commit(sd);
}
@@ -14471,8 +14471,8 @@ void clif_parse_Mail_refreshinbox(int fd, struct map_session_data *sd)
else
clif->mail_refreshinbox(sd);
- mail_removeitem(sd, 0);
- mail_removezeny(sd, 0);
+ mail->removeitem(sd, 0);
+ mail->removezeny(sd, 0);
}
@@ -14546,7 +14546,7 @@ void clif_parse_Mail_read(int fd, struct map_session_data *sd)
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
clif->mail_read(sd, RFIFOL(fd,2));
@@ -14565,7 +14565,7 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd)
return;
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -14626,7 +14626,7 @@ void clif_parse_Mail_delete(int fd, struct map_session_data *sd)
return;
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -14652,7 +14652,7 @@ void clif_parse_Mail_return(int fd, struct map_session_data *sd)
if( mail_id <= 0 )
return;
- if( mail_invalid_operation(sd) )
+ if( mail->invalid_operation(sd) )
return;
ARR_FIND(0, MAIL_MAX_INBOX, i, sd->mail.inbox.msg[i].id == mail_id);
@@ -14676,7 +14676,7 @@ void clif_parse_Mail_setattach(int fd, struct map_session_data *sd)
if (idx < 0 || amount < 0)
return;
- flag = mail_setitem(sd, idx, amount);
+ flag = mail->setitem(sd, idx, amount);
clif->mail_setattachment(fd,idx,flag);
}
@@ -14692,9 +14692,9 @@ void clif_parse_Mail_winopen(int fd, struct map_session_data *sd)
int flag = RFIFOW(fd,2);
if (flag == 0 || flag == 1)
- mail_removeitem(sd, 0);
+ mail->removeitem(sd, 0);
if (flag == 0 || flag == 2)
- mail_removezeny(sd, 0);
+ mail->removezeny(sd, 0);
}
@@ -14726,10 +14726,10 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
if (body_len > MAIL_BODY_LENGTH)
body_len = MAIL_BODY_LENGTH;
- if( !mail_setattachment(sd, &msg) ) { // Invalid Append condition
+ if( !mail->setattachment(sd, &msg) ) { // Invalid Append condition
clif->mail_send(sd->fd, true); // fail
- mail_removeitem(sd,0);
- mail_removezeny(sd,0);
+ mail->removeitem(sd,0);
+ mail->removezeny(sd,0);
return;
}
@@ -14751,7 +14751,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd)
msg.timestamp = time(NULL);
if( !intif_Mail_send(sd->status.account_id, &msg) )
- mail_deliveryfail(sd, &msg);
+ mail->deliveryfail(sd, &msg);
sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection
}
diff --git a/src/map/intif.c b/src/map/intif.c
index 3cdf93487..f3931e79e 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1582,7 +1582,7 @@ int intif_parse_Mail_getattach(int fd)
memcpy(&item, RFIFOP(fd,12), sizeof(struct item));
- mail_getattachment(sd, zeny, &item);
+ mail->getattachment(sd, zeny, &item);
return 0;
}
/*------------------------------------------
@@ -1718,7 +1718,7 @@ static void intif_parse_Mail_send(int fd)
if( sd != NULL )
{
if( fail )
- mail_deliveryfail(sd, &msg);
+ mail->deliveryfail(sd, &msg);
else
{
clif->mail_send(sd->fd, false);
diff --git a/src/map/mail.c b/src/map/mail.c
index 299fb5117..24af018ad 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -72,7 +72,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) {
return 0;
} else { // Item Transfer
idx -= 2;
- mail_removeitem(sd, 0);
+ mail->removeitem(sd, 0);
if( idx < 0 || idx >= MAX_INVENTORY )
return 1;
@@ -121,8 +121,8 @@ bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg)
msg->zeny = sd->mail.zeny;
// Removes the attachment from sender
- mail_removeitem(sd,1);
- mail_removezeny(sd,1);
+ mail->removeitem(sd,1);
+ mail->removezeny(sd,1);
return true;
}
@@ -183,3 +183,18 @@ bool mail_invalid_operation(struct map_session_data *sd)
return false;
}
+
+void mail_defaults(void)
+{
+ mail = &mail_s;
+
+ mail->clear = mail_clear;
+ mail->removeitem = mail_removeitem;
+ mail->removezeny = mail_removezeny;
+ mail->setitem = mail_setitem;
+ mail->setattachment = mail_setattachment;
+ mail->getattachment = mail_getattachment;
+ mail->openmail = mail_openmail;
+ mail->deliveryfail = mail_deliveryfail;
+ mail->invalid_operation = mail_invalid_operation;
+} \ No newline at end of file
diff --git a/src/map/mail.h b/src/map/mail.h
index cab582e55..5e5883aa6 100644
--- a/src/map/mail.h
+++ b/src/map/mail.h
@@ -6,14 +6,18 @@
#include "../common/mmo.h"
-void mail_clear(struct map_session_data *sd);
-int mail_removeitem(struct map_session_data *sd, short flag);
-int mail_removezeny(struct map_session_data *sd, short flag);
-unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount);
-bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg);
-void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item);
-int mail_openmail(struct map_session_data *sd);
-void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg);
-bool mail_invalid_operation(struct map_session_data *sd);
+struct mail_interface {
+ void (*clear) (struct map_session_data *sd);
+ int (*removeitem) (struct map_session_data *sd, short flag);
+ int (*removezeny) (struct map_session_data *sd, short flag);
+ unsigned char (*setitem) (struct map_session_data *sd, int idx, int amount);
+ bool (*setattachment) (struct map_session_data *sd, struct mail_message *msg);
+ void (*getattachment) (struct map_session_data* sd, int zeny, struct item* item);
+ int (*openmail) (struct map_session_data *sd);
+ void (*deliveryfail) (struct map_session_data *sd, struct mail_message *msg);
+ bool (*invalid_operation) (struct map_session_data *sd);
+} mail_s;
+
+struct mail_interface *mail;
#endif /* _MAIL_H_ */
diff --git a/src/map/pc.c b/src/map/pc.c
index 155812836..ef70aad97 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -6667,7 +6667,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
npc_script_event(sd,NPCE_DIE);
// Clear anything NPC-related when you die and was interacting with one.
- if (sd->npc_id) {
+ if (sd->npc_id || sd->npc_shopid) {
if (sd->state.using_fake_npc) {
clif->clearunit_single(sd->npc_id, CLR_OUTSIGHT, sd->fd);
sd->state.using_fake_npc = 0;
@@ -6678,6 +6678,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
sd->npc_menu = 0;
sd->npc_id = 0;
+ sd->npc_shopid = 0;
if (sd->st && sd->st->state != END)
sd->st->state = END;
}
diff --git a/src/map/script.c b/src/map/script.c
index a768ca7ae..15870aaa7 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -7223,6 +7223,9 @@ BUILDIN(successrefitem)
//Logs items, got from (N)PC scripts [Lupus]
logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
+ if (sd->status.inventory[i].refine >= MAX_REFINE)
+ return true;
+
sd->status.inventory[i].refine++;
pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
@@ -15263,7 +15266,7 @@ BUILDIN(openmail)
if( sd == NULL )
return true;
- mail_openmail(sd);
+ mail->openmail(sd);
return true;
}
diff --git a/src/map/trade.c b/src/map/trade.c
index 8311dbf3d..f469f4b28 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -331,7 +331,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL )
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
@@ -415,13 +415,13 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount)
if( (target_sd = iMap->id2sd(sd->trade_partner)) == NULL )
{
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
if( amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny )
{ // invalid values, no appropriate packet for it => abort
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
@@ -440,7 +440,7 @@ void trade_tradeok(struct map_session_data *sd)
return;
if ((target_sd = iMap->id2sd(sd->trade_partner)) == NULL) {
- trade_tradecancel(sd);
+ trade->cancel(sd);
return;
}
sd->state.deal_locked = 1;
@@ -532,18 +532,18 @@ void trade_tradecommit(struct map_session_data *sd)
//Now is a good time (to save on resources) to check that the trade can indeed be made and it's not exploitable.
// check exploit (trade more items that you have)
- if (impossible_trade_check(sd)) {
- trade_tradecancel(sd);
+ if (trade->check_impossible(sd)) {
+ trade->cancel(sd);
return;
}
// check exploit (trade more items that you have)
- if (impossible_trade_check(tsd)) {
- trade_tradecancel(tsd);
+ if (trade->check_impossible(tsd)) {
+ trade->cancel(tsd);
return;
}
// check for full inventory (can not add traded items)
- if (!trade_check(sd,tsd)) { // check the both players
- trade_tradecancel(sd);
+ if (!trade->check(sd,tsd)) { // check the both players
+ trade->cancel(sd);
return;
}
@@ -607,3 +607,18 @@ void trade_tradecommit(struct map_session_data *sd)
chrif_save(tsd,0);
}
}
+
+void trade_defaults(void)
+{
+ trade = &trade_s;
+
+ trade->request = trade_traderequest;
+ trade->ack = trade_tradeack;
+ trade->check_impossible = impossible_trade_check;
+ trade->check = trade_check;
+ trade->additem = trade_tradeadditem;
+ trade->addzeny = trade_tradeaddzeny;
+ trade->ok = trade_tradeok;
+ trade->cancel = trade_tradecancel;
+ trade->commit = trade_tradecommit;
+} \ No newline at end of file
diff --git a/src/map/trade.h b/src/map/trade.h
index 6bb39936e..6bcefdb96 100644
--- a/src/map/trade.h
+++ b/src/map/trade.h
@@ -7,12 +7,19 @@
//#include "map.h"
struct map_session_data;
-void trade_traderequest(struct map_session_data *sd, struct map_session_data *target_sd);
-void trade_tradeack(struct map_session_data *sd,int type);
-void trade_tradeadditem(struct map_session_data *sd,short index,short amount);
-void trade_tradeaddzeny(struct map_session_data *sd,int amount);
-void trade_tradeok(struct map_session_data *sd);
-void trade_tradecancel(struct map_session_data *sd);
-void trade_tradecommit(struct map_session_data *sd);
+struct trade_interface {
+ void (*request) (struct map_session_data *sd, struct map_session_data *target_sd);
+ void (*ack) (struct map_session_data *sd,int type);
+ int (*check_impossible) (struct map_session_data *sd);
+ int (*check) (struct map_session_data *sd, struct map_session_data *tsd);
+ void (*additem) (struct map_session_data *sd,short index,short amount);
+ void (*addzeny) (struct map_session_data *sd,int amount);
+ void (*ok) (struct map_session_data *sd);
+ void (*cancel) (struct map_session_data *sd);
+ void (*commit) (struct map_session_data *sd);
+} trade_s;
+
+struct trade_interface *trade;
+void trade_interface(void);
#endif /* _TRADE_H_ */
diff --git a/src/map/unit.c b/src/map/unit.c
index e5637e42d..021859bba 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2104,7 +2104,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if(sd->chatID)
chat_leavechat(sd,0);
if(sd->trade_partner)
- trade_tradecancel(sd);
+ trade->cancel(sd);
buyingstore->close(sd);
searchstore->close(sd);
if(sd->state.storage_flag == 1)