Thread: Region issues

Results 1 to 8 of 8
  1. #1 Region issues 
    Registered Member
    Join Date
    Mar 2020
    Posts
    20
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Fixed issues please close
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Mar 2020
    Posts
    20
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    anybody?
    Reply With Quote  
     

  3. #3  
    Administrator

    Kevy's Avatar
    Join Date
    Jul 2006
    Posts
    1,235
    Thanks given
    90
    Thanks received
    1,615
    Rep Power
    5000
    @[Only registered and activated users can see links. ] please also provide source of StraightPathFinder.java so we can see what is causing the nullpointer.
    Thanks, Kevin.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Mar 2020
    Posts
    20
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Kevy View Post
    @[Only registered and activated users can see links. ] please also provide source of StraightPathFinder.java so we can see what is causing the nullpointer.
    No worries;

    package com.xxx.rs2.entity.pathfinding;

    import com.xxx.core.cache.map.Region;
    import com.xxx.rs2.GameConstants;
    import com.xxx.rs2.entity.Location;

    /**
    * function canShoot coords[] path = path from loc a to loc b coord prev for
    * each next = coord in path if canMoveFrom(prev, next) and canMoveFrom(next,
    * prev) projectile can pass so continue else if certain boolean in object on
    * loc next projectile can pass so continue else projectile can not pass so
    * return false return true
    */

    public class StraightPathFinder {

    private static boolean canAttackOver(int x, int y, int z, int pX, int pY) {
    if (x == pX && y == pY) {
    return true;
    }

    int dir = GameConstants.getDirection(x, y, pX, pY);
    int dir2 = GameConstants.getDirection(pX, pY, x, y);

    if (dir == -1 || dir2 == -1) {
    System.out.println("NEGATIVE DIRECTION MELEE CLIP CHECK ERROR");
    return false;
    }


    if (Region.getRegion(x, y).canMove(x, y, z, dir)) {

    if (Region.getRegion(pX, pY) == null) {

    }
    }
    return Region.getRegion(x, y).canMove(x, y, z, dir) && Region.getRegion(pX, pY).canMove(pX, pY, z, dir2);
    }

    public static boolean isInteractionPathClear(final int x0, final int y0, final int z, final int x1, final int y1) {
    int deltaX = x1 - x0;
    int deltaY = y1 - y0;

    double error = 0;
    final double deltaError = Math.abs((deltaY) / (deltaX == 0 ? ((double) deltaY) : ((double) deltaX)));

    int x = x0;
    int y = y0;

    int pX = x;
    int pY = y;

    boolean incrX = x0 < x1;
    boolean incrY = y0 < y1;

    if (!RS317PathFinder.accessable(x0, y0, z, x1, y1)) {
    return false;
    }

    while (true) {
    if (x != x1) {
    x += (incrX ? 1 : -1);
    }

    if (y != y1) {
    error += deltaError;

    if (error >= 0.5) {
    y += (incrY ? 1 : -1);
    error -= 1;
    }
    }

    if (!canAttackOver(x, y, z, pX, pY)) {
    return false;
    }

    if (incrX && incrY && x >= x1 && y >= y1) {
    break;
    } else if (!incrX && !incrY && x <= x1 && y <= y1) {
    break;
    } else if (!incrX && incrY && x <= x1 && y >= y1) {
    break;
    } else if (incrX && !incrY && x >= x1 && y <= y1) {
    break;
    }

    pX = x;
    pY = y;
    }

    return true;
    }

    public static boolean isInteractionPathClear(Location a, Location b) {
    return isInteractionPathClear(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY());
    }

    public static boolean isProjectilePathClear(final int x0, final int y0, final int z, final int x1, final int y1) {
    int deltaX = x1 - x0;
    int deltaY = y1 - y0;

    double error = 0;
    final double deltaError = Math.abs((deltaY) / (deltaX == 0 ? ((double) deltaY) : ((double) deltaX)));

    int x = x0;
    int y = y0;

    int pX = x;
    int pY = y;

    boolean incrX = x0 < x1;
    boolean incrY = y0 < y1;

    while (true) {
    if (x != x1) {
    x += (incrX ? 1 : -1);
    }

    if (y != y1) {
    error += deltaError;

    if (error >= 0.5) {
    y += (incrY ? 1 : -1);
    error -= 1;
    }
    }

    if (!shootable(x, y, z, pX, pY)) {
    return false;
    }

    if (incrX && incrY && x >= x1 && y >= y1) {
    break;
    } else if (!incrX && !incrY && x <= x1 && y <= y1) {
    break;
    } else if (!incrX && incrY && x <= x1 && y >= y1) {
    break;
    } else if (incrX && !incrY && x >= x1 && y <= y1) {
    break;
    }

    pX = x;
    pY = y;
    }

    return true;
    }

    public static boolean isProjectilePathClear(Location a, Location b) {
    return isProjectilePathClear(a.getX(), a.getY(), a.getZ(), b.getX(), b.getY());
    }

    private static boolean shootable(int x, int y, int z, int pX, int pY) {
    if (x == pX && y == pY) {
    return true;
    }

    int dir = GameConstants.getDirection(x, y, pX, pY);
    int dir2 = GameConstants.getDirection(pX, pY, x, y);

    if (dir == -1 || dir2 == -1) {
    System.out.println("NEGATIVE DIRECTION PROJECTILE ERROR");
    return false;
    }

    if (Region.getRegion(x, y) == null || Region.getRegion(pX, pY) == null) {
    return false;
    }

    if (Region.getRegion(x, y).canMove(x, y, z, dir) && Region.getRegion(pX, pY).canMove(pX, pY, z, dir2)) {
    return true;
    } else {
    return Region.getRegion(x, y).canShoot(x, y, z, dir) && Region.getRegion(x, y).canShoot(pX, pY, z, dir2);
    }
    }
    }

    UPDATE:
    So i got curious about another map that i added that i was gonna work on at some point but it turns out it causes the same issue so i do think its an issue with the server reading the region, completely new area for me so any advice would be appreciated other then that i'm gonna go spend a few hours researching this shit
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Apr 2020
    Posts
    32
    Thanks given
    1
    Thanks received
    3
    Rep Power
    38
    Your missing the mapdata for these areas by the looks

    You can check this by

    Code:
    Region region = Region.getRegion(x, y);
    
    if (region == null) {
            System.out.println("region at x: "+ x +" y: "+ y +" does not exist");
            return false;
    }

    The part throwing the null is

    Code:
    if (Region.getRegion(x, y).canMove(x, y, z, dir)) {
    
    if (Region.getRegion(pX, pY) == null) {
    
    }
    }
    return Region.getRegion(x, y).canMove(x, y, z, dir) && Region.getRegion(pX, pY).canMove(pX, pY, z, dir2);
    }
    because it wasn't checked if the region existed first before checking if it could move or "canMove".
    you can prevent errors by replacing it with

    Code:
    Region region = Region.getRegion(x, y);
    
    if (region == null) {
            System.out.println("region at x: "+ x +" y: "+ y +" does not exist");
            return false;
    }
    
    return region.canMove(x, y, z, dir) && region.canMove(pX, pY, z, dir2);
    }
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Mar 2020
    Posts
    20
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by ggtip2 View Post
    Your missing the mapdata for these areas by the looks

    You can check this by

    Code:
    Region region = Region.getRegion(x, y);
    
    if (region == null) {
            System.out.println("region at x: "+ x +" y: "+ y +" does not exist");
            return false;
    }

    The part throwing the null is

    Code:
    if (Region.getRegion(x, y).canMove(x, y, z, dir)) {
    
    if (Region.getRegion(pX, pY) == null) {
    
    }
    }
    return Region.getRegion(x, y).canMove(x, y, z, dir) && Region.getRegion(pX, pY).canMove(pX, pY, z, dir2);
    }
    because it wasn't checked if the region existed first before checking if it could move or "canMove".
    you can prevent errors by replacing it with

    Code:
    Region region = Region.getRegion(x, y);
    
    if (region == null) {
            System.out.println("region at x: "+ x +" y: "+ y +" does not exist");
            return false;
    }
    
    return region.canMove(x, y, z, dir) && region.canMove(pX, pY, z, dir2);
    }
    By map data so you mean the. Gz files that go in the cache?
    I'll give what you said a try though, I'll let you know how it goes haha thanks

    Right so yeah you was right it logged:

    region at x: 2275 y: 10035 does not exist

    stopped the crashing though haha, however when i get close to an npc it just vanishes i'm assuming that't to do with the map data, i did get my mapindex and the other 2 files and then dumped the maps from the cache and put them all into data/maps in server ran the map update but it caused region errors haha

    Bump this is one of my last things i need to figure out so its kinda important!!

    bump
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Mar 2020
    Posts
    20
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Bump
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Mar 2020
    Posts
    20
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    so seriously nobody has any idea about this....
    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. [317] Dynamic Map/Region issue
    By Grant_ in forum Help
    Replies: 3
    Last Post: 08-23-2019, 10:22 PM
  2. Construction Region-Objects issue
    By Cuzzbuzz in forum Help
    Replies: 14
    Last Post: 06-24-2014, 01:09 PM
  3. [Matrix] Region Spawn Objects Issue
    By The Stoned in forum Help
    Replies: 2
    Last Post: 06-05-2014, 06:00 AM
  4. Messed up regions/Index issues?
    By Haywire in forum Help
    Replies: 3
    Last Post: 10-02-2013, 06:58 PM
  5. 718 Dynamic Region issue.
    By Dev David in forum Help
    Replies: 2
    Last Post: 07-28-2013, 03:17 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
  •