summaryrefslogtreecommitdiff
path: root/src/char_sql
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-26 08:42:32 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-26 08:42:32 +0000
commit525e08137aa36cc2bbd8284f8b48de01bbb70b4f (patch)
tree9ef040444cbd22550778ccfca75ec1bc697142db /src/char_sql
parent9befe305370ddcc177ca36f1d4d6c295ddfb7533 (diff)
downloadhercules-525e08137aa36cc2bbd8284f8b48de01bbb70b4f.tar.gz
hercules-525e08137aa36cc2bbd8284f8b48de01bbb70b4f.tar.bz2
hercules-525e08137aa36cc2bbd8284f8b48de01bbb70b4f.tar.xz
hercules-525e08137aa36cc2bbd8284f8b48de01bbb70b4f.zip
* Removed confusing map_nick2sd_nocase(), let the charserver handle it
* Added correct packet for attachment retrieval failure when overweight * Fixed one more mistake in r11571 (Sql->SqlStmt) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11579 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char_sql')
-rw-r--r--src/char_sql/int_mail.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/char_sql/int_mail.c b/src/char_sql/int_mail.c
index bdf7653f1..528c1be11 100644
--- a/src/char_sql/int_mail.c
+++ b/src/char_sql/int_mail.c
@@ -128,10 +128,10 @@ static int mail_savemessage(struct mail_message* msg)
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, msg->body, strnlen(msg->body, MAIL_BODY_LENGTH))
|| SQL_SUCCESS != SqlStmt_Execute(stmt) )
{
- Sql_ShowDebug(sql_handle);
+ SqlStmt_ShowDebug(stmt);
j = 0;
} else
- j = (int)Sql_LastInsertId(sql_handle);
+ j = (int)SqlStmt_LastInsertId(stmt);
StringBuf_Destroy(&buf);
@@ -190,7 +190,8 @@ static bool mail_loadmessage(int char_id, int mail_id, struct mail_message* msg)
StringBuf_Destroy(&buf);
Sql_FreeResult(sql_handle);
- ShowDebug("Loaded message (had read flag %d)\n", msg->read);
+ // this thing converts the database value (0,1,2) into a boolean yes/no
+ //TODO: provide decent enum instead of using 'magic' values
if (msg->read == 1)
{
msg->read = 0;
@@ -374,7 +375,8 @@ static void mapif_Mail_send(int fd, struct mail_message* msg)
static void mapif_parse_Mail_send(int fd)
{
struct mail_message msg;
- int mail_id = 0, account_id = 0;
+ char esc_name[NAME_LENGTH*2+1];
+ int account_id = 0;
if(RFIFOW(fd,2) != 8 + sizeof(struct mail_message))
return;
@@ -383,32 +385,28 @@ static void mapif_parse_Mail_send(int fd)
account_id = RFIFOL(fd,4);
- if( !msg.dest_id )
+ // 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);
+ else
+ if ( SQL_SUCCESS == Sql_NextRow(sql_handle) )
{
- // Try to find the Dest Char by Name
- char esc_name[NAME_LENGTH*2+1];
-
- 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);
- else
- if ( SQL_SUCCESS == Sql_NextRow(sql_handle) )
- {
- char *data;
- Sql_GetData(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);
- msg.dest_id = atoi(data);
- }
+ char *data;
+ Sql_GetData(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);
+ msg.dest_id = atoi(data);
}
- Sql_FreeResult(sql_handle);
}
+ Sql_FreeResult(sql_handle);
if( msg.dest_id > 0 )
- mail_id = mail_savemessage(&msg);
+ msg.id = mail_savemessage(&msg);
+ else
+ msg.id = 0;
- msg.id = mail_id;
mapif_Mail_send(fd, &msg);
}