diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 6f83491d..72017302 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -390,16 +390,16 @@ public class InfoCmd extends AbstractDevCmd { output += "Parent Zone LoadNum : " + targetNPC.getParentZone().getLoadNum(); } - - if (targetNPC.getRegion() != null){ + + if (targetNPC.region != null) { output += newline; - output += "BuildingID : " + targetNPC.getRegion().parentBuildingID; - output += "building level : " + targetNPC.getRegion().level; - output += "building room : " + targetNPC.getRegion().room; - }else if(targetNPC.getBuilding() != null) { + output += "BuildingID : " + targetNPC.region.parentBuildingID; + output += "building level : " + targetNPC.region.level; + output += "building room : " + targetNPC.region.room; + } else if (targetNPC.getBuilding() != null) { output += newline; output += "Building : " + targetNPC.getBuilding(); - }else{ + } else { output += newline; output += "No building found."; } @@ -463,13 +463,13 @@ public class InfoCmd extends AbstractDevCmd { output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); output += newline; output += "isMoving : " + targetMob.isMoving(); - if (targetMob.getRegion() != null){ + if (targetMob.region != null) { output += newline; - output += "BuildingID : " + targetMob.getRegion().parentBuildingID; - output += "building level : " + targetMob.getRegion().level; - output += "building room : " + targetMob.getRegion().room; + output += "BuildingID : " + targetMob.region.parentBuildingID; + output += "building level : " + targetMob.region.level; + output += "building room : " + targetMob.region.room; } - if(targetMob.building != null) { + if (targetMob.building != null) { output += "Building Name: " + targetMob.building.getName() + newline; output += "BuildingID : " + targetMob.building + newline; output += "Bind Loc : " + targetMob.getBindLoc() + newline; diff --git a/src/engine/devcmd/cmds/PrintLocationCmd.java b/src/engine/devcmd/cmds/PrintLocationCmd.java index 4453c457..e8ce418d 100644 --- a/src/engine/devcmd/cmds/PrintLocationCmd.java +++ b/src/engine/devcmd/cmds/PrintLocationCmd.java @@ -40,14 +40,14 @@ public class PrintLocationCmd extends AbstractDevCmd { throwbackInfo(pc, "Lat: " + tar.getLoc().getX()); throwbackInfo(pc, "Lon: " + -tar.getLoc().getZ()); throwbackInfo(pc, "Alt: " + tar.getLoc().getY()); - if (pc.getRegion() != null) { - this.throwbackInfo(pc, "Player Region Slope Position : " + Regions.SlopeLerpPercent(pc, pc.getRegion())); - this.throwbackInfo(pc, "Region Slope Magnitude : " + Regions.GetMagnitudeOfRegionSlope(pc.getRegion())); - this.throwbackInfo(pc, "Player Region Slope Magnitude : " + Regions.GetMagnitudeOfPlayerOnRegionSlope(pc.getRegion(), pc)); - }else{ + if (pc.region != null) { + this.throwbackInfo(pc, "Player Region Slope Position : " + Regions.SlopeLerpPercent(pc, pc.region)); + this.throwbackInfo(pc, "Region Slope Magnitude : " + Regions.GetMagnitudeOfRegionSlope(pc.region)); + this.throwbackInfo(pc, "Player Region Slope Magnitude : " + Regions.GetMagnitudeOfPlayerOnRegionSlope(pc.region, pc)); + } else { this.throwbackInfo(pc, "No Region Found for player."); } - + } else { throwbackInfo(pc, "Server location for " + tar.getFirstName() + " not found"); diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 48fd5390..928bcdfb 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -27,18 +27,18 @@ public class RegionCmd extends AbstractDevCmd { AbstractGameObject target) { - if (pc.getRegion() == null){ - this.throwbackInfo(pc, "No Region Found."); - return; - } + if (pc.region == null) { + this.throwbackInfo(pc, "No Region Found."); + return; + } String newLine = System.getProperty("line.separator"); String result = ""; - result+=(pc.getRegion().getClass().getSimpleName()); - result+=( " {" ); + result += (pc.region.getClass().getSimpleName()); + result += (" {"); result+=(newLine); - Field[] fields = pc.getRegion().getClass().getDeclaredFields(); + Field[] fields = pc.region.getClass().getDeclaredFields(); //print field names paired with their values for ( Field field : fields ) { @@ -51,7 +51,7 @@ public class RegionCmd extends AbstractDevCmd { result+=( field.getName()); result+=(": "); //requires access to private field: - result+=( field.get(pc.getRegion()).toString()); + result += (field.get(pc.region).toString()); } catch ( IllegalAccessException ex ) { System.out.println(ex); } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index a8b94e82..5b39a9ca 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -508,7 +508,7 @@ public enum BuildingManager { mob.setRank(rank); mob.setPlayerGuard(true); mob.BehaviourType = Enum.MobBehaviourType.GuardWallArcher; - MovementManager.translocate(mob,mob.getBindLoc(),mob.getRegion()); + MovementManager.translocate(mob, mob.getBindLoc(), mob.region); return true; } if (NPC.ISGuardCaptain(contract.getContractID())) { diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index 60785270..a3bc0a17 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -168,24 +168,24 @@ public enum MovementManager { toMove.setInBuilding(-1); msg.setStartCoord(toMove.getLoc()); } - + //make sure we set the correct player. msg.setSourceType(toMove.getObjectType().ordinal()); msg.setSourceID(toMove.getObjectUUID()); - + //if player in region, modify location to local location of building. set target to building. - if (toMove.getRegion() != null){ - Building regionBuilding = Regions.GetBuildingForRegion(toMove.getRegion()); - if (regionBuilding != null){ - msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.getRegion()), toMove.getLoc())); + if (toMove.region != null) { + Building regionBuilding = Regions.GetBuildingForRegion(toMove.region); + if (regionBuilding != null) { + msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc())); msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation)); - msg.setInBuilding(toMove.getRegion().level); - msg.setUnknown01(toMove.getRegion().room); + msg.setInBuilding(toMove.region.level); + msg.setUnknown01(toMove.region.room); msg.setTargetType(GameObjectType.Building.ordinal()); msg.setTargetID(regionBuilding.getObjectUUID()); } - - }else{ + + } else { toMove.setInBuildingID(0); toMove.setInFloorID(-1); toMove.setInBuilding(-1); diff --git a/src/engine/jobs/FinishSummonsJob.java b/src/engine/jobs/FinishSummonsJob.java index afe4f6d2..a375de8f 100644 --- a/src/engine/jobs/FinishSummonsJob.java +++ b/src/engine/jobs/FinishSummonsJob.java @@ -55,14 +55,14 @@ public class FinishSummonsJob extends AbstractScheduleJob { return; } - if (this.target.getBonuses() != null && this.target.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)){ + if (this.target.getBonuses() != null && this.target.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) { ErrorPopupMsg.sendErrorMsg(this.target, "You have been blocked from receiving summons!"); ErrorPopupMsg.sendErrorMsg(this.source, "Target is blocked from receiving summons!"); return; } - if (this.source.getRegion() != null) - this.target.setRegion(this.source.getRegion()); + if (this.source.region != null) + this.target.setRegion(this.source.region); //teleport target to source target.teleport(source.getLoc()); } diff --git a/src/engine/math/Bounds.java b/src/engine/math/Bounds.java index f295f1dc..08d40e32 100644 --- a/src/engine/math/Bounds.java +++ b/src/engine/math/Bounds.java @@ -358,7 +358,7 @@ public class Bounds { //player is inside building region, skip collision check. we only do collision from the outside. - if (player.getRegion() != null && player.getRegion().parentBuildingID == building.getObjectUUID()) + if (player.region != null && player.region.parentBuildingID == building.getObjectUUID()) continue; if (building.getBounds().colliders == null) continue; @@ -366,7 +366,7 @@ public class Bounds { for (Colliders collider: building.getBounds().colliders) { //links are what link together buildings, allow players to run through them only if they are in a building already. - if (collider.isLink() && player.getRegion() != null) + if (collider.isLink() && player.region != null) continue; if (collider.getDoorID() != 0 && building.isDoorOpen(collider.getDoorID())) continue; diff --git a/src/engine/net/client/handlers/ChangeAltitudeHandler.java b/src/engine/net/client/handlers/ChangeAltitudeHandler.java index b8b09fb4..9da70492 100644 --- a/src/engine/net/client/handlers/ChangeAltitudeHandler.java +++ b/src/engine/net/client/handlers/ChangeAltitudeHandler.java @@ -44,7 +44,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler { if (pc.isSwimming()) return false; - if (pc.getRegion() != null && !pc.getRegion().isOutside()) + if (pc.region != null && !pc.region.isOutside()) return false; @@ -79,7 +79,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler { pc.landingRegion = null; if (pc.getAltitude() == 0){ - Regions upRegion = pc.getRegion(); + Regions upRegion = pc.region; if (upRegion != null){ float startAlt = 0; Building regionBuilding = Regions.GetBuildingForRegion(upRegion); diff --git a/src/engine/net/client/msg/LoadCharacterMsg.java b/src/engine/net/client/msg/LoadCharacterMsg.java index 7dff7d18..c9de5425 100644 --- a/src/engine/net/client/msg/LoadCharacterMsg.java +++ b/src/engine/net/client/msg/LoadCharacterMsg.java @@ -74,8 +74,8 @@ public class LoadCharacterMsg extends ClientNetMsg { NPC npc = (NPC) absChar; if (npc.region != null) { - writer.putInt(npc.getRegion().getLevel()); - writer.putInt(npc.getRegion().getRoom()); + writer.putInt(npc.region.getLevel()); + writer.putInt(npc.region.getRoom()); } else { writer.putInt(-1); writer.putInt(-1); @@ -85,7 +85,7 @@ public class LoadCharacterMsg extends ClientNetMsg { } else if (absChar != null) { if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter)) { - Regions region = absChar.getRegion(); + Regions region = absChar.region; if (region == null) { writer.putInt(-1); @@ -102,7 +102,7 @@ public class LoadCharacterMsg extends ClientNetMsg { } } else if (absChar.getObjectType().equals(GameObjectType.Mob)){ - Regions region = absChar.getRegion(); + Regions region = absChar.region; if (region == null){ writer.putInt(-1); diff --git a/src/engine/net/client/msg/SendOwnPlayerMsg.java b/src/engine/net/client/msg/SendOwnPlayerMsg.java index 75b8362b..2a829990 100644 --- a/src/engine/net/client/msg/SendOwnPlayerMsg.java +++ b/src/engine/net/client/msg/SendOwnPlayerMsg.java @@ -74,18 +74,18 @@ public class SendOwnPlayerMsg extends ClientNetMsg { */ @Override protected void _serialize(ByteBufferWriter writer) { - - Regions region = this.ch.getRegion(); + + Regions region = this.ch.region; //region loading seralization. serialzes building level and floor. -1 = not in building. - if (region == null){ + if (region == null) { writer.putInt(-1); writer.putInt(-1); - }else{ + } else { Building regionBuilding = Regions.GetBuildingForRegion(region); - if (regionBuilding == null){ + if (regionBuilding == null) { writer.putInt(-1); writer.putInt(-1); - }else{ + } else { writer.putInt(region.getLevel()); writer.putInt(region.getRoom()); } diff --git a/src/engine/net/client/msg/TeleportToPointMsg.java b/src/engine/net/client/msg/TeleportToPointMsg.java index c94de917..23807599 100644 --- a/src/engine/net/client/msg/TeleportToPointMsg.java +++ b/src/engine/net/client/msg/TeleportToPointMsg.java @@ -42,21 +42,20 @@ public class TeleportToPointMsg extends ClientNetMsg { if (targetID != 0){ this.targetType = GameObjectType.Building.ordinal(); this.targetUUID = (int) targetID; - }else{ + } else { this.targetType = 0; this.targetUUID = 0; } - - + this.unknown01 = unknown01; this.unknown02 = unknown02; - - if (ago.getRegion() != null){ + + if (ago.region != null) { this.targetType = GameObjectType.Building.ordinal(); - this.targetUUID = ago.getRegion().parentBuildingID; - this.unknown01 = ago.getRegion().level; - this.unknown02 = ago.getRegion().room; + this.targetUUID = ago.region.parentBuildingID; + this.unknown01 = ago.region.level; + this.unknown02 = ago.region.room; } } diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 11305d41..99d3ec98 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -60,7 +60,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { protected GridObjectType gridObjectType; protected float altitude = 0; - protected Regions region; + public Regions region; protected boolean movingUp = false; public Regions landingRegion = null; public Vector3fImmutable lastLoc = Vector3fImmutable.ZERO; @@ -608,10 +608,6 @@ public abstract class AbstractWorldObject extends AbstractGameObject { return gridObjectType; } - public Regions getRegion() { - return region; - } - public boolean isMovingUp() { return movingUp; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 053d62c3..941ead81 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -90,7 +90,6 @@ public class NPC extends AbstractCharacter { private String nameOverride = ""; private int equipmentSetID = 0; public int runeSetID = 0; - public Regions region = null; private int repairCost = 5; public int extraRune2 = 0; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index d107d479..f4543603 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2054,17 +2054,17 @@ public class PlayerCharacter extends AbstractCharacter { writer.putInt(playerCharacter.getHeadlightsAsInt()); - if (playerCharacter.getRegion() != null && !loginData){ - Building building = Regions.GetBuildingForRegion(playerCharacter.getRegion()); - - if (building == null){ + if (playerCharacter.region != null && !loginData) { + Building building = Regions.GetBuildingForRegion(playerCharacter.region); + + if (building == null) { writer.putInt(0); writer.putInt(0); - }else{ + } else { writer.putInt(GameObjectType.Building.ordinal()); writer.putInt(building.getObjectUUID()); } - + } else{ writer.putInt(0); diff --git a/src/engine/objects/Regions.java b/src/engine/objects/Regions.java index 0a910d8d..ea03ce64 100644 --- a/src/engine/objects/Regions.java +++ b/src/engine/objects/Regions.java @@ -216,42 +216,42 @@ public class Regions { public static boolean CanEnterRegion(AbstractWorldObject worldObject, Regions toEnter){ - if (worldObject.getRegion() == null) + if (worldObject.region == null) if (toEnter.level == 0 || toEnter.room == -1 || toEnter.exit) return true; else return false; - - if (worldObject.getRegion().equals(toEnter)) + + if (worldObject.region.equals(toEnter)) return true; - if (worldObject.getRegion().level == toEnter.level) + if (worldObject.region.level == toEnter.level) return true; - + //next region is stairs, if they are on the same level as stairs or 1 up, world object can enter. - if (toEnter.stairs) - if (worldObject.getRegion().level == toEnter.level || toEnter.level - 1 == worldObject.getRegion().level) + if (toEnter.stairs) + if (worldObject.region.level == toEnter.level || toEnter.level - 1 == worldObject.region.level) return true; - if (worldObject.getRegion().stairs){ - + if (worldObject.region.stairs) { + boolean movingUp = false; - + boolean movingDown = false; - float yLerp = worldObject.getRegion().lerpY(worldObject); - - if (yLerp == (worldObject.getRegion().highLerp.y)) + float yLerp = worldObject.region.lerpY(worldObject); + + if (yLerp == (worldObject.region.highLerp.y)) movingUp = true; - else if (yLerp == (worldObject.getRegion().lowLerp.y)) - movingDown = true; + else if (yLerp == (worldObject.region.lowLerp.y)) + movingDown = true; //Stairs are always considered on the bottom floor. - if (movingUp){ - if(toEnter.level == worldObject.getRegion().level + 1) - return true; - }else if (movingDown) - if (toEnter.level == worldObject.getRegion().level) - return true; + if (movingUp) { + if (toEnter.level == worldObject.region.level + 1) + return true; + } else if (movingDown) + if (toEnter.level == worldObject.region.level) + return true; } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 1725936d..15ea7046 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -621,16 +621,16 @@ public class WorldServer { playerCharacter.stopMovement(playerCharacter.getLoc()); UpdateStateMsg updateStateMsg = new UpdateStateMsg(); updateStateMsg.setPlayer(playerCharacter); - + updateStateMsg.setActivity(5); DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); - - if (playerCharacter.getRegion() != null) - if (PlayerCharacter.CanBindToBuilding(playerCharacter, playerCharacter.getRegion().parentBuildingID)) - playerCharacter.bindBuilding = playerCharacter.getRegion().parentBuildingID; + + if (playerCharacter.region != null) + if (PlayerCharacter.CanBindToBuilding(playerCharacter, playerCharacter.region.parentBuildingID)) + playerCharacter.bindBuilding = playerCharacter.region.parentBuildingID; else playerCharacter.bindBuilding = 0; - + playerCharacter.getLoadedObjects().clear(); playerCharacter.getLoadedStaticObjects().clear();