- Important fix to Mail System allowing (by a low change) items duple.

- Added picklog to mail.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11721 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
zephyrus 2007-11-12 08:55:36 +00:00
parent b3c5cc4124
commit 0cf565292d
10 changed files with 80 additions and 91 deletions

View File

@ -8,6 +8,9 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
* The Forget-me-not status now behaves like Decrease AGI [ultramage]
- doesn't cancel Impressive Riff, Wind Walker, True Sight (bugreport:187)
- additionally, it doesn't cancel Cart Boost
* Fixed some bugs on mail system. [Zephyrus]
- Added the pc_candrop check (bugreport:305)
- Added picklog to mail.
2007/11/12
* Now when job changing to another class tree, status changes from skills
that belong to your previous class are cleared. [Skotlex]

View File

@ -15,6 +15,7 @@
// 1024 - (A) Log player created/deleted items (through @/# commands)
// 2048 - (R) Log items placed/retrieved from storage.
// 4096 - (G) Log items placed/retrieved from guild storage.
// 8192 - (E) Log mail system transactions.
// Example: Log trades+vending+script items+created items: 2+4+64+1024 = 1094
enable_logs: 1

View File

@ -0,0 +1 @@
ALTER TABLE `picklog` CHANGE `type` `type` ENUM( 'M', 'P', 'L', 'T', 'V', 'S', 'N', 'C', 'A', 'R', 'G', 'E' ) NOT NULL DEFAULT 'P';

View File

@ -384,11 +384,13 @@ static void mapif_parse_Mail_return(int fd)
*------------------------------------------*/
static void mapif_Mail_send(int fd, struct mail_message* msg)
{
WFIFOHEAD(fd,10);
int len = sizeof(struct mail_message) + 4;
WFIFOHEAD(fd,len);
WFIFOW(fd,0) = 0x384d;
WFIFOL(fd,2) = msg->send_id;
WFIFOL(fd,6) = msg->id;
WFIFOSET(fd,10);
WFIFOW(fd,2) = len;
memcpy(WFIFOP(fd,4), msg, sizeof(struct mail_message));
WFIFOSET(fd,len);
}
static void mapif_parse_Mail_send(int fd)
@ -419,37 +421,14 @@ static void mapif_parse_Mail_send(int fd)
}
}
Sql_FreeResult(sql_handle);
msg.status = MAIL_NEW;
if( msg.dest_id > 0 )
{
msg.status = MAIL_UNVERIFIED;
msg.id = mail_savemessage(&msg);
}
else
msg.id = 0;
mapif_Mail_send(fd, &msg);
}
static void mapif_parse_Mail_confirmation(int fd)
{
int mail_id = RFIFOL(fd,2);
bool fail = RFIFOB(fd,6);
if( fail )
{
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_INVALID, mail_id) )
Sql_ShowDebug(sql_handle);
}
else
{
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_NEW, mail_id) )
Sql_ShowDebug(sql_handle);
else
mapif_Mail_new(mail_id);
}
}
/*==========================================
* Packets From Map Server
*------------------------------------------*/
@ -463,7 +442,6 @@ int inter_mail_parse_frommap(int fd)
case 0x304b: mapif_parse_Mail_delete(fd); break;
case 0x304c: mapif_parse_Mail_return(fd); break;
case 0x304d: mapif_parse_Mail_send(fd); break;
case 0x304e: mapif_parse_Mail_confirmation(fd); break;
default:
return 0;
}

View File

@ -54,7 +54,7 @@ int inter_send_packet_length[] = {
-1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, // 3810-
35,-1,11,15, 34,29, 7,-1, 0, 0, 0, 0, 0, 0, 0, 0, // 3820-
10,-1,15, 0, 79,19, 7,-1, 0,-1,-1,-1, 14,67,186,-1, // 3830-
9, 9,-1, 0, 0, 0, 0, 0, -1,74,-1,11, 11,10, 0, 0, // 3840-
9, 9,-1, 0, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, // 3840-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3850-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3860-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3870-
@ -66,7 +66,7 @@ int inter_recv_packet_length[] = {
6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010-
-1, 6,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020-
-1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1, // 3030-
5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 7, 0, // 3040-
5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070-

View File

@ -240,7 +240,6 @@ struct mmo_charstatus {
};
enum mail_status {
MAIL_UNVERIFIED = -1,
MAIL_NEW,
MAIL_UNREAD,
MAIL_READ,

View File

@ -11650,8 +11650,8 @@ 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_getattach(sd, &msg) )
{
if( !mail_setattachment(sd, &msg) )
{ // Invalid Append condition
clif_Mail_send(sd->fd, 1); // fail
mail_removeitem(sd,0);
mail_removezeny(sd,0);

View File

@ -34,7 +34,7 @@ static const int packet_len_table[]={
-1, 7, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810
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,10, 0, 0, //0x3840
9, 9,-1,14, 0, 0, 0, 0, -1,74,-1,11, 11,-1, 0, 0, //0x3840
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,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -1560,19 +1560,9 @@ int intif_parse_Mail_getattach(int fd)
return 1;
}
if (zeny > 0)
{
sd->status.zeny += zeny;
clif_updatestatus(sd, SP_ZENY);
}
memcpy(&item, RFIFOP(fd,12), sizeof(struct item));
if (item.nameid > 0 && item.amount > 0)
{
pc_additem(sd, &item, item.amount);
clif_Mail_getattachment(sd->fd, 0);
}
mail_getattachment(sd, zeny, &item);
return 0;
}
/*------------------------------------------
@ -1695,33 +1685,43 @@ int intif_Mail_send(int account_id, struct mail_message *msg)
static void intif_parse_Mail_send(int fd)
{
struct map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
int mail_id = RFIFOL(fd,6);
bool fail = false;
struct mail_message msg;
struct map_session_data *sd;
bool fail;
if( mail_id == 0 )
fail = true;
else
if( RFIFOW(fd,2) - 4 != sizeof(struct mail_message) )
{
fail = !mail_checkattach(sd);
// Confirmation to CharServer
WFIFOHEAD(inter_fd,7);
WFIFOW(inter_fd,0) = 0x304e;
WFIFOL(inter_fd,2) = mail_id;
WFIFOB(inter_fd,6) = fail;
WFIFOSET(inter_fd,7);
if (battle_config.error_log)
ShowError("intif_parse_Mail_send: data size error %d %d\n", RFIFOW(fd,2) - 4, sizeof(struct mail_message));
return;
}
nullpo_retv(sd);
memcpy(&msg, RFIFOP(fd,4), sizeof(struct mail_message));
fail = (msg.id == 0);
if( (sd = map_charid2sd(msg.send_id)) )
{
if( fail )
{
pc_additem(sd, &msg.item, msg.item.amount);
if( msg.zeny > 0 )
{
sd->status.zeny += msg.zeny;
clif_updatestatus(sd, SP_ZENY);
}
}
clif_Mail_send(sd->fd, fail);
}
if( fail )
{ // Return items and zeny to owner
mail_removeitem(sd, 0);
mail_removezeny(sd, 0);
}
return;
clif_Mail_send(sd->fd, fail);
if( (sd = map_charid2sd(msg.dest_id)) )
{
sd->mail.inbox.changed = true;
clif_Mail_new(sd->fd, msg.id, msg.send_name, msg.title);
}
}
static void intif_parse_Mail_new(int fd)

View File

@ -9,6 +9,7 @@
#include "itemdb.h"
#include "clif.h"
#include "pc.h"
#include "log.h"
#include <time.h>
#include <string.h>
@ -26,7 +27,12 @@ int mail_removeitem(struct map_session_data *sd, short flag)
if( sd->mail.amount )
{
if (flag)
{ // Item send
if(log_config.enable_logs&0x2000)
log_pick_pc(sd, "E", sd->mail.nameid, -sd->mail.amount, &sd->status.inventory[sd->mail.index]);
pc_delitem(sd, sd->mail.index, sd->mail.amount, 1);
}
else
clif_additem(sd, sd->mail.index, sd->mail.amount, 0);
}
@ -72,7 +78,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount)
return 1;
if( amount < 0 || amount > sd->status.inventory[idx].amount )
return 1;
if( !itemdb_isdropable(&sd->status.inventory[idx], pc_isGM(sd)) )
if( !pc_candrop(sd, &sd->status.inventory[idx]) )
return 1;
sd->mail.index = idx;
@ -83,12 +89,12 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount)
}
}
bool mail_getattach(struct map_session_data *sd, struct mail_message *msg)
bool mail_setattachment(struct map_session_data *sd, struct mail_message *msg)
{
int n;
nullpo_retr(0,sd);
nullpo_retr(0,msg);
nullpo_retr(false,sd);
nullpo_retr(false,msg);
if( sd->mail.zeny < 0 || sd->mail.zeny > sd->status.zeny )
return false;
@ -110,31 +116,32 @@ bool mail_getattach(struct map_session_data *sd, struct mail_message *msg)
msg->zeny = sd->mail.zeny;
return true;
}
bool mail_checkattach(struct map_session_data *sd)
{
nullpo_retr(false,sd);
if( sd->mail.zeny > 0 && sd->status.zeny < sd->status.zeny )
return false;
if( sd->mail.amount > 0 )
{
if( sd->status.inventory[sd->mail.index].nameid != sd->mail.nameid )
return false;
if( sd->status.inventory[sd->mail.index].amount < sd->mail.amount )
return false;
}
// Removes the attachment from sender
mail_removeitem(sd,1);
mail_removezeny(sd,1);
return true;
}
void mail_getattachment(struct map_session_data* sd, int zeny, struct item* item)
{
if( zeny > 0 )
{
sd->status.zeny += zeny;
clif_updatestatus(sd, SP_ZENY);
}
if( item->nameid > 0 && item->amount > 0 )
{
pc_additem(sd, item, item->amount);
if(log_config.enable_logs&0x2000)
log_pick_pc(sd, "E", item->nameid, item->amount, item);
clif_Mail_getattachment(sd->fd, 0);
}
}
int mail_openmail(struct map_session_data *sd)
{
nullpo_retr(0,sd);

View File

@ -11,8 +11,8 @@ time_t mail_calctimes(void);
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_getattach(struct map_session_data *sd, struct mail_message *msg);
bool mail_checkattach(struct map_session_data *sd);
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);
#endif /* _MAIL_H_ */