summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-03-25 20:23:39 -0300
committerpanikon <panikon@zoho.com>2014-03-25 20:23:39 -0300
commit4b1cc23085b858364a332bdf03d634656778b1e6 (patch)
tree3928d9a1852ea0a49b6d6826e6a4f2730067b6ed /src
parent70a33d30013ada46b208506ac4b5a0861f5d6abb (diff)
downloadhercules-4b1cc23085b858364a332bdf03d634656778b1e6.tar.gz
hercules-4b1cc23085b858364a332bdf03d634656778b1e6.tar.bz2
hercules-4b1cc23085b858364a332bdf03d634656778b1e6.tar.xz
hercules-4b1cc23085b858364a332bdf03d634656778b1e6.zip
Added new return values to make_new_char_sql
Added char_id to charlog Corrected RE check in skill_magic_reflect (see commit c9310f3)
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c75
-rw-r--r--src/map/skill.c6
2 files changed, 50 insertions, 31 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 0769067fd..d460e4c85 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1509,9 +1509,10 @@ int rename_char_sql(struct char_session_data *sd, int char_id)
// log change
if( log_char )
{
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
- "VALUES (NOW(), '%s', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')",
- charlog_db, "change char name", sd->account_id, char_dat.slot, esc_name) )
+ if( SQL_ERROR == SQL->Query(sql_handle,
+ "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
+ "VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '0', '0', '0', '0', '0', '0', '0', '0')",
+ charlog_db, "change char name", sd->account_id, char_dat.char_id, char_dat.slot, esc_name) )
Sql_ShowDebug(sql_handle);
}
@@ -1550,7 +1551,7 @@ int check_char_name(char * name, char * esc_name)
{ // letters/symbols in char_name_letters are forbidden
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
if( strchr(char_name_letters, name[i]) != NULL )
- return -2;
+ return -5;
}
if( name_ignoring_case ) {
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT 1 FROM `%s` WHERE BINARY `name` = '%s' LIMIT 1", char_db, esc_name) ) {
@@ -1569,9 +1570,16 @@ int check_char_name(char * name, char * esc_name)
return 0;
}
-//-----------------------------------
-// Function to create a new character
-//-----------------------------------
+/**
+ * Creates a new character
+ * Return values:
+ * -1: 'Charname already exists'
+ * -2: 'Char creation denied'/ Unknown error
+ * -3: 'You are underaged'
+ * -4: 'You are not elegible to open the Character Slot.'
+ * -5: 'Symbols in Character Names are forbidden'
+ * char_id: Success
+ **/
#if PACKETVER >= 20120307
int make_new_char_sql(struct char_session_data* sd, char* name_, int slot, int hair_color, int hair_style) {
int str = 1, agi = 1, vit = 1, int_ = 1, dex = 1, luk = 1;
@@ -1610,13 +1618,6 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
if( sd->found_char[slot] != -1 )
return -2; /* character account limit exceeded */
- // validation success, log result
- if (log_char) {
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
- "VALUES (NOW(), '%s', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
- charlog_db, "make new char", sd->account_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) )
- Sql_ShowDebug(sql_handle);
- }
#if PACKETVER >= 20120307
//Insert the new char entry to the database
if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`account_id`, `char_num`, `name`, `zeny`, `status_point`,`str`, `agi`, `vit`, `int`, `dex`, `luk`, `max_hp`, `hp`,"
@@ -1645,6 +1646,17 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
//Retrieve the newly auto-generated char id
char_id = (int)SQL->LastInsertId(sql_handle);
+ if( !char_id )
+ return -2;
+
+ // Validation success, log result
+ if (log_char) {
+ if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s` (`time`, `char_msg`,`account_id`,`char_id`,`char_num`,`name`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`hair`,`hair_color`)"
+ "VALUES (NOW(), '%s', '%d', '%d', '%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
+ charlog_db, "make new char", sd->account_id, char_id, slot, esc_name, str, agi, vit, int_, dex, luk, hair_style, hair_color) )
+ Sql_ShowDebug(sql_handle);
+ }
+
//Give the char the default items
for (k = 0; k < ARRAYLENGTH(start_items) && start_items[k] != 0; k += 3) {
// FIXME: How to define if an item is stackable without having to lookup itemdb? [panikon]
@@ -1835,15 +1847,16 @@ int delete_char_sql(int char_id)
Sql_ShowDebug(sql_handle);
#endif
- if (log_char) {
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`char_msg`,`name`) VALUES (NOW(), '%d', '%d', 'Deleted char (CID %d)', '%s')",
- charlog_db, account_id, 0, char_id, esc_name) )
- Sql_ShowDebug(sql_handle);
- }
-
/* delete character */
if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", char_db, char_id) )
Sql_ShowDebug(sql_handle);
+ else if( log_char ) {
+ if( SQL_ERROR == SQL->Query(sql_handle,
+ "INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `char_msg`, `name`)"
+ " VALUES (NOW(), '%d', '%d', '%d', 'Deleted character', '%s')",
+ charlog_db, account_id, char_id, 0, esc_name) )
+ Sql_ShowDebug(sql_handle);
+ }
/* No need as we used inter_guild_leave [Skotlex]
// Also delete info from guildtables.
@@ -4311,10 +4324,11 @@ int parse_char(int fd)
if (log_char) {
char esc_name[NAME_LENGTH*2+1];
-
+ // FIXME: Why are we re-escaping the name if it was already escaped in rename/make_new_char? [Panikon]
SQL->EscapeStringLen(sql_handle, esc_name, char_dat.name, strnlen(char_dat.name, NAME_LENGTH));
- if( SQL_ERROR == SQL->Query(sql_handle, "INSERT INTO `%s`(`time`, `account_id`,`char_num`,`name`) VALUES (NOW(), '%d', '%d', '%s')",
- charlog_db, sd->account_id, slot, esc_name) )
+ if( SQL_ERROR == SQL->Query(sql_handle,
+ "INSERT INTO `%s`(`time`, `account_id`, `char_id`, `char_num`, `name`) VALUES (NOW(), '%d', '%d', '%d', '%s')",
+ charlog_db, sd->account_id, cd->char_id, slot, esc_name) )
Sql_ShowDebug(sql_handle);
}
ShowInfo("Selected char: (Account %d: %d - %s)\n", sd->account_id, slot, char_dat.name);
@@ -4429,7 +4443,6 @@ int parse_char(int fd)
result = make_new_char_sql(sd, (char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27),RFIFOB(fd,28),RFIFOB(fd,29),RFIFOB(fd,30),RFIFOB(fd,31),RFIFOB(fd,32),RFIFOW(fd,33),RFIFOW(fd,35));
#endif
- //'Charname already exists' (-1), 'Char creation denied' (-2) and 'You are underaged' (-3)
if (result < 0) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x6e;
@@ -4438,10 +4451,16 @@ int parse_char(int fd)
/* 0x03 = You are not elegible to open the Character Slot. */
/* 0x0B = This service is only available for premium users. */
switch (result) {
- case -1: WFIFOB(fd,2) = 0x00; break;
- case -2: WFIFOB(fd,2) = 0xFF; break;
- case -3: WFIFOB(fd,2) = 0x01; break;
- case -4: WFIFOB(fd,2) = 0x03; break;
+ case -1: WFIFOB(fd,2) = 0x00; break; // 'Charname already exists'
+ case -2: WFIFOB(fd,2) = 0xFF; break; // 'Char creation denied'
+ case -3: WFIFOB(fd,2) = 0x01; break; // 'You are underaged'
+ case -4: WFIFOB(fd,2) = 0x03; break; // 'You are not elegible to open the Character Slot.'
+ case -5: WFIFOB(fd,2) = 0x02; break; // 'Symbols in Character Names are forbidden'
+
+ default:
+ ShowWarning("parse_char: Unknown result received from make_new_char_sql!\n");
+ WFIFOB(fd,2) = 0xFF;
+ break;
}
WFIFOSET(fd,3);
} else {
diff --git a/src/map/skill.c b/src/map/skill.c
index 0ed6f7780..612b205e9 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -2201,12 +2201,12 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr
**/
#if MAGIC_REFLECTION_TYPE
- #if defined(DISABLE_RENEWAL)
+ #ifdef RENEWAL
+ if( dmg.dmg_lv != ATK_MISS ) //Wiz SL cancelled and consumed fragment
+ #else
// issue:6415 in pre-renewal Kaite reflected the entire damage received
// regardless of caster's equipament (Aegis 11.1)
if( dmg.dmg_lv != ATK_MISS && type == 1 ) //Wiz SL cancelled and consumed fragment
- #else
- if( dmg.dmg_lv != ATK_MISS ) //Wiz SL cancelled and consumed fragment
#endif
{
short s_ele = skill->get_ele(skill_id, skill_lv);