Thread: adding new skill index to player file

Results 1 to 3 of 3
  1. #1 adding new skill index to player file 
    Everything is Corrupt
    Corrupt's Avatar
    Join Date
    Oct 2020
    Posts
    115
    Thanks given
    15
    Thanks received
    36
    Rep Power
    63
    i just added divination to my server, but the problem is that any registered member before adding the divination doesnt have the index in their player file for divination.

    How would i go about adding the new skill index to the player file? I know how to load the serialized p file, but I'm not sure how to add a new index into it. trying to add the index 25 to it.
    Living in a Corrupted World

    Attached image
    Reply With Quote  
     

  2. #2  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    This is the reason serialized player saves are trash. There's no good way to modify/remove information without causing issues (as far as I'm aware). Just add a condition in the "start()" method (or whatever you call when a player logs in) to migrate your Skills.java:

    Code:
    Player:java
    
    public void start(...) {
        ...
        skills.migrate();
        ...
    }
    Code:
    Skills.java
    
    public void migrate() {
        if (level.length == 26 && xp.length == 26) return;
        newLevel = new short[26];
        newXp = new double[26];
        System.arraycopy(xp, 0, newXp, 0, 25);
        System.arraycopy(level, 0, newLevel , 0, 25);
        xp = newXp;
        level = newLevel;
    }
    Project thread
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Everything is Corrupt
    Corrupt's Avatar
    Join Date
    Oct 2020
    Posts
    115
    Thanks given
    15
    Thanks received
    36
    Rep Power
    63
    Quote Originally Posted by clem585 View Post
    This is the reason serialized player saves are trash. There's no good way to modify/remove information without causing issues (as far as I'm aware). Just add a condition in the "start()" method (or whatever you call when a player logs in) to migrate your Skills.java:

    Code:
    Player:java
    
    public void start(...) {
        ...
        skills.migrate();
        ...
    }
    Code:
    Skills.java
    
    public void migrate() {
        if (level.length == 26 && xp.length == 26) return;
        newLevel = new short[26];
        newXp = new double[26];
        System.arraycopy(xp, 0, newXp, 0, 25);
        System.arraycopy(level, 0, newLevel , 0, 25);
        xp = newXp;
        level = newLevel;
    }
    you are a freaking god ^.^
    Living in a Corrupted World

    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. need help adding new skill to my 718 rsps
    By Dark9Boy in forum Help
    Replies: 6
    Last Post: 01-11-2014, 07:00 PM
  2. [PI]adding new skill
    By Snake in forum Help
    Replies: 0
    Last Post: 07-18-2011, 04:57 PM
  3. Adding New Skill into Skill interface
    By Faris in forum Help
    Replies: 0
    Last Post: 07-12-2011, 10:16 AM
  4. Replies: 8
    Last Post: 04-23-2010, 03:18 AM
  5. adding new skills to calc. combat lvl
    By mige5 in forum Help
    Replies: 3
    Last Post: 03-03-2009, 01:06 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •