Thread: java.lang.ArrayIndexOutOfBoundsException: -1

Results 1 to 6 of 6
  1. #1 java.lang.ArrayIndexOutOfBoundsException: -1 
    Extreme Donator


    Join Date
    Dec 2011
    Posts
    323
    Thanks given
    92
    Thanks received
    46
    Rep Power
    81
    Hello. Im having this error at random times in the source console.
    It makes everyone DC, and the server stop running.
    Spoiler for issue:
    [4/30/12 11:33 AM]: java.lang.ArrayIndexOutOfBoundsException: -1
    [4/30/12 11:33 AM]: at server.world.WalkingHandler$TiledMap.getFlag(Walki ngH
    andler.java:67)
    [4/30/12 11:33 AM]: at server.world.WalkingHandler.traversable(WalkingHan dle
    r.java:27)
    [4/30/12 11:33 AM]: at server.model.npcs.NPC.getNextWalkingDirection(NPC. jav
    a:233)
    [4/30/12 11:33 AM]: at server.model.npcs.NPC.getNextNPCMovement(NPC.java: 244
    )
    [4/30/12 11:33 AM]: at server.model.npcs.NPCHandler.followPlayer(NPCHandl er.
    java:2880)
    [4/30/12 11:33 AM]: at server.model.npcs.NPCHandler.process(NPCHandler.ja va:
    1950)
    [4/30/12 11:33 AM]: at server.Server.main(Server.java:184)

    Spoiler for walkinghandler line 27:
    public boolean traversable(int x, int y, int direction) {
    int flag = map.getFlag(x, y);
    //System.out.println(direction);
    if (direction == 0 && (flag == 1 || flag == 4 || flag == 6 || flag == 7 || flag == 9 || flag == 11 || flag == 13 || flag == 14)) {
    return false;
    } else if (direction == 4 && (flag == 1 || flag == 7 || flag == 15 || flag == 10 || flag == 11 || flag == 12 || flag == 14 || flag == 5)) {
    return false;
    } else if (direction == 8 && (flag == 1 || flag == 2 || flag == 3 || flag == 4 || flag == 5 || flag == 6 || flag == 7 || flag == 12)) {
    return false;
    } else if (direction == 12 && (flag == 1 || flag == 3 || flag == 6 || flag == 9 || flag == 10 || flag == 11 || flag == 12 || flag == 8)) {
    return false;
    } else if(flag > 0 && flag < 15) {
    return false;
    }
    return true;
    }

    Spoiler for Walkinghandler line 67:
    private static class TiledMap {

    private final byte[] plane;

    public TiledMap(int width, int height) {
    this.plane = new byte[width * 10000 + height];
    }

    public int getFlag(int x, int y) {
    return plane[x * 10000 + y];
    }

    public void flag(int x, int y, byte flag) {
    this.plane[x * 10000 + y] = flag;
    }

    }

    Spoiler for NPC.java line 233:
    public int getNextWalkingDirection() {
    int dir;
    dir = Misc.direction(absX, absY, (absX + moveX), (absY + moveY));
    if (dir == -1 || !WalkingHandler.getSingleton().traversable(absX + moveX, absY + moveY, dir))
    return -1;
    dir >>= 1;
    absX += moveX;
    absY += moveY;
    return dir;
    }

    Spoiler for NPC.java:244:
    public void getNextNPCMovement(int i) {
    direction = -1;
    if(Server.npcHandler.npcs[i].freezeTimer == 0) {
    direction = getNextWalkingDirection();
    }
    }

    Spoiler for NPCHandler.java:2880:
    npcs[i].getNextNPCMovement(i);

    Spoiler for NPCHandler.java:1950:
    followPlayer(i, c.playerId);

    Spoiler for Server.java:184:
    npcHandler.process();


    I hope anyone can figure out the issue by looking at the information i've left by. If you need any more info, i'll get it

    Thanks in advise!
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Mar 2010
    Posts
    1,048
    Thanks given
    239
    Thanks received
    226
    Rep Power
    0
    Not sure what the problem is, but this will fix disconnections:

    Code:
    public int getFlag(int x, int y) {
    return plane[x * 10000 + y];
    }
    Replace:
    Code:
    public int getFlag(int x, int y) {
    return ((plane[x * 10000 + y]) > 0 ? (plane[x * 10000 + y]) : (1));
    }
    Untested, might not work because I'm not sure what the plane class consists of(I don't use project insanity).
    Reply With Quote  
     

  3. #3  
    Extreme Donator


    Join Date
    Dec 2011
    Posts
    323
    Thanks given
    92
    Thanks received
    46
    Rep Power
    81
    Thanks, trying it out now.
    Reply With Quote  
     

  4. #4  
    Donator

    Thock321's Avatar
    Join Date
    Jul 2011
    Posts
    1,804
    Thanks given
    706
    Thanks received
    363
    Rep Power
    416
    I think your X or Y is -1.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Oct 2008
    Posts
    49
    Thanks given
    3
    Thanks received
    1
    Rep Power
    6
    Logging out before a specific monster is spawned causes this error.

    Eg. Logging before Jad spawns will cause a server crash, add a logout prevention timer.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    May 2010
    Posts
    152
    Thanks given
    7
    Thanks received
    3
    Rep Power
    12
    Anyone have an actual fix? This is annoying as a son of a bitch x.x


    -Booo Yaaaaaa-
    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. Replies: 2
    Last Post: 02-09-2012, 01:50 PM
  2. java.lang.ArrayIndexOutOfBoundsException: 7390
    By zhstyle1990 in forum Help
    Replies: 0
    Last Post: 09-18-2011, 10:54 PM
  3. Replies: 1
    Last Post: 12-09-2009, 03:30 AM
  4. java.lang.ArrayIndexOutOfBoundsException: 0
    By Pilldom in forum Projects
    Replies: 0
    Last Post: 11-27-2008, 04:10 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •