diff options
-rw-r--r-- | sql-files/main.sql | 2 | ||||
-rw-r--r-- | sql-files/upgrades/2014-03-25--23-57.sql | 3 | ||||
-rw-r--r-- | src/char/char.c | 75 | ||||
-rw-r--r-- | src/map/skill.c | 6 |
4 files changed, 55 insertions, 31 deletions
diff --git a/sql-files/main.sql b/sql-files/main.sql index 654eee9f0..49d35a287 100644 --- a/sql-files/main.sql +++ b/sql-files/main.sql @@ -127,6 +127,7 @@ CREATE TABLE IF NOT EXISTS `charlog` ( `time` datetime NOT NULL default '0000-00-00 00:00:00', `char_msg` varchar(255) NOT NULL default 'char select', `account_id` int(11) NOT NULL default '0', + `char_id` int(11) unsigned NOT NULL default '0', `char_num` tinyint(4) NOT NULL default '0', `name` varchar(23) NOT NULL default '', `str` int(11) unsigned NOT NULL default '0', @@ -663,6 +664,7 @@ INSERT INTO `sql_updates` (`timestamp`) VALUES (1387844126); -- 2013-12-24--00-1 INSERT INTO `sql_updates` (`timestamp`) VALUES (1388854043); -- 2014-01-04--16-47.sql INSERT INTO `sql_updates` (`timestamp`) VALUES (1389028967); -- 2014-01-06--17-22.sql INSERT INTO `sql_updates` (`timestamp`) VALUES (1392832626); -- 2014-02-19--17-57.sql +INSERT INTO `sql_updates` (`timestamp`) VALUES (1395789302); -- 2014-03-25--23-57.sql -- -- Table structure for table `sstatus` diff --git a/sql-files/upgrades/2014-03-25--23-57.sql b/sql-files/upgrades/2014-03-25--23-57.sql new file mode 100644 index 000000000..f5c3aad00 --- /dev/null +++ b/sql-files/upgrades/2014-03-25--23-57.sql @@ -0,0 +1,3 @@ +#1395789302 +ALTER TABLE `charlog` ADD COLUMN `char_id` int(11) unsigned NOT NULL default '0' AFTER `account_id`; +INSERT INTO `sql_updates` (`timestamp`) VALUES (1395789302); 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); |