Added script command mail (#3043)

This commit is contained in:
Lemongrass3110
2018-04-12 00:46:01 +02:00
committed by GitHub
parent cc63bb594f
commit 5b13dc7009
3 changed files with 340 additions and 6 deletions

View File

@@ -484,7 +484,8 @@ void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
else if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_db, mail_id)
|| SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_attachment_db, mail_id) )
Sql_ShowDebug(sql_handle);
else
// If it was not sent by the server, since we do not want to return mails to the server
else if( msg.send_id != 0 )
{
char temp_[MAIL_TITLE_LENGTH];
@@ -543,20 +544,38 @@ void mapif_parse_Mail_send(int fd)
{
struct mail_message msg;
char esc_name[NAME_LENGTH*2+1];
char *data;
size_t len;
if(RFIFOW(fd,2) != 8 + sizeof(struct mail_message))
return;
memcpy(&msg, RFIFOP(fd,8), sizeof(struct mail_message));
if( msg.dest_id != 0 ){
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`, `name` FROM `%s` WHERE `char_id` = '%u'", schema_config.char_db, msg.dest_id) ){
Sql_ShowDebug(sql_handle);
return;
}
msg.dest_id = 0;
msg.dest_name[0] = '\0';
if( SQL_SUCCESS == Sql_NextRow(sql_handle) ){
Sql_GetData(sql_handle, 0, &data, NULL);
msg.dest_id = atoi(data);
Sql_GetData(sql_handle, 1, &data, &len);
safestrncpy(msg.dest_name, data, NAME_LENGTH);
}
Sql_FreeResult(sql_handle);
}
// Try to find the Dest Char by Name
Sql_EscapeStringLen(sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", schema_config.char_db, esc_name) )
if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", schema_config.char_db, esc_name) ){
Sql_ShowDebug(sql_handle);
else
if ( SQL_SUCCESS == Sql_NextRow(sql_handle) )
{
char *data;
}else if ( SQL_SUCCESS == Sql_NextRow(sql_handle) ){
#if PACKETVER < 20150513
uint32 account_id = RFIFOL(fd,4);