A Project for Chronicle 4 based on L2JServer.


    Error Enchant Skills when Relogin !!

    Share

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 25th July 2014, 10:04

    I have the following problem:

    my server is acumulative subclass, when enchant skill, which is not of this subclass in which the character is deleted when relogin.
    Code:

    For example:

    Character with subclass of Phantom summoner - Necromancer - Spellsinger

    Enchant --> Hydro Blast +4 and Vampiric Claw +4.

    when relogin --> Hydro Blast +4 but Vampiric Claw +0.


    Character with subclass of Phantom summoner - Spellsinger - Necromancerr

    Enchant --> Hydro Blast +4 and Vampiric Claw +4.

    when relogin --> Vampiric Claw +4 but Hydro Blast +0
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 25th July 2014, 20:07

    Is AllowedSkills protection enabled?
    It's this configuration in options settings.

    Code:

    # Check players for non-allowed skills
    # Default: False
    SkillCheckEnable = False

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 25th July 2014, 22:14

    i have false,   i put it true ?


    in source i see this

    Code:

     public boolean isSkillAllowed(L2PcInstance player, L2Skill skill)
        {
            if (player.isGM())
                return true;

            if (_loading) // prevent accidental skill remove during reload
                return true;

            int level = skill.getLevel();
            final int maxLvl = SkillTable.getInstance().getMaxLevel(skill.getId());
            int hashCode = SkillTable.getSkillHashCode(skill.getId(), level);

            if (_enchantSkillTrees.get(hashCode) != null)
                level = _enchantSkillTrees.get(hashCode).getBaseLevel();

            hashCode = SkillTable.getSkillHashCode(skill.getId(), Math.min(level, maxLvl));

            if (Arrays.binarySearch(_skillsByClassIdHashCodes.get(player.getClassId().ordinal()), hashCode) >= 0)
                return true;

            if (Arrays.binarySearch(_allSkillsHashCodes, hashCode) >= 0)
                return true;

            return false;
        }

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 02:31

    help i need a solution !! :S
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 03:03

    Just let it be False.
    Which patch have you used for accumulative subclass?
    I have to see the way it works.

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 03:09

    DnR wrote:Just let it be False.
    Which patch have you used for accumulative subclass?
    I have to see the way it works.


    i use this patch --> http://l2jlisvus.great-forum.com/t407-share-custom-subclass-configuration-more-than-3-subs?highlight=subclass
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 03:25

    What happens if skills have different enchant?
    For example Vampiric claw +4 & Hydro blast +5.

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 03:29

    DnR wrote:What happens if skills have different enchant?
    For example Vampiric claw +4 & Hydro blast +5.


    no matter the value, the only thing left is the skill of the class, the other does not correspond to the class becomes +0


    i see this in acumulative subclass patch

    Code:
    + // Go though the recordset of this SQL query
    + while (rset.next())
    + {
    + int id = rset.getInt("skill_id");
    + int level = rset.getInt("skill_level");
    +
    + if (id > 9000)
    + {
    + continue; // fake skills for base stats
    + }

    affects anything?

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 03:41

    or this ?

    Code:
    private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=? AND class_index=?";


          if ((oldSkill != null) && (newSkill != null))
             {
                statement = con.prepareStatement(UPDATE_CHARACTER_SKILL_LEVEL);
                statement.setInt(1, newSkill.getLevel());
                statement.setInt(2, oldSkill.getId());
                statement.setInt(3, getObjectId());
                statement.setInt(4, classIndex);
                statement.execute();
                statement.close();
             }



    Last edited by FLeandro93 on 26th July 2014, 03:44; edited 1 time in total
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 03:42

    Good news. I found the problem and i looking for a fix atm.
    This patch is incomplete and needs one more check.
    Please be patient. Smile

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 03:45

    DnR wrote:Good news. I found the problem and i looking for a fix atm.
    This patch is incomplete and needs one more check.
    Please be patient. Smile


    Thx DnR, Your serverpack is great, i wait .. Wink

    do not forget to post

    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 04:03

    First of all, delete this line (you don't need it anymore).

    Code:

    /** The Constant RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS. */
    private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";

    Then make void restoreSkills look like this:

    Code:

       /**
        * Retrieve from the database all skills of this L2PcInstance and add them to _skills.<BR><BR>
        */
       private void restoreSkills()
       {
           java.sql.Connection con = null;
           try
           {
               // Retrieve all skills of this L2PcInstance from the database
               con = L2DatabaseFactory.getInstance().getConnection();
               PreparedStatement statement;

               // Stuck Sub skills
               if (Config.KEEP_SUBCLASS_SKILLS)
               {
                   statement = con.prepareStatement("UPDATE character_skills SET class_index=? WHERE char_obj_id=?");
                   statement.setInt(1, getClassIndex());
                   statement.setInt(2, getObjectId());
                   statement.execute();
                   statement.close();
               }

               statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR);
               statement.setInt(1, getObjectId());
               statement.setInt(2, getClassIndex());
               ResultSet rset = statement.executeQuery();

               // Go though the recordset of this SQL query
               while (rset.next())
               {
                   int id = rset.getInt("skill_id");
                   int level = rset.getInt("skill_level");

                   if (id > 9000)
                       continue; // fake skills for base stats

                   // Create a L2Skill object for each record
                   L2Skill skill = SkillTable.getInstance().getInfo(id, level);

                   // Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
                   super.addSkill(skill);

                   if (Config.SKILL_CHECK_ENABLE && !isGM())
                   {
                       if (!SkillTreeTable.getInstance().isSkillAllowed(this, skill))
                       {
                           removeSkill(skill);
                           _log.warning("Removed invalid skill " + skill.getName() + " ("+skill.getId() + "/" + skill.getLevel() + ") from player " + getName() + " with class:" + getTemplate().className);
                       }
                   }
               }

               rset.close();
               statement.close();
           }
           catch (Exception e)
           {
               _log.warning("Could not restore character skills: " + e);
           }
           finally
           {
               try
               {
                   con.close();
               }
               catch (Exception e) {}
           }
       }
    My new patch executes more updates but it fixes skill enchantment, skill reuse time not being saved, and buffs not being saved for stuck subs.
    Please test and let me know. Smile

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 04:11

    but which replaced it by?

    for all code to restore skill ?


    Last edited by FLeandro93 on 26th July 2014, 04:13; edited 1 time in total
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 04:12

    Just delete old void restoreSkills() in L2PcInstance and replace it with this.

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 04:15

    DnR wrote:Just delete old void restoreSkills() in L2PcInstance and replace it with this.

    ok, in a few minute post result

    avoegio

    Posts : 75
    Join date : 2014-04-18

    Re: Error Enchant Skills when Relogin !!

    Post  avoegio on 26th July 2014, 04:17

    DnR is this problem on active SVN?
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 04:20

    avoegio wrote:DnR is this problem on active SVN?
    We don't have stuck sub on active svn.
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 04:21

    FLeandro93 wrote:
    DnR wrote:Just delete old void restoreSkills() in L2PcInstance and replace it with this.

    ok, in a few minute post result

    Also, add this small check in boolean modifySubclass()

    Code:

    +               if (!Config.KEEP_SUBCLASS_SKILLS)
    +               {
                        // Remove all effects info stored for this sub-class.
                        statement = con.prepareStatement(DELETE_SKILL_SAVE);
                        statement.setInt(1, getObjectId());
                        statement.setInt(2, classIndex);
                        statement.execute();
                        statement.close();


                        // Remove all skills info stored for this sub-class.
                        statement = con.prepareStatement(DELETE_CHAR_SKILLS);
                        statement.setInt(1, getObjectId());
                        statement.setInt(2, classIndex);
                        statement.execute();
                        statement.close();
    +               }

    With this, player will never lose subclass skills, even if subclass is deleted.
    Is that fine for you?

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 04:32

    did not work, the characters lost the skills of the previous subclas


    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 04:41

    DnR wrote:
    FLeandro93 wrote:
    DnR wrote:Just delete old void restoreSkills() in L2PcInstance and replace it with this.

    ok, in a few minute post result

    Also, add this small check in boolean modifySubclass()

    Code:

    +               if (!Config.KEEP_SUBCLASS_SKILLS)
    +               {
                        // Remove all effects info stored for this sub-class.
                        statement = con.prepareStatement(DELETE_SKILL_SAVE);
                        statement.setInt(1, getObjectId());
                        statement.setInt(2, classIndex);
                        statement.execute();
                        statement.close();


                        // Remove all skills info stored for this sub-class.
                        statement = con.prepareStatement(DELETE_CHAR_SKILLS);
                        statement.setInt(1, getObjectId());
                        statement.setInt(2, classIndex);
                        statement.execute();
                        statement.close();
    +               }

    With this, player will never lose subclass skills, even if subclass is deleted.
    Is that fine for you?

    I miss this, I try and answer

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 04:45

    this correct?

    Code:
       if (!Config.KEEP_SUBCLASS_SKILLS)
                {
                   
                   // Remove all effects info stored for this sub-class.
                   statement = con.prepareStatement(DELETE_SKILL_SAVE);
                   statement.setInt(1, getObjectId());
                   statement.setInt(2, classIndex);
                   statement.execute();
                   statement.close();
                   
                   // Remove all skills info stored for this sub-class.
                   statement = con.prepareStatement(DELETE_CHAR_SKILLS);
                   statement.setInt(1, getObjectId());
                   statement.setInt(2, classIndex);
                   statement.execute();
                   statement.close();
                }
                
                // Remove all basic info stored about this sub-class.
                statement = con.prepareStatement(DELETE_CHAR_SUBCLASS);
                statement.setInt(1, getObjectId());
                statement.setInt(2, classIndex);
                statement.execute();
                statement.close();
                
             };

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 04:57

    dont work :S

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 26th July 2014, 06:48

    I think we should do a update to verify that is a subclass skill

    example :

    Code:
    private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=? AND class_index=?";


    you say?
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error Enchant Skills when Relogin !!

    Post  DnR on 26th July 2014, 13:24

    Patch was untested and thought at 4:00 am. (for me) Very Happy
    Remove my patch, and add old patch.

    Then change this line.
    Code:

    -private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=? AND class_index=?";
    +private static final String UPDATE_CHARACTER_SKILL_LEVEL = "UPDATE character_skills SET skill_level=? WHERE skill_id=? AND char_obj_id=?";

    This fixes skill enchantment only.
    I made a new patch for you because you have got trouble with skills reuse delays, too.
    I'm going to add a completed stuck sub mod to trunk. For now, this is a temporary fix. Smile

    FLeandro93

    Posts : 48
    Join date : 2014-06-20

    Re: Error Enchant Skills when Relogin !!

    Post  FLeandro93 on 4th August 2014, 07:04

    i need fix

    Sponsored content

    Re: Error Enchant Skills when Relogin !!

    Post  Sponsored content


      Current date/time is 23rd October 2017, 05:25