Construct map packet changing object position on rotation

I’m honestly stumped as to what’s causing this because the server isn’t placing the objects. It’s simply setting the rotation value of the room and re-sending the tiles.

I was having a similar issue with my sink space, but that was a result from my placement code being wrong. You could tell because there was two copies of the object instead of just one.

PlayerRoom room = getRoom(pl, house); if (rotateLeft) { room.getRoomTile() .setRotation(room.getRoomTile().getRotation() < 1 ? 3 : (room.getRoomTile().getRotation() - 1)); } else { room.getRoomTile() .setRotation(room.getRoomTile().getRotation() > 2 ? 0 : (room.getRoomTile().getRotation() + 1)); } pl.getPacketSender().constructMapRegion(pl.getPlayerPalette());

PlayerRoom basically consists of:

private PaletteTile roomTile; private GameObject[] roomObjects; private int xIndex; private int yIndex; private int zIndex;

Palette (not my class):

[code=java]package server.world;

/**

  • Manages a palette of map regions for use in the constructed map region

  • packet.

  • @author Graham
    */
    public class Palette {

    /**

    • Normal direction.
      */
      public static final int DIRECTION_NORMAL = 0;

    /**

    • Rotation direction clockwise by 0 degrees.
      */
      public static final int DIRECTION_CW_0 = 0;

    /**

    • Rotation direction clockwise by 90 degrees.
      */
      public static final int DIRECTION_CW_90 = 1;

    /**

    • Rotation direction clockwise by 180 degrees.
      */
      public static final int DIRECTION_CW_180 = 2;

    /**

    • Rotation direction clockwise by 270 degrees.
      */
      public static final int DIRECTION_CW_270 = 3;

    /**

    • Represents a tile to copy in the palette.
    • @author Graham Edgecombe

    */
    public static class PaletteTile {

     /**
      * X coordinate.
      */
     private int x;
    
     /**
      * Y coordinate.
      */
     private int y;
    
     /**
      * Z coordinate.
      */
     private int z;
    
     /**
      * Rotation.
      */
     private int rot;
    
     public PaletteTile() {
     	this(0, 0, 0);
     }
    
     /**
      * Creates a tile.
      * 
      * @param x
      *            The x coordinate.
      * @param y
      *            The y coordinate.
      */
     public PaletteTile(int x, int y) {
     	this(x, y, 0);
     }
    
     /**
      * Creates a tile.
      * 
      * @param x
      *            The x coordinate.
      * @param y
      *            The y coordinate.
      * @param z
      *            The z coordinate.
      */
     public PaletteTile(int x, int y, int z) {
     	this(x, y, z, DIRECTION_NORMAL);
     }
    
     /**
      * Creates a tile.
      * 
      * @param x
      *            The x coordinate.
      * @param y
      *            The y coordinate.
      * @param z
      *            The z coordinate.
      * @param rot
      *            The rotation.
      */
     public PaletteTile(int x, int y, int z, int rot) {
     	this.x = x;
     	this.y = y;
     	this.z = z;
     	this.rot = rot;
     }
    
     /**
      * Gets the x coordinate.
      * 
      * @return The x coordinate divided by 8.
      */
     public int getX() {
     	return x / 8;
     }
    
     /**
      * Gets the x coordinate.
      * 
      * @return The x coordinate.
      */
     public int getBaseX() {
     	return x;
     }
    
     /**
      * Gets the y coordinate.
      * 
      * @return The y coordinate divided by 8.
      */
     public int getY() {
     	return y / 8;
     }
    
     /**
      * Gets the y coordinate.
      * 
      * @return The y coordinate.
      */
     public int getBaseY() {
     	return y;
     }
    
     /**
      * Gets the z coordinate.
      * 
      * @return The z coordinate divided by 4.
      */
     public int getZ() {
     	return z % 4;
     }
    
     /**
      * Gets the z coordinate.
      * 
      * @return The z coordinate.
      */
     public int getBaseZ() {
     	return x;
     }
    
     /**
      * Gets the rotation.
      * 
      * @return The rotation.
      */
     public int getRotation() {
     	return rot % 4;
     }
    
     public void setRotation(int rot) {
     	this.rot = rot;
     }
    
     public void setZ(int z) {
     	this.z = z;
     }
    

    }

    /**

    • The array of tiles.
      */
      private PaletteTile[][][] tiles = new PaletteTile[14][14][4];

    /**

    • Gets a tile.
    • @param x
    •        X position.
      
    • @param y
    •        Y position.
      
    • @param z
    •        Z position.
      
    • @return The tile.
      */
      public PaletteTile getTile(int x, int y, int z) {
      return tiles[x][y][z % 4];
      }

    /**

    */
    public void setTile(int x, int y, int z, PaletteTile tile) {
    tiles[x][y][z % 4] = tile;
    }
    }[/code]

This seems to occur on all fire-place like objects. However, other objects with similar sizes (the sink is the same size) don’t do it.

If it’s any help, this is the code I use to get the object’s offset when the room is rotated:

private static int getObjectOffset(GameObject o, PlayerRoom r, boolean isX) { if (o == null || r == null) { return 1; } ObjectDefinition obj = ObjectDefinition.getDefinition(o); int newX = o.getObjectX(); int newY = o.getObjectY(); int length = obj == null ? 1 : obj.getSizeX(); int width = obj == null ? 1 : obj.getSizeY(); switch (r.getRoomTile().getRotation()) { case Palette.DIRECTION_CW_270: newX = 8 - o.getObjectY() - width; newY = o.getObjectX(); break; case Palette.DIRECTION_CW_180: newX = 8 - o.getObjectX() - length; newY = 8 - o.getObjectY() - width; break; case Palette.DIRECTION_CW_90: newX = o.getObjectY(); newY = 8 - o.getObjectX() - length; break; case Palette.DIRECTION_CW_0: break; } if (o.getObjectId() == 15398) { System.out.println("L: " + length + " w: " + width + "new x: " + newX + " new y " + newY); } return isX ? newX : newY; }
(Not the best but it works)

Edit: I have verified it is not the object offset code
How? Easy. I disabled it and the issue still showed up.

I compared my construct map packet to a couple different servers - and it appears it’s the same.
One server had a value set to 5 where I had it set to 1, but changing that didn’t appear to change anything.

Can you do some checking if the server still thinks the object is there or if it has been moved? If the server thinks the object has not been moved then it’s a client issue.

Object offset code looks familiar :wink:

Yeah the server is having a hard time finding the objects when they’re in the wrong spots.

Wonder why :stuck_out_tongue: