Browse Source

Duplicate region field removed and inlined.

master
MagicBot 2 years ago
parent
commit
e554171e22
  1. 22
      src/engine/devcmd/cmds/InfoCmd.java
  2. 10
      src/engine/devcmd/cmds/PrintLocationCmd.java
  3. 16
      src/engine/devcmd/cmds/RegionCmd.java
  4. 2
      src/engine/gameManager/BuildingManager.java
  5. 14
      src/engine/gameManager/MovementManager.java
  6. 6
      src/engine/jobs/FinishSummonsJob.java
  7. 4
      src/engine/math/Bounds.java
  8. 4
      src/engine/net/client/handlers/ChangeAltitudeHandler.java
  9. 8
      src/engine/net/client/msg/LoadCharacterMsg.java
  10. 10
      src/engine/net/client/msg/SendOwnPlayerMsg.java
  11. 11
      src/engine/net/client/msg/TeleportToPointMsg.java
  12. 6
      src/engine/objects/AbstractWorldObject.java
  13. 1
      src/engine/objects/NPC.java
  14. 8
      src/engine/objects/PlayerCharacter.java
  15. 32
      src/engine/objects/Regions.java
  16. 6
      src/engine/server/world/WorldServer.java

22
src/engine/devcmd/cmds/InfoCmd.java

@ -391,15 +391,15 @@ public class InfoCmd extends AbstractDevCmd {
} }
if (targetNPC.getRegion() != null){ if (targetNPC.region != null) {
output += newline; output += newline;
output += "BuildingID : " + targetNPC.getRegion().parentBuildingID; output += "BuildingID : " + targetNPC.region.parentBuildingID;
output += "building level : " + targetNPC.getRegion().level; output += "building level : " + targetNPC.region.level;
output += "building room : " + targetNPC.getRegion().room; output += "building room : " + targetNPC.region.room;
}else if(targetNPC.getBuilding() != null) { } else if (targetNPC.getBuilding() != null) {
output += newline; output += newline;
output += "Building : " + targetNPC.getBuilding(); output += "Building : " + targetNPC.getBuilding();
}else{ } else {
output += newline; output += newline;
output += "No building found."; output += "No building found.";
} }
@ -463,13 +463,13 @@ public class InfoCmd extends AbstractDevCmd {
output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum();
output += newline; output += newline;
output += "isMoving : " + targetMob.isMoving(); output += "isMoving : " + targetMob.isMoving();
if (targetMob.getRegion() != null){ if (targetMob.region != null) {
output += newline; output += newline;
output += "BuildingID : " + targetMob.getRegion().parentBuildingID; output += "BuildingID : " + targetMob.region.parentBuildingID;
output += "building level : " + targetMob.getRegion().level; output += "building level : " + targetMob.region.level;
output += "building room : " + targetMob.getRegion().room; output += "building room : " + targetMob.region.room;
} }
if(targetMob.building != null) { if (targetMob.building != null) {
output += "Building Name: " + targetMob.building.getName() + newline; output += "Building Name: " + targetMob.building.getName() + newline;
output += "BuildingID : " + targetMob.building + newline; output += "BuildingID : " + targetMob.building + newline;
output += "Bind Loc : " + targetMob.getBindLoc() + newline; output += "Bind Loc : " + targetMob.getBindLoc() + newline;

10
src/engine/devcmd/cmds/PrintLocationCmd.java

@ -40,11 +40,11 @@ public class PrintLocationCmd extends AbstractDevCmd {
throwbackInfo(pc, "Lat: " + tar.getLoc().getX()); throwbackInfo(pc, "Lat: " + tar.getLoc().getX());
throwbackInfo(pc, "Lon: " + -tar.getLoc().getZ()); throwbackInfo(pc, "Lon: " + -tar.getLoc().getZ());
throwbackInfo(pc, "Alt: " + tar.getLoc().getY()); throwbackInfo(pc, "Alt: " + tar.getLoc().getY());
if (pc.getRegion() != null) { if (pc.region != null) {
this.throwbackInfo(pc, "Player Region Slope Position : " + Regions.SlopeLerpPercent(pc, pc.getRegion())); this.throwbackInfo(pc, "Player Region Slope Position : " + Regions.SlopeLerpPercent(pc, pc.region));
this.throwbackInfo(pc, "Region Slope Magnitude : " + Regions.GetMagnitudeOfRegionSlope(pc.getRegion())); this.throwbackInfo(pc, "Region Slope Magnitude : " + Regions.GetMagnitudeOfRegionSlope(pc.region));
this.throwbackInfo(pc, "Player Region Slope Magnitude : " + Regions.GetMagnitudeOfPlayerOnRegionSlope(pc.getRegion(), pc)); this.throwbackInfo(pc, "Player Region Slope Magnitude : " + Regions.GetMagnitudeOfPlayerOnRegionSlope(pc.region, pc));
}else{ } else {
this.throwbackInfo(pc, "No Region Found for player."); this.throwbackInfo(pc, "No Region Found for player.");
} }

16
src/engine/devcmd/cmds/RegionCmd.java

@ -27,18 +27,18 @@ public class RegionCmd extends AbstractDevCmd {
AbstractGameObject target) { AbstractGameObject target) {
if (pc.getRegion() == null){ if (pc.region == null) {
this.throwbackInfo(pc, "No Region Found."); this.throwbackInfo(pc, "No Region Found.");
return; return;
} }
String newLine = System.getProperty("line.separator"); String newLine = System.getProperty("line.separator");
String result = ""; String result = "";
result+=(pc.getRegion().getClass().getSimpleName()); result += (pc.region.getClass().getSimpleName());
result+=( " {" ); result += (" {");
result+=(newLine); result+=(newLine);
Field[] fields = pc.getRegion().getClass().getDeclaredFields(); Field[] fields = pc.region.getClass().getDeclaredFields();
//print field names paired with their values //print field names paired with their values
for ( Field field : fields ) { for ( Field field : fields ) {
@ -51,7 +51,7 @@ public class RegionCmd extends AbstractDevCmd {
result+=( field.getName()); result+=( field.getName());
result+=(": "); result+=(": ");
//requires access to private field: //requires access to private field:
result+=( field.get(pc.getRegion()).toString()); result += (field.get(pc.region).toString());
} catch ( IllegalAccessException ex ) { } catch ( IllegalAccessException ex ) {
System.out.println(ex); System.out.println(ex);
} }

2
src/engine/gameManager/BuildingManager.java

@ -508,7 +508,7 @@ public enum BuildingManager {
mob.setRank(rank); mob.setRank(rank);
mob.setPlayerGuard(true); mob.setPlayerGuard(true);
mob.BehaviourType = Enum.MobBehaviourType.GuardWallArcher; mob.BehaviourType = Enum.MobBehaviourType.GuardWallArcher;
MovementManager.translocate(mob,mob.getBindLoc(),mob.getRegion()); MovementManager.translocate(mob, mob.getBindLoc(), mob.region);
return true; return true;
} }
if (NPC.ISGuardCaptain(contract.getContractID())) { if (NPC.ISGuardCaptain(contract.getContractID())) {

14
src/engine/gameManager/MovementManager.java

@ -174,18 +174,18 @@ public enum MovementManager {
msg.setSourceID(toMove.getObjectUUID()); msg.setSourceID(toMove.getObjectUUID());
//if player in region, modify location to local location of building. set target to building. //if player in region, modify location to local location of building. set target to building.
if (toMove.getRegion() != null){ if (toMove.region != null) {
Building regionBuilding = Regions.GetBuildingForRegion(toMove.getRegion()); Building regionBuilding = Regions.GetBuildingForRegion(toMove.region);
if (regionBuilding != null){ if (regionBuilding != null) {
msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.getRegion()), toMove.getLoc())); msg.setStartCoord(ZoneManager.convertWorldToLocal(Regions.GetBuildingForRegion(toMove.region), toMove.getLoc()));
msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation)); msg.setEndCoord(ZoneManager.convertWorldToLocal(regionBuilding, endLocation));
msg.setInBuilding(toMove.getRegion().level); msg.setInBuilding(toMove.region.level);
msg.setUnknown01(toMove.getRegion().room); msg.setUnknown01(toMove.region.room);
msg.setTargetType(GameObjectType.Building.ordinal()); msg.setTargetType(GameObjectType.Building.ordinal());
msg.setTargetID(regionBuilding.getObjectUUID()); msg.setTargetID(regionBuilding.getObjectUUID());
} }
}else{ } else {
toMove.setInBuildingID(0); toMove.setInBuildingID(0);
toMove.setInFloorID(-1); toMove.setInFloorID(-1);
toMove.setInBuilding(-1); toMove.setInBuilding(-1);

6
src/engine/jobs/FinishSummonsJob.java

@ -55,14 +55,14 @@ public class FinishSummonsJob extends AbstractScheduleJob {
return; 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.target, "You have been blocked from receiving summons!");
ErrorPopupMsg.sendErrorMsg(this.source, "Target is blocked from receiving summons!"); ErrorPopupMsg.sendErrorMsg(this.source, "Target is blocked from receiving summons!");
return; return;
} }
if (this.source.getRegion() != null) if (this.source.region != null)
this.target.setRegion(this.source.getRegion()); this.target.setRegion(this.source.region);
//teleport target to source //teleport target to source
target.teleport(source.getLoc()); target.teleport(source.getLoc());
} }

4
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. //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; continue;
if (building.getBounds().colliders == null) if (building.getBounds().colliders == null)
continue; continue;
@ -366,7 +366,7 @@ public class Bounds {
for (Colliders collider: building.getBounds().colliders) { 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. //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; continue;
if (collider.getDoorID() != 0 && building.isDoorOpen(collider.getDoorID())) if (collider.getDoorID() != 0 && building.isDoorOpen(collider.getDoorID()))
continue; continue;

4
src/engine/net/client/handlers/ChangeAltitudeHandler.java

@ -44,7 +44,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
if (pc.isSwimming()) if (pc.isSwimming())
return false; return false;
if (pc.getRegion() != null && !pc.getRegion().isOutside()) if (pc.region != null && !pc.region.isOutside())
return false; return false;
@ -79,7 +79,7 @@ public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
pc.landingRegion = null; pc.landingRegion = null;
if (pc.getAltitude() == 0){ if (pc.getAltitude() == 0){
Regions upRegion = pc.getRegion(); Regions upRegion = pc.region;
if (upRegion != null){ if (upRegion != null){
float startAlt = 0; float startAlt = 0;
Building regionBuilding = Regions.GetBuildingForRegion(upRegion); Building regionBuilding = Regions.GetBuildingForRegion(upRegion);

8
src/engine/net/client/msg/LoadCharacterMsg.java

@ -74,8 +74,8 @@ public class LoadCharacterMsg extends ClientNetMsg {
NPC npc = (NPC) absChar; NPC npc = (NPC) absChar;
if (npc.region != null) { if (npc.region != null) {
writer.putInt(npc.getRegion().getLevel()); writer.putInt(npc.region.getLevel());
writer.putInt(npc.getRegion().getRoom()); writer.putInt(npc.region.getRoom());
} else { } else {
writer.putInt(-1); writer.putInt(-1);
writer.putInt(-1); writer.putInt(-1);
@ -85,7 +85,7 @@ public class LoadCharacterMsg extends ClientNetMsg {
} else if (absChar != null) { } else if (absChar != null) {
if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter)) { if (absChar.getObjectType().equals(GameObjectType.PlayerCharacter)) {
Regions region = absChar.getRegion(); Regions region = absChar.region;
if (region == null) { if (region == null) {
writer.putInt(-1); writer.putInt(-1);
@ -102,7 +102,7 @@ public class LoadCharacterMsg extends ClientNetMsg {
} }
} }
else if (absChar.getObjectType().equals(GameObjectType.Mob)){ else if (absChar.getObjectType().equals(GameObjectType.Mob)){
Regions region = absChar.getRegion(); Regions region = absChar.region;
if (region == null){ if (region == null){
writer.putInt(-1); writer.putInt(-1);

10
src/engine/net/client/msg/SendOwnPlayerMsg.java

@ -75,17 +75,17 @@ public class SendOwnPlayerMsg extends ClientNetMsg {
@Override @Override
protected void _serialize(ByteBufferWriter writer) { 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. //region loading seralization. serialzes building level and floor. -1 = not in building.
if (region == null){ if (region == null) {
writer.putInt(-1); writer.putInt(-1);
writer.putInt(-1); writer.putInt(-1);
}else{ } else {
Building regionBuilding = Regions.GetBuildingForRegion(region); Building regionBuilding = Regions.GetBuildingForRegion(region);
if (regionBuilding == null){ if (regionBuilding == null) {
writer.putInt(-1); writer.putInt(-1);
writer.putInt(-1); writer.putInt(-1);
}else{ } else {
writer.putInt(region.getLevel()); writer.putInt(region.getLevel());
writer.putInt(region.getRoom()); writer.putInt(region.getRoom());
} }

11
src/engine/net/client/msg/TeleportToPointMsg.java

@ -42,21 +42,20 @@ public class TeleportToPointMsg extends ClientNetMsg {
if (targetID != 0){ if (targetID != 0){
this.targetType = GameObjectType.Building.ordinal(); this.targetType = GameObjectType.Building.ordinal();
this.targetUUID = (int) targetID; this.targetUUID = (int) targetID;
}else{ } else {
this.targetType = 0; this.targetType = 0;
this.targetUUID = 0; this.targetUUID = 0;
} }
this.unknown01 = unknown01; this.unknown01 = unknown01;
this.unknown02 = unknown02; this.unknown02 = unknown02;
if (ago.getRegion() != null){ if (ago.region != null) {
this.targetType = GameObjectType.Building.ordinal(); this.targetType = GameObjectType.Building.ordinal();
this.targetUUID = ago.getRegion().parentBuildingID; this.targetUUID = ago.region.parentBuildingID;
this.unknown01 = ago.getRegion().level; this.unknown01 = ago.region.level;
this.unknown02 = ago.getRegion().room; this.unknown02 = ago.region.room;
} }
} }

6
src/engine/objects/AbstractWorldObject.java

@ -60,7 +60,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
protected GridObjectType gridObjectType; protected GridObjectType gridObjectType;
protected float altitude = 0; protected float altitude = 0;
protected Regions region; public Regions region;
protected boolean movingUp = false; protected boolean movingUp = false;
public Regions landingRegion = null; public Regions landingRegion = null;
public Vector3fImmutable lastLoc = Vector3fImmutable.ZERO; public Vector3fImmutable lastLoc = Vector3fImmutable.ZERO;
@ -608,10 +608,6 @@ public abstract class AbstractWorldObject extends AbstractGameObject {
return gridObjectType; return gridObjectType;
} }
public Regions getRegion() {
return region;
}
public boolean isMovingUp() { public boolean isMovingUp() {
return movingUp; return movingUp;

1
src/engine/objects/NPC.java

@ -90,7 +90,6 @@ public class NPC extends AbstractCharacter {
private String nameOverride = ""; private String nameOverride = "";
private int equipmentSetID = 0; private int equipmentSetID = 0;
public int runeSetID = 0; public int runeSetID = 0;
public Regions region = null;
private int repairCost = 5; private int repairCost = 5;
public int extraRune2 = 0; public int extraRune2 = 0;

8
src/engine/objects/PlayerCharacter.java

@ -2054,13 +2054,13 @@ public class PlayerCharacter extends AbstractCharacter {
writer.putInt(playerCharacter.getHeadlightsAsInt()); writer.putInt(playerCharacter.getHeadlightsAsInt());
if (playerCharacter.getRegion() != null && !loginData){ if (playerCharacter.region != null && !loginData) {
Building building = Regions.GetBuildingForRegion(playerCharacter.getRegion()); Building building = Regions.GetBuildingForRegion(playerCharacter.region);
if (building == null){ if (building == null) {
writer.putInt(0); writer.putInt(0);
writer.putInt(0); writer.putInt(0);
}else{ } else {
writer.putInt(GameObjectType.Building.ordinal()); writer.putInt(GameObjectType.Building.ordinal());
writer.putInt(building.getObjectUUID()); writer.putInt(building.getObjectUUID());
} }

32
src/engine/objects/Regions.java

@ -216,42 +216,42 @@ public class Regions {
public static boolean CanEnterRegion(AbstractWorldObject worldObject, Regions toEnter){ 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) if (toEnter.level == 0 || toEnter.room == -1 || toEnter.exit)
return true; return true;
else else
return false; return false;
if (worldObject.getRegion().equals(toEnter)) if (worldObject.region.equals(toEnter))
return true; return true;
if (worldObject.getRegion().level == toEnter.level) if (worldObject.region.level == toEnter.level)
return true; return true;
//next region is stairs, if they are on the same level as stairs or 1 up, world object can enter. //next region is stairs, if they are on the same level as stairs or 1 up, world object can enter.
if (toEnter.stairs) if (toEnter.stairs)
if (worldObject.getRegion().level == toEnter.level || toEnter.level - 1 == worldObject.getRegion().level) if (worldObject.region.level == toEnter.level || toEnter.level - 1 == worldObject.region.level)
return true; return true;
if (worldObject.getRegion().stairs){ if (worldObject.region.stairs) {
boolean movingUp = false; boolean movingUp = false;
boolean movingDown = false; boolean movingDown = false;
float yLerp = worldObject.getRegion().lerpY(worldObject); float yLerp = worldObject.region.lerpY(worldObject);
if (yLerp == (worldObject.getRegion().highLerp.y)) if (yLerp == (worldObject.region.highLerp.y))
movingUp = true; movingUp = true;
else if (yLerp == (worldObject.getRegion().lowLerp.y)) else if (yLerp == (worldObject.region.lowLerp.y))
movingDown = true; movingDown = true;
//Stairs are always considered on the bottom floor. //Stairs are always considered on the bottom floor.
if (movingUp){ if (movingUp) {
if(toEnter.level == worldObject.getRegion().level + 1) if (toEnter.level == worldObject.region.level + 1)
return true; return true;
}else if (movingDown) } else if (movingDown)
if (toEnter.level == worldObject.getRegion().level) if (toEnter.level == worldObject.region.level)
return true; return true;
} }

6
src/engine/server/world/WorldServer.java

@ -625,9 +625,9 @@ public class WorldServer {
updateStateMsg.setActivity(5); updateStateMsg.setActivity(5);
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); DispatchMessage.dispatchMsgToInterestArea(playerCharacter, updateStateMsg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
if (playerCharacter.getRegion() != null) if (playerCharacter.region != null)
if (PlayerCharacter.CanBindToBuilding(playerCharacter, playerCharacter.getRegion().parentBuildingID)) if (PlayerCharacter.CanBindToBuilding(playerCharacter, playerCharacter.region.parentBuildingID))
playerCharacter.bindBuilding = playerCharacter.getRegion().parentBuildingID; playerCharacter.bindBuilding = playerCharacter.region.parentBuildingID;
else else
playerCharacter.bindBuilding = 0; playerCharacter.bindBuilding = 0;

Loading…
Cancel
Save