summaryrefslogtreecommitdiff
path: root/src/map/mail.c
diff options
context:
space:
mode:
authorbrianluau <brianluau@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-12-05 02:53:33 +0000
committerbrianluau <brianluau@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-12-05 02:53:33 +0000
commit60a426c0742b3e7d8c5b557c7578df6eeeea377b (patch)
tree5d01f9ccc2798309f9b13f07c0096ed97c6a85c8 /src/map/mail.c
parent621db2441f69736a6c8f10d26bf966d5414fac74 (diff)
downloadhercules-60a426c0742b3e7d8c5b557c7578df6eeeea377b.tar.gz
hercules-60a426c0742b3e7d8c5b557c7578df6eeeea377b.tar.bz2
hercules-60a426c0742b3e7d8c5b557c7578df6eeeea377b.tar.xz
hercules-60a426c0742b3e7d8c5b557c7578df6eeeea377b.zip
- Undid r16968: SVN Replaced with source:/trunk/src/@16966 (tid:74924).
[16969:16991/trunk/src/] will be re-committed in the next 24 hours. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16992 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mail.c')
-rw-r--r--src/map/mail.c226
1 files changed, 116 insertions, 110 deletions
diff --git a/src/map/mail.c b/src/map/mail.c
index ecd79f957..03b8227b5 100644
--- a/src/map/mail.c
+++ b/src/map/mail.c
@@ -16,164 +16,170 @@
void mail_clear(struct map_session_data *sd)
{
- sd->mail.nameid = 0;
- sd->mail.index = 0;
- sd->mail.amount = 0;
- sd->mail.zeny = 0;
+ sd->mail.nameid = 0;
+ sd->mail.index = 0;
+ sd->mail.amount = 0;
+ sd->mail.zeny = 0;
- return;
+ return;
}
int mail_removeitem(struct map_session_data *sd, short flag)
{
- nullpo_ret(sd);
-
- if (sd->mail.amount) {
- if (flag) // Item send
- pc_delitem(sd, sd->mail.index, sd->mail.amount, 1, 0, LOG_TYPE_MAIL);
- else
- clif_additem(sd, sd->mail.index, sd->mail.amount, 0);
- }
-
- sd->mail.nameid = 0;
- sd->mail.index = 0;
- sd->mail.amount = 0;
- return 1;
+ nullpo_ret(sd);
+
+ if( sd->mail.amount )
+ {
+ if (flag) // Item send
+ pc_delitem(sd, sd->mail.index, sd->mail.amount, 1, 0, LOG_TYPE_MAIL);
+ else
+ clif_additem(sd, sd->mail.index, sd->mail.amount, 0);
+ }
+
+ sd->mail.nameid = 0;
+ sd->mail.index = 0;
+ sd->mail.amount = 0;
+ return 1;
}
int mail_removezeny(struct map_session_data *sd, short flag)
{
- nullpo_ret(sd);
+ nullpo_ret(sd);
- if (flag && sd->mail.zeny > 0) {
- //Zeny send
- pc_payzeny(sd,sd->mail.zeny,LOG_TYPE_MAIL, NULL);
- }
- sd->mail.zeny = 0;
+ if (flag && sd->mail.zeny > 0)
+ { //Zeny send
+ pc_payzeny(sd,sd->mail.zeny,LOG_TYPE_MAIL, NULL);
+ }
+ sd->mail.zeny = 0;
- return 1;
+ return 1;
}
-unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount)
-{
+unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) {
+
+ if( pc_istrading(sd) )
+ return 1;
+
+ if( idx == 0 ) { // Zeny Transfer
+ if( amount < 0 || !pc_can_give_items(sd) )
+ return 1;
+
+ if( amount > sd->status.zeny )
+ amount = sd->status.zeny;
+
+ sd->mail.zeny = amount;
+ // clif_updatestatus(sd, SP_ZENY);
+ return 0;
+ } else { // Item Transfer
+ idx -= 2;
+ mail_removeitem(sd, 0);
+
+ if( idx < 0 || idx >= MAX_INVENTORY )
+ return 1;
+ if( amount < 0 || amount > sd->status.inventory[idx].amount )
+ return 1;
+ if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
+ !itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd)) )
+ return 1;
+
+ sd->mail.index = idx;
+ sd->mail.nameid = sd->status.inventory[idx].nameid;
+ sd->mail.amount = amount;
- if (pc_istrading(sd))
- return 1;
-
- if (idx == 0) { // Zeny Transfer
- if (amount < 0 || !pc_can_give_items(sd))
- return 1;
-
- if (amount > sd->status.zeny)
- amount = sd->status.zeny;
-
- sd->mail.zeny = amount;
- // clif_updatestatus(sd, SP_ZENY);
- return 0;
- } else { // Item Transfer
- idx -= 2;
- mail_removeitem(sd, 0);
-
- if (idx < 0 || idx >= MAX_INVENTORY)
- return 1;
- if (amount < 0 || amount > sd->status.inventory[idx].amount)
- return 1;
- if (!pc_can_give_items(sd) || sd->status.inventory[idx].expire_time ||
- !itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd)))
- return 1;
-
- sd->mail.index = idx;
- sd->mail.nameid = sd->status.inventory[idx].nameid;
- sd->mail.amount = amount;
-
- return 0;
- }
+ return 0;
+ }
}
bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg)
{
- int n;
+ int n;
- nullpo_retr(false,sd);
- nullpo_retr(false,msg);
+ nullpo_retr(false,sd);
+ nullpo_retr(false,msg);
- if (sd->mail.zeny < 0 || sd->mail.zeny > sd->status.zeny)
- return false;
+ if( sd->mail.zeny < 0 || sd->mail.zeny > sd->status.zeny )
+ return false;
- n = sd->mail.index;
- if (sd->mail.amount) {
- if (sd->status.inventory[n].nameid != sd->mail.nameid)
- return false;
+ n = sd->mail.index;
+ if( sd->mail.amount )
+ {
+ if( sd->status.inventory[n].nameid != sd->mail.nameid )
+ return false;
- if (sd->status.inventory[n].amount < sd->mail.amount)
- return false;
+ if( sd->status.inventory[n].amount < sd->mail.amount )
+ return false;
- if (sd->weight > sd->max_weight)
- return false;
+ if( sd->weight > sd->max_weight )
+ return false;
- memcpy(&msg->item, &sd->status.inventory[n], sizeof(struct item));
- msg->item.amount = sd->mail.amount;
- } else
- memset(&msg->item, 0x00, sizeof(struct item));
+ memcpy(&msg->item, &sd->status.inventory[n], sizeof(struct item));
+ msg->item.amount = sd->mail.amount;
+ }
+ else
+ memset(&msg->item, 0x00, sizeof(struct item));
- msg->zeny = sd->mail.zeny;
+ msg->zeny = sd->mail.zeny;
- // Removes the attachment from sender
- mail_removeitem(sd,1);
- mail_removezeny(sd,1);
+ // Removes the attachment from sender
+ mail_removeitem(sd,1);
+ mail_removezeny(sd,1);
- return true;
+ return true;
}
-void mail_getattachment(struct map_session_data *sd, int zeny, struct item *item)
+void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item)
{
- if (item->nameid > 0 && item->amount > 0) {
- pc_additem(sd, item, item->amount, LOG_TYPE_MAIL);
- clif_Mail_getattachment(sd->fd, 0);
- }
-
- if (zeny > 0) {
- //Zeny receive
- pc_getzeny(sd, zeny,LOG_TYPE_MAIL, NULL);
- }
+ if( item->nameid > 0 && item->amount > 0 )
+ {
+ pc_additem(sd, item, item->amount, LOG_TYPE_MAIL);
+ clif_Mail_getattachment(sd->fd, 0);
+ }
+
+ if( zeny > 0 )
+ { //Zeny receive
+ pc_getzeny(sd, zeny,LOG_TYPE_MAIL, NULL);
+ }
}
int mail_openmail(struct map_session_data *sd)
{
- nullpo_ret(sd);
+ nullpo_ret(sd);
- if (sd->state.storage_flag || sd->state.vending || sd->state.buyingstore || sd->state.trading)
- return 0;
+ if( sd->state.storage_flag || sd->state.vending || sd->state.buyingstore || sd->state.trading )
+ return 0;
- clif_Mail_window(sd->fd, 0);
+ clif_Mail_window(sd->fd, 0);
- return 1;
+ return 1;
}
void mail_deliveryfail(struct map_session_data *sd, struct mail_message *msg)
{
- nullpo_retv(sd);
- nullpo_retv(msg);
+ nullpo_retv(sd);
+ nullpo_retv(msg);
- if (msg->item.amount > 0) {
- // Item receive (due to failure)
- pc_additem(sd, &msg->item, msg->item.amount, LOG_TYPE_MAIL);
- }
+ if( msg->item.amount > 0 )
+ {
+ // Item receive (due to failure)
+ pc_additem(sd, &msg->item, msg->item.amount, LOG_TYPE_MAIL);
+ }
- if (msg->zeny > 0) {
- pc_getzeny(sd,msg->zeny,LOG_TYPE_MAIL, NULL); //Zeny receive (due to failure)
- }
+ if( msg->zeny > 0 )
+ {
+ pc_getzeny(sd,msg->zeny,LOG_TYPE_MAIL, NULL); //Zeny receive (due to failure)
+ }
- clif_Mail_send(sd->fd, true);
+ clif_Mail_send(sd->fd, true);
}
// This function only check if the mail operations are valid
bool mail_invalid_operation(struct map_session_data *sd)
{
- if (!map[sd->bl.m].flag.town && !pc_can_use_command(sd, "mail", COMMAND_ATCOMMAND)) {
- ShowWarning("clif_parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name);
- return true;
- }
+ if( !map[sd->bl.m].flag.town && !pc_can_use_command(sd, "mail", COMMAND_ATCOMMAND) )
+ {
+ ShowWarning("clif_parse_Mail: char '%s' trying to do invalid mail operations.\n", sd->status.name);
+ return true;
+ }
- return false;
+ return false;
}