summaryrefslogtreecommitdiff
path: root/src/char/int_mail.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/int_mail.c')
-rw-r--r--src/char/int_mail.c288
1 files changed, 157 insertions, 131 deletions
diff --git a/src/char/int_mail.c b/src/char/int_mail.c
index 47d2cc1c5..c400ea01f 100644
--- a/src/char/int_mail.c
+++ b/src/char/int_mail.c
@@ -12,6 +12,7 @@
#include "char.h"
#include "inter.h"
+#include "mapif.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
#include "../common/showmsg.h"
@@ -20,7 +21,9 @@
#include "../common/strlib.h"
#include "../common/timer.h"
-static int mail_fromsql(int char_id, struct mail_data* md)
+struct inter_mail_interface inter_mail_s;
+
+static int inter_mail_fromsql(int char_id, struct mail_data* md)
{
int i, j;
struct mail_message *msg;
@@ -42,45 +45,45 @@ static int mail_fromsql(int char_id, struct mail_data* md)
StrBuf->Printf(&buf, " FROM `%s` WHERE `dest_id`='%d' AND `status` < 3 ORDER BY `id` LIMIT %d",
mail_db, char_id, MAIL_MAX_INBOX + 1);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
- for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == SQL->NextRow(sql_handle); ++i )
+ for (i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == SQL->NextRow(inter->sql_handle); ++i )
{
msg = &md->msg[i];
- SQL->GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
- SQL->GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
- SQL->GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); msg->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
item = &msg->item;
- SQL->GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
- SQL->GetData(sql_handle,11, &data, NULL); item->nameid = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); item->refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); item->identify = atoi(data);
- SQL->GetData(sql_handle,15, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); item->amount = (short)atoi(data);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); item->nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); item->refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); item->attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); item->identify = atoi(data);
+ SQL->GetData(inter->sql_handle,15, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
item->expire_time = 0;
item->bound = 0;
for (j = 0; j < MAX_SLOTS; j++)
{
- SQL->GetData(sql_handle, 16 + j, &data, NULL);
+ SQL->GetData(inter->sql_handle, 16 + j, &data, NULL);
item->card[j] = atoi(data);
}
}
- md->full = ( SQL->NumRows(sql_handle) > MAIL_MAX_INBOX );
+ md->full = ( SQL->NumRows(inter->sql_handle) > MAIL_MAX_INBOX );
md->amount = i;
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
md->unchecked = 0;
md->unread = 0;
@@ -89,8 +92,8 @@ static int mail_fromsql(int char_id, struct mail_data* md)
msg = &md->msg[i];
if( msg->status == MAIL_NEW )
{
- if ( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
- Sql_ShowDebug(sql_handle);
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
+ Sql_ShowDebug(inter->sql_handle);
msg->status = MAIL_UNREAD;
md->unchecked++;
@@ -105,7 +108,7 @@ static int mail_fromsql(int char_id, struct mail_data* md)
/// Stores a single message in the database.
/// Returns the message's ID if successful (or 0 if it fails).
-int mail_savemessage(struct mail_message* msg)
+int inter_mail_savemessage(struct mail_message* msg)
{
StringBuf buf;
SqlStmt* stmt;
@@ -123,7 +126,7 @@ int mail_savemessage(struct mail_message* msg)
StrBuf->AppendStr(&buf, ")");
// prepare and execute query
- stmt = SQL->StmtMalloc(sql_handle);
+ stmt = SQL->StmtMalloc(inter->sql_handle);
if( SQL_SUCCESS != SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 0, SQLDT_STRING, msg->send_name, strnlen(msg->send_name, NAME_LENGTH))
|| SQL_SUCCESS != SQL->StmtBindParam(stmt, 1, SQLDT_STRING, msg->dest_name, strnlen(msg->dest_name, NAME_LENGTH))
@@ -144,7 +147,7 @@ int mail_savemessage(struct mail_message* msg)
/// Retrieves a single message from the database.
/// Returns true if the operation succeeds (or false if it fails).
-static bool mail_loadmessage(int mail_id, struct mail_message* msg)
+static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg)
{
int j;
StringBuf buf;
@@ -157,11 +160,11 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
StrBuf->Printf(&buf, ",`card%d`", j);
StrBuf->Printf(&buf, " FROM `%s` WHERE `id` = '%d'", mail_db, mail_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf))
- || SQL_SUCCESS != SQL->NextRow(sql_handle) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf))
+ || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) )
{
- Sql_ShowDebug(sql_handle);
- SQL->FreeResult(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
+ SQL->FreeResult(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
}
@@ -169,76 +172,77 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
{
char* data;
- SQL->GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
- SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
- SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
- SQL->GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
- SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
- SQL->GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
- SQL->GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
- SQL->GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
- SQL->GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
- SQL->GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
- SQL->GetData(sql_handle,12, &data, NULL); msg->item.refine = atoi(data);
- SQL->GetData(sql_handle,13, &data, NULL); msg->item.attribute = atoi(data);
- SQL->GetData(sql_handle,14, &data, NULL); msg->item.identify = atoi(data);
- SQL->GetData(sql_handle,15, &data, NULL); msg->item.unique_id = strtoull(data, NULL, 10);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL); msg->id = atoi(data);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+ SQL->GetData(inter->sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
+ SQL->GetData(inter->sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+ SQL->GetData(inter->sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+ SQL->GetData(inter->sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
+ SQL->GetData(inter->sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
+ SQL->GetData(inter->sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
+ SQL->GetData(inter->sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data);
+ SQL->GetData(inter->sql_handle,11, &data, NULL); msg->item.nameid = atoi(data);
+ SQL->GetData(inter->sql_handle,12, &data, NULL); msg->item.refine = atoi(data);
+ SQL->GetData(inter->sql_handle,13, &data, NULL); msg->item.attribute = atoi(data);
+ SQL->GetData(inter->sql_handle,14, &data, NULL); msg->item.identify = atoi(data);
+ SQL->GetData(inter->sql_handle,15, &data, NULL); msg->item.unique_id = strtoull(data, NULL, 10);
msg->item.expire_time = 0;
msg->item.bound = 0;
for( j = 0; j < MAX_SLOTS; j++ )
{
- SQL->GetData(sql_handle,16 + j, &data, NULL);
+ SQL->GetData(inter->sql_handle,16 + j, &data, NULL);
msg->item.card[j] = atoi(data);
}
}
StrBuf->Destroy(&buf);
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
return true;
}
-/*==========================================
- * Client Inbox Request
- *------------------------------------------*/
-static void mapif_Mail_sendinbox(int fd, int char_id, unsigned char flag)
+void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md)
{
- struct mail_data md;
- memset(&md, 0, sizeof(md));
- mail_fromsql(char_id, &md);
-
//FIXME: dumping the whole structure like this is unsafe [ultramage]
- WFIFOHEAD(fd, sizeof(md) + 9);
+ WFIFOHEAD(fd, sizeof(struct mail_data) + 9);
WFIFOW(fd,0) = 0x3848;
- WFIFOW(fd,2) = sizeof(md) + 9;
+ WFIFOW(fd,2) = sizeof(struct mail_data) + 9;
WFIFOL(fd,4) = char_id;
WFIFOB(fd,8) = flag;
- memcpy(WFIFOP(fd,9),&md,sizeof(md));
+ memcpy(WFIFOP(fd,9),md,sizeof(struct mail_data));
WFIFOSET(fd,WFIFOW(fd,2));
}
-static void mapif_parse_Mail_requestinbox(int fd)
+/*==========================================
+ * Client Inbox Request
+ *------------------------------------------*/
+void mapif_parse_mail_requestinbox(int fd)
{
- mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6));
+ int char_id = RFIFOL(fd,2);
+ unsigned char flag = RFIFOB(fd,6);
+ struct mail_data md;
+ memset(&md, 0, sizeof(md));
+ inter_mail->fromsql(char_id, &md);
+ mapif->mail_sendinbox(fd, char_id, flag, &md);
}
/*==========================================
* Mark mail as 'Read'
*------------------------------------------*/
-static void mapif_parse_Mail_read(int fd)
+void mapif_parse_mail_read(int fd)
{
int mail_id = RFIFOL(fd,2);
- if( SQL_ERROR == SQL->Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
- Sql_ShowDebug(sql_handle);
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
+ Sql_ShowDebug(inter->sql_handle);
}
/*==========================================
* Client Attachment Request
*------------------------------------------*/
-static bool mail_DeleteAttach(int mail_id)
+static bool inter_mail_DeleteAttach(int mail_id)
{
StringBuf buf;
int i;
@@ -249,9 +253,9 @@ static bool mail_DeleteAttach(int mail_id)
StrBuf->Printf(&buf, ", `card%d` = '0'", i);
StrBuf->Printf(&buf, " WHERE `id` = '%d'", mail_id);
- if( SQL_ERROR == SQL->Query(sql_handle, StrBuf->Value(&buf)) )
+ if( SQL_ERROR == SQL->Query(inter->sql_handle, StrBuf->Value(&buf)) )
{
- Sql_ShowDebug(sql_handle);
+ Sql_ShowDebug(inter->sql_handle);
StrBuf->Destroy(&buf);
return false;
@@ -261,12 +265,23 @@ static bool mail_DeleteAttach(int mail_id)
return true;
}
-static void mapif_Mail_getattach(int fd, int char_id, int mail_id)
+void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg)
+{
+ WFIFOHEAD(fd, sizeof(struct item) + 12);
+ WFIFOW(fd,0) = 0x384a;
+ WFIFOW(fd,2) = sizeof(struct item) + 12;
+ WFIFOL(fd,4) = char_id;
+ WFIFOL(fd,8) = (msg->zeny > 0)?msg->zeny:0;
+ memcpy(WFIFOP(fd,12), &msg->item, sizeof(struct item));
+ WFIFOSET(fd,WFIFOW(fd,2));
+}
+
+void mapif_mail_getattach(int fd, int char_id, int mail_id)
{
struct mail_message msg;
memset(&msg, 0, sizeof(msg));
- if( !mail_loadmessage(mail_id, &msg) )
+ if( !inter_mail->loadmessage(mail_id, &msg) )
return;
if( msg.dest_id != char_id )
@@ -278,35 +293,22 @@ static void mapif_Mail_getattach(int fd, int char_id, int mail_id)
if( (msg.item.nameid < 1 || msg.item.amount < 1) && msg.zeny < 1 )
return; // No Attachment
- if( !mail_DeleteAttach(mail_id) )
+ if( !inter_mail->DeleteAttach(mail_id) )
return;
- WFIFOHEAD(fd, sizeof(struct item) + 12);
- WFIFOW(fd,0) = 0x384a;
- WFIFOW(fd,2) = sizeof(struct item) + 12;
- WFIFOL(fd,4) = char_id;
- WFIFOL(fd,8) = (msg.zeny > 0)?msg.zeny:0;
- memcpy(WFIFOP(fd,12), &msg.item, sizeof(struct item));
- WFIFOSET(fd,WFIFOW(fd,2));
+ mapif->mail_sendattach(fd, char_id, &msg);
}
-static void mapif_parse_Mail_getattach(int fd)
+void mapif_parse_mail_getattach(int fd)
{
- mapif_Mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6));
+ mapif->mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6));
}
/*==========================================
* Delete Mail
*------------------------------------------*/
-static void mapif_Mail_delete(int fd, int char_id, int mail_id)
+void mapif_mail_delete(int fd, int char_id, int mail_id, bool failed)
{
- bool failed = false;
- if ( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
- {
- Sql_ShowDebug(sql_handle);
- failed = true;
- }
-
WFIFOHEAD(fd,11);
WFIFOW(fd,0) = 0x384b;
WFIFOL(fd,2) = char_id;
@@ -315,15 +317,23 @@ static void mapif_Mail_delete(int fd, int char_id, int mail_id)
WFIFOSET(fd,11);
}
-static void mapif_parse_Mail_delete(int fd)
+void mapif_parse_mail_delete(int fd)
{
- mapif_Mail_delete(fd, RFIFOL(fd,2), RFIFOL(fd,6));
+ int char_id = RFIFOL(fd,2);
+ int mail_id = RFIFOL(fd,6);
+ bool failed = false;
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
+ {
+ Sql_ShowDebug(inter->sql_handle);
+ failed = true;
+ }
+ mapif->mail_delete(fd, char_id, mail_id, failed);
}
/*==========================================
* Report New Mail to Map Server
*------------------------------------------*/
-void mapif_Mail_new(struct mail_message *msg)
+void mapif_mail_new(struct mail_message *msg)
{
unsigned char buf[74];
@@ -335,23 +345,35 @@ void mapif_Mail_new(struct mail_message *msg)
WBUFL(buf,6) = msg->id;
memcpy(WBUFP(buf,10), msg->send_name, NAME_LENGTH);
memcpy(WBUFP(buf,34), msg->title, MAIL_TITLE_LENGTH);
- mapif_sendall(buf, 74);
+ mapif->sendall(buf, 74);
}
/*==========================================
* Return Mail
*------------------------------------------*/
-static void mapif_Mail_return(int fd, int char_id, int mail_id)
+void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail)
{
+ WFIFOHEAD(fd,11);
+ WFIFOW(fd,0) = 0x384c;
+ WFIFOL(fd,2) = char_id;
+ WFIFOL(fd,6) = mail_id;
+ WFIFOB(fd,10) = (new_mail == 0);
+ WFIFOSET(fd,11);
+}
+
+void mapif_parse_mail_return(int fd)
+{
+ int char_id = RFIFOL(fd,2);
+ int mail_id = RFIFOL(fd,6);
struct mail_message msg;
int new_mail = 0;
- if( mail_loadmessage(mail_id, &msg) )
+ if( inter_mail->loadmessage(mail_id, &msg) )
{
if( msg.dest_id != char_id)
return;
- else if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
- Sql_ShowDebug(sql_handle);
+ else if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
+ Sql_ShowDebug(inter->sql_handle);
else
{
char temp_[MAIL_TITLE_LENGTH];
@@ -369,28 +391,18 @@ static void mapif_Mail_return(int fd, int char_id, int mail_id)
msg.status = MAIL_NEW;
msg.timestamp = time(NULL);
- new_mail = mail_savemessage(&msg);
- mapif_Mail_new(&msg);
+ new_mail = inter_mail->savemessage(&msg);
+ mapif->mail_new(&msg);
}
}
- WFIFOHEAD(fd,11);
- WFIFOW(fd,0) = 0x384c;
- WFIFOL(fd,2) = char_id;
- WFIFOL(fd,6) = mail_id;
- WFIFOB(fd,10) = (new_mail == 0);
- WFIFOSET(fd,11);
-}
-
-static void mapif_parse_Mail_return(int fd)
-{
- mapif_Mail_return(fd, RFIFOL(fd,2), RFIFOL(fd,6));
+ mapif->mail_return(fd, char_id, mail_id, new_mail);
}
/*==========================================
* Send Mail
*------------------------------------------*/
-static void mapif_Mail_send(int fd, struct mail_message* msg)
+void mapif_mail_send(int fd, struct mail_message* msg)
{
int len = sizeof(struct mail_message) + 4;
@@ -401,7 +413,7 @@ static void mapif_Mail_send(int fd, struct mail_message* msg)
WFIFOSET(fd,len);
}
-static void mapif_parse_Mail_send(int fd)
+void mapif_parse_mail_send(int fd)
{
struct mail_message msg;
char esc_name[NAME_LENGTH*2+1];
@@ -414,31 +426,31 @@ static void mapif_parse_Mail_send(int fd)
memcpy(&msg, RFIFOP(fd,8), sizeof(struct mail_message));
// 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'", char_db, esc_name) )
- Sql_ShowDebug(sql_handle);
+ SQL->EscapeStringLen(inter->sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
+ if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
+ Sql_ShowDebug(inter->sql_handle);
else
- if ( SQL_SUCCESS == SQL->NextRow(sql_handle) )
+ if ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) )
{
char *data;
- SQL->GetData(sql_handle, 0, &data, NULL);
+ SQL->GetData(inter->sql_handle, 0, &data, NULL);
if (atoi(data) != account_id)
{ // Cannot send mail to char in the same account
- SQL->GetData(sql_handle, 1, &data, NULL);
+ SQL->GetData(inter->sql_handle, 1, &data, NULL);
msg.dest_id = atoi(data);
}
}
- SQL->FreeResult(sql_handle);
+ SQL->FreeResult(inter->sql_handle);
msg.status = MAIL_NEW;
if( msg.dest_id > 0 )
- msg.id = mail_savemessage(&msg);
+ msg.id = inter_mail->savemessage(&msg);
- mapif_Mail_send(fd, &msg); // notify sender
- mapif_Mail_new(&msg); // notify recipient
+ mapif->mail_send(fd, &msg); // notify sender
+ mapif->mail_new(&msg); // notify recipient
}
-void mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item)
+void inter_mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item)
{
struct mail_message msg;
memset(&msg, 0, sizeof(struct mail_message));
@@ -455,8 +467,8 @@ void mail_sendmail(int send_id, const char* send_name, int dest_id, const char*
msg.timestamp = time(NULL);
- mail_savemessage(&msg);
- mapif_Mail_new(&msg);
+ inter_mail->savemessage(&msg);
+ mapif->mail_new(&msg);
}
/*==========================================
@@ -466,12 +478,12 @@ int inter_mail_parse_frommap(int fd)
{
switch(RFIFOW(fd,0))
{
- case 0x3048: mapif_parse_Mail_requestinbox(fd); break;
- case 0x3049: mapif_parse_Mail_read(fd); break;
- case 0x304a: mapif_parse_Mail_getattach(fd); break;
- 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 0x3048: mapif->parse_mail_requestinbox(fd); break;
+ case 0x3049: mapif->parse_mail_read(fd); break;
+ case 0x304a: mapif->parse_mail_getattach(fd); break;
+ case 0x304b: mapif->parse_mail_delete(fd); break;
+ case 0x304c: mapif->parse_mail_return(fd); break;
+ case 0x304d: mapif->parse_mail_send(fd); break;
default:
return 0;
}
@@ -487,3 +499,17 @@ void inter_mail_sql_final(void)
{
return;
}
+
+void inter_mail_defaults(void)
+{
+ inter_mail = &inter_mail_s;
+
+ inter_mail->savemessage = inter_mail_savemessage;
+ inter_mail->DeleteAttach = inter_mail_DeleteAttach;
+ inter_mail->sendmail = inter_mail_sendmail;
+ inter_mail->parse_frommap = inter_mail_parse_frommap;
+ inter_mail->sql_init = inter_mail_sql_init;
+ inter_mail->sql_final = inter_mail_sql_final;
+ inter_mail->fromsql = inter_mail_fromsql;
+ inter_mail->loadmessage = inter_mail_loadmessage;
+}