summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-02-14 17:18:11 -0200
committershennetsind <ind@henn.et>2013-02-14 17:18:11 -0200
commit2bc85620e0b91aaaa29f929e618d5f6d6623b4f0 (patch)
tree3f828ba070367820df99d4e286dc2cc023b92cd9
parent810ba40b78087cc6aa7eb9ad3a3e46534393b9e8 (diff)
downloadhercules-2bc85620e0b91aaaa29f929e618d5f6d6623b4f0.tar.gz
hercules-2bc85620e0b91aaaa29f929e618d5f6d6623b4f0.tar.bz2
hercules-2bc85620e0b91aaaa29f929e618d5f6d6623b4f0.tar.xz
hercules-2bc85620e0b91aaaa29f929e618d5f6d6623b4f0.zip
Fixed Bug #5018
Skills granted through scripts are now permanent, until this date they were not relog persistent Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r--sql-files/main.sql3
-rw-r--r--sql-files/upgrades/2013-02-14--16-15.sql7
-rw-r--r--sql-files/upgrades/index.txt1
-rw-r--r--src/char/char.c26
-rw-r--r--src/map/pc.c17
5 files changed, 36 insertions, 18 deletions
diff --git a/sql-files/main.sql b/sql-files/main.sql
index d772cec98..fbdf40dde 100644
--- a/sql-files/main.sql
+++ b/sql-files/main.sql
@@ -618,6 +618,7 @@ CREATE TABLE IF NOT EXISTS `skill` (
`char_id` int(11) unsigned NOT NULL default '0',
`id` smallint(11) unsigned NOT NULL default '0',
`lv` tinyint(4) unsigned NOT NULL default '0',
+ `flag` TINYINT(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY (`char_id`,`id`)
) ENGINE=MyISAM;
@@ -641,6 +642,8 @@ CREATE TABLE IF NOT EXISTS `sql_updates` (
`ignored` enum('Yes','No') NOT NULL DEFAULT 'No'
) ENGINE=MyISAM;
+-- Existent updates to enter
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1360858500);
--
-- Table structure for table `sstatus`
diff --git a/sql-files/upgrades/2013-02-14--16-15.sql b/sql-files/upgrades/2013-02-14--16-15.sql
new file mode 100644
index 000000000..9afd034b1
--- /dev/null
+++ b/sql-files/upgrades/2013-02-14--16-15.sql
@@ -0,0 +1,7 @@
+#1360858500
+CREATE TABLE IF NOT EXISTS `sql_updates` (
+ `timestamp` int(11) unsigned NOT NULL,
+ `ignored` enum('Yes','No') NOT NULL DEFAULT 'No'
+) ENGINE=MyISAM;
+ALTER TABLE `skill` ADD COLUMN `flag` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1360858500); \ No newline at end of file
diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt
index e69de29bb..e0c49cbce 100644
--- a/sql-files/upgrades/index.txt
+++ b/sql-files/upgrades/index.txt
@@ -0,0 +1 @@
+2013-02-14--16-15.sql \ No newline at end of file
diff --git a/src/char/char.c b/src/char/char.c
index f3f93ab01..8be0134ba 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -595,19 +595,20 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
}
StringBuf_Clear(&buf);
- StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`) VALUES ", skill_db);
+ StringBuf_Printf(&buf, "INSERT INTO `%s`(`char_id`,`id`,`lv`,`flag`) VALUES ", skill_db);
//insert here.
- for( i = 0, count = 0; i < MAX_SKILL; ++i )
- {
- if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY )
- {
- if( p->skill[i].flag == SKILL_FLAG_PERMANENT && p->skill[i].lv == 0 )
+ for( i = 0, count = 0; i < MAX_SKILL; ++i ) {
+ if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY ) {
+
+ if( p->skill[i].lv == 0 && ( p->skill[i].flag == SKILL_FLAG_PERM_GRANTED || p->skill[i].flag == SKILL_FLAG_PERMANENT ) )
continue;
- if( p->skill[i].flag != SKILL_FLAG_PERMANENT && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 )
+ if( p->skill[i].flag != SKILL_FLAG_PERMANENT && p->skill[i].flag != SKILL_FLAG_PERM_GRANTED && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 )
continue;
if( count )
StringBuf_AppendStr(&buf, ",");
- StringBuf_Printf(&buf, "('%d','%d','%d')", char_id, p->skill[i].id, (p->skill[i].flag == SKILL_FLAG_PERMANENT ? p->skill[i].lv : p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0));
+ StringBuf_Printf(&buf, "('%d','%d','%d','%d')", char_id, p->skill[i].id,
+ ( (p->skill[i].flag == SKILL_FLAG_PERMANENT || p->skill[i].flag == SKILL_FLAG_PERM_GRANTED) ? p->skill[i].lv : p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0),
+ p->skill[i].flag == SKILL_FLAG_PERM_GRANTED ? p->skill[i].flag : 0);/* other flags do not need to be saved */
++count;
}
}
@@ -1274,13 +1275,16 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
//read skill
//`skill` (`char_id`, `id`, `lv`)
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `id`, `lv` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL)
+ if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL)
|| SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
|| SQL_ERROR == SqlStmt_Execute(stmt)
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id, 0, NULL, NULL)
- || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_USHORT, &tmp_skill.lv, 0, NULL, NULL) )
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_USHORT, &tmp_skill.lv, 0, NULL, NULL)
+ || SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_USHORT, &tmp_skill.flag, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- tmp_skill.flag = SKILL_FLAG_PERMANENT;
+
+ if( tmp_skill.flag != SKILL_FLAG_PERM_GRANTED )
+ tmp_skill.flag = SKILL_FLAG_PERMANENT;
for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
{
diff --git a/src/map/pc.c b/src/map/pc.c
index 0dd210394..1bc37040e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1253,7 +1253,7 @@ static int pc_calc_skillpoint(struct map_session_data* sd)
if(sd->status.skill[i].flag == SKILL_FLAG_PERMANENT)
skill_point += skill;
else
- if(sd->status.skill[i].flag >= SKILL_FLAG_REPLACED_LV_0)
+ if(sd->status.skill[i].flag == SKILL_FLAG_REPLACED_LV_0)
skill_point += (sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0);
}
}
@@ -1283,13 +1283,13 @@ int pc_calc_skilltree(struct map_session_data *sd)
for( i = 0; i < MAX_SKILL; i++ )
{
- if( sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED ) //Don't touch plagiarized skills
+ if( sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED ) //Don't touch these
sd->status.skill[i].id = 0; //First clear skills.
}
for( i = 0; i < MAX_SKILL; i++ )
{
- if( sd->status.skill[i].flag != SKILL_FLAG_PERMANENT && sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED )
+ if( sd->status.skill[i].flag != SKILL_FLAG_PERMANENT && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED && sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED )
{ // Restore original level of skills after deleting earned skills.
sd->status.skill[i].lv = (sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY) ? 0 : sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0;
sd->status.skill[i].flag = SKILL_FLAG_PERMANENT;
@@ -1509,7 +1509,7 @@ int pc_clean_skilltree(struct map_session_data *sd)
sd->status.skill[i].flag = 0;
}
else
- if (sd->status.skill[i].flag >= SKILL_FLAG_REPLACED_LV_0){
+ if (sd->status.skill[i].flag == SKILL_FLAG_REPLACED_LV_0){
sd->status.skill[i].lv = sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0;
sd->status.skill[i].flag = 0;
}
@@ -3442,7 +3442,7 @@ int pc_skill(TBL_PC* sd, int id, int level, int flag)
case 0: //Set skill data overwriting whatever was there before.
sd->status.skill[id].id = id;
sd->status.skill[id].lv = level;
- sd->status.skill[id].flag = SKILL_FLAG_PERMANENT;
+ sd->status.skill[id].flag = SKILL_FLAG_PERM_GRANTED;
if( level == 0 ) //Remove skill.
{
sd->status.skill[id].id = 0;
@@ -6056,7 +6056,7 @@ int pc_allskillup(struct map_session_data *sd)
nullpo_ret(sd);
for(i=0;i<MAX_SKILL;i++){
- if (sd->status.skill[i].flag != SKILL_FLAG_PERMANENT && sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED) {
+ if (sd->status.skill[i].flag != SKILL_FLAG_PERMANENT && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED && sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED) {
sd->status.skill[i].lv = (sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY) ? 0 : sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0;
sd->status.skill[i].flag = SKILL_FLAG_PERMANENT;
if (sd->status.skill[i].lv == 0)
@@ -6329,6 +6329,9 @@ int pc_resetskill(struct map_session_data* sd, int flag)
if( i == NV_BASIC && (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE )
continue;
+ if( sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED )
+ continue;
+
if( flag&4 && !skill_ischangesex(i) )
continue;
@@ -6344,7 +6347,7 @@ int pc_resetskill(struct map_session_data* sd, int flag)
if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT )
skill_point += lv;
else
- if( sd->status.skill[i].flag >= SKILL_FLAG_REPLACED_LV_0 )
+ if( sd->status.skill[i].flag == SKILL_FLAG_REPLACED_LV_0 )
skill_point += (sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0);
if( !(flag&2) )