Fix most of the clipping (minor stuff with doors left)

This commit is contained in:
dginovker
2019-12-20 12:35:12 -05:00
parent 00500a072b
commit 13977992d7
8 changed files with 12 additions and 19 deletions
@@ -56,30 +56,17 @@ public class Doors {
}
public boolean handleDoor(Player player, int id, int x, int y, int z) {
Doors d = getDoor(id, x, y, z);
if (d == null) {
if (DoubleDoors.getSingleton().handleDoor(player, id, x, y, z)) {
return true;
}
return false;
return DoubleDoors.getSingleton().handleDoor(player, id, x, y, z);
}
//todo: improvment: if player manage to get to door then open the door.
if(player.distanceToPoint(x, y) > 1) return false;
/**
* Here we shall remove the clipping from the door
* We can't add the clipping back when it is closed, because we apparently never update the d.open value....
*/
if(d != null) {
if(d.open == 0) {
Region.removeClipping(x, y, z);
} else {
//Region.addClipping(x, y, z, 0);
}
}
//Remove clipping for old door (gets added back in placeObject)
Region.removeClipping(x, y, z);
int xAdjustment = 0, yAdjustment = 0;
if (d.type == 0) {
@@ -10,6 +10,7 @@ import java.util.Scanner;
import com.rebotted.GameEngine;
import com.rebotted.game.objects.Objects;
import com.rebotted.game.players.Player;
import com.rebotted.world.clip.Region;
/**
*
@@ -47,8 +48,8 @@ public class DoubleDoors {
}
public boolean handleDoor(Player player, int id, int x, int y, int z) {
DoubleDoors doorClicked = getDoor(id, x, y, z);
DoubleDoors doorClicked = getDoor(id, x, y, z);
if (doorClicked == null) {
//GameEngine.objectHandler.placeObject(new Objects(-1, x, y, z, 0, 0, 0));
return true;
@@ -56,6 +57,9 @@ public class DoubleDoors {
if (doorClicked.doorId > 12000) {
return true; //nearly all of these are not opened
}
Region.removeClipping(x, y, z);
if (doorClicked.open == 0) {
if (doorClicked.originalFace == 0) {
DoubleDoors lowerDoor = getDoor(id - 3, x, y -1, z);
@@ -15,6 +15,7 @@ import com.rebotted.game.players.Client;
import com.rebotted.game.players.Player;
import com.rebotted.game.players.PlayerHandler;
import com.rebotted.util.Misc;
import com.rebotted.world.clip.Region;
/**
* @author Sanity
@@ -135,6 +136,7 @@ public class ObjectHandler {
* Creates the object for anyone who is within 60 squares of the object
**/
public void placeObject(Objects o) {
Region.addClipping(o.getObjectX(), o.getObjectY(), o.getObjectHeight(), 0);
for (Player p : PlayerHandler.players) {
if (p != null) {
Client person = (Client) p;
@@ -289,7 +289,7 @@ public class Region {
return projectileClips[height][x - regionAbsX][y - regionAbsY];
}
private static void addClipping(int x, int y, int height, int shift) {
public static void addClipping(int x, int y, int height, int shift) {
int regionX = x >> 3;
int regionY = y >> 3;
int regionId = (regionX / 8 << 8) + regionY / 8;