|
@@ -1,22 +1,26 @@
|
|
|
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
|
|
// For more information, see LICENCE in the main folder
|
|
|
|
|
|
+#include "int_mail.hpp"
|
|
|
+
|
|
|
+#include <stdlib.h>
|
|
|
+#include <string.h>
|
|
|
+
|
|
|
#include "../common/mmo.h"
|
|
|
#include "../common/showmsg.h"
|
|
|
#include "../common/socket.h"
|
|
|
#include "../common/strlib.h"
|
|
|
#include "../common/sql.h"
|
|
|
-#include "char.h"
|
|
|
-#include "char_mapif.h"
|
|
|
-#include "inter.h"
|
|
|
|
|
|
-#include <stdlib.h>
|
|
|
+#include "char.hpp"
|
|
|
+#include "char_mapif.hpp"
|
|
|
+#include "inter.hpp"
|
|
|
|
|
|
-static bool mail_loadmessage(int mail_id, struct mail_message* msg);
|
|
|
-static void mapif_Mail_return(int fd, uint32 char_id, int mail_id);
|
|
|
-static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted);
|
|
|
+bool mail_loadmessage(int mail_id, struct mail_message* msg);
|
|
|
+void mapif_Mail_return(int fd, uint32 char_id, int mail_id);
|
|
|
+void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted);
|
|
|
|
|
|
-static int mail_fromsql(uint32 char_id, struct mail_data* md)
|
|
|
+int mail_fromsql(uint32 char_id, struct mail_data* md)
|
|
|
{
|
|
|
int i;
|
|
|
char *data;
|
|
@@ -123,7 +127,7 @@ int mail_savemessage(struct mail_message* msg)
|
|
|
found = true;
|
|
|
}
|
|
|
|
|
|
- StringBuf_Printf(&buf, "('%"PRIu64"', '%hu', '%d', '%hu', '%d', '%d', '%d', '%"PRIu64"', '%d'", (uint64)msg->id, i, msg->item[i].amount, msg->item[i].nameid, msg->item[i].refine, msg->item[i].attribute, msg->item[i].identify, msg->item[i].unique_id, msg->item[i].bound);
|
|
|
+ StringBuf_Printf(&buf, "('%" PRIu64 "', '%hu', '%d', '%hu', '%d', '%d', '%d', '%" PRIu64 "', '%d'", (uint64)msg->id, i, msg->item[i].amount, msg->item[i].nameid, msg->item[i].refine, msg->item[i].attribute, msg->item[i].identify, msg->item[i].unique_id, msg->item[i].bound);
|
|
|
for (j = 0; j < MAX_SLOTS; j++)
|
|
|
StringBuf_Printf(&buf, ", '%hu'", msg->item[i].card[j]);
|
|
|
for (j = 0; j < MAX_ITEM_RDM_OPT; ++j) {
|
|
@@ -145,7 +149,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)
|
|
|
+bool mail_loadmessage(int mail_id, struct mail_message* msg)
|
|
|
{
|
|
|
int i, j;
|
|
|
StringBuf buf;
|
|
@@ -167,7 +171,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
|
|
|
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->type = atoi(data);
|
|
|
+ Sql_GetData(sql_handle,10, &data, NULL); msg->type = (mail_inbox_type)atoi(data);
|
|
|
|
|
|
if( msg->type == MAIL_INBOX_NORMAL && charserv_config.mail_return_days > 0 ){
|
|
|
msg->scheduled_deletion = msg->timestamp + charserv_config.mail_return_days * 24 * 60 * 60;
|
|
@@ -230,7 +234,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-static int mail_timer_sub( int limit, enum mail_inbox_type type ){
|
|
|
+int mail_timer_sub( int limit, enum mail_inbox_type type ){
|
|
|
struct{
|
|
|
int mail_id;
|
|
|
int char_id;
|
|
@@ -300,7 +304,7 @@ int mail_delete_timer( int tid, unsigned int tick, int id, intptr_t data ){
|
|
|
/*==========================================
|
|
|
* Client Inbox Request
|
|
|
*------------------------------------------*/
|
|
|
-static void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag, enum mail_inbox_type type)
|
|
|
+void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag, enum mail_inbox_type type)
|
|
|
{
|
|
|
struct mail_data md;
|
|
|
mail_fromsql(char_id, &md);
|
|
@@ -316,15 +320,15 @@ static void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag, enu
|
|
|
WFIFOSET(fd,WFIFOW(fd,2));
|
|
|
}
|
|
|
|
|
|
-static void mapif_parse_Mail_requestinbox(int fd)
|
|
|
+void mapif_parse_Mail_requestinbox(int fd)
|
|
|
{
|
|
|
- mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6), RFIFOB(fd,7));
|
|
|
+ mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6), (mail_inbox_type)RFIFOB(fd,7));
|
|
|
}
|
|
|
|
|
|
/*==========================================
|
|
|
* 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'", schema_config.mail_db, MAIL_READ, mail_id) )
|
|
@@ -334,7 +338,7 @@ static void mapif_parse_Mail_read(int fd)
|
|
|
/*==========================================
|
|
|
* Client Attachment Request
|
|
|
*------------------------------------------*/
|
|
|
-static bool mail_DeleteAttach(int mail_id){
|
|
|
+bool mail_DeleteAttach(int mail_id){
|
|
|
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_attachment_db, mail_id ) ){
|
|
|
Sql_ShowDebug(sql_handle);
|
|
|
return false;
|
|
@@ -343,7 +347,7 @@ static bool mail_DeleteAttach(int mail_id){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-static void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id, int type)
|
|
|
+void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id, int type)
|
|
|
{
|
|
|
struct mail_message msg;
|
|
|
|
|
@@ -407,7 +411,7 @@ static void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id, int type)
|
|
|
WFIFOSET(fd,WFIFOW(fd,2));
|
|
|
}
|
|
|
|
|
|
-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),RFIFOB(fd,10));
|
|
|
}
|
|
@@ -415,7 +419,7 @@ static void mapif_parse_Mail_getattach(int fd)
|
|
|
/*==========================================
|
|
|
* Delete Mail
|
|
|
*------------------------------------------*/
|
|
|
-static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
|
|
|
+void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
|
|
|
{
|
|
|
bool failed = false;
|
|
|
|
|
@@ -441,7 +445,7 @@ static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
|
|
|
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), false);
|
|
|
}
|
|
@@ -468,7 +472,7 @@ void mapif_Mail_new(struct mail_message *msg)
|
|
|
/*==========================================
|
|
|
* Return Mail
|
|
|
*------------------------------------------*/
|
|
|
-static void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
|
|
|
+void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
|
|
|
{
|
|
|
struct mail_message msg;
|
|
|
int new_mail = 0;
|
|
@@ -516,7 +520,7 @@ static void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
|
|
|
WFIFOSET(fd,11);
|
|
|
}
|
|
|
|
|
|
-static void mapif_parse_Mail_return(int fd)
|
|
|
+void mapif_parse_Mail_return(int fd)
|
|
|
{
|
|
|
mapif_Mail_return(fd, RFIFOL(fd,2), RFIFOL(fd,6));
|
|
|
}
|
|
@@ -524,7 +528,7 @@ static void mapif_parse_Mail_return(int fd)
|
|
|
/*==========================================
|
|
|
* 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;
|
|
|
|
|
@@ -535,7 +539,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];
|
|
@@ -609,7 +613,7 @@ bool mail_sendmail(int send_id, const char* send_name, int dest_id, const char*
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-static void mapif_Mail_receiver_send( int fd, int requesting_char_id, int char_id, int class_, int base_level, const char* name ){
|
|
|
+void mapif_Mail_receiver_send( int fd, int requesting_char_id, int char_id, int class_, int base_level, const char* name ){
|
|
|
WFIFOHEAD(fd,38);
|
|
|
WFIFOW(fd,0) = 0x384e;
|
|
|
WFIFOL(fd,2) = requesting_char_id;
|
|
@@ -620,7 +624,7 @@ static void mapif_Mail_receiver_send( int fd, int requesting_char_id, int char_i
|
|
|
WFIFOSET(fd,38);
|
|
|
}
|
|
|
|
|
|
-static void mapif_parse_Mail_receiver_check( int fd ){
|
|
|
+void mapif_parse_Mail_receiver_check( int fd ){
|
|
|
char name[NAME_LENGTH], esc_name[NAME_LENGTH * 2 + 1];
|
|
|
uint32 char_id = 0;
|
|
|
uint16 class_ = 0, base_level = 0;
|