From 847e62dd27c166afac788cecaed078dbc24a8682 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 19:51:39 -0500 Subject: [PATCH 001/289] setLoc now handles region assignment --- src/engine/objects/AbstractCharacter.java | 12 ++++++++++-- src/engine/objects/AbstractWorldObject.java | 3 --- src/engine/objects/Mob.java | 4 ---- src/engine/objects/PlayerCharacter.java | 3 --- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index cbbb88f3..9a60e116 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -983,8 +983,16 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { - super.setLoc(value); // set the location in the world - this.resetLastSetLocUpdate(); + Regions region = Regions.GetRegionForTeleport(value); + if(region != null){ + this.region = region; + Vector3fImmutable newValue = new Vector3fImmutable(value.x,region.lerpY(this),value.z); + super.setLoc(newValue); // set the location in the world + this.resetLastSetLocUpdate(); + } else { + super.setLoc(value); // set the location in the world + this.resetLastSetLocUpdate(); + } } public Vector3fImmutable getMovementLoc() { diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 4525dc65..0ea3c6b4 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -610,9 +610,6 @@ public abstract class AbstractWorldObject extends AbstractGameObject { this.movingUp = movingUp; } - public void setRegion(Regions region) { - this.region = region; - } //used for interestmanager loading and unloading objects to client. // if not in grid, unload from player. diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 97c08b4c..311839ea 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -841,13 +841,11 @@ public class Mob extends AbstractIntelligenceAgent { if (newLoc.equals(this.getEndLoc())) { this.stopMovement(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); return; //Next upda } setLoc(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); //Next update will be end Loc, lets stop him here. } @@ -971,8 +969,6 @@ public class Mob extends AbstractIntelligenceAgent { if (this.building == null && this.guardCaptain != null && ((Mob) this.guardCaptain).behaviourType.equals(MobBehaviourType.GuardCaptain)) this.building = this.guardCaptain.building; - else if (this.building != null) - this.region = BuildingManager.GetRegion(this.building, bindLoc.x, bindLoc.y, bindLoc.z); this.loadInventory(); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index cc09fd56..cd24f990 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4888,12 +4888,10 @@ public class PlayerCharacter extends AbstractCharacter { if (this.isAlive() == false || this.getBonuses().getBool(ModType.Stunned, SourceType.None) || this.getBonuses().getBool(ModType.CannotMove, SourceType.None)) { //Target is stunned or rooted. Don't move this.stopMovement(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); return; } if (newLoc.equals(this.getEndLoc())) { this.stopMovement(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); if (this.getDebug(1)) ChatManager.chatSystemInfo(this, "Arrived at End location. " + this.getEndLoc()); @@ -4902,7 +4900,6 @@ public class PlayerCharacter extends AbstractCharacter { } setLoc(newLoc); - this.region = AbstractWorldObject.GetRegionByWorldObject(this); if (this.getDebug(1)) ChatManager.chatSystemInfo(this, From e23c5527dac526a5025e1542daca82767af36730 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 19:52:17 -0500 Subject: [PATCH 002/289] null region assignment --- src/engine/objects/AbstractCharacter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 9a60e116..6bed2b27 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -990,6 +990,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { super.setLoc(newValue); // set the location in the world this.resetLastSetLocUpdate(); } else { + this.region = null; super.setLoc(value); // set the location in the world this.resetLastSetLocUpdate(); } From b34be1184eb228bd637483f9e825ccc3dedb6252 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 19:53:13 -0500 Subject: [PATCH 003/289] null region assignment --- src/engine/objects/AbstractCharacter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 6bed2b27..a2fbd429 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -986,7 +986,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { Regions region = Regions.GetRegionForTeleport(value); if(region != null){ this.region = region; - Vector3fImmutable newValue = new Vector3fImmutable(value.x,region.lerpY(this),value.z); + Vector3fImmutable newValue = new Vector3fImmutable(value.x,region.lerpY(this),value.z); //account for height offset of the current character region super.setLoc(newValue); // set the location in the world this.resetLastSetLocUpdate(); } else { From a313e3f3646bd1ea0a9010acd1289e58a6c010bf Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 19:56:54 -0500 Subject: [PATCH 004/289] setRegion removal --- src/engine/gameManager/MovementManager.java | 3 +-- src/engine/jobs/FinishSummonsJob.java | 2 -- src/engine/mobileAI/MobAI.java | 2 +- .../net/client/handlers/RequestEnterWorldHandler.java | 1 - src/engine/objects/AbstractCharacter.java | 6 ++---- src/engine/objects/PlayerCharacter.java | 3 +-- src/engine/powers/poweractions/MobRecallPowerAction.java | 2 +- src/engine/powers/poweractions/RecallPowerAction.java | 2 +- src/engine/powers/poweractions/TeleportPowerAction.java | 2 +- 9 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index a602169f..6bc4ced5 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -464,7 +464,7 @@ public enum MovementManager { } } - public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) { + public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc) { if (targetLoc == null) @@ -473,7 +473,6 @@ public enum MovementManager { Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc()); teleporter.stopMovement(targetLoc); - teleporter.setRegion(region); //mobs ignore region sets for now. if (teleporter.getObjectType().equals(GameObjectType.Mob)) { diff --git a/src/engine/jobs/FinishSummonsJob.java b/src/engine/jobs/FinishSummonsJob.java index 0ee0fc68..3c0c269a 100644 --- a/src/engine/jobs/FinishSummonsJob.java +++ b/src/engine/jobs/FinishSummonsJob.java @@ -61,8 +61,6 @@ public class FinishSummonsJob extends AbstractScheduleJob { return; } - if (this.source.region != null) - this.target.setRegion(this.source.region); //teleport target to source target.teleport(source.getLoc()); } diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 8b710e4b..10696af9 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -736,7 +736,7 @@ public class MobAI { //mob no longer has its owner loaded, translate pet to owner if (!mob.playerAgroMap.containsKey(mob.guardCaptain.getObjectUUID())) { - MovementManager.translocate(mob, mob.guardCaptain.getLoc(), null); + MovementManager.translocate(mob, mob.guardCaptain.getLoc()); return; } diff --git a/src/engine/net/client/handlers/RequestEnterWorldHandler.java b/src/engine/net/client/handlers/RequestEnterWorldHandler.java index 18b48254..e1654e6b 100644 --- a/src/engine/net/client/handlers/RequestEnterWorldHandler.java +++ b/src/engine/net/client/handlers/RequestEnterWorldHandler.java @@ -110,7 +110,6 @@ public class RequestEnterWorldHandler extends AbstractClientMsgHandler { player.stopMovement(player.getBindLoc()); player.setSafeMode(); player.updateLocation(); - player.setRegion(AbstractWorldObject.GetRegionByWorldObject(player)); } player.setTimeStamp("logout", 0); diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index a2fbd429..1017e337 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -512,10 +512,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } public static void teleport(AbstractCharacter worldObject, final Vector3fImmutable targetLoc) { - Regions targetRegion = Regions.GetRegionForTeleport(targetLoc); worldObject.locationLock.writeLock().lock(); try { - MovementManager.translocate(worldObject, targetLoc, targetRegion); + MovementManager.translocate(worldObject, targetLoc); if (worldObject.getObjectType().equals(GameObjectType.PlayerCharacter)) InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) worldObject); } catch (Exception e) { @@ -1458,10 +1457,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject { } public void teleport(final Vector3fImmutable targetLoc) { - Regions targetRegion = Regions.GetRegionForTeleport(targetLoc); locationLock.writeLock().lock(); try { - MovementManager.translocate(this, targetLoc, targetRegion); + MovementManager.translocate(this, targetLoc); MovementManager.sendRWSSMsg(this); } catch (Exception e) { Logger.error(e); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index cd24f990..32a536bc 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -5472,11 +5472,10 @@ public class PlayerCharacter extends AbstractCharacter { @Override public final void teleport(final Vector3fImmutable targetLoc) { - Regions targetRegion = Regions.GetRegionForTeleport(targetLoc); locationLock.writeLock().lock(); try { - MovementManager.translocate(this, targetLoc, targetRegion); + MovementManager.translocate(this, targetLoc); } catch (Exception e) { Logger.error(e); } finally { diff --git a/src/engine/powers/poweractions/MobRecallPowerAction.java b/src/engine/powers/poweractions/MobRecallPowerAction.java index d5318fcf..44fb93e8 100644 --- a/src/engine/powers/poweractions/MobRecallPowerAction.java +++ b/src/engine/powers/poweractions/MobRecallPowerAction.java @@ -38,7 +38,7 @@ public class MobRecallPowerAction extends AbstractPowerAction { return; - MovementManager.translocate(awoac, awoac.getBindLoc(), null); + MovementManager.translocate(awoac, awoac.getBindLoc()); if (awoac.getObjectType() == GameObjectType.Mob) { //MobAI.setAwake((Mob)awoac,true); ((Mob) awoac).setCombatTarget(null); diff --git a/src/engine/powers/poweractions/RecallPowerAction.java b/src/engine/powers/poweractions/RecallPowerAction.java index c0ffb409..8a0f6050 100644 --- a/src/engine/powers/poweractions/RecallPowerAction.java +++ b/src/engine/powers/poweractions/RecallPowerAction.java @@ -58,7 +58,7 @@ public class RecallPowerAction extends AbstractPowerAction { DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY); } else { - MovementManager.translocate(awoac, awoac.getBindLoc(), null); + MovementManager.translocate(awoac, awoac.getBindLoc()); } } else { Vector3fImmutable bindloc = awoac.getBindLoc(); diff --git a/src/engine/powers/poweractions/TeleportPowerAction.java b/src/engine/powers/poweractions/TeleportPowerAction.java index 36eed471..5f0c6e31 100644 --- a/src/engine/powers/poweractions/TeleportPowerAction.java +++ b/src/engine/powers/poweractions/TeleportPowerAction.java @@ -101,7 +101,7 @@ public class TeleportPowerAction extends AbstractPowerAction { if (region != null && !region.isOutside()) return; - MovementManager.translocate(awoac, targetLoc, region); + MovementManager.translocate(awoac, targetLoc); } @Override From c215047c00f89b89d1a8240102c9463fe57427b7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:00:23 -0500 Subject: [PATCH 005/289] teleport method removed form PLayerCharacter to use AbstractCharacter.teleport instead --- src/engine/objects/PlayerCharacter.java | 38 ------------------------- 1 file changed, 38 deletions(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 32a536bc..b99f5e62 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -120,7 +120,6 @@ public class PlayerCharacter extends AbstractCharacter { protected ArrayList runes; private BaseClass baseClass; private PromotionClass promotionClass; - private long channelMute = 0; // none muted. private ConcurrentHashMap ignoredPlayerIDs = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private boolean lfGroup = false; private boolean lfGuild = false; @@ -5433,14 +5432,6 @@ public class PlayerCharacter extends AbstractCharacter { return characterHeight; } - public void setCharacterHeight(float characterHeight) { - this.characterHeight = characterHeight; - } - - public void setCenterHeight(float centerHeight) { - this.centerHeight = centerHeight; - } - public boolean isEnteredWorld() { return enteredWorld; } @@ -5449,39 +5440,10 @@ public class PlayerCharacter extends AbstractCharacter { this.enteredWorld = enteredWorld; } - public long getChannelMute() { - return channelMute; - } - - public void setChannelMute(long channelMute) { - this.channelMute = channelMute; - } - public boolean isLastSwimming() { return lastSwimming; } - public boolean isTeleporting() { - return isTeleporting; - } - - public void setTeleporting(boolean isTeleporting) { - this.isTeleporting = isTeleporting; - } - - @Override - public final void teleport(final Vector3fImmutable targetLoc) { - - locationLock.writeLock().lock(); - - try { - MovementManager.translocate(this, targetLoc); - } catch (Exception e) { - Logger.error(e); - } finally { - locationLock.writeLock().unlock(); - } - } public ReadWriteLock getTeleportLock() { return teleportLock; From f8269bb7647b3e23c77db4a7fe493ffacc0536d8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:06:12 -0500 Subject: [PATCH 006/289] character runes moved form PlayerCharacter to AbstractCharacter --- src/engine/objects/AbstractCharacter.java | 2 ++ src/engine/objects/PlayerCharacter.java | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 1017e337..2574e3ad 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -121,6 +121,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public int hidden = 0; // current rank of hide/sneak/invis public CopyOnWriteArrayList minions = new CopyOnWriteArrayList(); + protected ArrayList runes; + public AbstractCharacter() { super(); this.firstName = ""; diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index b99f5e62..69cee884 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -117,7 +117,6 @@ public class PlayerCharacter extends AbstractCharacter { public float landingAltitude = 0; public int bindBuilding = 0; public FriendStatus friendStatus = FriendStatus.Available; - protected ArrayList runes; private BaseClass baseClass; private PromotionClass promotionClass; private ConcurrentHashMap ignoredPlayerIDs = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); From bd9dbcbb42dc72854cfdf406a534d884a32c7636 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:12:07 -0500 Subject: [PATCH 007/289] NPCs load rune sets --- src/engine/gameManager/NPCManager.java | 7 +++++++ src/engine/objects/AbstractCharacter.java | 2 +- src/engine/objects/NPC.java | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index bd5a4ce4..e53a0332 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -458,4 +458,11 @@ public enum NPCManager { mob.skills.put(entry.skill_type, new CharacterSkill(skillBase, mob, entry.rank + mob.skills.get(entry.skill_type).getNumTrains())); } } + + public static void applyRunesForNPC(NPC npc){ + for(int runeID : _runeSetMap.get(npc.runeSetID)){ + RuneBase rb = RuneBase.getRuneBase(runeID); + npc.runes.add(new CharacterRune(rb,npc.getObjectUUID())); + } + } } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 2574e3ad..31b77ca5 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -121,7 +121,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public int hidden = 0; // current rank of hide/sneak/invis public CopyOnWriteArrayList minions = new CopyOnWriteArrayList(); - protected ArrayList runes; + public ArrayList runes; public AbstractCharacter() { super(); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 88bb5a11..61eb24d5 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -972,6 +972,11 @@ public class NPC extends AbstractCharacter { Bounds npcBounds = Bounds.borrow(); npcBounds.setBounds(this.getLoc()); + //apply NPC rune effects + if(NPCManager._runeSetMap.containsKey(this.runeSetID)){ + NPCManager.applyRunesForNPC(this); + } + } catch (Exception e) { Logger.error(e.getMessage()); } From 5a9f5f2ecac5c5e56f9117a9acd3613449d46dad Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:22:56 -0500 Subject: [PATCH 008/289] NPCs apply runes from set --- src/engine/gameManager/NPCManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index e53a0332..43dddeea 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -462,7 +462,13 @@ public enum NPCManager { public static void applyRunesForNPC(NPC npc){ for(int runeID : _runeSetMap.get(npc.runeSetID)){ RuneBase rb = RuneBase.getRuneBase(runeID); - npc.runes.add(new CharacterRune(rb,npc.getObjectUUID())); + CharacterRune toApply = new CharacterRune(rb,npc.getObjectUUID()); + npc.runes.add(toApply); + EffectsBase effectsBase; + for(MobBaseEffects effect : toApply.getRuneBase().getEffectsList()){ + effectsBase = PowersManager.getEffectByToken(effect.getToken()); + npc.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, effect.getRank(), true); + } } } } From 96bc894962a018423696244875ffb828450c2702 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:27:38 -0500 Subject: [PATCH 009/289] print runes command --- src/engine/devcmd/cmds/PrintRunesCmd.java | 67 +++++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 1 + 2 files changed, 68 insertions(+) create mode 100644 src/engine/devcmd/cmds/PrintRunesCmd.java diff --git a/src/engine/devcmd/cmds/PrintRunesCmd.java b/src/engine/devcmd/cmds/PrintRunesCmd.java new file mode 100644 index 00000000..45b19d44 --- /dev/null +++ b/src/engine/devcmd/cmds/PrintRunesCmd.java @@ -0,0 +1,67 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.devcmd.AbstractDevCmd; +import engine.objects.*; + +import java.util.HashMap; + +/** + * + */ + +public class PrintRunesCmd extends AbstractDevCmd { + + public PrintRunesCmd() { + super("printrunes"); + // super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN); + } + + public static ItemBase getWeaponBase(int slot, HashMap equip) { + if (equip.containsKey(slot)) { + MobEquipment item = equip.get(slot); + if (item != null && item.getItemBase() != null) { + return item.getItemBase(); + } + } + return null; + } + + @Override + protected void _doCmd(PlayerCharacter pc, String[] words, + AbstractGameObject target) { + + AbstractCharacter tar; + + if (target != null && target instanceof AbstractCharacter) { + tar = (AbstractCharacter) target; + + String newline = "\r\n "; + String output = "Applied Runes For Character: " + ((AbstractCharacter) target).getName() + newline; + + for(CharacterRune rune : ((AbstractCharacter)target).runes){ + output += rune.getRuneBaseID() + " " + rune.getRuneBase().getName() + newline; + } + throwbackInfo(pc, output); + } + } + + @Override + protected String _getHelpString() { + return "Returns the player's current stats"; + } + + @Override + protected String _getUsageString() { + return "' /printstats'"; + } + +} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 30bc4b2e..2b66f1b7 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -49,6 +49,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new PrintEquipCmd()); DevCmdManager.registerDevCmd(new PrintInventoryCmd()); DevCmdManager.registerDevCmd(new PrintVaultCmd()); + DevCmdManager.registerDevCmd(new PrintRunesCmd()); DevCmdManager.registerDevCmd(new PrintStatsCmd()); DevCmdManager.registerDevCmd(new PrintSkillsCmd()); DevCmdManager.registerDevCmd(new PrintPowersCmd()); From 8869772fa4fd27ab5d1f0ea1ea1bd6fe66ac213c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:34:48 -0500 Subject: [PATCH 010/289] print effects command --- src/engine/devcmd/cmds/PrintEffectsCmd.java | 67 +++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 1 + 2 files changed, 68 insertions(+) create mode 100644 src/engine/devcmd/cmds/PrintEffectsCmd.java diff --git a/src/engine/devcmd/cmds/PrintEffectsCmd.java b/src/engine/devcmd/cmds/PrintEffectsCmd.java new file mode 100644 index 00000000..89bddecb --- /dev/null +++ b/src/engine/devcmd/cmds/PrintEffectsCmd.java @@ -0,0 +1,67 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.devcmd.AbstractDevCmd; +import engine.objects.*; + +import java.util.HashMap; + +/** + * + */ + +public class PrintEffectsCmd extends AbstractDevCmd { + + public PrintEffectsCmd() { + super("printeffects"); + // super("printstats", MBServerStatics.ACCESS_LEVEL_ADMIN); + } + + public static ItemBase getWeaponBase(int slot, HashMap equip) { + if (equip.containsKey(slot)) { + MobEquipment item = equip.get(slot); + if (item != null && item.getItemBase() != null) { + return item.getItemBase(); + } + } + return null; + } + + @Override + protected void _doCmd(PlayerCharacter pc, String[] words, + AbstractGameObject target) { + + AbstractCharacter tar; + + if (target != null && target instanceof AbstractCharacter) { + tar = (AbstractCharacter) target; + + String newline = "\r\n "; + String output = "Applied Runes For Character: " + tar.getName() + newline; + + for(String effect : tar.effects.keySet()){ + output += effect + newline; + } + throwbackInfo(pc, output); + } + } + + @Override + protected String _getHelpString() { + return "Returns the player's current stats"; + } + + @Override + protected String _getUsageString() { + return "' /printstats'"; + } + +} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 2b66f1b7..803ad944 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -46,6 +46,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new GetZoneCmd()); DevCmdManager.registerDevCmd(new ZoneSetCmd()); DevCmdManager.registerDevCmd(new PrintBankCmd()); + DevCmdManager.registerDevCmd(new PrintEffectsCmd()); DevCmdManager.registerDevCmd(new PrintEquipCmd()); DevCmdManager.registerDevCmd(new PrintInventoryCmd()); DevCmdManager.registerDevCmd(new PrintVaultCmd()); From 1fdd0a1b322d11f09650c2f395c4c5aadd128771 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:45:21 -0500 Subject: [PATCH 011/289] initialize runes array list for NPC --- src/engine/devcmd/cmds/PrintEffectsCmd.java | 2 +- src/engine/gameManager/NPCManager.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/PrintEffectsCmd.java b/src/engine/devcmd/cmds/PrintEffectsCmd.java index 89bddecb..6f810012 100644 --- a/src/engine/devcmd/cmds/PrintEffectsCmd.java +++ b/src/engine/devcmd/cmds/PrintEffectsCmd.java @@ -45,7 +45,7 @@ public class PrintEffectsCmd extends AbstractDevCmd { tar = (AbstractCharacter) target; String newline = "\r\n "; - String output = "Applied Runes For Character: " + tar.getName() + newline; + String output = "Effects For Character: " + tar.getName() + newline; for(String effect : tar.effects.keySet()){ output += effect + newline; diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 43dddeea..e86ab3c5 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -460,6 +460,7 @@ public enum NPCManager { } public static void applyRunesForNPC(NPC npc){ + npc.runes = new ArrayList<>(); for(int runeID : _runeSetMap.get(npc.runeSetID)){ RuneBase rb = RuneBase.getRuneBase(runeID); CharacterRune toApply = new CharacterRune(rb,npc.getObjectUUID()); From 200318ddcfc0db02c3e7c5e054e09ef87a01d85a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 20:48:02 -0500 Subject: [PATCH 012/289] add region height to world height in setLoc --- src/engine/objects/AbstractCharacter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 31b77ca5..d5da6a61 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -987,7 +987,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { Regions region = Regions.GetRegionForTeleport(value); if(region != null){ this.region = region; - Vector3fImmutable newValue = new Vector3fImmutable(value.x,region.lerpY(this),value.z); //account for height offset of the current character region + Vector3fImmutable newValue = new Vector3fImmutable(value.x,value.y + region.lerpY(this),value.z); //account for height offset of the current character region super.setLoc(newValue); // set the location in the world this.resetLastSetLocUpdate(); } else { From 9b7fc0a93bbdf32ff413530193cb5da572e5d5f3 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 21:07:57 -0500 Subject: [PATCH 013/289] region height work --- src/engine/devcmd/cmds/RegionCmd.java | 41 +++++------------------ src/engine/objects/AbstractCharacter.java | 4 ++- src/engine/objects/Mob.java | 3 +- src/engine/objects/NPC.java | 2 +- 4 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index ca19fd25..b7b12c7e 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -9,9 +9,9 @@ package engine.devcmd.cmds; +import engine.Enum; import engine.devcmd.AbstractDevCmd; -import engine.objects.AbstractGameObject; -import engine.objects.PlayerCharacter; +import engine.objects.*; import java.lang.reflect.Field; @@ -25,42 +25,17 @@ public class RegionCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { - - if (pc.region == null) { + Regions region = ((AbstractCharacter)target).region; + if (region == null) { this.throwbackInfo(pc, "No Region Found."); return; } - - String newLine = System.getProperty("line.separator"); - String result = ""; - result += (pc.region.getClass().getSimpleName()); - result += (" {"); - result += (newLine); - Field[] fields = pc.region.getClass().getDeclaredFields(); - - //print field names paired with their values - for (Field field : fields) { - field.setAccessible(true); - result += (" "); - try { - - if (field.getName().contains("Furniture")) - continue; - result += (field.getName()); - result += (": "); - //requires access to private field: - result += (field.get(pc.region).toString()); - } catch (IllegalAccessException ex) { - System.out.println(ex); - } - result.trim(); - result += (newLine); + if(region != null) { + this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName()); + this.throwbackInfo(pc, "Region Name: " + region); + this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target)); } - result += ("}"); - - this.throwbackInfo(pc, result.toString()); - } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index d5da6a61..f74f1a66 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -11,6 +11,7 @@ package engine.objects; import engine.Enum; import engine.Enum.*; +import engine.InterestManagement.HeightMap; import engine.InterestManagement.InterestManager; import engine.InterestManagement.WorldGrid; import engine.exception.SerializationException; @@ -986,8 +987,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject { public final void setLoc(final Vector3fImmutable value) { Regions region = Regions.GetRegionForTeleport(value); if(region != null){ + float regionHeight = region.lerpY(this); this.region = region; - Vector3fImmutable newValue = new Vector3fImmutable(value.x,value.y + region.lerpY(this),value.z); //account for height offset of the current character region + Vector3fImmutable newValue = new Vector3fImmutable(value.x,regionHeight,value.z); //account for height offset of the current character region super.setLoc(newValue); // set the location in the world this.resetLastSetLocUpdate(); } else { diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 311839ea..a7528f9e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1649,7 +1649,7 @@ public class Mob extends AbstractIntelligenceAgent { // Setup location for this Mobile - this.loc = new Vector3fImmutable(bindLoc); + this.setLoc(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc); // Initialize inventory @@ -1743,6 +1743,7 @@ public class Mob extends AbstractIntelligenceAgent { this.level = (short) newRank; this.recalculateStats(); this.setHealth(this.healthMax); + this.setLoc(this.bindLoc); } public boolean isRanking() { diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 61eb24d5..10d8884f 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -865,7 +865,7 @@ public class NPC extends AbstractCharacter { this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); - this.loc = new Vector3fImmutable(bindLoc); + this.setLoc(bindLoc); // Handle NPCs within buildings From 7654d5183ae8e6d8a2c237a417dc49e80c9edcec Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 21:28:20 -0500 Subject: [PATCH 014/289] region lookup and height offset for AbstractCharacters when setLoc is called --- src/engine/objects/AbstractWorldObject.java | 8 +++++++- src/engine/objects/Mob.java | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index 0ea3c6b4..cb647707 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -502,7 +502,13 @@ public abstract class AbstractWorldObject extends AbstractGameObject { return; this.lastLoc = new Vector3fImmutable(this.loc); this.loc = loc; - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + + if(this instanceof AbstractCharacter && this.region != null){ + this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude()); + } else{ + this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + } + //lets not add mob to world grid if he is currently despawned. if (this.getObjectType().equals(GameObjectType.Mob) && ((Mob) this).despawned) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index a7528f9e..532a6aeb 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1743,7 +1743,6 @@ public class Mob extends AbstractIntelligenceAgent { this.level = (short) newRank; this.recalculateStats(); this.setHealth(this.healthMax); - this.setLoc(this.bindLoc); } public boolean isRanking() { From c1498145e6460d615ce8bdd9dc7ff1f97d086c31 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 21:45:15 -0500 Subject: [PATCH 015/289] NPC rune work --- src/engine/gameManager/NPCManager.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index e86ab3c5..76112b05 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -465,11 +465,6 @@ public enum NPCManager { RuneBase rb = RuneBase.getRuneBase(runeID); CharacterRune toApply = new CharacterRune(rb,npc.getObjectUUID()); npc.runes.add(toApply); - EffectsBase effectsBase; - for(MobBaseEffects effect : toApply.getRuneBase().getEffectsList()){ - effectsBase = PowersManager.getEffectByToken(effect.getToken()); - npc.addEffectNoTimer(Integer.toString(effectsBase.getUUID()), effectsBase, effect.getRank(), true); - } } } } From 048e90fb8f5437faa27fda708a06fed44e468e3a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 21:56:18 -0500 Subject: [PATCH 016/289] NPC all apply "shopkeeper" rune --- src/engine/gameManager/NPCManager.java | 13 +++++++++---- src/engine/objects/NPC.java | 4 +--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 76112b05..da125cd9 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -461,10 +461,15 @@ public enum NPCManager { public static void applyRunesForNPC(NPC npc){ npc.runes = new ArrayList<>(); - for(int runeID : _runeSetMap.get(npc.runeSetID)){ - RuneBase rb = RuneBase.getRuneBase(runeID); - CharacterRune toApply = new CharacterRune(rb,npc.getObjectUUID()); - npc.runes.add(toApply); + RuneBase shopkeeperBase = RuneBase.getRuneBase(252620); + CharacterRune shopkeeper = new CharacterRune(shopkeeperBase,npc.getObjectUUID()); + npc.runes.add(shopkeeper); + if(NPCManager._runeSetMap.containsKey(npc.runeSetID)) { + for (int runeID : _runeSetMap.get(npc.runeSetID)) { + RuneBase rb = RuneBase.getRuneBase(runeID); + CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID()); + npc.runes.add(toApply); + } } } } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 10d8884f..7e2701d5 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -973,9 +973,7 @@ public class NPC extends AbstractCharacter { npcBounds.setBounds(this.getLoc()); //apply NPC rune effects - if(NPCManager._runeSetMap.containsKey(this.runeSetID)){ - NPCManager.applyRunesForNPC(this); - } + NPCManager.applyRunesForNPC(this); } catch (Exception e) { Logger.error(e.getMessage()); From a004c247ab95e3ced6d4e357dc17d3a9a85c9183 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 21:57:17 -0500 Subject: [PATCH 017/289] abstract character cleanup --- src/engine/objects/AbstractCharacter.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index f74f1a66..d7a88aef 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -985,18 +985,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { - Regions region = Regions.GetRegionForTeleport(value); - if(region != null){ - float regionHeight = region.lerpY(this); - this.region = region; - Vector3fImmutable newValue = new Vector3fImmutable(value.x,regionHeight,value.z); //account for height offset of the current character region - super.setLoc(newValue); // set the location in the world - this.resetLastSetLocUpdate(); - } else { - this.region = null; - super.setLoc(value); // set the location in the world - this.resetLastSetLocUpdate(); - } + super.setLoc(value); // set the location in the world + this.resetLastSetLocUpdate(); } public Vector3fImmutable getMovementLoc() { From cdc1c2d7769f4423260dd02ec1066d35b8485f8c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 21:58:20 -0500 Subject: [PATCH 018/289] region assignment --- src/engine/objects/AbstractCharacter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index d7a88aef..c87438e4 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -985,8 +985,14 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { + Regions region = Regions.GetRegionForTeleport(value); + if(region != null){ + this.region = region; + } + super.setLoc(value); // set the location in the world this.resetLastSetLocUpdate(); + } public Vector3fImmutable getMovementLoc() { From ff78c1443c3488084335d0d366424d846fe18501 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 22:04:23 -0500 Subject: [PATCH 019/289] null check --- src/engine/gameManager/NPCManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index da125cd9..16395ad2 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -467,8 +467,10 @@ public enum NPCManager { if(NPCManager._runeSetMap.containsKey(npc.runeSetID)) { for (int runeID : _runeSetMap.get(npc.runeSetID)) { RuneBase rb = RuneBase.getRuneBase(runeID); - CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID()); - npc.runes.add(toApply); + if(rb != null) { + CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID()); + npc.runes.add(toApply); + } } } } From 5c5c4915970c8830b56767a12d695733a537dc96 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 22:10:22 -0500 Subject: [PATCH 020/289] debug code --- src/engine/gameManager/NPCManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 16395ad2..323005eb 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -471,6 +471,9 @@ public enum NPCManager { CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID()); npc.runes.add(toApply); } + else{ + int debugpause = 1; + } } } } From 874eb6189ec24879313a5b2415f0c38ba8f54328 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 22:24:10 -0500 Subject: [PATCH 021/289] NPC apply runes --- src/engine/gameManager/NPCManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 323005eb..16395ad2 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -471,9 +471,6 @@ public enum NPCManager { CharacterRune toApply = new CharacterRune(rb, npc.getObjectUUID()); npc.runes.add(toApply); } - else{ - int debugpause = 1; - } } } } From 3ce887cb3402bec4c87a9e76735ec44cc6e4c0fd Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 22:30:24 -0500 Subject: [PATCH 022/289] NPC are immune to all --- src/engine/objects/NPC.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 7e2701d5..dfa8e827 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -974,6 +974,7 @@ public class NPC extends AbstractCharacter { //apply NPC rune effects NPCManager.applyRunesForNPC(this); + this.resists.setImmuneToAll(true); } catch (Exception e) { Logger.error(e.getMessage()); From 41a83115be948e9292c505631bc4a5f871ba04e5 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 13 Sep 2023 22:34:57 -0500 Subject: [PATCH 023/289] safehold guard exclusion from equipment dropping --- src/engine/gameManager/LootManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index a569324d..96d699b4 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -330,6 +330,8 @@ public enum LootManager { public static void GenerateEquipmentDrop(Mob mob) { + if(mob.behaviourType.equals(Enum.MobBehaviourType.HamletGuard)) + return; // safehold guards don't drop their equipment //do equipment here int dropCount = 0; if (mob.getEquip() != null) From e4235d4d754c9a18e473b4f5bcf453a2348d515a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 09:13:02 -0400 Subject: [PATCH 024/289] Bugfix in setparent. --- src/engine/objects/Zone.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index edec6d7a..bcc6da39 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -253,7 +253,17 @@ public class Zone extends AbstractGameObject { this.setBounds(); - if (this.getHeightMap() != null && this.getHeightMap().getSeaLevel() != 0) + if (this.getParent() == null) { + this.seaLevel = 0; + return; + } + + if (this.getHeightMap() == null) { + this.seaLevel = this.parent.seaLevel; + return; + } + + if (this.getHeightMap().getSeaLevel() != 0) this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel(); else this.seaLevel = this.parent.seaLevel; From 1d7a2d4eae8f9c2058575bcca80f626441f2c624 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 10:09:10 -0400 Subject: [PATCH 025/289] Added sea level info to command. --- src/engine/devcmd/cmds/GetHeightCmd.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index f2d61089..43d99eee 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -41,12 +41,15 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.getName()); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName()); + this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude); + this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel()); this.throwbackInfo(playerCharacter, "Height returned: " + currentHeight); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc); this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); + this.throwbackInfo(playerCharacter, "------------" + currentHeight); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "Character Height: " + playerCharacter.getCharacterHeight()); From 91eb0c314f6e3202d20282be488582e3f9ad4936 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 10:14:31 -0400 Subject: [PATCH 026/289] SeAudit command created --- src/engine/devcmd/cmds/SeaAuditCmd.java | 43 +++++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/engine/devcmd/cmds/SeaAuditCmd.java diff --git a/src/engine/devcmd/cmds/SeaAuditCmd.java b/src/engine/devcmd/cmds/SeaAuditCmd.java new file mode 100644 index 00000000..5ec6a40f --- /dev/null +++ b/src/engine/devcmd/cmds/SeaAuditCmd.java @@ -0,0 +1,43 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.devcmd.AbstractDevCmd; +import engine.gameManager.ZoneManager; +import engine.objects.AbstractGameObject; +import engine.objects.PlayerCharacter; +import engine.objects.Zone; + +public class SeaAuditCmd extends AbstractDevCmd { + + public SeaAuditCmd() { + super("seaaudit"); + } + + @Override + protected void _doCmd(PlayerCharacter playerCharacter, String[] words, + AbstractGameObject target) { + + for (Zone zone : ZoneManager.getAllZones()) + if (zone.getSeaLevel() > zone.worldAltitude) + this.throwbackInfo(playerCharacter, zone.getObjectUUID() + zone.getName()); + } + + @Override + protected String _getHelpString() { + return "Queries heightmap engine"; + } + + @Override + protected String _getUsageString() { + return "' /getheight"; + } + +} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 803ad944..b6334361 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -144,7 +144,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new ApplyBonusCmd()); DevCmdManager.registerDevCmd(new AuditFailedItemsCmd()); DevCmdManager.registerDevCmd(new SlotTestCmd()); - + DevCmdManager.registerDevCmd(new SeaAuditCmd()); } private static void registerDevCmd(AbstractDevCmd cmd) { From e26121177fe5fc6acd02b29f99811195716e4a91 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:07:08 -0400 Subject: [PATCH 027/289] World altitude set in setparent. --- src/engine/objects/Zone.java | 4 +++- src/engine/server/world/WorldServer.java | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index bcc6da39..12873eb5 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -251,10 +251,12 @@ public class Zone extends AbstractGameObject { this.maxLvl = this.parent.maxLvl; } + this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); + this.setBounds(); if (this.getParent() == null) { - this.seaLevel = 0; + this.seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE; return; } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 413fc74b..435670cd 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -566,7 +566,6 @@ public class WorldServer { for (Zone zone : rootParent) { ZoneManager.addZone(zone.getLoadNum(), zone); - zone.worldAltitude = ZoneManager.caclulateWorldAltitude(zone); //Handle Buildings From 4b46eddc47cec5b4ec5aea76d3acf6466b45f939 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:09:50 -0400 Subject: [PATCH 028/289] Dev command updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 43d99eee..db044253 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -21,7 +21,6 @@ public class GetHeightCmd extends AbstractDevCmd { public GetHeightCmd() { super("getHeight"); - this.addCmdString("height"); } @Override @@ -53,6 +52,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "Character Height: " + playerCharacter.getCharacterHeight()); + this.throwbackInfo(playerCharacter, "Drowning Height: " + heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight()); } @Override From fd7b5952c2abeb43feeb6f75f67406121e860223 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:21:12 -0400 Subject: [PATCH 029/289] Dev command updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index db044253..c7a52264 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -52,7 +52,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "Character Height: " + playerCharacter.getCharacterHeight()); - this.throwbackInfo(playerCharacter, "Drowning Height: " + heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight()); + this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); } @Override From dfca76747660fe09507d59360db29a596c7260a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:25:18 -0400 Subject: [PATCH 030/289] Multiple not divide. --- src/engine/InterestManagement/HeightMap.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 61c09b98..77b12f8b 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,6 +30,7 @@ public class HeightMap { // Class variables + public static final float SCALEVALUE = 1.0f / 255; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); @@ -417,7 +418,7 @@ public class HeightMap { interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY)); - interpolatedHeight *= (float) this.maxHeight / 256; // Scale height + interpolatedHeight *= (float) this.maxHeight / SCALEVALUE; // Scale height return interpolatedHeight; } From f64607531150f6585513c8d5427074e6e55a3fc6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:28:36 -0400 Subject: [PATCH 031/289] Static method to save memory. --- src/engine/InterestManagement/HeightMap.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 77b12f8b..12e28ac1 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -103,7 +103,7 @@ public class HeightMap { // Generate pixel array from image data - generatePixelData(); + generatePixelData(this); HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this); @@ -423,19 +423,19 @@ public class HeightMap { return interpolatedHeight; } - private void generatePixelData() { + private static void generatePixelData(HeightMap heightMap) { Color color; // Generate altitude lookup table for this heightmap - this.pixelColorValues = new int[this.heightmapImage.getWidth()][this.heightmapImage.getHeight()]; + heightMap.pixelColorValues = new int[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; - for (int y = 0; y < this.heightmapImage.getHeight(); y++) { - for (int x = 0; x < this.heightmapImage.getWidth(); x++) { + for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { + for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { - color = new Color(this.heightmapImage.getRGB(x, y)); - pixelColorValues[x][y] = color.getRed(); + color = new Color(heightMap.heightmapImage.getRGB(x, y)); + heightMap.pixelColorValues[x][y] = color.getRed(); } } From 2af08d6823fa3274c5f8b4d5405225f0c677830c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:29:26 -0400 Subject: [PATCH 032/289] Reformat file. --- src/engine/InterestManagement/HeightMap.java | 55 +++++++++----------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 12e28ac1..23675512 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -44,17 +44,17 @@ public class HeightMap { public BufferedImage heightmapImage; - private int heightMapID; - private int maxHeight; - private int fullExtentsX; - private int fullExtentsY; + private final int heightMapID; + private final int maxHeight; + private final int fullExtentsX; + private final int fullExtentsY; private float bucketWidthX; private float bucketWidthY; - private int zoneLoadID; + private final int zoneLoadID; private float seaLevel = 0; - private float outsetX; - private float outsetZ; + private final float outsetX; + private final float outsetZ; private int[][] pixelColorValues; public HeightMap(ResultSet rs) throws SQLException { @@ -87,7 +87,7 @@ public class HeightMap { try { this.heightmapImage = ImageIO.read(imageFile); } catch (IOException e) { - Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e.toString()); + Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e); } // We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin. @@ -334,10 +334,25 @@ public class HeightMap { float localAltitude = HeightMap.getWorldHeight(currentLoc); Zone zone = ZoneManager.findSmallestZone(currentLoc); - if (localAltitude < zone.getSeaLevel()) - return true; + return localAltitude < zone.getSeaLevel(); + } + + private static void generatePixelData(HeightMap heightMap) { + + Color color; + + // Generate altitude lookup table for this heightmap + + heightMap.pixelColorValues = new int[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; + + for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { + for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { + + color = new Color(heightMap.heightmapImage.getRGB(x, y)); + heightMap.pixelColorValues[x][y] = color.getRed(); + } + } - return false; } public Vector2f getGridSquare(Vector2f zoneLoc) { @@ -423,24 +438,6 @@ public class HeightMap { return interpolatedHeight; } - private static void generatePixelData(HeightMap heightMap) { - - Color color; - - // Generate altitude lookup table for this heightmap - - heightMap.pixelColorValues = new int[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; - - for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { - for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { - - color = new Color(heightMap.heightmapImage.getRGB(x, y)); - heightMap.pixelColorValues[x][y] = color.getRed(); - } - } - - } - public float getBucketWidthX() { return bucketWidthX; } From 12872ee51e01cf71f759b452f7e9e294bcac007c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:30:54 -0400 Subject: [PATCH 033/289] Variable initialized. --- src/engine/objects/Zone.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 12873eb5..8fd76b18 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -57,8 +57,7 @@ public class Zone extends AbstractGameObject { private boolean isPlayerCity = false; private String hash; public float worldAltitude = 0; - private float seaLevel = 0; - //public static ArrayList respawnQue = new ArrayList<>(); + private float seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; /** From 9839de128c62ac6b9d8c4ebc8d96e46a177e9f1e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:38:47 -0400 Subject: [PATCH 034/289] Variable initialized. --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 23675512..ed3285a1 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,7 +30,7 @@ public class HeightMap { // Class variables - public static final float SCALEVALUE = 1.0f / 255; + public static final float SCALEVALUE = 1.0f / 256f; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); From d26a2d35bfde2e68130fbe8e59638d4a46f7ee6f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 12:39:31 -0400 Subject: [PATCH 035/289] Multiple not divide --- src/engine/InterestManagement/HeightMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index ed3285a1..2534d0a4 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,7 +30,7 @@ public class HeightMap { // Class variables - public static final float SCALEVALUE = 1.0f / 256f; + public static final float SCALEVALUE = 1.0f / 255; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); @@ -433,7 +433,7 @@ public class HeightMap { interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY)); - interpolatedHeight *= (float) this.maxHeight / SCALEVALUE; // Scale height + interpolatedHeight *= (float) this.maxHeight * SCALEVALUE; // Scale height return interpolatedHeight; } From 693dfd827c4ebdb1fbd7e09cd1a950ff13726fb3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:01:22 -0400 Subject: [PATCH 036/289] Updated dev cmd output --- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index c7a52264..462ef745 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -48,7 +48,7 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc); this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); - this.throwbackInfo(playerCharacter, "------------" + currentHeight); + this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "Character Height: " + playerCharacter.getCharacterHeight()); From 031c52e25a8da6ecd4e1756dfc731f8ba27bd3b9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:03:06 -0400 Subject: [PATCH 037/289] Divisor test. --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 2534d0a4..c1a71c7c 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,7 +30,7 @@ public class HeightMap { // Class variables - public static final float SCALEVALUE = 1.0f / 255; + public static final float SCALEVALUE = 1.0f / 256; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); From a2fbfad00e87288b36b12043b696b627a9079257 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:07:32 -0400 Subject: [PATCH 038/289] Revert initialize. --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 8fd76b18..67b356bc 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -57,7 +57,7 @@ public class Zone extends AbstractGameObject { private boolean isPlayerCity = false; private String hash; public float worldAltitude = 0; - private float seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE; + private float seaLevel = 0f; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; /** From aaa506a581a9466a6565cb4641dc8ac0f5c94112 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:21:02 -0400 Subject: [PATCH 039/289] Divisor testing. --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index c1a71c7c..2534d0a4 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,7 +30,7 @@ public class HeightMap { // Class variables - public static final float SCALEVALUE = 1.0f / 256; + public static final float SCALEVALUE = 1.0f / 255; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); From cbf05cfe5b76f836bcb06082836f4dd9719e3d0e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:30:46 -0400 Subject: [PATCH 040/289] Devcmd output updated. --- src/engine/devcmd/cmds/GetHeightCmd.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 462ef745..86d881f6 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -38,21 +38,21 @@ public class GetHeightCmd extends AbstractDevCmd { float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc()); float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc()); + Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); + Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc); + this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.getName()); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName()); this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel()); - this.throwbackInfo(playerCharacter, "Height returned: " + currentHeight); - - Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); - Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc); - this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); + this.throwbackInfo(playerCharacter, "***Height returned: " + currentHeight); + this.throwbackInfo(playerCharacter, "***Adjusted Height: " + playerCharacter.getCharacterHeight()); + this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); + this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); - this.throwbackInfo(playerCharacter, "Character Height: " + playerCharacter.getCharacterHeight()); - this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); } @Override From 525d0c21bbb97ad8efff549269185e21822cb1e5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:41:07 -0400 Subject: [PATCH 041/289] Devcmd output updated. --- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 86d881f6..43519205 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -47,7 +47,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel()); this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); this.throwbackInfo(playerCharacter, "***Height returned: " + currentHeight); - this.throwbackInfo(playerCharacter, "***Adjusted Height: " + playerCharacter.getCharacterHeight()); + this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "------------"); From 15f42c9658afc1acbe5092b2b22977ec6b6923ae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 13:54:22 -0400 Subject: [PATCH 042/289] Devcmd output updated. --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 2534d0a4..c1a71c7c 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,7 +30,7 @@ public class HeightMap { // Class variables - public static final float SCALEVALUE = 1.0f / 255; + public static final float SCALEVALUE = 1.0f / 256; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); From 75c56cbeeed5552002633b2e3ac1bdd680dc9d54 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Sep 2023 14:11:26 -0400 Subject: [PATCH 043/289] Devcmd output updated. --- src/engine/InterestManagement/HeightMap.java | 2 +- src/engine/devcmd/cmds/GetHeightCmd.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index c1a71c7c..aa395368 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -30,7 +30,7 @@ public class HeightMap { // Class variables - public static final float SCALEVALUE = 1.0f / 256; + public static float SCALEVALUE = 1.0f / 256; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 43519205..64c470b2 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -46,8 +46,14 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel()); this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); - this.throwbackInfo(playerCharacter, "***Height returned: " + currentHeight); + this.throwbackInfo(playerCharacter, "*** 256: " + currentHeight); this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight())); + + HeightMap.SCALEVALUE = 1f / 255f; + currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc()); + HeightMap.SCALEVALUE = 1f / 256f; + + this.throwbackInfo(playerCharacter, "***255 Adjusted: " + (currentHeight + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "------------"); From c24f8fc85b776e1cdb86df90d81cc0681d3c75be Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 15 Sep 2023 14:23:34 -0400 Subject: [PATCH 044/289] Login check modified for testing. --- .../server/login/LoginServerMsgHandler.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index dff76ce7..98d0deb1 100644 --- a/src/engine/server/login/LoginServerMsgHandler.java +++ b/src/engine/server/login/LoginServerMsgHandler.java @@ -136,25 +136,25 @@ public class LoginServerMsgHandler implements NetMsgHandler { cMajorVer = vim.getMajorVersion(); cMinorVer = vim.getMinorVersion(); - if (!cMajorVer.equals(this.server.getDefaultVersionInfo().getMajorVersion())) { - this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Major Version Failure: " + cMajorVer, cc); - return; - } + // if (!cMajorVer.equals(this.server.getDefaultVersionInfo().getMajorVersion())) { + // this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Major Version Failure: " + cMajorVer, cc); + // return; + // } /* if (!cMinorVer.equals(this.server.getDefaultVersionInfo().getMinorVersion())) { this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: " + cMinorVer, cc); return; } */ - if (cMinorVer == null) { - this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", cc); - return; - } + // if (cMinorVer == null) { + // this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", cc); + // return; + // } - if (cMinorVer.length() < 8 || cMinorVer.length() > 16) { - this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", cc); - return; - } + // if (cMinorVer.length() < 8 || cMinorVer.length() > 16) { + // this.KickToLogin(MBServerStatics.LOGINERROR_INCORRECT_CLIENT_VERSION, "Minor Version Failure: ", cc); + // return; + // } // set MachineID for this connection From 44b9ba911dc261ac092930cf1a701a3ad6b0bed8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 15 Sep 2023 17:29:51 -0400 Subject: [PATCH 045/289] Indices added to command output. --- src/engine/devcmd/cmds/GetHeightCmd.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 64c470b2..7fda3a6e 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -59,6 +59,10 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); + this.throwbackInfo(playerCharacter, "[" + (gridSquare.x) + "][" + (gridSquare.y) + "]"); + this.throwbackInfo(playerCharacter, "[" + (gridSquare.x + 1) + "][" + (gridSquare.y) + "]"); + this.throwbackInfo(playerCharacter, "[" + (gridSquare.x) + "][" + (gridSquare.y + 1) + "]"); + this.throwbackInfo(playerCharacter, "[" + (gridSquare.x + 1) + "][" + (gridSquare.y + 1) + "]"); } @Override From 403bff27b44023851f27ee472a58a4a2499ae9b9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 08:01:46 -0400 Subject: [PATCH 046/289] Test of raw heightmaps --- src/engine/InterestManagement/HeightMap.java | 91 ++------------------ 1 file changed, 7 insertions(+), 84 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index aa395368..5566f6e0 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -53,8 +53,6 @@ public class HeightMap { private float bucketWidthY; private final int zoneLoadID; private float seaLevel = 0; - private final float outsetX; - private final float outsetZ; private int[][] pixelColorValues; public HeightMap(ResultSet rs) throws SQLException { @@ -65,9 +63,6 @@ public class HeightMap { int halfExtentsY = rs.getInt("zRadius"); this.zoneLoadID = rs.getInt("zoneLoadID"); this.seaLevel = rs.getFloat("seaLevel"); - this.outsetX = rs.getFloat("outsetX"); - this.outsetZ = rs.getFloat("outsetZ"); - // Cache the full extents to avoid the calculation @@ -90,16 +85,15 @@ public class HeightMap { Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e); } - // We needed to flip the image as OpenGL and Shadowbane both use the bottom left corner as origin. - - // this.heightmapImage = MapLoader.flipImage(this.heightmapImage); - // Calculate the data we do not load from table - float numOfBuckets = this.heightmapImage.getWidth() - 1; - float calculatedWidth = this.fullExtentsX / numOfBuckets; - this.bucketWidthX = calculatedWidth; - this.bucketWidthY = this.bucketWidthX; // This makes no sense. + float numOfBucketsX = this.heightmapImage.getWidth() - 1; + float calculatedWidthX = this.fullExtentsX / numOfBucketsX; + this.bucketWidthX = calculatedWidthX; + + float numOfBucketsY = this.heightmapImage.getWidth() - 1; + float calculatedWidthY = this.fullExtentsY / numOfBucketsY; + this.bucketWidthX = calculatedWidthY; // Generate pixel array from image data @@ -119,8 +113,6 @@ public class HeightMap { int halfExtentsY = (int) Enum.CityBoundsType.ZONE.extents; this.zoneLoadID = 0; this.seaLevel = 0; - this.outsetX = 128; - this.outsetZ = 128; // Cache the full extents to avoid the calculation @@ -152,8 +144,6 @@ public class HeightMap { int halfExtentsY = (int) zone.getBounds().getHalfExtents().y; this.zoneLoadID = 0; this.seaLevel = 0; - this.outsetX = 0; - this.outsetZ = 0; // Cache the full extents to avoid the calculation @@ -209,8 +199,6 @@ public class HeightMap { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { - Vector2f parentLoc = new Vector2f(-1, -1); - if (currentZone == null) return 0; @@ -219,17 +207,12 @@ public class HeightMap { if (currentZone == ZoneManager.getSeaFloor()) return currentZone.getAbsY(); - Zone parentZone = getNextZoneWithTerrain(currentZone.getParent()); HeightMap heightMap = currentZone.getHeightMap(); if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) return currentZone.getAbsY(); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, currentZone); - Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLoc, currentZone); - - if ((parentZone != null) && (parentZone.getHeightMap() != null)) - parentLoc = ZoneManager.worldToZoneSpace(worldLoc, parentZone); float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); @@ -237,66 +220,6 @@ public class HeightMap { float realWorldAltitude = interaltitude + worldAltitude; - //OUTSET - - if (parentZone != null) { - - float parentXRadius = currentZone.getBounds().getHalfExtents().x; - float parentZRadius = currentZone.getBounds().getHalfExtents().y; - - float offsetX = Math.abs((localLocFromCenter.x / parentXRadius)); - float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius)); - - float bucketScaleX = heightMap.outsetX / parentXRadius; - float bucketScaleZ = heightMap.outsetZ / parentZRadius; - - float outsideGridSizeX = 1 - bucketScaleX; //32/256 - float outsideGridSizeZ = 1 - bucketScaleZ; - float weight; - - double scale; - - if (offsetX > outsideGridSizeX && offsetX > offsetZ) { - weight = (offsetX - outsideGridSizeX) / bucketScaleX; - scale = Math.atan2((.5 - weight) * 3.1415927, 1); - - float scaleChild = (float) ((scale + 1) * .5); - float scaleParent = 1 - scaleChild; - - float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc); - float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone)); - - parentCenterAltitude += currentZone.getYCoord(); - parentCenterAltitude += interaltitude; - - float firstScale = parentAltitude * scaleParent; - float secondScale = parentCenterAltitude * scaleChild; - float outsetALt = firstScale + secondScale; - - outsetALt += currentZone.getParent().worldAltitude; - realWorldAltitude = outsetALt; - - } else if (offsetZ > outsideGridSizeZ) { - - weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ; - scale = Math.atan2((.5 - weight) * 3.1415927, 1); - - float scaleChild = (float) ((scale + 1) * .5); - float scaleParent = 1 - scaleChild; - float parentAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(parentLoc); - float parentCenterAltitude = parentZone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(currentZone.getLoc(), parentZone)); - - parentCenterAltitude += currentZone.getYCoord(); - parentCenterAltitude += interaltitude; - float firstScale = parentAltitude * scaleParent; - float secondScale = parentCenterAltitude * scaleChild; - float outsetALt = firstScale + secondScale; - - outsetALt += currentZone.getParent().worldAltitude; - realWorldAltitude = outsetALt; - } - } - return realWorldAltitude; } From fc602ce9f440961f2f22a9775db6f95e4bc5cad2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 08:04:49 -0400 Subject: [PATCH 047/289] Test of raw heightmaps --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 5566f6e0..ba4df79a 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -91,7 +91,7 @@ public class HeightMap { float calculatedWidthX = this.fullExtentsX / numOfBucketsX; this.bucketWidthX = calculatedWidthX; - float numOfBucketsY = this.heightmapImage.getWidth() - 1; + float numOfBucketsY = this.heightmapImage.getHeight() - 1; float calculatedWidthY = this.fullExtentsY / numOfBucketsY; this.bucketWidthX = calculatedWidthY; From 7268de6e1e7cca116767ecc9072be4f707ce1990 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 08:06:31 -0400 Subject: [PATCH 048/289] Test of raw heightmaps --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index ba4df79a..85c03158 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -93,7 +93,7 @@ public class HeightMap { float numOfBucketsY = this.heightmapImage.getHeight() - 1; float calculatedWidthY = this.fullExtentsY / numOfBucketsY; - this.bucketWidthX = calculatedWidthY; + this.bucketWidthY = calculatedWidthY; // Generate pixel array from image data From 797a6951a8b85aa3dfc41494d6445be56a4328c1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 08:28:20 -0400 Subject: [PATCH 049/289] Tightened clamping. --- src/engine/InterestManagement/HeightMap.java | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 85c03158..ae1295a7 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -306,11 +306,17 @@ public class HeightMap { Vector2f gridSquare; - if (zoneLoc.x < 0 || zoneLoc.x > this.fullExtentsX) - return -1; + if (zoneLoc.x < 0) + zoneLoc.x = 0; + + if (zoneLoc.y < 0) + zoneLoc.y = 0; - if (zoneLoc.y < 0 || zoneLoc.y > this.fullExtentsY) - return -1; + if (zoneLoc.x > this.fullExtentsX) + zoneLoc.x = this.fullExtentsX; + + if (zoneLoc.y > this.fullExtentsY) + zoneLoc.y = this.fullExtentsY; int maxX = (int) (this.fullExtentsX / this.bucketWidthX); int maxY = (int) (this.fullExtentsY / this.bucketWidthY); @@ -320,10 +326,15 @@ public class HeightMap { int gridX = (int) gridSquare.x; int gridY = (int) gridSquare.y; + if (gridX < 0) + gridX = 0; + if (gridY < 0) + gridY = 0; + if (gridX > maxX) - gridX = maxX; + gridX = maxX - 1; if (gridY > maxY) - gridY = maxY; + gridY = maxY - 1; float offsetX = (gridSquare.x - gridX); float offsetY = gridSquare.y - gridY; From 1ac65dd9bd4b5f45ec6dc62fdb74d54aa6b27bef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 08:31:04 -0400 Subject: [PATCH 050/289] Tightened clamping. --- src/engine/InterestManagement/HeightMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index ae1295a7..edccb593 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -331,9 +331,9 @@ public class HeightMap { if (gridY < 0) gridY = 0; - if (gridX > maxX) + if (gridX >= maxX) gridX = maxX - 1; - if (gridY > maxY) + if (gridY >= maxY) gridY = maxY - 1; float offsetX = (gridSquare.x - gridX); From 9aa5820ac22b047bb252cf21fb8e7d955d4755a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 13:18:36 -0400 Subject: [PATCH 051/289] Cleanup of getWorldHeight() --- src/engine/InterestManagement/HeightMap.java | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index edccb593..4bca8037 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -199,28 +199,31 @@ public class HeightMap { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { - if (currentZone == null) - return 0; + Zone heightMapZone; - currentZone = getNextZoneWithTerrain(currentZone); + // Seafloor is rather flat. if (currentZone == ZoneManager.getSeaFloor()) - return currentZone.getAbsY(); + return currentZone.worldAltitude; + + // Retrieve the next zone with a heightmap attached. + // Zones without a heightmap use the next zone up the + // tree to calculate heights from. + + heightMapZone = getNextZoneWithTerrain(currentZone); - HeightMap heightMap = currentZone.getHeightMap(); + // Transform world loc into zone space coordinate system - if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) - return currentZone.getAbsY(); + Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, heightMapZone); - Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, currentZone); + // Interpolate height for this position using pixel array. - float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); + float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); - float worldAltitude = currentZone.worldAltitude; + // Position returned from Heightmap engine is relative to zone world height - float realWorldAltitude = interaltitude + worldAltitude; + return interpolatedTerrainHeight + heightMapZone.worldAltitude; - return realWorldAltitude; } public static float getWorldHeight(Vector3fImmutable worldLoc) { From b717c3d5501197ab5654ce90d01434527066c704 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 16 Sep 2023 16:03:22 -0400 Subject: [PATCH 052/289] Starting work to sync heightmap model with Shadowbane. --- src/engine/InterestManagement/HeightMap.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 4bca8037..fef1edf9 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -55,6 +55,9 @@ public class HeightMap { private float seaLevel = 0; private int[][] pixelColorValues; + private float zone_minBlend; + private float zone_maxBlend; + public HeightMap(ResultSet rs) throws SQLException { this.heightMapID = rs.getInt("heightMapID"); @@ -64,6 +67,9 @@ public class HeightMap { this.zoneLoadID = rs.getInt("zoneLoadID"); this.seaLevel = rs.getFloat("seaLevel"); + this.zone_minBlend = rs.getFloat("outsetZ"); + this.zone_maxBlend = rs.getFloat("outsetX"); + // Cache the full extents to avoid the calculation this.fullExtentsX = halfExtentsX * 2; From a3a3070158016cfc0fd96dbdb1d6710c06aa9f10 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 07:42:46 -0400 Subject: [PATCH 053/289] Blending configuration setup in SetParent() --- src/engine/InterestManagement/HeightMap.java | 4 ++-- src/engine/objects/Zone.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index fef1edf9..5be2524f 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -55,8 +55,8 @@ public class HeightMap { private float seaLevel = 0; private int[][] pixelColorValues; - private float zone_minBlend; - private float zone_maxBlend; + public float zone_minBlend; + public float zone_maxBlend; public HeightMap(ResultSet rs) throws SQLException { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 67b356bc..e92b3feb 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -60,6 +60,10 @@ public class Zone extends AbstractGameObject { private float seaLevel = 0f; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; + + public Bounds minBlend; + public Bounds maxBlend; + /** * ResultSet Constructor */ @@ -162,9 +166,6 @@ public class Zone extends AbstractGameObject { */ public void setBounds() { - float halfExtentX; - float halfExtentY; - // Set initial bounds object this.bounds = Bounds.borrow(); @@ -185,6 +186,16 @@ public class Zone extends AbstractGameObject { else bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f); + HeightMap heightMap = this.getHeightMap(); + + // Set heightmap blending bounds + + if (heightMap != null) { + this.minBlend = Bounds.borrow(); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + } + } public int getPlayerCityUUID() { From d33ad0cdef73f24b64e998efa4255739dcb7fbc1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 08:03:50 -0400 Subject: [PATCH 054/289] Preparation for blend lerp insertion. --- src/engine/InterestManagement/HeightMap.java | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 5be2524f..48edff22 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -12,6 +12,7 @@ import engine.Enum; import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; +import engine.math.Bounds; import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.Zone; @@ -26,6 +27,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; +import static java.lang.Math.abs; + public class HeightMap { // Class variables @@ -206,6 +209,7 @@ public class HeightMap { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { Zone heightMapZone; + float worldHeight; // Seafloor is rather flat. @@ -226,6 +230,24 @@ public class HeightMap { float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); + // Heightmap blending is based on distance to edge of zone. + + if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) { + worldHeight = interpolatedTerrainHeight + heightMapZone.worldAltitude; + return worldHeight; + } + + if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) { + + // How far into blend zone are we? + + Bounds blendBounds = Bounds.borrow(); + zoneLoc.x = abs(zoneLoc.x); + zoneLoc.y = abs(zoneLoc.x); + blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); + + } + // Position returned from Heightmap engine is relative to zone world height return interpolatedTerrainHeight + heightMapZone.worldAltitude; From 240373898a94b516285769f1d4fa802d0d54327c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 08:08:28 -0400 Subject: [PATCH 055/289] Preparation for blend lerp insertion. --- src/engine/InterestManagement/HeightMap.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 48edff22..39879260 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -209,7 +209,9 @@ public class HeightMap { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { Zone heightMapZone; + Zone parentZone; float worldHeight; + float parentHeight; // Seafloor is rather flat. @@ -237,6 +239,11 @@ public class HeightMap { return worldHeight; } + // We will need the parent height if we got this far into the method + + parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); + parentHeight = HeightMap.getWorldHeight(parentZone, worldLoc); + if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) { // How far into blend zone are we? @@ -246,6 +253,7 @@ public class HeightMap { zoneLoc.y = abs(zoneLoc.x); blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); + } // Position returned from Heightmap engine is relative to zone world height From 6a0520b1268281b94daddd62d5052897c10dd11b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 11:54:57 -0400 Subject: [PATCH 056/289] Blend lerp implemented. --- src/engine/InterestManagement/HeightMap.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 39879260..b5a914f5 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -13,6 +13,7 @@ import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.math.Bounds; +import engine.math.FastMath; import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.Zone; @@ -231,13 +232,12 @@ public class HeightMap { // Interpolate height for this position using pixel array. float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); + worldHeight = interpolatedTerrainHeight + heightMapZone.worldAltitude; // Heightmap blending is based on distance to edge of zone. - if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) { - worldHeight = interpolatedTerrainHeight + heightMapZone.worldAltitude; + if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) return worldHeight; - } // We will need the parent height if we got this far into the method @@ -253,12 +253,21 @@ public class HeightMap { zoneLoc.y = abs(zoneLoc.x); blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); + float childArea = (blendBounds.getHalfExtents().x * 2) * + (blendBounds.getHalfExtents().y * 2); + float parentArea = (parentZone.minBlend.getHalfExtents().x * 2) * + (parentZone.minBlend.getHalfExtents().y * 2); + + float areaDelta = childArea / parentArea; + + interpolatedTerrainHeight = FastMath.LERP(interpolatedTerrainHeight, parentHeight, areaDelta); + return interpolatedTerrainHeight + heightMapZone.worldAltitude; } - // Position returned from Heightmap engine is relative to zone world height + // Past min blend we just return the parent height. - return interpolatedTerrainHeight + heightMapZone.worldAltitude; + return parentHeight + heightMapZone.worldAltitude; } From c096b29521b2bacfe185e394dcd11b87f1df4b33 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 11:57:24 -0400 Subject: [PATCH 057/289] parameter ordering fixed. --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index b5a914f5..4e152de9 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -260,7 +260,7 @@ public class HeightMap { float areaDelta = childArea / parentArea; - interpolatedTerrainHeight = FastMath.LERP(interpolatedTerrainHeight, parentHeight, areaDelta); + interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, parentHeight); return interpolatedTerrainHeight + heightMapZone.worldAltitude; } From 227bd0523e55ec9c5fb2dce67d90e6f4cbf065fe Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 11:59:46 -0400 Subject: [PATCH 058/289] clamping cleaned up. --- src/engine/InterestManagement/HeightMap.java | 24 ++------------------ 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 4e152de9..15c16f9e 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -328,6 +328,8 @@ public class HeightMap { public Vector2f getGridSquare(Vector2f zoneLoc) { + // Clamp values. + if (zoneLoc.x < 0) zoneLoc.setX(0); @@ -354,18 +356,6 @@ public class HeightMap { Vector2f gridSquare; - if (zoneLoc.x < 0) - zoneLoc.x = 0; - - if (zoneLoc.y < 0) - zoneLoc.y = 0; - - if (zoneLoc.x > this.fullExtentsX) - zoneLoc.x = this.fullExtentsX; - - if (zoneLoc.y > this.fullExtentsY) - zoneLoc.y = this.fullExtentsY; - int maxX = (int) (this.fullExtentsX / this.bucketWidthX); int maxY = (int) (this.fullExtentsY / this.bucketWidthY); @@ -374,16 +364,6 @@ public class HeightMap { int gridX = (int) gridSquare.x; int gridY = (int) gridSquare.y; - if (gridX < 0) - gridX = 0; - if (gridY < 0) - gridY = 0; - - if (gridX >= maxX) - gridX = maxX - 1; - if (gridY >= maxY) - gridY = maxY - 1; - float offsetX = (gridSquare.x - gridX); float offsetY = gridSquare.y - gridY; From ee809ddb3751055066e11d008e06781242d8df59 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:01:13 -0400 Subject: [PATCH 059/289] clamping cleaned up. --- src/engine/InterestManagement/HeightMap.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 15c16f9e..76ce63b6 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -356,9 +356,6 @@ public class HeightMap { Vector2f gridSquare; - int maxX = (int) (this.fullExtentsX / this.bucketWidthX); - int maxY = (int) (this.fullExtentsY / this.bucketWidthY); - gridSquare = getGridSquare(zoneLoc); int gridX = (int) gridSquare.x; @@ -377,12 +374,6 @@ public class HeightMap { int nextY = gridY + 1; int nextX = gridX + 1; - if (nextY > maxY) - nextY = gridY; - - if (nextX > maxX) - nextX = gridX; - topLeftHeight = pixelColorValues[gridX][gridY]; topRightHeight = pixelColorValues[nextX][gridY]; bottomLeftHeight = pixelColorValues[gridX][nextY]; From f8caaf0e9961c2d27dbd0be7fd82b4c5a14d1b27 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:07:43 -0400 Subject: [PATCH 060/289] Correction to blend configuration. --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index e92b3feb..bc340e5f 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -192,8 +192,8 @@ public class Zone extends AbstractGameObject { if (heightMap != null) { this.minBlend = Bounds.borrow(); + this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); } } From c38103068e656375b2641e4a715032ac4a784194 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:13:46 -0400 Subject: [PATCH 061/289] Correction to blend configuration. --- src/engine/objects/Zone.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index bc340e5f..d3e9166b 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -190,8 +190,13 @@ public class Zone extends AbstractGameObject { // Set heightmap blending bounds - if (heightMap != null) { - this.minBlend = Bounds.borrow(); + this.minBlend = Bounds.borrow(); + this.maxBlend = Bounds.borrow(); + + if (heightMap == null) { + this.minBlend = this.getBounds(); + this.maxBlend = this.getBounds(); + } else { this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); } From a94b12e8cd4e30c908c2a0e0c4e921bc84d58a41 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:15:21 -0400 Subject: [PATCH 062/289] Correction to blend configuration. --- src/engine/objects/Zone.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index d3e9166b..3c9a790e 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -190,13 +190,13 @@ public class Zone extends AbstractGameObject { // Set heightmap blending bounds - this.minBlend = Bounds.borrow(); - this.maxBlend = Bounds.borrow(); - if (heightMap == null) { this.minBlend = this.getBounds(); this.maxBlend = this.getBounds(); } else { + this.minBlend = Bounds.borrow(); + this.maxBlend = Bounds.borrow(); + this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); } From 8ece4caf1c6a6ff513de7db376e7429f4ffd0f72 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:23:06 -0400 Subject: [PATCH 063/289] value is halfExtent --- src/engine/Enum.java | 6 +++--- src/engine/InterestManagement/HeightMap.java | 4 ++-- src/engine/gameManager/ZoneManager.java | 2 +- src/engine/mobileAI/utilities/MovementUtilities.java | 2 +- .../client/handlers/ClaimGuildTreeMsgHandler.java | 2 +- .../net/client/handlers/PlaceAssetMsgHandler.java | 4 ++-- src/engine/objects/Building.java | 4 ++-- src/engine/objects/City.java | 6 +++--- src/engine/objects/Zone.java | 12 ++++++------ 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 125bc6f7..2510c2ac 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2310,10 +2310,10 @@ public class Enum { ZONE(875), PLACEMENT(876); - public final float extents; + public final float halfExtents; - CityBoundsType(float extents) { - this.extents = extents; + CityBoundsType(float halfExtents) { + this.halfExtents = halfExtents; } } diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 76ce63b6..f7eb71fe 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -119,8 +119,8 @@ public class HeightMap { this.heightMapID = 999999; this.maxHeight = 5; // for real... - int halfExtentsX = (int) Enum.CityBoundsType.ZONE.extents; - int halfExtentsY = (int) Enum.CityBoundsType.ZONE.extents; + int halfExtentsX = (int) Enum.CityBoundsType.ZONE.halfExtents; + int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; this.zoneLoadID = 0; this.seaLevel = 0; diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 8c50d995..8967dad8 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -411,7 +411,7 @@ public enum ZoneManager { treeBounds = Bounds.borrow(); - treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.extents, Enum.CityBoundsType.PLACEMENT.extents), 0.0f); + treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.halfExtents, Enum.CityBoundsType.PLACEMENT.halfExtents), 0.0f); zoneList = currentZone.getNodes(); diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 6b322f35..63a6982b 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -51,7 +51,7 @@ public class MovementUtilities { //Guards recall distance = 814. if (tol != null) { - return !(agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.extents)); + return !(agent.getLoc().distanceSquared2D(tol.getLoc()) > sqr(Enum.CityBoundsType.ZONE.halfExtents)); } } diff --git a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java index dad056fd..23570e45 100644 --- a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java +++ b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java @@ -117,7 +117,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler { dispatch = Dispatch.borrow(sourcePlayer, gtsm); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - CityZoneMsg czm = new CityZoneMsg(2, playerZone.getLoc().x, playerZone.getLoc().y, playerZone.getLoc().z, playerCity.getCityName(), playerZone, Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents); + CityZoneMsg czm = new CityZoneMsg(2, playerZone.getLoc().x, playerZone.getLoc().y, playerZone.getLoc().z, playerCity.getCityName(), playerZone, Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents); DispatchMessage.dispatchMsgToAll(czm); break; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index a3f2b30c..f20d216c 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -661,7 +661,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (!building.getBlueprint().isSiegeEquip()) continue; - if (!building.getLoc().isInsideCircle(serverCity.getLoc(), CityBoundsType.ZONE.extents)) + if (!building.getLoc().isInsideCircle(serverCity.getLoc(), CityBoundsType.ZONE.halfExtents)) continue; if (building.getGuild() == null) @@ -807,7 +807,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Update guild binds and tags //load the new city on the clients - CityZoneMsg czm = new CityZoneMsg(1, treeObject.getLoc().x, treeObject.getLoc().y, treeObject.getLoc().z, cityObject.getCityName(), zoneObject, Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents); + CityZoneMsg czm = new CityZoneMsg(1, treeObject.getLoc().x, treeObject.getLoc().y, treeObject.getLoc().z, cityObject.getCityName(), zoneObject, Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents); DispatchMessage.dispatchMsgToAll(czm); GuildManager.updateAllGuildBinds(playerNation, cityObject); diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 4bcc1086..7f63ab41 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -446,14 +446,14 @@ public class Building extends AbstractWorldObject { if (this.getBlueprint() != null && this.getBlueprint().isSiegeEquip() && this.protectionState.equals(ProtectionState.PROTECTED)) { if (this.getGuild() != null) { if (this.getGuild().getOwnedCity() != null) { - if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.extents)) + if (this.getLoc().isInsideCircle(this.getGuild().getOwnedCity().getLoc(), CityBoundsType.ZONE.halfExtents)) return this.getGuild().getOwnedCity(); } else { Bane bane = Bane.getBaneByAttackerGuild(this.getGuild()); if (bane != null) { if (bane.getCity() != null) { - if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.extents)) + if (this.getLoc().isInsideCircle(bane.getCity().getLoc(), CityBoundsType.ZONE.halfExtents)) return bane.getCity(); } } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index f163b498..39b70bd9 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -583,7 +583,7 @@ public class City extends AbstractWorldObject { Bounds cityBounds = Bounds.borrow(); cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city. - new Vector2f(Enum.CityBoundsType.GRID.extents, Enum.CityBoundsType.GRID.extents), + new Vector2f(Enum.CityBoundsType.GRID.halfExtents, Enum.CityBoundsType.GRID.halfExtents), 0.0f); this.setBounds(cityBounds); @@ -869,7 +869,7 @@ public class City extends AbstractWorldObject { public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) { - return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.extents); + return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.halfExtents); } @@ -934,7 +934,7 @@ public class City extends AbstractWorldObject { // Gather current list of players within the zone bounds - currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.extents, MBServerStatics.MASK_PLAYER); + currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, CityBoundsType.ZONE.halfExtents, MBServerStatics.MASK_PLAYER); currentMemory = new HashSet<>(); for (AbstractWorldObject playerObject : currentPlayers) { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 3c9a790e..7c5cf7aa 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -116,8 +116,8 @@ public class Zone extends AbstractGameObject { if (zone.playerCityID > 0) { writer.put((byte) 1); // Player City - True - writer.putFloat(Enum.CityBoundsType.ZONE.extents); - writer.putFloat(Enum.CityBoundsType.ZONE.extents); + writer.putFloat(Enum.CityBoundsType.ZONE.halfExtents); + writer.putFloat(Enum.CityBoundsType.ZONE.halfExtents); } else writer.put((byte) 0); // Player City - False @@ -173,7 +173,7 @@ public class Zone extends AbstractGameObject { // Player cities are assigned default value if (this.loadNum == 0) { - bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f); + bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); return; } @@ -184,7 +184,7 @@ public class Zone extends AbstractGameObject { if (zoneSize != null) this.bounds.setBounds(new Vector2f(this.absX, this.absZ), zoneSize, 0.0f); else - bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents), 0.0f); + bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); HeightMap heightMap = this.getHeightMap(); @@ -197,8 +197,8 @@ public class Zone extends AbstractGameObject { this.minBlend = Bounds.borrow(); this.maxBlend = Bounds.borrow(); - this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); + this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); } } From 013ddcff665fc2054c36534183a95afc4d44f4f5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:25:07 -0400 Subject: [PATCH 064/289] heightmap blend configuration completed. --- src/engine/objects/Zone.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 7c5cf7aa..fdfa9d49 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -197,8 +197,8 @@ public class Zone extends AbstractGameObject { this.minBlend = Bounds.borrow(); this.maxBlend = Bounds.borrow(); - this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents).subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents).subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); + this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); } } From 6de8249fb0aaee9029f3c1aec049ccf797486f0c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:44:37 -0400 Subject: [PATCH 065/289] Devcmd output updated. --- src/engine/devcmd/cmds/GetHeightCmd.java | 27 ++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 7fda3a6e..a909b0d2 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -12,6 +12,7 @@ package engine.devcmd.cmds; import engine.InterestManagement.HeightMap; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ZoneManager; +import engine.math.Bounds; import engine.math.Vector2f; import engine.objects.AbstractGameObject; import engine.objects.PlayerCharacter; @@ -45,24 +46,28 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName()); this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel()); + this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); this.throwbackInfo(playerCharacter, "*** 256: " + currentHeight); this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight())); - HeightMap.SCALEVALUE = 1f / 255f; - currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc()); - HeightMap.SCALEVALUE = 1f / 256f; - - this.throwbackInfo(playerCharacter, "***255 Adjusted: " + (currentHeight + playerCharacter.getCharacterHeight())); - this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); - this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); - this.throwbackInfo(playerCharacter, "[" + (gridSquare.x) + "][" + (gridSquare.y) + "]"); - this.throwbackInfo(playerCharacter, "[" + (gridSquare.x + 1) + "][" + (gridSquare.y) + "]"); - this.throwbackInfo(playerCharacter, "[" + (gridSquare.x) + "][" + (gridSquare.y + 1) + "]"); - this.throwbackInfo(playerCharacter, "[" + (gridSquare.x + 1) + "][" + (gridSquare.y + 1) + "]"); + this.throwbackInfo(playerCharacter, "------------"); + + if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.maxBlend)) { + this.throwbackInfo(playerCharacter, "Blend: Max / Child"); + return; + } + + if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.minBlend)) { + this.throwbackInfo(playerCharacter, "Blend: Min / LERP"); + return; + } + + this.throwbackInfo(playerCharacter, "Blend: None / Parent"); + } @Override From 83be09d643d5ee9c503df4488527f2b4bcd52161 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:49:30 -0400 Subject: [PATCH 066/289] Comment and name cleanup --- src/engine/InterestManagement/HeightMap.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index f7eb71fe..93fa7996 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -212,7 +212,7 @@ public class HeightMap { Zone heightMapZone; Zone parentZone; float worldHeight; - float parentHeight; + float interpolatedParentTerrainHeight; // Seafloor is rather flat. @@ -242,11 +242,11 @@ public class HeightMap { // We will need the parent height if we got this far into the method parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); - parentHeight = HeightMap.getWorldHeight(parentZone, worldLoc); + interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); - if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) { + // Between maxBlend and minBlend distance from edge of zone we LERP between the two heights - // How far into blend zone are we? + if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) { Bounds blendBounds = Bounds.borrow(); zoneLoc.x = abs(zoneLoc.x); @@ -260,14 +260,14 @@ public class HeightMap { float areaDelta = childArea / parentArea; - interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, parentHeight); + interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight); return interpolatedTerrainHeight + heightMapZone.worldAltitude; } // Past min blend we just return the parent height. - return parentHeight + heightMapZone.worldAltitude; + return interpolatedParentTerrainHeight + heightMapZone.worldAltitude; } From 3fb08ca2c3acd7289acbf9a6df1ee9204daa2e3b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 12:53:56 -0400 Subject: [PATCH 067/289] Visibility promotion for a data class --- src/engine/InterestManagement/HeightMap.java | 38 +++++-------------- .../db/handlers/dbHeightMapHandler.java | 4 +- src/engine/devcmd/cmds/ZoneInfoCmd.java | 6 +-- src/engine/objects/Zone.java | 4 +- src/engine/server/world/WorldServer.java | 2 +- 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 93fa7996..0ad19d18 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -48,16 +48,16 @@ public class HeightMap { public BufferedImage heightmapImage; - private final int heightMapID; - private final int maxHeight; - private final int fullExtentsX; - private final int fullExtentsY; + public final int heightMapID; + public final int maxHeight; + public final int fullExtentsX; + public final int fullExtentsY; - private float bucketWidthX; - private float bucketWidthY; - private final int zoneLoadID; - private float seaLevel = 0; - private int[][] pixelColorValues; + public float bucketWidthX; + public float bucketWidthY; + public final int zoneLoadID; + public float seaLevel = 0; + public int[][] pixelColorValues; public float zone_minBlend; public float zone_maxBlend; @@ -391,24 +391,4 @@ public class HeightMap { return interpolatedHeight; } - public float getBucketWidthX() { - return bucketWidthX; - } - - public float getBucketWidthY() { - return bucketWidthY; - } - - public int getHeightMapID() { - return heightMapID; - } - - public BufferedImage getHeightmapImage() { - return heightmapImage; - } - - public float getSeaLevel() { - return seaLevel; - } - } diff --git a/src/engine/db/handlers/dbHeightMapHandler.java b/src/engine/db/handlers/dbHeightMapHandler.java index eec0bfbc..514008de 100644 --- a/src/engine/db/handlers/dbHeightMapHandler.java +++ b/src/engine/db/handlers/dbHeightMapHandler.java @@ -29,8 +29,8 @@ public class dbHeightMapHandler extends dbHandlerBase { while (rs.next()) { thisHeightmap = new HeightMap(rs); - if (thisHeightmap.getHeightmapImage() == null) { - Logger.info("Imagemap for " + thisHeightmap.getHeightMapID() + " was null"); + if (thisHeightmap.heightmapImage == null) { + Logger.info("Imagemap for " + thisHeightmap.heightMapID + " was null"); continue; } } diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 37325aef..6a1daa3d 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -91,11 +91,11 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; if (zone.getHeightMap() != null) { - output += "HeightMap ID: " + zone.getHeightMap().getHeightMapID(); + output += "HeightMap ID: " + zone.getHeightMap().heightMapID; output += newline; - output += "Bucket Width X : " + zone.getHeightMap().getBucketWidthX(); + output += "Bucket Width X : " + zone.getHeightMap().bucketWidthX; output += newline; - output += "Bucket Width Y : " + zone.getHeightMap().getBucketWidthY(); + output += "Bucket Width Y : " + zone.getHeightMap().bucketWidthY; } output += "radius: x: " + zone.getBounds().getHalfExtents().x + ", z: " + zone.getBounds().getHalfExtents().y; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index fdfa9d49..2b644f48 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -280,8 +280,8 @@ public class Zone extends AbstractGameObject { return; } - if (this.getHeightMap().getSeaLevel() != 0) - this.seaLevel = this.worldAltitude + this.getHeightMap().getSeaLevel(); + if (this.getHeightMap().seaLevel != 0) + this.seaLevel = this.worldAltitude + this.getHeightMap().seaLevel; else this.seaLevel = this.parent.seaLevel; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 435670cd..0956ca11 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -468,7 +468,7 @@ public class WorldServer { for (Zone zone : ZoneManager.getAllZones()) { if (zone.getHeightMap() != null) { - if (zone.getHeightMap().getBucketWidthX() == 0) { + if (zone.getHeightMap().bucketWidthX == 0) { System.out.println("Zone load num: " + zone.getLoadNum() + " has no bucket width"); } } From f18acf3e68bdd4deef259a9018111d922cb08786 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 13:08:51 -0400 Subject: [PATCH 068/289] DevCmd output updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index a909b0d2..c486a29f 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -56,17 +56,20 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "------------"); + this.throwbackInfo(playerCharacter, "Min: " + heightmapZone.getHeightMap().zone_maxBlend + " Max: " + heightmapZone.getHeightMap().zone_maxBlend); + + if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.maxBlend)) { - this.throwbackInfo(playerCharacter, "Blend: Max / Child"); + this.throwbackInfo(playerCharacter, "Blend: Max (Child)"); return; } if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.minBlend)) { - this.throwbackInfo(playerCharacter, "Blend: Min / LERP"); + this.throwbackInfo(playerCharacter, "Blend: Min (LERP)"); return; } - this.throwbackInfo(playerCharacter, "Blend: None / Parent"); + this.throwbackInfo(playerCharacter, "Blend: None (Parent)"); } From 37d2f8a8ad2568cfa9345439a4c5789e07e7a7ab Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 13:11:29 -0400 Subject: [PATCH 069/289] DevCmd output updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index c486a29f..5c014663 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -56,7 +56,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "------------"); - this.throwbackInfo(playerCharacter, "Min: " + heightmapZone.getHeightMap().zone_maxBlend + " Max: " + heightmapZone.getHeightMap().zone_maxBlend); + this.throwbackInfo(playerCharacter, "Min: " + heightmapZone.getHeightMap().zone_minBlend + " Max: " + heightmapZone.getHeightMap().zone_maxBlend); if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.maxBlend)) { From 8c6eb4887602c3f1861bbd00ae99543ec65f21b9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 13:25:15 -0400 Subject: [PATCH 070/289] max based on min blend --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 2b644f48..d414037e 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -198,7 +198,7 @@ public class Zone extends AbstractGameObject { this.maxBlend = Bounds.borrow(); this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.minBlend.getHalfExtents().subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); } } From ea6092db8a9ec736e62a06ccae5dfc1e48e81a48 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 13:28:23 -0400 Subject: [PATCH 071/289] max based on min blend --- src/engine/InterestManagement/HeightMap.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 0ad19d18..584d20bc 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -123,6 +123,8 @@ public class HeightMap { int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; this.zoneLoadID = 0; this.seaLevel = 0; + this.zone_minBlend = 256; + this.zone_maxBlend = 256; // Cache the full extents to avoid the calculation From a323f1ffb7855b3df639b6849c81854caeb3090b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 13:30:16 -0400 Subject: [PATCH 072/289] max based on min blend --- src/engine/InterestManagement/HeightMap.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 584d20bc..2c8f48d2 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -268,6 +268,7 @@ public class HeightMap { } // Past min blend we just return the parent height. + // This should never be reached return interpolatedParentTerrainHeight + heightMapZone.worldAltitude; From df45e00fbdee60df3bfd636e2b8d7c39dcb70a30 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 13:39:42 -0400 Subject: [PATCH 073/289] 255 to normalize --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 2c8f48d2..02bf06ab 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -34,7 +34,7 @@ public class HeightMap { // Class variables - public static float SCALEVALUE = 1.0f / 256; + public static float SCALEVALUE = 1.0f / 255; // Heightmap data for all zones. public static final HashMap heightmapByLoadNum = new HashMap<>(); From 40c27eef79b0ecd22278ec627ce3522e248fcf25 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 14:00:00 -0400 Subject: [PATCH 074/289] Update to blend logic. --- src/engine/InterestManagement/HeightMap.java | 45 +++++++------------- src/engine/devcmd/cmds/GetHeightCmd.java | 7 +-- src/engine/objects/Zone.java | 8 +--- 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 02bf06ab..4e3afbd7 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -34,28 +34,23 @@ public class HeightMap { // Class variables - public static float SCALEVALUE = 1.0f / 255; - // Heightmap data for all zones. - public static final HashMap heightmapByLoadNum = new HashMap<>(); + // Heightmap data for all zones. + public static float SCALEVALUE = 1.0f / 255; // Bootstrap Tracking - public static int heightMapsCreated = 0; public static HeightMap PlayerCityHeightMap; // Heightmap data for this heightmap - - public BufferedImage heightmapImage; - public final int heightMapID; public final int maxHeight; public final int fullExtentsX; public final int fullExtentsY; - + public final int zoneLoadID; + public BufferedImage heightmapImage; public float bucketWidthX; public float bucketWidthY; - public final int zoneLoadID; public float seaLevel = 0; public int[][] pixelColorValues; @@ -246,31 +241,21 @@ public class HeightMap { parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); - // Between maxBlend and minBlend distance from edge of zone we LERP between the two heights - - if (Bounds.collide(worldLoc, heightMapZone.minBlend) == true) { + Bounds blendBounds = Bounds.borrow(); + zoneLoc.x = abs(zoneLoc.x); + zoneLoc.y = abs(zoneLoc.x); - Bounds blendBounds = Bounds.borrow(); - zoneLoc.x = abs(zoneLoc.x); - zoneLoc.y = abs(zoneLoc.x); - blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); + blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); - float childArea = (blendBounds.getHalfExtents().x * 2) * - (blendBounds.getHalfExtents().y * 2); - float parentArea = (parentZone.minBlend.getHalfExtents().x * 2) * - (parentZone.minBlend.getHalfExtents().y * 2); - - float areaDelta = childArea / parentArea; - - interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight); - return interpolatedTerrainHeight + heightMapZone.worldAltitude; - - } + float currentArea = (blendBounds.getHalfExtents().x * 2) * + (blendBounds.getHalfExtents().y * 2); + float zoneArea = (heightMapZone.getBounds().getHalfExtents().x * 2) * + (heightMapZone.getBounds().getHalfExtents().y * 2); - // Past min blend we just return the parent height. - // This should never be reached + float areaDelta = currentArea / zoneArea; - return interpolatedParentTerrainHeight + heightMapZone.worldAltitude; + interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight); + return interpolatedTerrainHeight + heightMapZone.worldAltitude; } diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 5c014663..df8331a5 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -64,12 +64,7 @@ public class GetHeightCmd extends AbstractDevCmd { return; } - if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.minBlend)) { - this.throwbackInfo(playerCharacter, "Blend: Min (LERP)"); - return; - } - - this.throwbackInfo(playerCharacter, "Blend: None (Parent)"); + this.throwbackInfo(playerCharacter, "Blend: Min (LERP)"); } diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index d414037e..d53087a9 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -60,8 +60,6 @@ public class Zone extends AbstractGameObject { private float seaLevel = 0f; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; - - public Bounds minBlend; public Bounds maxBlend; /** @@ -191,14 +189,10 @@ public class Zone extends AbstractGameObject { // Set heightmap blending bounds if (heightMap == null) { - this.minBlend = this.getBounds(); this.maxBlend = this.getBounds(); } else { - this.minBlend = Bounds.borrow(); this.maxBlend = Bounds.borrow(); - - this.minBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.minBlend.getHalfExtents().subtract(heightMap.zone_maxBlend, heightMap.zone_maxBlend), 0.0f); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); } } From 913a2601d5279a65fce36760f2bad0663b148404 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 14:02:17 -0400 Subject: [PATCH 075/289] Update to blend logic. --- src/engine/InterestManagement/HeightMap.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 4e3afbd7..63f629d6 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -229,12 +229,11 @@ public class HeightMap { // Interpolate height for this position using pixel array. float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); - worldHeight = interpolatedTerrainHeight + heightMapZone.worldAltitude; // Heightmap blending is based on distance to edge of zone. if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) - return worldHeight; + return interpolatedTerrainHeight + heightMapZone.worldAltitude; // We will need the parent height if we got this far into the method From 80f2db794f85237619910fcb525f87b4e7b16015 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 23:46:00 -0400 Subject: [PATCH 076/289] Bounds must be set before setting parent. --- src/engine/InterestManagement/HeightMap.java | 2 +- src/engine/objects/Zone.java | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 63f629d6..64400671 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -208,7 +208,7 @@ public class HeightMap { Zone heightMapZone; Zone parentZone; - float worldHeight; + float interpolatedParentTerrainHeight; // Seafloor is rather flat. diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index d53087a9..3ff7891e 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -84,9 +84,11 @@ public class Zone extends AbstractGameObject { this.minLvl = rs.getInt("minLvl"); this.maxLvl = rs.getInt("maxLvl"); + this.setBounds(); + //this needs to be here specifically for new zones created after server boot (e.g. player city zones) - Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); + Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); this.setParent(parentZone); if (this.minLvl == 0 && parentZone != null) { @@ -238,8 +240,6 @@ public class Zone extends AbstractGameObject { this.parent = value; this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0; - // Zone AABB is set here as it's coordinate space is world requiring a parent. - // Seafloor if (this.parent == null) { @@ -247,7 +247,6 @@ public class Zone extends AbstractGameObject { this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE; this.absZ = this.zCoord; this.seaLevel = 0; - this.setBounds(); return; } @@ -262,8 +261,6 @@ public class Zone extends AbstractGameObject { this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); - this.setBounds(); - if (this.getParent() == null) { this.seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE; return; From 897ddfe77ac9af812e8ee98ff471025bcdac539d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 23:53:06 -0400 Subject: [PATCH 077/289] Bounds must be set before setting parent. --- src/engine/objects/Zone.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 3ff7891e..c682c0b1 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -84,8 +84,6 @@ public class Zone extends AbstractGameObject { this.minLvl = rs.getInt("minLvl"); this.maxLvl = rs.getInt("maxLvl"); - this.setBounds(); - //this needs to be here specifically for new zones created after server boot (e.g. player city zones) Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); @@ -247,6 +245,7 @@ public class Zone extends AbstractGameObject { this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE; this.absZ = this.zCoord; this.seaLevel = 0; + this.setBounds(); return; } @@ -259,6 +258,7 @@ public class Zone extends AbstractGameObject { this.maxLvl = this.parent.maxLvl; } + this.setBounds(); this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); if (this.getParent() == null) { From da238b9986e2b77267fce1dc91979662babc4963 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Sep 2023 23:56:45 -0400 Subject: [PATCH 078/289] Cleanup in bounds configuration --- src/engine/objects/Zone.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index c682c0b1..42595a35 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -168,13 +168,6 @@ public class Zone extends AbstractGameObject { this.bounds = Bounds.borrow(); - // Player cities are assigned default value - - if (this.loadNum == 0) { - bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); - return; - } - Vector2f zoneSize = ZoneManager._zone_size_data.get(this.loadNum); // Default to player zone size on error? Maybe log this From cbc8216fe09e65f4ea6866f283637ef022492d5f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 18 Sep 2023 00:05:53 -0400 Subject: [PATCH 079/289] Blender --- src/engine/InterestManagement/HeightMap.java | 28 ++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 64400671..6527deb4 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -118,8 +118,8 @@ public class HeightMap { int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; this.zoneLoadID = 0; this.seaLevel = 0; - this.zone_minBlend = 256; - this.zone_maxBlend = 256; + this.zone_minBlend = 0; + this.zone_maxBlend = 0; // Cache the full extents to avoid the calculation @@ -246,14 +246,26 @@ public class HeightMap { blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); - float currentArea = (blendBounds.getHalfExtents().x * 2) * - (blendBounds.getHalfExtents().y * 2); - float zoneArea = (heightMapZone.getBounds().getHalfExtents().x * 2) * - (heightMapZone.getBounds().getHalfExtents().y * 2); + float maxBlendArea = (heightMapZone.maxBlend.getHalfExtents().x) * + (heightMapZone.maxBlend.getHalfExtents().y); + float currentArea = (blendBounds.getHalfExtents().x) * + (blendBounds.getHalfExtents().y); + float zoneArea = (heightMapZone.getBounds().getHalfExtents().x) * + (heightMapZone.getBounds().getHalfExtents().y); - float areaDelta = currentArea / zoneArea; + float blendDelta = zoneArea - maxBlendArea; + float currentDelta = zoneArea - currentArea; - interpolatedTerrainHeight = FastMath.LERP(areaDelta, interpolatedTerrainHeight, interpolatedParentTerrainHeight); + float percentage; + + if (currentDelta != 0 && blendDelta != 0) + percentage = currentDelta / blendDelta; + else + percentage = 0.0f; + + interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); + + interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); return interpolatedTerrainHeight + heightMapZone.worldAltitude; } From e359b1dfdf70c45d0fbc52d75c29e4819429bc50 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 18 Sep 2023 02:11:38 -0400 Subject: [PATCH 080/289] Interpolating world altitude --- src/engine/InterestManagement/HeightMap.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 6527deb4..09d7b83c 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -262,11 +262,9 @@ public class HeightMap { percentage = currentDelta / blendDelta; else percentage = 0.0f; - - interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); - + float interpolatedWorldAltitude = FastMath.LERP(percentage, heightMapZone.worldAltitude, parentZone.worldAltitude); interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); - return interpolatedTerrainHeight + heightMapZone.worldAltitude; + return interpolatedTerrainHeight + interpolatedWorldAltitude; } From 5ba06796b19f4a92c7b634a4fe0e50e187f5491a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 18 Sep 2023 03:19:00 -0400 Subject: [PATCH 081/289] Interpolating from adjusted altitudes. --- src/engine/InterestManagement/HeightMap.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 09d7b83c..44de1097 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -229,16 +229,18 @@ public class HeightMap { // Interpolate height for this position using pixel array. float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); + interpolatedTerrainHeight += heightMapZone.worldAltitude; // Heightmap blending is based on distance to edge of zone. if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) - return interpolatedTerrainHeight + heightMapZone.worldAltitude; + return interpolatedTerrainHeight; // We will need the parent height if we got this far into the method parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); + interpolatedParentTerrainHeight += parentZone.worldAltitude; Bounds blendBounds = Bounds.borrow(); zoneLoc.x = abs(zoneLoc.x); @@ -262,9 +264,9 @@ public class HeightMap { percentage = currentDelta / blendDelta; else percentage = 0.0f; - float interpolatedWorldAltitude = FastMath.LERP(percentage, heightMapZone.worldAltitude, parentZone.worldAltitude); + interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); - return interpolatedTerrainHeight + interpolatedWorldAltitude; + return interpolatedTerrainHeight; } From c7b2245005475f95197fb245f9d3dd26a3312fb9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 11:35:39 -0400 Subject: [PATCH 082/289] Unused methods removed --- src/engine/objects/Realm.java | 82 ----------------------------------- 1 file changed, 82 deletions(-) diff --git a/src/engine/objects/Realm.java b/src/engine/objects/Realm.java index e97a4533..64397870 100644 --- a/src/engine/objects/Realm.java +++ b/src/engine/objects/Realm.java @@ -175,22 +175,6 @@ public class Realm { return (this.rulingCityUUID != 0); } - public float getMapR() { - return this.mapR; - } - - public float getMapG() { - return this.mapG; - } - - public float getMapB() { - return this.mapB; - } - - public float getMapA() { - return this.mapA; - } - public boolean getCanBeClaimed() { return this.canBeClaimed; } @@ -211,37 +195,6 @@ public class Realm { return City.getCity(this.rulingCityUUID); } - public float getMapY1() { - return this.mapY1; - } - - public float getMapX1() { - return this.mapX1; - } - - public float getMapY2() { - return this.mapY2; - } - - public float getMapX2() { - return this.mapX2; - } - - public int getStretchX() { - return this.stretchX; - } - - public int getStretchY() { - return this.stretchY; - } - - public int getlocX() { - return this.locX; - } - - public int getlocY() { - return this.locY; - } // Call this after changing ownership before you serialize a realm @@ -370,13 +323,6 @@ public class Realm { return charterType; } - /** - * @param charterType the charterType to set - */ - public void setCharterType(int charterType) { - this.charterType = charterType; - } - public void abandonRealm() { // Push event to warehouse @@ -417,32 +363,4 @@ public class Realm { return hash; } - public void setHash() { - - this.hash = DataWarehouse.hasher.encrypt(this.realmID); - - // Write hash to player character table - - DataWarehouse.writeHash(Enum.DataRecordType.REALM, this.realmID); - } - - /* *** Keeping around in case needed for server wipe or some other emergency - - public static void backfillRealms() { - - // Backfill realm records - - for (Realm realm : _realms.values()) { - - realm.setHash(); - - if ( (realm.isRuled() == true) && - (DataWarehouse.recordExists(Enum.DataRecordType.REALM, realm.getRealmID()) == false)) { - RealmRecord realmRecord = RealmRecord.borrow(realm, Enum.RecordEventType.CAPTURE); - DataWarehouse.pushToWarehouse(realmRecord); - } - - } - } - */ } From 26a3ea4b18b57ba825e862306f6426abcc0140d9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 11:38:39 -0400 Subject: [PATCH 083/289] Release bounds after usage. --- src/engine/InterestManagement/HeightMap.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 44de1097..89b603b2 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -255,6 +255,8 @@ public class HeightMap { float zoneArea = (heightMapZone.getBounds().getHalfExtents().x) * (heightMapZone.getBounds().getHalfExtents().y); + blendBounds.release(); + float blendDelta = zoneArea - maxBlendArea; float currentDelta = zoneArea - currentArea; From 6290c6d0af877efebd5a88f83ed4c79365429961 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 11:40:29 -0400 Subject: [PATCH 084/289] Start separate PLANAR from TARGA --- src/engine/InterestManagement/HeightMap.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 89b603b2..03bdb9df 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -238,6 +238,13 @@ public class HeightMap { // We will need the parent height if we got this far into the method + return interpolatePLANAR(worldLoc, heightMapZone, zoneLoc, interpolatedTerrainHeight); + + } + + private static float interpolatePLANAR(Vector3fImmutable worldLoc, Zone heightMapZone, Vector2f zoneLoc, float interpolatedTerrainHeight) { + Zone parentZone; + float interpolatedParentTerrainHeight; parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); interpolatedParentTerrainHeight += parentZone.worldAltitude; @@ -269,7 +276,6 @@ public class HeightMap { interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); return interpolatedTerrainHeight; - } public static float getWorldHeight(Vector3fImmutable worldLoc) { From 1fdf1f13391f9b1f89520f10753a892e19894620 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 11:59:43 -0400 Subject: [PATCH 085/289] New collection defined for pixel data --- src/engine/InterestManagement/HeightMap.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 03bdb9df..f92546f0 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -35,6 +35,9 @@ public class HeightMap { // Class variables public static final HashMap heightmapByLoadNum = new HashMap<>(); + + public static final HashMap _pixelData = new HashMap<>(); + // Heightmap data for all zones. public static float SCALEVALUE = 1.0f / 255; From d0b4634429428bdde235f2965e9987d02f3006f4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 12:46:41 -0400 Subject: [PATCH 086/289] Framework to load pixel data --- src/engine/InterestManagement/HeightMap.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index f92546f0..8dffdcda 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -24,9 +24,13 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; +import java.util.stream.Stream; import static java.lang.Math.abs; @@ -308,6 +312,17 @@ public class HeightMap { } Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); + + // Load pixel data + + try (Stream paths = Files.walk(Paths.get("mb.data/heightmaps/TARGA/"))) { + paths + .filter(Files::isRegularFile) + .forEach(System.out::println); + } catch (IOException e) { + Logger.error(e); + } + } public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { From 6638fdcaff1f6d7b4b3eb870f7c7edd3bd282238 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 13:06:18 -0400 Subject: [PATCH 087/289] Framework to load pixel data --- src/engine/InterestManagement/HeightMap.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 8dffdcda..b399c912 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -315,10 +315,21 @@ public class HeightMap { // Load pixel data - try (Stream paths = Files.walk(Paths.get("mb.data/heightmaps/TARGA/"))) { - paths - .filter(Files::isRegularFile) - .forEach(System.out::println); + try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { + filePathStream.forEach(filePath -> { + + if (Files.isRegularFile(filePath)) { + File imageFile = filePath.toFile(); + + try { + BufferedImage heightmapImage = ImageIO.read(imageFile); + } catch (IOException e) { + throw new RuntimeException(e); + } + + + } + }); } catch (IOException e) { Logger.error(e); } From cb2ed0c766b90de817a25a8f61754b8931916ca1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 13:23:02 -0400 Subject: [PATCH 088/289] Testing image reader --- src/engine/InterestManagement/HeightMap.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index b399c912..af377ec6 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -20,6 +20,7 @@ import engine.objects.Zone; import org.pmw.tinylog.Logger; import javax.imageio.ImageIO; +import javax.imageio.ImageReader; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; @@ -30,6 +31,7 @@ import java.nio.file.Paths; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; +import java.util.Iterator; import java.util.stream.Stream; import static java.lang.Math.abs; @@ -315,6 +317,11 @@ public class HeightMap { // Load pixel data + Iterator readers = ImageIO.getImageReadersByFormatName("TGA"); + while (readers.hasNext()) { + System.out.println("reader: " + readers.next()); + } + try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { filePathStream.forEach(filePath -> { @@ -323,6 +330,7 @@ public class HeightMap { try { BufferedImage heightmapImage = ImageIO.read(imageFile); + int width = heightmapImage.getWidth(); } catch (IOException e) { throw new RuntimeException(e); } From e3675ec9a4d669d51c685f6cbe89e7e76a692dad Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 13:26:54 -0400 Subject: [PATCH 089/289] Testing image reader --- src/engine/InterestManagement/HeightMap.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index af377ec6..a7b80545 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -25,14 +25,10 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.Iterator; -import java.util.stream.Stream; import static java.lang.Math.abs; @@ -318,11 +314,12 @@ public class HeightMap { // Load pixel data Iterator readers = ImageIO.getImageReadersByFormatName("TGA"); + while (readers.hasNext()) { System.out.println("reader: " + readers.next()); } - try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { + /* try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { filePathStream.forEach(filePath -> { if (Files.isRegularFile(filePath)) { @@ -341,7 +338,7 @@ public class HeightMap { } catch (IOException e) { Logger.error(e); } - +*/ } public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { From 2dfd2a53c2b9c37880891565ae394728a1a415a5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 13:37:43 -0400 Subject: [PATCH 090/289] Testing image reader --- src/engine/InterestManagement/HeightMap.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index a7b80545..4132b67e 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -20,15 +20,17 @@ import engine.objects.Zone; import org.pmw.tinylog.Logger; import javax.imageio.ImageIO; -import javax.imageio.ImageReader; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -import java.util.Iterator; +import java.util.stream.Stream; import static java.lang.Math.abs; @@ -313,13 +315,7 @@ public class HeightMap { // Load pixel data - Iterator readers = ImageIO.getImageReadersByFormatName("TGA"); - - while (readers.hasNext()) { - System.out.println("reader: " + readers.next()); - } - - /* try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { + try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { filePathStream.forEach(filePath -> { if (Files.isRegularFile(filePath)) { @@ -338,7 +334,7 @@ public class HeightMap { } catch (IOException e) { Logger.error(e); } -*/ + } public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { From d46f36959901be56d950fc38ca02da809b42c507 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 13:49:27 -0400 Subject: [PATCH 091/289] Unused variables --- src/engine/InterestManagement/HeightMap.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 4132b67e..0b1bf7bf 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -214,9 +214,6 @@ public class HeightMap { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { Zone heightMapZone; - Zone parentZone; - - float interpolatedParentTerrainHeight; // Seafloor is rather flat. From 9714393538c466d263811f4a2d8e3ebaaac9fc13 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 13:59:32 -0400 Subject: [PATCH 092/289] Pixel data loaded from TARGA files --- src/engine/InterestManagement/HeightMap.java | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 0b1bf7bf..44712e89 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -40,7 +40,7 @@ public class HeightMap { public static final HashMap heightmapByLoadNum = new HashMap<>(); - public static final HashMap _pixelData = new HashMap<>(); + public static final HashMap _pixelData = new HashMap<>(); // Heightmap data for all zones. public static float SCALEVALUE = 1.0f / 255; @@ -310,7 +310,7 @@ public class HeightMap { Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); - // Load pixel data + // Load pixel data for heightmaps try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { filePathStream.forEach(filePath -> { @@ -320,7 +320,24 @@ public class HeightMap { try { BufferedImage heightmapImage = ImageIO.read(imageFile); - int width = heightmapImage.getWidth(); + + // Generate pixel for this heightmap. RPG channels are all the same + // in this greyscale TGA heightmap. We will choose red. + + int[][] colorData = new int[heightmapImage.getWidth()][heightmapImage.getHeight()]; + + for (int y = 0; y < heightmapImage.getHeight(); y++) { + for (int x = 0; x < heightmapImage.getWidth(); x++) { + + Color color = new Color(heightmapImage.getRGB(x, y)); + colorData[x][y] = color.getRed(); + } + } + + // Insert color data into lookup table + + _pixelData.put(imageFile.getName().substring(0, imageFile.getName().lastIndexOf(".")), colorData); + } catch (IOException e) { throw new RuntimeException(e); } From 1ddcda5c5d148d8bdd2c6eedb5e19f2516c306c4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 14:04:55 -0400 Subject: [PATCH 093/289] Logging to console --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 44712e89..5b8e18b7 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -339,7 +339,7 @@ public class HeightMap { _pixelData.put(imageFile.getName().substring(0, imageFile.getName().lastIndexOf(".")), colorData); } catch (IOException e) { - throw new RuntimeException(e); + Logger.error(e); } From 7793fab5d2fb6cca7adb7245c828258d7af69412 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 14:14:55 -0400 Subject: [PATCH 094/289] Unnecessary initialization. --- src/engine/InterestManagement/HeightMap.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 5b8e18b7..85b8f661 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -417,10 +417,10 @@ public class HeightMap { //get height of the 4 vertices. - float topLeftHeight = 0; - float topRightHeight = 0; - float bottomLeftHeight = 0; - float bottomRightHeight = 0; + float topLeftHeight; + float topRightHeight; + float bottomLeftHeight; + float bottomRightHeight; int nextY = gridY + 1; int nextX = gridX + 1; From 7b8cafc8ac3540ba2dd909194fd2e9b3cbf153a0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 14:20:22 -0400 Subject: [PATCH 095/289] Cleanup of interpolation method --- src/engine/InterestManagement/HeightMap.java | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 85b8f661..dab19d2d 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -405,32 +405,29 @@ public class HeightMap { public float getInterpolatedTerrainHeight(Vector2f zoneLoc) { - Vector2f gridSquare; + float interpolatedHeight; - gridSquare = getGridSquare(zoneLoc); + Vector2f gridSquare = getGridSquare(zoneLoc); int gridX = (int) gridSquare.x; int gridY = (int) gridSquare.y; - float offsetX = (gridSquare.x - gridX); - float offsetY = gridSquare.y - gridY; - - //get height of the 4 vertices. + //get 4 surrounding vertices from the pixel array. float topLeftHeight; float topRightHeight; float bottomLeftHeight; float bottomRightHeight; - int nextY = gridY + 1; - int nextX = gridX + 1; - topLeftHeight = pixelColorValues[gridX][gridY]; - topRightHeight = pixelColorValues[nextX][gridY]; - bottomLeftHeight = pixelColorValues[gridX][nextY]; - bottomRightHeight = pixelColorValues[nextX][nextY]; + topRightHeight = pixelColorValues[gridX + 1][gridY]; + bottomLeftHeight = pixelColorValues[gridX][gridY + 1]; + bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1]; - float interpolatedHeight; + // Interpolate between the 4 vertices + + float offsetX = (gridSquare.x - gridX); + float offsetY = gridSquare.y - gridY; interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX); interpolatedHeight += (bottomRightHeight * offsetY * offsetX); From bf9fdae58ba2ae4a57d72661d7e474babe16f86a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 14:31:48 -0400 Subject: [PATCH 096/289] Method moved to manager. --- src/engine/InterestManagement/HeightMap.java | 8 -------- src/engine/gameManager/ZoneManager.java | 8 ++++++++ src/engine/net/client/handlers/PlaceAssetMsgHandler.java | 5 ++--- src/engine/objects/Bane.java | 3 +-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index dab19d2d..06813a46 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -351,14 +351,6 @@ public class HeightMap { } - public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { - - float localAltitude = HeightMap.getWorldHeight(currentLoc); - Zone zone = ZoneManager.findSmallestZone(currentLoc); - - return localAltitude < zone.getSeaLevel(); - } - private static void generatePixelData(HeightMap heightMap) { Color color; diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 8967dad8..8da4ee9e 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -481,4 +481,12 @@ public enum ZoneManager { return worldAlttitude; } + + public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { + + float localAltitude = HeightMap.getWorldHeight(currentLoc); + Zone zone = findSmallestZone(currentLoc); + + return localAltitude < zone.getSeaLevel(); + } } diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index f20d216c..3abbb6f2 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -2,7 +2,6 @@ package engine.net.client.handlers; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.InterestManager; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; @@ -112,7 +111,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Cannot place a tree underwater - if (HeightMap.isLocUnderwater(placementInfo.getLoc())) { + if (ZoneManager.isLocUnderwater(placementInfo.getLoc())) { PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater return false; } @@ -178,7 +177,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Cannot place a building underwater - if (HeightMap.isLocUnderwater(placementInfo.getLoc())) { + if (ZoneManager.isLocUnderwater(placementInfo.getLoc())) { PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater return false; } diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index 5b98aaa4..8ba5a1f9 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -13,7 +13,6 @@ import engine.Enum; import engine.Enum.ProtectionState; import engine.Enum.SiegePhase; import engine.Enum.SiegeResult; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.WorldGrid; import engine.db.archive.BaneRecord; import engine.db.archive.DataWarehouse; @@ -135,7 +134,7 @@ public final class Bane { // Cannot place banestone underwater; - if (HeightMap.isLocUnderwater(player.getLoc())) { + if (ZoneManager.isLocUnderwater(player.getLoc())) { PlaceAssetMsg.sendPlaceAssetError(origin, 6, ""); // Cannot place underwater return false; } From 46b3db033bbde6ea9726e21543da2040d6dee369 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 15:43:01 -0400 Subject: [PATCH 097/289] Inlined empty getters --- src/engine/Enum.java | 2 +- src/engine/InterestManagement/HeightMap.java | 19 ++- src/engine/db/archive/CityRecord.java | 2 +- src/engine/db/archive/MineRecord.java | 2 +- src/engine/db/archive/PvpRecord.java | 2 +- src/engine/db/handlers/dbZoneHandler.java | 12 +- src/engine/devcmd/cmds/AddMobCmd.java | 2 +- src/engine/devcmd/cmds/AuditMobsCmd.java | 6 +- src/engine/devcmd/cmds/GetHeightCmd.java | 12 +- src/engine/devcmd/cmds/GetOffsetCmd.java | 2 +- src/engine/devcmd/cmds/GetZoneCmd.java | 2 +- src/engine/devcmd/cmds/GotoCmd.java | 6 +- src/engine/devcmd/cmds/HotzoneCmd.java | 4 +- src/engine/devcmd/cmds/InfoCmd.java | 4 +- src/engine/devcmd/cmds/MakeBaneCmd.java | 4 +- src/engine/devcmd/cmds/PurgeObjectsCmd.java | 2 +- src/engine/devcmd/cmds/RealmInfoCmd.java | 6 +- src/engine/devcmd/cmds/RemoveBaneCmd.java | 4 +- src/engine/devcmd/cmds/RemoveObjectCmd.java | 2 +- src/engine/devcmd/cmds/SeaAuditCmd.java | 4 +- src/engine/devcmd/cmds/SetBaneActiveCmd.java | 4 +- .../devcmd/cmds/SetForceRenameCityCmd.java | 4 +- src/engine/devcmd/cmds/SummonCmd.java | 2 +- src/engine/devcmd/cmds/ZoneInfoCmd.java | 24 ++-- src/engine/devcmd/cmds/ZoneSetCmd.java | 2 +- src/engine/gameManager/LootManager.java | 2 +- src/engine/gameManager/MovementManager.java | 2 +- src/engine/gameManager/ZoneManager.java | 48 +++---- .../mobileAI/utilities/MovementUtilities.java | 4 +- src/engine/net/client/ClientMessagePump.java | 6 +- .../handlers/AbandonAssetMsgHandler.java | 2 +- .../handlers/AssetSupportMsgHandler.java | 2 +- .../handlers/ChannelMuteMsgHandler.java | 2 +- .../handlers/ClaimGuildTreeMsgHandler.java | 2 +- .../handlers/ManageCityAssetMsgHandler.java | 6 +- .../handlers/ObjectActionMsgHandler.java | 2 +- .../client/handlers/OrderNPCMsgHandler.java | 2 +- .../client/handlers/PlaceAssetMsgHandler.java | 44 +++--- .../handlers/RepairBuildingMsgHandler.java | 4 +- src/engine/net/client/msg/CityAssetMsg.java | 2 +- .../net/client/msg/GuildTreeStatusMsg.java | 4 +- .../net/client/msg/ManageCityAssetsMsg.java | 12 +- .../net/client/msg/ViewResourcesMessage.java | 2 +- .../objects/AbstractIntelligenceAgent.java | 2 +- src/engine/objects/Bane.java | 4 +- src/engine/objects/Building.java | 6 +- src/engine/objects/City.java | 10 +- src/engine/objects/ItemFactory.java | 4 +- src/engine/objects/Mine.java | 4 +- src/engine/objects/NPC.java | 4 +- src/engine/objects/PlayerCharacter.java | 30 ++-- src/engine/objects/Runegate.java | 2 +- src/engine/objects/Warehouse.java | 2 +- src/engine/objects/Zone.java | 129 ++++-------------- .../poweractions/SummonPowerAction.java | 2 +- src/engine/server/world/WorldServer.java | 4 +- src/engine/workthreads/DestroyCityThread.java | 4 +- src/engine/workthreads/HourlyJobThread.java | 4 +- 58 files changed, 210 insertions(+), 284 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 2510c2ac..b7b78c73 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -469,7 +469,7 @@ public class Enum { // 14001 does not have a banestone to bind at - if (ruinZone.getLoadNum() == 14001) + if (ruinZone.loadNum == 14001) spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30); else spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc() diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 06813a46..06957997 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -154,8 +154,8 @@ public class HeightMap { this.heightMapID = 999999; this.maxHeight = 0; - int halfExtentsX = (int) zone.getBounds().getHalfExtents().x; - int halfExtentsY = (int) zone.getBounds().getHalfExtents().y; + int halfExtentsX = (int) zone.bounds.getHalfExtents().x; + int halfExtentsY = (int) zone.bounds.getHalfExtents().y; this.zoneLoadID = 0; this.seaLevel = 0; @@ -191,7 +191,7 @@ public class HeightMap { HeightMap heightMap = new HeightMap(zone); - HeightMap.heightmapByLoadNum.put(zone.getLoadNum(), heightMap); + HeightMap.heightmapByLoadNum.put(zone.loadNum, heightMap); } @@ -206,7 +206,7 @@ public class HeightMap { return zone; while (nextZone.getHeightMap() == null) - nextZone = nextZone.getParent(); + nextZone = nextZone.parent; return nextZone; } @@ -247,9 +247,14 @@ public class HeightMap { } private static float interpolatePLANAR(Vector3fImmutable worldLoc, Zone heightMapZone, Vector2f zoneLoc, float interpolatedTerrainHeight) { + + // zones of type PLANAR + Zone parentZone; float interpolatedParentTerrainHeight; - parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.getParent()); + + parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.parent); + interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); interpolatedParentTerrainHeight += parentZone.worldAltitude; @@ -263,8 +268,8 @@ public class HeightMap { (heightMapZone.maxBlend.getHalfExtents().y); float currentArea = (blendBounds.getHalfExtents().x) * (blendBounds.getHalfExtents().y); - float zoneArea = (heightMapZone.getBounds().getHalfExtents().x) * - (heightMapZone.getBounds().getHalfExtents().y); + float zoneArea = (heightMapZone.bounds.getHalfExtents().x) * + (heightMapZone.bounds.getHalfExtents().y); blendBounds.release(); diff --git a/src/engine/db/archive/CityRecord.java b/src/engine/db/archive/CityRecord.java index 099ddf7d..f8a0e9c2 100644 --- a/src/engine/db/archive/CityRecord.java +++ b/src/engine/db/archive/CityRecord.java @@ -67,7 +67,7 @@ public class CityRecord extends DataRecord { cityRecord.locX = cityRecord.city.getTOL().getLoc().x; cityRecord.locY = -cityRecord.city.getTOL().getLoc().z; // flip sign on 'y' coordinate - cityRecord.zoneHash = cityRecord.city.getParent().getHash(); + cityRecord.zoneHash = cityRecord.city.getParent().hash; if (cityRecord.eventType.equals(Enum.RecordEventType.CREATE)) cityRecord.establishedDatetime = cityRecord.city.established; diff --git a/src/engine/db/archive/MineRecord.java b/src/engine/db/archive/MineRecord.java index 25c151bd..ee67a24c 100644 --- a/src/engine/db/archive/MineRecord.java +++ b/src/engine/db/archive/MineRecord.java @@ -52,7 +52,7 @@ public class MineRecord extends DataRecord { mineRecord.eventType = eventType; } - mineRecord.zoneHash = mine.getParentZone().getHash(); + mineRecord.zoneHash = mine.getParentZone().hash; if (character.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) { player = (PlayerCharacter) character; diff --git a/src/engine/db/archive/PvpRecord.java b/src/engine/db/archive/PvpRecord.java index bfe3652e..e90a8832 100644 --- a/src/engine/db/archive/PvpRecord.java +++ b/src/engine/db/archive/PvpRecord.java @@ -281,7 +281,7 @@ public class PvpRecord extends DataRecord { outStatement.setInt(8, this.victim.getLevel()); outStatement.setString(9, DataWarehouse.hasher.encrypt(zone.getObjectUUID())); - outStatement.setString(10, zone.getName()); + outStatement.setString(10, zone.zoneName); outStatement.setFloat(11, this.location.getX()); outStatement.setFloat(12, -this.location.getZ()); // flip sign on 'y' coordinate outStatement.setBoolean(13, this.pvpExp); diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 84abc1a7..c367d22e 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -33,18 +33,18 @@ public class dbZoneHandler extends dbHandlerBase { ArrayList wsmList = new ArrayList<>(); wsmList.addAll(zone.getNodes()); if (zone.absX == 0.0f) { - zone.absX = zone.getXCoord(); + zone.absX = zone.xCoord; } if (zone.absY == 0.0f) { - zone.absY = zone.getYCoord(); + zone.absY = zone.yCoord; } if (zone.absZ == 0.0f) { - zone.absZ = zone.getZCoord(); + zone.absZ = zone.zCoord; } for (Zone child : zone.getNodes()) { - child.absX = child.getXCoord() + zone.absX; - child.absY = child.getYCoord() + zone.absY; - child.absZ = child.getZCoord() + zone.absZ; + child.absX = child.xCoord + zone.absX; + child.absY = child.yCoord + zone.absY; + child.absZ = child.zCoord + zone.absZ; wsmList.addAll(this.GET_ALL_NODES(child)); } return wsmList; diff --git a/src/engine/devcmd/cmds/AddMobCmd.java b/src/engine/devcmd/cmds/AddMobCmd.java index 59e0f7e7..30fbac56 100644 --- a/src/engine/devcmd/cmds/AddMobCmd.java +++ b/src/engine/devcmd/cmds/AddMobCmd.java @@ -78,7 +78,7 @@ public class AddMobCmd extends AbstractDevCmd { return; } - if (zone.isPlayerCity()) { + if (zone.isPlayerCity) { throwbackError(pc, "Cannot use ./mob on Player cities. Try ./servermob instead."); return; } diff --git a/src/engine/devcmd/cmds/AuditMobsCmd.java b/src/engine/devcmd/cmds/AuditMobsCmd.java index d8586911..42a22506 100644 --- a/src/engine/devcmd/cmds/AuditMobsCmd.java +++ b/src/engine/devcmd/cmds/AuditMobsCmd.java @@ -40,8 +40,8 @@ public class AuditMobsCmd extends AbstractDevCmd { if (size >= count) { plusplus++; - throwbackInfo(pcSender, zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. "); - System.out.println(zoneMicro.getName() + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. "); + throwbackInfo(pcSender, zoneMicro.zoneName + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. "); + System.out.println(zoneMicro.zoneName + " at location " + zoneMicro.getLoc().toString() + " has " + size + " mobs. "); } @@ -80,7 +80,7 @@ public class AuditMobsCmd extends AbstractDevCmd { //ConcurrentHashMap respawnMap = Mob.getRespawnMap(); // ConcurrentHashMap despawnMap = Mob.getDespawnMap(); - throwbackInfo(pcSender, zone.getName() + ", numMobs: " + zone.zoneMobSet.size()); + throwbackInfo(pcSender, zone.zoneName + ", numMobs: " + zone.zoneMobSet.size()); throwbackInfo(pcSender, "UUID, dbID, inRespawnMap, isAlive, activeAI, Loc"); diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index df8331a5..29792691 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -34,7 +34,7 @@ public class GetHeightCmd extends AbstractDevCmd { currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone); - parentZone = HeightMap.getNextZoneWithTerrain(currentZone.getParent()); + parentZone = HeightMap.getNextZoneWithTerrain(currentZone.parent); float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc()); float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc()); @@ -42,17 +42,17 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc); - this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.getName()); - this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.getName()); + this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); + this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude); - this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.getSeaLevel()); - this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.getSeaLevel() + playerCharacter.getCharacterHeight())); + this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); + this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.seaLevel + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); this.throwbackInfo(playerCharacter, "*** 256: " + currentHeight); this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight())); this.throwbackInfo(playerCharacter, "------------"); - this.throwbackInfo(playerCharacter, "Parent : " + parentZone.getName()); + this.throwbackInfo(playerCharacter, "Parent : " + parentZone.zoneName); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "------------"); diff --git a/src/engine/devcmd/cmds/GetOffsetCmd.java b/src/engine/devcmd/cmds/GetOffsetCmd.java index 46c75b14..2330a8b1 100644 --- a/src/engine/devcmd/cmds/GetOffsetCmd.java +++ b/src/engine/devcmd/cmds/GetOffsetCmd.java @@ -48,7 +48,7 @@ public class GetOffsetCmd extends AbstractDevCmd { float difY = pcSender.getLoc().y - zone.absY; float difZ = pcSender.getLoc().z - zone.absZ; - throwbackInfo(pcSender, zone.getName() + ": (x: " + difX + ", y: " + difY + ", z: " + difZ + ')'); + throwbackInfo(pcSender, zone.zoneName + ": (x: " + difX + ", y: " + difY + ", z: " + difZ + ')'); } @Override diff --git a/src/engine/devcmd/cmds/GetZoneCmd.java b/src/engine/devcmd/cmds/GetZoneCmd.java index dc7c3693..a2deba81 100644 --- a/src/engine/devcmd/cmds/GetZoneCmd.java +++ b/src/engine/devcmd/cmds/GetZoneCmd.java @@ -51,7 +51,7 @@ public class GetZoneCmd extends AbstractDevCmd { } for (Zone zone : allIn) - throwbackInfo(pcSender, zone.getName() + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.getLoadNum()); + throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.loadNum); } @Override diff --git a/src/engine/devcmd/cmds/GotoCmd.java b/src/engine/devcmd/cmds/GotoCmd.java index 95ab5f93..e2864d82 100644 --- a/src/engine/devcmd/cmds/GotoCmd.java +++ b/src/engine/devcmd/cmds/GotoCmd.java @@ -81,7 +81,7 @@ public class GotoCmd extends AbstractDevCmd { continue; Zone zone = city.getParent(); if (zone != null) { - if (zone.isNPCCity() || zone.isPlayerCity()) + if (zone.isNPCCity || zone.isPlayerCity) loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); else loc = zone.getLoc(); @@ -97,10 +97,10 @@ public class GotoCmd extends AbstractDevCmd { Zone zone = (Zone) zoneAgo; if (zone == null) continue; - if (!zone.getName().equalsIgnoreCase(cityName)) + if (!zone.zoneName.equalsIgnoreCase(cityName)) continue; if (zone != null) { - if (zone.isNPCCity() || zone.isPlayerCity()) + if (zone.isNPCCity || zone.isPlayerCity) loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); else loc = zone.getLoc(); diff --git a/src/engine/devcmd/cmds/HotzoneCmd.java b/src/engine/devcmd/cmds/HotzoneCmd.java index 2aa88f14..67db790f 100644 --- a/src/engine/devcmd/cmds/HotzoneCmd.java +++ b/src/engine/devcmd/cmds/HotzoneCmd.java @@ -40,7 +40,7 @@ public class HotzoneCmd extends AbstractDevCmd { String input = data.toString().trim(); if (input.length() == 0) { - outString = "Current hotZone: " + ZoneManager.hotZone.getName() + "\r\n"; + outString = "Current hotZone: " + ZoneManager.hotZone.zoneName + "\r\n"; outString += "Available hotZones: " + ZoneManager.availableHotZones(); throwbackInfo(playerCharacter, outString); return; @@ -48,7 +48,7 @@ public class HotzoneCmd extends AbstractDevCmd { if (input.equalsIgnoreCase("random")) { ZoneManager.generateAndSetRandomHotzone(); - outString = "New hotZone: " + ZoneManager.hotZone.getName() + "\r\n"; + outString = "New hotZone: " + ZoneManager.hotZone.zoneName + "\r\n"; outString += "Available hotZones: " + ZoneManager.availableHotZones(); throwbackInfo(playerCharacter, outString); return; diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 51edb93a..34bb73e2 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -387,7 +387,7 @@ public class InfoCmd extends AbstractDevCmd { output += newline; output += "EquipSet: " + targetNPC.getEquipmentSetID(); output += newline; - output += "Parent Zone LoadNum : " + targetNPC.getParentZone().getLoadNum(); + output += "Parent Zone LoadNum : " + targetNPC.getParentZone().loadNum; } @@ -473,7 +473,7 @@ public class InfoCmd extends AbstractDevCmd { output += "EquipSet: " + targetMob.equipmentSetID; output += newline; try { - output += "Parent Zone LoadNum : " + targetMob.getParentZone().getLoadNum(); + output += "Parent Zone LoadNum : " + targetMob.getParentZone().loadNum; } catch (Exception ex) { //who cares } diff --git a/src/engine/devcmd/cmds/MakeBaneCmd.java b/src/engine/devcmd/cmds/MakeBaneCmd.java index e4328ec0..17f82685 100644 --- a/src/engine/devcmd/cmds/MakeBaneCmd.java +++ b/src/engine/devcmd/cmds/MakeBaneCmd.java @@ -111,12 +111,12 @@ public class MakeBaneCmd extends AbstractDevCmd { return; } - if (!zone.isPlayerCity()) { + if (!zone.isPlayerCity) { throwbackError(pc, "This is not a player city."); return; } - City city = City.getCity(zone.getPlayerCityUUID()); + City city = City.getCity(zone.playerCityID); if (city == null) { throwbackError(pc, "Unable to find the city associated with this zone."); return; diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index 74922c07..deb30cd8 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -42,7 +42,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { private static void PurgeWalls(Zone zone, PlayerCharacter pc) { - if (!zone.isPlayerCity()) + if (!zone.isPlayerCity) return; for (Building building : zone.zoneBuildingSet) { diff --git a/src/engine/devcmd/cmds/RealmInfoCmd.java b/src/engine/devcmd/cmds/RealmInfoCmd.java index 21c29e8d..916e51a6 100644 --- a/src/engine/devcmd/cmds/RealmInfoCmd.java +++ b/src/engine/devcmd/cmds/RealmInfoCmd.java @@ -60,12 +60,12 @@ public class RealmInfoCmd extends AbstractDevCmd { outString += ")"; outString += newline; - outString += " Zone: " + serverZone.getName(); + outString += " Zone: " + serverZone.zoneName; outString += newline; - if (serverZone.getParent() != null) - outString += " Parent: " + serverZone.getParent().getName(); + if (serverZone.parent != null) + outString += " Parent: " + serverZone.parent.zoneName; else outString += "Parent: NONE"; diff --git a/src/engine/devcmd/cmds/RemoveBaneCmd.java b/src/engine/devcmd/cmds/RemoveBaneCmd.java index 31994552..0e760f50 100644 --- a/src/engine/devcmd/cmds/RemoveBaneCmd.java +++ b/src/engine/devcmd/cmds/RemoveBaneCmd.java @@ -34,12 +34,12 @@ public class RemoveBaneCmd extends AbstractDevCmd { return; } - if (!zone.isPlayerCity()) { + if (!zone.isPlayerCity) { throwbackError(pc, "This is not a player city."); return; } - City city = City.getCity(zone.getPlayerCityUUID()); + City city = City.getCity(zone.playerCityID); if (city == null) { throwbackError(pc, "Unable to find the city associated with this zone."); return; diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index 6f7ac8f0..19a9fd2c 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -130,7 +130,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { building.disableSpire(false); if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)) { - City city = City.getCity(building.getParentZone().getPlayerCityUUID()); + City city = City.getCity(building.getParentZone().playerCityID); if (city != null) { city.setWarehouseBuildingID(0); } diff --git a/src/engine/devcmd/cmds/SeaAuditCmd.java b/src/engine/devcmd/cmds/SeaAuditCmd.java index 5ec6a40f..f5cdbdde 100644 --- a/src/engine/devcmd/cmds/SeaAuditCmd.java +++ b/src/engine/devcmd/cmds/SeaAuditCmd.java @@ -26,8 +26,8 @@ public class SeaAuditCmd extends AbstractDevCmd { AbstractGameObject target) { for (Zone zone : ZoneManager.getAllZones()) - if (zone.getSeaLevel() > zone.worldAltitude) - this.throwbackInfo(playerCharacter, zone.getObjectUUID() + zone.getName()); + if (zone.seaLevel > zone.worldAltitude) + this.throwbackInfo(playerCharacter, zone.getObjectUUID() + zone.zoneName); } @Override diff --git a/src/engine/devcmd/cmds/SetBaneActiveCmd.java b/src/engine/devcmd/cmds/SetBaneActiveCmd.java index eb24655b..e7c0ba56 100644 --- a/src/engine/devcmd/cmds/SetBaneActiveCmd.java +++ b/src/engine/devcmd/cmds/SetBaneActiveCmd.java @@ -41,12 +41,12 @@ public class SetBaneActiveCmd extends AbstractDevCmd { return; } - if (!zone.isPlayerCity()) { + if (!zone.isPlayerCity) { throwbackError(pc, "This is not a player city."); return; } - City city = City.getCity(zone.getPlayerCityUUID()); + City city = City.getCity(zone.playerCityID); if (city == null) { throwbackError(pc, "Unable to find the city associated with this zone."); return; diff --git a/src/engine/devcmd/cmds/SetForceRenameCityCmd.java b/src/engine/devcmd/cmds/SetForceRenameCityCmd.java index 3fded48b..5b275697 100644 --- a/src/engine/devcmd/cmds/SetForceRenameCityCmd.java +++ b/src/engine/devcmd/cmds/SetForceRenameCityCmd.java @@ -31,9 +31,9 @@ public class SetForceRenameCityCmd extends AbstractDevCmd { if (zone == null) return; boolean rename = words[0].equalsIgnoreCase("true") ? true : false; - if (zone.getPlayerCityUUID() == 0) + if (zone.playerCityID == 0) return; - City city = City.getCity(zone.getPlayerCityUUID()); + City city = City.getCity(zone.playerCityID); if (city == null) return; city.setForceRename(rename); diff --git a/src/engine/devcmd/cmds/SummonCmd.java b/src/engine/devcmd/cmds/SummonCmd.java index 184903ca..6877db2c 100644 --- a/src/engine/devcmd/cmds/SummonCmd.java +++ b/src/engine/devcmd/cmds/SummonCmd.java @@ -40,7 +40,7 @@ public class SummonCmd extends AbstractDevCmd { Zone zone = ZoneManager.findSmallestZone(pc.getLoc()); String location = "Somewhere"; if (zone != null) - location = zone.getName(); + location = zone.zoneName; RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(), location, false); toSummon.getClientConnection().sendMsg(rsrm); diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 6a1daa3d..17d1226a 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -73,21 +73,21 @@ public class ZoneInfoCmd extends AbstractDevCmd { output = "Target Information:" + newline; output += StringUtils.addWS("UUID: " + objectUUID, 20); output += newline; - output += "name: " + zone.getName(); + output += "name: " + zone.zoneName; output += newline; - output += "loadNum: " + zone.getLoadNum(); - if (zone.getParent() != null) { - output += StringUtils.addWS(", parent: " + zone.getParent().getObjectUUID(), 30); - output += "Parentabs: x: " + zone.getParent().getAbsX() + ", y: " + zone.getParent().getAbsY() + ", z: " + zone.getParent().getAbsZ(); + output += "loadNum: " + zone.loadNum; + if (zone.parent != null) { + output += StringUtils.addWS(", parent: " + zone.parent.getObjectUUID(), 30); + output += "Parentabs: x: " + zone.parent.absX + ", y: " + zone.parent.absY + ", z: " + zone.parent.absZ; } else output += StringUtils.addWS(", parent: none", 30); output += newline; - output += "absLoc: x: " + zone.getAbsX() + ", y: " + zone.getAbsY() + ", z: " + zone.getAbsZ(); + output += "absLoc: x: " + zone.absX + ", y: " + zone.absY + ", z: " + zone.absZ; output += newline; - output += "offset: x: " + zone.getXCoord() + ", y: " + zone.getYCoord() + ", z: " + zone.getZCoord(); + output += "offset: x: " + zone.xCoord + ", y: " + zone.yCoord + ", z: " + zone.zCoord; output += newline; - output += "radius: x: " + zone.getBounds().getHalfExtents().x + ", z: " + zone.getBounds().getHalfExtents().y; + output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; output += newline; if (zone.getHeightMap() != null) { @@ -98,11 +98,11 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += "Bucket Width Y : " + zone.getHeightMap().bucketWidthY; } - output += "radius: x: " + zone.getBounds().getHalfExtents().x + ", z: " + zone.getBounds().getHalfExtents().y; + output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; output += newline; // output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl(); output += newline; - output += "Sea Level = " + zone.getSeaLevel(); + output += "Sea Level = " + zone.seaLevel; output += newline; output += "World Altitude = " + zone.worldAltitude; throwbackInfo(player, output); @@ -110,7 +110,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { City city = ZoneManager.getCityAtLocation(player.getLoc()); output += newline; - output += (city == null) ? "None" : city.getParent().getName(); + output += (city == null) ? "None" : city.getParent().zoneName; if (city != null) { @@ -130,7 +130,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { for (Zone child : nodes) { output += newline; - output += child.getName() + " (" + child.getLoadNum() + ')'; + output += child.zoneName + " (" + child.loadNum + ')'; } } throwbackInfo(player, output); diff --git a/src/engine/devcmd/cmds/ZoneSetCmd.java b/src/engine/devcmd/cmds/ZoneSetCmd.java index 2d6b3a56..9da9cbbd 100644 --- a/src/engine/devcmd/cmds/ZoneSetCmd.java +++ b/src/engine/devcmd/cmds/ZoneSetCmd.java @@ -40,7 +40,7 @@ public class ZoneSetCmd extends AbstractDevCmd { zone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); - throwbackInfo(playerCharacter, zone.getName() + " (" + zone.getLoadNum() + ") " + zone.getObjectUUID()); + throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.loadNum + ") " + zone.getObjectUUID()); // NPC diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index 96d699b4..16409aaf 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -86,7 +86,7 @@ public enum LootManager { if(ib == null) break; if (ib.isDiscRune() || ib.getName().toLowerCase().contains("of the gods")) { - ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().getName() + " has found the " + ib.getName() + ". Are you tough enough to take it?"); + ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + ib.getName() + ". Are you tough enough to take it?"); chatMsg.setMessageType(10); chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index 6bc4ced5..c8f3569e 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -267,7 +267,7 @@ public enum MovementManager { Zone serverZone = null; serverZone = ZoneManager.findSmallestZone(player.getLoc()); - cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.getPlayerCityUUID()); + cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.playerCityID); // Do not send group messages if player is on grid diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 8da4ee9e..77ecd6a7 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -61,8 +61,8 @@ public enum ZoneManager { if (zone != null) { allIn.add(zone); - while (zone.getParent() != null) { - zone = zone.getParent(); + while (zone.parent != null) { + zone = zone.parent; allIn.add(zone); } } @@ -90,7 +90,7 @@ public enum ZoneManager { if (nodes != null) for (Zone child : nodes) { - if (Bounds.collide(loc, child.getBounds()) == true) { + if (Bounds.collide(loc, child.bounds) == true) { zone = child; childFound = true; break; @@ -106,7 +106,7 @@ public enum ZoneManager { ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone); - ZoneManager.zonesByName.put(zone.getName().toLowerCase(), zone); + ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone); } @@ -169,7 +169,7 @@ public enum ZoneManager { if (ZoneManager.hotZone == null) return false; - return (Bounds.collide(loc, ZoneManager.hotZone.getBounds()) == true); + return (Bounds.collide(loc, ZoneManager.hotZone.bounds) == true); } public static Zone getSeaFloor() { @@ -182,7 +182,7 @@ public enum ZoneManager { public static final void populateWorldZones(final Zone zone) { - int loadNum = zone.getLoadNum(); + int loadNum = zone.loadNum; // Zones are added to separate // collections for quick access @@ -194,12 +194,12 @@ public enum ZoneManager { } - if (zone.isPlayerCity()) { + if (zone.isPlayerCity) { addPlayerCityZone(zone); return; } - if (zone.isNPCCity()) + if (zone.isNPCCity) addNPCCityZone(zone); } @@ -209,12 +209,12 @@ public enum ZoneManager { } private static void addNPCCityZone(final Zone zone) { - zone.setNPCCity(true); + zone.isNPCCity = true; ZoneManager.npcCityZones.add(zone); } public static final void addPlayerCityZone(final Zone zone) { - zone.setPlayerCity(true); + zone.isPlayerCity = true; ZoneManager.playerCityZones.add(zone); } @@ -250,7 +250,7 @@ public enum ZoneManager { public static final boolean validHotZone(Zone zone) { - if (zone.getSafeZone() == (byte) 1) + if (zone.peaceZone == (byte) 1) return false; // no safe zone hotzones// if (this.hotzone == null) if (zone.getNodes().isEmpty()) @@ -298,14 +298,14 @@ public enum ZoneManager { // Top left corner of zone is calculated in world space by the center and it's extents. zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z); - zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.getBounds().getHalfExtents().x, serverZone.getBounds().getHalfExtents().y)); + zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.bounds.getHalfExtents().x, serverZone.bounds.getHalfExtents().y)); // Local coordinate in world space translated to an offset from the calculated zone origin. localCoords = new Vector2f(worldVector.x, worldVector.z); localCoords = localCoords.subtract(zoneOrigin); - localCoords.setY((serverZone.getBounds().getHalfExtents().y * 2) - localCoords.y); + localCoords.setY((serverZone.bounds.getHalfExtents().y * 2) - localCoords.y); // TODO : Make sure this value does not go outside the zone's bounds. @@ -387,8 +387,8 @@ public enum ZoneManager { currentZone = ZoneManager.findSmallestZone(worldLoc); - if (currentZone.isPlayerCity()) - return City.getCity(currentZone.getPlayerCityUUID()); + if (currentZone.isPlayerCity) + return City.getCity(currentZone.playerCityID); return null; } @@ -420,7 +420,7 @@ public enum ZoneManager { if (zone.isContinent()) continue; - if (Bounds.collide(treeBounds, zone.getBounds(), 0.0f)) + if (Bounds.collide(treeBounds, zone.bounds, 0.0f)) validLocation = false; } @@ -440,8 +440,8 @@ public enum ZoneManager { //not player city, must be npc city.. - if (!zone.isPlayerCity()) - zone.setNPCCity(true); + if (!zone.isPlayerCity) + zone.isNPCCity = true; if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) { @@ -461,15 +461,15 @@ public enum ZoneManager { // Seafloor - if (zone.getParent() == null) + if (zone.parent == null) return worldAlttitude; - Zone parentZone = zone.getParent(); + Zone parentZone = zone.parent; // Children of seafloor - if (parentZone.getParent() == null) - return worldAlttitude + zone.getYCoord(); + if (parentZone.parent == null) + return worldAlttitude + zone.yCoord; // return height from heightmap engine at zone location @@ -477,7 +477,7 @@ public enum ZoneManager { // Add zone offset to value - worldAlttitude += zone.getYCoord(); + worldAlttitude += zone.yCoord; return worldAlttitude; } @@ -487,6 +487,6 @@ public enum ZoneManager { float localAltitude = HeightMap.getWorldHeight(currentLoc); Zone zone = findSmallestZone(currentLoc); - return localAltitude < zone.getSeaLevel(); + return localAltitude < zone.seaLevel; } } diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 63a6982b..c00bfffa 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -68,8 +68,8 @@ public class MovementUtilities { float zoneRange = 250; if (agent.getParentZone() != null) { - if (agent.getParentZone().getBounds() != null) - zoneRange = agent.getParentZone().getBounds().getHalfExtents().x * 2; + if (agent.getParentZone().bounds != null) + zoneRange = agent.getParentZone().bounds.getHalfExtents().x * 2; } if (zoneRange > 300) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 14f62c3b..8086ef33 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1196,7 +1196,7 @@ public class ClientMessagePump implements NetMsgHandler { if (npc.getCharItemManager().getInventoryCount() > 150) { - if (npc.getParentZone() != null && npc.getParentZone().getPlayerCityUUID() == 0) { + if (npc.getParentZone() != null && npc.getParentZone().playerCityID == 0) { ArrayList inv = npc.getInventory(); for (int i = 0; i < 20; i++) { try { @@ -1229,7 +1229,7 @@ public class ClientMessagePump implements NetMsgHandler { if (ib == null) return; - if (npc.getParentZone() != null && npc.getParentZone().getPlayerCityUUID() != 0) + if (npc.getParentZone() != null && npc.getParentZone().playerCityID != 0) if (!npc.getCharItemManager().hasRoomInventory(ib.getWeight())) { ErrorPopupMsg.sendErrorPopup(player, 21); @@ -1280,7 +1280,7 @@ public class ClientMessagePump implements NetMsgHandler { if (building != null && building.getProtectionState().equals(ProtectionState.NPC)) building = null; - if (npc.getParentZone().getPlayerCityUUID() == 0) + if (npc.getParentZone().playerCityID == 0) building = null; //make sure npc can afford item diff --git a/src/engine/net/client/handlers/AbandonAssetMsgHandler.java b/src/engine/net/client/handlers/AbandonAssetMsgHandler.java index 168afbf0..8774242d 100644 --- a/src/engine/net/client/handlers/AbandonAssetMsgHandler.java +++ b/src/engine/net/client/handlers/AbandonAssetMsgHandler.java @@ -151,7 +151,7 @@ public class AbandonAssetMsgHandler extends AbstractClientMsgHandler { cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc()); // Can't abandon a tree not within a player city zone - if (cityZone.isPlayerCity() == false) + if (cityZone.isPlayerCity == false) return; if (targetBuilding.getCity() == null) diff --git a/src/engine/net/client/handlers/AssetSupportMsgHandler.java b/src/engine/net/client/handlers/AssetSupportMsgHandler.java index d7bcc3d3..0f4439ae 100644 --- a/src/engine/net/client/handlers/AssetSupportMsgHandler.java +++ b/src/engine/net/client/handlers/AssetSupportMsgHandler.java @@ -45,7 +45,7 @@ public class AssetSupportMsgHandler extends AbstractClientMsgHandler { if (serverZone == null) return; - serverCity = City.GetCityFromCache(serverZone.getPlayerCityUUID()); + serverCity = City.GetCityFromCache(serverZone.playerCityID); if (serverCity == null) return; diff --git a/src/engine/net/client/handlers/ChannelMuteMsgHandler.java b/src/engine/net/client/handlers/ChannelMuteMsgHandler.java index 71d40686..30a003fc 100644 --- a/src/engine/net/client/handlers/ChannelMuteMsgHandler.java +++ b/src/engine/net/client/handlers/ChannelMuteMsgHandler.java @@ -65,7 +65,7 @@ public class ChannelMuteMsgHandler extends AbstractClientMsgHandler { cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc()); // Can't abandon a tree not within a player city zone - if (cityZone.isPlayerCity() == false) + if (cityZone.isPlayerCity == false) return; if (targetBuilding.getCity().hasBeenTransfered == true) { diff --git a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java index 23570e45..c942f40c 100644 --- a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java +++ b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java @@ -69,7 +69,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler { playerZone = building.getParentZone(); if (playerZone != null) - playerCity = City.getCity(playerZone.getPlayerCityUUID()); + playerCity = City.getCity(playerZone.playerCityID); // Oops! *** Refactor: Log error switch (msg.getMessageType()) { diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index e2b0af01..0f55d6a0 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -75,12 +75,12 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { Zone zone = ZoneManager.findSmallestZone(player.getLoc()); - if (!zone.isPlayerCity()) { + if (!zone.isPlayerCity) { ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); return true; } - City city = City.GetCityFromCache(zone.getPlayerCityUUID()); + City city = City.GetCityFromCache(zone.playerCityID); if (city == null) { ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); @@ -254,7 +254,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { if (baneZone == null) return true; - City banedCity = City.getCity(baneZone.getPlayerCityUUID()); + City banedCity = City.getCity(baneZone.playerCityID); if (banedCity == null) return true; diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index d6ef538e..1ffba79c 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -334,7 +334,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { Zone zone = ZoneManager.findSmallestZone(player.getLoc()); if (zone != null) { - if (zone.isPlayerCity()) { + if (zone.isPlayerCity) { loc = zone.getLoc(); } } diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index e26933ab..3de83fee 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -288,7 +288,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (zone == null) return false; - if (zone.getPlayerCityUUID() == 0) + if (zone.playerCityID == 0) return false; City city = building.getCity(); diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 3abbb6f2..773bdc81 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -137,7 +137,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { private static boolean validateBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo placementInfo) { - if (serverZone.isPlayerCity() == false) { + if (serverZone.isPlayerCity == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, player.getName()); return false; } @@ -156,7 +156,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Retrieve the building details we're placing - if (serverZone.isNPCCity() == true) { + if (serverZone.isNPCCity == true) { PlaceAssetMsg.sendPlaceAssetError(origin, 15, ""); // Cannot place in a peace zone return false; } @@ -185,7 +185,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Players cannot place buildings in mob zones. if ((serverZone.isMacroZone() == true) - || (serverZone.getParent().isMacroZone() == true)) { + || (serverZone.parent.isMacroZone() == true)) { PlaceAssetMsg.sendPlaceAssetError(origin, 57, player.getName()); // No building may be placed within this territory return false; } @@ -201,8 +201,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Cannot place assets on a dead tree - if ((serverZone.isPlayerCity()) - && (City.getCity(serverZone.getPlayerCityUUID()).getTOL().getRank() == -1)) { + if ((serverZone.isPlayerCity) + && (City.getCity(serverZone.playerCityID).getTOL().getRank() == -1)) { PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot place asset on dead tree until world heals"); return false; } @@ -261,14 +261,14 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Must be a player city - if (serverZone.isPlayerCity() == false) { + if (serverZone.isPlayerCity == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 41, player.getName()); // Cannot place outside a guild zone return false; } //Test zone has a city object - City city = City.getCity(serverZone.getPlayerCityUUID()); + City city = City.getCity(serverZone.playerCityID); if (city == null) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); //"no city to associate asset with" @@ -512,7 +512,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (serverZone == null) return false; - cityObject = City.getCity(serverZone.getPlayerCityUUID()); + cityObject = City.getCity(serverZone.playerCityID); // Early exit if something went horribly wrong @@ -571,7 +571,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // No valid player city found - if (serverCity == null || serverCity.getParent().isPlayerCity() == false) { + if (serverCity == null || serverCity.getParent().isPlayerCity == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); // Cannot place outisde a guild zone return false; } @@ -749,8 +749,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { cityObjects = DbManager.CityQueries.CREATE_CITY(playerCharacter.getObjectUUID(), serverZone.getObjectUUID(), serverRealm.getRealmID(), - plantLoc.x - serverZone.getAbsX(), plantLoc.y, - plantLoc.z - serverZone.getAbsZ(), treeInfo.getRot().y, treeInfo.getW(), playerCharacter.getGuild().getName(), LocalDateTime.now()); + plantLoc.x - serverZone.absX, plantLoc.y, + plantLoc.z - serverZone.absZ, treeInfo.getRot().y, treeInfo.getW(), playerCharacter.getGuild().getName(), LocalDateTime.now()); // Uh oh! @@ -783,10 +783,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Link the zone with the city and then add // to the appropriate hash tables and cache - zoneObject.setPlayerCity(true); + zoneObject.isPlayerCity = true; - if (zoneObject.getParent() != null) - zoneObject.getParent().addNode(zoneObject); //add as child to parent + if (zoneObject.parent != null) + zoneObject.parent.addNode(zoneObject); //add as child to parent ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject); ZoneManager.addPlayerCityZone(zoneObject); @@ -857,7 +857,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (serverZone == null) return false; - cityObject = City.getCity(serverZone.getPlayerCityUUID()); + cityObject = City.getCity(serverZone.playerCityID); if (cityObject == null) return false; @@ -931,7 +931,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { int shrineCount = 0; - cityObject = City.getCity(serverZone.getPlayerCityUUID()); + cityObject = City.getCity(serverZone.playerCityID); // Cannot place shrine in abandoned city. Shrines must be owned // by the tol owner not the person placing them. @@ -1001,7 +1001,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { int barracksCount = 0; - cityObject = City.getCity(serverZone.getPlayerCityUUID()); + cityObject = City.getCity(serverZone.playerCityID); // Cannot place barracks in abandoned city. @@ -1061,7 +1061,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (validateCityBuildingPlacement(serverZone, msg, origin, player, msg.getFirstPlacementInfo()) == false) return false; - cityObject = City.getCity(serverZone.getPlayerCityUUID()); + cityObject = City.getCity(serverZone.playerCityID); // We need to be able to access how much gold a character is carrying @@ -1117,7 +1117,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { building.removeFromCache(); WorldGrid.RemoveWorldObject(building); WorldGrid.removeObject(building); - building.getParentZone().getParent().zoneBuildingSet.remove(building); + building.getParentZone().parent.zoneBuildingSet.remove(building); if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)) { building.RemoveFromBarracksList(); } @@ -1229,7 +1229,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { shrineType = Shrine.getShrineTypeByBlueprintUUID(blueprint.getBlueprintUUID()); - city = City.getCity(currentZone.getPlayerCityUUID()); + city = City.getCity(currentZone.playerCityID); if (city == null) return false; @@ -1294,7 +1294,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; } - city = City.getCity(currentZone.getPlayerCityUUID()); + city = City.getCity(currentZone.playerCityID); if (city == null) return false; @@ -1369,7 +1369,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { newMesh.runAfterLoad(); } else if (ago.getObjectType() == GameObjectType.Warehouse) { Warehouse warehouse = (Warehouse) ago; - City city = City.getCity(currentZone.getPlayerCityUUID()); + City city = City.getCity(currentZone.playerCityID); if (city == null) return true; diff --git a/src/engine/net/client/handlers/RepairBuildingMsgHandler.java b/src/engine/net/client/handlers/RepairBuildingMsgHandler.java index 393c54be..9582b269 100644 --- a/src/engine/net/client/handlers/RepairBuildingMsgHandler.java +++ b/src/engine/net/client/handlers/RepairBuildingMsgHandler.java @@ -44,11 +44,11 @@ public class RepairBuildingMsgHandler extends AbstractClientMsgHandler { serverZone = ZoneManager.findSmallestZone(pc.getLoc()); - if (serverZone.getPlayerCityUUID() == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE) + if (serverZone.playerCityID == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE) return; - City city = City.GetCityFromCache(serverZone.getPlayerCityUUID()); + City city = City.GetCityFromCache(serverZone.playerCityID); if (city != null) { if (city.getBane() != null && city.protectionEnforced == false) diff --git a/src/engine/net/client/msg/CityAssetMsg.java b/src/engine/net/client/msg/CityAssetMsg.java index e83a1830..0d8490d7 100644 --- a/src/engine/net/client/msg/CityAssetMsg.java +++ b/src/engine/net/client/msg/CityAssetMsg.java @@ -92,7 +92,7 @@ public class CityAssetMsg extends ClientNetMsg { return; } - city = City.getCity(zone.getPlayerCityUUID()); + city = City.getCity(zone.playerCityID); if (city == null) { Logger.debug("Failed to load city data for Tree of life."); diff --git a/src/engine/net/client/msg/GuildTreeStatusMsg.java b/src/engine/net/client/msg/GuildTreeStatusMsg.java index f9c662d7..40538544 100644 --- a/src/engine/net/client/msg/GuildTreeStatusMsg.java +++ b/src/engine/net/client/msg/GuildTreeStatusMsg.java @@ -117,8 +117,8 @@ public class GuildTreeStatusMsg extends ClientNetMsg { city = null; if (cityZone != null) - if (cityZone.isPlayerCity()) - city = City.GetCityFromCache(cityZone.getPlayerCityUUID()); + if (cityZone.isPlayerCity) + city = City.GetCityFromCache(cityZone.playerCityID); else if (this.treeOfLife != null && this.treeOfLife.getGuild() != null) city = this.treeOfLife.getGuild().getOwnedCity(); diff --git a/src/engine/net/client/msg/ManageCityAssetsMsg.java b/src/engine/net/client/msg/ManageCityAssetsMsg.java index 473082b2..94cc837b 100644 --- a/src/engine/net/client/msg/ManageCityAssetsMsg.java +++ b/src/engine/net/client/msg/ManageCityAssetsMsg.java @@ -299,8 +299,8 @@ public class ManageCityAssetsMsg extends ClientNetMsg { Set buildings = ZoneManager.findSmallestZone(assetManager.getLoc()).zoneBuildingSet; Building tol = null; - if (playerZone.getPlayerCityUUID() != 0) - city = City.GetCityFromCache(playerZone.getPlayerCityUUID()); + if (playerZone.playerCityID != 0) + city = City.GetCityFromCache(playerZone.playerCityID); if (city != null) tol = city.getTOL(); @@ -368,7 +368,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg { if (zone == null) return; - City banedCity = City.getCity(zone.getPlayerCityUUID()); + City banedCity = City.getCity(zone.playerCityID); if (banedCity == null) return; @@ -479,7 +479,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg { if (zone == null) writer.putString("Forlord"); else - writer.putString(zone.getName()); + writer.putString(zone.zoneName); writer.putString(building.getGuild().getName()); @@ -621,9 +621,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg { } else { writer.putInt(1); //kos on/off? writer.putInt(3); // was 3 - if (zone.getPlayerCityUUID() != 0 && asset.assetIsProtected()) { + if (zone.playerCityID != 0 && asset.assetIsProtected()) { writer.putInt(GameObjectType.Building.ordinal()); - writer.putInt(City.getCity(zone.getPlayerCityUUID()).getTOL().getObjectUUID()); + writer.putInt(City.getCity(zone.playerCityID).getTOL().getObjectUUID()); } else { writer.putInt(0); writer.putInt(0); diff --git a/src/engine/net/client/msg/ViewResourcesMessage.java b/src/engine/net/client/msg/ViewResourcesMessage.java index 9457e159..55a4eab0 100644 --- a/src/engine/net/client/msg/ViewResourcesMessage.java +++ b/src/engine/net/client/msg/ViewResourcesMessage.java @@ -73,7 +73,7 @@ public class ViewResourcesMessage extends ClientNetMsg { if (this.warehouseBuilding.getParentZone() == null) return false; - this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().getPlayerCityUUID()); + this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().playerCityID); if (this.city == null) return false; diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index 193ee31d..2c9313a3 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -130,7 +130,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { ArrayList allIn = ZoneManager.getAllZonesIn(this.getLoc()); for (Zone zone : allIn) - if (zone.getSafeZone() == (byte) 1) + if (zone.peaceZone == (byte) 1) return true; return false; diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index 8ba5a1f9..38f50ff9 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -162,8 +162,8 @@ public final class Bane { // Cannot place assets on a dead tree - if ((cityZone.isPlayerCity()) && - (City.getCity(cityZone.getPlayerCityUUID()).getTOL().getRank() == -1)) { + if ((cityZone.isPlayerCity) && + (City.getCity(cityZone.playerCityID).getTOL().getRank() == -1)) { PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot bane a dead tree!"); return false; } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 7f63ab41..33cf5b06 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -460,10 +460,10 @@ public class Building extends AbstractWorldObject { } } } - if (this.parentZone.isPlayerCity() == false) + if (this.parentZone.isPlayerCity == false) return null; - return City.getCity(this.parentZone.getPlayerCityUUID()); + return City.getCity(this.parentZone.playerCityID); } @@ -1402,7 +1402,7 @@ public class Building extends AbstractWorldObject { // Buildings on an npc citygrid are never vulnerable if (this.getCity() != null) { - if (this.getCity().getParent().isNPCCity() == true) + if (this.getCity().getParent().isNPCCity == true) return false; } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 39b70bd9..834b155e 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -334,7 +334,7 @@ public class City extends AbstractWorldObject { if (city.noTeleport) continue; - if (city.parentZone != null && city.parentZone.isPlayerCity()) { + if (city.parentZone != null && city.parentZone.isPlayerCity) { if (pc.getAccount().status.equals(AccountStatus.ADMIN)) { cities.add(city); @@ -395,7 +395,7 @@ public class City extends AbstractWorldObject { if (city.noRepledge) continue; - if (city.parentZone != null && city.parentZone.isPlayerCity()) { + if (city.parentZone != null && city.parentZone.isPlayerCity) { //list Player cities //open city, just list @@ -589,7 +589,7 @@ public class City extends AbstractWorldObject { if (zone.getHeightMap() == null && this.isNpc == 1 && this.getObjectUUID() != 1213) { HeightMap.GenerateCustomHeightMap(zone); - Logger.info(zone.getName() + " created custom heightmap"); + Logger.info(zone.zoneName + " created custom heightmap"); } } catch (Exception e) { Logger.error(e); @@ -791,7 +791,7 @@ public class City extends AbstractWorldObject { // Any players currently in the zone will not be processed by the heartbeat // if it's not the first effect toggled so we do it here manually - currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, this.parentZone.getBounds().getHalfExtents().x * 1.2f, MBServerStatics.MASK_PLAYER); + currentPlayers = WorldGrid.getObjectsInRangePartial(this.location, this.parentZone.bounds.getHalfExtents().x * 1.2f, MBServerStatics.MASK_PLAYER); for (AbstractWorldObject playerObject : currentPlayers) { @@ -874,7 +874,7 @@ public class City extends AbstractWorldObject { } public boolean isLocationOnCityZone(Vector3fImmutable insideLoc) { - return Bounds.collide(insideLoc, this.parentZone.getBounds()); + return Bounds.collide(insideLoc, this.parentZone.bounds); } private void applyAllCityEffects(PlayerCharacter player) { diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 34b06cb0..20229512 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -104,7 +104,7 @@ public class ItemFactory { if (zone == null) return null; - City city = City.getCity(zone.getPlayerCityUUID()); + City city = City.getCity(zone.playerCityID); if (city == null) return null; @@ -796,7 +796,7 @@ public class ItemFactory { if (zone == null) return null; - City city = City.getCity(zone.getPlayerCityUUID()); + City city = City.getCity(zone.playerCityID); if (city == null) return null; diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 7a2a4b56..5a46af13 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -64,7 +64,7 @@ public class Mine extends AbstractGameObject { this.flags = rs.getInt("flags"); int parent = rs.getInt("parent"); this.parentZone = ZoneManager.getZoneByUUID(parent); - this.zoneName = this.parentZone.getParent().getName(); + this.zoneName = this.parentZone.parent.zoneName; this.owningGuild = Guild.getGuild(ownerUID); Guild nation = null; @@ -129,7 +129,7 @@ public class Mine extends AbstractGameObject { mine.getTimestamps().put("MineAttack", System.currentTimeMillis() + MBServerStatics.ONE_MINUTE); - ChatManager.chatNationInfo(mine.getGuild().getNation(), mine.getName() + " in " + mine.getParentZone().getParent().getName() + " is Under attack!"); + ChatManager.chatNationInfo(mine.getGuild().getNation(), mine.getName() + " in " + mine.getParentZone().parent.zoneName + " is Under attack!"); } public static void loadAllMines() { diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index dfa8e827..662c8a46 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -894,7 +894,7 @@ public class NPC extends AbstractCharacter { this.stamina.set(this.staminaMax); } - if (this.parentZone.isPlayerCity()) + if (this.parentZone.isPlayerCity) if (NPC.GetNPCProfits(this) == null) NPCProfits.CreateProfits(this); @@ -1192,7 +1192,7 @@ public class NPC extends AbstractCharacter { if (serverZone == null) return null; - city = City.GetCityFromCache(serverZone.getPlayerCityUUID()); + city = City.GetCityFromCache(serverZone.playerCityID); if (city == null) { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 69cee884..170d0cec 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1507,16 +1507,16 @@ public class PlayerCharacter extends AbstractCharacter { return true; Zone zone = ZoneManager.findSmallestZone(breather.getLoc()); - if (zone.getSeaLevel() != 0) { + if (zone.seaLevel != 0) { float localAltitude = breather.getLoc().y; - if (localAltitude + breather.characterHeight < zone.getSeaLevel() - 2) + if (localAltitude + breather.characterHeight < zone.seaLevel - 2) return false; if (breather.isMoving()) { - if (localAltitude + breather.characterHeight < zone.getSeaLevel()) + if (localAltitude + breather.characterHeight < zone.seaLevel) return false; } } else { @@ -1547,12 +1547,12 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(enterer.getLoc()); - if (zone.getSeaLevel() != 0) { + if (zone.seaLevel != 0) { float localAltitude = enterer.getLoc().y + enterer.characterHeight; - if (localAltitude < zone.getSeaLevel()) + if (localAltitude < zone.seaLevel) return true; } else { if (enterer.getLoc().y + enterer.characterHeight < 0) @@ -1579,12 +1579,12 @@ public class PlayerCharacter extends AbstractCharacter { leaveWater = 1f; - if (zone.getSeaLevel() != 0) { + if (zone.seaLevel != 0) { float localAltitude = leaver.getLoc().y; - if (localAltitude + leaveWater < zone.getSeaLevel()) + if (localAltitude + leaveWater < zone.seaLevel) return false; } else { if (leaver.getLoc().y + leaveWater < 0) @@ -1703,7 +1703,7 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(this.getLoc()); if (zone != null) { - return zone.getSafeZone() == (byte) 1; + return zone.peaceZone == (byte) 1; } return false; @@ -1797,7 +1797,7 @@ public class PlayerCharacter extends AbstractCharacter { //DeathShroud - if (zone.getSafeZone() == 0) + if (zone.peaceZone == 0) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); //enable this to give players deathshroud if mobs kill player. @@ -1843,7 +1843,7 @@ public class PlayerCharacter extends AbstractCharacter { //DeathShroud - if (zone.getSafeZone() == 0) + if (zone.peaceZone == 0) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); if (doPVPEXP) { @@ -1898,7 +1898,7 @@ public class PlayerCharacter extends AbstractCharacter { killCleanup(); Zone zone = ZoneManager.findSmallestZone(this.getLoc()); - if (zone.getSafeZone() == 0) + if (zone.peaceZone == 0) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); // Send death message if needed @@ -4739,10 +4739,10 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(this.getLoc()); - if (zone.getSeaLevel() != 0) { + if (zone.seaLevel != 0) { float localAltitude = this.getLoc().y + this.centerHeight; - if (localAltitude < zone.getSeaLevel()) + if (localAltitude < zone.seaLevel) return true; } else { if (this.getLoc().y + this.centerHeight < 0) @@ -4764,9 +4764,9 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(currentLoc); - if (zone.getSeaLevel() != 0) { + if (zone.seaLevel != 0) { - if (localAltitude < zone.getSeaLevel()) + if (localAltitude < zone.seaLevel) return true; } else { if (localAltitude < 0) diff --git a/src/engine/objects/Runegate.java b/src/engine/objects/Runegate.java index 762265a5..673df36c 100644 --- a/src/engine/objects/Runegate.java +++ b/src/engine/objects/Runegate.java @@ -108,7 +108,7 @@ public class Runegate { writer.putInt(gateBuilding.getObjectType().ordinal()); writer.putInt(gateBuilding.getObjectUUID()); - writer.putString(gateBuilding.getParentZone().getName()); + writer.putString(gateBuilding.getParentZone().zoneName); writer.putFloat(gateBuilding.getLoc().getLat()); writer.putFloat(gateBuilding.getLoc().getAlt()); writer.putFloat(gateBuilding.getLoc().getLong()); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index f96a5fcb..effb2a83 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -1272,7 +1272,7 @@ public class Warehouse extends AbstractWorldObject { return; } - City city = City.getCity(cityZone.getPlayerCityUUID()); + City city = City.getCity(cityZone.playerCityID); if (city == null) { Logger.error("Failed to load City for Warehouse with UUID " + this.getObjectUUID()); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 42595a35..400c7def 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -33,31 +33,31 @@ public class Zone extends AbstractGameObject { public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); - private final int playerCityID; - private final String zoneName; - private final float xCoord; - private final float zCoord; - private final float yCoord; - private final int loadNum; - private final byte safeZone; - private final String Icon1; - private final String Icon2; - private final String Icon3; + public final int playerCityID; + public final String zoneName; + public final float xCoord; + public final float zCoord; + public final float yCoord; + public final int loadNum; + public final byte peaceZone; + public final String Icon1; + public final String Icon2; + public final String Icon3; public float absX = 0.0f; public float absY = 0.0f; public float absZ = 0.0f; public int minLvl; public int maxLvl; public boolean hasBeenHotzone = false; - private ArrayList nodes = null; - private int parentZoneID; - private Zone parent = null; - private Bounds bounds; - private boolean isNPCCity = false; - private boolean isPlayerCity = false; - private String hash; + public ArrayList nodes = null; + public int parentZoneID; + public Zone parent = null; + public Bounds bounds; + public boolean isNPCCity = false; + public boolean isPlayerCity = false; + public String hash; public float worldAltitude = 0; - private float seaLevel = 0f; + public float seaLevel = 0f; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; public Bounds maxBlend; @@ -75,7 +75,7 @@ public class Zone extends AbstractGameObject { this.zCoord = rs.getFloat("ZCoord"); this.yCoord = rs.getFloat("YOffset"); this.loadNum = rs.getInt("LoadNum"); - this.safeZone = rs.getByte("SafeZone"); + this.peaceZone = rs.getByte("SafeZone"); this.Icon1 = rs.getString("Icon1"); this.Icon2 = rs.getString("Icon2"); this.Icon3 = rs.getString("Icon3"); @@ -147,7 +147,7 @@ public class Zone extends AbstractGameObject { writer.putString(city.getCityName()); else writer.putString(zone.zoneName); - writer.put(zone.safeZone); + writer.put(zone.peaceZone); writer.putString(zone.Icon1); writer.putString(zone.Icon2); writer.putString(zone.Icon3); @@ -182,50 +182,14 @@ public class Zone extends AbstractGameObject { // Set heightmap blending bounds if (heightMap == null) { - this.maxBlend = this.getBounds(); + this.maxBlend = bounds; } else { this.maxBlend = Bounds.borrow(); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), this.getBounds().getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); } } - public int getPlayerCityUUID() { - return this.playerCityID; - } - - public String getName() { - return zoneName; - } - - public float getXCoord() { - return xCoord; - } - - public float getYCoord() { - return yCoord; - } - - public float getZCoord() { - return zCoord; - } - - public int getLoadNum() { - return loadNum; - } - - public byte getSafeZone() { - return safeZone; - } - - public String getIcon1() { - return Icon1; - } - - public Zone getParent() { - return this.parent; - } - public void setParent(final Zone value) { this.parent = value; @@ -254,7 +218,7 @@ public class Zone extends AbstractGameObject { this.setBounds(); this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); - if (this.getParent() == null) { + if (this.parent == null) { this.seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE; return; } @@ -271,18 +235,6 @@ public class Zone extends AbstractGameObject { } - public float getAbsX() { - return this.absX; - } - - public float getAbsY() { - return this.absY; - } - - public float getAbsZ() { - return this.absZ; - } - public boolean isMacroZone() { // Macro zones have icons. @@ -293,23 +245,7 @@ public class Zone extends AbstractGameObject { if (this.parent == null) return false; - return !this.getIcon1().equals(""); - } - - public boolean isNPCCity() { - return this.isNPCCity; - } - - public void setNPCCity(boolean value) { - this.isNPCCity = value; - } - - public boolean isPlayerCity() { - return this.isPlayerCity; - } - - public void setPlayerCity(boolean value) { - this.isPlayerCity = value; + return !Icon1.equals(""); } public Vector3fImmutable getLoc() { @@ -358,19 +294,8 @@ public class Zone extends AbstractGameObject { if (this.getNodes().get(0).isMacroZone()) return true; - return this.getParent().equals(ZoneManager.getSeaFloor()); - - } - - /** - * @return the bounds - */ - public Bounds getBounds() { - return bounds; - } + return this.parent.equals(ZoneManager.getSeaFloor()); - public String getHash() { - return hash; } public void setHash() { @@ -392,8 +317,4 @@ public class Zone extends AbstractGameObject { return HeightMap.heightmapByLoadNum.get(this.loadNum); } - public float getSeaLevel() { - return seaLevel; - } - } diff --git a/src/engine/powers/poweractions/SummonPowerAction.java b/src/engine/powers/poweractions/SummonPowerAction.java index 92d3c92e..03fe028e 100644 --- a/src/engine/powers/poweractions/SummonPowerAction.java +++ b/src/engine/powers/poweractions/SummonPowerAction.java @@ -55,7 +55,7 @@ public class SummonPowerAction extends AbstractPowerAction { String location = "Somewhere"; if (zone != null) - location = zone.getName(); + location = zone.zoneName; RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(source.getObjectType().ordinal(), source.getObjectUUID(), source.getFirstName(), location, false); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 0956ca11..da1437f1 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -469,7 +469,7 @@ public class WorldServer { for (Zone zone : ZoneManager.getAllZones()) { if (zone.getHeightMap() != null) { if (zone.getHeightMap().bucketWidthX == 0) { - System.out.println("Zone load num: " + zone.getLoadNum() + " has no bucket width"); + System.out.println("Zone load num: " + zone.loadNum + " has no bucket width"); } } } @@ -565,7 +565,7 @@ public class WorldServer { for (Zone zone : rootParent) { - ZoneManager.addZone(zone.getLoadNum(), zone); + ZoneManager.addZone(zone.loadNum, zone); //Handle Buildings diff --git a/src/engine/workthreads/DestroyCityThread.java b/src/engine/workthreads/DestroyCityThread.java index aeb46a6c..22cb72e1 100644 --- a/src/engine/workthreads/DestroyCityThread.java +++ b/src/engine/workthreads/DestroyCityThread.java @@ -53,7 +53,7 @@ public class DestroyCityThread implements Runnable { // Member variable assignment cityZone = city.getParent(); - newParent = cityZone.getParent(); + newParent = cityZone.parent; formerGuild = city.getTOL().getGuild(); // Former guild loses it's tree! @@ -150,6 +150,6 @@ public class DestroyCityThread implements Runnable { // Zone and city should vanish upon next reboot // if the codebase reaches here. - Logger.info(city.getParent().getName() + " uuid:" + city.getObjectUUID() + "has been destroyed!"); + Logger.info(city.getParent().zoneName + " uuid:" + city.getObjectUUID() + "has been destroyed!"); } } diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index dbf17e0c..556175c9 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -166,7 +166,7 @@ public class HourlyJobThread implements Runnable { mineBuilding.rebuildMine(); WorldGrid.updateObject(mineBuilding); - ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.lastClaimer.getName() + " has claimed the mine in " + mine.getParentZone().getParent().getName() + " for " + mine.getOwningGuild().getName() + ". The mine is no longer active."); + ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.lastClaimer.getName() + " has claimed the mine in " + mine.getParentZone().parent.zoneName + " for " + mine.getOwningGuild().getName() + ". The mine is no longer active."); chatMsg.setMessageType(10); chatMsg.setChannel(Enum.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); @@ -205,7 +205,7 @@ public class HourlyJobThread implements Runnable { if (ZoneManager.hotZone == null) { Logger.error("Null HotZone returned from ZoneManager"); } else { - Logger.info("HotZone switched to: " + ZoneManager.hotZone.getName()); + Logger.info("HotZone switched to: " + ZoneManager.hotZone.zoneName); } } catch (Exception e) { From e0387dce00852ff89126d40b481404caba4b331d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 15:53:41 -0400 Subject: [PATCH 098/289] class and table schema now conform to JSON --- src/engine/Enum.java | 2 +- src/engine/InterestManagement/HeightMap.java | 8 +- src/engine/db/handlers/dbZoneHandler.java | 12 +-- src/engine/devcmd/cmds/AddMobCmd.java | 2 +- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- src/engine/devcmd/cmds/GetZoneCmd.java | 2 +- src/engine/devcmd/cmds/GotoCmd.java | 4 +- src/engine/devcmd/cmds/InfoCmd.java | 4 +- src/engine/devcmd/cmds/MakeBaneCmd.java | 4 +- src/engine/devcmd/cmds/PurgeObjectsCmd.java | 2 +- src/engine/devcmd/cmds/RemoveBaneCmd.java | 4 +- src/engine/devcmd/cmds/RemoveObjectCmd.java | 2 +- src/engine/devcmd/cmds/SetBaneActiveCmd.java | 4 +- .../devcmd/cmds/SetForceRenameCityCmd.java | 4 +- src/engine/devcmd/cmds/ZoneInfoCmd.java | 6 +- src/engine/devcmd/cmds/ZoneSetCmd.java | 2 +- src/engine/gameManager/MovementManager.java | 2 +- src/engine/gameManager/ZoneManager.java | 16 ++-- src/engine/net/client/ClientMessagePump.java | 6 +- .../handlers/AbandonAssetMsgHandler.java | 2 +- .../handlers/AssetSupportMsgHandler.java | 2 +- .../handlers/ChannelMuteMsgHandler.java | 2 +- .../handlers/ClaimGuildTreeMsgHandler.java | 2 +- .../handlers/ManageCityAssetMsgHandler.java | 6 +- .../handlers/ObjectActionMsgHandler.java | 2 +- .../client/handlers/OrderNPCMsgHandler.java | 2 +- .../client/handlers/PlaceAssetMsgHandler.java | 30 +++---- .../handlers/RepairBuildingMsgHandler.java | 4 +- src/engine/net/client/msg/CityAssetMsg.java | 2 +- .../net/client/msg/GuildTreeStatusMsg.java | 4 +- .../net/client/msg/ManageCityAssetsMsg.java | 10 +-- .../net/client/msg/ViewResourcesMessage.java | 2 +- src/engine/objects/Bane.java | 4 +- src/engine/objects/Building.java | 4 +- src/engine/objects/City.java | 4 +- src/engine/objects/ItemFactory.java | 4 +- src/engine/objects/NPC.java | 4 +- src/engine/objects/Warehouse.java | 2 +- src/engine/objects/Zone.java | 81 +++++++++---------- src/engine/server/world/WorldServer.java | 4 +- 40 files changed, 132 insertions(+), 133 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index b7b78c73..8abd1d8a 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -469,7 +469,7 @@ public class Enum { // 14001 does not have a banestone to bind at - if (ruinZone.loadNum == 14001) + if (ruinZone.zoneTemplate == 14001) spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30); else spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc() diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 06957997..a2f7168c 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -191,7 +191,7 @@ public class HeightMap { HeightMap heightMap = new HeightMap(zone); - HeightMap.heightmapByLoadNum.put(zone.loadNum, heightMap); + HeightMap.heightmapByLoadNum.put(zone.zoneTemplate, heightMap); } @@ -237,7 +237,7 @@ public class HeightMap { // Heightmap blending is based on distance to edge of zone. - if (Bounds.collide(worldLoc, heightMapZone.maxBlend) == true) + if (Bounds.collide(worldLoc, heightMapZone.blendBounds) == true) return interpolatedTerrainHeight; // We will need the parent height if we got this far into the method @@ -264,8 +264,8 @@ public class HeightMap { blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); - float maxBlendArea = (heightMapZone.maxBlend.getHalfExtents().x) * - (heightMapZone.maxBlend.getHalfExtents().y); + float maxBlendArea = (heightMapZone.blendBounds.getHalfExtents().x) * + (heightMapZone.blendBounds.getHalfExtents().y); float currentArea = (blendBounds.getHalfExtents().x) * (blendBounds.getHalfExtents().y); float zoneArea = (heightMapZone.bounds.getHalfExtents().x) * diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index c367d22e..b782ad38 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -33,18 +33,18 @@ public class dbZoneHandler extends dbHandlerBase { ArrayList wsmList = new ArrayList<>(); wsmList.addAll(zone.getNodes()); if (zone.absX == 0.0f) { - zone.absX = zone.xCoord; + zone.absX = zone.xOffset; } if (zone.absY == 0.0f) { - zone.absY = zone.yCoord; + zone.absY = zone.yOffset; } if (zone.absZ == 0.0f) { - zone.absZ = zone.zCoord; + zone.absZ = zone.zOffset; } for (Zone child : zone.getNodes()) { - child.absX = child.xCoord + zone.absX; - child.absY = child.yCoord + zone.absY; - child.absZ = child.zCoord + zone.absZ; + child.absX = child.xOffset + zone.absX; + child.absY = child.yOffset + zone.absY; + child.absZ = child.zOffset + zone.absZ; wsmList.addAll(this.GET_ALL_NODES(child)); } return wsmList; diff --git a/src/engine/devcmd/cmds/AddMobCmd.java b/src/engine/devcmd/cmds/AddMobCmd.java index 30fbac56..57459f67 100644 --- a/src/engine/devcmd/cmds/AddMobCmd.java +++ b/src/engine/devcmd/cmds/AddMobCmd.java @@ -78,7 +78,7 @@ public class AddMobCmd extends AbstractDevCmd { return; } - if (zone.isPlayerCity) { + if (zone.isGuildZone) { throwbackError(pc, "Cannot use ./mob on Player cities. Try ./servermob instead."); return; } diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 29792691..eb0eb280 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -59,7 +59,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Min: " + heightmapZone.getHeightMap().zone_minBlend + " Max: " + heightmapZone.getHeightMap().zone_maxBlend); - if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.maxBlend)) { + if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.blendBounds)) { this.throwbackInfo(playerCharacter, "Blend: Max (Child)"); return; } diff --git a/src/engine/devcmd/cmds/GetZoneCmd.java b/src/engine/devcmd/cmds/GetZoneCmd.java index a2deba81..62ffb1df 100644 --- a/src/engine/devcmd/cmds/GetZoneCmd.java +++ b/src/engine/devcmd/cmds/GetZoneCmd.java @@ -51,7 +51,7 @@ public class GetZoneCmd extends AbstractDevCmd { } for (Zone zone : allIn) - throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.loadNum); + throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.zoneTemplate); } @Override diff --git a/src/engine/devcmd/cmds/GotoCmd.java b/src/engine/devcmd/cmds/GotoCmd.java index e2864d82..3d7550c1 100644 --- a/src/engine/devcmd/cmds/GotoCmd.java +++ b/src/engine/devcmd/cmds/GotoCmd.java @@ -81,7 +81,7 @@ public class GotoCmd extends AbstractDevCmd { continue; Zone zone = city.getParent(); if (zone != null) { - if (zone.isNPCCity || zone.isPlayerCity) + if (zone.isNPCCity || zone.isGuildZone) loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); else loc = zone.getLoc(); @@ -100,7 +100,7 @@ public class GotoCmd extends AbstractDevCmd { if (!zone.zoneName.equalsIgnoreCase(cityName)) continue; if (zone != null) { - if (zone.isNPCCity || zone.isPlayerCity) + if (zone.isNPCCity || zone.isGuildZone) loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); else loc = zone.getLoc(); diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 34bb73e2..d0257efb 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -387,7 +387,7 @@ public class InfoCmd extends AbstractDevCmd { output += newline; output += "EquipSet: " + targetNPC.getEquipmentSetID(); output += newline; - output += "Parent Zone LoadNum : " + targetNPC.getParentZone().loadNum; + output += "Parent Zone LoadNum : " + targetNPC.getParentZone().zoneTemplate; } @@ -473,7 +473,7 @@ public class InfoCmd extends AbstractDevCmd { output += "EquipSet: " + targetMob.equipmentSetID; output += newline; try { - output += "Parent Zone LoadNum : " + targetMob.getParentZone().loadNum; + output += "Parent Zone LoadNum : " + targetMob.getParentZone().zoneTemplate; } catch (Exception ex) { //who cares } diff --git a/src/engine/devcmd/cmds/MakeBaneCmd.java b/src/engine/devcmd/cmds/MakeBaneCmd.java index 17f82685..829ca955 100644 --- a/src/engine/devcmd/cmds/MakeBaneCmd.java +++ b/src/engine/devcmd/cmds/MakeBaneCmd.java @@ -111,12 +111,12 @@ public class MakeBaneCmd extends AbstractDevCmd { return; } - if (!zone.isPlayerCity) { + if (!zone.isGuildZone) { throwbackError(pc, "This is not a player city."); return; } - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city == null) { throwbackError(pc, "Unable to find the city associated with this zone."); return; diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index deb30cd8..b32e1480 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -42,7 +42,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { private static void PurgeWalls(Zone zone, PlayerCharacter pc) { - if (!zone.isPlayerCity) + if (!zone.isGuildZone) return; for (Building building : zone.zoneBuildingSet) { diff --git a/src/engine/devcmd/cmds/RemoveBaneCmd.java b/src/engine/devcmd/cmds/RemoveBaneCmd.java index 0e760f50..1669265c 100644 --- a/src/engine/devcmd/cmds/RemoveBaneCmd.java +++ b/src/engine/devcmd/cmds/RemoveBaneCmd.java @@ -34,12 +34,12 @@ public class RemoveBaneCmd extends AbstractDevCmd { return; } - if (!zone.isPlayerCity) { + if (!zone.isGuildZone) { throwbackError(pc, "This is not a player city."); return; } - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city == null) { throwbackError(pc, "Unable to find the city associated with this zone."); return; diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index 19a9fd2c..944ccfc2 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -130,7 +130,7 @@ public class RemoveObjectCmd extends AbstractDevCmd { building.disableSpire(false); if ((building.getBlueprint() != null) && (building.getBlueprint().getBuildingGroup() == BuildingGroup.WAREHOUSE)) { - City city = City.getCity(building.getParentZone().playerCityID); + City city = City.getCity(building.getParentZone().playerCityUUID); if (city != null) { city.setWarehouseBuildingID(0); } diff --git a/src/engine/devcmd/cmds/SetBaneActiveCmd.java b/src/engine/devcmd/cmds/SetBaneActiveCmd.java index e7c0ba56..b1caccb9 100644 --- a/src/engine/devcmd/cmds/SetBaneActiveCmd.java +++ b/src/engine/devcmd/cmds/SetBaneActiveCmd.java @@ -41,12 +41,12 @@ public class SetBaneActiveCmd extends AbstractDevCmd { return; } - if (!zone.isPlayerCity) { + if (!zone.isGuildZone) { throwbackError(pc, "This is not a player city."); return; } - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city == null) { throwbackError(pc, "Unable to find the city associated with this zone."); return; diff --git a/src/engine/devcmd/cmds/SetForceRenameCityCmd.java b/src/engine/devcmd/cmds/SetForceRenameCityCmd.java index 5b275697..da2e0ca0 100644 --- a/src/engine/devcmd/cmds/SetForceRenameCityCmd.java +++ b/src/engine/devcmd/cmds/SetForceRenameCityCmd.java @@ -31,9 +31,9 @@ public class SetForceRenameCityCmd extends AbstractDevCmd { if (zone == null) return; boolean rename = words[0].equalsIgnoreCase("true") ? true : false; - if (zone.playerCityID == 0) + if (zone.playerCityUUID == 0) return; - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city == null) return; city.setForceRename(rename); diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 17d1226a..efc069e9 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -75,7 +75,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; output += "name: " + zone.zoneName; output += newline; - output += "loadNum: " + zone.loadNum; + output += "loadNum: " + zone.zoneTemplate; if (zone.parent != null) { output += StringUtils.addWS(", parent: " + zone.parent.getObjectUUID(), 30); output += "Parentabs: x: " + zone.parent.absX + ", y: " + zone.parent.absY + ", z: " + zone.parent.absZ; @@ -85,7 +85,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; output += "absLoc: x: " + zone.absX + ", y: " + zone.absY + ", z: " + zone.absZ; output += newline; - output += "offset: x: " + zone.xCoord + ", y: " + zone.yCoord + ", z: " + zone.zCoord; + output += "offset: x: " + zone.xOffset + ", y: " + zone.yOffset + ", z: " + zone.zOffset; output += newline; output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; output += newline; @@ -130,7 +130,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { for (Zone child : nodes) { output += newline; - output += child.zoneName + " (" + child.loadNum + ')'; + output += child.zoneName + " (" + child.zoneTemplate + ')'; } } throwbackInfo(player, output); diff --git a/src/engine/devcmd/cmds/ZoneSetCmd.java b/src/engine/devcmd/cmds/ZoneSetCmd.java index 9da9cbbd..aedb78ac 100644 --- a/src/engine/devcmd/cmds/ZoneSetCmd.java +++ b/src/engine/devcmd/cmds/ZoneSetCmd.java @@ -40,7 +40,7 @@ public class ZoneSetCmd extends AbstractDevCmd { zone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); - throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.loadNum + ") " + zone.getObjectUUID()); + throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.zoneTemplate + ") " + zone.getObjectUUID()); // NPC diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index c8f3569e..f24ffaf6 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -267,7 +267,7 @@ public enum MovementManager { Zone serverZone = null; serverZone = ZoneManager.findSmallestZone(player.getLoc()); - cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.playerCityID); + cityObject = (City) DbManager.getFromCache(GameObjectType.City, serverZone.playerCityUUID); // Do not send group messages if player is on grid diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 77ecd6a7..65ab0177 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -182,7 +182,7 @@ public enum ZoneManager { public static final void populateWorldZones(final Zone zone) { - int loadNum = zone.loadNum; + int loadNum = zone.zoneTemplate; // Zones are added to separate // collections for quick access @@ -194,7 +194,7 @@ public enum ZoneManager { } - if (zone.isPlayerCity) { + if (zone.isGuildZone) { addPlayerCityZone(zone); return; } @@ -214,7 +214,7 @@ public enum ZoneManager { } public static final void addPlayerCityZone(final Zone zone) { - zone.isPlayerCity = true; + zone.isGuildZone = true; ZoneManager.playerCityZones.add(zone); } @@ -387,8 +387,8 @@ public enum ZoneManager { currentZone = ZoneManager.findSmallestZone(worldLoc); - if (currentZone.isPlayerCity) - return City.getCity(currentZone.playerCityID); + if (currentZone.isGuildZone) + return City.getCity(currentZone.playerCityUUID); return null; } @@ -440,7 +440,7 @@ public enum ZoneManager { //not player city, must be npc city.. - if (!zone.isPlayerCity) + if (!zone.isGuildZone) zone.isNPCCity = true; if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) { @@ -469,7 +469,7 @@ public enum ZoneManager { // Children of seafloor if (parentZone.parent == null) - return worldAlttitude + zone.yCoord; + return worldAlttitude + zone.yOffset; // return height from heightmap engine at zone location @@ -477,7 +477,7 @@ public enum ZoneManager { // Add zone offset to value - worldAlttitude += zone.yCoord; + worldAlttitude += zone.yOffset; return worldAlttitude; } diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 8086ef33..2a8334ad 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1196,7 +1196,7 @@ public class ClientMessagePump implements NetMsgHandler { if (npc.getCharItemManager().getInventoryCount() > 150) { - if (npc.getParentZone() != null && npc.getParentZone().playerCityID == 0) { + if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID == 0) { ArrayList inv = npc.getInventory(); for (int i = 0; i < 20; i++) { try { @@ -1229,7 +1229,7 @@ public class ClientMessagePump implements NetMsgHandler { if (ib == null) return; - if (npc.getParentZone() != null && npc.getParentZone().playerCityID != 0) + if (npc.getParentZone() != null && npc.getParentZone().playerCityUUID != 0) if (!npc.getCharItemManager().hasRoomInventory(ib.getWeight())) { ErrorPopupMsg.sendErrorPopup(player, 21); @@ -1280,7 +1280,7 @@ public class ClientMessagePump implements NetMsgHandler { if (building != null && building.getProtectionState().equals(ProtectionState.NPC)) building = null; - if (npc.getParentZone().playerCityID == 0) + if (npc.getParentZone().playerCityUUID == 0) building = null; //make sure npc can afford item diff --git a/src/engine/net/client/handlers/AbandonAssetMsgHandler.java b/src/engine/net/client/handlers/AbandonAssetMsgHandler.java index 8774242d..aea94ffd 100644 --- a/src/engine/net/client/handlers/AbandonAssetMsgHandler.java +++ b/src/engine/net/client/handlers/AbandonAssetMsgHandler.java @@ -151,7 +151,7 @@ public class AbandonAssetMsgHandler extends AbstractClientMsgHandler { cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc()); // Can't abandon a tree not within a player city zone - if (cityZone.isPlayerCity == false) + if (cityZone.isGuildZone == false) return; if (targetBuilding.getCity() == null) diff --git a/src/engine/net/client/handlers/AssetSupportMsgHandler.java b/src/engine/net/client/handlers/AssetSupportMsgHandler.java index 0f4439ae..1627b0ac 100644 --- a/src/engine/net/client/handlers/AssetSupportMsgHandler.java +++ b/src/engine/net/client/handlers/AssetSupportMsgHandler.java @@ -45,7 +45,7 @@ public class AssetSupportMsgHandler extends AbstractClientMsgHandler { if (serverZone == null) return; - serverCity = City.GetCityFromCache(serverZone.playerCityID); + serverCity = City.GetCityFromCache(serverZone.playerCityUUID); if (serverCity == null) return; diff --git a/src/engine/net/client/handlers/ChannelMuteMsgHandler.java b/src/engine/net/client/handlers/ChannelMuteMsgHandler.java index 30a003fc..b6d3ddbb 100644 --- a/src/engine/net/client/handlers/ChannelMuteMsgHandler.java +++ b/src/engine/net/client/handlers/ChannelMuteMsgHandler.java @@ -65,7 +65,7 @@ public class ChannelMuteMsgHandler extends AbstractClientMsgHandler { cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc()); // Can't abandon a tree not within a player city zone - if (cityZone.isPlayerCity == false) + if (cityZone.isGuildZone == false) return; if (targetBuilding.getCity().hasBeenTransfered == true) { diff --git a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java index c942f40c..82aa5d83 100644 --- a/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java +++ b/src/engine/net/client/handlers/ClaimGuildTreeMsgHandler.java @@ -69,7 +69,7 @@ public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler { playerZone = building.getParentZone(); if (playerZone != null) - playerCity = City.getCity(playerZone.playerCityID); + playerCity = City.getCity(playerZone.playerCityUUID); // Oops! *** Refactor: Log error switch (msg.getMessageType()) { diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index 0f55d6a0..4672efc0 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -75,12 +75,12 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { Zone zone = ZoneManager.findSmallestZone(player.getLoc()); - if (!zone.isPlayerCity) { + if (!zone.isGuildZone) { ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); return true; } - City city = City.GetCityFromCache(zone.playerCityID); + City city = City.GetCityFromCache(zone.playerCityUUID); if (city == null) { ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); @@ -254,7 +254,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { if (baneZone == null) return true; - City banedCity = City.getCity(baneZone.playerCityID); + City banedCity = City.getCity(baneZone.playerCityUUID); if (banedCity == null) return true; diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 1ffba79c..fad51445 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -334,7 +334,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { Zone zone = ZoneManager.findSmallestZone(player.getLoc()); if (zone != null) { - if (zone.isPlayerCity) { + if (zone.isGuildZone) { loc = zone.getLoc(); } } diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index 3de83fee..c7414459 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -288,7 +288,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (zone == null) return false; - if (zone.playerCityID == 0) + if (zone.playerCityUUID == 0) return false; City city = building.getCity(); diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 773bdc81..4efb7add 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -137,7 +137,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { private static boolean validateBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo placementInfo) { - if (serverZone.isPlayerCity == false) { + if (serverZone.isGuildZone == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, player.getName()); return false; } @@ -201,8 +201,8 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Cannot place assets on a dead tree - if ((serverZone.isPlayerCity) - && (City.getCity(serverZone.playerCityID).getTOL().getRank() == -1)) { + if ((serverZone.isGuildZone) + && (City.getCity(serverZone.playerCityUUID).getTOL().getRank() == -1)) { PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot place asset on dead tree until world heals"); return false; } @@ -261,14 +261,14 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Must be a player city - if (serverZone.isPlayerCity == false) { + if (serverZone.isGuildZone == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 41, player.getName()); // Cannot place outside a guild zone return false; } //Test zone has a city object - City city = City.getCity(serverZone.playerCityID); + City city = City.getCity(serverZone.playerCityUUID); if (city == null) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); //"no city to associate asset with" @@ -512,7 +512,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (serverZone == null) return false; - cityObject = City.getCity(serverZone.playerCityID); + cityObject = City.getCity(serverZone.playerCityUUID); // Early exit if something went horribly wrong @@ -571,7 +571,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // No valid player city found - if (serverCity == null || serverCity.getParent().isPlayerCity == false) { + if (serverCity == null || serverCity.getParent().isGuildZone == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); // Cannot place outisde a guild zone return false; } @@ -783,7 +783,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Link the zone with the city and then add // to the appropriate hash tables and cache - zoneObject.isPlayerCity = true; + zoneObject.isGuildZone = true; if (zoneObject.parent != null) zoneObject.parent.addNode(zoneObject); //add as child to parent @@ -857,7 +857,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (serverZone == null) return false; - cityObject = City.getCity(serverZone.playerCityID); + cityObject = City.getCity(serverZone.playerCityUUID); if (cityObject == null) return false; @@ -931,7 +931,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { int shrineCount = 0; - cityObject = City.getCity(serverZone.playerCityID); + cityObject = City.getCity(serverZone.playerCityUUID); // Cannot place shrine in abandoned city. Shrines must be owned // by the tol owner not the person placing them. @@ -1001,7 +1001,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { int barracksCount = 0; - cityObject = City.getCity(serverZone.playerCityID); + cityObject = City.getCity(serverZone.playerCityUUID); // Cannot place barracks in abandoned city. @@ -1061,7 +1061,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (validateCityBuildingPlacement(serverZone, msg, origin, player, msg.getFirstPlacementInfo()) == false) return false; - cityObject = City.getCity(serverZone.playerCityID); + cityObject = City.getCity(serverZone.playerCityUUID); // We need to be able to access how much gold a character is carrying @@ -1229,7 +1229,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { shrineType = Shrine.getShrineTypeByBlueprintUUID(blueprint.getBlueprintUUID()); - city = City.getCity(currentZone.playerCityID); + city = City.getCity(currentZone.playerCityUUID); if (city == null) return false; @@ -1294,7 +1294,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; } - city = City.getCity(currentZone.playerCityID); + city = City.getCity(currentZone.playerCityUUID); if (city == null) return false; @@ -1369,7 +1369,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { newMesh.runAfterLoad(); } else if (ago.getObjectType() == GameObjectType.Warehouse) { Warehouse warehouse = (Warehouse) ago; - City city = City.getCity(currentZone.playerCityID); + City city = City.getCity(currentZone.playerCityUUID); if (city == null) return true; diff --git a/src/engine/net/client/handlers/RepairBuildingMsgHandler.java b/src/engine/net/client/handlers/RepairBuildingMsgHandler.java index 9582b269..615d0045 100644 --- a/src/engine/net/client/handlers/RepairBuildingMsgHandler.java +++ b/src/engine/net/client/handlers/RepairBuildingMsgHandler.java @@ -44,11 +44,11 @@ public class RepairBuildingMsgHandler extends AbstractClientMsgHandler { serverZone = ZoneManager.findSmallestZone(pc.getLoc()); - if (serverZone.playerCityID == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE) + if (serverZone.playerCityUUID == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE) return; - City city = City.GetCityFromCache(serverZone.playerCityID); + City city = City.GetCityFromCache(serverZone.playerCityUUID); if (city != null) { if (city.getBane() != null && city.protectionEnforced == false) diff --git a/src/engine/net/client/msg/CityAssetMsg.java b/src/engine/net/client/msg/CityAssetMsg.java index 0d8490d7..6d3dc207 100644 --- a/src/engine/net/client/msg/CityAssetMsg.java +++ b/src/engine/net/client/msg/CityAssetMsg.java @@ -92,7 +92,7 @@ public class CityAssetMsg extends ClientNetMsg { return; } - city = City.getCity(zone.playerCityID); + city = City.getCity(zone.playerCityUUID); if (city == null) { Logger.debug("Failed to load city data for Tree of life."); diff --git a/src/engine/net/client/msg/GuildTreeStatusMsg.java b/src/engine/net/client/msg/GuildTreeStatusMsg.java index 40538544..19899da3 100644 --- a/src/engine/net/client/msg/GuildTreeStatusMsg.java +++ b/src/engine/net/client/msg/GuildTreeStatusMsg.java @@ -117,8 +117,8 @@ public class GuildTreeStatusMsg extends ClientNetMsg { city = null; if (cityZone != null) - if (cityZone.isPlayerCity) - city = City.GetCityFromCache(cityZone.playerCityID); + if (cityZone.isGuildZone) + city = City.GetCityFromCache(cityZone.playerCityUUID); else if (this.treeOfLife != null && this.treeOfLife.getGuild() != null) city = this.treeOfLife.getGuild().getOwnedCity(); diff --git a/src/engine/net/client/msg/ManageCityAssetsMsg.java b/src/engine/net/client/msg/ManageCityAssetsMsg.java index 94cc837b..9392838e 100644 --- a/src/engine/net/client/msg/ManageCityAssetsMsg.java +++ b/src/engine/net/client/msg/ManageCityAssetsMsg.java @@ -299,8 +299,8 @@ public class ManageCityAssetsMsg extends ClientNetMsg { Set buildings = ZoneManager.findSmallestZone(assetManager.getLoc()).zoneBuildingSet; Building tol = null; - if (playerZone.playerCityID != 0) - city = City.GetCityFromCache(playerZone.playerCityID); + if (playerZone.playerCityUUID != 0) + city = City.GetCityFromCache(playerZone.playerCityUUID); if (city != null) tol = city.getTOL(); @@ -368,7 +368,7 @@ public class ManageCityAssetsMsg extends ClientNetMsg { if (zone == null) return; - City banedCity = City.getCity(zone.playerCityID); + City banedCity = City.getCity(zone.playerCityUUID); if (banedCity == null) return; @@ -621,9 +621,9 @@ public class ManageCityAssetsMsg extends ClientNetMsg { } else { writer.putInt(1); //kos on/off? writer.putInt(3); // was 3 - if (zone.playerCityID != 0 && asset.assetIsProtected()) { + if (zone.playerCityUUID != 0 && asset.assetIsProtected()) { writer.putInt(GameObjectType.Building.ordinal()); - writer.putInt(City.getCity(zone.playerCityID).getTOL().getObjectUUID()); + writer.putInt(City.getCity(zone.playerCityUUID).getTOL().getObjectUUID()); } else { writer.putInt(0); writer.putInt(0); diff --git a/src/engine/net/client/msg/ViewResourcesMessage.java b/src/engine/net/client/msg/ViewResourcesMessage.java index 55a4eab0..0bb3ff74 100644 --- a/src/engine/net/client/msg/ViewResourcesMessage.java +++ b/src/engine/net/client/msg/ViewResourcesMessage.java @@ -73,7 +73,7 @@ public class ViewResourcesMessage extends ClientNetMsg { if (this.warehouseBuilding.getParentZone() == null) return false; - this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().playerCityID); + this.city = (City) DbManager.getObject(Enum.GameObjectType.City, this.warehouseBuilding.getParentZone().playerCityUUID); if (this.city == null) return false; diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index 38f50ff9..4578d653 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -162,8 +162,8 @@ public final class Bane { // Cannot place assets on a dead tree - if ((cityZone.isPlayerCity) && - (City.getCity(cityZone.playerCityID).getTOL().getRank() == -1)) { + if ((cityZone.isGuildZone) && + (City.getCity(cityZone.playerCityUUID).getTOL().getRank() == -1)) { PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot bane a dead tree!"); return false; } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 33cf5b06..d172b0bf 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -460,10 +460,10 @@ public class Building extends AbstractWorldObject { } } } - if (this.parentZone.isPlayerCity == false) + if (this.parentZone.isGuildZone == false) return null; - return City.getCity(this.parentZone.playerCityID); + return City.getCity(this.parentZone.playerCityUUID); } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 834b155e..5ab37717 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -334,7 +334,7 @@ public class City extends AbstractWorldObject { if (city.noTeleport) continue; - if (city.parentZone != null && city.parentZone.isPlayerCity) { + if (city.parentZone != null && city.parentZone.isGuildZone) { if (pc.getAccount().status.equals(AccountStatus.ADMIN)) { cities.add(city); @@ -395,7 +395,7 @@ public class City extends AbstractWorldObject { if (city.noRepledge) continue; - if (city.parentZone != null && city.parentZone.isPlayerCity) { + if (city.parentZone != null && city.parentZone.isGuildZone) { //list Player cities //open city, just list diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 20229512..abac878f 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -104,7 +104,7 @@ public class ItemFactory { if (zone == null) return null; - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city == null) return null; @@ -796,7 +796,7 @@ public class ItemFactory { if (zone == null) return null; - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city == null) return null; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 662c8a46..d3d914ce 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -894,7 +894,7 @@ public class NPC extends AbstractCharacter { this.stamina.set(this.staminaMax); } - if (this.parentZone.isPlayerCity) + if (this.parentZone.isGuildZone) if (NPC.GetNPCProfits(this) == null) NPCProfits.CreateProfits(this); @@ -1192,7 +1192,7 @@ public class NPC extends AbstractCharacter { if (serverZone == null) return null; - city = City.GetCityFromCache(serverZone.playerCityID); + city = City.GetCityFromCache(serverZone.playerCityUUID); if (city == null) { diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index effb2a83..9b55a1f7 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -1272,7 +1272,7 @@ public class Warehouse extends AbstractWorldObject { return; } - City city = City.getCity(cityZone.playerCityID); + City city = City.getCity(cityZone.playerCityUUID); if (city == null) { Logger.error("Failed to load City for Warehouse with UUID " + this.getObjectUUID()); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 400c7def..ece867c3 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -33,12 +33,12 @@ public class Zone extends AbstractGameObject { public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); - public final int playerCityID; + public final int playerCityUUID; public final String zoneName; - public final float xCoord; - public final float zCoord; - public final float yCoord; - public final int loadNum; + public final float xOffset; + public final float zOffset; + public final float yOffset; + public final int zoneTemplate; public final byte peaceZone; public final String Icon1; public final String Icon2; @@ -54,13 +54,13 @@ public class Zone extends AbstractGameObject { public Zone parent = null; public Bounds bounds; public boolean isNPCCity = false; - public boolean isPlayerCity = false; + public boolean isGuildZone; public String hash; public float worldAltitude = 0; public float seaLevel = 0f; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; - public Bounds maxBlend; + public Bounds blendBounds; /** * ResultSet Constructor @@ -68,22 +68,21 @@ public class Zone extends AbstractGameObject { public Zone(ResultSet rs) throws SQLException { super(rs); this.parentZoneID = rs.getInt("parent"); - this.playerCityID = rs.getInt("isPlayerCity"); - this.isPlayerCity = this.playerCityID != 0; + this.playerCityUUID = rs.getInt("playerCityUUID"); + this.isGuildZone = this.playerCityUUID != 0; this.zoneName = rs.getString("Name"); - this.xCoord = rs.getFloat("XCoord"); - this.zCoord = rs.getFloat("ZCoord"); - this.yCoord = rs.getFloat("YOffset"); - this.loadNum = rs.getInt("LoadNum"); - this.peaceZone = rs.getByte("SafeZone"); - this.Icon1 = rs.getString("Icon1"); - this.Icon2 = rs.getString("Icon2"); - this.Icon3 = rs.getString("Icon3"); + this.xOffset = rs.getFloat("xOffset"); + this.zOffset = rs.getFloat("zOffset"); + this.yOffset = rs.getFloat("yOffset"); + this.zoneTemplate = rs.getInt("zoneTemplate"); + this.peaceZone = rs.getByte("paceZone"); + this.Icon1 = rs.getString("icon1"); + this.Icon2 = rs.getString("icon2"); + this.Icon3 = rs.getString("icon3"); + this.minLvl = rs.getInt("min_level"); + this.maxLvl = rs.getInt("max_level"); this.hash = rs.getString("hash"); - this.minLvl = rs.getInt("minLvl"); - this.maxLvl = rs.getInt("maxLvl"); - //this needs to be here specifically for new zones created after server boot (e.g. player city zones) Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); @@ -107,28 +106,28 @@ public class Zone extends AbstractGameObject { public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { - if (zone.loadNum == 0 && zone.playerCityID == 0) + if (zone.zoneTemplate == 0 && zone.playerCityUUID == 0) Logger.warn("Warning! WorldServerMap with ID " + zone.getObjectUUID() + " has a loadnum of 0 (player city) and no city linked. This will probably crash the client!"); // Player City Terraform values serialized here. - if (zone.playerCityID > 0) { + if (zone.playerCityUUID > 0) { writer.put((byte) 1); // Player City - True writer.putFloat(Enum.CityBoundsType.ZONE.halfExtents); writer.putFloat(Enum.CityBoundsType.ZONE.halfExtents); } else writer.put((byte) 0); // Player City - False - writer.putFloat(zone.xCoord); - writer.putFloat(zone.zCoord); - writer.putFloat(zone.yCoord); + writer.putFloat(zone.xOffset); + writer.putFloat(zone.zOffset); + writer.putFloat(zone.yOffset); writer.putInt(0); writer.putInt(0); - writer.putInt(zone.loadNum); + writer.putInt(zone.zoneTemplate); - if (zone.playerCityID > 0) { - City k = City.getCity(zone.playerCityID); + if (zone.playerCityUUID > 0) { + City k = City.getCity(zone.playerCityUUID); if (k != null) { writer.putInt(k.getObjectType().ordinal()); @@ -141,7 +140,7 @@ public class Zone extends AbstractGameObject { } writer.putInt(zone.nodes.size()); - City city = City.getCity(zone.playerCityID); + City city = City.getCity(zone.playerCityUUID); if (city != null) writer.putString(city.getCityName()); @@ -168,7 +167,7 @@ public class Zone extends AbstractGameObject { this.bounds = Bounds.borrow(); - Vector2f zoneSize = ZoneManager._zone_size_data.get(this.loadNum); + Vector2f zoneSize = ZoneManager._zone_size_data.get(this.zoneTemplate); // Default to player zone size on error? Maybe log this @@ -182,10 +181,10 @@ public class Zone extends AbstractGameObject { // Set heightmap blending bounds if (heightMap == null) { - this.maxBlend = bounds; + this.blendBounds = bounds; } else { - this.maxBlend = Bounds.borrow(); - this.maxBlend.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + this.blendBounds = Bounds.borrow(); + this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); } } @@ -198,17 +197,17 @@ public class Zone extends AbstractGameObject { // Seafloor if (this.parent == null) { - this.absX = this.xCoord; + this.absX = this.xOffset; this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE; - this.absZ = this.zCoord; + this.absZ = this.zOffset; this.seaLevel = 0; this.setBounds(); return; } - this.absX = this.xCoord + parent.absX; - this.absY = this.yCoord + parent.absY; - this.absZ = this.zCoord + parent.absZ; + this.absX = this.xOffset + parent.absX; + this.absY = this.yOffset + parent.absY; + this.absZ = this.zOffset + parent.absZ; if (this.minLvl == 0 || this.maxLvl == 0) { this.minLvl = this.parent.minLvl; @@ -239,7 +238,7 @@ public class Zone extends AbstractGameObject { // Macro zones have icons. - if (this.isPlayerCity == true) + if (this.isGuildZone == true) return false; if (this.parent == null) @@ -311,10 +310,10 @@ public class Zone extends AbstractGameObject { public HeightMap getHeightMap() { - if (this.isPlayerCity) + if (this.isGuildZone) return HeightMap.PlayerCityHeightMap; - return HeightMap.heightmapByLoadNum.get(this.loadNum); + return HeightMap.heightmapByLoadNum.get(this.zoneTemplate); } } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index da1437f1..06156bad 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -469,7 +469,7 @@ public class WorldServer { for (Zone zone : ZoneManager.getAllZones()) { if (zone.getHeightMap() != null) { if (zone.getHeightMap().bucketWidthX == 0) { - System.out.println("Zone load num: " + zone.loadNum + " has no bucket width"); + System.out.println("Zone load num: " + zone.zoneTemplate + " has no bucket width"); } } } @@ -565,7 +565,7 @@ public class WorldServer { for (Zone zone : rootParent) { - ZoneManager.addZone(zone.loadNum, zone); + ZoneManager.addZone(zone.zoneTemplate, zone); //Handle Buildings From 61961bab050c9c33ce762e4f2a0d0b8d09a09ed1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:00:16 -0400 Subject: [PATCH 099/289] class and table schema now conform to JSON --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index ece867c3..08ed51af 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -70,7 +70,7 @@ public class Zone extends AbstractGameObject { this.parentZoneID = rs.getInt("parent"); this.playerCityUUID = rs.getInt("playerCityUUID"); this.isGuildZone = this.playerCityUUID != 0; - this.zoneName = rs.getString("Name"); + this.zoneName = rs.getString("zoneName"); this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); From 56f159d50a6543dcf5cf3a3b82ea02ff61b48c67 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:01:01 -0400 Subject: [PATCH 100/289] class and table schema now conform to JSON --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 08ed51af..6889fcb1 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -74,7 +74,7 @@ public class Zone extends AbstractGameObject { this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); - this.zoneTemplate = rs.getInt("zoneTemplate"); + this.zoneTemplate = rs.getInt("template"); this.peaceZone = rs.getByte("paceZone"); this.Icon1 = rs.getString("icon1"); this.Icon2 = rs.getString("icon2"); From 82897860993000f8d5907a8b0de30a2627de9850 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:03:55 -0400 Subject: [PATCH 101/289] class and table schema now conform to JSON --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 6889fcb1..f9a715cd 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -75,7 +75,7 @@ public class Zone extends AbstractGameObject { this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); this.zoneTemplate = rs.getInt("template"); - this.peaceZone = rs.getByte("paceZone"); + this.peaceZone = rs.getByte("peaceZone"); this.Icon1 = rs.getString("icon1"); this.Icon2 = rs.getString("icon2"); this.Icon3 = rs.getString("icon3"); From be107c08588b73c022a4c70913251bb8947925d8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:05:57 -0400 Subject: [PATCH 102/289] class and table schema now conform to JSON --- src/engine/devcmd/cmds/AddMobCmd.java | 2 +- src/engine/devcmd/cmds/GotoCmd.java | 4 ++-- src/engine/devcmd/cmds/MakeBaneCmd.java | 2 +- src/engine/devcmd/cmds/PurgeObjectsCmd.java | 2 +- src/engine/devcmd/cmds/RemoveBaneCmd.java | 2 +- src/engine/devcmd/cmds/SetBaneActiveCmd.java | 2 +- src/engine/gameManager/ZoneManager.java | 10 +++++----- .../client/handlers/AbandonAssetMsgHandler.java | 2 +- .../net/client/handlers/ChannelMuteMsgHandler.java | 2 +- .../client/handlers/ManageCityAssetMsgHandler.java | 2 +- .../client/handlers/ObjectActionMsgHandler.java | 2 +- .../net/client/handlers/PlaceAssetMsgHandler.java | 10 +++++----- src/engine/net/client/msg/GuildTreeStatusMsg.java | 2 +- src/engine/objects/AbstractIntelligenceAgent.java | 2 +- src/engine/objects/Bane.java | 2 +- src/engine/objects/Building.java | 2 +- src/engine/objects/City.java | 4 ++-- src/engine/objects/NPC.java | 2 +- src/engine/objects/PlayerCharacter.java | 8 ++++---- src/engine/objects/Zone.java | 14 +++++++------- 20 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/engine/devcmd/cmds/AddMobCmd.java b/src/engine/devcmd/cmds/AddMobCmd.java index 57459f67..1bb09c47 100644 --- a/src/engine/devcmd/cmds/AddMobCmd.java +++ b/src/engine/devcmd/cmds/AddMobCmd.java @@ -78,7 +78,7 @@ public class AddMobCmd extends AbstractDevCmd { return; } - if (zone.isGuildZone) { + if (zone.guild_zone) { throwbackError(pc, "Cannot use ./mob on Player cities. Try ./servermob instead."); return; } diff --git a/src/engine/devcmd/cmds/GotoCmd.java b/src/engine/devcmd/cmds/GotoCmd.java index 3d7550c1..93ae4e5f 100644 --- a/src/engine/devcmd/cmds/GotoCmd.java +++ b/src/engine/devcmd/cmds/GotoCmd.java @@ -81,7 +81,7 @@ public class GotoCmd extends AbstractDevCmd { continue; Zone zone = city.getParent(); if (zone != null) { - if (zone.isNPCCity || zone.isGuildZone) + if (zone.isNPCCity || zone.guild_zone) loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); else loc = zone.getLoc(); @@ -100,7 +100,7 @@ public class GotoCmd extends AbstractDevCmd { if (!zone.zoneName.equalsIgnoreCase(cityName)) continue; if (zone != null) { - if (zone.isNPCCity || zone.isGuildZone) + if (zone.isNPCCity || zone.guild_zone) loc = Vector3fImmutable.getRandomPointOnCircle(zone.getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS); else loc = zone.getLoc(); diff --git a/src/engine/devcmd/cmds/MakeBaneCmd.java b/src/engine/devcmd/cmds/MakeBaneCmd.java index 829ca955..4b4b379d 100644 --- a/src/engine/devcmd/cmds/MakeBaneCmd.java +++ b/src/engine/devcmd/cmds/MakeBaneCmd.java @@ -111,7 +111,7 @@ public class MakeBaneCmd extends AbstractDevCmd { return; } - if (!zone.isGuildZone) { + if (!zone.guild_zone) { throwbackError(pc, "This is not a player city."); return; } diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index b32e1480..23c5a1c8 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -42,7 +42,7 @@ public class PurgeObjectsCmd extends AbstractDevCmd { private static void PurgeWalls(Zone zone, PlayerCharacter pc) { - if (!zone.isGuildZone) + if (!zone.guild_zone) return; for (Building building : zone.zoneBuildingSet) { diff --git a/src/engine/devcmd/cmds/RemoveBaneCmd.java b/src/engine/devcmd/cmds/RemoveBaneCmd.java index 1669265c..cb720307 100644 --- a/src/engine/devcmd/cmds/RemoveBaneCmd.java +++ b/src/engine/devcmd/cmds/RemoveBaneCmd.java @@ -34,7 +34,7 @@ public class RemoveBaneCmd extends AbstractDevCmd { return; } - if (!zone.isGuildZone) { + if (!zone.guild_zone) { throwbackError(pc, "This is not a player city."); return; } diff --git a/src/engine/devcmd/cmds/SetBaneActiveCmd.java b/src/engine/devcmd/cmds/SetBaneActiveCmd.java index b1caccb9..caf1615f 100644 --- a/src/engine/devcmd/cmds/SetBaneActiveCmd.java +++ b/src/engine/devcmd/cmds/SetBaneActiveCmd.java @@ -41,7 +41,7 @@ public class SetBaneActiveCmd extends AbstractDevCmd { return; } - if (!zone.isGuildZone) { + if (!zone.guild_zone) { throwbackError(pc, "This is not a player city."); return; } diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 65ab0177..13749067 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -194,7 +194,7 @@ public enum ZoneManager { } - if (zone.isGuildZone) { + if (zone.guild_zone) { addPlayerCityZone(zone); return; } @@ -214,7 +214,7 @@ public enum ZoneManager { } public static final void addPlayerCityZone(final Zone zone) { - zone.isGuildZone = true; + zone.guild_zone = true; ZoneManager.playerCityZones.add(zone); } @@ -250,7 +250,7 @@ public enum ZoneManager { public static final boolean validHotZone(Zone zone) { - if (zone.peaceZone == (byte) 1) + if (zone.peace_zone == (byte) 1) return false; // no safe zone hotzones// if (this.hotzone == null) if (zone.getNodes().isEmpty()) @@ -387,7 +387,7 @@ public enum ZoneManager { currentZone = ZoneManager.findSmallestZone(worldLoc); - if (currentZone.isGuildZone) + if (currentZone.guild_zone) return City.getCity(currentZone.playerCityUUID); return null; @@ -440,7 +440,7 @@ public enum ZoneManager { //not player city, must be npc city.. - if (!zone.isGuildZone) + if (!zone.guild_zone) zone.isNPCCity = true; if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) { diff --git a/src/engine/net/client/handlers/AbandonAssetMsgHandler.java b/src/engine/net/client/handlers/AbandonAssetMsgHandler.java index aea94ffd..fbbcea93 100644 --- a/src/engine/net/client/handlers/AbandonAssetMsgHandler.java +++ b/src/engine/net/client/handlers/AbandonAssetMsgHandler.java @@ -151,7 +151,7 @@ public class AbandonAssetMsgHandler extends AbstractClientMsgHandler { cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc()); // Can't abandon a tree not within a player city zone - if (cityZone.isGuildZone == false) + if (cityZone.guild_zone == false) return; if (targetBuilding.getCity() == null) diff --git a/src/engine/net/client/handlers/ChannelMuteMsgHandler.java b/src/engine/net/client/handlers/ChannelMuteMsgHandler.java index b6d3ddbb..1e71fe89 100644 --- a/src/engine/net/client/handlers/ChannelMuteMsgHandler.java +++ b/src/engine/net/client/handlers/ChannelMuteMsgHandler.java @@ -65,7 +65,7 @@ public class ChannelMuteMsgHandler extends AbstractClientMsgHandler { cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc()); // Can't abandon a tree not within a player city zone - if (cityZone.isGuildZone == false) + if (cityZone.guild_zone == false) return; if (targetBuilding.getCity().hasBeenTransfered == true) { diff --git a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java index 4672efc0..a2e7726b 100644 --- a/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java +++ b/src/engine/net/client/handlers/ManageCityAssetMsgHandler.java @@ -75,7 +75,7 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler { Zone zone = ZoneManager.findSmallestZone(player.getLoc()); - if (!zone.isGuildZone) { + if (!zone.guild_zone) { ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command."); return true; } diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index fad51445..5f4c4451 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -334,7 +334,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { Zone zone = ZoneManager.findSmallestZone(player.getLoc()); if (zone != null) { - if (zone.isGuildZone) { + if (zone.guild_zone) { loc = zone.getLoc(); } } diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 4efb7add..6ef021a3 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -137,7 +137,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { private static boolean validateBuildingPlacement(Zone serverZone, PlaceAssetMsg msg, ClientConnection origin, PlayerCharacter player, PlacementInfo placementInfo) { - if (serverZone.isGuildZone == false) { + if (serverZone.guild_zone == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, player.getName()); return false; } @@ -201,7 +201,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Cannot place assets on a dead tree - if ((serverZone.isGuildZone) + if ((serverZone.guild_zone) && (City.getCity(serverZone.playerCityUUID).getTOL().getRank() == -1)) { PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot place asset on dead tree until world heals"); return false; @@ -261,7 +261,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Must be a player city - if (serverZone.isGuildZone == false) { + if (serverZone.guild_zone == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 41, player.getName()); // Cannot place outside a guild zone return false; } @@ -571,7 +571,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // No valid player city found - if (serverCity == null || serverCity.getParent().isGuildZone == false) { + if (serverCity == null || serverCity.getParent().guild_zone == false) { PlaceAssetMsg.sendPlaceAssetError(origin, 52, ""); // Cannot place outisde a guild zone return false; } @@ -783,7 +783,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { // Link the zone with the city and then add // to the appropriate hash tables and cache - zoneObject.isGuildZone = true; + zoneObject.guild_zone = true; if (zoneObject.parent != null) zoneObject.parent.addNode(zoneObject); //add as child to parent diff --git a/src/engine/net/client/msg/GuildTreeStatusMsg.java b/src/engine/net/client/msg/GuildTreeStatusMsg.java index 19899da3..8b108589 100644 --- a/src/engine/net/client/msg/GuildTreeStatusMsg.java +++ b/src/engine/net/client/msg/GuildTreeStatusMsg.java @@ -117,7 +117,7 @@ public class GuildTreeStatusMsg extends ClientNetMsg { city = null; if (cityZone != null) - if (cityZone.isGuildZone) + if (cityZone.guild_zone) city = City.GetCityFromCache(cityZone.playerCityUUID); else if (this.treeOfLife != null && this.treeOfLife.getGuild() != null) city = this.treeOfLife.getGuild().getOwnedCity(); diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index 2c9313a3..783029cc 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -130,7 +130,7 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { ArrayList allIn = ZoneManager.getAllZonesIn(this.getLoc()); for (Zone zone : allIn) - if (zone.peaceZone == (byte) 1) + if (zone.peace_zone == (byte) 1) return true; return false; diff --git a/src/engine/objects/Bane.java b/src/engine/objects/Bane.java index 4578d653..61c9cfb7 100644 --- a/src/engine/objects/Bane.java +++ b/src/engine/objects/Bane.java @@ -162,7 +162,7 @@ public final class Bane { // Cannot place assets on a dead tree - if ((cityZone.isGuildZone) && + if ((cityZone.guild_zone) && (City.getCity(cityZone.playerCityUUID).getTOL().getRank() == -1)) { PlaceAssetMsg.sendPlaceAssetError(origin, 1, "Cannot bane a dead tree!"); return false; diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index d172b0bf..442d3513 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -460,7 +460,7 @@ public class Building extends AbstractWorldObject { } } } - if (this.parentZone.isGuildZone == false) + if (this.parentZone.guild_zone == false) return null; return City.getCity(this.parentZone.playerCityUUID); diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 5ab37717..d1820480 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -334,7 +334,7 @@ public class City extends AbstractWorldObject { if (city.noTeleport) continue; - if (city.parentZone != null && city.parentZone.isGuildZone) { + if (city.parentZone != null && city.parentZone.guild_zone) { if (pc.getAccount().status.equals(AccountStatus.ADMIN)) { cities.add(city); @@ -395,7 +395,7 @@ public class City extends AbstractWorldObject { if (city.noRepledge) continue; - if (city.parentZone != null && city.parentZone.isGuildZone) { + if (city.parentZone != null && city.parentZone.guild_zone) { //list Player cities //open city, just list diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index d3d914ce..bfb64654 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -894,7 +894,7 @@ public class NPC extends AbstractCharacter { this.stamina.set(this.staminaMax); } - if (this.parentZone.isGuildZone) + if (this.parentZone.guild_zone) if (NPC.GetNPCProfits(this) == null) NPCProfits.CreateProfits(this); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 170d0cec..a1381bb8 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1703,7 +1703,7 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(this.getLoc()); if (zone != null) { - return zone.peaceZone == (byte) 1; + return zone.peace_zone == (byte) 1; } return false; @@ -1797,7 +1797,7 @@ public class PlayerCharacter extends AbstractCharacter { //DeathShroud - if (zone.peaceZone == 0) + if (zone.peace_zone == 0) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); //enable this to give players deathshroud if mobs kill player. @@ -1843,7 +1843,7 @@ public class PlayerCharacter extends AbstractCharacter { //DeathShroud - if (zone.peaceZone == 0) + if (zone.peace_zone == 0) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); if (doPVPEXP) { @@ -1898,7 +1898,7 @@ public class PlayerCharacter extends AbstractCharacter { killCleanup(); Zone zone = ZoneManager.findSmallestZone(this.getLoc()); - if (zone.peaceZone == 0) + if (zone.peace_zone == 0) PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false); // Send death message if needed diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index f9a715cd..7d8a484c 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -39,7 +39,7 @@ public class Zone extends AbstractGameObject { public final float zOffset; public final float yOffset; public final int zoneTemplate; - public final byte peaceZone; + public final byte peace_zone; public final String Icon1; public final String Icon2; public final String Icon3; @@ -54,7 +54,7 @@ public class Zone extends AbstractGameObject { public Zone parent = null; public Bounds bounds; public boolean isNPCCity = false; - public boolean isGuildZone; + public boolean guild_zone; public String hash; public float worldAltitude = 0; public float seaLevel = 0f; @@ -69,13 +69,13 @@ public class Zone extends AbstractGameObject { super(rs); this.parentZoneID = rs.getInt("parent"); this.playerCityUUID = rs.getInt("playerCityUUID"); - this.isGuildZone = this.playerCityUUID != 0; + this.guild_zone = this.playerCityUUID != 0; this.zoneName = rs.getString("zoneName"); this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); this.zoneTemplate = rs.getInt("template"); - this.peaceZone = rs.getByte("peaceZone"); + this.peace_zone = rs.getByte("peace_zone"); this.Icon1 = rs.getString("icon1"); this.Icon2 = rs.getString("icon2"); this.Icon3 = rs.getString("icon3"); @@ -146,7 +146,7 @@ public class Zone extends AbstractGameObject { writer.putString(city.getCityName()); else writer.putString(zone.zoneName); - writer.put(zone.peaceZone); + writer.put(zone.peace_zone); writer.putString(zone.Icon1); writer.putString(zone.Icon2); writer.putString(zone.Icon3); @@ -238,7 +238,7 @@ public class Zone extends AbstractGameObject { // Macro zones have icons. - if (this.isGuildZone == true) + if (this.guild_zone == true) return false; if (this.parent == null) @@ -310,7 +310,7 @@ public class Zone extends AbstractGameObject { public HeightMap getHeightMap() { - if (this.isGuildZone) + if (this.guild_zone) return HeightMap.PlayerCityHeightMap; return HeightMap.heightmapByLoadNum.get(this.zoneTemplate); From 34d450fecf647bf4e983cffd16dfe4f9b2779ffa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:06:57 -0400 Subject: [PATCH 103/289] class and table schema now conform to JSON --- src/engine/Enum.java | 2 +- src/engine/InterestManagement/HeightMap.java | 2 +- src/engine/devcmd/cmds/GetZoneCmd.java | 2 +- src/engine/devcmd/cmds/InfoCmd.java | 4 ++-- src/engine/devcmd/cmds/ZoneInfoCmd.java | 4 ++-- src/engine/devcmd/cmds/ZoneSetCmd.java | 2 +- src/engine/gameManager/ZoneManager.java | 2 +- src/engine/objects/Zone.java | 12 ++++++------ src/engine/server/world/WorldServer.java | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 8abd1d8a..266730c3 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -469,7 +469,7 @@ public class Enum { // 14001 does not have a banestone to bind at - if (ruinZone.zoneTemplate == 14001) + if (ruinZone.template == 14001) spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30); else spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc() diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index a2f7168c..a5c0a658 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -191,7 +191,7 @@ public class HeightMap { HeightMap heightMap = new HeightMap(zone); - HeightMap.heightmapByLoadNum.put(zone.zoneTemplate, heightMap); + HeightMap.heightmapByLoadNum.put(zone.template, heightMap); } diff --git a/src/engine/devcmd/cmds/GetZoneCmd.java b/src/engine/devcmd/cmds/GetZoneCmd.java index 62ffb1df..85ec0afb 100644 --- a/src/engine/devcmd/cmds/GetZoneCmd.java +++ b/src/engine/devcmd/cmds/GetZoneCmd.java @@ -51,7 +51,7 @@ public class GetZoneCmd extends AbstractDevCmd { } for (Zone zone : allIn) - throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.zoneTemplate); + throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.template); } @Override diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index d0257efb..38a7fe77 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -387,7 +387,7 @@ public class InfoCmd extends AbstractDevCmd { output += newline; output += "EquipSet: " + targetNPC.getEquipmentSetID(); output += newline; - output += "Parent Zone LoadNum : " + targetNPC.getParentZone().zoneTemplate; + output += "Parent Zone LoadNum : " + targetNPC.getParentZone().template; } @@ -473,7 +473,7 @@ public class InfoCmd extends AbstractDevCmd { output += "EquipSet: " + targetMob.equipmentSetID; output += newline; try { - output += "Parent Zone LoadNum : " + targetMob.getParentZone().zoneTemplate; + output += "Parent Zone LoadNum : " + targetMob.getParentZone().template; } catch (Exception ex) { //who cares } diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index efc069e9..b5e8165d 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -75,7 +75,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; output += "name: " + zone.zoneName; output += newline; - output += "loadNum: " + zone.zoneTemplate; + output += "loadNum: " + zone.template; if (zone.parent != null) { output += StringUtils.addWS(", parent: " + zone.parent.getObjectUUID(), 30); output += "Parentabs: x: " + zone.parent.absX + ", y: " + zone.parent.absY + ", z: " + zone.parent.absZ; @@ -130,7 +130,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { for (Zone child : nodes) { output += newline; - output += child.zoneName + " (" + child.zoneTemplate + ')'; + output += child.zoneName + " (" + child.template + ')'; } } throwbackInfo(player, output); diff --git a/src/engine/devcmd/cmds/ZoneSetCmd.java b/src/engine/devcmd/cmds/ZoneSetCmd.java index aedb78ac..4d949134 100644 --- a/src/engine/devcmd/cmds/ZoneSetCmd.java +++ b/src/engine/devcmd/cmds/ZoneSetCmd.java @@ -40,7 +40,7 @@ public class ZoneSetCmd extends AbstractDevCmd { zone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); - throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.zoneTemplate + ") " + zone.getObjectUUID()); + throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.template + ") " + zone.getObjectUUID()); // NPC diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 13749067..7cedb711 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -182,7 +182,7 @@ public enum ZoneManager { public static final void populateWorldZones(final Zone zone) { - int loadNum = zone.zoneTemplate; + int loadNum = zone.template; // Zones are added to separate // collections for quick access diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 7d8a484c..7a6d8615 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -38,7 +38,7 @@ public class Zone extends AbstractGameObject { public final float xOffset; public final float zOffset; public final float yOffset; - public final int zoneTemplate; + public final int template; public final byte peace_zone; public final String Icon1; public final String Icon2; @@ -74,7 +74,7 @@ public class Zone extends AbstractGameObject { this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); - this.zoneTemplate = rs.getInt("template"); + this.template = rs.getInt("template"); this.peace_zone = rs.getByte("peace_zone"); this.Icon1 = rs.getString("icon1"); this.Icon2 = rs.getString("icon2"); @@ -106,7 +106,7 @@ public class Zone extends AbstractGameObject { public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { - if (zone.zoneTemplate == 0 && zone.playerCityUUID == 0) + if (zone.template == 0 && zone.playerCityUUID == 0) Logger.warn("Warning! WorldServerMap with ID " + zone.getObjectUUID() + " has a loadnum of 0 (player city) and no city linked. This will probably crash the client!"); // Player City Terraform values serialized here. @@ -124,7 +124,7 @@ public class Zone extends AbstractGameObject { writer.putInt(0); writer.putInt(0); - writer.putInt(zone.zoneTemplate); + writer.putInt(zone.template); if (zone.playerCityUUID > 0) { City k = City.getCity(zone.playerCityUUID); @@ -167,7 +167,7 @@ public class Zone extends AbstractGameObject { this.bounds = Bounds.borrow(); - Vector2f zoneSize = ZoneManager._zone_size_data.get(this.zoneTemplate); + Vector2f zoneSize = ZoneManager._zone_size_data.get(this.template); // Default to player zone size on error? Maybe log this @@ -313,7 +313,7 @@ public class Zone extends AbstractGameObject { if (this.guild_zone) return HeightMap.PlayerCityHeightMap; - return HeightMap.heightmapByLoadNum.get(this.zoneTemplate); + return HeightMap.heightmapByLoadNum.get(this.template); } } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 06156bad..1ed40144 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -469,7 +469,7 @@ public class WorldServer { for (Zone zone : ZoneManager.getAllZones()) { if (zone.getHeightMap() != null) { if (zone.getHeightMap().bucketWidthX == 0) { - System.out.println("Zone load num: " + zone.zoneTemplate + " has no bucket width"); + System.out.println("Zone load num: " + zone.template + " has no bucket width"); } } } @@ -565,7 +565,7 @@ public class WorldServer { for (Zone zone : rootParent) { - ZoneManager.addZone(zone.zoneTemplate, zone); + ZoneManager.addZone(zone.template, zone); //Handle Buildings From bd97745ed1158b4de5bc9b0a1666b61e5c4417ba Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:07:50 -0400 Subject: [PATCH 104/289] class and table schema now conform to JSON --- src/engine/gameManager/ZoneManager.java | 2 +- src/engine/objects/Zone.java | 40 ++++++++++++------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 7cedb711..95d6cedf 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -266,7 +266,7 @@ public enum ZoneManager { // Enforce min level - if (zone.minLvl < Integer.parseInt(ConfigManager.MB_HOTZONE_MIN_LEVEL.getValue())) + if (zone.min_level < Integer.parseInt(ConfigManager.MB_HOTZONE_MIN_LEVEL.getValue())) return false; if (ZoneManager.hotZone != null) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 7a6d8615..34c6d793 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -40,14 +40,14 @@ public class Zone extends AbstractGameObject { public final float yOffset; public final int template; public final byte peace_zone; - public final String Icon1; - public final String Icon2; - public final String Icon3; + public final String icon1; + public final String icon2; + public final String icon3; public float absX = 0.0f; public float absY = 0.0f; public float absZ = 0.0f; - public int minLvl; - public int maxLvl; + public int min_level; + public int max_level; public boolean hasBeenHotzone = false; public ArrayList nodes = null; public int parentZoneID; @@ -76,11 +76,11 @@ public class Zone extends AbstractGameObject { this.yOffset = rs.getFloat("yOffset"); this.template = rs.getInt("template"); this.peace_zone = rs.getByte("peace_zone"); - this.Icon1 = rs.getString("icon1"); - this.Icon2 = rs.getString("icon2"); - this.Icon3 = rs.getString("icon3"); - this.minLvl = rs.getInt("min_level"); - this.maxLvl = rs.getInt("max_level"); + this.icon1 = rs.getString("icon1"); + this.icon2 = rs.getString("icon2"); + this.icon3 = rs.getString("icon3"); + this.min_level = rs.getInt("min_level"); + this.max_level = rs.getInt("max_level"); this.hash = rs.getString("hash"); //this needs to be here specifically for new zones created after server boot (e.g. player city zones) @@ -88,9 +88,9 @@ public class Zone extends AbstractGameObject { Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); this.setParent(parentZone); - if (this.minLvl == 0 && parentZone != null) { - this.minLvl = parentZone.minLvl; - this.maxLvl = parentZone.maxLvl; + if (this.min_level == 0 && parentZone != null) { + this.min_level = parentZone.min_level; + this.max_level = parentZone.max_level; } if (parentZone != null) @@ -147,9 +147,9 @@ public class Zone extends AbstractGameObject { else writer.putString(zone.zoneName); writer.put(zone.peace_zone); - writer.putString(zone.Icon1); - writer.putString(zone.Icon2); - writer.putString(zone.Icon3); + writer.putString(zone.icon1); + writer.putString(zone.icon2); + writer.putString(zone.icon3); writer.put((byte) 0); // Pad for (Zone child : zone.nodes) { @@ -209,9 +209,9 @@ public class Zone extends AbstractGameObject { this.absY = this.yOffset + parent.absY; this.absZ = this.zOffset + parent.absZ; - if (this.minLvl == 0 || this.maxLvl == 0) { - this.minLvl = this.parent.minLvl; - this.maxLvl = this.parent.maxLvl; + if (this.min_level == 0 || this.max_level == 0) { + this.min_level = this.parent.min_level; + this.max_level = this.parent.max_level; } this.setBounds(); @@ -244,7 +244,7 @@ public class Zone extends AbstractGameObject { if (this.parent == null) return false; - return !Icon1.equals(""); + return !icon1.equals(""); } public Vector3fImmutable getLoc() { From 1e9eec2c484b4423a2b64b6258f01efc7d24f19f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:24:00 -0400 Subject: [PATCH 105/289] Heightmap is now an integer. --- src/engine/InterestManagement/HeightMap.java | 5 +++-- src/engine/objects/Zone.java | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index a5c0a658..b863a143 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -40,7 +40,7 @@ public class HeightMap { public static final HashMap heightmapByLoadNum = new HashMap<>(); - public static final HashMap _pixelData = new HashMap<>(); + public static final HashMap _pixelData = new HashMap<>(); // Heightmap data for all zones. public static float SCALEVALUE = 1.0f / 255; @@ -341,7 +341,8 @@ public class HeightMap { // Insert color data into lookup table - _pixelData.put(imageFile.getName().substring(0, imageFile.getName().lastIndexOf(".")), colorData); + int heightMapID = Integer.parseInt(imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."))); + _pixelData.put(heightMapID, colorData); } catch (IOException e) { Logger.error(e); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 34c6d793..c4af8ee1 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -61,6 +61,15 @@ public class Zone extends AbstractGameObject { public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; public Bounds blendBounds; + public float major_radius; + public float minor_radius; + public float min_blend; + public float max_blend; + public String sea_level_type; + public float sea_level; + public String terrain_type; + public float terrain_max_y; + public int terrain_image; /** * ResultSet Constructor @@ -81,7 +90,15 @@ public class Zone extends AbstractGameObject { this.icon3 = rs.getString("icon3"); this.min_level = rs.getInt("min_level"); this.max_level = rs.getInt("max_level"); - this.hash = rs.getString("hash"); + this.major_radius = rs.getFloat("major_radius"); + this.minor_radius = rs.getFloat("minor_radius"); + this.min_blend = rs.getFloat("min_blend"); + this.max_blend = rs.getFloat("max_blend"); + this.sea_level_type = rs.getString("sea_level_type"); + this.sea_level = rs.getFloat("sea_level"); + this.terrain_type = rs.getString("terrain_type"); + this.terrain_max_y = rs.getFloat("terrain_max_y"); + this.terrain_image = rs.getInt("terrain_image"); //this needs to be here specifically for new zones created after server boot (e.g. player city zones) From 85983954de68e660b17cce04cfc5b9a0fb7d784f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 16:28:26 -0400 Subject: [PATCH 106/289] Conform to database --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index c4af8ee1..f2a7f4ee 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -79,7 +79,7 @@ public class Zone extends AbstractGameObject { this.parentZoneID = rs.getInt("parent"); this.playerCityUUID = rs.getInt("playerCityUUID"); this.guild_zone = this.playerCityUUID != 0; - this.zoneName = rs.getString("zoneName"); + this.zoneName = rs.getString("zone_name"); this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); From 6fd61889a84f43a9c85e0e571e4240697b35d615 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 17:20:54 -0400 Subject: [PATCH 107/289] byte array to save memory. --- src/engine/InterestManagement/HeightMap.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index b863a143..312928cc 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -40,7 +40,7 @@ public class HeightMap { public static final HashMap heightmapByLoadNum = new HashMap<>(); - public static final HashMap _pixelData = new HashMap<>(); + public static final HashMap _pixelData = new HashMap<>(); // Heightmap data for all zones. public static float SCALEVALUE = 1.0f / 255; @@ -326,16 +326,16 @@ public class HeightMap { try { BufferedImage heightmapImage = ImageIO.read(imageFile); - // Generate pixel for this heightmap. RPG channels are all the same + // Generate pixel data for this heightmap. RPG channels are all the same // in this greyscale TGA heightmap. We will choose red. - int[][] colorData = new int[heightmapImage.getWidth()][heightmapImage.getHeight()]; + byte[][] colorData = new byte[heightmapImage.getWidth()][heightmapImage.getHeight()]; for (int y = 0; y < heightmapImage.getHeight(); y++) { for (int x = 0; x < heightmapImage.getWidth(); x++) { Color color = new Color(heightmapImage.getRGB(x, y)); - colorData[x][y] = color.getRed(); + colorData[x][y] = (byte) color.getRed(); } } From 3497d275a81bd1517df07959898e3de1a3843db9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 17:21:34 -0400 Subject: [PATCH 108/289] File reformat --- src/engine/InterestManagement/HeightMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 312928cc..f966010d 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -345,7 +345,7 @@ public class HeightMap { _pixelData.put(heightMapID, colorData); } catch (IOException e) { - Logger.error(e); + Logger.error(e); } From d7044c16637b7f5b5fdbd180432648b7c0da02c6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 17:24:41 -0400 Subject: [PATCH 109/289] Depth less one --- src/engine/InterestManagement/HeightMap.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index f966010d..962e4678 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -331,13 +331,12 @@ public class HeightMap { byte[][] colorData = new byte[heightmapImage.getWidth()][heightmapImage.getHeight()]; - for (int y = 0; y < heightmapImage.getHeight(); y++) { + for (int y = 0; y < heightmapImage.getHeight(); y++) for (int x = 0; x < heightmapImage.getWidth(); x++) { Color color = new Color(heightmapImage.getRGB(x, y)); colorData[x][y] = (byte) color.getRed(); } - } // Insert color data into lookup table From 438ea04a1abe1f84275cfb7a9616f0c21d79742d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 20 Sep 2023 17:26:00 -0400 Subject: [PATCH 110/289] Comment cleanup --- src/engine/InterestManagement/HeightMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 962e4678..a00524bd 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -347,9 +347,9 @@ public class HeightMap { Logger.error(e); } - } - }); + }); // Try with resources block + } catch (IOException e) { Logger.error(e); } From c19ec913cb36c9452a35ea467169a939e4e8d22c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 21 Sep 2023 14:39:37 -0400 Subject: [PATCH 111/289] Disable blend until after refactor. --- src/engine/InterestManagement/HeightMap.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index a00524bd..217acd23 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -237,12 +237,12 @@ public class HeightMap { // Heightmap blending is based on distance to edge of zone. - if (Bounds.collide(worldLoc, heightMapZone.blendBounds) == true) + // if (Bounds.collide(worldLoc, heightMapZone.blendBounds) == true) return interpolatedTerrainHeight; // We will need the parent height if we got this far into the method - return interpolatePLANAR(worldLoc, heightMapZone, zoneLoc, interpolatedTerrainHeight); + // return interpolatePLANAR(worldLoc, heightMapZone, zoneLoc, interpolatedTerrainHeight); } From c6d24d25ccf986a58d12c2785367812ce273184c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 13:57:20 -0400 Subject: [PATCH 112/289] Method cleanup --- src/engine/gameManager/ZoneManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 95d6cedf..991a2b06 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -464,16 +464,14 @@ public enum ZoneManager { if (zone.parent == null) return worldAlttitude; - Zone parentZone = zone.parent; - // Children of seafloor - if (parentZone.parent == null) + if (ZoneManager.seaFloor.equals(zone.parent)) return worldAlttitude + zone.yOffset; // return height from heightmap engine at zone location - worldAlttitude = HeightMap.getWorldHeight(parentZone, zone.getLoc()); + worldAlttitude = HeightMap.getWorldHeight(zone.parent, zone.getLoc()); // Add zone offset to value From 6a750f4eb2f632f67d5790e719001c262cbc07e3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:04:26 -0400 Subject: [PATCH 113/289] Unused methods removed --- src/engine/InterestManagement/HeightMap.java | 53 +------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 217acd23..b71a1be5 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -12,8 +12,6 @@ import engine.Enum; import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; -import engine.math.Bounds; -import engine.math.FastMath; import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.Zone; @@ -32,8 +30,6 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.stream.Stream; -import static java.lang.Math.abs; - public class HeightMap { // Class variables @@ -235,57 +231,10 @@ public class HeightMap { float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); interpolatedTerrainHeight += heightMapZone.worldAltitude; - // Heightmap blending is based on distance to edge of zone. - - // if (Bounds.collide(worldLoc, heightMapZone.blendBounds) == true) - return interpolatedTerrainHeight; - - // We will need the parent height if we got this far into the method - - // return interpolatePLANAR(worldLoc, heightMapZone, zoneLoc, interpolatedTerrainHeight); + return interpolatedTerrainHeight; } - private static float interpolatePLANAR(Vector3fImmutable worldLoc, Zone heightMapZone, Vector2f zoneLoc, float interpolatedTerrainHeight) { - - // zones of type PLANAR - - Zone parentZone; - float interpolatedParentTerrainHeight; - - parentZone = HeightMap.getNextZoneWithTerrain(heightMapZone.parent); - - interpolatedParentTerrainHeight = HeightMap.getWorldHeight(parentZone, worldLoc); - interpolatedParentTerrainHeight += parentZone.worldAltitude; - - Bounds blendBounds = Bounds.borrow(); - zoneLoc.x = abs(zoneLoc.x); - zoneLoc.y = abs(zoneLoc.x); - - blendBounds.setBounds(new Vector2f(heightMapZone.absX, heightMapZone.absZ), zoneLoc, 0.0f); - - float maxBlendArea = (heightMapZone.blendBounds.getHalfExtents().x) * - (heightMapZone.blendBounds.getHalfExtents().y); - float currentArea = (blendBounds.getHalfExtents().x) * - (blendBounds.getHalfExtents().y); - float zoneArea = (heightMapZone.bounds.getHalfExtents().x) * - (heightMapZone.bounds.getHalfExtents().y); - - blendBounds.release(); - - float blendDelta = zoneArea - maxBlendArea; - float currentDelta = zoneArea - currentArea; - - float percentage; - - if (currentDelta != 0 && blendDelta != 0) - percentage = currentDelta / blendDelta; - else - percentage = 0.0f; - - interpolatedTerrainHeight = FastMath.LERP(percentage, interpolatedTerrainHeight, interpolatedParentTerrainHeight); - return interpolatedTerrainHeight; - } public static float getWorldHeight(Vector3fImmutable worldLoc) { From 7dcde390cdc399420f51c3135a6d4e7a3dd16f18 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:19:30 -0400 Subject: [PATCH 114/289] Flip Flop --- src/engine/InterestManagement/HeightMap.java | 4 ---- src/engine/gameManager/ZoneManager.java | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index b71a1be5..566977cd 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -339,10 +339,6 @@ public class HeightMap { if (zoneLoc.y > this.fullExtentsY) zoneLoc.setY(this.fullExtentsY); - // Flip Y coordinates - - zoneLoc.setY(this.fullExtentsY - zoneLoc.y); - float xBucket = (zoneLoc.x / this.bucketWidthX); float yBucket = (zoneLoc.y / this.bucketWidthY); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 991a2b06..0c6c4a1f 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -305,9 +305,6 @@ public enum ZoneManager { localCoords = new Vector2f(worldVector.x, worldVector.z); localCoords = localCoords.subtract(zoneOrigin); - localCoords.setY((serverZone.bounds.getHalfExtents().y * 2) - localCoords.y); - - // TODO : Make sure this value does not go outside the zone's bounds. return localCoords; From d9b513e88c4befd2a717aae6136fef7e4bc2b190 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:32:08 -0400 Subject: [PATCH 115/289] cell count cached --- src/engine/InterestManagement/HeightMap.java | 32 ++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 566977cd..03d3df1f 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -56,6 +56,8 @@ public class HeightMap { public float bucketWidthY; public float seaLevel = 0; public int[][] pixelColorValues; + public int bucketCountX; + public int bucketCountY; public float zone_minBlend; public float zone_maxBlend; @@ -95,13 +97,11 @@ public class HeightMap { // Calculate the data we do not load from table - float numOfBucketsX = this.heightmapImage.getWidth() - 1; - float calculatedWidthX = this.fullExtentsX / numOfBucketsX; - this.bucketWidthX = calculatedWidthX; + bucketCountX = this.heightmapImage.getWidth() - 1; + this.bucketWidthX = this.fullExtentsX / bucketCountX; - float numOfBucketsY = this.heightmapImage.getHeight() - 1; - float calculatedWidthY = this.fullExtentsY / numOfBucketsY; - this.bucketWidthY = calculatedWidthY; + bucketCountY = this.heightmapImage.getHeight() - 1; + this.bucketWidthY = this.fullExtentsY / bucketCountY; // Generate pixel array from image data @@ -325,22 +325,16 @@ public class HeightMap { public Vector2f getGridSquare(Vector2f zoneLoc) { - // Clamp values. - - if (zoneLoc.x < 0) - zoneLoc.setX(0); - - if (zoneLoc.x >= this.fullExtentsX) - zoneLoc.setX(this.fullExtentsX); + float xBucket = (zoneLoc.x / this.bucketWidthX); + float yBucket = (zoneLoc.y / this.bucketWidthY); - if (zoneLoc.y < 0) - zoneLoc.setY(0); + // Standing on the pole - if (zoneLoc.y > this.fullExtentsY) - zoneLoc.setY(this.fullExtentsY); + if (xBucket == this.bucketCountX) + xBucket--; - float xBucket = (zoneLoc.x / this.bucketWidthX); - float yBucket = (zoneLoc.y / this.bucketWidthY); + if (yBucket == this.bucketCountY) + yBucket--; return new Vector2f(xBucket, yBucket); } From e7571f3e8312d751ec097742380a86680e268b83 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:43:17 -0400 Subject: [PATCH 116/289] Audit of zone loc --- src/engine/InterestManagement/HeightMap.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 03d3df1f..3439663a 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -325,16 +325,16 @@ public class HeightMap { public Vector2f getGridSquare(Vector2f zoneLoc) { - float xBucket = (zoneLoc.x / this.bucketWidthX); - float yBucket = (zoneLoc.y / this.bucketWidthY); + // Clamp values. - // Standing on the pole + if (zoneLoc.x >= this.fullExtentsX) + Logger.error("Outside of zone"); - if (xBucket == this.bucketCountX) - xBucket--; + if (zoneLoc.y >= this.fullExtentsY) + Logger.error("Outside of zone"); - if (yBucket == this.bucketCountY) - yBucket--; + float xBucket = zoneLoc.x / this.bucketWidthX; + float yBucket = zoneLoc.y / this.bucketWidthY; return new Vector2f(xBucket, yBucket); } From 5db8c47aa898ce338f6f385540695c2874c60d4d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:47:35 -0400 Subject: [PATCH 117/289] Clamp value at pole --- src/engine/InterestManagement/HeightMap.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 3439663a..d3361472 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -327,15 +327,15 @@ public class HeightMap { // Clamp values. - if (zoneLoc.x >= this.fullExtentsX) - Logger.error("Outside of zone"); - - if (zoneLoc.y >= this.fullExtentsY) - Logger.error("Outside of zone"); - float xBucket = zoneLoc.x / this.bucketWidthX; float yBucket = zoneLoc.y / this.bucketWidthY; + if (xBucket >= this.bucketCountX) + xBucket = this.bucketCountX - 1; + + if (yBucket >= this.bucketCountY) + yBucket = this.bucketCountY - 1; + return new Vector2f(xBucket, yBucket); } From f454fb5e1c753aff1fa418c25c54ba3d8fa2f697 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 20:55:11 -0400 Subject: [PATCH 118/289] Need float value --- src/engine/InterestManagement/HeightMap.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index d3361472..7c09c945 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -98,10 +98,10 @@ public class HeightMap { // Calculate the data we do not load from table bucketCountX = this.heightmapImage.getWidth() - 1; - this.bucketWidthX = this.fullExtentsX / bucketCountX; + this.bucketWidthX = this.fullExtentsX / (float) bucketCountX; bucketCountY = this.heightmapImage.getHeight() - 1; - this.bucketWidthY = this.fullExtentsY / bucketCountY; + this.bucketWidthY = this.fullExtentsY / (float) bucketCountY; // Generate pixel array from image data @@ -331,10 +331,10 @@ public class HeightMap { float yBucket = zoneLoc.y / this.bucketWidthY; if (xBucket >= this.bucketCountX) - xBucket = this.bucketCountX - 1; + xBucket = xBucket - 1; if (yBucket >= this.bucketCountY) - yBucket = this.bucketCountY - 1; + yBucket = xBucket - 1; return new Vector2f(xBucket, yBucket); } From 6b339da061e76b8562648a748b826b57836478d2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Oct 2023 21:03:47 -0400 Subject: [PATCH 119/289] Count propagated --- src/engine/InterestManagement/HeightMap.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 7c09c945..8550b2ad 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -144,6 +144,8 @@ public class HeightMap { } } + bucketCountX = this.pixelColorValues.length - 1; + bucketCountY = this.pixelColorValues[0].length - 1; } public HeightMap(Zone zone) { @@ -175,6 +177,8 @@ public class HeightMap { } } + bucketCountX = this.pixelColorValues.length - 1; + bucketCountY = this.pixelColorValues[0].length - 1; } public static void GeneratePlayerCityHeightMap() { From 5fdaa113671c338edb5b8d44bc673ef5656e7af4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:04:15 -0400 Subject: [PATCH 120/289] Prepare for terrain --- src/engine/InterestManagement/HeightMap.java | 92 ++++++++++---------- src/engine/devcmd/cmds/ZoneInfoCmd.java | 4 +- src/engine/server/world/WorldServer.java | 2 +- 3 files changed, 47 insertions(+), 51 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 8550b2ad..97a3075a 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -36,10 +36,7 @@ public class HeightMap { public static final HashMap heightmapByLoadNum = new HashMap<>(); - public static final HashMap _pixelData = new HashMap<>(); - - // Heightmap data for all zones. - public static float SCALEVALUE = 1.0f / 255; + public static final HashMap _pixelData = new HashMap<>(); // Bootstrap Tracking public static int heightMapsCreated = 0; @@ -52,16 +49,17 @@ public class HeightMap { public final int fullExtentsY; public final int zoneLoadID; public BufferedImage heightmapImage; - public float bucketWidthX; - public float bucketWidthY; + public float cell_size_x; + public float cell_size_y; public float seaLevel = 0; - public int[][] pixelColorValues; - public int bucketCountX; - public int bucketCountY; - + public short[][] pixelColorValues; + public int cell_count_x; + public int cell_count_y; public float zone_minBlend; public float zone_maxBlend; + public float terrain_scale; + public HeightMap(ResultSet rs) throws SQLException { this.heightMapID = rs.getInt("heightMapID"); @@ -97,11 +95,13 @@ public class HeightMap { // Calculate the data we do not load from table - bucketCountX = this.heightmapImage.getWidth() - 1; - this.bucketWidthX = this.fullExtentsX / (float) bucketCountX; + this.cell_count_x = this.heightmapImage.getWidth() - 1; + this.cell_size_x = this.fullExtentsX / (float) cell_count_x; - bucketCountY = this.heightmapImage.getHeight() - 1; - this.bucketWidthY = this.fullExtentsY / (float) bucketCountY; + this.cell_count_y = this.heightmapImage.getHeight() - 1; + this.cell_size_y = this.fullExtentsY / (float) cell_count_y; + + this.terrain_scale = this.maxHeight / 255f; // Generate pixel array from image data @@ -133,10 +133,10 @@ public class HeightMap { // Calculate the data we do not load from table - this.bucketWidthX = halfExtentsX; - this.bucketWidthY = halfExtentsY; + this.cell_size_x = halfExtentsX; + this.cell_size_y = halfExtentsY; - this.pixelColorValues = new int[this.fullExtentsX][this.fullExtentsY]; + this.pixelColorValues = new short[this.fullExtentsX][this.fullExtentsY]; for (int y = 0; y < this.fullExtentsY; y++) { for (int x = 0; x < this.fullExtentsX; x++) { @@ -144,8 +144,9 @@ public class HeightMap { } } - bucketCountX = this.pixelColorValues.length - 1; - bucketCountY = this.pixelColorValues[0].length - 1; + cell_count_x = this.pixelColorValues.length - 1; + cell_count_y = this.pixelColorValues[0].length - 1; + this.terrain_scale = this.maxHeight / 255f; } public HeightMap(Zone zone) { @@ -166,10 +167,10 @@ public class HeightMap { // Calculate the data we do not load from table - this.bucketWidthX = halfExtentsX; - this.bucketWidthY = halfExtentsY; + this.cell_size_x = halfExtentsX; + this.cell_size_y = halfExtentsY; - this.pixelColorValues = new int[this.fullExtentsX][this.fullExtentsY]; + this.pixelColorValues = new short[this.fullExtentsX][this.fullExtentsY]; for (int y = 0; y < this.fullExtentsY; y++) { for (int x = 0; x < this.fullExtentsX; x++) { @@ -177,8 +178,9 @@ public class HeightMap { } } - bucketCountX = this.pixelColorValues.length - 1; - bucketCountY = this.pixelColorValues[0].length - 1; + cell_count_x = this.pixelColorValues.length - 1; + cell_count_y = this.pixelColorValues[0].length - 1; + this.terrain_scale = this.maxHeight / 255f; } public static void GeneratePlayerCityHeightMap() { @@ -239,13 +241,13 @@ public class HeightMap { } - public static float getWorldHeight(Vector3fImmutable worldLoc) { Zone currentZone = ZoneManager.findSmallestZone(worldLoc); if (currentZone == null) return 0; + return getWorldHeight(currentZone, worldLoc); } @@ -260,12 +262,6 @@ public class HeightMap { HeightMap.GeneratePlayerCityHeightMap(); - // Clear all heightmap image data as it's no longer needed. - - for (HeightMap heightMap : HeightMap.heightmapByLoadNum.values()) { - heightMap.heightmapImage = null; - } - Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); // Load pixel data for heightmaps @@ -282,13 +278,13 @@ public class HeightMap { // Generate pixel data for this heightmap. RPG channels are all the same // in this greyscale TGA heightmap. We will choose red. - byte[][] colorData = new byte[heightmapImage.getWidth()][heightmapImage.getHeight()]; + short[][] colorData = new short[heightmapImage.getWidth()][heightmapImage.getHeight()]; for (int y = 0; y < heightmapImage.getHeight(); y++) for (int x = 0; x < heightmapImage.getWidth(); x++) { Color color = new Color(heightmapImage.getRGB(x, y)); - colorData[x][y] = (byte) color.getRed(); + colorData[x][y] = (short) color.getRed(); } // Insert color data into lookup table @@ -315,13 +311,13 @@ public class HeightMap { // Generate altitude lookup table for this heightmap - heightMap.pixelColorValues = new int[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; + heightMap.pixelColorValues = new short[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { color = new Color(heightMap.heightmapImage.getRGB(x, y)); - heightMap.pixelColorValues[x][y] = color.getRed(); + heightMap.pixelColorValues[x][y] = (short) color.getRed(); } } @@ -329,28 +325,31 @@ public class HeightMap { public Vector2f getGridSquare(Vector2f zoneLoc) { - // Clamp values. + float xBucket = zoneLoc.x / this.cell_size_x; + float yBucket = zoneLoc.y / this.cell_size_y; - float xBucket = zoneLoc.x / this.bucketWidthX; - float yBucket = zoneLoc.y / this.bucketWidthY; + // Clamp values when standing directly on max pole - if (xBucket >= this.bucketCountX) + if (xBucket >= this.cell_count_x) xBucket = xBucket - 1; - if (yBucket >= this.bucketCountY) + if (yBucket >= this.cell_count_y) yBucket = xBucket - 1; return new Vector2f(xBucket, yBucket); } - public float getInterpolatedTerrainHeight(Vector2f zoneLoc) { + public float getInterpolatedTerrainHeight(Vector2f terrainLoc) { float interpolatedHeight; - Vector2f gridSquare = getGridSquare(zoneLoc); + Vector2f gridSquare = getGridSquare(terrainLoc); - int gridX = (int) gridSquare.x; - int gridY = (int) gridSquare.y; + int gridX = (int) Math.floor(gridSquare.x); + int gridY = (int) Math.floor(gridSquare.y); + + float offsetX = gridSquare.x % 1; + float offsetY = gridSquare.y % 1; //get 4 surrounding vertices from the pixel array. @@ -366,15 +365,12 @@ public class HeightMap { // Interpolate between the 4 vertices - float offsetX = (gridSquare.x - gridX); - float offsetY = gridSquare.y - gridY; - interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX); interpolatedHeight += (bottomRightHeight * offsetY * offsetX); interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY)); - interpolatedHeight *= (float) this.maxHeight * SCALEVALUE; // Scale height + interpolatedHeight *= this.terrain_scale; // Scale height return interpolatedHeight; } diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index b5e8165d..2e0292c9 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -93,9 +93,9 @@ public class ZoneInfoCmd extends AbstractDevCmd { if (zone.getHeightMap() != null) { output += "HeightMap ID: " + zone.getHeightMap().heightMapID; output += newline; - output += "Bucket Width X : " + zone.getHeightMap().bucketWidthX; + output += "Bucket Width X : " + zone.getHeightMap().cell_size_x; output += newline; - output += "Bucket Width Y : " + zone.getHeightMap().bucketWidthY; + output += "Bucket Width Y : " + zone.getHeightMap().cell_size_y; } output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 1ed40144..9f070596 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -468,7 +468,7 @@ public class WorldServer { for (Zone zone : ZoneManager.getAllZones()) { if (zone.getHeightMap() != null) { - if (zone.getHeightMap().bucketWidthX == 0) { + if (zone.getHeightMap().cell_size_x == 0) { System.out.println("Zone load num: " + zone.template + " has no bucket width"); } } From ffb541a12ec2c5f992f954046082840f065e7032 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:09:50 -0400 Subject: [PATCH 121/289] Prepare for terrain --- src/engine/InterestManagement/HeightMap.java | 44 ++++++++++---------- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 97a3075a..a9e3cfb7 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -199,7 +199,7 @@ public class HeightMap { public static Zone getNextZoneWithTerrain(Zone zone) { - Zone nextZone = zone; + Zone terrain_zone = zone; if (zone.getHeightMap() != null) return zone; @@ -207,15 +207,15 @@ public class HeightMap { if (zone.equals(ZoneManager.getSeaFloor())) return zone; - while (nextZone.getHeightMap() == null) - nextZone = nextZone.parent; + while (terrain_zone.getHeightMap() == null) + terrain_zone = terrain_zone.parent; - return nextZone; + return terrain_zone; } public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { - Zone heightMapZone; + Zone terrainZone; // Seafloor is rather flat. @@ -226,16 +226,16 @@ public class HeightMap { // Zones without a heightmap use the next zone up the // tree to calculate heights from. - heightMapZone = getNextZoneWithTerrain(currentZone); + terrainZone = getNextZoneWithTerrain(currentZone); // Transform world loc into zone space coordinate system - Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, heightMapZone); + Vector2f terrainLoc = ZoneManager.worldToZoneSpace(worldLoc, terrainZone); // Interpolate height for this position using pixel array. - float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); - interpolatedTerrainHeight += heightMapZone.worldAltitude; + float interpolatedTerrainHeight = terrainZone.getHeightMap().getInterpolatedTerrainHeight(terrainLoc); + interpolatedTerrainHeight += terrainZone.worldAltitude; return interpolatedTerrainHeight; @@ -323,33 +323,33 @@ public class HeightMap { } - public Vector2f getGridSquare(Vector2f zoneLoc) { + public Vector2f getTerrainCell(Vector2f terrainLoc) { - float xBucket = zoneLoc.x / this.cell_size_x; - float yBucket = zoneLoc.y / this.cell_size_y; + float terrainCell_x = terrainLoc.x / this.cell_size_x; + float terrainCell_y = terrainLoc.y / this.cell_size_y; // Clamp values when standing directly on max pole - if (xBucket >= this.cell_count_x) - xBucket = xBucket - 1; + if (terrainCell_x >= this.cell_count_x) + terrainCell_x = terrainCell_x - 1; - if (yBucket >= this.cell_count_y) - yBucket = xBucket - 1; + if (terrainCell_y >= this.cell_count_y) + terrainCell_y = terrainCell_x - 1; - return new Vector2f(xBucket, yBucket); + return new Vector2f(terrainCell_x, terrainCell_y); } public float getInterpolatedTerrainHeight(Vector2f terrainLoc) { float interpolatedHeight; - Vector2f gridSquare = getGridSquare(terrainLoc); + Vector2f terrain_cell = getTerrainCell(terrainLoc); - int gridX = (int) Math.floor(gridSquare.x); - int gridY = (int) Math.floor(gridSquare.y); + int gridX = (int) Math.floor(terrain_cell.x); + int gridY = (int) Math.floor(terrain_cell.y); - float offsetX = gridSquare.x % 1; - float offsetY = gridSquare.y % 1; + float offsetX = terrain_cell.x % 1; + float offsetY = terrain_cell.y % 1; //get 4 surrounding vertices from the pixel array. diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index eb0eb280..96983f98 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -40,7 +40,7 @@ public class GetHeightCmd extends AbstractDevCmd { float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc()); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); - Vector2f gridSquare = heightmapZone.getHeightMap().getGridSquare(zoneLoc); + Vector2f gridSquare = heightmapZone.getHeightMap().getTerrainCell(zoneLoc); this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); From 0d75e6db9bec45f3147cc55054ffeedcf39ff152 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:18:43 -0400 Subject: [PATCH 122/289] Start terrain refactor --- .../{HeightMap.java => Terrain.java} | 36 +++++++++---------- .../db/handlers/dbHeightMapHandler.java | 8 ++--- src/engine/devcmd/cmds/GetHeightCmd.java | 10 +++--- src/engine/gameManager/PowersManager.java | 6 ++-- src/engine/gameManager/ZoneManager.java | 6 ++-- src/engine/objects/AbstractCharacter.java | 1 - src/engine/objects/AbstractWorldObject.java | 4 +-- src/engine/objects/Building.java | 4 +-- src/engine/objects/City.java | 4 +-- src/engine/objects/PlayerCharacter.java | 8 ++--- src/engine/objects/Zone.java | 14 ++++---- src/engine/server/world/WorldServer.java | 4 +-- 12 files changed, 52 insertions(+), 53 deletions(-) rename src/engine/InterestManagement/{HeightMap.java => Terrain.java} (90%) diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/Terrain.java similarity index 90% rename from src/engine/InterestManagement/HeightMap.java rename to src/engine/InterestManagement/Terrain.java index a9e3cfb7..c374839d 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/Terrain.java @@ -30,17 +30,17 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.stream.Stream; -public class HeightMap { +public class Terrain { // Class variables - public static final HashMap heightmapByLoadNum = new HashMap<>(); + public static final HashMap heightmapByLoadNum = new HashMap<>(); public static final HashMap _pixelData = new HashMap<>(); // Bootstrap Tracking public static int heightMapsCreated = 0; - public static HeightMap PlayerCityHeightMap; + public static Terrain playerCityTerrain; // Heightmap data for this heightmap public final int heightMapID; @@ -60,7 +60,7 @@ public class HeightMap { public float terrain_scale; - public HeightMap(ResultSet rs) throws SQLException { + public Terrain(ResultSet rs) throws SQLException { this.heightMapID = rs.getInt("heightMapID"); this.maxHeight = rs.getInt("maxHeight"); @@ -107,13 +107,13 @@ public class HeightMap { generatePixelData(this); - HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this); + Terrain.heightmapByLoadNum.put(this.zoneLoadID, this); heightMapsCreated++; } //Created for PlayerCities - public HeightMap() { + public Terrain() { this.heightMapID = 999999; this.maxHeight = 5; // for real... @@ -149,7 +149,7 @@ public class HeightMap { this.terrain_scale = this.maxHeight / 255f; } - public HeightMap(Zone zone) { + public Terrain(Zone zone) { this.heightMapID = 999999; this.maxHeight = 0; @@ -185,15 +185,15 @@ public class HeightMap { public static void GeneratePlayerCityHeightMap() { - HeightMap.PlayerCityHeightMap = new HeightMap(); + Terrain.playerCityTerrain = new Terrain(); } public static void GenerateCustomHeightMap(Zone zone) { - HeightMap heightMap = new HeightMap(zone); + Terrain heightMap = new Terrain(zone); - HeightMap.heightmapByLoadNum.put(zone.template, heightMap); + Terrain.heightmapByLoadNum.put(zone.template, heightMap); } @@ -260,9 +260,9 @@ public class HeightMap { //generate static player city heightmap. - HeightMap.GeneratePlayerCityHeightMap(); + Terrain.GeneratePlayerCityHeightMap(); - Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); + Logger.info(Terrain.heightmapByLoadNum.size() + " Heightmaps cached."); // Load pixel data for heightmaps @@ -305,19 +305,19 @@ public class HeightMap { } - private static void generatePixelData(HeightMap heightMap) { + private static void generatePixelData(Terrain terrain) { Color color; // Generate altitude lookup table for this heightmap - heightMap.pixelColorValues = new short[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; + terrain.pixelColorValues = new short[terrain.heightmapImage.getWidth()][terrain.heightmapImage.getHeight()]; - for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { - for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { + for (int y = 0; y < terrain.heightmapImage.getHeight(); y++) { + for (int x = 0; x < terrain.heightmapImage.getWidth(); x++) { - color = new Color(heightMap.heightmapImage.getRGB(x, y)); - heightMap.pixelColorValues[x][y] = (short) color.getRed(); + color = new Color(terrain.heightmapImage.getRGB(x, y)); + terrain.pixelColorValues[x][y] = (short) color.getRed(); } } diff --git a/src/engine/db/handlers/dbHeightMapHandler.java b/src/engine/db/handlers/dbHeightMapHandler.java index 514008de..87cb9428 100644 --- a/src/engine/db/handlers/dbHeightMapHandler.java +++ b/src/engine/db/handlers/dbHeightMapHandler.java @@ -1,6 +1,6 @@ package engine.db.handlers; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.gameManager.DbManager; import org.pmw.tinylog.Logger; @@ -18,8 +18,8 @@ public class dbHeightMapHandler extends dbHandlerBase { public void LOAD_ALL_HEIGHTMAPS() { - HeightMap thisHeightmap; - HeightMap.heightMapsCreated = 0; + Terrain thisHeightmap; + Terrain.heightMapsCreated = 0; try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_heightmap INNER JOIN static_zone_size ON static_zone_size.loadNum = static_zone_heightmap.zoneLoadID")) { @@ -27,7 +27,7 @@ public class dbHeightMapHandler extends dbHandlerBase { ResultSet rs = preparedStatement.executeQuery(); while (rs.next()) { - thisHeightmap = new HeightMap(rs); + thisHeightmap = new Terrain(rs); if (thisHeightmap.heightmapImage == null) { Logger.info("Imagemap for " + thisHeightmap.heightMapID + " was null"); diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 96983f98..642c9533 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -9,7 +9,7 @@ package engine.devcmd.cmds; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ZoneManager; import engine.math.Bounds; @@ -33,11 +33,11 @@ public class GetHeightCmd extends AbstractDevCmd { Zone heightmapZone; currentZone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); - heightmapZone = HeightMap.getNextZoneWithTerrain(currentZone); - parentZone = HeightMap.getNextZoneWithTerrain(currentZone.parent); + heightmapZone = Terrain.getNextZoneWithTerrain(currentZone); + parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent); - float currentHeight = HeightMap.getWorldHeight(currentZone, playerCharacter.getLoc()); - float parentHeight = HeightMap.getWorldHeight(parentZone, playerCharacter.getLoc()); + float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc()); + float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); Vector2f gridSquare = heightmapZone.getHeightMap().getTerrainCell(zoneLoc); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 573207f7..1875a898 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -9,7 +9,7 @@ package engine.gameManager; import engine.Enum.*; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.handlers.dbEffectsBaseHandler; import engine.db.handlers.dbPowerHandler; @@ -1772,7 +1772,7 @@ public enum PowersManager { } else { targetLoc = tl; try { - targetLoc = targetLoc.setY(HeightMap.getWorldHeight(targetLoc)); //on ground + targetLoc = targetLoc.setY(Terrain.getWorldHeight(targetLoc)); //on ground } catch (Exception e) { Logger.error(e); targetLoc = tl; @@ -1974,7 +1974,7 @@ public enum PowersManager { } else { targetLoc = tl; try { - targetLoc = targetLoc.setY(HeightMap.getWorldHeight(targetLoc)); //on ground + targetLoc = targetLoc.setY(Terrain.getWorldHeight(targetLoc)); //on ground } catch (Exception e) { Logger.error(e); } diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 0c6c4a1f..25b3e2b7 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -9,7 +9,7 @@ package engine.gameManager; import engine.Enum; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; import engine.math.Bounds; @@ -468,7 +468,7 @@ public enum ZoneManager { // return height from heightmap engine at zone location - worldAlttitude = HeightMap.getWorldHeight(zone.parent, zone.getLoc()); + worldAlttitude = Terrain.getWorldHeight(zone.parent, zone.getLoc()); // Add zone offset to value @@ -479,7 +479,7 @@ public enum ZoneManager { public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { - float localAltitude = HeightMap.getWorldHeight(currentLoc); + float localAltitude = Terrain.getWorldHeight(currentLoc); Zone zone = findSmallestZone(currentLoc); return localAltitude < zone.seaLevel; diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index c87438e4..7834b0cb 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -11,7 +11,6 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.InterestManager; import engine.InterestManagement.WorldGrid; import engine.exception.SerializationException; diff --git a/src/engine/objects/AbstractWorldObject.java b/src/engine/objects/AbstractWorldObject.java index cb647707..0bf5939a 100644 --- a/src/engine/objects/AbstractWorldObject.java +++ b/src/engine/objects/AbstractWorldObject.java @@ -13,7 +13,7 @@ import engine.Enum.DispatchChannel; import engine.Enum.EffectSourceType; import engine.Enum.GameObjectType; import engine.Enum.GridObjectType; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.job.AbstractScheduleJob; import engine.job.JobContainer; @@ -506,7 +506,7 @@ public abstract class AbstractWorldObject extends AbstractGameObject { if(this instanceof AbstractCharacter && this.region != null){ this.loc = this.loc.setY(this.region.lerpY(this) + this.getAltitude()); } else{ - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 442d3513..4d43e1ab 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -11,8 +11,8 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; @@ -206,7 +206,7 @@ public class Building extends AbstractWorldObject { // Altitude of this building is derived from the heightmap engine. Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); - tempLoc = new Vector3fImmutable(tempLoc.x, HeightMap.getWorldHeight(tempLoc), tempLoc.z); + tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); this.setLoc(tempLoc); } } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index d1820480..10f0204f 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -11,8 +11,8 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; @@ -588,7 +588,7 @@ public class City extends AbstractWorldObject { this.setBounds(cityBounds); if (zone.getHeightMap() == null && this.isNpc == 1 && this.getObjectUUID() != 1213) { - HeightMap.GenerateCustomHeightMap(zone); + Terrain.GenerateCustomHeightMap(zone); Logger.info(zone.zoneName + " created custom heightmap"); } } catch (Exception e) { diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index a1381bb8..a063df6f 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -11,9 +11,9 @@ package engine.objects; import engine.Enum; import engine.Enum.*; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.InterestManager; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CharacterRecord; import engine.db.archive.DataWarehouse; @@ -4760,7 +4760,7 @@ public class PlayerCharacter extends AbstractCharacter { // If char is flying they aren't quite swimming try { - float localAltitude = HeightMap.getWorldHeight(currentLoc); + float localAltitude = Terrain.getWorldHeight(currentLoc); Zone zone = ZoneManager.findSmallestZone(currentLoc); @@ -4832,7 +4832,7 @@ public class PlayerCharacter extends AbstractCharacter { } else this.altitude = this.getDesiredAltitude(); - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); this.setTakeOffTime(0); MovementManager.finishChangeAltitude(this, this.getDesiredAltitude()); @@ -4840,7 +4840,7 @@ public class PlayerCharacter extends AbstractCharacter { return; } - this.loc = this.loc.setY(HeightMap.getWorldHeight(this.getLoc()) + this.getAltitude()); + this.loc = this.loc.setY(Terrain.getWorldHeight(this.getLoc()) + this.getAltitude()); } public boolean hasBoon() { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index f2a7f4ee..a951daea 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -10,7 +10,7 @@ package engine.objects; import engine.Enum; -import engine.InterestManagement.HeightMap; +import engine.InterestManagement.Terrain; import engine.db.archive.DataWarehouse; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; @@ -193,15 +193,15 @@ public class Zone extends AbstractGameObject { else bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); - HeightMap heightMap = this.getHeightMap(); + Terrain terrain = this.getHeightMap(); // Set heightmap blending bounds - if (heightMap == null) { + if (terrain == null) { this.blendBounds = bounds; } else { this.blendBounds = Bounds.borrow(); - this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(heightMap.zone_minBlend, heightMap.zone_minBlend), 0.0f); + this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(terrain.zone_minBlend, terrain.zone_minBlend), 0.0f); } } @@ -325,12 +325,12 @@ public class Zone extends AbstractGameObject { // Return heightmap for this Zone. - public HeightMap getHeightMap() { + public Terrain getHeightMap() { if (this.guild_zone) - return HeightMap.PlayerCityHeightMap; + return Terrain.playerCityTerrain; - return HeightMap.heightmapByLoadNum.get(this.template); + return Terrain.heightmapByLoadNum.get(this.template); } } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 9f070596..595d91c8 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -13,8 +13,8 @@ import engine.Enum; import engine.Enum.DispatchChannel; import engine.Enum.MinionType; import engine.Enum.SupportMsgType; -import engine.InterestManagement.HeightMap; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; import engine.db.handlers.dbRuneBaseHandler; @@ -385,7 +385,7 @@ public class WorldServer { Blueprint.loadAllBlueprints(); Logger.info("Initializing Heightmap data"); - HeightMap.loadAlHeightMaps(); + Terrain.loadAlHeightMaps(); Logger.info("Loading Race data"); Enum.RaceType.initRaceTypeTables(); From 5279fa8fbe924c1d3535d032c4f95d047e8138e2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:22:53 -0400 Subject: [PATCH 123/289] Dev command updated --- src/engine/InterestManagement/Terrain.java | 7 ------- src/engine/devcmd/cmds/GetHeightCmd.java | 20 +++----------------- src/engine/objects/Zone.java | 12 ------------ 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index c374839d..63ea58f6 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -55,8 +55,6 @@ public class Terrain { public short[][] pixelColorValues; public int cell_count_x; public int cell_count_y; - public float zone_minBlend; - public float zone_maxBlend; public float terrain_scale; @@ -69,9 +67,6 @@ public class Terrain { this.zoneLoadID = rs.getInt("zoneLoadID"); this.seaLevel = rs.getFloat("seaLevel"); - this.zone_minBlend = rs.getFloat("outsetZ"); - this.zone_maxBlend = rs.getFloat("outsetX"); - // Cache the full extents to avoid the calculation this.fullExtentsX = halfExtentsX * 2; @@ -121,8 +116,6 @@ public class Terrain { int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; this.zoneLoadID = 0; this.seaLevel = 0; - this.zone_minBlend = 0; - this.zone_maxBlend = 0; // Cache the full extents to avoid the calculation diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 642c9533..88810832 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -12,7 +12,6 @@ package engine.devcmd.cmds; import engine.InterestManagement.Terrain; import engine.devcmd.AbstractDevCmd; import engine.gameManager.ZoneManager; -import engine.math.Bounds; import engine.math.Vector2f; import engine.objects.AbstractGameObject; import engine.objects.PlayerCharacter; @@ -44,28 +43,15 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); - this.throwbackInfo(playerCharacter, "Zone Height: " + heightmapZone.worldAltitude); + this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); - this.throwbackInfo(playerCharacter, "Drowning Height: " + (heightmapZone.seaLevel + playerCharacter.getCharacterHeight())); - this.throwbackInfo(playerCharacter, "Grid : " + (int) gridSquare.x + "x" + (int) gridSquare.y); - this.throwbackInfo(playerCharacter, "*** 256: " + currentHeight); - this.throwbackInfo(playerCharacter, "***Adjusted Height: " + (currentHeight + playerCharacter.getCharacterHeight())); + this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); + this.throwbackInfo(playerCharacter, "Height returned: " + currentHeight); this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.zoneName); this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); this.throwbackInfo(playerCharacter, "------------"); - - this.throwbackInfo(playerCharacter, "Min: " + heightmapZone.getHeightMap().zone_minBlend + " Max: " + heightmapZone.getHeightMap().zone_maxBlend); - - - if (Bounds.collide(playerCharacter.getLoc(), heightmapZone.blendBounds)) { - this.throwbackInfo(playerCharacter, "Blend: Max (Child)"); - return; - } - - this.throwbackInfo(playerCharacter, "Blend: Min (LERP)"); - } @Override diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index a951daea..85a6d85b 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -60,7 +60,6 @@ public class Zone extends AbstractGameObject { public float seaLevel = 0f; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; - public Bounds blendBounds; public float major_radius; public float minor_radius; public float min_blend; @@ -193,17 +192,6 @@ public class Zone extends AbstractGameObject { else bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); - Terrain terrain = this.getHeightMap(); - - // Set heightmap blending bounds - - if (terrain == null) { - this.blendBounds = bounds; - } else { - this.blendBounds = Bounds.borrow(); - this.blendBounds.setBounds(new Vector2f(this.absX, this.absZ), bounds.getHalfExtents().subtract(terrain.zone_minBlend, terrain.zone_minBlend), 0.0f); - } - } public void setParent(final Zone value) { From 0ce9ec3ae2ecea2b3b5dbd61c27d4442dcea8ff8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:32:08 -0400 Subject: [PATCH 124/289] Output conforms with client --- src/engine/devcmd/cmds/GetHeightCmd.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 88810832..1d3bc628 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -46,11 +46,11 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); - this.throwbackInfo(playerCharacter, "Height returned: " + currentHeight); + this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Parent : " + parentZone.zoneName); - this.throwbackInfo(playerCharacter, "Height returned : " + parentHeight); + this.throwbackInfo(playerCharacter, "Height returned : " + Math.ceil(parentHeight)); this.throwbackInfo(playerCharacter, "------------"); } From 4b62517d995e491ec87a741642af559a7e827d09 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:49:49 -0400 Subject: [PATCH 125/289] Partial refactor. --- src/engine/InterestManagement/Terrain.java | 262 ++------------------- src/engine/objects/City.java | 5 - src/engine/objects/Zone.java | 2 + src/engine/server/world/WorldServer.java | 12 +- src/engine/util/MapLoader.java | 48 ++++ 5 files changed, 70 insertions(+), 259 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 63ea58f6..73c7aa9e 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -8,185 +8,32 @@ package engine.InterestManagement; -import engine.Enum; -import engine.gameManager.ConfigManager; -import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.Zone; -import org.pmw.tinylog.Logger; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.sql.ResultSet; -import java.sql.SQLException; + import java.util.HashMap; -import java.util.stream.Stream; public class Terrain { // Class variables - public static final HashMap heightmapByLoadNum = new HashMap<>(); - - public static final HashMap _pixelData = new HashMap<>(); + public static final HashMap _heightmap_pixel_cache = new HashMap<>(); - // Bootstrap Tracking - public static int heightMapsCreated = 0; - public static Terrain playerCityTerrain; - // Heightmap data for this heightmap - public final int heightMapID; - public final int maxHeight; - public final int fullExtentsX; - public final int fullExtentsY; - public final int zoneLoadID; - public BufferedImage heightmapImage; - public float cell_size_x; - public float cell_size_y; - public float seaLevel = 0; - public short[][] pixelColorValues; - public int cell_count_x; - public int cell_count_y; + public int template; + public short[][] terrain_pixel_data; + public Vector2f terrain_size = new Vector2f(); + public Vector2f cell_size = new Vector2f(); + public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public Terrain(ResultSet rs) throws SQLException { - - this.heightMapID = rs.getInt("heightMapID"); - this.maxHeight = rs.getInt("maxHeight"); - int halfExtentsX = rs.getInt("xRadius"); - int halfExtentsY = rs.getInt("zRadius"); - this.zoneLoadID = rs.getInt("zoneLoadID"); - this.seaLevel = rs.getFloat("seaLevel"); - - // Cache the full extents to avoid the calculation - - this.fullExtentsX = halfExtentsX * 2; - this.fullExtentsY = halfExtentsY * 2; - - this.heightmapImage = null; - File imageFile = new File(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/" + this.heightMapID + ".bmp"); - - // early exit if no image file was found. Will log in caller. - - if (!imageFile.exists()) - return; - - // load the heightmap image. - - try { - this.heightmapImage = ImageIO.read(imageFile); - } catch (IOException e) { - Logger.error("***Error loading heightmap data for heightmap " + this.heightMapID + e); - } - - // Calculate the data we do not load from table - - this.cell_count_x = this.heightmapImage.getWidth() - 1; - this.cell_size_x = this.fullExtentsX / (float) cell_count_x; - - this.cell_count_y = this.heightmapImage.getHeight() - 1; - this.cell_size_y = this.fullExtentsY / (float) cell_count_y; - - this.terrain_scale = this.maxHeight / 255f; - - // Generate pixel array from image data - - generatePixelData(this); - - Terrain.heightmapByLoadNum.put(this.zoneLoadID, this); - - heightMapsCreated++; - } + public static int heightMapsCreated; - //Created for PlayerCities public Terrain() { - this.heightMapID = 999999; - this.maxHeight = 5; // for real... - int halfExtentsX = (int) Enum.CityBoundsType.ZONE.halfExtents; - int halfExtentsY = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.zoneLoadID = 0; - this.seaLevel = 0; - - // Cache the full extents to avoid the calculation - - this.fullExtentsX = halfExtentsX * 2; - this.fullExtentsY = halfExtentsY * 2; - - this.heightmapImage = null; - - // Calculate the data we do not load from table - - this.cell_size_x = halfExtentsX; - this.cell_size_y = halfExtentsY; - - this.pixelColorValues = new short[this.fullExtentsX][this.fullExtentsY]; - - for (int y = 0; y < this.fullExtentsY; y++) { - for (int x = 0; x < this.fullExtentsX; x++) { - pixelColorValues[x][y] = 255; - } - } - - cell_count_x = this.pixelColorValues.length - 1; - cell_count_y = this.pixelColorValues[0].length - 1; - this.terrain_scale = this.maxHeight / 255f; - } - - public Terrain(Zone zone) { - - this.heightMapID = 999999; - this.maxHeight = 0; - int halfExtentsX = (int) zone.bounds.getHalfExtents().x; - int halfExtentsY = (int) zone.bounds.getHalfExtents().y; - this.zoneLoadID = 0; - this.seaLevel = 0; - - // Cache the full extents to avoid the calculation - - this.fullExtentsX = halfExtentsX * 2; - this.fullExtentsY = halfExtentsY * 2; - - this.heightmapImage = null; - - // Calculate the data we do not load from table - - this.cell_size_x = halfExtentsX; - this.cell_size_y = halfExtentsY; - - this.pixelColorValues = new short[this.fullExtentsX][this.fullExtentsY]; - - for (int y = 0; y < this.fullExtentsY; y++) { - for (int x = 0; x < this.fullExtentsX; x++) { - pixelColorValues[x][y] = 0; - } - } - - cell_count_x = this.pixelColorValues.length - 1; - cell_count_y = this.pixelColorValues[0].length - 1; - this.terrain_scale = this.maxHeight / 255f; - } - - public static void GeneratePlayerCityHeightMap() { - - Terrain.playerCityTerrain = new Terrain(); - - } - - public static void GenerateCustomHeightMap(Zone zone) { - - Terrain heightMap = new Terrain(zone); - - Terrain.heightmapByLoadNum.put(zone.template, heightMap); } @@ -245,91 +92,19 @@ public class Terrain { } - public static void loadAlHeightMaps() { - - // Load the heightmaps into staging hashmap keyed by HashMapID - - DbManager.HeightMapQueries.LOAD_ALL_HEIGHTMAPS(); - - //generate static player city heightmap. - - Terrain.GeneratePlayerCityHeightMap(); - - Logger.info(Terrain.heightmapByLoadNum.size() + " Heightmaps cached."); - - // Load pixel data for heightmaps - - try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { - filePathStream.forEach(filePath -> { - - if (Files.isRegularFile(filePath)) { - File imageFile = filePath.toFile(); - - try { - BufferedImage heightmapImage = ImageIO.read(imageFile); - - // Generate pixel data for this heightmap. RPG channels are all the same - // in this greyscale TGA heightmap. We will choose red. - - short[][] colorData = new short[heightmapImage.getWidth()][heightmapImage.getHeight()]; - - for (int y = 0; y < heightmapImage.getHeight(); y++) - for (int x = 0; x < heightmapImage.getWidth(); x++) { - - Color color = new Color(heightmapImage.getRGB(x, y)); - colorData[x][y] = (short) color.getRed(); - } - - // Insert color data into lookup table - - int heightMapID = Integer.parseInt(imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."))); - _pixelData.put(heightMapID, colorData); - - } catch (IOException e) { - Logger.error(e); - } - - } - }); // Try with resources block - - } catch (IOException e) { - Logger.error(e); - } - - } - - private static void generatePixelData(Terrain terrain) { - - Color color; - - // Generate altitude lookup table for this heightmap - - terrain.pixelColorValues = new short[terrain.heightmapImage.getWidth()][terrain.heightmapImage.getHeight()]; - - for (int y = 0; y < terrain.heightmapImage.getHeight(); y++) { - for (int x = 0; x < terrain.heightmapImage.getWidth(); x++) { - - color = new Color(terrain.heightmapImage.getRGB(x, y)); - terrain.pixelColorValues[x][y] = (short) color.getRed(); - } - } - - } - public Vector2f getTerrainCell(Vector2f terrainLoc) { - float terrainCell_x = terrainLoc.x / this.cell_size_x; - float terrainCell_y = terrainLoc.y / this.cell_size_y; + Vector2f terrain_cell = new Vector2f(terrainLoc.x / this.cell_size.x, terrainLoc.y / this.cell_size.y); // Clamp values when standing directly on max pole - if (terrainCell_x >= this.cell_count_x) - terrainCell_x = terrainCell_x - 1; + if (terrain_cell.x >= this.cell_count.x) + terrain_cell.x = terrain_cell.x - 1; - if (terrainCell_y >= this.cell_count_y) - terrainCell_y = terrainCell_x - 1; + if (terrain_cell.x >= this.cell_count.y) + terrain_cell.y = terrain_cell.y - 1; - return new Vector2f(terrainCell_x, terrainCell_y); + return terrain_cell; } public float getInterpolatedTerrainHeight(Vector2f terrainLoc) { @@ -351,10 +126,10 @@ public class Terrain { float bottomLeftHeight; float bottomRightHeight; - topLeftHeight = pixelColorValues[gridX][gridY]; - topRightHeight = pixelColorValues[gridX + 1][gridY]; - bottomLeftHeight = pixelColorValues[gridX][gridY + 1]; - bottomRightHeight = pixelColorValues[gridX + 1][gridY + 1]; + topLeftHeight = terrain_pixel_data[gridX][gridY]; + topRightHeight = terrain_pixel_data[gridX + 1][gridY]; + bottomLeftHeight = terrain_pixel_data[gridX][gridY + 1]; + bottomRightHeight = terrain_pixel_data[gridX + 1][gridY + 1]; // Interpolate between the 4 vertices @@ -367,5 +142,4 @@ public class Terrain { return interpolatedHeight; } - } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 10f0204f..69ab5aba 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -12,7 +12,6 @@ package engine.objects; import engine.Enum; import engine.Enum.*; import engine.InterestManagement.RealmMap; -import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.CityRecord; import engine.db.archive.DataWarehouse; @@ -587,10 +586,6 @@ public class City extends AbstractWorldObject { 0.0f); this.setBounds(cityBounds); - if (zone.getHeightMap() == null && this.isNpc == 1 && this.getObjectUUID() != 1213) { - Terrain.GenerateCustomHeightMap(zone); - Logger.info(zone.zoneName + " created custom heightmap"); - } } catch (Exception e) { Logger.error(e); } diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 85a6d85b..bbcafdd1 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -70,6 +70,8 @@ public class Zone extends AbstractGameObject { public float terrain_max_y; public int terrain_image; + public Terrain terrain = null; + /** * ResultSet Constructor */ diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 595d91c8..275925d6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -14,7 +14,6 @@ import engine.Enum.DispatchChannel; import engine.Enum.MinionType; import engine.Enum.SupportMsgType; import engine.InterestManagement.RealmMap; -import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; import engine.db.handlers.dbRuneBaseHandler; @@ -39,6 +38,7 @@ import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; import engine.server.MBServerStatics; +import engine.util.MapLoader; import engine.util.ThreadUtils; import engine.workthreads.DisconnectTrashTask; import engine.workthreads.HourlyJobThread; @@ -385,7 +385,7 @@ public class WorldServer { Blueprint.loadAllBlueprints(); Logger.info("Initializing Heightmap data"); - Terrain.loadAlHeightMaps(); + MapLoader.loadAlHeightMaps(); Logger.info("Loading Race data"); Enum.RaceType.initRaceTypeTables(); @@ -466,14 +466,6 @@ public class WorldServer { Logger.info("Starting Mob AI Thread"); MobAIThread.startAIThread(); - for (Zone zone : ZoneManager.getAllZones()) { - if (zone.getHeightMap() != null) { - if (zone.getHeightMap().cell_size_x == 0) { - System.out.println("Zone load num: " + zone.template + " has no bucket width"); - } - } - } - Logger.info("World data loaded."); //set default accesslevel for server *** Refactor who two separate variables? diff --git a/src/engine/util/MapLoader.java b/src/engine/util/MapLoader.java index a8f14ae6..ce187965 100644 --- a/src/engine/util/MapLoader.java +++ b/src/engine/util/MapLoader.java @@ -5,6 +5,7 @@ package engine.util; import engine.InterestManagement.RealmMap; +import engine.InterestManagement.Terrain; import engine.gameManager.ConfigManager; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -14,6 +15,10 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.stream.Stream; public enum MapLoader { @@ -87,4 +92,47 @@ public enum MapLoader { g.dispose(); return dimg; } + + public static void loadAlHeightMaps() { + + // Load pixel data for heightmaps + + try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { + filePathStream.forEach(filePath -> { + + if (Files.isRegularFile(filePath)) { + File imageFile = filePath.toFile(); + + try { + BufferedImage heightmapImage = ImageIO.read(imageFile); + + // Generate pixel data for this heightmap. RPG channels are all the same + // in this greyscale TGA heightmap. We will choose red. + + short[][] colorData = new short[heightmapImage.getWidth()][heightmapImage.getHeight()]; + + for (int y = 0; y < heightmapImage.getHeight(); y++) + for (int x = 0; x < heightmapImage.getWidth(); x++) { + + Color color = new Color(heightmapImage.getRGB(x, y)); + colorData[x][y] = (short) color.getRed(); + } + + // Insert color data into lookup table + + int heightMapID = Integer.parseInt(imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."))); + Terrain._heightmap_pixel_cache.put(heightMapID, colorData); + + } catch (IOException e) { + Logger.error(e); + } + + } + }); // Try with resources block + + } catch (IOException e) { + Logger.error(e); + } + + } } From df54840a88fdb9c1d716840e174f45e59dcd4587 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 09:59:13 -0400 Subject: [PATCH 126/289] Completed partial refactor. --- src/engine/InterestManagement/Terrain.java | 6 +-- .../db/handlers/dbHeightMapHandler.java | 43 ------------------- src/engine/devcmd/cmds/GetHeightCmd.java | 3 +- src/engine/devcmd/cmds/ZoneInfoCmd.java | 9 ++-- src/engine/gameManager/DbManager.java | 1 - src/engine/objects/Zone.java | 37 ++++++++-------- 6 files changed, 27 insertions(+), 72 deletions(-) delete mode 100644 src/engine/db/handlers/dbHeightMapHandler.java diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 73c7aa9e..328ff890 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -41,13 +41,13 @@ public class Terrain { Zone terrain_zone = zone; - if (zone.getHeightMap() != null) + if (zone.terrain != null) return zone; if (zone.equals(ZoneManager.getSeaFloor())) return zone; - while (terrain_zone.getHeightMap() == null) + while (terrain_zone.terrain == null) terrain_zone = terrain_zone.parent; return terrain_zone; @@ -74,7 +74,7 @@ public class Terrain { // Interpolate height for this position using pixel array. - float interpolatedTerrainHeight = terrainZone.getHeightMap().getInterpolatedTerrainHeight(terrainLoc); + float interpolatedTerrainHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedTerrainHeight += terrainZone.worldAltitude; return interpolatedTerrainHeight; diff --git a/src/engine/db/handlers/dbHeightMapHandler.java b/src/engine/db/handlers/dbHeightMapHandler.java deleted file mode 100644 index 87cb9428..00000000 --- a/src/engine/db/handlers/dbHeightMapHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -package engine.db.handlers; - -import engine.InterestManagement.Terrain; -import engine.gameManager.DbManager; -import org.pmw.tinylog.Logger; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class dbHeightMapHandler extends dbHandlerBase { - - public dbHeightMapHandler() { - - - } - - public void LOAD_ALL_HEIGHTMAPS() { - - Terrain thisHeightmap; - Terrain.heightMapsCreated = 0; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_heightmap INNER JOIN static_zone_size ON static_zone_size.loadNum = static_zone_heightmap.zoneLoadID")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - thisHeightmap = new Terrain(rs); - - if (thisHeightmap.heightmapImage == null) { - Logger.info("Imagemap for " + thisHeightmap.heightMapID + " was null"); - continue; - } - } - - } catch (SQLException e) { - Logger.error(e); - } - } - -} diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 1d3bc628..9663c5c6 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -39,7 +39,8 @@ public class GetHeightCmd extends AbstractDevCmd { float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); - Vector2f gridSquare = heightmapZone.getHeightMap().getTerrainCell(zoneLoc); + + Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 2e0292c9..3786d1b4 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -90,14 +90,11 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; output += newline; - if (zone.getHeightMap() != null) { - output += "HeightMap ID: " + zone.getHeightMap().heightMapID; + if (zone.terrain != null) { + output += "Terrain image: " + zone.terrain_image; output += newline; - output += "Bucket Width X : " + zone.getHeightMap().cell_size_x; - output += newline; - output += "Bucket Width Y : " + zone.getHeightMap().cell_size_y; - } + output += "radius: x: " + zone.bounds.getHalfExtents().x + ", z: " + zone.bounds.getHalfExtents().y; output += newline; // output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl(); diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index 92917a35..cbd52a3d 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -70,7 +70,6 @@ public enum DbManager { public static final dbBlueprintHandler BlueprintQueries = new dbBlueprintHandler(); public static final dbBoonHandler BoonQueries = new dbBoonHandler(); public static final dbShrineHandler ShrineQueries = new dbShrineHandler(); - public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler(); public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler(); public static final dbPowerHandler PowerQueries = new dbPowerHandler(); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index bbcafdd1..40212443 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -58,6 +58,7 @@ public class Zone extends AbstractGameObject { public String hash; public float worldAltitude = 0; public float seaLevel = 0f; + public float sea_level_offset = 0; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); public static long lastRespawn = 0; public float major_radius; @@ -224,21 +225,29 @@ public class Zone extends AbstractGameObject { this.setBounds(); this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); + setSeaLevel(); + } + + private void setSeaLevel() { + + int world_sea_level = 0; + if (this.parent == null) { - this.seaLevel = MBServerStatics.SEA_FLOOR_ALTITUDE; + this.sea_level = world_sea_level; return; } - if (this.getHeightMap() == null) { - this.seaLevel = this.parent.seaLevel; - return; + switch (this.sea_level_type) { + case "WORLD": + this.sea_level = world_sea_level + this.sea_level_offset; + break; + case "PARENT": + this.sea_level = this.parent.sea_level + this.sea_level_offset; + break; + case "SELF": + this.sea_level = this.worldAltitude + this.sea_level_offset; + break; } - - if (this.getHeightMap().seaLevel != 0) - this.seaLevel = this.worldAltitude + this.getHeightMap().seaLevel; - else - this.seaLevel = this.parent.seaLevel; - } public boolean isMacroZone() { @@ -315,12 +324,4 @@ public class Zone extends AbstractGameObject { // Return heightmap for this Zone. - public Terrain getHeightMap() { - - if (this.guild_zone) - return Terrain.playerCityTerrain; - - return Terrain.heightmapByLoadNum.get(this.template); - } - } From a0d2ccb5abc4809cb8cdd7fd22d7cc02748cb0dc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 20:26:37 -0400 Subject: [PATCH 127/289] Completed partial refactor. --- src/engine/InterestManagement/Terrain.java | 11 +++++++---- src/engine/objects/Zone.java | 10 +++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 328ff890..463f8fe8 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -20,9 +20,7 @@ public class Terrain { // Class variables public static final HashMap _heightmap_pixel_cache = new HashMap<>(); - - - public int template; + Zone zone; public short[][] terrain_pixel_data; public Vector2f terrain_size = new Vector2f(); @@ -32,7 +30,12 @@ public class Terrain { public static int heightMapsCreated; - public Terrain() { + public Terrain(Zone zone) { + + this.terrain_size.x = zone.major_radius; + this.terrain_size.y = zone.minor_radius; + + this.terrain_pixel_data = } diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 40212443..d32e0338 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -97,7 +97,7 @@ public class Zone extends AbstractGameObject { this.min_blend = rs.getFloat("min_blend"); this.max_blend = rs.getFloat("max_blend"); this.sea_level_type = rs.getString("sea_level_type"); - this.sea_level = rs.getFloat("sea_level"); + this.sea_level_offset = rs.getFloat("sea_level"); this.terrain_type = rs.getString("terrain_type"); this.terrain_max_y = rs.getFloat("terrain_max_y"); this.terrain_image = rs.getInt("terrain_image"); @@ -272,16 +272,15 @@ public class Zone extends AbstractGameObject { } public ArrayList getNodes() { + if (this.nodes == null) { this.nodes = DbManager.ZoneQueries.GET_MAP_NODES(super.getObjectUUID()); //Add reverse lookup for child->parent if (this.nodes != null) - for (Zone zone : this.nodes) { + for (Zone zone : this.nodes) zone.setParent(this); - } } - return nodes; } @@ -312,7 +311,6 @@ public class Zone extends AbstractGameObject { return this.parent.equals(ZoneManager.getSeaFloor()); } - public void setHash() { this.hash = DataWarehouse.hasher.encrypt(this.getObjectUUID()); @@ -322,6 +320,4 @@ public class Zone extends AbstractGameObject { DataWarehouse.writeHash(Enum.DataRecordType.ZONE, this.getObjectUUID()); } - // Return heightmap for this Zone. - } From 79bf0523a5cafcb44c542b906801016c7e5f6016 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 21:50:27 -0400 Subject: [PATCH 128/289] Constructor filled in --- src/engine/InterestManagement/Terrain.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 463f8fe8..be730b55 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -22,7 +22,6 @@ public class Terrain { public static final HashMap _heightmap_pixel_cache = new HashMap<>(); Zone zone; public short[][] terrain_pixel_data; - public Vector2f terrain_size = new Vector2f(); public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); @@ -35,8 +34,15 @@ public class Terrain { this.terrain_size.x = zone.major_radius; this.terrain_size.y = zone.minor_radius; - this.terrain_pixel_data = + this.terrain_pixel_data = _heightmap_pixel_cache.get(zone.terrain_image); + + this.cell_count.x = this.terrain_pixel_data.length - 1; + this.cell_count.y = this.terrain_pixel_data[0].length - 1; + + this.cell_size.x = terrain_size.x / this.cell_count.x; + this.cell_size.y = terrain_size.y / this.cell_count.y; + this.terrain_scale = zone.terrain_max_y / 255f; } From bc099e9dc0e65f6ad9ad0162dccc33677ad23857 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 21:51:16 -0400 Subject: [PATCH 129/289] Constructor filled in --- src/engine/InterestManagement/Terrain.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index be730b55..6e114dc6 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -27,8 +27,6 @@ public class Terrain { public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public static int heightMapsCreated; - public Terrain(Zone zone) { this.terrain_size.x = zone.major_radius; From d31d6c1f958f609c85991af5ec111133971d4721 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 22:36:26 -0400 Subject: [PATCH 130/289] Configure player cities and PLANAR --- src/engine/InterestManagement/Terrain.java | 11 ++++++++++- src/engine/objects/Zone.java | 13 +++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 6e114dc6..c44be525 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -26,13 +26,22 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; + public int template; + public int heightmap; public Terrain(Zone zone) { + this.heightmap = zone.terrain_image; + + // Configure PLANAR + + if (zone.terrain_type.equals("PLANAR")) + this.heightmap = 1006300; + this.terrain_size.x = zone.major_radius; this.terrain_size.y = zone.minor_radius; - this.terrain_pixel_data = _heightmap_pixel_cache.get(zone.terrain_image); + this.terrain_pixel_data = _heightmap_pixel_cache.get(heightmap); this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index d32e0338..52914035 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -102,6 +102,19 @@ public class Zone extends AbstractGameObject { this.terrain_max_y = rs.getFloat("terrain_max_y"); this.terrain_image = rs.getInt("terrain_image"); + if (this.guild_zone) { + this.max_blend = 128; + this.min_blend = 128; + this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.terrain_type = "PLANAR"; + } + + if (this.terrain_type.equals("None")) + this.terrain = null; + else + this.terrain = new Terrain(this); + //this needs to be here specifically for new zones created after server boot (e.g. player city zones) Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); From 02a92569509394f97012fd14e780798b5b07fd96 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 22:40:31 -0400 Subject: [PATCH 131/289] Configure player cities and PLANAR --- src/engine/InterestManagement/Terrain.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index c44be525..ef650d82 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -26,7 +26,6 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public int template; public int heightmap; public Terrain(Zone zone) { @@ -41,7 +40,7 @@ public class Terrain { this.terrain_size.x = zone.major_radius; this.terrain_size.y = zone.minor_radius; - this.terrain_pixel_data = _heightmap_pixel_cache.get(heightmap); + this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap); this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; From 13163ddb7e02628b7894176dd765b2cd7745ae5d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 22:44:34 -0400 Subject: [PATCH 132/289] Error logging added --- src/engine/InterestManagement/Terrain.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index ef650d82..488c97b5 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -12,6 +12,7 @@ import engine.gameManager.ZoneManager; import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.objects.Zone; +import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -42,6 +43,9 @@ public class Terrain { this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap); + if (terrain_pixel_data == null) + Logger.error("Pixel map empty"); + this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; From 59c3bea2d69f5870ff6dea96fab85ebc281e52de Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 22:45:33 -0400 Subject: [PATCH 133/289] Error logging added --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 488c97b5..9901c3df 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -44,7 +44,7 @@ public class Terrain { this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap); if (terrain_pixel_data == null) - Logger.error("Pixel map empty"); + Logger.error("Pixel map empty for zone: " + zone.getObjectUUID() + ":" + zone.zoneName); this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; From bc5d0cc4a96cd444a14b56d0e40ecf08342ac6d8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 22:49:13 -0400 Subject: [PATCH 134/289] Terrain zone set in constructor --- src/engine/InterestManagement/Terrain.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9901c3df..64144736 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -31,15 +31,17 @@ public class Terrain { public Terrain(Zone zone) { - this.heightmap = zone.terrain_image; + this.zone = zone; + + this.heightmap = this.zone.terrain_image; // Configure PLANAR - if (zone.terrain_type.equals("PLANAR")) + if (this.zone.terrain_type.equals("PLANAR")) this.heightmap = 1006300; - this.terrain_size.x = zone.major_radius; - this.terrain_size.y = zone.minor_radius; + this.terrain_size.x = this.zone.major_radius; + this.terrain_size.y = this.zone.minor_radius; this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap); @@ -52,7 +54,7 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; - this.terrain_scale = zone.terrain_max_y / 255f; + this.terrain_scale = this.zone.terrain_max_y / 255f; } From 0d58aee2fe9b15306db54e16d69fdc84d5ce3e49 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 22:54:40 -0400 Subject: [PATCH 135/289] Terrain type is capitalized --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 52914035..a14a4dc4 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -110,7 +110,7 @@ public class Zone extends AbstractGameObject { this.terrain_type = "PLANAR"; } - if (this.terrain_type.equals("None")) + if (this.terrain_type.equals("NONE")) this.terrain = null; else this.terrain = new Terrain(this); From a3d29bb8f09d68759eba0ecd1a1eab292036fb67 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 23:05:41 -0400 Subject: [PATCH 136/289] Error trap --- src/engine/objects/Zone.java | 102 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index a14a4dc4..015d5854 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -77,63 +77,69 @@ public class Zone extends AbstractGameObject { * ResultSet Constructor */ public Zone(ResultSet rs) throws SQLException { - super(rs); - this.parentZoneID = rs.getInt("parent"); - this.playerCityUUID = rs.getInt("playerCityUUID"); - this.guild_zone = this.playerCityUUID != 0; - this.zoneName = rs.getString("zone_name"); - this.xOffset = rs.getFloat("xOffset"); - this.zOffset = rs.getFloat("zOffset"); - this.yOffset = rs.getFloat("yOffset"); - this.template = rs.getInt("template"); - this.peace_zone = rs.getByte("peace_zone"); - this.icon1 = rs.getString("icon1"); - this.icon2 = rs.getString("icon2"); - this.icon3 = rs.getString("icon3"); - this.min_level = rs.getInt("min_level"); - this.max_level = rs.getInt("max_level"); - this.major_radius = rs.getFloat("major_radius"); - this.minor_radius = rs.getFloat("minor_radius"); - this.min_blend = rs.getFloat("min_blend"); - this.max_blend = rs.getFloat("max_blend"); - this.sea_level_type = rs.getString("sea_level_type"); - this.sea_level_offset = rs.getFloat("sea_level"); - this.terrain_type = rs.getString("terrain_type"); - this.terrain_max_y = rs.getFloat("terrain_max_y"); - this.terrain_image = rs.getInt("terrain_image"); - - if (this.guild_zone) { - this.max_blend = 128; - this.min_blend = 128; - this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.terrain_type = "PLANAR"; - } - - if (this.terrain_type.equals("NONE")) - this.terrain = null; - else - this.terrain = new Terrain(this); - //this needs to be here specifically for new zones created after server boot (e.g. player city zones) - - Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); - this.setParent(parentZone); + super(rs); - if (this.min_level == 0 && parentZone != null) { - this.min_level = parentZone.min_level; - this.max_level = parentZone.max_level; + try { + this.parentZoneID = rs.getInt("parent"); + this.playerCityUUID = rs.getInt("playerCityUUID"); + this.guild_zone = this.playerCityUUID != 0; + this.zoneName = rs.getString("zone_name"); + this.xOffset = rs.getFloat("xOffset"); + this.zOffset = rs.getFloat("zOffset"); + this.yOffset = rs.getFloat("yOffset"); + this.template = rs.getInt("template"); + this.peace_zone = rs.getByte("peace_zone"); + this.icon1 = rs.getString("icon1"); + this.icon2 = rs.getString("icon2"); + this.icon3 = rs.getString("icon3"); + this.min_level = rs.getInt("min_level"); + this.max_level = rs.getInt("max_level"); + this.major_radius = rs.getFloat("major_radius"); + this.minor_radius = rs.getFloat("minor_radius"); + this.min_blend = rs.getFloat("min_blend"); + this.max_blend = rs.getFloat("max_blend"); + this.sea_level_type = rs.getString("sea_level_type"); + this.sea_level_offset = rs.getFloat("sea_level"); + this.terrain_type = rs.getString("terrain_type"); + this.terrain_max_y = rs.getFloat("terrain_max_y"); + this.terrain_image = rs.getInt("terrain_image"); + + if (this.guild_zone) { + this.max_blend = 128; + this.min_blend = 128; + this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.terrain_type = "PLANAR"; + } + + if (this.terrain_type.equals("NONE")) + this.terrain = null; + else + this.terrain = new Terrain(this); + + //this needs to be here specifically for new zones created after server boot (e.g. player city zones) + + Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); + this.setParent(parentZone); + + if (this.min_level == 0 && parentZone != null) { + this.min_level = parentZone.min_level; + this.max_level = parentZone.max_level; + } + + if (parentZone != null) + parentZone.addNode(this); + } catch (Exception e) { + Logger.error(e); + throw new RuntimeException(e); } - if (parentZone != null) - parentZone.addNode(this); - // If zone doesn't yet hava a hash then write it back to the zone table if (hash == null) setHash(); - } public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { From 4bbbbf9fa20a1df985b5f187dea2c189f105c726 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 8 Oct 2023 23:11:59 -0400 Subject: [PATCH 137/289] Error trap --- src/engine/objects/Zone.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 015d5854..49c8cc01 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -80,7 +80,6 @@ public class Zone extends AbstractGameObject { super(rs); - try { this.parentZoneID = rs.getInt("parent"); this.playerCityUUID = rs.getInt("playerCityUUID"); this.guild_zone = this.playerCityUUID != 0; @@ -130,10 +129,6 @@ public class Zone extends AbstractGameObject { if (parentZone != null) parentZone.addNode(this); - } catch (Exception e) { - Logger.error(e); - throw new RuntimeException(e); - } // If zone doesn't yet hava a hash then write it back to the zone table From d6d4008348e3072e5de52bad16adcaa2d8847279 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 04:11:55 -0400 Subject: [PATCH 138/289] Error trap --- src/engine/objects/Zone.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 49c8cc01..b4e69507 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -237,7 +237,12 @@ public class Zone extends AbstractGameObject { } this.setBounds(); - this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); + + try { + this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); + } catch (Exception e) { + throw new RuntimeException(e); + } setSeaLevel(); } From cd1de763e3ca33b7aeb4d07b94a95fecefe25614 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 04:14:51 -0400 Subject: [PATCH 139/289] Terrain size set by zone radius --- src/engine/InterestManagement/Terrain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 64144736..9a728e0c 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -40,8 +40,8 @@ public class Terrain { if (this.zone.terrain_type.equals("PLANAR")) this.heightmap = 1006300; - this.terrain_size.x = this.zone.major_radius; - this.terrain_size.y = this.zone.minor_radius; + this.terrain_size.x = this.zone.major_radius * 2; + this.terrain_size.y = this.zone.minor_radius * 2; this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap); From 07f736b8e6d08c803fd77c5d8db6800021066b87 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 04:32:57 -0400 Subject: [PATCH 140/289] WorldAltitude for seafloor set --- src/engine/gameManager/ZoneManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 25b3e2b7..cc92ac21 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -458,7 +458,7 @@ public enum ZoneManager { // Seafloor - if (zone.parent == null) + if (ZoneManager.seaFloor.equals(zone)) return worldAlttitude; // Children of seafloor From 483ccbff00984a73e394410d16bc87ac553046b3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 04:37:54 -0400 Subject: [PATCH 141/289] WorldAltitude for seafloor set --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9a728e0c..d5e6bf37 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -81,7 +81,7 @@ public class Terrain { // Seafloor is rather flat. if (currentZone == ZoneManager.getSeaFloor()) - return currentZone.worldAltitude; + return currentZone.yOffset; // Retrieve the next zone with a heightmap attached. // Zones without a heightmap use the next zone up the From ef8754c0180ce59660c68ae4cffce9c40dd6f6e4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 04:48:22 -0400 Subject: [PATCH 142/289] WorldAltitude for seafloor set --- src/engine/InterestManagement/Terrain.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index d5e6bf37..403179b9 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -78,11 +78,6 @@ public class Terrain { Zone terrainZone; - // Seafloor is rather flat. - - if (currentZone == ZoneManager.getSeaFloor()) - return currentZone.yOffset; - // Retrieve the next zone with a heightmap attached. // Zones without a heightmap use the next zone up the // tree to calculate heights from. From fe8d5125963ca28bc71dfa09d7f6b7d4e0603d66 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 04:51:50 -0400 Subject: [PATCH 143/289] WorldAltitude for seafloor set --- src/engine/gameManager/ZoneManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index cc92ac21..e4a0c7b9 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -474,6 +474,11 @@ public enum ZoneManager { worldAlttitude += zone.yOffset; + // Player cities have platform + + if (zone.guild_zone) + worldAlttitude += 5; + return worldAlttitude; } From 73b6854266aba96ebdcf8a9417aafaf55e7e0b42 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 05:44:38 -0400 Subject: [PATCH 144/289] Map loaded updated --- src/engine/util/MapLoader.java | 37 ++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/engine/util/MapLoader.java b/src/engine/util/MapLoader.java index ce187965..779080bd 100644 --- a/src/engine/util/MapLoader.java +++ b/src/engine/util/MapLoader.java @@ -103,31 +103,38 @@ public enum MapLoader { if (Files.isRegularFile(filePath)) { File imageFile = filePath.toFile(); + BufferedImage heightmapImage; + try { - BufferedImage heightmapImage = ImageIO.read(imageFile); + heightmapImage = ImageIO.read(imageFile); + } catch (IOException e) { + throw new RuntimeException(e); + } - // Generate pixel data for this heightmap. RPG channels are all the same - // in this greyscale TGA heightmap. We will choose red. + int fileName = Integer.parseInt(imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."))); + boolean singleBandRaster = heightmapImage.getRaster().getNumBands() == 1; + int color; - short[][] colorData = new short[heightmapImage.getWidth()][heightmapImage.getHeight()]; + // Generate pixel data for this heightmap. - for (int y = 0; y < heightmapImage.getHeight(); y++) - for (int x = 0; x < heightmapImage.getWidth(); x++) { + short[][] colorData = new short[heightmapImage.getWidth()][heightmapImage.getHeight()]; - Color color = new Color(heightmapImage.getRGB(x, y)); - colorData[x][y] = (short) color.getRed(); - } + for (int y = 0; y < heightmapImage.getHeight(); y++) + for (int x = 0; x < heightmapImage.getWidth(); x++) { - // Insert color data into lookup table + if (singleBandRaster) + color = heightmapImage.getRaster().getSample(x, y, 0); + else + color = new Color(heightmapImage.getRGB(x, y)).getRed(); - int heightMapID = Integer.parseInt(imageFile.getName().substring(0, imageFile.getName().lastIndexOf("."))); - Terrain._heightmap_pixel_cache.put(heightMapID, colorData); + colorData[x][y] = (short) color; + } - } catch (IOException e) { - Logger.error(e); - } + // Add pixel for this TGA image into the collection + Terrain._heightmap_pixel_cache.put(fileName, colorData); } + }); // Try with resources block } catch (IOException e) { From a17b9fdd13fb5bdb901874a1a206f9107436c260 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 06:04:37 -0400 Subject: [PATCH 145/289] Zone extents derived from zone --- src/engine/db/handlers/dbZoneHandler.java | 22 ---------------------- src/engine/gameManager/ZoneManager.java | 19 +++++++++++-------- src/engine/objects/Zone.java | 10 +--------- src/engine/server/world/WorldServer.java | 3 --- 4 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index b782ad38..9cceccaa 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -11,8 +11,6 @@ package engine.db.handlers; import engine.Enum; import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; -import engine.math.Vector2f; import engine.objects.Zone; import org.pmw.tinylog.Logger; @@ -91,26 +89,6 @@ public class dbZoneHandler extends dbHandlerBase { return zoneList; } - public void LOAD_ZONE_EXTENTS() { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_zone_size`;")) { - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - Vector2f zoneSize = new Vector2f(); - int loadNum = rs.getInt("loadNum"); - zoneSize.x = rs.getFloat("xRadius"); - zoneSize.y = rs.getFloat("zRadius"); - ZoneManager._zone_size_data.put(loadNum, zoneSize); - } - - } catch (SQLException e) { - Logger.error(e); - } - } - public boolean DELETE_ZONE(final Zone zone) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index e4a0c7b9..32f463fc 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -25,7 +25,10 @@ import org.pmw.tinylog.Logger; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -46,7 +49,7 @@ public enum ZoneManager { public static Instant hotZoneLastUpdate; public static Zone hotZone = null; public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config. - public static HashMap _zone_size_data = new HashMap<>(); + /* Instance variables */ private static Zone seaFloor = null; @@ -71,7 +74,7 @@ public enum ZoneManager { // Find smallest zone coordinates fit into. - public static final Zone findSmallestZone(final Vector3fImmutable loc) { + public static Zone findSmallestZone(final Vector3fImmutable loc) { Zone zone = ZoneManager.seaFloor; @@ -90,7 +93,7 @@ public enum ZoneManager { if (nodes != null) for (Zone child : nodes) { - if (Bounds.collide(loc, child.bounds) == true) { + if (Bounds.collide(loc, child.bounds)) { zone = child; childFound = true; break; @@ -148,11 +151,11 @@ public enum ZoneManager { return ZoneManager.zonesByName.get(zoneName); } - public static final Collection getAllZones() { + public static Collection getAllZones() { return ZoneManager.zonesByUUID.values(); } - public static final void setHotZone(final Zone zone) { + public static void setHotZone(final Zone zone) { if (!zone.isMacroZone()) return; @@ -169,7 +172,7 @@ public enum ZoneManager { if (ZoneManager.hotZone == null) return false; - return (Bounds.collide(loc, ZoneManager.hotZone.bounds) == true); + return (Bounds.collide(loc, ZoneManager.hotZone.bounds)); } public static Zone getSeaFloor() { @@ -180,7 +183,7 @@ public enum ZoneManager { ZoneManager.seaFloor = value; } - public static final void populateWorldZones(final Zone zone) { + public static void populateWorldZones(final Zone zone) { int loadNum = zone.template; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index b4e69507..76ac747c 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -199,15 +199,7 @@ public class Zone extends AbstractGameObject { // Set initial bounds object this.bounds = Bounds.borrow(); - - Vector2f zoneSize = ZoneManager._zone_size_data.get(this.template); - - // Default to player zone size on error? Maybe log this - - if (zoneSize != null) - this.bounds.setBounds(new Vector2f(this.absX, this.absZ), zoneSize, 0.0f); - else - bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents), 0.0f); + this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f); } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 275925d6..66088b8b 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -360,9 +360,6 @@ public class WorldServer { Logger.info("Loading item enchants"); DbManager.LootQueries.LOAD_ENCHANT_VALUES(); - Logger.info("Loading zone extent cache"); - DbManager.ZoneQueries.LOAD_ZONE_EXTENTS(); - Logger.info("Loading Realms"); Realm.loadAllRealms(); From 085f79cefd4eeb34f717ced51e6ad362a5f8d104 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 06:14:06 -0400 Subject: [PATCH 146/289] Sanity check added --- src/engine/InterestManagement/Terrain.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 403179b9..9fed2cd9 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -62,6 +62,9 @@ public class Terrain { Zone terrain_zone = zone; + if (zone == null) + return ZoneManager.getSeaFloor(); + if (zone.terrain != null) return zone; From 95558371df589649b347e8e46d9cf07a35988332 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 06:16:25 -0400 Subject: [PATCH 147/289] Method inlined --- src/engine/InterestManagement/Terrain.java | 4 ++-- src/engine/gameManager/ZoneManager.java | 6 +----- src/engine/mobileAI/MobAI.java | 2 +- src/engine/net/client/msg/WorldDataMsg.java | 2 +- src/engine/objects/Mob.java | 2 +- src/engine/objects/Zone.java | 4 ++-- src/engine/powers/poweractions/CreateMobPowerAction.java | 2 +- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9fed2cd9..e2e5f38e 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -63,12 +63,12 @@ public class Terrain { Zone terrain_zone = zone; if (zone == null) - return ZoneManager.getSeaFloor(); + return ZoneManager.seaFloor; if (zone.terrain != null) return zone; - if (zone.equals(ZoneManager.getSeaFloor())) + if (zone.equals(ZoneManager.seaFloor)) return zone; while (terrain_zone.terrain == null) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 32f463fc..cf1594d2 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -51,7 +51,7 @@ public enum ZoneManager { public static int hotZoneCycle = 0; // Used with HOTZONE_DURATION from config. /* Instance variables */ - private static Zone seaFloor = null; + public static Zone seaFloor = null; // Find all zones coordinates fit into, starting with Sea Floor @@ -175,10 +175,6 @@ public enum ZoneManager { return (Bounds.collide(loc, ZoneManager.hotZone.bounds)); } - public static Zone getSeaFloor() { - return ZoneManager.seaFloor; - } - public static void setSeaFloor(final Zone value) { ZoneManager.seaFloor = value; } diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 10696af9..38864cac 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -991,7 +991,7 @@ public class MobAI { try { if (mob.guardCaptain == null && mob.isNecroPet() == false && mob.isSiege() == false) - if (ZoneManager.getSeaFloor().zoneMobSet.contains(mob)) + if (ZoneManager.seaFloor.zoneMobSet.contains(mob)) mob.killCharacter("no owner"); if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index 2db0ee11..d18178e7 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -73,7 +73,7 @@ public class WorldDataMsg extends ClientNetMsg { // TODO replace this return with SerializationException - Zone root = ZoneManager.getSeaFloor(); + Zone root = ZoneManager.seaFloor; if (root == null) { Logger.error("Failed to find Sea Floor!"); return; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 532a6aeb..222485d5 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -897,7 +897,7 @@ public class Mob extends AbstractIntelligenceAgent { this.setCombatTarget(null); this.hasLoot = false; - ZoneManager.getSeaFloor().zoneMobSet.remove(this); + ZoneManager.seaFloor.zoneMobSet.remove(this); try { this.clearEffects(); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 76ac747c..ee1db826 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -310,7 +310,7 @@ public class Zone extends AbstractGameObject { public boolean isContinent() { - if (this.equals(ZoneManager.getSeaFloor())) + if (this.equals(ZoneManager.seaFloor)) return false; if (this.getNodes().isEmpty()) @@ -319,7 +319,7 @@ public class Zone extends AbstractGameObject { if (this.getNodes().get(0).isMacroZone()) return true; - return this.parent.equals(ZoneManager.getSeaFloor()); + return this.parent.equals(ZoneManager.seaFloor); } public void setHash() { diff --git a/src/engine/powers/poweractions/CreateMobPowerAction.java b/src/engine/powers/poweractions/CreateMobPowerAction.java index 41c7e810..a0ec17e9 100644 --- a/src/engine/powers/poweractions/CreateMobPowerAction.java +++ b/src/engine/powers/poweractions/CreateMobPowerAction.java @@ -56,7 +56,7 @@ public class CreateMobPowerAction extends AbstractPowerAction { PlayerCharacter owner = (PlayerCharacter) source; Mob currentPet = owner.getPet(); - Zone seaFloor = ZoneManager.getSeaFloor(); + Zone seaFloor = ZoneManager.seaFloor; Guild guild = Guild.getErrantGuild(); ClientConnection origin = owner.getClientConnection(); From e80dd66809b9429099929ed31bd64014859725f5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 06:20:17 -0400 Subject: [PATCH 148/289] Interpolation cleanup --- src/engine/InterestManagement/Terrain.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index e2e5f38e..cd5423d7 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -152,10 +152,10 @@ public class Terrain { // Interpolate between the 4 vertices - interpolatedHeight = topRightHeight * (1 - offsetY) * (offsetX); - interpolatedHeight += (bottomRightHeight * offsetY * offsetX); + interpolatedHeight = topLeftHeight * (1 - offsetX) * (1 - offsetY); + interpolatedHeight += topRightHeight * (1 - offsetY) * (offsetX); interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); - interpolatedHeight += (topLeftHeight * (1 - offsetX) * (1 - offsetY)); + interpolatedHeight += (bottomRightHeight * offsetY * offsetX); interpolatedHeight *= this.terrain_scale; // Scale height From c90a250ba7fd3af68e672164e717e17751733c60 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 07:05:54 -0400 Subject: [PATCH 149/289] Blend function installed --- src/engine/InterestManagement/Terrain.java | 66 +++++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index cd5423d7..21ea9849 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -16,18 +16,22 @@ import org.pmw.tinylog.Logger; import java.util.HashMap; +import static java.lang.Math.PI; + public class Terrain { // Class variables public static final HashMap _heightmap_pixel_cache = new HashMap<>(); - Zone zone; public short[][] terrain_pixel_data; public Vector2f terrain_size = new Vector2f(); public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; + public float min_blend; + public float max_blend; public int heightmap; + Zone zone; public Terrain(Zone zone) { @@ -54,6 +58,9 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; + this.max_blend = this.zone.max_blend / this.zone.major_radius; + this.min_blend = this.zone.min_blend / this.zone.minor_radius; + this.terrain_scale = this.zone.terrain_max_y / 255f; } @@ -80,22 +87,34 @@ public class Terrain { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { Zone terrainZone; + Zone parentZone; // Retrieve the next zone with a heightmap attached. // Zones without a heightmap use the next zone up the // tree to calculate heights from. terrainZone = getNextZoneWithTerrain(currentZone); + parentZone = getNextZoneWithTerrain(currentZone.parent); // Transform world loc into zone space coordinate system Vector2f terrainLoc = ZoneManager.worldToZoneSpace(worldLoc, terrainZone); + Vector2f parentLoc = ZoneManager.worldToZoneSpace(worldLoc, parentZone); - // Interpolate height for this position using pixel array. + // Interpolate height for this position in terrain float interpolatedTerrainHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedTerrainHeight += terrainZone.worldAltitude; + // Interpolate height for this position in parent + + float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc); + interpolatedParentTerrainHeight += parentZone.worldAltitude; + + // Blend between heights + + interpolatedTerrainHeight = interpolatedTerrainHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.heightBlend(terrainLoc)); + return interpolatedTerrainHeight; } @@ -161,4 +180,47 @@ public class Terrain { return interpolatedHeight; } + + public float heightBlend(Vector2f terrainLoc) { + + // Normalize terrain loc + + Vector2f normalizedLoc = new Vector2f(terrainLoc.x / this.terrain_size.x, + terrainLoc.y / terrain_size.y); + + float minp = this.zone.min_blend / this.zone.major_radius; + float maxp = this.zone.max_blend / this.zone.major_radius; + + float xval; + + if (minp > 0.4f) + xval = minp; + else + xval = Math.min(maxp, 0.4f); + + float minpy = this.zone.min_blend / this.zone.minor_radius; + float maxpy = this.zone.max_blend / this.zone.minor_radius; + + float yval; + + if (minpy > 0.4f) + yval = minpy; + else + yval = Math.min(maxpy, 0.4f); + + float value; + + if (normalizedLoc.x <= 1 - xval || normalizedLoc.x <= normalizedLoc.y) { + + if (normalizedLoc.x < 1 - yval) + return 1; + + value = (normalizedLoc.y - (1 - yval)) / yval; + } else + value = (normalizedLoc.x - (1 - xval)) / xval; + + value = (float) Math.atan((0.5f - value) * PI); + + return (value + 1) * 0.5f; + } } From 53f7165e24dcd4c0b4f486e62016514dcd25164c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 07:47:50 -0400 Subject: [PATCH 150/289] Blend function installed --- src/engine/InterestManagement/Terrain.java | 8 +++----- src/engine/objects/Zone.java | 8 +------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 21ea9849..254cb398 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -103,8 +103,8 @@ public class Terrain { // Interpolate height for this position in terrain - float interpolatedTerrainHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); - interpolatedTerrainHeight += terrainZone.worldAltitude; + float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); + interpolatedChildHeight += terrainZone.worldAltitude; // Interpolate height for this position in parent @@ -113,9 +113,7 @@ public class Terrain { // Blend between heights - interpolatedTerrainHeight = interpolatedTerrainHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.heightBlend(terrainLoc)); - - return interpolatedTerrainHeight; + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - parentZone.terrain.heightBlend(parentLoc)); } diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index ee1db826..dfb78c6a 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -229,13 +229,7 @@ public class Zone extends AbstractGameObject { } this.setBounds(); - - try { - this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); - } catch (Exception e) { - throw new RuntimeException(e); - } - + this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); setSeaLevel(); } From d2dc95c169a9688496698b56288a75f2ebc66ceb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 08:44:06 -0400 Subject: [PATCH 151/289] Dev command updated --- src/engine/InterestManagement/Terrain.java | 2 +- src/engine/devcmd/cmds/GetHeightCmd.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 254cb398..b9e4570c 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -113,7 +113,7 @@ public class Terrain { // Blend between heights - return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - parentZone.terrain.heightBlend(parentLoc)); + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.heightBlend(terrainLoc)); } diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 9663c5c6..3e7fde23 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -47,6 +47,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); + this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.heightBlend(zoneLoc)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); this.throwbackInfo(playerCharacter, "------------"); From dd01fd168879ecfe1894e47a8e1c90005be87d43 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 09:22:41 -0400 Subject: [PATCH 152/289] Proper setting of maxpy --- src/engine/InterestManagement/Terrain.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index b9e4570c..5ba97c6b 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -196,8 +196,8 @@ public class Terrain { else xval = Math.min(maxp, 0.4f); + float maxpy = this.zone.max_blend / this.zone.major_radius; float minpy = this.zone.min_blend / this.zone.minor_radius; - float maxpy = this.zone.max_blend / this.zone.minor_radius; float yval; @@ -208,9 +208,9 @@ public class Terrain { float value; - if (normalizedLoc.x <= 1 - xval || normalizedLoc.x <= normalizedLoc.y) { + if (normalizedLoc.x <= 1 - xval || normalizedLoc.y <= 1 - yval) { - if (normalizedLoc.x < 1 - yval) + if (normalizedLoc.x < 1 - xval) return 1; value = (normalizedLoc.y - (1 - yval)) / yval; From a0c82d3f3f8fd8a2fba2660a9725cbd66cbce917 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 09:32:20 -0400 Subject: [PATCH 153/289] Blend cleanup --- src/engine/InterestManagement/Terrain.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 5ba97c6b..c289ce8f 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -189,6 +189,9 @@ public class Terrain { float minp = this.zone.min_blend / this.zone.major_radius; float maxp = this.zone.max_blend / this.zone.major_radius; + float minpy = this.zone.min_blend / this.zone.minor_radius; + float maxpy = this.zone.max_blend / this.zone.minor_radius; + float xval; if (minp > 0.4f) @@ -196,9 +199,6 @@ public class Terrain { else xval = Math.min(maxp, 0.4f); - float maxpy = this.zone.max_blend / this.zone.major_radius; - float minpy = this.zone.min_blend / this.zone.minor_radius; - float yval; if (minpy > 0.4f) From f7952008cd9044fa1012956fe460fb845474f70c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 09:35:24 -0400 Subject: [PATCH 154/289] Blend cleanup --- src/engine/InterestManagement/Terrain.java | 4 ++-- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index c289ce8f..55aaa925 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -113,7 +113,7 @@ public class Terrain { // Blend between heights - return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.heightBlend(terrainLoc)); + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainLoc)); } @@ -179,7 +179,7 @@ public class Terrain { return interpolatedHeight; } - public float heightBlend(Vector2f terrainLoc) { + public float terrainBlend(Vector2f terrainLoc) { // Normalize terrain loc diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 3e7fde23..8849802a 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -47,7 +47,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); - this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.heightBlend(zoneLoc)); + this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneLoc)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); this.throwbackInfo(playerCharacter, "------------"); From bd208bd1ab7345bdfc9922dba56fc9b53d85d84d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 09:45:04 -0400 Subject: [PATCH 155/289] Blend cleanup --- src/engine/InterestManagement/Terrain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 55aaa925..9721afac 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -208,9 +208,9 @@ public class Terrain { float value; - if (normalizedLoc.x <= 1 - xval || normalizedLoc.y <= 1 - yval) { + if (normalizedLoc.x <= 1 - xval || normalizedLoc.x <= normalizedLoc.y) { - if (normalizedLoc.x < 1 - xval) + if (normalizedLoc.y < 1 - yval) return 1; value = (normalizedLoc.y - (1 - yval)) / yval; From 52b66be43b4ea7a66c057bdb956a62af9586c2e7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 10:47:48 -0400 Subject: [PATCH 156/289] Blend cleanup --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9721afac..4872e3fe 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -113,7 +113,7 @@ public class Terrain { // Blend between heights - return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainLoc)); + return interpolatedChildHeight + parentZone.worldAltitude * (1 - terrainZone.terrain.terrainBlend(terrainLoc)); } From f73184ac1ef72ef7132a15df4810440434ec5d93 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 9 Oct 2023 10:56:39 -0400 Subject: [PATCH 157/289] Blend cleanup --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 4872e3fe..9721afac 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -113,7 +113,7 @@ public class Terrain { // Blend between heights - return interpolatedChildHeight + parentZone.worldAltitude * (1 - terrainZone.terrain.terrainBlend(terrainLoc)); + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainLoc)); } From 0afc8a2dc5858af6ba0912d646aece712770c6d9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 10 Oct 2023 07:59:42 -0400 Subject: [PATCH 158/289] Platform update --- src/engine/InterestManagement/Terrain.java | 5 +++++ src/engine/gameManager/ZoneManager.java | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9721afac..6c39bf7b 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -106,6 +106,11 @@ public class Terrain { float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedChildHeight += terrainZone.worldAltitude; + // Player cities have platform + + if (terrainZone.guild_zone) + interpolatedChildHeight += 5; + // Interpolate height for this position in parent float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index cf1594d2..008ddc03 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -473,11 +473,6 @@ public enum ZoneManager { worldAlttitude += zone.yOffset; - // Player cities have platform - - if (zone.guild_zone) - worldAlttitude += 5; - return worldAlttitude; } From 859de1004ee68dd4d7ee1cd3a31da18a657387a6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 10 Oct 2023 12:31:43 -0400 Subject: [PATCH 159/289] Platform revert --- src/engine/InterestManagement/Terrain.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 6c39bf7b..9721afac 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -106,11 +106,6 @@ public class Terrain { float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedChildHeight += terrainZone.worldAltitude; - // Player cities have platform - - if (terrainZone.guild_zone) - interpolatedChildHeight += 5; - // Interpolate height for this position in parent float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc); From 6494e07e9ea245fe4a1b1d3cd82f4dc44cf6c007 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 10 Oct 2023 12:34:21 -0400 Subject: [PATCH 160/289] Test baseline --- src/engine/InterestManagement/Terrain.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9721afac..7e053288 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -99,22 +99,13 @@ public class Terrain { // Transform world loc into zone space coordinate system Vector2f terrainLoc = ZoneManager.worldToZoneSpace(worldLoc, terrainZone); - Vector2f parentLoc = ZoneManager.worldToZoneSpace(worldLoc, parentZone); // Interpolate height for this position in terrain float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedChildHeight += terrainZone.worldAltitude; - // Interpolate height for this position in parent - - float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc); - interpolatedParentTerrainHeight += parentZone.worldAltitude; - - // Blend between heights - - return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainLoc)); - + return interpolatedChildHeight; } public static float getWorldHeight(Vector3fImmutable worldLoc) { From 68aef50283b4721e70598e399956600f14c6db4e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 10:40:27 -0400 Subject: [PATCH 161/289] Debug code added --- src/engine/InterestManagement/Terrain.java | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 7e053288..327fc06c 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -136,38 +136,42 @@ public class Terrain { public float getInterpolatedTerrainHeight(Vector2f terrainLoc) { - float interpolatedHeight; + try { + float interpolatedHeight; - Vector2f terrain_cell = getTerrainCell(terrainLoc); + Vector2f terrain_cell = getTerrainCell(terrainLoc); - int gridX = (int) Math.floor(terrain_cell.x); - int gridY = (int) Math.floor(terrain_cell.y); + int gridX = (int) Math.floor(terrain_cell.x); + int gridY = (int) Math.floor(terrain_cell.y); - float offsetX = terrain_cell.x % 1; - float offsetY = terrain_cell.y % 1; + float offsetX = terrain_cell.x % 1; + float offsetY = terrain_cell.y % 1; - //get 4 surrounding vertices from the pixel array. + //get 4 surrounding vertices from the pixel array. - float topLeftHeight; - float topRightHeight; - float bottomLeftHeight; - float bottomRightHeight; + float topLeftHeight; + float topRightHeight; + float bottomLeftHeight; + float bottomRightHeight; - topLeftHeight = terrain_pixel_data[gridX][gridY]; - topRightHeight = terrain_pixel_data[gridX + 1][gridY]; - bottomLeftHeight = terrain_pixel_data[gridX][gridY + 1]; - bottomRightHeight = terrain_pixel_data[gridX + 1][gridY + 1]; + topLeftHeight = terrain_pixel_data[gridX][gridY]; + topRightHeight = terrain_pixel_data[gridX + 1][gridY]; + bottomLeftHeight = terrain_pixel_data[gridX][gridY + 1]; + bottomRightHeight = terrain_pixel_data[gridX + 1][gridY + 1]; - // Interpolate between the 4 vertices + // Interpolate between the 4 vertices - interpolatedHeight = topLeftHeight * (1 - offsetX) * (1 - offsetY); - interpolatedHeight += topRightHeight * (1 - offsetY) * (offsetX); - interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); - interpolatedHeight += (bottomRightHeight * offsetY * offsetX); + interpolatedHeight = topLeftHeight * (1 - offsetX) * (1 - offsetY); + interpolatedHeight += topRightHeight * (1 - offsetY) * (offsetX); + interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); + interpolatedHeight += (bottomRightHeight * offsetY * offsetX); - interpolatedHeight *= this.terrain_scale; // Scale height + interpolatedHeight *= this.terrain_scale; // Scale height - return interpolatedHeight; + return interpolatedHeight; + } catch (Exception e) { + throw new RuntimeException(e); + } } public float terrainBlend(Vector2f terrainLoc) { From 7655b6733808572aa2d7c7c6f5ae52d9daab31c2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 10:42:04 -0400 Subject: [PATCH 162/289] Debug code added --- src/engine/InterestManagement/Terrain.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 327fc06c..3254d547 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -170,7 +170,8 @@ public class Terrain { return interpolatedHeight; } catch (Exception e) { - throw new RuntimeException(e); + Logger.error(this.zone.zoneName + ":" + this.zone.getObjectUUID()); + return 0; } } From 68c8d9187165484a1bc429a4c078f863da026480 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 10:43:44 -0400 Subject: [PATCH 163/289] Assignment removed for now --- src/engine/InterestManagement/Terrain.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 3254d547..59172eeb 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -87,14 +87,12 @@ public class Terrain { public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { Zone terrainZone; - Zone parentZone; // Retrieve the next zone with a heightmap attached. // Zones without a heightmap use the next zone up the // tree to calculate heights from. terrainZone = getNextZoneWithTerrain(currentZone); - parentZone = getNextZoneWithTerrain(currentZone.parent); // Transform world loc into zone space coordinate system From 368429695900287d371083ae768533e70b47ed38 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 10:53:58 -0400 Subject: [PATCH 164/289] Assignment removed for now --- src/engine/InterestManagement/Terrain.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 59172eeb..883184ea 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -167,8 +167,9 @@ public class Terrain { interpolatedHeight *= this.terrain_scale; // Scale height return interpolatedHeight; + } catch (Exception e) { - Logger.error(this.zone.zoneName + ":" + this.zone.getObjectUUID()); + Logger.error(this.zone.zoneName + ":" + this.zone.getObjectUUID() + e); return 0; } } From a1a3ea6234084e2b38a399b371b035c4e099ec55 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 11:01:04 -0400 Subject: [PATCH 165/289] Debug code added --- src/engine/gameManager/ZoneManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 008ddc03..5a6f9afd 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -294,6 +294,9 @@ public enum ZoneManager { Vector2f localCoords; Vector2f zoneOrigin; + if (ZoneManager.seaFloor.equals(serverZone)) + zoneOrigin = new Vector2f(); + // Top left corner of zone is calculated in world space by the center and it's extents. zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z); From 6809988e9c2e907d2ff4315390a7d661d7956561 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 11:15:41 -0400 Subject: [PATCH 166/289] bugfix in variable assignment --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 883184ea..9509b07b 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -126,7 +126,7 @@ public class Terrain { if (terrain_cell.x >= this.cell_count.x) terrain_cell.x = terrain_cell.x - 1; - if (terrain_cell.x >= this.cell_count.y) + if (terrain_cell.y >= this.cell_count.y) terrain_cell.y = terrain_cell.y - 1; return terrain_cell; From 823061c6993a1d01aa766eefdd26fdf7124803e9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 11:23:20 -0400 Subject: [PATCH 167/289] Improved clamping --- src/engine/InterestManagement/Terrain.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9509b07b..7ffbcf6b 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -121,13 +121,10 @@ public class Terrain { Vector2f terrain_cell = new Vector2f(terrainLoc.x / this.cell_size.x, terrainLoc.y / this.cell_size.y); - // Clamp values when standing directly on max pole + // Clamp values when standing directly on pole - if (terrain_cell.x >= this.cell_count.x) - terrain_cell.x = terrain_cell.x - 1; - - if (terrain_cell.y >= this.cell_count.y) - terrain_cell.y = terrain_cell.y - 1; + terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 1, terrain_cell.x)); + terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 1, terrain_cell.y)); return terrain_cell; } From b9ef4eee6339ad7b12f9266493a81e8e76c50bba Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 11:32:43 -0400 Subject: [PATCH 168/289] Class cleanup and comments --- src/engine/InterestManagement/Terrain.java | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 7ffbcf6b..3e36c68b 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -39,18 +39,24 @@ public class Terrain { this.heightmap = this.zone.terrain_image; - // Configure PLANAR + // Configure PLANAR zones to use the same + // 16x16 pixel image that all other flat + // terrains share. if (this.zone.terrain_type.equals("PLANAR")) this.heightmap = 1006300; - this.terrain_size.x = this.zone.major_radius * 2; - this.terrain_size.y = this.zone.minor_radius * 2; + // Load pixel data for this terrain from cache this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap); if (terrain_pixel_data == null) - Logger.error("Pixel map empty for zone: " + zone.getObjectUUID() + ":" + zone.zoneName); + Logger.error("Pixel map empty for zone: " + this.zone.getObjectUUID() + ":" + this.zone.zoneName); + + // Configure terrain based on zone properties + + this.terrain_size.x = this.zone.major_radius * 2; + this.terrain_size.y = this.zone.minor_radius * 2; this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; @@ -67,6 +73,10 @@ public class Terrain { public static Zone getNextZoneWithTerrain(Zone zone) { + // Not all zones have a terrain. Some are for display only + // and heights returned are from the parent heightmap. This + // is controlled in the JSON via the has_terrain_gen field. + Zone terrain_zone = zone; if (zone == null) @@ -88,9 +98,7 @@ public class Terrain { Zone terrainZone; - // Retrieve the next zone with a heightmap attached. - // Zones without a heightmap use the next zone up the - // tree to calculate heights from. + // Retrieve the next zone with a terrain defined. terrainZone = getNextZoneWithTerrain(currentZone); @@ -136,11 +144,10 @@ public class Terrain { Vector2f terrain_cell = getTerrainCell(terrainLoc); - int gridX = (int) Math.floor(terrain_cell.x); - int gridY = (int) Math.floor(terrain_cell.y); + int pixel_x = (int) Math.floor(terrain_cell.x); + int pixel_t = (int) Math.floor(terrain_cell.y); - float offsetX = terrain_cell.x % 1; - float offsetY = terrain_cell.y % 1; + Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1); //get 4 surrounding vertices from the pixel array. @@ -149,17 +156,17 @@ public class Terrain { float bottomLeftHeight; float bottomRightHeight; - topLeftHeight = terrain_pixel_data[gridX][gridY]; - topRightHeight = terrain_pixel_data[gridX + 1][gridY]; - bottomLeftHeight = terrain_pixel_data[gridX][gridY + 1]; - bottomRightHeight = terrain_pixel_data[gridX + 1][gridY + 1]; + topLeftHeight = terrain_pixel_data[pixel_x][pixel_t]; + topRightHeight = terrain_pixel_data[pixel_x + 1][pixel_t]; + bottomLeftHeight = terrain_pixel_data[pixel_x][pixel_t + 1]; + bottomRightHeight = terrain_pixel_data[pixel_x + 1][pixel_t + 1]; // Interpolate between the 4 vertices - interpolatedHeight = topLeftHeight * (1 - offsetX) * (1 - offsetY); - interpolatedHeight += topRightHeight * (1 - offsetY) * (offsetX); - interpolatedHeight += (bottomLeftHeight * (1 - offsetX) * offsetY); - interpolatedHeight += (bottomRightHeight * offsetY * offsetX); + interpolatedHeight = topLeftHeight * (1 - pixel_offset.x) * (1 - pixel_offset.y); + interpolatedHeight += topRightHeight * (1 - pixel_offset.y) * (pixel_offset.x); + interpolatedHeight += (bottomLeftHeight * (1 - pixel_offset.x) * pixel_offset.y); + interpolatedHeight += (bottomRightHeight * pixel_offset.y * pixel_offset.x); interpolatedHeight *= this.terrain_scale; // Scale height From 17640412724503612a72c9fecbc11cd6104e7abd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 11:34:37 -0400 Subject: [PATCH 169/289] Class cleanup and comments --- src/engine/InterestManagement/Terrain.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 3e36c68b..0e8a6e1c 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -145,7 +145,7 @@ public class Terrain { Vector2f terrain_cell = getTerrainCell(terrainLoc); int pixel_x = (int) Math.floor(terrain_cell.x); - int pixel_t = (int) Math.floor(terrain_cell.y); + int pixel_y = (int) Math.floor(terrain_cell.y); Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1); @@ -156,10 +156,10 @@ public class Terrain { float bottomLeftHeight; float bottomRightHeight; - topLeftHeight = terrain_pixel_data[pixel_x][pixel_t]; - topRightHeight = terrain_pixel_data[pixel_x + 1][pixel_t]; - bottomLeftHeight = terrain_pixel_data[pixel_x][pixel_t + 1]; - bottomRightHeight = terrain_pixel_data[pixel_x + 1][pixel_t + 1]; + topLeftHeight = terrain_pixel_data[pixel_x][pixel_y]; + topRightHeight = terrain_pixel_data[pixel_x + 1][pixel_y]; + bottomLeftHeight = terrain_pixel_data[pixel_x][pixel_y + 1]; + bottomRightHeight = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; // Interpolate between the 4 vertices From dadfc15d39b662134b982ee2afe534fdf23447c2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 11:36:28 -0400 Subject: [PATCH 170/289] Class cleanup and comments --- src/engine/gameManager/ZoneManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 5a6f9afd..008ddc03 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -294,9 +294,6 @@ public enum ZoneManager { Vector2f localCoords; Vector2f zoneOrigin; - if (ZoneManager.seaFloor.equals(serverZone)) - zoneOrigin = new Vector2f(); - // Top left corner of zone is calculated in world space by the center and it's extents. zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z); From 280bd61e2a01d6bb5f1b1943cf2eb9a1145eed9f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 16:50:52 -0400 Subject: [PATCH 171/289] Offset support for blend. --- src/engine/InterestManagement/Terrain.java | 8 +++--- src/engine/devcmd/cmds/GetHeightCmd.java | 6 ++-- src/engine/gameManager/ZoneManager.java | 32 ++++++++++++---------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 0e8a6e1c..5c072627 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -104,7 +104,7 @@ public class Terrain { // Transform world loc into zone space coordinate system - Vector2f terrainLoc = ZoneManager.worldToZoneSpace(worldLoc, terrainZone); + Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(worldLoc, terrainZone); // Interpolate height for this position in terrain @@ -178,12 +178,12 @@ public class Terrain { } } - public float terrainBlend(Vector2f terrainLoc) { + public float terrainBlend(Vector2f zoneOffset) { // Normalize terrain loc - Vector2f normalizedLoc = new Vector2f(terrainLoc.x / this.terrain_size.x, - terrainLoc.y / terrain_size.y); + Vector2f normalizedLoc = new Vector2f(zoneOffset.x / this.terrain_size.x, + zoneOffset.y / terrain_size.y); float minp = this.zone.min_blend / this.zone.major_radius; float maxp = this.zone.max_blend / this.zone.major_radius; diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 8849802a..bb9b56f9 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -38,8 +38,8 @@ public class GetHeightCmd extends AbstractDevCmd { float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc()); float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); - Vector2f zoneLoc = ZoneManager.worldToZoneSpace(playerCharacter.getLoc(), heightmapZone); - + Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); + Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); @@ -47,7 +47,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); - this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneLoc)); + this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); this.throwbackInfo(playerCharacter, "------------"); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 008ddc03..450c24d7 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -288,8 +288,22 @@ public enum ZoneManager { return localCoords; } - public static Vector2f worldToZoneSpace(Vector3fImmutable worldVector, - Zone serverZone) { + public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc, + Zone serverZone) { + + Vector2f localCoords; + Vector2f zoneOrigin; + + zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z); + localCoords = new Vector2f(worldLoc.x, worldLoc.z); + localCoords = localCoords.subtract(zoneOrigin); + + return localCoords; + + } + + public static Vector2f worldToTerrainSpace(Vector3fImmutable worldLoc, + Zone serverZone) { Vector2f localCoords; Vector2f zoneOrigin; @@ -301,7 +315,7 @@ public enum ZoneManager { // Local coordinate in world space translated to an offset from the calculated zone origin. - localCoords = new Vector2f(worldVector.x, worldVector.z); + localCoords = new Vector2f(worldLoc.x, worldLoc.z); localCoords = localCoords.subtract(zoneOrigin); // TODO : Make sure this value does not go outside the zone's bounds. @@ -311,18 +325,6 @@ public enum ZoneManager { // Converts local zone coordinates to world coordinates - public static Vector3fImmutable localToWorld(Vector3fImmutable worldVector, - Zone serverZone) { - - Vector3fImmutable worldCoords; - - worldCoords = new Vector3fImmutable(worldVector.x + serverZone.absX, - worldVector.y + serverZone.absY, worldVector.z - + serverZone.absZ); - - return worldCoords; - } - /** * Converts from local (relative to this building) to world. From 20d9a232cc0a0b0d14c2c9843293e7efefd4d365 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 17:00:01 -0400 Subject: [PATCH 172/289] Method cleanup --- src/engine/InterestManagement/Terrain.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 5c072627..de6f3899 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -28,8 +28,9 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public float min_blend; - public float max_blend; + + public Vector2f minor_blend; + public Vector2f major_blend; public int heightmap; Zone zone; @@ -64,8 +65,13 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; - this.max_blend = this.zone.max_blend / this.zone.major_radius; - this.min_blend = this.zone.min_blend / this.zone.minor_radius; + // Blending and scaling configuration + + this.major_blend.x = this.zone.max_blend / this.zone.major_radius; + this.major_blend.y = this.zone.min_blend / this.zone.major_radius; + + this.minor_blend.x = this.zone.max_blend / this.zone.minor_radius; + this.minor_blend.y = this.zone.min_blend / this.zone.minor_radius; this.terrain_scale = this.zone.terrain_max_y / 255f; @@ -185,25 +191,19 @@ public class Terrain { Vector2f normalizedLoc = new Vector2f(zoneOffset.x / this.terrain_size.x, zoneOffset.y / terrain_size.y); - float minp = this.zone.min_blend / this.zone.major_radius; - float maxp = this.zone.max_blend / this.zone.major_radius; - - float minpy = this.zone.min_blend / this.zone.minor_radius; - float maxpy = this.zone.max_blend / this.zone.minor_radius; - float xval; - if (minp > 0.4f) - xval = minp; + if (this.major_blend.y > 0.4f) + xval = this.major_blend.y; else - xval = Math.min(maxp, 0.4f); + xval = Math.min(this.major_blend.x, 0.4f); float yval; - if (minpy > 0.4f) - yval = minpy; + if (this.minor_blend.y > 0.4f) + yval = this.minor_blend.y; else - yval = Math.min(maxpy, 0.4f); + yval = Math.min(this.minor_blend.x, 0.4f); float value; From dc5a778610cc6b459eccc1b7411a942a2db97d14 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 17:00:53 -0400 Subject: [PATCH 173/289] Method cleanup --- src/engine/InterestManagement/Terrain.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index de6f3899..07a822a1 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -28,7 +28,6 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public Vector2f minor_blend; public Vector2f major_blend; public int heightmap; @@ -65,7 +64,7 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; - // Blending and scaling configuration + // Blending and height scaling configuration this.major_blend.x = this.zone.max_blend / this.zone.major_radius; this.major_blend.y = this.zone.min_blend / this.zone.major_radius; From 6ac65c73d5507744f482e00e091ea6480474fd3f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 17:04:09 -0400 Subject: [PATCH 174/289] Method cleanup --- src/engine/InterestManagement/Terrain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 07a822a1..5db8df36 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -187,8 +187,8 @@ public class Terrain { // Normalize terrain loc - Vector2f normalizedLoc = new Vector2f(zoneOffset.x / this.terrain_size.x, - zoneOffset.y / terrain_size.y); + Vector2f normalizedLoc = new Vector2f(Math.abs(zoneOffset.x / this.terrain_size.x), + Math.abs(zoneOffset.y / terrain_size.y)); float xval; From 1a0f318968f161ba86d30c0e3f4ea15d54dd9894 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 17:14:40 -0400 Subject: [PATCH 175/289] abs is up the chain a step --- src/engine/InterestManagement/Terrain.java | 79 ++++++++++------------ 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 5db8df36..c33fd5a6 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -28,15 +28,14 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public Vector2f minor_blend; public Vector2f major_blend; + public Vector2f minor_blend; public int heightmap; Zone zone; public Terrain(Zone zone) { this.zone = zone; - this.heightmap = this.zone.terrain_image; // Configure PLANAR zones to use the same @@ -73,7 +72,6 @@ public class Terrain { this.minor_blend.y = this.zone.min_blend / this.zone.minor_radius; this.terrain_scale = this.zone.terrain_max_y / 255f; - } public static Zone getNextZoneWithTerrain(Zone zone) { @@ -99,17 +97,15 @@ public class Terrain { return terrain_zone; } - public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { - - Zone terrainZone; + public static float getWorldHeight(Zone zone, Vector3fImmutable world_loc) { // Retrieve the next zone with a terrain defined. - terrainZone = getNextZoneWithTerrain(currentZone); + Zone terrainZone = getNextZoneWithTerrain(zone); // Transform world loc into zone space coordinate system - Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(worldLoc, terrainZone); + Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(world_loc, terrainZone); // Interpolate height for this position in terrain @@ -119,20 +115,20 @@ public class Terrain { return interpolatedChildHeight; } - public static float getWorldHeight(Vector3fImmutable worldLoc) { + public static float getWorldHeight(Vector3fImmutable world_loc) { - Zone currentZone = ZoneManager.findSmallestZone(worldLoc); + Zone currentZone = ZoneManager.findSmallestZone(world_loc); if (currentZone == null) return 0; - return getWorldHeight(currentZone, worldLoc); + return getWorldHeight(currentZone, world_loc); } - public Vector2f getTerrainCell(Vector2f terrainLoc) { + public Vector2f getTerrainCell(Vector2f terrain_loc) { - Vector2f terrain_cell = new Vector2f(terrainLoc.x / this.cell_size.x, terrainLoc.y / this.cell_size.y); + Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y); // Clamp values when standing directly on pole @@ -142,53 +138,48 @@ public class Terrain { return terrain_cell; } - public float getInterpolatedTerrainHeight(Vector2f terrainLoc) { + public float getInterpolatedTerrainHeight(Vector2f terrain_loc) { - try { - float interpolatedHeight; + float interpolatedHeight; - Vector2f terrain_cell = getTerrainCell(terrainLoc); + Vector2f terrain_cell = getTerrainCell(terrain_loc); - int pixel_x = (int) Math.floor(terrain_cell.x); - int pixel_y = (int) Math.floor(terrain_cell.y); + int pixel_x = (int) Math.floor(terrain_cell.x); + int pixel_y = (int) Math.floor(terrain_cell.y); - Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1); + Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1); - //get 4 surrounding vertices from the pixel array. + //get 4 surrounding vertices from the pixel array. - float topLeftHeight; - float topRightHeight; - float bottomLeftHeight; - float bottomRightHeight; + float top_left_pixel; + float top_right_pixel; + float bottom_left_pixel; + float bottom_right_pixel; - topLeftHeight = terrain_pixel_data[pixel_x][pixel_y]; - topRightHeight = terrain_pixel_data[pixel_x + 1][pixel_y]; - bottomLeftHeight = terrain_pixel_data[pixel_x][pixel_y + 1]; - bottomRightHeight = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; + top_left_pixel = terrain_pixel_data[pixel_x][pixel_y]; + top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y]; + bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1]; + bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; - // Interpolate between the 4 vertices + // Interpolate between the 4 vertices - interpolatedHeight = topLeftHeight * (1 - pixel_offset.x) * (1 - pixel_offset.y); - interpolatedHeight += topRightHeight * (1 - pixel_offset.y) * (pixel_offset.x); - interpolatedHeight += (bottomLeftHeight * (1 - pixel_offset.x) * pixel_offset.y); - interpolatedHeight += (bottomRightHeight * pixel_offset.y * pixel_offset.x); + interpolatedHeight = top_left_pixel * (1 - pixel_offset.x) * (1 - pixel_offset.y); + interpolatedHeight += top_right_pixel * (1 - pixel_offset.y) * (pixel_offset.x); + interpolatedHeight += (bottom_left_pixel * (1 - pixel_offset.x) * pixel_offset.y); + interpolatedHeight += (bottom_right_pixel * pixel_offset.y * pixel_offset.x); - interpolatedHeight *= this.terrain_scale; // Scale height + interpolatedHeight *= this.terrain_scale; // Scale height - return interpolatedHeight; + return interpolatedHeight; - } catch (Exception e) { - Logger.error(this.zone.zoneName + ":" + this.zone.getObjectUUID() + e); - return 0; - } } - public float terrainBlend(Vector2f zoneOffset) { + public float terrainBlend(Vector2f zone_offset) { - // Normalize terrain loc + // Normalize terrain offset - Vector2f normalizedLoc = new Vector2f(Math.abs(zoneOffset.x / this.terrain_size.x), - Math.abs(zoneOffset.y / terrain_size.y)); + Vector2f normalizedLoc = new Vector2f(zone_offset.x / this.terrain_size.x, + zone_offset.y / terrain_size.y); float xval; From 99a79df02d4e36028a052b556c747fcece3836b6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 17:17:18 -0400 Subject: [PATCH 176/289] abs is up the chain a step --- src/engine/InterestManagement/Terrain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index c33fd5a6..05550c87 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -178,8 +178,8 @@ public class Terrain { // Normalize terrain offset - Vector2f normalizedLoc = new Vector2f(zone_offset.x / this.terrain_size.x, - zone_offset.y / terrain_size.y); + Vector2f normalizedLoc = new Vector2f(Math.abs(zone_offset.x) / this.terrain_size.x, + Math.abs(zone_offset.y) / terrain_size.y); float xval; From a53c68054d30ddc2ad06c4ad66c16cc299650243 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 11 Oct 2023 17:20:23 -0400 Subject: [PATCH 177/289] Only one kind of zone. --- src/engine/gameManager/ZoneManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 450c24d7..ae544cfe 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -277,24 +277,24 @@ public enum ZoneManager { // Converts world coordinates to coordinates local to a given zone. public static Vector3fImmutable worldToLocal(Vector3fImmutable worldVector, - Zone serverZone) { + Zone zone) { Vector3fImmutable localCoords; - localCoords = new Vector3fImmutable(worldVector.x - serverZone.absX, - worldVector.y - serverZone.absY, worldVector.z - - serverZone.absZ); + localCoords = new Vector3fImmutable(worldVector.x - zone.absX, + worldVector.y - zone.absY, worldVector.z + - zone.absZ); return localCoords; } public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc, - Zone serverZone) { + Zone zone) { Vector2f localCoords; Vector2f zoneOrigin; - zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z); + zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z); localCoords = new Vector2f(worldLoc.x, worldLoc.z); localCoords = localCoords.subtract(zoneOrigin); @@ -303,15 +303,15 @@ public enum ZoneManager { } public static Vector2f worldToTerrainSpace(Vector3fImmutable worldLoc, - Zone serverZone) { + Zone zone) { Vector2f localCoords; Vector2f zoneOrigin; // Top left corner of zone is calculated in world space by the center and it's extents. - zoneOrigin = new Vector2f(serverZone.getLoc().x, serverZone.getLoc().z); - zoneOrigin = zoneOrigin.subtract(new Vector2f(serverZone.bounds.getHalfExtents().x, serverZone.bounds.getHalfExtents().y)); + zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z); + zoneOrigin = zoneOrigin.subtract(new Vector2f(zone.bounds.getHalfExtents().x, zone.bounds.getHalfExtents().y)); // Local coordinate in world space translated to an offset from the calculated zone origin. From c1e1c730bb9c64c5d9c1b2820b9458b5f7a3166b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 05:49:22 -0400 Subject: [PATCH 178/289] Opposite of 1006300 created as 1006301. --- src/engine/objects/Zone.java | 4 +++- src/engine/util/MapLoader.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index dfb78c6a..637893cd 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -107,9 +107,11 @@ public class Zone extends AbstractGameObject { if (this.guild_zone) { this.max_blend = 128; this.min_blend = 128; + this.terrain_max_y = 5; this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.terrain_type = "PLANAR"; + this.terrain_type = "TARGA"; + this.terrain_image = 1006301; } if (this.terrain_type.equals("NONE")) diff --git a/src/engine/util/MapLoader.java b/src/engine/util/MapLoader.java index 779080bd..312b5ffc 100644 --- a/src/engine/util/MapLoader.java +++ b/src/engine/util/MapLoader.java @@ -18,6 +18,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.stream.Stream; public enum MapLoader { @@ -137,6 +138,16 @@ public enum MapLoader { }); // Try with resources block + // Generate full white alternate to 1600300 + // Declare and initialize an array of short[16][16] + + short[][] heightMapEntry = new short[16][16]; + + for (short[] shorts : heightMapEntry) + Arrays.fill(shorts, (short) 255); + + Terrain._heightmap_pixel_cache.put(1006301, heightMapEntry); + } catch (IOException e) { Logger.error(e); } From d15b8a5246fd0ae1f743f122c7b5b23025644826 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:01:55 -0400 Subject: [PATCH 179/289] Opposite of 1006300 created as 1006301. --- src/engine/InterestManagement/Terrain.java | 5 ++++- src/engine/objects/Zone.java | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 05550c87..a39c325a 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -43,7 +43,10 @@ public class Terrain { // terrains share. if (this.zone.terrain_type.equals("PLANAR")) - this.heightmap = 1006300; + if (this.zone.guild_zone) + this.heightmap = 1006301; + else + this.heightmap = 1006300; // Load pixel data for this terrain from cache diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 637893cd..1878e903 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -110,8 +110,7 @@ public class Zone extends AbstractGameObject { this.terrain_max_y = 5; this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.terrain_type = "TARGA"; - this.terrain_image = 1006301; + this.terrain_type = "PLANAR"; } if (this.terrain_type.equals("NONE")) From 9f9c3ba7f1ebdacffbb6111ef47d39d710490473 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:08:29 -0400 Subject: [PATCH 180/289] Ratios initialized. --- src/engine/InterestManagement/Terrain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index a39c325a..07f5c8c5 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -28,8 +28,8 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public Vector2f major_blend; - public Vector2f minor_blend; + public Vector2f major_blend = new Vector2f(); + public Vector2f minor_blend = new Vector2f(); public int heightmap; Zone zone; From 9e96add2993b4e61dde2bf43c047e904ed1ace23 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:12:40 -0400 Subject: [PATCH 181/289] Class cleanup --- src/engine/InterestManagement/Terrain.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 07f5c8c5..c404286d 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -19,9 +19,6 @@ import java.util.HashMap; import static java.lang.Math.PI; public class Terrain { - - // Class variables - public static final HashMap _heightmap_pixel_cache = new HashMap<>(); public short[][] terrain_pixel_data; public Vector2f terrain_size = new Vector2f(); @@ -131,6 +128,8 @@ public class Terrain { public Vector2f getTerrainCell(Vector2f terrain_loc) { + // Calculate terrain cell with offset + Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y); // Clamp values when standing directly on pole @@ -152,17 +151,12 @@ public class Terrain { Vector2f pixel_offset = new Vector2f(terrain_cell.x % 1, terrain_cell.y % 1); - //get 4 surrounding vertices from the pixel array. - - float top_left_pixel; - float top_right_pixel; - float bottom_left_pixel; - float bottom_right_pixel; + // 4 surrounding vertices from the pixel array. - top_left_pixel = terrain_pixel_data[pixel_x][pixel_y]; - top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y]; - bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1]; - bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; + float top_left_pixel = terrain_pixel_data[pixel_x][pixel_y]; + float top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y]; + float bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1]; + float bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; // Interpolate between the 4 vertices From 1b2c218e83e59ddbb6afd7780eecb18a33650ddb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:19:22 -0400 Subject: [PATCH 182/289] property conforms to JSON --- src/engine/InterestManagement/Terrain.java | 12 ++++++------ src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- src/engine/devcmd/cmds/SeaAuditCmd.java | 2 +- src/engine/devcmd/cmds/ZoneInfoCmd.java | 2 +- src/engine/gameManager/ZoneManager.java | 2 +- .../net/client/handlers/PlaceAssetMsgHandler.java | 2 +- src/engine/objects/Zone.java | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index c404286d..f49eb9f3 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -35,15 +35,15 @@ public class Terrain { this.zone = zone; this.heightmap = this.zone.terrain_image; - // Configure PLANAR zones to use the same - // 16x16 pixel image that all other flat - // terrains share. + // Configure PLANAR zones to use the same 16x16 pixel image + // that all similar terrains share. (See JSON) Guild zones + // use an inverted clone of this heightmap. if (this.zone.terrain_type.equals("PLANAR")) if (this.zone.guild_zone) - this.heightmap = 1006301; + this.heightmap = 1006301; // all 255 else - this.heightmap = 1006300; + this.heightmap = 1006300; // all 0 // Load pixel data for this terrain from cache @@ -110,7 +110,7 @@ public class Terrain { // Interpolate height for this position in terrain float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); - interpolatedChildHeight += terrainZone.worldAltitude; + interpolatedChildHeight += terrainZone.global_height; return interpolatedChildHeight; } diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index bb9b56f9..9b8266e7 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -44,7 +44,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); - this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.worldAltitude); + this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.global_height); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); diff --git a/src/engine/devcmd/cmds/SeaAuditCmd.java b/src/engine/devcmd/cmds/SeaAuditCmd.java index f5cdbdde..ec0e6c96 100644 --- a/src/engine/devcmd/cmds/SeaAuditCmd.java +++ b/src/engine/devcmd/cmds/SeaAuditCmd.java @@ -26,7 +26,7 @@ public class SeaAuditCmd extends AbstractDevCmd { AbstractGameObject target) { for (Zone zone : ZoneManager.getAllZones()) - if (zone.seaLevel > zone.worldAltitude) + if (zone.seaLevel > zone.global_height) this.throwbackInfo(playerCharacter, zone.getObjectUUID() + zone.zoneName); } diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 3786d1b4..53e7ac61 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -101,7 +101,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; output += "Sea Level = " + zone.seaLevel; output += newline; - output += "World Altitude = " + zone.worldAltitude; + output += "World Altitude = " + zone.global_height; throwbackInfo(player, output); City city = ZoneManager.getCityAtLocation(player.getLoc()); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index ae544cfe..90fbb599 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -453,7 +453,7 @@ public enum ZoneManager { } } - public static float caclulateWorldAltitude(Zone zone) { + public static float calculateGlobalZoneHeight(Zone zone) { float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 6ef021a3..c62c7e8c 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -792,7 +792,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { ZoneManager.addPlayerCityZone(zoneObject); serverZone.addNode(zoneObject); - zoneObject.worldAltitude = ZoneManager.caclulateWorldAltitude(zoneObject); + zoneObject.global_height = ZoneManager.calculateGlobalZoneHeight(zoneObject); cityObject.setParent(zoneObject); cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 1878e903..8376a151 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -56,7 +56,7 @@ public class Zone extends AbstractGameObject { public boolean isNPCCity = false; public boolean guild_zone; public String hash; - public float worldAltitude = 0; + public float global_height = 0; public float seaLevel = 0f; public float sea_level_offset = 0; public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); @@ -230,7 +230,7 @@ public class Zone extends AbstractGameObject { } this.setBounds(); - this.worldAltitude = ZoneManager.caclulateWorldAltitude(this); + this.global_height = ZoneManager.calculateGlobalZoneHeight(this); setSeaLevel(); } @@ -251,7 +251,7 @@ public class Zone extends AbstractGameObject { this.sea_level = this.parent.sea_level + this.sea_level_offset; break; case "SELF": - this.sea_level = this.worldAltitude + this.sea_level_offset; + this.sea_level = this.global_height + this.sea_level_offset; break; } } From affe6b08ab2f4e3287df78ecc6de332e53c94a3f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:33:22 -0400 Subject: [PATCH 183/289] Method is now called --- src/engine/InterestManagement/Terrain.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index f49eb9f3..9de5e0a6 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -102,17 +102,26 @@ public class Terrain { // Retrieve the next zone with a terrain defined. Zone terrainZone = getNextZoneWithTerrain(zone); + Zone parentZone = getNextZoneWithTerrain(zone); // Transform world loc into zone space coordinate system Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(world_loc, terrainZone); + Vector2f terrainOffset = ZoneManager.worldToZoneOffset(world_loc, terrainZone); + Vector2f parentLoc = ZoneManager.worldToTerrainSpace(world_loc, parentZone); // Interpolate height for this position in terrain float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedChildHeight += terrainZone.global_height; - return interpolatedChildHeight; + float interpolatedParentTerrainHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentLoc); + interpolatedParentTerrainHeight += parentZone.global_height; + + // Blend between terrains + + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + } public static float getWorldHeight(Vector3fImmutable world_loc) { From ad661ea4643104672715432a142d5e6fcc6b6065 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:43:02 -0400 Subject: [PATCH 184/289] Dev command updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 9b8266e7..cb6e9abd 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -41,12 +41,15 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); + gridSquare.x = (float) Math.floor(gridSquare.x); + gridSquare.y = (float) Math.floor(gridSquare.y); this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.global_height); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); - this.throwbackInfo(playerCharacter, "Grid : " + Math.floor(gridSquare.x) + "x" + Math.floor(gridSquare.y)); + this.throwbackInfo(playerCharacter, "Grid : " + gridSquare); + this.throwbackInfo(playerCharacter, "Offset: " + zoneOffset); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); From 10b9f19036577de870038376c0b67e436408f4f7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 06:51:01 -0400 Subject: [PATCH 185/289] Dev command updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index cb6e9abd..96d3837d 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -48,8 +48,8 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.global_height); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); - this.throwbackInfo(playerCharacter, "Grid : " + gridSquare); - this.throwbackInfo(playerCharacter, "Offset: " + zoneOffset); + this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); + this.throwbackInfo(playerCharacter, "Offset: " + "[" + zoneOffset.x + "]" + "[" + zoneOffset.y + "]"); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); From c6e0e3653179fad094eace7bf4b6f1a3b215be85 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 07:01:11 -0400 Subject: [PATCH 186/289] Dev command updated --- src/engine/InterestManagement/Terrain.java | 10 +++++----- src/engine/devcmd/cmds/GetHeightCmd.java | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9de5e0a6..99b07424 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -184,7 +184,7 @@ public class Terrain { // Normalize terrain offset - Vector2f normalizedLoc = new Vector2f(Math.abs(zone_offset.x) / this.terrain_size.x, + Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.terrain_size.x, Math.abs(zone_offset.y) / terrain_size.y); float xval; @@ -203,14 +203,14 @@ public class Terrain { float value; - if (normalizedLoc.x <= 1 - xval || normalizedLoc.x <= normalizedLoc.y) { + if (normalizedOffset.x <= 1 - xval || normalizedOffset.x <= normalizedOffset.y) { - if (normalizedLoc.y < 1 - yval) + if (normalizedOffset.y < 1 - yval) return 1; - value = (normalizedLoc.y - (1 - yval)) / yval; + value = (normalizedOffset.y - (1 - yval)) / yval; } else - value = (normalizedLoc.x - (1 - xval)) / xval; + value = (normalizedOffset.x - (1 - xval)) / xval; value = (float) Math.atan((0.5f - value) * PI); diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 96d3837d..12701f12 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -40,6 +40,9 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); + Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.terrain.terrain_size.x, + Math.abs(zoneOffset.y) / heightmapZone.terrain.terrain_size.y); + Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); gridSquare.x = (float) Math.floor(gridSquare.x); gridSquare.y = (float) Math.floor(gridSquare.y); @@ -49,7 +52,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.global_height); this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); - this.throwbackInfo(playerCharacter, "Offset: " + "[" + zoneOffset.x + "]" + "[" + zoneOffset.y + "]"); + this.throwbackInfo(playerCharacter, "Offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); From 279a0aed9149b7492dca32a4d9a34d5c581ea803 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 12 Oct 2023 07:04:27 -0400 Subject: [PATCH 187/289] Use half extents as offset from center --- src/engine/InterestManagement/Terrain.java | 4 ++-- src/engine/devcmd/cmds/GetHeightCmd.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 99b07424..dddd4a1c 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -184,8 +184,8 @@ public class Terrain { // Normalize terrain offset - Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.terrain_size.x, - Math.abs(zone_offset.y) / terrain_size.y); + Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.major_radius, + Math.abs(zone_offset.y) / this.zone.minor_radius); float xval; diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 12701f12..ff88d6f0 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -40,8 +40,8 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); - Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.terrain.terrain_size.x, - Math.abs(zoneOffset.y) / heightmapZone.terrain.terrain_size.y); + Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.major_radius, + Math.abs(zoneOffset.y) / heightmapZone.minor_radius); Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); gridSquare.x = (float) Math.floor(gridSquare.x); From d414c19904474b3ce7e622b2f14e7ee4f773c9c6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 13:31:31 -0400 Subject: [PATCH 188/289] Set parent zone properly --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index dddd4a1c..b484134a 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -102,7 +102,7 @@ public class Terrain { // Retrieve the next zone with a terrain defined. Zone terrainZone = getNextZoneWithTerrain(zone); - Zone parentZone = getNextZoneWithTerrain(zone); + Zone parentZone = getNextZoneWithTerrain(zone.parent); // Transform world loc into zone space coordinate system From 11664a92183f6507885dadcdce6894f14cd8c82b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 13:42:28 -0400 Subject: [PATCH 189/289] Dev cmd updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 31 ++++++++++++++---------- src/engine/gameManager/ZoneManager.java | 10 +++----- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index ff88d6f0..4cc1662f 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -35,30 +35,35 @@ public class GetHeightCmd extends AbstractDevCmd { heightmapZone = Terrain.getNextZoneWithTerrain(currentZone); parentZone = Terrain.getNextZoneWithTerrain(currentZone.parent); - float currentHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc()); - float parentHeight = Terrain.getWorldHeight(parentZone, playerCharacter.getLoc()); + Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); + Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); + Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.major_radius, + Math.abs(childZoneOffset.y) / heightmapZone.minor_radius); + Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone); - Vector2f zoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); - Vector2f zoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); - Vector2f normalizedOffset = new Vector2f(Math.abs(zoneOffset.x) / heightmapZone.major_radius, - Math.abs(zoneOffset.y) / heightmapZone.minor_radius); + float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc); + childHeight = childHeight + heightmapZone.global_height; - Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(zoneLoc); + float parentHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentZoneLoc); + parentHeight += parentZone.global_height; + + Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(childZoneLoc); gridSquare.x = (float) Math.floor(gridSquare.x); gridSquare.y = (float) Math.floor(gridSquare.y); this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName); this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName); - this.throwbackInfo(playerCharacter, "Global Height: " + heightmapZone.global_height); - this.throwbackInfo(playerCharacter, "Sea Level: " + heightmapZone.seaLevel); + this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName); + this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); this.throwbackInfo(playerCharacter, "Offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); - this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(zoneOffset)); - this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(currentHeight)); + this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(childZoneOffset)); + this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(childHeight)); this.throwbackInfo(playerCharacter, "------------"); - this.throwbackInfo(playerCharacter, "Parent : " + parentZone.zoneName); - this.throwbackInfo(playerCharacter, "Height returned : " + Math.ceil(parentHeight)); + + this.throwbackInfo(playerCharacter, "Child Height: " + Math.ceil(childHeight)); + this.throwbackInfo(playerCharacter, "Parent Height : " + Math.ceil(parentHeight)); this.throwbackInfo(playerCharacter, "------------"); } diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 90fbb599..ffd08263 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -291,14 +291,12 @@ public enum ZoneManager { public static Vector2f worldToZoneOffset(Vector3fImmutable worldLoc, Zone zone) { - Vector2f localCoords; - Vector2f zoneOrigin; + Vector2f zoneLoc; - zoneOrigin = new Vector2f(zone.getLoc().x, zone.getLoc().z); - localCoords = new Vector2f(worldLoc.x, worldLoc.z); - localCoords = localCoords.subtract(zoneOrigin); + zoneLoc = new Vector2f(worldLoc.x, worldLoc.z).subtract(zone.getLoc().x, zone.getLoc().z); + zoneLoc.y *= -1; - return localCoords; + return zoneLoc; } From 4ee4054ab3259858ebba4b867fa00a3b20ae6e50 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 13:46:39 -0400 Subject: [PATCH 190/289] Dev cmd updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 4cc1662f..0f493de2 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -47,6 +47,8 @@ public class GetHeightCmd extends AbstractDevCmd { float parentHeight = parentZone.terrain.getInterpolatedTerrainHeight(parentZoneLoc); parentHeight += parentZone.global_height; + float blendedHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc()); + Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(childZoneLoc); gridSquare.x = (float) Math.floor(gridSquare.x); gridSquare.y = (float) Math.floor(gridSquare.y); @@ -58,13 +60,13 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); this.throwbackInfo(playerCharacter, "Offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(childZoneOffset)); - this.throwbackInfo(playerCharacter, "Height returned: " + Math.ceil(childHeight)); this.throwbackInfo(playerCharacter, "------------"); this.throwbackInfo(playerCharacter, "Child Height: " + Math.ceil(childHeight)); this.throwbackInfo(playerCharacter, "Parent Height : " + Math.ceil(parentHeight)); - this.throwbackInfo(playerCharacter, "------------"); + this.throwbackInfo(playerCharacter, "Blended Height : " + Math.ceil(blendedHeight)); + } @Override From 12e073ca46439f61bce31557c4533883558cdbcc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 13:47:35 -0400 Subject: [PATCH 191/289] Dev cmd updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 0f493de2..74cc6e69 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -58,7 +58,8 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName); this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); - this.throwbackInfo(playerCharacter, "Offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); + this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]"); + this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(childZoneOffset)); this.throwbackInfo(playerCharacter, "------------"); From 06049a7135ff925381c93099fe315c97a6cbb9e2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 13:47:52 -0400 Subject: [PATCH 192/289] Dev cmd updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 74cc6e69..8e779a8d 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -58,7 +58,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName); this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); - this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]"); + this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]"); this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(childZoneOffset)); From 6ed3495780f1bd09b620ee764927a23057a71157 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 13:57:18 -0400 Subject: [PATCH 193/289] Blend updated --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index b484134a..6a26faba 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -120,7 +120,7 @@ public class Terrain { // Blend between terrains - return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + return interpolatedChildHeight + parentZone.global_height * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); } From 65eebcbb5d0116cf888f9f8dbc92d085d737bfb7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 14:07:54 -0400 Subject: [PATCH 194/289] Blend updated --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 6a26faba..b484134a 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -120,7 +120,7 @@ public class Terrain { // Blend between terrains - return interpolatedChildHeight + parentZone.global_height * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); } From 3f93bf08fb989f5c511276736bcab8aab666a2d2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 14:27:52 -0400 Subject: [PATCH 195/289] Test raw blend --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index b484134a..9801ac75 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -120,7 +120,7 @@ public class Terrain { // Blend between terrains - return interpolatedChildHeight + interpolatedParentTerrainHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + return (interpolatedChildHeight + interpolatedParentTerrainHeight) * terrainZone.terrain.terrainBlend(terrainOffset); } From db9e9505587aeac17d5e8a440e629d5fef5793d9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 14:30:58 -0400 Subject: [PATCH 196/289] Comment cleanup --- src/engine/InterestManagement/Terrain.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 9801ac75..58513006 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -107,10 +107,13 @@ public class Terrain { // Transform world loc into zone space coordinate system Vector2f terrainLoc = ZoneManager.worldToTerrainSpace(world_loc, terrainZone); - Vector2f terrainOffset = ZoneManager.worldToZoneOffset(world_loc, terrainZone); Vector2f parentLoc = ZoneManager.worldToTerrainSpace(world_loc, parentZone); - // Interpolate height for this position in terrain + // Offset from origin needed for blending function + + Vector2f terrainOffset = ZoneManager.worldToZoneOffset(world_loc, terrainZone); + + // Interpolate height for this position in both terrains float interpolatedChildHeight = terrainZone.terrain.getInterpolatedTerrainHeight(terrainLoc); interpolatedChildHeight += terrainZone.global_height; From 13f5e3eff2bf408b8a9c0462ac736a40e8f725d1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 14:35:16 -0400 Subject: [PATCH 197/289] Comment cleanup --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 58513006..34703978 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -123,7 +123,7 @@ public class Terrain { // Blend between terrains - return (interpolatedChildHeight + interpolatedParentTerrainHeight) * terrainZone.terrain.terrainBlend(terrainOffset); + return (interpolatedChildHeight + interpolatedParentTerrainHeight) * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); } From 5900068898cffd3c2d79ebd99bbd5e7244434e8d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 14:44:32 -0400 Subject: [PATCH 198/289] Blend test --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 34703978..8bba456a 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -123,7 +123,7 @@ public class Terrain { // Blend between terrains - return (interpolatedChildHeight + interpolatedParentTerrainHeight) * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + return interpolatedChildHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); } From 761ec6f4afb889d258e43cd682a52e012748c04a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 14:55:19 -0400 Subject: [PATCH 199/289] Blend test --- src/engine/InterestManagement/Terrain.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 8bba456a..f8aa914b 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -123,7 +123,12 @@ public class Terrain { // Blend between terrains - return interpolatedChildHeight * (1 - terrainZone.terrain.terrainBlend(terrainOffset)); + float blendFactor = terrainZone.terrain.terrainBlend(terrainOffset); + + float terrainHeight = interpolatedChildHeight * blendFactor; + terrainHeight += interpolatedParentTerrainHeight * (1 - blendFactor); + + return terrainHeight; } From 3d4058ad01ce32dfcd364cb32f2f89e92c08776b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 15:57:58 -0400 Subject: [PATCH 200/289] Height for seafloor --- src/engine/objects/Zone.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 8376a151..60ee12c0 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -214,6 +214,7 @@ public class Zone extends AbstractGameObject { if (this.parent == null) { this.absX = this.xOffset; this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE; + this.global_height = MBServerStatics.SEA_FLOOR_ALTITUDE; this.absZ = this.zOffset; this.seaLevel = 0; this.setBounds(); From 2cbe5f38cd89b5394a1a526939d8c2fa9aa5cd9a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 16:40:31 -0400 Subject: [PATCH 201/289] Configuration moved to constructor --- src/engine/InterestManagement/Terrain.java | 54 +++++++++------------- src/engine/devcmd/cmds/GetHeightCmd.java | 2 +- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index f8aa914b..63f79a98 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -25,8 +25,7 @@ public class Terrain { public Vector2f cell_size = new Vector2f(); public Vector2f cell_count = new Vector2f(); public float terrain_scale; - public Vector2f major_blend = new Vector2f(); - public Vector2f minor_blend = new Vector2f(); + public Vector2f blend_ratio = new Vector2f(); public int heightmap; Zone zone; @@ -65,11 +64,21 @@ public class Terrain { // Blending and height scaling configuration - this.major_blend.x = this.zone.max_blend / this.zone.major_radius; - this.major_blend.y = this.zone.min_blend / this.zone.major_radius; + Vector2f major_blend = new Vector2f(this.zone.max_blend / this.zone.major_radius, + this.zone.min_blend / this.zone.major_radius); - this.minor_blend.x = this.zone.max_blend / this.zone.minor_radius; - this.minor_blend.y = this.zone.min_blend / this.zone.minor_radius; + Vector2f minor_blend = new Vector2f(this.zone.max_blend / this.zone.minor_radius, + this.zone.min_blend / this.zone.minor_radius); + + if (major_blend.y > 0.4f) + blend_ratio.x = major_blend.y; + else + blend_ratio.x = Math.min(major_blend.x, 0.4f); + + if (minor_blend.y > 0.4f) + blend_ratio.y = minor_blend.y; + else + blend_ratio.y = Math.min(minor_blend.x, 0.4f); this.terrain_scale = this.zone.terrain_max_y / 255f; } @@ -123,10 +132,10 @@ public class Terrain { // Blend between terrains - float blendFactor = terrainZone.terrain.terrainBlend(terrainOffset); + float blendCoefficient = terrainZone.terrain.getTerrainBlendCoefficient(terrainOffset); - float terrainHeight = interpolatedChildHeight * blendFactor; - terrainHeight += interpolatedParentTerrainHeight * (1 - blendFactor); + float terrainHeight = interpolatedChildHeight * blendCoefficient; + terrainHeight += interpolatedParentTerrainHeight * (1 - blendCoefficient); return terrainHeight; @@ -136,9 +145,6 @@ public class Terrain { Zone currentZone = ZoneManager.findSmallestZone(world_loc); - if (currentZone == null) - return 0; - return getWorldHeight(currentZone, world_loc); } @@ -188,37 +194,23 @@ public class Terrain { } - public float terrainBlend(Vector2f zone_offset) { + public float getTerrainBlendCoefficient(Vector2f zone_offset) { // Normalize terrain offset Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.major_radius, Math.abs(zone_offset.y) / this.zone.minor_radius); - float xval; - - if (this.major_blend.y > 0.4f) - xval = this.major_blend.y; - else - xval = Math.min(this.major_blend.x, 0.4f); - - float yval; - - if (this.minor_blend.y > 0.4f) - yval = this.minor_blend.y; - else - yval = Math.min(this.minor_blend.x, 0.4f); - float value; - if (normalizedOffset.x <= 1 - xval || normalizedOffset.x <= normalizedOffset.y) { + if (normalizedOffset.x <= 1 - blend_ratio.x || normalizedOffset.x <= normalizedOffset.y) { - if (normalizedOffset.y < 1 - yval) + if (normalizedOffset.y < 1 - blend_ratio.y) return 1; - value = (normalizedOffset.y - (1 - yval)) / yval; + value = (normalizedOffset.y - (1 - blend_ratio.y)) / blend_ratio.y; } else - value = (normalizedOffset.x - (1 - xval)) / xval; + value = (normalizedOffset.x - (1 - blend_ratio.x)) / blend_ratio.x; value = (float) Math.atan((0.5f - value) * PI); diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 8e779a8d..6231f05a 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -60,7 +60,7 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]"); this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); - this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.terrainBlend(childZoneOffset)); + this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset)); this.throwbackInfo(playerCharacter, "------------"); From 274cf08dadfd0c2cff9e8cfca773d504d317a859 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 16:43:20 -0400 Subject: [PATCH 202/289] Comment cleanup --- src/engine/InterestManagement/Terrain.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 63f79a98..b71e89cb 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -62,7 +62,10 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; - // Blending and height scaling configuration + // Blending and height scaling configuration. These rations are used to + // determine whether a location is within the blending area. Can also be + // done with bounding boxes and subtracting two areas but this is the way + // SB modeled things, and we are an SB emulator! Vector2f major_blend = new Vector2f(this.zone.max_blend / this.zone.major_radius, this.zone.min_blend / this.zone.major_radius); From cbd8685d4b91c4ca0bcb8a9351620c59d8046a4d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 16:46:48 -0400 Subject: [PATCH 203/289] Guild zone performance tweak --- src/engine/InterestManagement/Terrain.java | 13 +++++++------ src/engine/util/MapLoader.java | 11 ----------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index b71e89cb..664001dd 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -35,14 +35,10 @@ public class Terrain { this.heightmap = this.zone.terrain_image; // Configure PLANAR zones to use the same 16x16 pixel image - // that all similar terrains share. (See JSON) Guild zones - // use an inverted clone of this heightmap. + // that all similar terrains share. (See JSON) if (this.zone.terrain_type.equals("PLANAR")) - if (this.zone.guild_zone) - this.heightmap = 1006301; // all 255 - else - this.heightmap = 1006300; // all 0 + this.heightmap = 1006301; // all 255 // Load pixel data for this terrain from cache @@ -170,6 +166,11 @@ public class Terrain { float interpolatedHeight; + // Early exit for guild zones + + if (this.zone.guild_zone) + return 5.0f; + Vector2f terrain_cell = getTerrainCell(terrain_loc); int pixel_x = (int) Math.floor(terrain_cell.x); diff --git a/src/engine/util/MapLoader.java b/src/engine/util/MapLoader.java index 312b5ffc..779080bd 100644 --- a/src/engine/util/MapLoader.java +++ b/src/engine/util/MapLoader.java @@ -18,7 +18,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.stream.Stream; public enum MapLoader { @@ -138,16 +137,6 @@ public enum MapLoader { }); // Try with resources block - // Generate full white alternate to 1600300 - // Declare and initialize an array of short[16][16] - - short[][] heightMapEntry = new short[16][16]; - - for (short[] shorts : heightMapEntry) - Arrays.fill(shorts, (short) 255); - - Terrain._heightmap_pixel_cache.put(1006301, heightMapEntry); - } catch (IOException e) { Logger.error(e); } From f9d2232a9b8a063964d1a8de2a6628c846760aec Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 17:22:05 -0400 Subject: [PATCH 204/289] Comment cleanup --- src/engine/InterestManagement/Terrain.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 664001dd..4b9f7cac 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -38,7 +38,7 @@ public class Terrain { // that all similar terrains share. (See JSON) if (this.zone.terrain_type.equals("PLANAR")) - this.heightmap = 1006301; // all 255 + this.heightmap = 1006301; // all 0 // Load pixel data for this terrain from cache @@ -58,10 +58,9 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; - // Blending and height scaling configuration. These rations are used to - // determine whether a location is within the blending area. Can also be - // done with bounding boxes and subtracting two areas but this is the way - // SB modeled things, and we are an SB emulator! + // Blending and height scaling configuration. These ratios are used to + // determine the blending area between child and parent terrains when + // they are stitched together. Vector2f major_blend = new Vector2f(this.zone.max_blend / this.zone.major_radius, this.zone.min_blend / this.zone.major_radius); From 80799753be4705a9b80e628558284aaf688eebd8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 17:23:16 -0400 Subject: [PATCH 205/289] Comment cleanup --- src/engine/InterestManagement/Terrain.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 4b9f7cac..d6d2ee7e 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -58,8 +58,8 @@ public class Terrain { this.cell_size.x = terrain_size.x / this.cell_count.x; this.cell_size.y = terrain_size.y / this.cell_count.y; - // Blending and height scaling configuration. These ratios are used to - // determine the blending area between child and parent terrains when + // Blending configuration. These ratios are used to calculate + // the blending area between child and parent terrains when // they are stitched together. Vector2f major_blend = new Vector2f(this.zone.max_blend / this.zone.major_radius, @@ -78,6 +78,8 @@ public class Terrain { else blend_ratio.y = Math.min(minor_blend.x, 0.4f); + // Scale coefficient for this terrain + this.terrain_scale = this.zone.terrain_max_y / 255f; } From 928be0facb3d0d4b24ca97baff6a8497056b30a8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 17:28:20 -0400 Subject: [PATCH 206/289] Named for context --- src/engine/InterestManagement/Terrain.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index d6d2ee7e..36644ae4 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -206,19 +206,19 @@ public class Terrain { Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.major_radius, Math.abs(zone_offset.y) / this.zone.minor_radius); - float value; + float blendCoefficient; if (normalizedOffset.x <= 1 - blend_ratio.x || normalizedOffset.x <= normalizedOffset.y) { if (normalizedOffset.y < 1 - blend_ratio.y) return 1; - value = (normalizedOffset.y - (1 - blend_ratio.y)) / blend_ratio.y; + blendCoefficient = (normalizedOffset.y - (1 - blend_ratio.y)) / blend_ratio.y; } else - value = (normalizedOffset.x - (1 - blend_ratio.x)) / blend_ratio.x; + blendCoefficient = (normalizedOffset.x - (1 - blend_ratio.x)) / blend_ratio.x; - value = (float) Math.atan((0.5f - value) * PI); + blendCoefficient = (float) Math.atan((0.5f - blendCoefficient) * PI); - return (value + 1) * 0.5f; + return (blendCoefficient + 1) * 0.5f; } } From 610de198e969e62d4305ccbbecc5b9fc36bbdfd4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 15 Oct 2023 17:39:02 -0400 Subject: [PATCH 207/289] All 0 heightmap for PLANAR --- src/engine/InterestManagement/Terrain.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 36644ae4..16a6a4a2 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -38,7 +38,7 @@ public class Terrain { // that all similar terrains share. (See JSON) if (this.zone.terrain_type.equals("PLANAR")) - this.heightmap = 1006301; // all 0 + this.heightmap = 1006300; // all 0 // Load pixel data for this terrain from cache From 6f990d488f339b89b549cf1cf8a4b2643a21e8e0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 13:41:18 -0500 Subject: [PATCH 208/289] region assignment in AbstractCharacter.setLoc --- src/engine/objects/AbstractCharacter.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 7834b0cb..f778755a 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -12,6 +12,7 @@ package engine.objects; import engine.Enum; import engine.Enum.*; import engine.InterestManagement.InterestManager; +import engine.InterestManagement.Terrain; import engine.InterestManagement.WorldGrid; import engine.exception.SerializationException; import engine.gameManager.*; @@ -985,11 +986,22 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { Regions region = Regions.GetRegionForTeleport(value); + float regionHeightOffset = 0; if(region != null){ this.region = region; - } - - super.setLoc(value); // set the location in the world + regionHeightOffset = region.lerpY(this); + this.inBuilding = region.level; // -1 not in building 0 on ground floor, 1 on first floor etc + this.inBuildingID = region.parentBuildingID; + this.inFloorID = region.room; + } else { + this.region = null; + this.inBuilding = -1; + this.inBuildingID = 0; + this.inFloorID = -1; + } + float terrainHeight = Terrain.getWorldHeight(value); + Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z); + super.setLoc(finalLocation); // set the location in the world this.resetLastSetLocUpdate(); } From e3d6a325543f272f6e0e84d74b6be83b32161924 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 14:02:48 -0500 Subject: [PATCH 209/289] 1 second delay for mob movements --- src/engine/mobileAI/MobAI.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 38864cac..4b7a14ef 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -721,6 +721,14 @@ public class MobAI { try { + if(mob.getTimestamps().containsKey("lastChase") == false) { + mob.getTimestamps().put("lastChase", System.currentTimeMillis()); + return;//ensure mob timestamps have the lastChase parameter + } + + if(mob.getTimestamps().get("lastChase") + 1000 < System.currentTimeMillis()) + return; // only allows mobs to chase once a second + if (!MovementUtilities.canMove(mob)) return; From 5ed7662798f057c6886c5a6a83c44932f074036c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 14:13:33 -0500 Subject: [PATCH 210/289] 1 second delay for mob movements --- src/engine/mobileAI/MobAI.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 4b7a14ef..2b9ae40a 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -722,8 +722,7 @@ public class MobAI { try { if(mob.getTimestamps().containsKey("lastChase") == false) { - mob.getTimestamps().put("lastChase", System.currentTimeMillis()); - return;//ensure mob timestamps have the lastChase parameter + mob.getTimestamps().put("lastChase", System.currentTimeMillis());//ensure mob timestamps have the lastChase parameter } if(mob.getTimestamps().get("lastChase") + 1000 < System.currentTimeMillis()) From 1a0fc309f97318d54545af2320ffaddc0095578a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 14:23:18 -0500 Subject: [PATCH 211/289] remove mob movement delay --- src/engine/mobileAI/MobAI.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 2b9ae40a..38864cac 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -721,13 +721,6 @@ public class MobAI { try { - if(mob.getTimestamps().containsKey("lastChase") == false) { - mob.getTimestamps().put("lastChase", System.currentTimeMillis());//ensure mob timestamps have the lastChase parameter - } - - if(mob.getTimestamps().get("lastChase") + 1000 < System.currentTimeMillis()) - return; // only allows mobs to chase once a second - if (!MovementUtilities.canMove(mob)) return; From d506807a8fce68f579c44ac1e712e1d61fc36834 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 14:33:09 -0500 Subject: [PATCH 212/289] 1 second delay for mobs chasing target --- src/engine/mobileAI/MobAI.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 38864cac..911bd375 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -896,6 +896,11 @@ public class MobAI { try { + if(mob.getTimestamps().containsKey("lastChase") == false) + mob.getTimestamps().put("lastChase",System.currentTimeMillis()); + else if(System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + 1000) + return; + if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { if (mob.getRange() > 15) { mob.destination = mob.getCombatTarget().getLoc(); From cb89cc17be8a3e04db49e255127e9c8a1caee875 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 14:37:17 -0500 Subject: [PATCH 213/289] update lastChase timestamp for mobs --- src/engine/mobileAI/MobAI.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 911bd375..5bf35d43 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -901,6 +901,8 @@ public class MobAI { else if(System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + 1000) return; + mob.getTimestamps().put("lastChase",System.currentTimeMillis()); + if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { if (mob.getRange() > 15) { mob.destination = mob.getCombatTarget().getLoc(); From d0374a2deaa1ae369b0eb12e7c4e8cc6d551675c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 15:07:39 -0500 Subject: [PATCH 214/289] random delay between mob chase --- src/engine/mobileAI/MobAI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 5bf35d43..8a925021 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -898,7 +898,7 @@ public class MobAI { if(mob.getTimestamps().containsKey("lastChase") == false) mob.getTimestamps().put("lastChase",System.currentTimeMillis()); - else if(System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + 1000) + else if(System.currentTimeMillis() < mob.getTimestamps().get("lastChase").longValue() + (750 + ThreadLocalRandom.current().nextInt(0,500))) return; mob.getTimestamps().put("lastChase",System.currentTimeMillis()); From f9a3b17677ad752d579c8a738d47bd237ee57d21 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 15:10:09 -0500 Subject: [PATCH 215/289] teleport cleanup --- src/engine/gameManager/MovementManager.java | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index f24ffaf6..516c74e7 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -469,25 +469,8 @@ public enum MovementManager { if (targetLoc == null) return; - - Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc()); - teleporter.stopMovement(targetLoc); - - //mobs ignore region sets for now. - if (teleporter.getObjectType().equals(GameObjectType.Mob)) { - teleporter.setInBuildingID(0); - teleporter.setInBuilding(-1); - teleporter.setInFloorID(-1); - TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); - DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); - return; - } - TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); - //we shouldnt need to send teleport message to new area, as loadjob should pick it up. - // DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - + teleporter.setLoc(targetLoc); if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter)) InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) teleporter); From 7f4d47505e57f11c01308a2bc43e869465b25fc7 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 18:46:44 -0500 Subject: [PATCH 216/289] teleport cleanup --- src/engine/gameManager/MovementManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index 516c74e7..2ef2d5bb 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -470,10 +470,14 @@ public enum MovementManager { if (targetLoc == null) return; teleporter.stopMovement(targetLoc); + Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc()); teleporter.setLoc(targetLoc); if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter)) InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) teleporter); + TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); + DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); + } private static void syncLoc(AbstractCharacter ac, Vector3fImmutable clientLoc, boolean useClientLoc) { From ea6ea4b0ee92f0d8bcc914f77ab9cb5d0277b7fe Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 19:07:34 -0500 Subject: [PATCH 217/289] teleport work --- src/engine/gameManager/MovementManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index 2ef2d5bb..907e5d60 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -475,7 +475,7 @@ public enum MovementManager { if (teleporter.getObjectType().equals(GameObjectType.PlayerCharacter)) InterestManager.INTERESTMANAGER.HandleLoadForTeleport((PlayerCharacter) teleporter); - TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); + TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, teleporter.loc.getX(), teleporter.loc.getY(), teleporter.loc.getZ(), 0, -1, -1); DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); } From 5d4192bbcfe0ee99a2c5ccbcf118bdf97abfaa12 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 16 Oct 2023 19:56:08 -0500 Subject: [PATCH 218/289] add offset for runegate teleport regions --- src/engine/objects/Portal.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Portal.java b/src/engine/objects/Portal.java index f285f45a..2601dc5a 100644 --- a/src/engine/objects/Portal.java +++ b/src/engine/objects/Portal.java @@ -3,6 +3,7 @@ package engine.objects; import engine.Enum; import engine.Enum.PortalType; import engine.InterestManagement.WorldGrid; +import engine.gameManager.BuildingManager; import engine.gameManager.ConfigManager; import engine.job.JobScheduler; import engine.jobs.CloseGateJob; @@ -104,7 +105,7 @@ public class Portal { if (player.getTimeStamp("lastMoveGate") < this.lastActive) return; - player.teleport(targetGate.getLoc()); + player.teleport(targetGate.getLoc().add(0,6,0));//offset height of runegate player.setSafeMode(); } From f1a2bea67c85125dbb4a66d48aad14591683cc61 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 07:56:31 -0400 Subject: [PATCH 219/289] Pixel values are shorts for memory --- src/engine/InterestManagement/Terrain.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 16a6a4a2..1bf98daa 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -172,6 +172,8 @@ public class Terrain { if (this.zone.guild_zone) return 5.0f; + // Determine terrain and offset from top left vertex + Vector2f terrain_cell = getTerrainCell(terrain_loc); int pixel_x = (int) Math.floor(terrain_cell.x); @@ -181,10 +183,10 @@ public class Terrain { // 4 surrounding vertices from the pixel array. - float top_left_pixel = terrain_pixel_data[pixel_x][pixel_y]; - float top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y]; - float bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1]; - float bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; + short top_left_pixel = terrain_pixel_data[pixel_x][pixel_y]; + short top_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y]; + short bottom_left_pixel = terrain_pixel_data[pixel_x][pixel_y + 1]; + short bottom_right_pixel = terrain_pixel_data[pixel_x + 1][pixel_y + 1]; // Interpolate between the 4 vertices From 9d5e16aa5c28367693bfb7214c4d0cc2fcc43660 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 08:28:18 -0400 Subject: [PATCH 220/289] Removed debug command --- src/engine/devcmd/cmds/SeaAuditCmd.java | 43 ----------------------- src/engine/gameManager/DevCmdManager.java | 1 - 2 files changed, 44 deletions(-) delete mode 100644 src/engine/devcmd/cmds/SeaAuditCmd.java diff --git a/src/engine/devcmd/cmds/SeaAuditCmd.java b/src/engine/devcmd/cmds/SeaAuditCmd.java deleted file mode 100644 index ec0e6c96..00000000 --- a/src/engine/devcmd/cmds/SeaAuditCmd.java +++ /dev/null @@ -1,43 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.devcmd.cmds; - -import engine.devcmd.AbstractDevCmd; -import engine.gameManager.ZoneManager; -import engine.objects.AbstractGameObject; -import engine.objects.PlayerCharacter; -import engine.objects.Zone; - -public class SeaAuditCmd extends AbstractDevCmd { - - public SeaAuditCmd() { - super("seaaudit"); - } - - @Override - protected void _doCmd(PlayerCharacter playerCharacter, String[] words, - AbstractGameObject target) { - - for (Zone zone : ZoneManager.getAllZones()) - if (zone.seaLevel > zone.global_height) - this.throwbackInfo(playerCharacter, zone.getObjectUUID() + zone.zoneName); - } - - @Override - protected String _getHelpString() { - return "Queries heightmap engine"; - } - - @Override - protected String _getUsageString() { - return "' /getheight"; - } - -} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index b6334361..52c730b6 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -144,7 +144,6 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new ApplyBonusCmd()); DevCmdManager.registerDevCmd(new AuditFailedItemsCmd()); DevCmdManager.registerDevCmd(new SlotTestCmd()); - DevCmdManager.registerDevCmd(new SeaAuditCmd()); } private static void registerDevCmd(AbstractDevCmd cmd) { From 34024c9fb48a940181cf014954d9dfad74153163 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 08:45:33 -0400 Subject: [PATCH 221/289] New handlers created --- src/engine/db/handlers/dbCityHandler.java | 17 +++++++++++++++++ src/engine/db/handlers/dbMobHandler.java | 17 +++++++++++++++++ src/engine/db/handlers/dbNPCHandler.java | 17 +++++++++++++++++ src/engine/db/handlers/dbZoneHandler.java | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/src/engine/db/handlers/dbCityHandler.java b/src/engine/db/handlers/dbCityHandler.java index bf3d9d98..bf3cd67b 100644 --- a/src/engine/db/handlers/dbCityHandler.java +++ b/src/engine/db/handlers/dbCityHandler.java @@ -96,6 +96,23 @@ public class dbCityHandler extends dbHandlerBase { return objectList; } + public ArrayList GET_ALL_CITIES() { + + ArrayList cityList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + cityList = getObjectsFromRs(rs, 100); + + } catch (SQLException e) { + Logger.error(e); + } + + return cityList; + } + public ArrayList GET_CITIES_BY_ZONE(final int objectUUID) { ArrayList cityList = new ArrayList<>(); diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 862ac29f..4934b6ee 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -65,6 +65,23 @@ public class dbMobHandler extends dbHandlerBase { return mobile; } + public ArrayList GET_ALL_MOBS() { + + ArrayList mobileList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + mobileList = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return mobileList; + } + public boolean updateUpgradeTime(Mob mob, DateTime upgradeDateTime) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 51b20246..f11576ec 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -94,6 +94,23 @@ public class dbNPCHandler extends dbHandlerBase { return row_count; } + public ArrayList GET_ALL_NPCS() { + + ArrayList npcList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + npcList = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return npcList; + } + public ArrayList GET_ALL_NPCS_FOR_ZONE(Zone zone) { ArrayList npcList = new ArrayList<>(); diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 9cceccaa..66b68e69 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -27,6 +27,23 @@ public class dbZoneHandler extends dbHandlerBase { this.localObjectType = Enum.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public ArrayList GET_ALL_ZONES() { + + ArrayList zoneList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + zoneList = getObjectsFromRs(rs, 2000); + + } catch (SQLException e) { + Logger.error(e); + } + + return zoneList; + } + public ArrayList GET_ALL_NODES(Zone zone) { ArrayList wsmList = new ArrayList<>(); wsmList.addAll(zone.getNodes()); From f889bcf9271f906abf2b5281a4724b0ceb37533c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 14:43:28 -0400 Subject: [PATCH 222/289] Building handler added --- src/engine/db/handlers/dbBuildingHandler.java | 17 ++ src/engine/net/client/msg/SyncMessage.java | 151 ------------------ src/engine/server/world/WorldServer.java | 61 ------- 3 files changed, 17 insertions(+), 212 deletions(-) delete mode 100644 src/engine/net/client/msg/SyncMessage.java diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 449def09..51bdda4c 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -88,6 +88,23 @@ public class dbBuildingHandler extends dbHandlerBase { return removeFromBuildings(b); } + public ArrayList GET_ALL_BUILDINGS() { + + ArrayList buildings = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` ORDER BY `object`.`UID` ASC;")) { + + ResultSet rs = preparedStatement.executeQuery(); + buildings = getObjectsFromRs(rs, 1000); + + } catch (SQLException e) { + Logger.error(e); + } + + return buildings; + } + public ArrayList GET_ALL_BUILDINGS_FOR_ZONE(Zone zone) { ArrayList buildings = new ArrayList<>(); diff --git a/src/engine/net/client/msg/SyncMessage.java b/src/engine/net/client/msg/SyncMessage.java deleted file mode 100644 index dfe5a150..00000000 --- a/src/engine/net/client/msg/SyncMessage.java +++ /dev/null @@ -1,151 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.net.client.msg; - - -import engine.exception.SerializationException; -import engine.gameManager.BuildingManager; -import engine.gameManager.DbManager; -import engine.gameManager.ZoneManager; -import engine.net.AbstractConnection; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; -import engine.objects.Building; -import engine.objects.Zone; -import org.pmw.tinylog.Logger; - -import java.util.ArrayList; - -public class SyncMessage extends ClientNetMsg { - - private int type; - private int size; - private int pad = 0; - private int objectType; - private int objectUUID; - - /** - * This constructor is used by NetMsgFactory. It attempts to deserialize the - * ByteBuffer into a message. If a BufferUnderflow occurs (based on reading - * past the limit) then this constructor Throws that Exception to the - * caller. - */ - public SyncMessage(AbstractConnection origin, ByteBufferReader reader) { - super(Protocol.CITYASSET, origin, reader); - } - - public SyncMessage() { - super(Protocol.CITYASSET); - } - - /** - * Deserializes the subclass specific items from the supplied NetMsgReader. - */ - @Override - protected void _deserialize(ByteBufferReader reader) { - //none yet - } - - /** - * Serializes the subclass specific items to the supplied NetMsgWriter. - */ - @Override - protected void _serialize(ByteBufferWriter writer) throws SerializationException { - //lets do returns before writing so we don't send improper structures to the client - - Building tol = BuildingManager.getBuilding(this.objectUUID); - - if (tol == null) { - Logger.debug("TOL is null"); - return; - } - Zone zone = ZoneManager.findSmallestZone(tol.getLoc()); - if (zone == null) { - Logger.debug("Zone is null"); - return; - } - ArrayList allCityAssets = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); - - // *** Refactor: collection created but never used? - - ArrayList canProtectAssets = new ArrayList<>(); - - for (Building b : allCityAssets) { - if (b.getBlueprintUUID() != 0) - canProtectAssets.add(b); - } - - // *** Refactor : Not sure what this synch message does - // Get the feeling it should be looping over upgradable - // assets. - writer.putInt(0); - writer.putInt(0); - writer.putInt(this.objectType); - writer.putInt(this.objectUUID); - writer.putInt(allCityAssets.size()); - for (Building b : allCityAssets) { - String name = b.getName(); - // if (name.equals("")) - // name = b.getBuildingSet().getName(); - writer.putInt(b.getObjectType().ordinal()); - writer.putInt(b.getObjectUUID()); - - writer.putString(b.getName()); // Blueprint name? - writer.putString(b.getGuild().getName()); - writer.putInt(20);// \/ Temp \/ - writer.putInt(b.getRank()); - writer.putInt(1); // symbol - writer.putInt(7); //TODO identify these Guild tags?? - writer.putInt(17); - writer.putInt(14); - writer.putInt(14); - writer.putInt(98);// /\ Temp /\ - - } - } - - public int getObjectType() { - return objectType; - } - - public void setObjectType(int value) { - this.objectType = value; - } - - public int getUUID() { - return objectUUID; - - } - - public int getPad() { - return pad; - } - - public void setPad(int value) { - this.pad = value; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } -} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 66088b8b..9b1a09de 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -555,67 +555,6 @@ public class WorldServer { for (Zone zone : rootParent) { ZoneManager.addZone(zone.template, zone); - - //Handle Buildings - - try { - ArrayList bList; - bList = DbManager.BuildingQueries.GET_ALL_BUILDINGS_FOR_ZONE(zone); - - for (Building b : bList) { - - b.setObjectTypeMask(MBServerStatics.MASK_BUILDING); - b.setLoc(b.getLoc()); - } - } catch (Exception e) { - Logger.error(e); - e.printStackTrace(); - } - - //Handle Mobs - - try { - ArrayList mobs; - mobs = DbManager.MobQueries.GET_ALL_MOBS_FOR_ZONE(zone); - - for (Mob m : mobs) { - m.setObjectTypeMask(MBServerStatics.MASK_MOB | m.getTypeMasks()); - m.setLoc(m.getLoc()); - - // Load Minions for Guard Captains here. - - if (m.building != null && m.building.getBlueprint() != null && m.building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK) - DbManager.MobQueries.LOAD_GUARD_MINIONS(m); - } - } catch (Exception e) { - Logger.error(e); - e.printStackTrace(); - } - - //Handle NPCs - - try { - ArrayList npcs; - - // Ignore NPCs on the seafloor (npc guild leaders, etc) - - if (zone.equals(seaFloor)) - continue; - - npcs = DbManager.NPCQueries.GET_ALL_NPCS_FOR_ZONE(zone); - - for (NPC n : npcs) { - n.setObjectTypeMask(MBServerStatics.MASK_NPC); - n.setLoc(n.getLoc()); - } - - } catch (Exception e) { - Logger.error(e); - e.printStackTrace(); - } - //Handle cities - - ZoneManager.loadCities(zone); ZoneManager.populateWorldZones(zone); } From ab17dd08cd1d5343ebb11c7e6618c5df7895f2dc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 14:52:13 -0400 Subject: [PATCH 223/289] Refactor towards new bootstrap system. --- src/engine/server/world/WorldServer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 9b1a09de..e77430e3 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -559,6 +559,11 @@ public class WorldServer { } + DbManager.BuildingQueries.GET_ALL_BUILDINGS(); + DbManager.NPCQueries.GET_ALL_NPCS(); + DbManager.MobQueries.GET_ALL_MOBS(); + DbManager.CityQueries.GET_ALL_CITIES(); + Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); } From 6b3c64faea4a47c1c6208b9084fe89dfba03657b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 15:09:42 -0400 Subject: [PATCH 224/289] Minions loaded for guard captain --- src/engine/objects/Mob.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 222485d5..8f7f2b2d 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1677,10 +1677,13 @@ public class Mob extends AbstractIntelligenceAgent { if (this.getMobBase().enemy.size() > 0) this.enemy.addAll(this.getMobBase().enemy); } + + // Load skills, powers and effects + NPCManager.applyMobbaseEffects(this); NPCManager.applyEquipmentResists(this); NPCManager.applyMobbaseSkill(this); - NPCManager.applyRuneSkills(this,this.getMobBaseID()); + NPCManager.applyRuneSkills(this, this.getMobBaseID()); this.recalculateStats(); this.setHealth(this.healthMax); @@ -1695,6 +1698,11 @@ public class Mob extends AbstractIntelligenceAgent { if (this.agentType.equals(AIAgentType.MOBILE)) NPCManager.AssignPatrolPoints(this); + // Load minions for guard captain. + + if (this.agentType.equals(AIAgentType.GUARDCAPTAIN)) + DbManager.MobQueries.LOAD_GUARD_MINIONS(this); + this.deathTime = 0; } @@ -1732,9 +1740,9 @@ public class Mob extends AbstractIntelligenceAgent { if (!ac.getObjectType().equals(GameObjectType.PlayerCharacter)) return; - if (this.getCombatTarget() == null) { + if (this.getCombatTarget() == null) this.setCombatTarget(ac); - } + } public void setRank(int newRank) { From 694b10d3b2e1fb7bf5dbe4f91a8d6041a57a9422 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 16:32:36 -0400 Subject: [PATCH 225/289] Begin refactor of cities --- src/engine/gameManager/ZoneManager.java | 29 ----- .../client/handlers/PlaceAssetMsgHandler.java | 3 - src/engine/objects/City.java | 121 +++++++++--------- 3 files changed, 61 insertions(+), 92 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index ffd08263..f1606434 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -10,8 +10,6 @@ package engine.gameManager; import engine.Enum; import engine.InterestManagement.Terrain; -import engine.db.archive.CityRecord; -import engine.db.archive.DataWarehouse; import engine.math.Bounds; import engine.math.Vector2f; import engine.math.Vector3f; @@ -424,33 +422,6 @@ public enum ZoneManager { return validLocation; } - public static void loadCities(Zone zone) { - - ArrayList cities = DbManager.CityQueries.GET_CITIES_BY_ZONE(zone.getObjectUUID()); - - for (City city : cities) { - - city.setParent(zone); - city.setObjectTypeMask(MBServerStatics.MASK_CITY); - city.setLoc(city.getLoc()); // huh? - -//not player city, must be npc city.. - - if (!zone.guild_zone) - zone.isNPCCity = true; - - if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (city.getHash() == null)) { - - city.setHash(); - - if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, city.getObjectUUID()) == false) { - CityRecord cityRecord = CityRecord.borrow(city, Enum.RecordEventType.CREATE); - DataWarehouse.pushToWarehouse(cityRecord); - } - } - } - } - public static float calculateGlobalZoneHeight(Zone zone) { float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index c62c7e8c..0d6e0bc8 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -794,9 +794,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { zoneObject.global_height = ZoneManager.calculateGlobalZoneHeight(zoneObject); - cityObject.setParent(zoneObject); - cityObject.setObjectTypeMask(MBServerStatics.MASK_CITY); // *** Refactor : should have it already - //Link the tree of life with the new zone treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING); diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 69ab5aba..9d9037b1 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -48,6 +48,8 @@ public class City extends AbstractWorldObject { public static long lastCityUpdate = 0; public final HashSet _playerMemory = new HashSet<>(); + private final boolean isOpen = false; + private final boolean reverseKOS = false; public java.time.LocalDateTime established; public boolean hasBeenTransfered = false; public LocalDateTime realmTaxDate; @@ -55,7 +57,8 @@ public class City extends AbstractWorldObject { public volatile boolean protectionEnforced = true; public ArrayList cityBarracks; public ArrayList cityOutlaws = new ArrayList<>(); - protected Zone parentZone; + public Zone parentZone; + public int parentZoneUUID; private String cityName; private String motto; private String description; @@ -73,15 +76,12 @@ public class City extends AbstractWorldObject { private boolean forceRename = false; private boolean noTeleport = false; //used by npc cities private boolean noRepledge = false; //used by npc cities - private final boolean isOpen = false; private int treeOfLifeID; private Vector3fImmutable location = Vector3fImmutable.ZERO; - // Players who have entered the city (used for adding and removing affects) private Vector3fImmutable bindLoc; private int warehouseBuildingID = 0; private boolean open = false; - private boolean reverseKOS = false; private String hash; /** @@ -91,6 +91,7 @@ public class City extends AbstractWorldObject { public City(ResultSet rs) throws SQLException { super(rs); try { + this.parentZoneUUID = rs.getInt("parent"); this.cityName = rs.getString("name"); this.motto = rs.getString("motto"); this.isNpc = rs.getByte("isNpc"); @@ -126,7 +127,9 @@ public class City extends AbstractWorldObject { this.location.getY(), this.location.getZ() + this.bindZ); this.radiusType = rs.getInt("radiusType"); + float bindradiustemp = rs.getFloat("bindRadius"); + if (bindradiustemp > 2) bindradiustemp -= 2; @@ -135,30 +138,8 @@ public class City extends AbstractWorldObject { this.forceRename = rs.getInt("forceRename") == 1; this.open = rs.getInt("open") == 1; - if (this.cityName.equals("Perdition") || this.cityName.equals("Bastion")) { - this.noTeleport = true; - this.noRepledge = true; - } else { - this.noTeleport = false; - this.noRepledge = false; - } - this.hash = rs.getString("hash"); - if (this.motto.isEmpty()) { - Guild guild = this.getGuild(); - - if (guild != null && guild.isEmptyGuild() == false) - this.motto = guild.getMotto(); - } - - Zone zone = ZoneManager.getZoneByUUID(rs.getInt("parent")); - - if (zone != null) - setParent(zone); - - //npc cities without heightmaps except swampstone are specials. - this.realmID = rs.getInt("realmID"); } catch (Exception e) { @@ -567,30 +548,6 @@ public class City extends AbstractWorldObject { return this.parentZone; } - public void setParent(Zone zone) { - - try { - - - this.parentZone = zone; - this.location = new Vector3fImmutable(zone.absX, zone.absY, zone.absZ); - this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, - this.location.y, - this.location.z + this.bindZ); - - // set city bounds - - Bounds cityBounds = Bounds.borrow(); - cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city. - new Vector2f(Enum.CityBoundsType.GRID.halfExtents, Enum.CityBoundsType.GRID.halfExtents), - 0.0f); - this.setBounds(cityBounds); - - } catch (Exception e) { - Logger.error(e); - } - } - public AbstractCharacter getOwner() { if (this.getTOL() == null) @@ -720,9 +677,31 @@ public class City extends AbstractWorldObject { @Override public void runAfterLoad() { - // Set city bounds - // *** Note: Moved to SetParent() - // for some undocumented reason + this.setObjectTypeMask(MBServerStatics.MASK_CITY); + + // Set parent + + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); + + // If it's not a player city then must be an NPC city + + if (!parentZone.guild_zone) + parentZone.isNPCCity = true; + + // Set location for this city + + this.location = new Vector3fImmutable(this.parentZone.absX, this.parentZone.absY, this.parentZone.absZ); + this.bindLoc = new Vector3fImmutable(this.location.x + this.bindX, + this.location.y, + this.location.z + this.bindZ); + + // set city bounds + + Bounds cityBounds = Bounds.borrow(); + cityBounds.setBounds(new Vector2f(this.location.x + 64, this.location.z + 64), // location x and z are offset by 64 from the center of the city. + new Vector2f(Enum.CityBoundsType.GRID.halfExtents, Enum.CityBoundsType.GRID.halfExtents), + 0.0f); + this.setBounds(cityBounds); // Set city motto to current guild motto @@ -749,8 +728,10 @@ public class City extends AbstractWorldObject { for (Guild sub : this.getGuild().getSubGuildList()) { if ((sub.getGuildState() == GuildState.Protectorate) || - (sub.getGuildState() == GuildState.Province)) + (sub.getGuildState() == GuildState.Province)) { this.isCapital = 1; + break; + } } ArrayList guildList = Guild.GuildRoster(this.getGuild()); @@ -758,6 +739,26 @@ public class City extends AbstractWorldObject { this.population = guildList.size(); } + if (this.cityName.equals("Perdition") || this.cityName.equals("Bastion")) { + this.noTeleport = true; + this.noRepledge = true; + } else { + this.noTeleport = false; + this.noRepledge = false; + } + + // Add city entry to data warehouse if newly created + + if ((ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER)) && (this.getHash() == null)) { + + this.setHash(); + + if (DataWarehouse.recordExists(Enum.DataRecordType.CITY, this.getObjectUUID()) == false) { + CityRecord cityRecord = CityRecord.borrow(this, Enum.RecordEventType.CREATE); + DataWarehouse.pushToWarehouse(cityRecord); + } + } + // Banes are loaded for this city from the database at this point if (this.getBane() == null) @@ -765,12 +766,12 @@ public class City extends AbstractWorldObject { // if this city is baned, add the siege effect - try { - this.getTOL().addEffectBit((1 << 16)); - this.getBane().getStone().addEffectBit((1 << 19)); - } catch (Exception e) { - Logger.info("Failed ao add bane effects on city." + e.getMessage()); - } + this.getTOL().addEffectBit((1 << 16)); + this.getBane().getStone().addEffectBit((1 << 19)); + + // Spawn city + + this.setLoc(this.getLoc()); } public void addCityEffect(EffectsBase effectBase, int rank) { From 9392ceda61f58d149bf368a82b7cbcd401012dae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 17 Oct 2023 17:07:52 -0400 Subject: [PATCH 226/289] Comment cleanup --- src/engine/objects/City.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 9d9037b1..9bca4b2c 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -703,7 +703,7 @@ public class City extends AbstractWorldObject { 0.0f); this.setBounds(cityBounds); - // Set city motto to current guild motto + // Sanity check; no tol if (BuildingManager.getBuilding(this.treeOfLifeID) == null) Logger.info("City UID " + this.getObjectUUID() + " Failed to Load Tree of Life with ID " + this.treeOfLifeID); @@ -719,6 +719,8 @@ public class City extends AbstractWorldObject { Logger.error("Unable to find realm of ID " + realmID + " for city " + this.getObjectUUID()); } + // Set city motto to current guild motto + if (this.getGuild() != null) { this.motto = this.getGuild().getMotto(); From da327659022a0dbcc06303e1c3bfe93e8c27f74e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 08:03:47 -0400 Subject: [PATCH 227/289] Change to AWO --- src/engine/objects/Zone.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 60ee12c0..a63ac369 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -28,7 +28,7 @@ import java.util.Collections; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -public class Zone extends AbstractGameObject { +public class Zone extends AbstractWorldObject { public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); @@ -128,8 +128,8 @@ public class Zone extends AbstractGameObject { this.max_level = parentZone.max_level; } - if (parentZone != null) - parentZone.addNode(this); + if (parentZone != null) + parentZone.addNode(this); // If zone doesn't yet hava a hash then write it back to the zone table @@ -138,6 +138,11 @@ public class Zone extends AbstractGameObject { } + @Override + public void runAfterLoad() { + + } + public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { if (zone.template == 0 && zone.playerCityUUID == 0) From e689cb541a48de55c9df792b7c17b21f69cf5f6f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 08:25:05 -0400 Subject: [PATCH 228/289] Refactored Zone to new system --- src/engine/gameManager/ZoneManager.java | 25 ++---- .../client/handlers/PlaceAssetMsgHandler.java | 1 - src/engine/objects/Zone.java | 81 ++++++++++--------- src/engine/server/world/WorldServer.java | 25 +----- 4 files changed, 53 insertions(+), 79 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index f1606434..1ca43c33 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -101,16 +101,6 @@ public enum ZoneManager { return zone; } - public static void addZone(final int zoneID, final Zone zone) { - - ZoneManager.zonesByID.put(zoneID, zone); - - ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone); - - ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone); - - } - // Returns the number of available hotZones // remaining in this cycle (1am) @@ -173,24 +163,23 @@ public enum ZoneManager { return (Bounds.collide(loc, ZoneManager.hotZone.bounds)); } - public static void setSeaFloor(final Zone value) { - ZoneManager.seaFloor = value; - } - - public static void populateWorldZones(final Zone zone) { - - int loadNum = zone.template; + public static void populateZoneCollections(final Zone zone) { // Zones are added to separate // collections for quick access // based upon their type. + ZoneManager.zonesByID.put(zone.template, zone); + + ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone); + + ZoneManager.zonesByName.put(zone.zoneName.toLowerCase(), zone); + if (zone.isMacroZone()) { addMacroZone(zone); return; } - if (zone.guild_zone) { addPlayerCityZone(zone); return; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 0d6e0bc8..1f40da87 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -788,7 +788,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (zoneObject.parent != null) zoneObject.parent.addNode(zoneObject); //add as child to parent - ZoneManager.addZone(zoneObject.getObjectUUID(), zoneObject); ZoneManager.addPlayerCityZone(zoneObject); serverZone.addNode(zoneObject); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index a63ac369..9b5e62ea 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -94,42 +94,26 @@ public class Zone extends AbstractWorldObject { this.icon3 = rs.getString("icon3"); this.min_level = rs.getInt("min_level"); this.max_level = rs.getInt("max_level"); - this.major_radius = rs.getFloat("major_radius"); - this.minor_radius = rs.getFloat("minor_radius"); - this.min_blend = rs.getFloat("min_blend"); - this.max_blend = rs.getFloat("max_blend"); - this.sea_level_type = rs.getString("sea_level_type"); - this.sea_level_offset = rs.getFloat("sea_level"); - this.terrain_type = rs.getString("terrain_type"); - this.terrain_max_y = rs.getFloat("terrain_max_y"); - this.terrain_image = rs.getInt("terrain_image"); - - if (this.guild_zone) { - this.max_blend = 128; - this.min_blend = 128; - this.terrain_max_y = 5; - this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.terrain_type = "PLANAR"; - } - - if (this.terrain_type.equals("NONE")) - this.terrain = null; - else - this.terrain = new Terrain(this); - - //this needs to be here specifically for new zones created after server boot (e.g. player city zones) - - Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); - this.setParent(parentZone); - - if (this.min_level == 0 && parentZone != null) { - this.min_level = parentZone.min_level; - this.max_level = parentZone.max_level; - } - - if (parentZone != null) - parentZone.addNode(this); + this.major_radius = rs.getFloat("major_radius"); + this.minor_radius = rs.getFloat("minor_radius"); + this.min_blend = rs.getFloat("min_blend"); + this.max_blend = rs.getFloat("max_blend"); + this.sea_level_type = rs.getString("sea_level_type"); + this.sea_level_offset = rs.getFloat("sea_level"); + this.terrain_type = rs.getString("terrain_type"); + this.terrain_max_y = rs.getFloat("terrain_max_y"); + this.terrain_image = rs.getInt("terrain_image"); + + // Configuration for player cities + + if (this.guild_zone) { + this.max_blend = 128; + this.min_blend = 128; + this.terrain_max_y = 5; + this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + this.terrain_type = "PLANAR"; + } // If zone doesn't yet hava a hash then write it back to the zone table @@ -141,6 +125,31 @@ public class Zone extends AbstractWorldObject { @Override public void runAfterLoad() { + // First zone is always the seafloor + + if (ZoneManager.seaFloor == null) + ZoneManager.seaFloor = this; + + if (this.terrain_type.equals("NONE")) + this.terrain = null; + else + this.terrain = new Terrain(this); + + //this needs to be here specifically for new zones created after server boot (e.g. player city zones) + + Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); + this.setParent(parentZone); + + if (this.min_level == 0 && parentZone != null) { + this.min_level = parentZone.min_level; + this.max_level = parentZone.max_level; + } + + if (parentZone != null) + parentZone.addNode(this); + + ZoneManager.populateZoneCollections(this); + } public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e77430e3..853ac58b 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -533,32 +533,9 @@ public class WorldServer { private void getWorldBuildingsMobsNPCs() { - ArrayList rootParent; - - rootParent = DbManager.ZoneQueries.GET_MAP_NODES(worldUUID); - - if (rootParent.isEmpty()) { - Logger.error("populateWorldBuildings: No entries found in worldMap for parent " + worldUUID); - return; - } - - //Set sea floor object for server - - Zone seaFloor = rootParent.get(0); - seaFloor.setParent(null); - ZoneManager.setSeaFloor(seaFloor); - - rootParent.addAll(DbManager.ZoneQueries.GET_ALL_NODES(seaFloor)); - long start = System.currentTimeMillis(); - for (Zone zone : rootParent) { - - ZoneManager.addZone(zone.template, zone); - ZoneManager.populateWorldZones(zone); - - } - + DbManager.ZoneQueries.GET_ALL_ZONES(); DbManager.BuildingQueries.GET_ALL_BUILDINGS(); DbManager.NPCQueries.GET_ALL_NPCS(); DbManager.MobQueries.GET_ALL_MOBS(); From 5ed21f9b7639248014ba9f2e7031ba15ffccaffd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 08:33:49 -0400 Subject: [PATCH 229/289] Refactored Zone to new system --- src/engine/db/handlers/dbZoneHandler.java | 4 ++-- src/engine/devcmd/cmds/ZoneInfoCmd.java | 2 +- src/engine/gameManager/ZoneManager.java | 6 +++--- src/engine/net/client/msg/WorldDataMsg.java | 13 +++++-------- src/engine/objects/Zone.java | 18 ++---------------- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 66b68e69..1540196a 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -46,7 +46,7 @@ public class dbZoneHandler extends dbHandlerBase { public ArrayList GET_ALL_NODES(Zone zone) { ArrayList wsmList = new ArrayList<>(); - wsmList.addAll(zone.getNodes()); + wsmList.addAll(zone.nodes); if (zone.absX == 0.0f) { zone.absX = zone.xOffset; } @@ -56,7 +56,7 @@ public class dbZoneHandler extends dbHandlerBase { if (zone.absZ == 0.0f) { zone.absZ = zone.zOffset; } - for (Zone child : zone.getNodes()) { + for (Zone child : zone.nodes) { child.absX = child.xOffset + zone.absX; child.absY = child.yOffset + zone.absY; child.absZ = child.zOffset + zone.absZ; diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 53e7ac61..05b80230 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -120,7 +120,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { } else { output = "children:"; - ArrayList nodes = zone.getNodes(); + ArrayList nodes = zone.nodes; if (nodes.isEmpty()) output += " none"; diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 1ca43c33..f987c4d1 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -85,7 +85,7 @@ public enum ZoneManager { childFound = false; - ArrayList nodes = zone.getNodes(); + ArrayList nodes = zone.nodes; // Logger.info("soze", "" + nodes.size()); if (nodes != null) @@ -239,7 +239,7 @@ public enum ZoneManager { if (zone.peace_zone == (byte) 1) return false; // no safe zone hotzones// if (this.hotzone == null) - if (zone.getNodes().isEmpty()) + if (zone.nodes.isEmpty()) return false; if (zone.equals(ZoneManager.seaFloor)) @@ -396,7 +396,7 @@ public enum ZoneManager { treeBounds = Bounds.borrow(); treeBounds.setBounds(new Vector2f(positionX, positionZ), new Vector2f(Enum.CityBoundsType.PLACEMENT.halfExtents, Enum.CityBoundsType.PLACEMENT.halfExtents), 0.0f); - zoneList = currentZone.getNodes(); + zoneList = currentZone.nodes; for (Zone zone : zoneList) { diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index d18178e7..b24c1cf3 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -10,8 +10,10 @@ package engine.net.client.msg; +import engine.Enum; import engine.exception.SerializationException; import engine.gameManager.ConfigManager; +import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.net.AbstractConnection; import engine.net.AbstractNetMsg; @@ -44,14 +46,9 @@ public class WorldDataMsg extends ClientNetMsg { super(Protocol.NEWWORLD, origin, reader); } - private static int getTotalMapSize(Zone root) { - if (root.getNodes().isEmpty()) - return 0; + private static int getTotalMapSize() { - int size = root.getNodes().size(); - for (Zone child : root.getNodes()) - size += getTotalMapSize(child); - return size; + return DbManager.getList(Enum.GameObjectType.Zone).size(); } /** @@ -86,7 +83,7 @@ public class WorldDataMsg extends ClientNetMsg { writer.putInt(WorldServer.worldMapID); writer.putInt(0x00000000); - writer.putInt(getTotalMapSize(root) + 1); + writer.putInt(getTotalMapSize() + 1); Zone.serializeForClientMsg(root, writer); Zone hotzone = ZoneManager.hotZone; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 9b5e62ea..07cd5730 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -12,7 +12,6 @@ package engine.objects; import engine.Enum; import engine.InterestManagement.Terrain; import engine.db.archive.DataWarehouse; -import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.math.Bounds; import engine.math.Vector2f; @@ -292,19 +291,6 @@ public class Zone extends AbstractWorldObject { return this.parentZoneID; } - public ArrayList getNodes() { - - if (this.nodes == null) { - this.nodes = DbManager.ZoneQueries.GET_MAP_NODES(super.getObjectUUID()); - - //Add reverse lookup for child->parent - if (this.nodes != null) - for (Zone zone : this.nodes) - zone.setParent(this); - } - return nodes; - } - /* * Serializing */ @@ -323,10 +309,10 @@ public class Zone extends AbstractWorldObject { if (this.equals(ZoneManager.seaFloor)) return false; - if (this.getNodes().isEmpty()) + if (this.nodes.isEmpty()) return false; - if (this.getNodes().get(0).isMacroZone()) + if (this.nodes.get(0).isMacroZone()) return true; return this.parent.equals(ZoneManager.seaFloor); From bf06734a9b9d714a891b0f012b651de0c02c3f73 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 08:42:40 -0400 Subject: [PATCH 230/289] Refactored Zone to new system --- src/engine/objects/Zone.java | 96 +++++++++++++++++------------------- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 07cd5730..ac31e776 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -29,6 +29,8 @@ import java.util.concurrent.ConcurrentHashMap; public class Zone extends AbstractWorldObject { + public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); + public static long lastRespawn = 0; public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); @@ -58,8 +60,6 @@ public class Zone extends AbstractWorldObject { public float global_height = 0; public float seaLevel = 0f; public float sea_level_offset = 0; - public static final Set respawnQue = Collections.newSetFromMap(new ConcurrentHashMap<>()); - public static long lastRespawn = 0; public float major_radius; public float minor_radius; public float min_blend; @@ -79,20 +79,20 @@ public class Zone extends AbstractWorldObject { super(rs); - this.parentZoneID = rs.getInt("parent"); - this.playerCityUUID = rs.getInt("playerCityUUID"); - this.guild_zone = this.playerCityUUID != 0; - this.zoneName = rs.getString("zone_name"); - this.xOffset = rs.getFloat("xOffset"); - this.zOffset = rs.getFloat("zOffset"); - this.yOffset = rs.getFloat("yOffset"); - this.template = rs.getInt("template"); - this.peace_zone = rs.getByte("peace_zone"); - this.icon1 = rs.getString("icon1"); - this.icon2 = rs.getString("icon2"); - this.icon3 = rs.getString("icon3"); - this.min_level = rs.getInt("min_level"); - this.max_level = rs.getInt("max_level"); + this.parentZoneID = rs.getInt("parent"); + this.playerCityUUID = rs.getInt("playerCityUUID"); + this.guild_zone = this.playerCityUUID != 0; + this.zoneName = rs.getString("zone_name"); + this.xOffset = rs.getFloat("xOffset"); + this.zOffset = rs.getFloat("zOffset"); + this.yOffset = rs.getFloat("yOffset"); + this.template = rs.getInt("template"); + this.peace_zone = rs.getByte("peace_zone"); + this.icon1 = rs.getString("icon1"); + this.icon2 = rs.getString("icon2"); + this.icon3 = rs.getString("icon3"); + this.min_level = rs.getInt("min_level"); + this.max_level = rs.getInt("max_level"); this.major_radius = rs.getFloat("major_radius"); this.minor_radius = rs.getFloat("minor_radius"); this.min_blend = rs.getFloat("min_blend"); @@ -121,36 +121,6 @@ public class Zone extends AbstractWorldObject { } - @Override - public void runAfterLoad() { - - // First zone is always the seafloor - - if (ZoneManager.seaFloor == null) - ZoneManager.seaFloor = this; - - if (this.terrain_type.equals("NONE")) - this.terrain = null; - else - this.terrain = new Terrain(this); - - //this needs to be here specifically for new zones created after server boot (e.g. player city zones) - - Zone parentZone = ZoneManager.getZoneByUUID(parentZoneID); - this.setParent(parentZone); - - if (this.min_level == 0 && parentZone != null) { - this.min_level = parentZone.min_level; - this.max_level = parentZone.max_level; - } - - if (parentZone != null) - parentZone.addNode(this); - - ZoneManager.populateZoneCollections(this); - - } - public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { if (zone.template == 0 && zone.playerCityUUID == 0) @@ -204,6 +174,30 @@ public class Zone extends AbstractWorldObject { } } + @Override + public void runAfterLoad() { + + // First zone is always the seafloor + + if (ZoneManager.seaFloor == null) + ZoneManager.seaFloor = this; + + if (this.terrain_type.equals("NONE")) + this.terrain = null; + else + this.terrain = new Terrain(this); + + this.setParent(); + + if (this.min_level == 0 && this.parent != null) { + this.min_level = this.parent.min_level; + this.max_level = this.parent.max_level; + } + + ZoneManager.populateZoneCollections(this); + + } + /* Method sets a default value for player cities * otherwise using values derived from the loadnum * field in the obj_zone database table. @@ -217,14 +211,13 @@ public class Zone extends AbstractWorldObject { } - public void setParent(final Zone value) { + public void setParent() { - this.parent = value; - this.parentZoneID = (this.parent != null) ? this.parent.getObjectUUID() : 0; + this.parent = ZoneManager.getZoneByZoneID(parentZoneID); // Seafloor - if (this.parent == null) { + if (ZoneManager.seaFloor.equals(this)) { this.absX = this.xOffset; this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE; this.global_height = MBServerStatics.SEA_FLOOR_ALTITUDE; @@ -274,7 +267,7 @@ public class Zone extends AbstractWorldObject { // Macro zones have icons. - if (this.guild_zone == true) + if (this.guild_zone) return false; if (this.parent == null) @@ -318,6 +311,7 @@ public class Zone extends AbstractWorldObject { return this.parent.equals(ZoneManager.seaFloor); } + public void setHash() { this.hash = DataWarehouse.hasher.encrypt(this.getObjectUUID()); From e1add3c7e61f69b2a4cebf30fc22c9d3f136e299 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 08:51:46 -0400 Subject: [PATCH 231/289] Refactored Zone to new system --- src/engine/objects/Zone.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index ac31e776..69b11b0c 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -213,7 +213,7 @@ public class Zone extends AbstractWorldObject { public void setParent() { - this.parent = ZoneManager.getZoneByZoneID(parentZoneID); + this.parent = ZoneManager.getZoneByUUID(parentZoneID); // Seafloor From ff1c0bd3470a7892a50f4b2dc564c4580af695d6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 09:08:41 -0400 Subject: [PATCH 232/289] Refactored Zone to new system --- src/engine/gameManager/ZoneManager.java | 4 ++-- src/engine/objects/Zone.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index f987c4d1..5d79ee2b 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -239,10 +239,10 @@ public enum ZoneManager { if (zone.peace_zone == (byte) 1) return false; // no safe zone hotzones// if (this.hotzone == null) - if (zone.nodes.isEmpty()) + if (zone.equals(ZoneManager.seaFloor)) return false; - if (zone.equals(ZoneManager.seaFloor)) + if (zone.nodes.isEmpty()) return false; //no duplicate hotZones diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 69b11b0c..49415c24 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -50,7 +50,7 @@ public class Zone extends AbstractWorldObject { public int min_level; public int max_level; public boolean hasBeenHotzone = false; - public ArrayList nodes = null; + public ArrayList nodes = new ArrayList<>(); public int parentZoneID; public Zone parent = null; public Bounds bounds; From ee4009bf8dff7f3c5ac535a4fd8f5853862af168 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 09:13:11 -0400 Subject: [PATCH 233/289] Refactored Zone to new system --- src/engine/objects/Zone.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 49415c24..207cff18 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -215,6 +215,9 @@ public class Zone extends AbstractWorldObject { this.parent = ZoneManager.getZoneByUUID(parentZoneID); + if (parent != null) + parent.addNode(this); + // Seafloor if (ZoneManager.seaFloor.equals(this)) { From 77cc91319a2d085d40d5bef7f93147dbb7dd712b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 09:22:54 -0400 Subject: [PATCH 234/289] Refactored Zone to new system --- src/engine/net/client/msg/WorldDataMsg.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index b24c1cf3..5d2feff2 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -83,7 +83,7 @@ public class WorldDataMsg extends ClientNetMsg { writer.putInt(WorldServer.worldMapID); writer.putInt(0x00000000); - writer.putInt(getTotalMapSize() + 1); + writer.putInt(getTotalMapSize()); Zone.serializeForClientMsg(root, writer); Zone hotzone = ZoneManager.hotZone; From 9ee60c936186e08ddc722d1cd4c7e00ce53e903b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 09:24:56 -0400 Subject: [PATCH 235/289] Refactored Zone to new system --- src/engine/net/client/msg/WorldDataMsg.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index 5d2feff2..6826d6f6 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -87,7 +87,6 @@ public class WorldDataMsg extends ClientNetMsg { Zone.serializeForClientMsg(root, writer); Zone hotzone = ZoneManager.hotZone; - ; if (hotzone == null) writer.putLong(0L); @@ -96,7 +95,6 @@ public class WorldDataMsg extends ClientNetMsg { writer.putInt(hotzone.getObjectUUID()); } - writer.putFloat(0); writer.putFloat(1); writer.putFloat(0); From 4d290c90646bcdd8e8d7013a948be9cb35f35fa2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 09:38:19 -0400 Subject: [PATCH 236/289] Refactored city planting to use new system. --- src/engine/gameManager/ZoneManager.java | 7 +---- .../client/handlers/PlaceAssetMsgHandler.java | 26 +++++-------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 5d79ee2b..a4e4ebf1 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -181,7 +181,7 @@ public enum ZoneManager { } if (zone.guild_zone) { - addPlayerCityZone(zone); + ZoneManager.playerCityZones.add(zone); return; } @@ -199,11 +199,6 @@ public enum ZoneManager { ZoneManager.npcCityZones.add(zone); } - public static final void addPlayerCityZone(final Zone zone) { - zone.guild_zone = true; - ZoneManager.playerCityZones.add(zone); - } - public static final void generateAndSetRandomHotzone() { Zone hotZone; diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 1f40da87..79f9eb10 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -780,33 +780,19 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { playerNation = playerCharacter.getGuild(); playerNation.setGuildState(GuildState.Sovereign); - // Link the zone with the city and then add - // to the appropriate hash tables and cache - - zoneObject.guild_zone = true; - - if (zoneObject.parent != null) - zoneObject.parent.addNode(zoneObject); //add as child to parent - - ZoneManager.addPlayerCityZone(zoneObject); - serverZone.addNode(zoneObject); - - zoneObject.global_height = ZoneManager.calculateGlobalZoneHeight(zoneObject); - - //Link the tree of life with the new zone + // Update guild binds and tags - treeObject.setObjectTypeMask(MBServerStatics.MASK_BUILDING); - treeObject.setParentZone(zoneObject); - MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7)); + GuildManager.updateAllGuildBinds(playerNation, cityObject); + GuildManager.updateAllGuildTags(playerNation); - // Update guild binds and tags //load the new city on the clients CityZoneMsg czm = new CityZoneMsg(1, treeObject.getLoc().x, treeObject.getLoc().y, treeObject.getLoc().z, cityObject.getCityName(), zoneObject, Enum.CityBoundsType.ZONE.halfExtents, Enum.CityBoundsType.ZONE.halfExtents); DispatchMessage.dispatchMsgToAll(czm); - GuildManager.updateAllGuildBinds(playerNation, cityObject); - GuildManager.updateAllGuildTags(playerNation); + // Set maintenance date + + MaintenanceManager.setMaintDateTime(treeObject, LocalDateTime.now().plusDays(7)); // Send all the cities to the clients? // *** Refactor : figure out how to send like, one? From 89cb8084816525e705f1732a303b88daf6077410 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 10:23:35 -0400 Subject: [PATCH 237/289] Removed old handlers --- src/engine/db/handlers/dbBuildingHandler.java | 19 ------------------ src/engine/db/handlers/dbCityHandler.java | 19 ------------------ src/engine/db/handlers/dbMobHandler.java | 20 ------------------- src/engine/db/handlers/dbNPCHandler.java | 20 ------------------- 4 files changed, 78 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 51bdda4c..0c88a5d6 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -105,25 +105,6 @@ public class dbBuildingHandler extends dbHandlerBase { return buildings; } - public ArrayList GET_ALL_BUILDINGS_FOR_ZONE(Zone zone) { - - ArrayList buildings = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_building`.*, `object`.`parent` FROM `object` INNER JOIN `obj_building` ON `obj_building`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) { - - preparedStatement.setLong(1, zone.getObjectUUID()); - - ResultSet rs = preparedStatement.executeQuery(); - buildings = getObjectsFromRs(rs, 1000); - - } catch (SQLException e) { - Logger.error(e); - } - - return buildings; - } - public Building GET_BUILDINGBYUUID(int uuid) { if (uuid == 0) diff --git a/src/engine/db/handlers/dbCityHandler.java b/src/engine/db/handlers/dbCityHandler.java index bf3cd67b..a31b738e 100644 --- a/src/engine/db/handlers/dbCityHandler.java +++ b/src/engine/db/handlers/dbCityHandler.java @@ -113,25 +113,6 @@ public class dbCityHandler extends dbHandlerBase { return cityList; } - public ArrayList GET_CITIES_BY_ZONE(final int objectUUID) { - - ArrayList cityList = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_city`.*, `object`.`parent` FROM `obj_city` INNER JOIN `object` ON `object`.`UID` = `obj_city`.`UID` WHERE `object`.`parent`=?;")) { - - preparedStatement.setLong(1, objectUUID); - - ResultSet rs = preparedStatement.executeQuery(); - cityList = getObjectsFromRs(rs, 100); - - } catch (SQLException e) { - Logger.error(e); - } - - return cityList; - } - public City GET_CITY(final int cityId) { City city = (City) DbManager.getFromCache(Enum.GameObjectType.City, cityId); diff --git a/src/engine/db/handlers/dbMobHandler.java b/src/engine/db/handlers/dbMobHandler.java index 4934b6ee..ad9e0a70 100644 --- a/src/engine/db/handlers/dbMobHandler.java +++ b/src/engine/db/handlers/dbMobHandler.java @@ -11,7 +11,6 @@ package engine.db.handlers; import engine.gameManager.DbManager; import engine.objects.Mob; -import engine.objects.Zone; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -191,25 +190,6 @@ public class dbMobHandler extends dbHandlerBase { } } - public ArrayList GET_ALL_MOBS_FOR_ZONE(Zone zone) { - - ArrayList mobileList = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_mob`.*, `object`.`parent` FROM `object` INNER JOIN `obj_mob` ON `obj_mob`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) { - - preparedStatement.setLong(1, zone.getObjectUUID()); - - ResultSet rs = preparedStatement.executeQuery(); - mobileList = getObjectsFromRs(rs, 1000); - - } catch (SQLException e) { - Logger.error(e); - } - - return mobileList; - } - public Mob GET_MOB(final int objectUUID) { Mob mobile = null; diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index f11576ec..9887c6ed 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -15,7 +15,6 @@ import engine.math.Vector3fImmutable; import engine.objects.NPC; import engine.objects.NPCProfits; import engine.objects.ProducedItem; -import engine.objects.Zone; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -111,25 +110,6 @@ public class dbNPCHandler extends dbHandlerBase { return npcList; } - public ArrayList GET_ALL_NPCS_FOR_ZONE(Zone zone) { - - ArrayList npcList = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_npc`.*, `object`.`parent` FROM `object` INNER JOIN `obj_npc` ON `obj_npc`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) { - - preparedStatement.setLong(1, zone.getObjectUUID()); - - ResultSet rs = preparedStatement.executeQuery(); - npcList = getObjectsFromRs(rs, 1000); - - } catch (SQLException e) { - Logger.error(e); - } - - return npcList; - } - public NPC GET_NPC(final int objectUUID) { NPC npc = null; From 602f8bc84337ce401fc222f3f94f763cb33f2691 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 10:33:58 -0400 Subject: [PATCH 238/289] Cleanup building initialization --- src/engine/db/handlers/dbZoneHandler.java | 40 ------ src/engine/objects/Building.java | 149 ++++++++++------------ 2 files changed, 70 insertions(+), 119 deletions(-) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 1540196a..64b5754f 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -44,27 +44,6 @@ public class dbZoneHandler extends dbHandlerBase { return zoneList; } - public ArrayList GET_ALL_NODES(Zone zone) { - ArrayList wsmList = new ArrayList<>(); - wsmList.addAll(zone.nodes); - if (zone.absX == 0.0f) { - zone.absX = zone.xOffset; - } - if (zone.absY == 0.0f) { - zone.absY = zone.yOffset; - } - if (zone.absZ == 0.0f) { - zone.absZ = zone.zOffset; - } - for (Zone child : zone.nodes) { - child.absX = child.xOffset + zone.absX; - child.absY = child.yOffset + zone.absY; - child.absZ = child.zOffset + zone.absZ; - wsmList.addAll(this.GET_ALL_NODES(child)); - } - return wsmList; - } - public Zone GET_BY_UID(long ID) { Zone zone = (Zone) DbManager.getFromCache(Enum.GameObjectType.Zone, (int) ID); @@ -87,25 +66,6 @@ public class dbZoneHandler extends dbHandlerBase { return zone; } - public ArrayList GET_MAP_NODES(final int objectUUID) { - - ArrayList zoneList = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT `obj_zone`.*, `object`.`parent` FROM `object` INNER JOIN `obj_zone` ON `obj_zone`.`UID` = `object`.`UID` WHERE `object`.`parent` = ?;")) { - - preparedStatement.setLong(1, objectUUID); - - ResultSet rs = preparedStatement.executeQuery(); - zoneList = getObjectsFromRs(rs, 2000); - - } catch (SQLException e) { - Logger.error(e); - } - - return zoneList; - } - public boolean DELETE_ZONE(final Zone zone) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 4d43e1ab..9535411f 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -55,6 +55,7 @@ public class Building extends AbstractWorldObject { private final HashMap doorJobs = new HashMap<>(); public int meshUUID; public Zone parentZone; + public int parentZoneUUID; public boolean reverseKOS; public int reserve = 0; public float statLat; @@ -106,27 +107,23 @@ public class Building extends AbstractWorldObject { super(rs); float scale; - Blueprint blueprint = null; try { this.meshUUID = rs.getInt("meshUUID"); this.setObjectTypeMask(MBServerStatics.MASK_BUILDING); this.blueprintUUID = rs.getInt("blueprintUUID"); this.gridObjectType = GridObjectType.STATIC; - this.parentZone = DbManager.ZoneQueries.GET_BY_UID(rs.getLong("parent")); + this.parentZoneUUID = rs.getInt("parent"); this.name = rs.getString("name"); this.ownerUUID = rs.getInt("ownerUUID"); - - // Orphaned Object Sanity Check - //This was causing ABANDONED Tols. - // if (objectType == DbObjectType.INVALID) - // this.ownerUUID = 0; - this.doorState = rs.getInt("doorState"); this.setHealth(rs.getInt("currentHP")); this.w = rs.getFloat("w"); this.setRot(new Vector3f(0f, rs.getFloat("rotY"), 0f)); - this.reverseKOS = rs.getByte("reverseKOS") == 1 ? true : false; + this.reverseKOS = rs.getByte("reverseKOS") == 1; + this.statLat = rs.getFloat("locationX"); + this.statAlt = rs.getFloat("locationY"); + this.statLon = rs.getFloat("locationZ"); scale = rs.getFloat("scale"); this.meshScale = new Vector3f(scale, scale, scale); @@ -143,79 +140,10 @@ public class Building extends AbstractWorldObject { this.level = rs.getInt("level"); this.isFurniture = (rs.getBoolean("isFurniture")); - // Lookup building blueprint - - if (this.blueprintUUID == 0) - blueprint = Blueprint._meshLookup.get(meshUUID); - else - blueprint = this.getBlueprint(); - - // Log error if something went horrible wrong - - if ((this.blueprintUUID != 0) && (blueprint == null)) - Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); - - // Note: We handle R8 tree edge case for mesh and health - // after city is loaded to avoid recursive result set call - // in City resulting in a stack ovreflow. - - if (blueprint != null) { - - // Only switch mesh for player dropped structures - - if (this.blueprintUUID != 0) - this.meshUUID = blueprint.getMeshForRank(rank); - - this.healthMax = blueprint.getMaxHealth(this.rank); - - // If this object has no blueprint but is a blueprint - // mesh then set it's current health to max health - - if (this.blueprintUUID == 0) - this.setHealth(healthMax); - - if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK)) - this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this); - - } else { - this.healthMax = 100000; // Structures with no blueprint mesh - this.setHealth(healthMax); - } - - // Null out blueprint if not needed (npc building) - - if (blueprintUUID == 0) - blueprint = null; - - resists = new Resists("Building"); - this.statLat = rs.getFloat("locationX"); - this.statAlt = rs.getFloat("locationY"); - this.statLon = rs.getFloat("locationZ"); - - if (this.parentZone != null) { - if (this.parentBuildingID != 0) { - Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); - if (parentBuilding != null) { - this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); - } else { - this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); - - } - } else { - - // Altitude of this building is derived from the heightmap engine. - - Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); - tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); - this.setLoc(tempLoc); - } - } - this._strongboxValue = rs.getInt("currentGold"); this.maxGold = 15000000; // *** Refactor to blueprint method this.reserve = rs.getInt("reserve"); - // Does building have a protection contract? this.taxType = TaxType.valueOf(rs.getString("taxType")); this.taxAmount = rs.getInt("taxAmount"); this.protectionState = ProtectionState.valueOf(rs.getString("protectionState")); @@ -236,7 +164,6 @@ public class Building extends AbstractWorldObject { this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault()); } catch (Exception e) { - Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e.toString()); } } @@ -1076,8 +1003,72 @@ public class Building extends AbstractWorldObject { try { + // Lookup building blueprint + + Blueprint blueprint; + + if (this.blueprintUUID == 0) + blueprint = Blueprint._meshLookup.get(meshUUID); + else + blueprint = this.getBlueprint(); + + // Log error if something went horrible wrong + + if ((this.blueprintUUID != 0) && (blueprint == null)) + Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); + + // Note: We handle R8 tree edge case for mesh and health + // after city is loaded to avoid recursive result set call + // in City resulting in a stack ovreflow. + + if (blueprint != null) { + + // Only switch mesh for player dropped structures + + if (this.blueprintUUID != 0) + this.meshUUID = blueprint.getMeshForRank(rank); + + this.healthMax = blueprint.getMaxHealth(this.rank); + + // If this object has no blueprint but is a blueprint + // mesh then set it's current health to max health + + if (this.blueprintUUID == 0) + this.setHealth(healthMax); + + if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK)) + this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this); + + } else { + this.healthMax = 100000; // Structures with no blueprint mesh + this.setHealth(healthMax); + } + + resists = new Resists("Building"); + + if (this.parentZone != null) { + if (this.parentBuildingID != 0) { + Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); + if (parentBuilding != null) { + this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); + } else { + this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); + + } + } else { + + // Altitude of this building is derived from the heightmap engine. + + Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); + tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); + this.setLoc(tempLoc); + } + } + + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); this.parentZone.zoneBuildingSet.add(this); + // Submit upgrade job if building is currently set to rank. try { From d2c00cce70f98bc6d41fac976536959d66f0e550 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 10:38:55 -0400 Subject: [PATCH 239/289] Removed unused methods --- src/engine/objects/Building.java | 48 ++------------------------------ 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 9535411f..ccc24963 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -869,13 +869,8 @@ public class Building extends AbstractWorldObject { DispatchMessage.sendToAllInRange(this, applyBuildingEffectMsg); } - /* - * Utils - */ - public void removeEffectBit(int bit) { this.effectFlags &= (~bit); - } @Override @@ -892,11 +887,6 @@ public class Building extends AbstractWorldObject { this.updateName(); } - - /* - * Serializing - */ - public final AbstractCharacter getOwner() { if (this.ownerUUID == 0) @@ -908,10 +898,6 @@ public class Building extends AbstractWorldObject { } - /* - * Database - */ - public final String getOwnerName() { AbstractCharacter owner = this.getOwner(); if (owner != null) @@ -972,13 +958,11 @@ public class Building extends AbstractWorldObject { } - // *** Refactor: Can't we just use setRank() for this? - public final void rebuildMine() { this.setRank(1); this.meshUUID = this.getBlueprint().getMeshForRank(this.rank); - // New rank mean new max hitpoints. + // New rank mean new max hit points. this.healthMax = this.getBlueprint().getMaxHealth(this.rank); this.setCurrentHitPoints(this.healthMax); @@ -996,8 +980,6 @@ public class Building extends AbstractWorldObject { return maxGold; } - //This returns if a player is allowed access to control the building - @Override public void runAfterLoad() { @@ -1184,7 +1166,6 @@ public class Building extends AbstractWorldObject { this.ownerIsNPC = (newOwner.getObjectType() == GameObjectType.NPC); } - // Set new guild for hirelings and refresh all clients this.refreshGuild(); @@ -1304,7 +1285,7 @@ public class Building extends AbstractWorldObject { } // Save to database ? - if (updateRecord == true) + if (updateRecord) return DbManager.BuildingQueries.UPDATE_DOOR_LOCK(this.getObjectUUID(), this.doorState); else return true; @@ -1340,7 +1321,6 @@ public class Building extends AbstractWorldObject { this.spireIsActive = true; this.updateEffects(); - } public final void disableSpire(boolean refreshEffect) { @@ -1629,18 +1609,10 @@ public class Building extends AbstractWorldObject { return patrolPoints; } - public void setPatrolPoints(ArrayList patrolPoints) { - this.patrolPoints = patrolPoints; - } - public ArrayList getSentryPoints() { return sentryPoints; } - public void setSentryPoints(ArrayList sentryPoints) { - this.sentryPoints = sentryPoints; - } - public synchronized boolean addProtectionTax(Building building, PlayerCharacter pc, final TaxType taxType, int amount, boolean enforceKOS) { if (building == null) return false; @@ -1665,14 +1637,6 @@ public class Building extends AbstractWorldObject { } - public synchronized boolean declineTaxOffer() { - return true; - } - - public synchronized boolean acceptTaxOffer() { - return true; - } - public synchronized boolean acceptTaxes() { if (!DbManager.BuildingQueries.acceptTaxes(this)) @@ -1697,14 +1661,6 @@ public class Building extends AbstractWorldObject { return true; } - public boolean isTaxed() { - if (this.taxType == TaxType.NONE) - return false; - if (this.taxAmount == 0) - return false; - return this.taxDateTime != null; - } - public void AddToBarracksList() { City playerCity = ZoneManager.getCityAtLocation(this.loc); if (playerCity != null) { From 145d9bafa0e6afd79d83e3a2677089efc1a5f8ef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 10:59:50 -0400 Subject: [PATCH 240/289] Removed unused methods --- src/engine/math/Bounds.java | 5 +++-- src/engine/objects/Building.java | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/engine/math/Bounds.java b/src/engine/math/Bounds.java index 04998e1c..cfa3afe6 100644 --- a/src/engine/math/Bounds.java +++ b/src/engine/math/Bounds.java @@ -422,7 +422,7 @@ public class Bounds { this.origin.set(building.getLoc().x, building.getLoc().z); - // Magicbane uses half halfExtents + // Magicbane uses halfExtents if (meshBounds == null) { halfExtentX = 1; @@ -438,8 +438,10 @@ public class Bounds { // The rotation is reset after the new aabb is calculated. this.rotation = building.getRot().y; + // Caclculate and set the new half halfExtents for the rotated bounding box // and reset the rotation to 0 for this bounds. + this.halfExtents.set(halfExtentX, (halfExtentY)); this.rotation = 0; @@ -453,7 +455,6 @@ public class Bounds { this.halfExtents.set(blueprint.getExtents()); this.flipExtents = Bounds.calculateFlipExtents(this); - this.setRegions(building); this.setColliders(building); diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index ccc24963..408121e5 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -779,10 +779,6 @@ public class Building extends AbstractWorldObject { return this.meshUUID; } - public final void setMeshUUID(int value) { - this.meshUUID = value; - } - public final Resists getResists() { return this.resists; } From a04bdc147fce326a28fdc3322ca3f14e321f8f9e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 11:03:08 -0400 Subject: [PATCH 241/289] Parent zone set --- src/engine/objects/Building.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 408121e5..e915bced 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -981,6 +981,11 @@ public class Building extends AbstractWorldObject { try { + // Set Parent Zone + + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); + this.parentZone.zoneBuildingSet.add(this); + // Lookup building blueprint Blueprint blueprint; @@ -1043,9 +1048,6 @@ public class Building extends AbstractWorldObject { } } - this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); - this.parentZone.zoneBuildingSet.add(this); - // Submit upgrade job if building is currently set to rank. From 88f67efd517d96b8a28f14ce5b6005967ad0955c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 11:04:57 -0400 Subject: [PATCH 242/289] Want to fail fast here --- src/engine/objects/Building.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index e915bced..e2521bca 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -979,8 +979,6 @@ public class Building extends AbstractWorldObject { @Override public void runAfterLoad() { - try { - // Set Parent Zone this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); @@ -1135,10 +1133,6 @@ public class Building extends AbstractWorldObject { if (this.upgradeDateTime != null) BuildingManager.submitUpgradeJob(this); - - } catch (Exception e) { - e.printStackTrace(); - } } public synchronized boolean setOwner(AbstractCharacter newOwner) { From 44743b772b9e81aa280573663b44c429c7bee6a7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 11:21:29 -0400 Subject: [PATCH 243/289] Every building does not need a rebuild mine method. --- src/engine/gameManager/BuildingManager.java | 11 +++++++++++ src/engine/objects/Building.java | 13 +------------ src/engine/workthreads/HourlyJobThread.java | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 7c21db71..1d68332b 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -851,4 +851,15 @@ public enum BuildingManager { } } + + public static void rebuildMine(Building mineBuilding) { + mineBuilding.setRank(1); + mineBuilding.meshUUID = mineBuilding.getBlueprint().getMeshForRank(mineBuilding.rank); + + // New rank mean new max hit points. + + mineBuilding.healthMax = mineBuilding.getBlueprint().getMaxHealth(mineBuilding.rank); + mineBuilding.setCurrentHitPoints(mineBuilding.healthMax); + mineBuilding.getBounds().setBounds(mineBuilding); + } } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index e2521bca..05d9984d 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -89,7 +89,7 @@ public class Building extends AbstractWorldObject { private int maxGold; private int effectFlags = 0; private String name = ""; - private int rank; + public int rank; private boolean ownerIsNPC = true; private boolean spireIsActive = false; private ConcurrentHashMap timers = null; @@ -954,17 +954,6 @@ public class Building extends AbstractWorldObject { } - public final void rebuildMine() { - this.setRank(1); - this.meshUUID = this.getBlueprint().getMeshForRank(this.rank); - - // New rank mean new max hit points. - - this.healthMax = this.getBlueprint().getMaxHealth(this.rank); - this.setCurrentHitPoints(this.healthMax); - this.getBounds().setBounds(this); - } - public final void refreshGuild() { UpdateObjectMsg uom = new UpdateObjectMsg(this, 5); diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 556175c9..811a9c90 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -163,7 +163,7 @@ public class HourlyJobThread implements Runnable { mine.nationName = nation.getName(); mine.nationTag = nation.getGuildTag(); - mineBuilding.rebuildMine(); + BuildingManager.rebuildMine(mineBuilding); WorldGrid.updateObject(mineBuilding); ChatSystemMsg chatMsg = new ChatSystemMsg(null, mine.lastClaimer.getName() + " has claimed the mine in " + mine.getParentZone().parent.zoneName + " for " + mine.getOwningGuild().getName() + ". The mine is no longer active."); From 838776c471c7ba5a6dc588f365dae80a564cb135 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 11:30:22 -0400 Subject: [PATCH 244/289] Method made static and moved to manager. --- src/engine/devcmd/cmds/MakeBaneCmd.java | 2 +- src/engine/devcmd/cmds/SetRankCmd.java | 7 +- src/engine/gameManager/BuildingManager.java | 82 +++++++++++++++- src/engine/jobs/UpgradeBuildingJob.java | 3 +- .../handlers/DestroyBuildingHandler.java | 2 +- .../handlers/ObjectActionMsgHandler.java | 2 +- src/engine/objects/Building.java | 98 ++----------------- src/engine/workthreads/DestroyCityThread.java | 3 +- src/engine/workthreads/HourlyJobThread.java | 2 +- .../workthreads/TransferCityThread.java | 2 +- 10 files changed, 102 insertions(+), 101 deletions(-) diff --git a/src/engine/devcmd/cmds/MakeBaneCmd.java b/src/engine/devcmd/cmds/MakeBaneCmd.java index 4b4b379d..fb521c0f 100644 --- a/src/engine/devcmd/cmds/MakeBaneCmd.java +++ b/src/engine/devcmd/cmds/MakeBaneCmd.java @@ -167,7 +167,7 @@ public class MakeBaneCmd extends AbstractDevCmd { return; } stone.addEffectBit((1 << 19)); - stone.setRank((byte) rank); + BuildingManager.setRank(stone, (byte) rank); stone.setMaxHitPoints(blueprint.getMaxHealth(stone.getRank())); stone.setCurrentHitPoints(stone.getMaxHitPoints()); BuildingManager.setUpgradeDateTime(stone, null, 0); diff --git a/src/engine/devcmd/cmds/SetRankCmd.java b/src/engine/devcmd/cmds/SetRankCmd.java index 614701c4..08ee01b0 100644 --- a/src/engine/devcmd/cmds/SetRankCmd.java +++ b/src/engine/devcmd/cmds/SetRankCmd.java @@ -57,7 +57,7 @@ public class SetRankCmd extends AbstractDevCmd { Blueprint blueprint = targetBuilding.getBlueprint(); if (blueprint == null) { - targetBuilding.setRank(targetRank); + BuildingManager.setRank(targetBuilding, targetRank); ChatManager.chatSayInfo(player, "Building ranked without blueprint" + targetBuilding.getObjectUUID()); return; } @@ -68,9 +68,8 @@ public class SetRankCmd extends AbstractDevCmd { } // Set the current targetRank - int lastMeshID = targetBuilding.getMeshUUID(); - targetBuilding.setRank(targetRank); + BuildingManager.setRank(targetBuilding, targetRank); ChatManager.chatSayInfo(player, "Rank set for building with ID " + targetBuilding.getObjectUUID() + " to rank " + targetRank); break; case NPC: @@ -114,7 +113,7 @@ public class SetRankCmd extends AbstractDevCmd { // Set the current targetRank int lastMeshID = targetBuilding.getMeshUUID(); - targetBuilding.setRank(targetRank); + BuildingManager.setRank(targetBuilding, targetRank); if (lastMeshID != targetBuilding.getMeshUUID()) targetBuilding.refresh(true); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 1d68332b..d603a4ce 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -853,7 +853,7 @@ public enum BuildingManager { } public static void rebuildMine(Building mineBuilding) { - mineBuilding.setRank(1); + setRank(mineBuilding, 1); mineBuilding.meshUUID = mineBuilding.getBlueprint().getMeshForRank(mineBuilding.rank); // New rank mean new max hit points. @@ -862,4 +862,84 @@ public enum BuildingManager { mineBuilding.setCurrentHitPoints(mineBuilding.healthMax); mineBuilding.getBounds().setBounds(mineBuilding); } + + public static void setRank(Building building, int rank) { + + int newMeshUUID; + boolean success; + + + // If this building has no blueprint then set rank and exit immediatly. + + if (building.blueprintUUID == 0 || building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)) { + building.rank = rank; + DbManager.BuildingQueries.CHANGE_RANK(building.getObjectUUID(), rank); + return; + } + + // Delete any upgrade jobs before doing anything else. It won't quite work + // if in a few lines we happen to delete this building. + + JobContainer jc = building.getTimers().get("UPGRADE"); + + if (jc != null) { + if (!JobScheduler.getInstance().cancelScheduledJob(jc)) + Logger.error("failed to cancel existing upgrade job."); + } + + // Attempt write to database, or delete the building + // if we are destroying it. + + if (rank == -1) + success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(building); + else + success = DbManager.BuildingQueries.updateBuildingRank(building, rank); + + if (success == false) { + Logger.error("Error writing to database UUID: " + building.getObjectUUID()); + return; + } + + building.isDeranking.compareAndSet(false, true); + + // Change the building's rank + + building.rank = rank; + + // New rank means new mesh + + newMeshUUID = building.getBlueprint().getMeshForRank(building.rank); + building.meshUUID = newMeshUUID; + + // New rank mean new max hitpoints. + + building.healthMax = building.getBlueprint().getMaxHealth(building.rank); + building.setCurrentHitPoints(building.healthMax); + + if (building.getUpgradeDateTime() != null) + setUpgradeDateTime(building, null, 0); + + // If we destroyed this building make sure to turn off + // protection + + if (building.rank == -1) + building.protectionState = Enum.ProtectionState.NONE; + + if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) + && (building.rank == 8)) + building.meshUUID = Realm.getRealmMesh(building.getCity()); + + // update object to clients + + building.refresh(true); + + if (building.getBounds() != null) + building.getBounds().setBounds(building); + + // Cleanup hirelings resulting from rank change + + cleanupHirelings(building); + + building.isDeranking.compareAndSet(true, false); + } } diff --git a/src/engine/jobs/UpgradeBuildingJob.java b/src/engine/jobs/UpgradeBuildingJob.java index c9032af9..4170e90e 100644 --- a/src/engine/jobs/UpgradeBuildingJob.java +++ b/src/engine/jobs/UpgradeBuildingJob.java @@ -1,5 +1,6 @@ package engine.jobs; +import engine.gameManager.BuildingManager; import engine.job.AbstractScheduleJob; import engine.objects.Building; import org.pmw.tinylog.Logger; @@ -39,7 +40,7 @@ public class UpgradeBuildingJob extends AbstractScheduleJob { // SetCurrentRank also changes the mesh and maxhp // accordingly for buildings with blueprints - rankingBuilding.setRank(rankingBuilding.getRank() + 1); + BuildingManager.setRank(rankingBuilding, rankingBuilding.getRank() + 1); // Reload the object diff --git a/src/engine/net/client/handlers/DestroyBuildingHandler.java b/src/engine/net/client/handlers/DestroyBuildingHandler.java index 18ce4d05..b1b90bf4 100644 --- a/src/engine/net/client/handlers/DestroyBuildingHandler.java +++ b/src/engine/net/client/handlers/DestroyBuildingHandler.java @@ -95,7 +95,7 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler { city.setWarehouseBuildingID(0); } - building.setRank(-1); + BuildingManager.setRank(building, -1); WorldGrid.RemoveWorldObject(building); WorldGrid.removeObject(building); building.getParentZone().zoneBuildingSet.remove(building); diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 5f4c4451..6896f566 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -182,7 +182,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { realm.claimRealmForCity(city, charterUUID); - tol.setRank(8); + BuildingManager.setRank(tol, 8); WorldGrid.updateObject(tol); for (Building building : city.getParent().zoneBuildingSet) { diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 05d9984d..04113af4 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -80,7 +80,7 @@ public class Building extends AbstractWorldObject { /* The Blueprint class has methods able to derive * all defining characteristics of this building, */ - private int blueprintUUID = 0; + public int blueprintUUID = 0; private float w = 1.0f; private Vector3f meshScale = new Vector3f(1.0f, 1.0f, 1.0f); private int doorState = 0; @@ -96,7 +96,7 @@ public class Building extends AbstractWorldObject { private ConcurrentHashMap timestamps = null; private ConcurrentHashMap friends = new ConcurrentHashMap<>(); private ConcurrentHashMap condemned = new ConcurrentHashMap<>(); - private ProtectionState protectionState = ProtectionState.NONE; + public ProtectionState protectionState = ProtectionState.NONE; private ArrayList children = null; /** @@ -277,86 +277,6 @@ public class Building extends AbstractWorldObject { return rank; } - public final void setRank(int newRank) { - - int newMeshUUID; - boolean success; - - - // If this building has no blueprint then set rank and exit immediatly. - - if (this.blueprintUUID == 0 || this.getBlueprint() != null && this.getBlueprint().getBuildingGroup().equals(BuildingGroup.MINE)) { - this.rank = newRank; - DbManager.BuildingQueries.CHANGE_RANK(this.getObjectUUID(), newRank); - return; - } - - // Delete any upgrade jobs before doing anything else. It won't quite work - // if in a few lines we happen to delete this building. - - JobContainer jc = this.getTimers().get("UPGRADE"); - - if (jc != null) { - if (!JobScheduler.getInstance().cancelScheduledJob(jc)) - Logger.error("failed to cancel existing upgrade job."); - } - - // Attempt write to database, or delete the building - // if we are destroying it. - - if (newRank == -1) - success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(this); - else - success = DbManager.BuildingQueries.updateBuildingRank(this, newRank); - - if (success == false) { - Logger.error("Error writing to database UUID: " + this.getObjectUUID()); - return; - } - - this.isDeranking.compareAndSet(false, true); - - // Change the building's rank - - this.rank = newRank; - - // New rank means new mesh - - newMeshUUID = this.getBlueprint().getMeshForRank(this.rank); - this.meshUUID = newMeshUUID; - - // New rank mean new max hitpoints. - - this.healthMax = this.getBlueprint().getMaxHealth(this.rank); - this.setCurrentHitPoints(this.healthMax); - - if (this.getUpgradeDateTime() != null) - BuildingManager.setUpgradeDateTime(this, null, 0); - - // If we destroyed this building make sure to turn off - // protection - - if (this.rank == -1) - this.protectionState = ProtectionState.NONE; - - if ((this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) - && (this.rank == 8)) - this.meshUUID = Realm.getRealmMesh(this.getCity()); - ; - - // update object to clients - - this.refresh(true); - if (this.getBounds() != null) - this.getBounds().setBounds(this); - - // Cleanup hirelings resulting from rank change - - BuildingManager.cleanupHirelings(this); - - this.isDeranking.compareAndSet(true, false); - } - public final int getOwnerUUID() { return ownerUUID; } @@ -528,7 +448,7 @@ public class Building extends AbstractWorldObject { MineRecord mineRecord = MineRecord.borrow(mine, attacker, RecordEventType.DESTROY); DataWarehouse.pushToWarehouse(mineRecord); - this.setRank(-1); + BuildingManager.setRank(this, -1); this.setCurrentHitPoints((float) 1); this.healthMax = (float) 1; this.meshUUID = this.getBlueprint().getMeshForRank(this.rank); @@ -551,9 +471,9 @@ public class Building extends AbstractWorldObject { // Time to either derank or destroy the building. if ((this.rank - 1) < 1) - this.setRank(-1); + BuildingManager.setRank(this, -1); else - this.setRank(this.rank - 1); + BuildingManager.setRank(this, this.rank - 1); } @@ -611,7 +531,7 @@ public class Building extends AbstractWorldObject { if (spireBuilding != null) { spireBuilding.disableSpire(true); - spireBuilding.setRank(-1); + BuildingManager.setRank(spireBuilding, -1); } } @@ -622,7 +542,7 @@ public class Building extends AbstractWorldObject { // Delete a random shrine if (shrineBuilding != null) - shrineBuilding.setRank(-1); + BuildingManager.setRank(shrineBuilding, -1); } if (barracksBuildings.size() > this.rank - 1) { @@ -632,7 +552,7 @@ public class Building extends AbstractWorldObject { // Delete a random barrack if (barracksBuilding != null) - barracksBuilding.setRank(-1); + BuildingManager.setRank(barracksBuilding, -1); } // If the tree is R8 and deranking, we need to update it's @@ -661,7 +581,7 @@ public class Building extends AbstractWorldObject { // Let's do so and early exit if (this.rank > 1) { - this.setRank(rank - 1); + BuildingManager.setRank(this, rank - 1); City.lastCityUpdate = System.currentTimeMillis(); return; } diff --git a/src/engine/workthreads/DestroyCityThread.java b/src/engine/workthreads/DestroyCityThread.java index 22cb72e1..25f18fcb 100644 --- a/src/engine/workthreads/DestroyCityThread.java +++ b/src/engine/workthreads/DestroyCityThread.java @@ -19,6 +19,7 @@ package engine.workthreads; */ import engine.Enum; +import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; import engine.gameManager.GuildManager; import engine.gameManager.ZoneManager; @@ -127,7 +128,7 @@ public class DestroyCityThread implements Runnable { || (cityBuilding.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.WAREHOUSE)) { if (cityBuilding.getRank() != -1) - cityBuilding.setRank(-1); + BuildingManager.setRank(cityBuilding, -1); } } diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 811a9c90..26795745 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -176,7 +176,7 @@ public class HourlyJobThread implements Runnable { MineRecord mineRecord = MineRecord.borrow(mine, mine.lastClaimer, Enum.RecordEventType.CAPTURE); DataWarehouse.pushToWarehouse(mineRecord); - mineBuilding.setRank(mineBuilding.getRank()); + BuildingManager.setRank(mineBuilding, mineBuilding.getRank()); mine.lastClaimer = null; mine.setActive(false); mine.wasClaimed = true; diff --git a/src/engine/workthreads/TransferCityThread.java b/src/engine/workthreads/TransferCityThread.java index 812f82fe..cd4d1cb4 100644 --- a/src/engine/workthreads/TransferCityThread.java +++ b/src/engine/workthreads/TransferCityThread.java @@ -74,7 +74,7 @@ public class TransferCityThread implements Runnable { //Reset TOL to rank 1 - city.getTOL().setRank(1); + BuildingManager.setRank(city.getTOL(), 1); // Transfer all assets to new owner From 385695a610566f50d1aef5708ae3bbe4ff64f5ca Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 12:24:32 -0400 Subject: [PATCH 245/289] Load collection from db --- src/engine/db/handlers/dbBuildingHandler.java | 35 +++++++++++++++++-- src/engine/gameManager/BuildingManager.java | 7 ++-- .../OpenFriendsCondemnListMsgHandler.java | 2 +- .../client/msg/OpenFriendsCondemnListMsg.java | 14 ++++---- src/engine/objects/BuildingFriends.java | 20 +++-------- src/engine/server/world/WorldServer.java | 3 ++ 6 files changed, 52 insertions(+), 29 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 0c88a5d6..8d5c331d 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -13,6 +13,7 @@ import engine.Enum; import engine.Enum.DbObjectType; import engine.Enum.ProtectionState; import engine.Enum.TaxType; +import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; import engine.math.Vector3fImmutable; import engine.objects.*; @@ -423,6 +424,34 @@ public class dbBuildingHandler extends dbHandlerBase { return false; } + public void LOAD_BUILDING_FRIENDS() { + + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + BuildingFriends friend = new BuildingFriends(rs); + + switch (friend.friendType) { + case 7: + BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.playerUID, friend); + break; + case 8: + case 9: + BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.guildUID, friend); + break; + } + } + + } catch (SQLException e) { + Logger.error(e); + } + + } + public void LOAD_ALL_FRIENDS_FOR_BUILDING(Building building) { if (building == null) @@ -436,13 +465,13 @@ public class dbBuildingHandler extends dbHandlerBase { while (rs.next()) { BuildingFriends friend = new BuildingFriends(rs); - switch (friend.getFriendType()) { + switch (friend.friendType) { case 7: - building.getFriends().put(friend.getPlayerUID(), friend); + building.getFriends().put(friend.playerUID, friend); break; case 8: case 9: - building.getFriends().put(friend.getGuildUID(), friend); + building.getFriends().put(friend.guildUID, friend); break; } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index d603a4ce..c3524069 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -31,6 +31,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; public enum BuildingManager { @@ -40,6 +41,8 @@ public enum BuildingManager { public static HashMap> _stuckLocations = new HashMap<>(); public static HashMap> _slotLocations = new HashMap<>(); + public static HashMap> _buildingFriends = new HashMap<>(); + public static int getAvailableSlot(Building building) { ArrayList slotLocations = _slotLocations.get(building.meshUUID); @@ -127,11 +130,11 @@ public enum BuildingManager { return true; if (building.getFriends().get(player.getGuild().getObjectUUID()) != null - && building.getFriends().get(player.getGuild().getObjectUUID()).getFriendType() == 8) + && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8) return true; if (building.getFriends().get(player.getGuild().getObjectUUID()) != null - && building.getFriends().get(player.getGuild().getObjectUUID()).getFriendType() == 9 + && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus())) return true; diff --git a/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java b/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java index ccb93609..a5d260b3 100644 --- a/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java +++ b/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java @@ -354,7 +354,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler { if (friend == null) return true; - if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.getPlayerUID(), friend.getGuildUID(), friend.getFriendType())) { + if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.playerUID, friend.guildUID, friend.friendType)) { Logger.debug("Failed to remove Friend: " + msg.getRemoveFriendID() + " from Building With UID " + sourceBuilding.getObjectUUID()); return true; } diff --git a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java index f6eaefad..0503b5ca 100644 --- a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java +++ b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java @@ -619,22 +619,22 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg { writer.putInt(listSize); for (BuildingFriends friend : this.friends.values()) { - pc = PlayerCharacter.getFromCache(friend.getPlayerUID()); - guild = Guild.getGuild(friend.getGuildUID()); - if (friend.getFriendType() == 7) { + pc = PlayerCharacter.getFromCache(friend.playerUID); + guild = Guild.getGuild(friend.guildUID); + if (friend.friendType == 7) { if (pc != null) name = pc.getCombinedName(); } else if (guild != null) name = guild.getName(); writer.put((byte) 1); - if (friend.getFriendType() == 7) { + if (friend.friendType == 7) { writer.putInt(GameObjectType.PlayerCharacter.ordinal()); - writer.putInt(friend.getPlayerUID()); + writer.putInt(friend.playerUID); } else { writer.putInt(GameObjectType.Guild.ordinal()); - writer.putInt(friend.getGuildUID()); + writer.putInt(friend.guildUID); } - writer.putInt(friend.getFriendType()); + writer.putInt(friend.friendType); writer.putInt(0); writer.putInt(0); diff --git a/src/engine/objects/BuildingFriends.java b/src/engine/objects/BuildingFriends.java index b5308978..67914261 100644 --- a/src/engine/objects/BuildingFriends.java +++ b/src/engine/objects/BuildingFriends.java @@ -14,10 +14,10 @@ import java.sql.SQLException; public class BuildingFriends { - private int playerUID; - private int buildingUID; - private int guildUID; - private int friendType; + public int playerUID; + public int buildingUID; + public int guildUID; + public int friendType; /** * ResultSet Constructor @@ -38,16 +38,4 @@ public class BuildingFriends { this.friendType = friendType; } - public int getPlayerUID() { - return playerUID; - } - - public int getGuildUID() { - return guildUID; - } - - public int getFriendType() { - return friendType; - } - } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 853ac58b..daf7b59d 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -318,6 +318,9 @@ public class WorldServer { Logger.info("Initializing Player Friends"); DbManager.PlayerCharacterQueries.LOAD_PLAYER_FRIENDS(); + Logger.info("Initializing Building Friends"); + DbManager.BuildingQueries.LOAD_BUILDING_FRIENDS(); + Logger.info("Initializing NPC Profits"); DbManager.NPCQueries.LOAD_NPC_PROFITS(); From 6fb1e2e5f1e2aa6447628831ecf5d73e1d81393f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 12:31:39 -0400 Subject: [PATCH 246/289] Load collection from db --- src/engine/db/handlers/dbBuildingHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 8d5c331d..b8ddb0e2 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -28,6 +28,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; public class dbBuildingHandler extends dbHandlerBase { @@ -435,6 +436,11 @@ public class dbBuildingHandler extends dbHandlerBase { while (rs.next()) { BuildingFriends friend = new BuildingFriends(rs); + // Create map if it does not yet exist + + if (!BuildingManager._buildingFriends.containsKey(friend.buildingUID)) + BuildingManager._buildingFriends.put(friend.buildingUID, new ConcurrentHashMap<>()); + switch (friend.friendType) { case 7: BuildingManager._buildingFriends.get(friend.buildingUID).put(friend.playerUID, friend); From 5ac62d60be7bddf111bc9c427520676405415ce5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 12:38:04 -0400 Subject: [PATCH 247/289] Collection used and old handler removed. --- src/engine/db/handlers/dbBuildingHandler.java | 30 ---------------- src/engine/objects/Building.java | 35 ++++++++++--------- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index b8ddb0e2..c81003b7 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -458,36 +458,6 @@ public class dbBuildingHandler extends dbHandlerBase { } - public void LOAD_ALL_FRIENDS_FOR_BUILDING(Building building) { - - if (building == null) - return; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends` WHERE `buildingUID` = ?")) { - - preparedStatement.setInt(1, building.getObjectUUID()); - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - BuildingFriends friend = new BuildingFriends(rs); - switch (friend.friendType) { - case 7: - building.getFriends().put(friend.playerUID, friend); - break; - case 8: - case 9: - building.getFriends().put(friend.guildUID, friend); - break; - } - } - - } catch (SQLException e) { - Logger.error(e); - } - - } - public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) { if (building == null) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 04113af4..2c0f2c68 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -94,7 +94,7 @@ public class Building extends AbstractWorldObject { private boolean spireIsActive = false; private ConcurrentHashMap timers = null; private ConcurrentHashMap timestamps = null; - private ConcurrentHashMap friends = new ConcurrentHashMap<>(); + private ConcurrentHashMap friends; private ConcurrentHashMap condemned = new ConcurrentHashMap<>(); public ProtectionState protectionState = ProtectionState.NONE; private ArrayList children = null; @@ -956,26 +956,27 @@ public class Building extends AbstractWorldObject { } - // Submit upgrade job if building is currently set to rank. + // Submit upgrade job if building is currently set to rank. - try { - DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID); - this.ownerIsNPC = (objectType == DbObjectType.NPC); - } catch (Exception e) { - this.ownerIsNPC = false; - Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString()); - } + try { + DbObjectType objectType = DbManager.BuildingQueries.GET_UID_ENUM(this.ownerUUID); + this.ownerIsNPC = (objectType == DbObjectType.NPC); + } catch (Exception e) { + this.ownerIsNPC = false; + Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString()); + } - try { - DbManager.BuildingQueries.LOAD_ALL_FRIENDS_FOR_BUILDING(this); - DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this); - } catch (Exception e) { - Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage()); - } + this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID()); + + try { + DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this); + } catch (Exception e) { + Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage()); + } - //LOad Owners in Cache so we do not have to continuely look in the db for owner. + //LOad Owners in Cache so we do not have to continuely look in the db for owner. - if (this.ownerIsNPC) { + if (this.ownerIsNPC) { if (NPC.getNPC(this.ownerUUID) == null) Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); From 2cc37481cada022a6db634ccfaccca0004abb01f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 12:54:06 -0400 Subject: [PATCH 248/289] New collection created in handled and loaded from db --- src/engine/db/handlers/dbBuildingHandler.java | 47 +++++++++++++++---- src/engine/gameManager/BuildingManager.java | 14 +++--- src/engine/mobileAI/MobAI.java | 12 ++--- .../OpenFriendsCondemnListMsgHandler.java | 4 +- .../client/msg/OpenFriendsCondemnListMsg.java | 34 +++++++------- src/engine/objects/Condemned.java | 47 ++++--------------- src/engine/server/world/WorldServer.java | 3 ++ 7 files changed, 84 insertions(+), 77 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index c81003b7..e2becf1e 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -427,7 +427,6 @@ public class dbBuildingHandler extends dbHandlerBase { public void LOAD_BUILDING_FRIENDS() { - try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_friends`")) { @@ -458,6 +457,38 @@ public class dbBuildingHandler extends dbHandlerBase { } + public void LOAD_BUILDING_CONDEMNED() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + Condemned condemned = new Condemned(rs); + + // Create map if it does not yet exist + + if (!BuildingManager._buildingCondemned.containsKey(condemned.buildingUUID)) + BuildingManager._buildingCondemned.put(condemned.buildingUUID, new ConcurrentHashMap<>()); + + switch (condemned.friendType) { + case 2: + BuildingManager._buildingCondemned.get(condemned.buildingUUID).put(condemned.playerUID, condemned); + break; + case 4: + case 5: + BuildingManager._buildingCondemned.get(condemned.buildingUUID).put(condemned.guildUID, condemned); + break; + } + } + + } catch (SQLException e) { + Logger.error(e); + } + } + public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) { if (building == null) @@ -471,13 +502,13 @@ public class dbBuildingHandler extends dbHandlerBase { while (rs.next()) { Condemned condemned = new Condemned(rs); - switch (condemned.getFriendType()) { + switch (condemned.friendType) { case 2: - building.getCondemned().put(condemned.getPlayerUID(), condemned); + building.getCondemned().put(condemned.playerUID, condemned); break; case 4: case 5: - building.getCondemned().put(condemned.getGuildUID(), condemned); + building.getCondemned().put(condemned.guildUID, condemned); break; } } @@ -725,10 +756,10 @@ public class dbBuildingHandler extends dbHandlerBase { + "WHERE`buildingUID` = ? AND `playerUID` = ? AND `guildUID` = ? AND `friendType` = ?")) { preparedStatement.setBoolean(1, active); - preparedStatement.setInt(2, condemn.getParent()); - preparedStatement.setInt(3, condemn.getPlayerUID()); - preparedStatement.setInt(4, condemn.getGuildUID()); - preparedStatement.setInt(5, condemn.getFriendType()); + preparedStatement.setInt(2, condemn.buildingUUID); + preparedStatement.setInt(3, condemn.playerUID); + preparedStatement.setInt(4, condemn.guildUID); + preparedStatement.setInt(5, condemn.friendType); return (preparedStatement.executeUpdate() > 0); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index c3524069..180504cf 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -42,7 +42,7 @@ public enum BuildingManager { public static HashMap> _slotLocations = new HashMap<>(); public static HashMap> _buildingFriends = new HashMap<>(); - + public static HashMap> _buildingCondemned = new HashMap<>(); public static int getAvailableSlot(Building building) { ArrayList slotLocations = _slotLocations.get(building.meshUUID); @@ -497,18 +497,18 @@ public enum BuildingManager { Condemned condemn = building.getCondemned().get(player.getObjectUUID()); - if (condemn != null && condemn.isActive()) + if (condemn != null && condemn.active) return true; if (player.getGuild() != null) { Condemned guildCondemn = building.getCondemned().get(player.getGuild().getObjectUUID()); - if (guildCondemn != null && guildCondemn.isActive()) + if (guildCondemn != null && guildCondemn.active) return true; Condemned nationCondemn = building.getCondemned().get(player.getGuild().getNation().getObjectUUID()); - return nationCondemn != null && nationCondemn.isActive() && nationCondemn.getFriendType() == Condemned.NATION; + return nationCondemn != null && nationCondemn.active && nationCondemn.friendType == Condemned.NATION; } else { //TODO ADD ERRANT KOS CHECK } @@ -516,18 +516,18 @@ public enum BuildingManager { Condemned condemn = building.getCondemned().get(player.getObjectUUID()); - if (condemn != null && condemn.isActive()) + if (condemn != null && condemn.active) return false; if (player.getGuild() != null) { Condemned guildCondemn = building.getCondemned().get(player.getGuild().getObjectUUID()); - if (guildCondemn != null && guildCondemn.isActive()) + if (guildCondemn != null && guildCondemn.active) return false; Condemned nationCondemn = building.getCondemned().get(player.getGuild().getNation().getObjectUUID()); - return nationCondemn == null || !nationCondemn.isActive() || nationCondemn.getFriendType() != Condemned.NATION; + return nationCondemn == null || !nationCondemn.active || nationCondemn.friendType != Condemned.NATION; } else { //TODO ADD ERRANT KOS CHECK } diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 8a925021..0fa3d462 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -1175,17 +1175,17 @@ public class MobAI { //target is listed individually - if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) + if (entry.getValue().playerUID == target.getObjectUUID() && entry.getValue().active) return false; //target's guild is listed - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild()) + if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild()) return false; //target's nation is listed - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation()) + if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild().getNation()) return false; } return true; @@ -1197,17 +1197,17 @@ public class MobAI { //target is listed individually - if (entry.getValue().getPlayerUID() == target.getObjectUUID() && entry.getValue().isActive()) + if (entry.getValue().playerUID == target.getObjectUUID() && entry.getValue().active) return true; //target's guild is listed - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild()) + if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild()) return true; //target's nation is listed - if (Guild.getGuild(entry.getValue().getGuildUID()) == target.getGuild().getNation()) + if (Guild.getGuild(entry.getValue().guildUID) == target.getGuild().getNation()) return true; } } diff --git a/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java b/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java index a5d260b3..6d70d4a2 100644 --- a/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java +++ b/src/engine/net/client/handlers/OpenFriendsCondemnListMsgHandler.java @@ -151,7 +151,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler { if (removeCondemn == null) return true; - if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.getParent(), removeCondemn.getPlayerUID(), removeCondemn.getGuildUID(), removeCondemn.getFriendType())) + if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.buildingUUID, removeCondemn.playerUID, removeCondemn.guildUID, removeCondemn.friendType)) return true; sourceBuilding.getCondemned().remove(msg.getRemoveFriendID()); @@ -175,7 +175,7 @@ public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler { return true; condemn.setActive(msg.isReverseKOS()); - openFriendsCondemnListMsg.setReverseKOS(condemn.isActive()); + openFriendsCondemnListMsg.setReverseKOS(condemn.active); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); break; diff --git a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java index 0503b5ca..c014a95f 100644 --- a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java +++ b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java @@ -513,17 +513,17 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg { writer.put((byte) 1); - switch (condemned.getFriendType()) { + switch (condemned.friendType) { case 2: - PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getObject(engine.Enum.GameObjectType.PlayerCharacter, condemned.getPlayerUID()); + PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getObject(engine.Enum.GameObjectType.PlayerCharacter, condemned.playerUID); guild = playerCharacter.getGuild(); writer.putInt(GameObjectType.PlayerCharacter.ordinal()); - writer.putInt(condemned.getPlayerUID()); - writer.putInt(condemned.getFriendType()); + writer.putInt(condemned.playerUID); + writer.putInt(condemned.friendType); writer.putInt(GameObjectType.PlayerCharacter.ordinal()); - writer.putInt(condemned.getPlayerUID()); + writer.putInt(condemned.playerUID); writer.putInt(0); writer.putInt(0); writer.putInt(GameObjectType.Guild.ordinal()); @@ -531,9 +531,9 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg { writer.putInt(guild.getObjectUUID()); else writer.putInt(0); - writer.put(condemned.isActive() ? (byte) 1 : (byte) 0); + writer.put(condemned.active ? (byte) 1 : (byte) 0); writer.put((byte) 0); - writer.put(condemned.isActive() ? (byte) 1 : (byte) 0); + writer.put(condemned.active ? (byte) 1 : (byte) 0); if (playerCharacter != null) writer.putString(playerCharacter.getFirstName()); @@ -547,16 +547,16 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg { } break; case 4: - guild = Guild.getGuild(condemned.getGuildUID()); + guild = Guild.getGuild(condemned.guildUID); writer.putInt(GameObjectType.Guild.ordinal()); - writer.putInt(condemned.getGuildUID()); - writer.putInt(condemned.getFriendType()); + writer.putInt(condemned.guildUID); + writer.putInt(condemned.friendType); writer.putLong(0); writer.putInt(GameObjectType.Guild.ordinal()); - writer.putInt(condemned.getGuildUID()); + writer.putInt(condemned.guildUID); writer.putLong(0); writer.put((byte) 0); - writer.put(condemned.isActive() ? (byte) 1 : (byte) 0); + writer.put(condemned.active ? (byte) 1 : (byte) 0); writer.put((byte) 0); if (guild != null) writer.putString(guild.getName()); @@ -570,17 +570,17 @@ public class OpenFriendsCondemnListMsg extends ClientNetMsg { GuildTag._serializeForDisplay(GuildTag.ERRANT, writer); break; case 5: - guild = Guild.getGuild(condemned.getGuildUID()); + guild = Guild.getGuild(condemned.guildUID); writer.putInt(GameObjectType.Guild.ordinal()); - writer.putInt(condemned.getGuildUID()); - writer.putInt(condemned.getFriendType()); + writer.putInt(condemned.guildUID); + writer.putInt(condemned.friendType); writer.putLong(0); writer.putLong(0); writer.putInt(GameObjectType.Guild.ordinal()); - writer.putInt(condemned.getGuildUID()); + writer.putInt(condemned.guildUID); writer.put((byte) 0); writer.put((byte) 0); - writer.put(condemned.isActive() ? (byte) 1 : (byte) 0); + writer.put(condemned.active ? (byte) 1 : (byte) 0); if (guild != null) writer.putString(guild.getName()); else diff --git a/src/engine/objects/Condemned.java b/src/engine/objects/Condemned.java index bdcb59a6..3f89bccb 100644 --- a/src/engine/objects/Condemned.java +++ b/src/engine/objects/Condemned.java @@ -14,72 +14,45 @@ import engine.gameManager.DbManager; import java.sql.ResultSet; import java.sql.SQLException; - public class Condemned { public static final int INDIVIDUAL = 2; public static final int GUILD = 4; public static final int NATION = 5; - private int ID; - private int playerUID; - private int parent; - private int guildUID; - private int friendType; - private boolean active; + public int playerUID; + public int buildingUUID; + public int guildUID; + public int friendType; + public boolean active; /** * ResultSet Constructor */ public Condemned(ResultSet rs) throws SQLException { this.playerUID = rs.getInt("playerUID"); - this.parent = rs.getInt("buildingUID"); + this.buildingUUID = rs.getInt("buildingUID"); this.guildUID = rs.getInt("guildUID"); this.friendType = rs.getInt("friendType"); this.active = rs.getBoolean("active"); } - - public Condemned(int playerUID, int parent, int guildUID, int friendType) { + public Condemned(int playerUID, int buildingUUID, int guildUID, int friendType) { super(); this.playerUID = playerUID; - this.parent = parent; + this.buildingUUID = buildingUUID; this.guildUID = guildUID; this.friendType = friendType; this.active = false; } - - public int getPlayerUID() { - return playerUID; - } - - - public int getParent() { - return parent; - } - - - public int getGuildUID() { - return guildUID; - } - - - public int getFriendType() { - return friendType; - } - - public boolean isActive() { - return active; - } - - public boolean setActive(boolean active) { + if (!DbManager.BuildingQueries.updateActiveCondemn(this, active)) return false; + this.active = active; return true; } - } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index daf7b59d..e79b2d07 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -321,6 +321,9 @@ public class WorldServer { Logger.info("Initializing Building Friends"); DbManager.BuildingQueries.LOAD_BUILDING_FRIENDS(); + Logger.info("Initializing Building Condemned"); + DbManager.BuildingQueries.LOAD_BUILDING_CONDEMNED(); + Logger.info("Initializing NPC Profits"); DbManager.NPCQueries.LOAD_NPC_PROFITS(); From beb2b47162e51e574e6713afb4e60518f155105c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 18 Oct 2023 13:03:40 -0400 Subject: [PATCH 249/289] Collection used and old method deleted. --- src/engine/db/handlers/dbBuildingHandler.java | 29 ------------------- src/engine/objects/Building.java | 13 ++++----- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index e2becf1e..d1786e1f 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -489,35 +489,6 @@ public class dbBuildingHandler extends dbHandlerBase { } } - public void LOAD_ALL_CONDEMNED_FOR_BUILDING(Building building) { - - if (building == null) - return; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_condemned` WHERE `buildingUID` = ?")) { - - preparedStatement.setInt(1, building.getObjectUUID()); - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - Condemned condemned = new Condemned(rs); - switch (condemned.friendType) { - case 2: - building.getCondemned().put(condemned.playerUID, condemned); - break; - case 4: - case 5: - building.getCondemned().put(condemned.guildUID, condemned); - break; - } - } - - } catch (SQLException e) { - Logger.error(e); - } - } - public ArrayList LOAD_PATROL_POINTS(Building building) { if (building == null) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 2c0f2c68..3acefafb 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -966,19 +966,16 @@ public class Building extends AbstractWorldObject { Logger.error("Failed to find Object Type for owner " + this.ownerUUID + " Location " + this.getLoc().toString()); } - this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID()); + // Reference friend and condemn lists from BuildingManager - try { - DbManager.BuildingQueries.LOAD_ALL_CONDEMNED_FOR_BUILDING(this); - } catch (Exception e) { - Logger.error(this.getObjectUUID() + " failed to load friends/condemned." + e.getMessage()); - } + this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID()); + this.condemned = BuildingManager._buildingCondemned.get(this.getObjectUUID()); //LOad Owners in Cache so we do not have to continuely look in the db for owner. if (this.ownerIsNPC) { - if (NPC.getNPC(this.ownerUUID) == null) - Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); + if (NPC.getNPC(this.ownerUUID) == null) + Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); } else if (this.ownerUUID != 0) { if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) { From b928bedeb6d60d15557d473bcc2f9dc157eb35cc Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 18:23:14 -0500 Subject: [PATCH 250/289] new region lookup --- src/engine/devcmd/cmds/RegionCmd.java | 7 +++++++ src/engine/gameManager/BuildingManager.java | 19 +++++++++++++++++++ src/engine/objects/AbstractCharacter.java | 10 +++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index b7b12c7e..dbda7ae7 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -11,6 +11,7 @@ package engine.devcmd.cmds; import engine.Enum; import engine.devcmd.AbstractDevCmd; +import engine.gameManager.BuildingManager; import engine.objects.*; import java.lang.reflect.Field; @@ -25,6 +26,12 @@ public class RegionCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { + Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc); + if(building == null){ + this.throwbackInfo(pc, "No Building At This Location.") ; + } else{ + this.throwbackInfo(pc, "Building At Location: " + building.getName()); + } Regions region = ((AbstractCharacter)target).region; if (region == null) { this.throwbackInfo(pc, "No Region Found."); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 180504cf..ca32184d 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -18,6 +18,7 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeBuildingJob; import engine.math.Bounds; +import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.net.client.ClientConnection; import engine.net.client.msg.ErrorPopupMsg; @@ -26,7 +27,9 @@ import engine.net.client.msg.PlaceAssetMsg; import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import org.w3c.dom.css.Rect; +import java.awt.*; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; @@ -945,4 +948,20 @@ public enum BuildingManager { building.isDeranking.compareAndSet(true, false); } + public static Building getBuildingAtLocation(Vector3fImmutable loc){ + for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,128,MBServerStatics.MASK_BUILDING)){ + Building building = (Building)awo; + if(building == null) + continue; + float minX = building.loc.x - building.getBounds().getHalfExtents().x; + float maxX = building.loc.x + building.getBounds().getHalfExtents().x; + float minZ = building.loc.z - building.getBounds().getHalfExtents().y; + float maxZ = building.loc.z + building.getBounds().getHalfExtents().y; + + if(loc.x > minX && loc.x < maxX && loc.z > minZ && loc.x < maxZ) + return building; + + } + return null; + } } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index f778755a..c8ab7b60 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -985,7 +985,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject { @Override public final void setLoc(final Vector3fImmutable value) { - Regions region = Regions.GetRegionForTeleport(value); + + Building building = BuildingManager.getBuildingAtLocation(this.loc); + Regions region = null; + if(building != null){ + //look for region in the building we are in + for(Regions regionCycle : building.getBounds().getRegions()) + if(regionCycle.isPointInPolygon(value)) + region = regionCycle; + } float regionHeightOffset = 0; if(region != null){ this.region = region; From 7886aa6041d41f3aa0302d2846a8252509fbddf9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 18:45:50 -0500 Subject: [PATCH 251/289] building and region lookup completed --- src/engine/devcmd/cmds/RegionCmd.java | 14 +++++++++----- src/engine/gameManager/BuildingManager.java | 6 ++++-- src/engine/objects/AbstractCharacter.java | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index dbda7ae7..74da48fc 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -26,11 +26,13 @@ public class RegionCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { + String newline = "\r\n "; + String output; + output = "Target Region Information:" + newline; + Building building = BuildingManager.getBuildingAtLocation(((AbstractCharacter) target).loc); if(building == null){ this.throwbackInfo(pc, "No Building At This Location.") ; - } else{ - this.throwbackInfo(pc, "Building At Location: " + building.getName()); } Regions region = ((AbstractCharacter)target).region; if (region == null) { @@ -39,9 +41,11 @@ public class RegionCmd extends AbstractDevCmd { } if(region != null) { - this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName()); - this.throwbackInfo(pc, "Region Name: " + region); - this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target)); + output += "Player Info: " + ((AbstractCharacter) target).getName() + newline; + output += "Region Building: " + building.getName() + newline; + output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline; + output += "is Stairs: " + region.stairs + newline; + this.throwbackInfo(pc, output); } } diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index ca32184d..787917dc 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -949,7 +949,7 @@ public enum BuildingManager { building.isDeranking.compareAndSet(true, false); } public static Building getBuildingAtLocation(Vector3fImmutable loc){ - for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,128,MBServerStatics.MASK_BUILDING)){ + for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,64,MBServerStatics.MASK_BUILDING)){ Building building = (Building)awo; if(building == null) continue; @@ -958,7 +958,9 @@ public enum BuildingManager { float minZ = building.loc.z - building.getBounds().getHalfExtents().y; float maxZ = building.loc.z + building.getBounds().getHalfExtents().y; - if(loc.x > minX && loc.x < maxX && loc.z > minZ && loc.x < maxZ) + boolean meetsX = loc.x > minX && loc.x < maxX; + boolean meetsY = loc.z > minZ && loc.z < maxZ; + if(meetsX && meetsY) return building; } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index c8ab7b60..41169b0b 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -991,7 +991,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { if(building != null){ //look for region in the building we are in for(Regions regionCycle : building.getBounds().getRegions()) - if(regionCycle.isPointInPolygon(value)) + if(regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < 10) region = regionCycle; } float regionHeightOffset = 0; From 79eb5b9cdf23989c404bb9ce3ea4bcf7a9e03b3c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 20:03:41 -0500 Subject: [PATCH 252/289] stairs region corrected --- src/engine/devcmd/cmds/RegionCmd.java | 3 ++- src/engine/objects/AbstractCharacter.java | 2 ++ src/engine/objects/Regions.java | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/engine/devcmd/cmds/RegionCmd.java b/src/engine/devcmd/cmds/RegionCmd.java index 74da48fc..7ba118eb 100644 --- a/src/engine/devcmd/cmds/RegionCmd.java +++ b/src/engine/devcmd/cmds/RegionCmd.java @@ -44,7 +44,8 @@ public class RegionCmd extends AbstractDevCmd { output += "Player Info: " + ((AbstractCharacter) target).getName() + newline; output += "Region Building: " + building.getName() + newline; output += "Region Height: " + region.lerpY((AbstractCharacter)target) + newline; - output += "is Stairs: " + region.stairs + newline; + output += "is Stairs: " + region.isStairs() + newline; + output += "is Outside: " + region.isOutside(); this.throwbackInfo(pc, output); } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 41169b0b..a2abf80a 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -27,6 +27,7 @@ import engine.math.Bounds; import engine.math.Vector3fImmutable; import engine.net.ByteBufferWriter; import engine.net.DispatchMessage; +import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.UpdateStateMsg; import engine.powers.EffectsBase; import engine.server.MBServerStatics; @@ -1007,6 +1008,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject { this.inBuildingID = 0; this.inFloorID = -1; } + float terrainHeight = Terrain.getWorldHeight(value); Vector3fImmutable finalLocation = new Vector3fImmutable(value.x,terrainHeight + regionHeightOffset, value.z); super.setLoc(finalLocation); // set the location in the world diff --git a/src/engine/objects/Regions.java b/src/engine/objects/Regions.java index 0b51baca..1683003c 100644 --- a/src/engine/objects/Regions.java +++ b/src/engine/objects/Regions.java @@ -170,10 +170,10 @@ public class Regions { 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 (toEnter.isStairs()) if (worldObject.region.level == toEnter.level || toEnter.level - 1 == worldObject.region.level) return true; - if (worldObject.region.stairs) { + if (worldObject.region.isStairs()) { boolean movingUp = false; @@ -239,7 +239,7 @@ public class Regions { return true; //cant move up a level without stairs. - if (!fromRegion.stairs) + if (!fromRegion.isStairs()) return false; boolean movingUp = false; @@ -367,7 +367,8 @@ public class Regions { } public boolean isStairs() { - return stairs; + + return this.highLerp.y - this.lowLerp.y > 0.25f; } public boolean isExit() { From 7a1700cec3afdce714468813d68c94fb1e0d47e0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 20:17:26 -0500 Subject: [PATCH 253/289] finalized --- src/engine/objects/AbstractCharacter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index a2abf80a..eddf8ba6 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -989,11 +989,13 @@ public abstract class AbstractCharacter extends AbstractWorldObject { Building building = BuildingManager.getBuildingAtLocation(this.loc); Regions region = null; - if(building != null){ + if(building != null) { //look for region in the building we are in - for(Regions regionCycle : building.getBounds().getRegions()) - if(regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < 10) + for (Regions regionCycle : building.getBounds().getRegions()) { + float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y; + if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight) region = regionCycle; + } } float regionHeightOffset = 0; if(region != null){ From e991a01b5007bfb02a7738a653a3a122e1d4b2e2 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 20:21:26 -0500 Subject: [PATCH 254/289] final touch up --- src/engine/objects/AbstractCharacter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index eddf8ba6..03aebf86 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -993,6 +993,8 @@ public abstract class AbstractCharacter extends AbstractWorldObject { //look for region in the building we are in for (Regions regionCycle : building.getBounds().getRegions()) { float regionHeight = regionCycle.highLerp.y - regionCycle.lowLerp.y; + if(regionHeight < 10) + regionHeight = 10; if (regionCycle.isPointInPolygon(value) && Math.abs(regionCycle.highLerp.y - value.y) < regionHeight) region = regionCycle; } From 5e629e7890aead59183289f79b20df7c574b0dd1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Wed, 18 Oct 2023 20:50:47 -0500 Subject: [PATCH 255/289] null checks for Building.getFriends() --- src/engine/gameManager/BuildingManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 787917dc..6e591cc4 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -118,7 +118,7 @@ public enum BuildingManager { return true; //individual friend. - if (building.getFriends().get(player.getObjectUUID()) != null) + if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null) return true; //Admin's can access stuff @@ -132,11 +132,11 @@ public enum BuildingManager { if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) return true; - if (building.getFriends().get(player.getGuild().getObjectUUID()) != null + if (building.getFriends() != null && building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8) return true; - if (building.getFriends().get(player.getGuild().getObjectUUID()) != null + if (building.getFriends() != null && building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus())) return true; From 4274e6a148d3cd73a09d7e2aa5c4069f656e099e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 07:59:44 -0400 Subject: [PATCH 256/289] Cleanup of friend and condemned initialization. --- src/engine/gameManager/BuildingManager.java | 35 +++++++++------------ src/engine/objects/Building.java | 19 ++++++++--- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 6e591cc4..3dcd8bb6 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -18,7 +18,6 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeBuildingJob; import engine.math.Bounds; -import engine.math.Vector2f; import engine.math.Vector3fImmutable; import engine.net.client.ClientConnection; import engine.net.client.msg.ErrorPopupMsg; @@ -27,9 +26,7 @@ import engine.net.client.msg.PlaceAssetMsg; import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import org.w3c.dom.css.Rect; -import java.awt.*; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; @@ -110,7 +107,6 @@ public enum BuildingManager { if (building == null) return false; - if (building.getRank() == -1) return false; @@ -121,22 +117,21 @@ public enum BuildingManager { if (building.getFriends() != null && building.getFriends().get(player.getObjectUUID()) != null) return true; - //Admin's can access stuff + //Admins can access stuff if (player.isCSR()) return true; //Guild stuff - - if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) + if (building.getGuild().isGuildLeader(player.getObjectUUID())) return true; - if (building.getFriends() != null && building.getFriends().get(player.getGuild().getObjectUUID()) != null + if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8) return true; - if (building.getFriends() != null && building.getFriends().get(player.getGuild().getObjectUUID()) != null + if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus())) return true; @@ -948,22 +943,20 @@ public enum BuildingManager { building.isDeranking.compareAndSet(true, false); } - public static Building getBuildingAtLocation(Vector3fImmutable loc){ - for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc,64,MBServerStatics.MASK_BUILDING)){ - Building building = (Building)awo; - if(building == null) + + public static Building getBuildingAtLocation(Vector3fImmutable loc) { + + for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(loc, 64, MBServerStatics.MASK_BUILDING)) { + Building building = (Building) awo; + + if (building == null) continue; - float minX = building.loc.x - building.getBounds().getHalfExtents().x; - float maxX = building.loc.x + building.getBounds().getHalfExtents().x; - float minZ = building.loc.z - building.getBounds().getHalfExtents().y; - float maxZ = building.loc.z + building.getBounds().getHalfExtents().y; - - boolean meetsX = loc.x > minX && loc.x < maxX; - boolean meetsY = loc.z > minZ && loc.z < maxZ; - if(meetsX && meetsY) + + if (Bounds.collide(loc, building)) return building; } return null; } + } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 3acefafb..2b85d26d 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -95,7 +95,7 @@ public class Building extends AbstractWorldObject { private ConcurrentHashMap timers = null; private ConcurrentHashMap timestamps = null; private ConcurrentHashMap friends; - private ConcurrentHashMap condemned = new ConcurrentHashMap<>(); + private ConcurrentHashMap condemned; public ProtectionState protectionState = ProtectionState.NONE; private ArrayList children = null; @@ -969,17 +969,28 @@ public class Building extends AbstractWorldObject { // Reference friend and condemn lists from BuildingManager this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID()); + + if (this.friends == null) { + this.friends = new ConcurrentHashMap<>(); + BuildingManager._buildingFriends.put(this.getObjectUUID(), this.friends); + } + this.condemned = BuildingManager._buildingCondemned.get(this.getObjectUUID()); + if (this.condemned == null) { + this.condemned = new ConcurrentHashMap<>(); + BuildingManager._buildingCondemned.put(this.getObjectUUID(), this.condemned); + } + //LOad Owners in Cache so we do not have to continuely look in the db for owner. if (this.ownerIsNPC) { if (NPC.getNPC(this.ownerUUID) == null) Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); - } else if (this.ownerUUID != 0) { - if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) { - Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); + } else if (this.ownerUUID != 0) { + if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) { + Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); } } From 944bcb7e84ddd0860a8ba24249a72f2db0c3665f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 08:15:22 -0400 Subject: [PATCH 257/289] Changed method used to direct bounds --- src/engine/gameManager/BuildingManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 3dcd8bb6..d87b5589 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -951,8 +951,9 @@ public enum BuildingManager { if (building == null) continue; + ; - if (Bounds.collide(loc, building)) + if (Bounds.collide(loc, building.getBounds())) return building; } From fb6ec0caf47310380cda11456d0c63653a23c07c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 08:15:32 -0400 Subject: [PATCH 258/289] Changed method used to direct bounds --- src/engine/gameManager/BuildingManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index d87b5589..096fce75 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -951,7 +951,6 @@ public enum BuildingManager { if (building == null) continue; - ; if (Bounds.collide(loc, building.getBounds())) return building; From 5858fa4de4efdc09890597795168f74dc878cf95 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 08:20:28 -0400 Subject: [PATCH 259/289] R8 bonus application moved to City --- src/engine/objects/Building.java | 29 +------------------------- src/engine/objects/City.java | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 2b85d26d..aa06721d 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -994,34 +994,6 @@ public class Building extends AbstractWorldObject { } } - // Apply health bonus and special mesh for realm if applicable - if ((this.getCity() != null) && this.getCity().getTOL() != null && (this.getCity().getTOL().rank == 8)) { - - // Update mesh accordingly - if (this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() == BuildingGroup.TOL) - this.meshUUID = Realm.getRealmMesh(this.getCity()); - - // Apply realm capital health bonus. - // Do not apply bonus to banestones or TOL's. *** Refactor: - // Possibly only protected buildings? Needs some thought. - - float missingHealth = 0; - - if (this.health.get() != 0) - missingHealth = this.healthMax - this.health.get(); - - if ((this.getBlueprint() != null && this.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) - && (this.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE)) { - this.healthMax += (this.healthMax * Realm.getRealmHealthMod(this.getCity())); - - if (this.health.get() != 0) - this.health.set(this.healthMax - missingHealth); - - if (this.health.get() > this.healthMax) - this.health.set(this.healthMax); - } - } - // Set bounds for this building Bounds buildingBounds = Bounds.borrow(); @@ -1043,6 +1015,7 @@ public class Building extends AbstractWorldObject { //add furniture to region cache. floor and level are reversed in database, //TODO Fix Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z); + if (region != null) Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 9bca4b2c..a27dc5a8 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -761,6 +761,41 @@ public class City extends AbstractWorldObject { } } + // Apply health bonus and special mesh for realm if applicable + + if (this.getTOL().rank == 8) { + + // Update mesh accordingly + + this.getTOL().meshUUID = Realm.getRealmMesh(this); + + // Apply realm capital health bonus. + // Do not apply bonus to banestones or TOL's. *** Refactor: + // Possibly only protected buildings? Needs some thought. + + float missingHealth = 0; + + if (this.health.get() != 0) + missingHealth = this.healthMax - this.health.get(); + + for (Building building : this.parentZone.zoneBuildingSet) { + + if (building.getBlueprint() != null && + building.getBlueprint().getBuildingGroup() != BuildingGroup.BANESTONE && + building.getBlueprint().getBuildingGroup() != BuildingGroup.TOL) { + + building.healthMax += (building.healthMax * Realm.getRealmHealthMod(this)); + + if (this.health.get() != 0) + this.health.set(this.healthMax - missingHealth); + + if (this.health.get() > this.healthMax) + this.health.set(this.healthMax); + } + + } + } + // Banes are loaded for this city from the database at this point if (this.getBane() == null) From a2df7cda22ade05023b0fa4d39faa6b7fffdb400 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 08:47:28 -0400 Subject: [PATCH 260/289] Inlined populate world method --- src/engine/server/world/WorldServer.java | 29 +++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index e79b2d07..19685fe5 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -415,7 +415,17 @@ public class WorldServer { //Load Buildings, Mobs and NPCs for server - getWorldBuildingsMobsNPCs(); + Logger.info("Populating world with objects"); + + long start = System.currentTimeMillis(); + + DbManager.ZoneQueries.GET_ALL_ZONES(); + DbManager.BuildingQueries.GET_ALL_BUILDINGS(); + DbManager.NPCQueries.GET_ALL_NPCS(); + DbManager.MobQueries.GET_ALL_MOBS(); + DbManager.CityQueries.GET_ALL_CITIES(); + + Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); // Configure realms for serialization // Doing this after the world is loaded @@ -445,7 +455,7 @@ public class WorldServer { ZoneManager.generateAndSetRandomHotzone(); Logger.info("Loading All Players from database to Server Cache"); - long start = System.currentTimeMillis(); + start = System.currentTimeMillis(); try { DbManager.PlayerCharacterQueries.GET_ALL_CHARACTERS(); @@ -455,7 +465,7 @@ public class WorldServer { long end = System.currentTimeMillis(); - Logger.info("Loading All Players took " + (end - start) + " ms."); + Logger.info("Time to load players " + (end - start) + " ms."); ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); @@ -537,19 +547,6 @@ public class WorldServer { return true; } - private void getWorldBuildingsMobsNPCs() { - - long start = System.currentTimeMillis(); - - DbManager.ZoneQueries.GET_ALL_ZONES(); - DbManager.BuildingQueries.GET_ALL_BUILDINGS(); - DbManager.NPCQueries.GET_ALL_NPCS(); - DbManager.MobQueries.GET_ALL_MOBS(); - DbManager.CityQueries.GET_ALL_CITIES(); - - Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); - } - /** * Called to remove a client on "leave world", "quit game", killed client * process, etc. From fff16d22117162e50e602ad8c8a60ecc42e2f150 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 16:10:53 -0400 Subject: [PATCH 261/289] Comment cleanup --- src/engine/gameManager/ZoneManager.java | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index a4e4ebf1..86081dd5 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -298,8 +298,6 @@ public enum ZoneManager { localCoords = new Vector2f(worldLoc.x, worldLoc.z); localCoords = localCoords.subtract(zoneOrigin); - // TODO : Make sure this value does not go outside the zone's bounds. - return localCoords; } @@ -320,9 +318,10 @@ public enum ZoneManager { if (building.getBounds().getQuaternion() == null) return building.getLoc(); + // handle building rotation + Vector3fImmutable rotatedLocal = Vector3fImmutable.rotateAroundPoint(Vector3fImmutable.ZERO, localPos, building.getBounds().getQuaternion()); - // handle building rotation // handle building translation return building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z); @@ -332,12 +331,10 @@ public enum ZoneManager { //used for regions, Building bounds not set yet. public static Vector3f convertLocalToWorld(Building building, Vector3f localPos, Bounds bounds) { - // convert from SB rotation value to radians - + // handle building rotation Vector3f rotatedLocal = Vector3f.rotateAroundPoint(Vector3f.ZERO, localPos, bounds.getQuaternion()); - // handle building rotation // handle building translation return new Vector3f(building.getLoc().add(rotatedLocal.x, rotatedLocal.y, rotatedLocal.z)); @@ -360,8 +357,6 @@ public enum ZoneManager { public static City getCityAtLocation(Vector3fImmutable worldLoc) { Zone currentZone; - ArrayList zoneList; - City city; currentZone = ZoneManager.findSmallestZone(worldLoc); @@ -408,27 +403,27 @@ public enum ZoneManager { public static float calculateGlobalZoneHeight(Zone zone) { - float worldAlttitude = MBServerStatics.SEA_FLOOR_ALTITUDE; + float worldAltitude = MBServerStatics.SEA_FLOOR_ALTITUDE; // Seafloor if (ZoneManager.seaFloor.equals(zone)) - return worldAlttitude; + return worldAltitude; // Children of seafloor if (ZoneManager.seaFloor.equals(zone.parent)) - return worldAlttitude + zone.yOffset; + return worldAltitude + zone.yOffset; // return height from heightmap engine at zone location - worldAlttitude = Terrain.getWorldHeight(zone.parent, zone.getLoc()); + worldAltitude = Terrain.getWorldHeight(zone.parent, zone.getLoc()); // Add zone offset to value - worldAlttitude += zone.yOffset; + worldAltitude += zone.yOffset; - return worldAlttitude; + return worldAltitude; } public static boolean isLocUnderwater(Vector3fImmutable currentLoc) { From 6a76cc7a291230abe7c9b8064ec1960cdea5f01c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 16:20:43 -0400 Subject: [PATCH 262/289] Patrol points loaded --- src/engine/db/handlers/dbBuildingHandler.java | 23 +++++++++++++++++++ src/engine/gameManager/BuildingManager.java | 1 + 2 files changed, 24 insertions(+) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index d1786e1f..21a20fe6 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -489,6 +489,29 @@ public class dbBuildingHandler extends dbHandlerBase { } } + public void LOAD_BARRACKS_PATROL_POINTS() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + + int buildingUUID = rs.getInt("buildingUID"); + + if (!BuildingManager._buildingPatrolPoints.containsKey(buildingUUID)) + BuildingManager._buildingPatrolPoints.put(buildingUUID, new ArrayList<>()); + + Vector3fImmutable patrolPoint = new Vector3fImmutable(rs.getFloat("patrolX"), rs.getFloat("patrolY"), rs.getFloat("patrolZ")); + BuildingManager._buildingPatrolPoints.get(buildingUUID).add(patrolPoint); + } + + } catch (SQLException e) { + Logger.error(e); + } + } + public ArrayList LOAD_PATROL_POINTS(Building building) { if (building == null) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 096fce75..bde12730 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -43,6 +43,7 @@ public enum BuildingManager { public static HashMap> _buildingFriends = new HashMap<>(); public static HashMap> _buildingCondemned = new HashMap<>(); + public static HashMap> _buildingPatrolPoints = new HashMap<>(); public static int getAvailableSlot(Building building) { ArrayList slotLocations = _slotLocations.get(building.meshUUID); From cf7e19bfde805e81843b707e104b4921d4d6e0b7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 16:24:18 -0400 Subject: [PATCH 263/289] Patrol points loaded --- src/engine/server/world/WorldServer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 19685fe5..df8c866d 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -312,18 +312,21 @@ public class WorldServer { Logger.info("Initializing PowersManager."); PowersManager.initPowersManager(true); - Logger.info("Initializing granted Skills for Runes"); + Logger.info("Loading granted Skills for Runes"); DbManager.SkillsBaseQueries.LOAD_ALL_RUNE_SKILLS(); - Logger.info("Initializing Player Friends"); + Logger.info("Loading Player Friends"); DbManager.PlayerCharacterQueries.LOAD_PLAYER_FRIENDS(); - Logger.info("Initializing Building Friends"); + Logger.info("Loading Building Friends"); DbManager.BuildingQueries.LOAD_BUILDING_FRIENDS(); - Logger.info("Initializing Building Condemned"); + Logger.info("Loading Building Condemned"); DbManager.BuildingQueries.LOAD_BUILDING_CONDEMNED(); + Logger.info("Loading Barracks Patrol Points"); + DbManager.BuildingQueries.LOAD_BARRACKS_PATROL_POINTS(); + Logger.info("Initializing NPC Profits"); DbManager.NPCQueries.LOAD_NPC_PROFITS(); From 1daa45d6047bbe875825828f0db6a2f7b81bfbc4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 16:44:29 -0400 Subject: [PATCH 264/289] New collection utilized --- src/engine/objects/Building.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index aa06721d..e62d9dd9 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -63,7 +63,6 @@ public class Building extends AbstractWorldObject { public float statAlt; public LocalDateTime upgradeDateTime = null; public LocalDateTime taxDateTime = null; - public ArrayList patrolPoints = new ArrayList<>(); public ArrayList sentryPoints = new ArrayList<>(); public TaxType taxType = TaxType.NONE; public int taxAmount; @@ -96,6 +95,7 @@ public class Building extends AbstractWorldObject { private ConcurrentHashMap timestamps = null; private ConcurrentHashMap friends; private ConcurrentHashMap condemned; + public ArrayList patrolPoints; public ProtectionState protectionState = ProtectionState.NONE; private ArrayList children = null; @@ -926,8 +926,7 @@ public class Building extends AbstractWorldObject { if (this.blueprintUUID == 0) this.setHealth(healthMax); - if (blueprint.getBuildingGroup().equals(BuildingGroup.BARRACK)) - this.patrolPoints = DbManager.BuildingQueries.LOAD_PATROL_POINTS(this); + this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>()); } else { this.healthMax = 100000; // Structures with no blueprint mesh From eaaba8ab0c69902695fed34a57cd60cacf51e314 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 16:48:39 -0400 Subject: [PATCH 265/289] Refactored assignment. --- src/engine/objects/Building.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index e62d9dd9..e39536fb 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -967,19 +967,8 @@ public class Building extends AbstractWorldObject { // Reference friend and condemn lists from BuildingManager - this.friends = BuildingManager._buildingFriends.get(this.getObjectUUID()); - - if (this.friends == null) { - this.friends = new ConcurrentHashMap<>(); - BuildingManager._buildingFriends.put(this.getObjectUUID(), this.friends); - } - - this.condemned = BuildingManager._buildingCondemned.get(this.getObjectUUID()); - - if (this.condemned == null) { - this.condemned = new ConcurrentHashMap<>(); - BuildingManager._buildingCondemned.put(this.getObjectUUID(), this.condemned); - } + this.friends = BuildingManager._buildingFriends.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); + this.condemned = BuildingManager._buildingCondemned.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); //LOad Owners in Cache so we do not have to continuely look in the db for owner. From 3ef444c128631367cd16af7616d575a0a0995b8b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 16:53:15 -0400 Subject: [PATCH 266/289] Cleanup in runafterload --- src/engine/objects/Building.java | 168 ++++++++++++++----------------- 1 file changed, 76 insertions(+), 92 deletions(-) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index e39536fb..18715e6c 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -75,11 +75,14 @@ public class Building extends AbstractWorldObject { public int level; public AtomicBoolean isDeranking = new AtomicBoolean(false); public LocalDateTime maintDateTime; - protected Resists resists; /* The Blueprint class has methods able to derive * all defining characteristics of this building, */ public int blueprintUUID = 0; + public int rank; + public ArrayList patrolPoints; + public ProtectionState protectionState = ProtectionState.NONE; + protected Resists resists; private float w = 1.0f; private Vector3f meshScale = new Vector3f(1.0f, 1.0f, 1.0f); private int doorState = 0; @@ -88,15 +91,12 @@ public class Building extends AbstractWorldObject { private int maxGold; private int effectFlags = 0; private String name = ""; - public int rank; private boolean ownerIsNPC = true; private boolean spireIsActive = false; private ConcurrentHashMap timers = null; private ConcurrentHashMap timestamps = null; private ConcurrentHashMap friends; private ConcurrentHashMap condemned; - public ArrayList patrolPoints; - public ProtectionState protectionState = ProtectionState.NONE; private ArrayList children = null; /** @@ -164,7 +164,7 @@ public class Building extends AbstractWorldObject { this.upgradeDateTime = LocalDateTime.ofInstant(upgradeTimeStamp.toInstant(), ZoneId.systemDefault()); } catch (Exception e) { - Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e.toString()); + Logger.error("Failed for object " + this.blueprintUUID + ' ' + this.getObjectUUID() + e); } } @@ -385,14 +385,14 @@ public class Building extends AbstractWorldObject { Mine.SendMineAttackMessage(this); City playerCity = ZoneManager.getCityAtLocation(this.loc); - if(playerCity != null){ - if(this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())){ + if (playerCity != null) { + if (this.getGuild().getNation().equals(playerCity.getTOL().getGuild().getNation())) { //friendly building has been attacked, add attacker to city outlaw list - if(!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) + if (!playerCity.cityOutlaws.contains(attacker.getObjectUUID()) && attacker.getObjectType().equals(GameObjectType.PlayerCharacter)) playerCity.cityOutlaws.add(attacker.getObjectUUID()); - for(Mob guard : playerCity.getParent().zoneMobSet) - if(guard.combatTarget == null) - guard.setCombatTarget(attacker); + for (Mob guard : playerCity.getParent().zoneMobSet) + if (guard.combatTarget == null) + guard.setCombatTarget(attacker); } } @@ -888,72 +888,71 @@ public class Building extends AbstractWorldObject { @Override public void runAfterLoad() { - // Set Parent Zone + // Set Parent Zone - this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); - this.parentZone.zoneBuildingSet.add(this); + this.parentZone = ZoneManager.getZoneByUUID(this.parentZoneUUID); + this.parentZone.zoneBuildingSet.add(this); - // Lookup building blueprint + // Lookup building blueprint - Blueprint blueprint; - - if (this.blueprintUUID == 0) - blueprint = Blueprint._meshLookup.get(meshUUID); - else - blueprint = this.getBlueprint(); - - // Log error if something went horrible wrong + Blueprint blueprint; - if ((this.blueprintUUID != 0) && (blueprint == null)) - Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); + if (this.blueprintUUID == 0) + blueprint = Blueprint._meshLookup.get(meshUUID); + else + blueprint = this.getBlueprint(); - // Note: We handle R8 tree edge case for mesh and health - // after city is loaded to avoid recursive result set call - // in City resulting in a stack ovreflow. + // Log error if something went horrible wrong - if (blueprint != null) { + if ((this.blueprintUUID != 0) && (blueprint == null)) + Logger.error("Invalid blueprint for object: " + this.getObjectUUID()); - // Only switch mesh for player dropped structures + // Note: We handle R8 tree edge case for mesh and health + // after city is loaded to avoid recursive result set call + // in City resulting in a stack ovreflow. - if (this.blueprintUUID != 0) - this.meshUUID = blueprint.getMeshForRank(rank); + if (blueprint != null) { - this.healthMax = blueprint.getMaxHealth(this.rank); + // Only switch mesh for player dropped structures - // If this object has no blueprint but is a blueprint - // mesh then set it's current health to max health + if (this.blueprintUUID != 0) + this.meshUUID = blueprint.getMeshForRank(rank); - if (this.blueprintUUID == 0) - this.setHealth(healthMax); + this.healthMax = blueprint.getMaxHealth(this.rank); - this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>()); + // If this object has no blueprint but is a blueprint + // mesh then set it's current health to max health - } else { - this.healthMax = 100000; // Structures with no blueprint mesh + if (this.blueprintUUID == 0) this.setHealth(healthMax); - } - resists = new Resists("Building"); + this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>()); - if (this.parentZone != null) { - if (this.parentBuildingID != 0) { - Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); - if (parentBuilding != null) { - this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); - } else { - this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); + } else { + this.healthMax = 100000; // Structures with no blueprint mesh + this.setHealth(healthMax); + } - } - } else { + resists = new Resists("Building"); - // Altitude of this building is derived from the heightmap engine. + if (this.parentZone != null) { + if (this.parentBuildingID != 0) { + Building parentBuilding = BuildingManager.getBuilding(this.parentBuildingID); + if (parentBuilding != null) { + this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX + parentBuilding.statLat, this.statAlt + this.parentZone.absY + parentBuilding.statAlt, this.statLon + this.parentZone.absZ + parentBuilding.statLon)); + } else { + this.setLoc(new Vector3fImmutable(this.statLat + this.parentZone.absX, this.statAlt + this.parentZone.absY, this.statLon + this.parentZone.absZ)); - Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); - tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); - this.setLoc(tempLoc); } - } + } else { + // Altitude of this building is derived from the heightmap engine. + + Vector3fImmutable tempLoc = new Vector3fImmutable(this.statLat + this.parentZone.absX, 0, this.statLon + this.parentZone.absZ); + tempLoc = new Vector3fImmutable(tempLoc.x, Terrain.getWorldHeight(tempLoc), tempLoc.z); + this.setLoc(tempLoc); + } + } // Submit upgrade job if building is currently set to rank. @@ -970,48 +969,36 @@ public class Building extends AbstractWorldObject { this.friends = BuildingManager._buildingFriends.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); this.condemned = BuildingManager._buildingCondemned.computeIfAbsent(this.getObjectUUID(), k -> new ConcurrentHashMap<>()); - //LOad Owners in Cache so we do not have to continuely look in the db for owner. - - if (this.ownerIsNPC) { - if (NPC.getNPC(this.ownerUUID) == null) - Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); - - } else if (this.ownerUUID != 0) { - if (PlayerCharacter.getPlayerCharacter(this.ownerUUID) == null) { - Logger.info("Building UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.ownerUUID + " Location " + this.getLoc().toString()); - } - } - - // Set bounds for this building + // Set bounds for this building - Bounds buildingBounds = Bounds.borrow(); - buildingBounds.setBounds(this); - this.setBounds(buildingBounds); + Bounds buildingBounds = Bounds.borrow(); + buildingBounds.setBounds(this); + this.setBounds(buildingBounds); - //create a new list for children if the building is not a child. children list default is null. - //TODO Remove Furniture/Child buildings from building class and move them into a seperate class. + //create a new list for children if the building is not a child. children list default is null. + //TODO Remove Furniture/Child buildings from building class and move them into a seperate class. - if (this.parentBuildingID == 0) - this.children = new ArrayList<>(); + if (this.parentBuildingID == 0) + this.children = new ArrayList<>(); - if (this.parentBuildingID != 0) { - Building parent = BuildingManager.getBuildingFromCache(this.parentBuildingID); + if (this.parentBuildingID != 0) { + Building parent = BuildingManager.getBuilding(this.parentBuildingID); - if (parent != null) { - parent.children.add(this); + if (parent != null) { + parent.children.add(this); - //add furniture to region cache. floor and level are reversed in database, //TODO Fix + //add furniture to region cache. floor and level are reversed in database, //TODO Fix - Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z); - - if (region != null) - Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); - } + Regions region = BuildingManager.GetRegion(parent, this.level, this.floor, this.getLoc().x, this.getLoc().z); + if (region != null) + Regions.FurnitureRegionMap.put(this.getObjectUUID(), region); } - if (this.upgradeDateTime != null) - BuildingManager.submitUpgradeJob(this); + } + + if (this.upgradeDateTime != null) + BuildingManager.submitUpgradeJob(this); } public synchronized boolean setOwner(AbstractCharacter newOwner) { @@ -1400,10 +1387,7 @@ public class Building extends AbstractWorldObject { public boolean assetIsProtected() { - boolean outValue = false; - - if (protectionState.equals(ProtectionState.PROTECTED)) - outValue = true; + boolean outValue = protectionState.equals(ProtectionState.PROTECTED); if (protectionState.equals(ProtectionState.CONTRACT)) outValue = true; From 1c93846ed3e6e1414a2d03136d061a387e996835 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 19 Oct 2023 17:01:26 -0400 Subject: [PATCH 267/289] Full error is output --- src/engine/mobileAI/MobAI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 0fa3d462..c50fd941 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -1263,7 +1263,7 @@ public class MobAI { } } } catch (Exception e) { - Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e.getMessage()); + Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: randomGuardPatrolPoints" + " " + e); } } From 4c994e6e550a2fc048e33d5ebcf73af0ec5ce803 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 08:06:40 -0400 Subject: [PATCH 268/289] Removed old method --- src/engine/db/handlers/dbBuildingHandler.java | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/src/engine/db/handlers/dbBuildingHandler.java b/src/engine/db/handlers/dbBuildingHandler.java index 21a20fe6..375dbf17 100644 --- a/src/engine/db/handlers/dbBuildingHandler.java +++ b/src/engine/db/handlers/dbBuildingHandler.java @@ -512,37 +512,6 @@ public class dbBuildingHandler extends dbHandlerBase { } } - public ArrayList LOAD_PATROL_POINTS(Building building) { - - if (building == null) - return null; - - ArrayList patrolPoints = new ArrayList<>(); - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_building_patrol_points` WHERE `buildingUID` = ?")) { - - preparedStatement.setInt(1, building.getObjectUUID()); - - - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - float x1 = rs.getFloat("patrolX"); - float y1 = rs.getFloat("patrolY"); - float z1 = rs.getFloat("patrolZ"); - Vector3fImmutable patrolPoint = new Vector3fImmutable(x1, y1, z1); - patrolPoints.add(patrolPoint); - } - - } catch (SQLException e) { - Logger.error(e); - } - - return patrolPoints; - - } - public boolean ADD_TO_CONDEMNLIST(final long parentUID, final long playerUID, final long guildID, final int friendType) { try (Connection connection = DbManager.getConnection(); From 3a63f98ac3b5b161d5ab4ea62efa4d203eb6a813 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 08:09:42 -0400 Subject: [PATCH 269/289] Error log added --- src/engine/objects/Building.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 18715e6c..b60415e3 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -928,6 +928,9 @@ public class Building extends AbstractWorldObject { this.patrolPoints = BuildingManager._buildingPatrolPoints.computeIfAbsent(this.getObjectUUID(), k -> new ArrayList<>()); + if (this.patrolPoints == null) + Logger.error("Null patrol points"); + } else { this.healthMax = 100000; // Structures with no blueprint mesh this.setHealth(healthMax); From f0fedcc049df82c0fce95cf087336e1c89cf15f5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 09:39:05 -0400 Subject: [PATCH 270/289] Cleanup and reformat --- src/engine/objects/Guild.java | 54 +++++++++-------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 154e286a..8bb733d7 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -189,22 +189,6 @@ public class Guild extends AbstractWorldObject { return a.getObjectUUID() == b.getObjectUUID(); } - public static boolean sameGuildExcludeErrant(Guild a, Guild b) { - if (a == null || b == null) - return false; - if (a.isEmptyGuild() || b.isEmptyGuild()) - return false; - return a.getObjectUUID() == b.getObjectUUID(); - } - - public static boolean sameGuildIncludeErrant(Guild a, Guild b) { - if (a == null || b == null) - return false; - if (a.isEmptyGuild() || b.isEmptyGuild()) - return true; - return a.getObjectUUID() == b.getObjectUUID(); - } - public static boolean sameNation(Guild a, Guild b) { if (a == null || b == null) return false; @@ -225,11 +209,6 @@ public class Guild extends AbstractWorldObject { return a.nation.getObjectUUID() == b.nation.getObjectUUID() && !a.nation.isEmptyGuild(); } - public static boolean isTaxCollector(int uuid) { - //TODO add the handling for this later - return false; - } - public static boolean canSwearIn(Guild toSub) { boolean canSwear = false; @@ -393,7 +372,9 @@ public class Guild extends AbstractWorldObject { } public static ArrayList GuildRoster(Guild guild) { + ArrayList roster = new ArrayList<>(); + if (guild == null) return roster; @@ -402,6 +383,7 @@ public class Guild extends AbstractWorldObject { if (DbManager.getList(GameObjectType.PlayerCharacter) == null) return roster; + for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)) { PlayerCharacter toAdd = (PlayerCharacter) ago; @@ -462,14 +444,6 @@ public class Guild extends AbstractWorldObject { return banishList; } - public ArrayList getCharacterKOSList() { - return characterKOSList; - } - - public ArrayList getGuildKOSList() { - return guildKOSList; - } - public ArrayList getAllyList() { return allyList; } @@ -560,9 +534,12 @@ public class Guild extends AbstractWorldObject { } public boolean setGuildLeader(AbstractCharacter ac) { + if (ac == null) return false; + // errant guilds cant be guild leader. + if (this.isEmptyGuild()) return false; @@ -575,6 +552,7 @@ public class Guild extends AbstractWorldObject { PlayerCharacter oldGuildLeader = PlayerCharacter.getFromCache(this.guildLeaderUUID); //old guildLeader no longer has guildLeadership stauts. + if (oldGuildLeader != null) oldGuildLeader.setGuildLeader(false); @@ -586,9 +564,12 @@ public class Guild extends AbstractWorldObject { } public boolean setGuildLeaderForCreate(AbstractCharacter ac) { + if (ac == null) return false; + // errant guilds cant be guild leader. + if (this.isEmptyGuild()) return false; @@ -824,17 +805,6 @@ public class Guild extends AbstractWorldObject { Logger.error("Failed to find Object Type for owner " + this.guildLeaderUUID); } - - //LOad Owners in Cache so we do not have to continuely look in the db for owner. - if (this.ownerIsNPC) { - if (NPC.getNPC(this.guildLeaderUUID) == null) - Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.guildLeaderUUID); - - } else if (this.guildLeaderUUID != 0) { - if (PlayerCharacter.getPlayerCharacter(this.guildLeaderUUID) == null) - Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.guildLeaderUUID); - } - // If loading this guild for the first time write it's character record to disk if (ConfigManager.serverType.equals(ServerType.WORLDSERVER) @@ -859,7 +829,9 @@ public class Guild extends AbstractWorldObject { if (this.nation == null) this.nation = Guild.getErrantGuild(); + //Get guild states. + try { this.subGuildList = DbManager.GuildQueries.GET_SUB_GUILDS(this.getObjectUUID()); } catch (Exception e) { @@ -882,7 +854,6 @@ public class Guild extends AbstractWorldObject { if (this.cityUUID == 0) return; - // Calculate number of realms this guild controls // Only do this on the game server to avoid loading a TOL/City/Zone needlessly @@ -898,6 +869,7 @@ public class Guild extends AbstractWorldObject { //add alliance list, clear all lists as there seems to be a bug where alliances are doubled, need to find where. //possible runAfterLoad being called twice?!?! + this.banishList = dbGuildHandler.GET_GUILD_BANISHED(this.getObjectUUID()); this.characterKOSList = DbManager.GuildQueries.GET_GUILD_KOS_CHARACTER(this.getObjectUUID()); this.guildKOSList = DbManager.GuildQueries.GET_GUILD_KOS_GUILD(this.getObjectUUID()); From a487a7bd2f054a8a6e461978b03e7ea196e0789e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 09:41:24 -0400 Subject: [PATCH 271/289] Removed duplicate and unused code --- src/engine/objects/Guild.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 8bb733d7..9ea566e4 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -59,8 +59,6 @@ public class Guild extends AbstractWorldObject { private int cityUUID = 0; private int mineTime; private ArrayList banishList; - private ArrayList characterKOSList; - private ArrayList guildKOSList; private ArrayList allyList = new ArrayList<>(); private ArrayList enemyList = new ArrayList<>(); private ArrayList recommendList = new ArrayList<>(); @@ -83,8 +81,6 @@ public class Guild extends AbstractWorldObject { this.leadershipType = leadershipType; this.banishList = new ArrayList<>(); - this.characterKOSList = new ArrayList<>(); - this.guildKOSList = new ArrayList<>(); this.allyList = new ArrayList<>(); this.enemyList = new ArrayList<>(); this.subGuildList = new ArrayList<>(); @@ -115,8 +111,6 @@ public class Guild extends AbstractWorldObject { this.leadershipType = leadershipType; this.banishList = new ArrayList<>(); - this.characterKOSList = new ArrayList<>(); - this.guildKOSList = new ArrayList<>(); this.allyList = new ArrayList<>(); this.enemyList = new ArrayList<>(); this.subGuildList = new ArrayList<>(); @@ -869,10 +863,8 @@ public class Guild extends AbstractWorldObject { //add alliance list, clear all lists as there seems to be a bug where alliances are doubled, need to find where. //possible runAfterLoad being called twice?!?! - + this.banishList = dbGuildHandler.GET_GUILD_BANISHED(this.getObjectUUID()); - this.characterKOSList = DbManager.GuildQueries.GET_GUILD_KOS_CHARACTER(this.getObjectUUID()); - this.guildKOSList = DbManager.GuildQueries.GET_GUILD_KOS_GUILD(this.getObjectUUID()); this.allyList.clear(); this.enemyList.clear(); From 7ce94a51660014f5218b868325660a3a1e099cd6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 09:48:24 -0400 Subject: [PATCH 272/289] should never pull directly form cache --- src/engine/mobileAI/MobAI.java | 6 +++--- src/engine/objects/Building.java | 5 +++-- src/engine/objects/City.java | 7 ------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index c50fd941..22cd65dd 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -657,7 +657,7 @@ public class MobAI { for (Entry playerEntry : loadedPlayers.entrySet()) { int playerID = (int) playerEntry.getKey(); - PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); + PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID); //Player is null, let's remove them from the list. @@ -1105,7 +1105,7 @@ public class MobAI { for (Entry playerEntry : loadedPlayers.entrySet()) { int playerID = (int) playerEntry.getKey(); - PlayerCharacter loadedPlayer = PlayerCharacter.getFromCache(playerID); + PlayerCharacter loadedPlayer = PlayerCharacter.getPlayerCharacter(playerID); //Player is null, let's remove them from the list. @@ -1280,7 +1280,7 @@ public class MobAI { for (Entry playerEntry : mob.playerAgroMap.entrySet()) { - PlayerCharacter potentialTarget = PlayerCharacter.getFromCache((int) playerEntry.getKey()); + PlayerCharacter potentialTarget = PlayerCharacter.getPlayerCharacter((int) playerEntry.getKey()); if (potentialTarget.equals(mob.getCombatTarget())) continue; diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index b60415e3..b288f0e2 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -807,10 +807,11 @@ public class Building extends AbstractWorldObject { if (this.ownerUUID == 0) return null; + if (this.ownerIsNPC) - return NPC.getFromCache(this.ownerUUID); + return NPC.getNPC(this.ownerUUID); - return PlayerCharacter.getFromCache(this.ownerUUID); + return PlayerCharacter.getPlayerCharacter(this.ownerUUID); } diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index a27dc5a8..1b12ee4d 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -868,7 +868,6 @@ public class City extends AbstractWorldObject { player.addCityEffect(Integer.toString(effectBase.getUUID()), effectBase, rank, MBServerStatics.FOURTYFIVE_SECONDS, false, this); } - } public Warehouse getWarehouse() { @@ -894,12 +893,6 @@ public class City extends AbstractWorldObject { return collided; } - public boolean isLocationOnCityGrid(Bounds newBounds) { - - boolean collided = Bounds.collide(this.getBounds(), newBounds, 0); - return collided; - } - public boolean isLocationWithinSiegeBounds(Vector3fImmutable insideLoc) { return insideLoc.isInsideCircle(this.getLoc(), CityBoundsType.ZONE.halfExtents); From 781a4ee16d9284903ddcfb71cbf4ac5191291ea8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 09:50:48 -0400 Subject: [PATCH 273/289] Load cities after buildings --- src/engine/server/world/WorldServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index df8c866d..1cd9d0a2 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -424,9 +424,9 @@ public class WorldServer { DbManager.ZoneQueries.GET_ALL_ZONES(); DbManager.BuildingQueries.GET_ALL_BUILDINGS(); + DbManager.CityQueries.GET_ALL_CITIES(); DbManager.NPCQueries.GET_ALL_NPCS(); DbManager.MobQueries.GET_ALL_MOBS(); - DbManager.CityQueries.GET_ALL_CITIES(); Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); From db8b33a621174835f67eef7bba9e7bca03180820 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 09:58:47 -0400 Subject: [PATCH 274/289] No longer pre-cache players --- src/engine/server/world/WorldServer.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 1cd9d0a2..b5a8f883 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -457,19 +457,6 @@ public class WorldServer { //pick a startup Hotzone ZoneManager.generateAndSetRandomHotzone(); - Logger.info("Loading All Players from database to Server Cache"); - start = System.currentTimeMillis(); - - try { - DbManager.PlayerCharacterQueries.GET_ALL_CHARACTERS(); - } catch (Exception e) { - e.printStackTrace(); - } - - long end = System.currentTimeMillis(); - - Logger.info("Time to load players " + (end - start) + " ms."); - ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); Logger.info("Loading Player Heraldries"); From 6559f232a387730e4e2d0e26a2dfd437faae6af8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 10:08:39 -0400 Subject: [PATCH 275/289] Dev command updated --- src/engine/devcmd/cmds/GetHeightCmd.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 6231f05a..01f43e6a 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -60,13 +60,13 @@ public class GetHeightCmd extends AbstractDevCmd { this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]"); this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]"); this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]"); - this.throwbackInfo(playerCharacter, "Blend: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset)); + this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset)); this.throwbackInfo(playerCharacter, "------------"); - this.throwbackInfo(playerCharacter, "Child Height: " + Math.ceil(childHeight)); - this.throwbackInfo(playerCharacter, "Parent Height : " + Math.ceil(parentHeight)); - this.throwbackInfo(playerCharacter, "Blended Height : " + Math.ceil(blendedHeight)); + this.throwbackInfo(playerCharacter, "Child Height at loc: " + Math.ceil(childHeight)); + this.throwbackInfo(playerCharacter, "Parent Height at loc: " + Math.ceil(parentHeight)); + this.throwbackInfo(playerCharacter, "Blended Height (Ceil): " + blendedHeight + " (" + Math.ceil(blendedHeight) + ")"); } From 4795a315ad5d255865ed65d2ad9c3cd2040eaf49 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 15:20:30 -0400 Subject: [PATCH 276/289] Template now templteID to make room for the actual template. --- src/engine/Enum.java | 2 +- src/engine/devcmd/cmds/GetZoneCmd.java | 2 +- src/engine/devcmd/cmds/InfoCmd.java | 4 ++-- src/engine/devcmd/cmds/ZoneInfoCmd.java | 4 ++-- src/engine/devcmd/cmds/ZoneSetCmd.java | 2 +- src/engine/gameManager/ZoneManager.java | 2 +- src/engine/objects/Zone.java | 8 ++++---- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 266730c3..e4b4b9a3 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -469,7 +469,7 @@ public class Enum { // 14001 does not have a banestone to bind at - if (ruinZone.template == 14001) + if (ruinZone.templateID == 14001) spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30); else spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc() diff --git a/src/engine/devcmd/cmds/GetZoneCmd.java b/src/engine/devcmd/cmds/GetZoneCmd.java index 85ec0afb..857a3a47 100644 --- a/src/engine/devcmd/cmds/GetZoneCmd.java +++ b/src/engine/devcmd/cmds/GetZoneCmd.java @@ -51,7 +51,7 @@ public class GetZoneCmd extends AbstractDevCmd { } for (Zone zone : allIn) - throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.template); + throwbackInfo(pcSender, zone.zoneName + "; UUID: " + zone.getObjectUUID() + ", loadNum: " + zone.templateID); } @Override diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 38a7fe77..de86ac66 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -387,7 +387,7 @@ public class InfoCmd extends AbstractDevCmd { output += newline; output += "EquipSet: " + targetNPC.getEquipmentSetID(); output += newline; - output += "Parent Zone LoadNum : " + targetNPC.getParentZone().template; + output += "Parent Zone LoadNum : " + targetNPC.getParentZone().templateID; } @@ -473,7 +473,7 @@ public class InfoCmd extends AbstractDevCmd { output += "EquipSet: " + targetMob.equipmentSetID; output += newline; try { - output += "Parent Zone LoadNum : " + targetMob.getParentZone().template; + output += "Parent Zone LoadNum : " + targetMob.getParentZone().templateID; } catch (Exception ex) { //who cares } diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 05b80230..46650c2a 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -75,7 +75,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; output += "name: " + zone.zoneName; output += newline; - output += "loadNum: " + zone.template; + output += "loadNum: " + zone.templateID; if (zone.parent != null) { output += StringUtils.addWS(", parent: " + zone.parent.getObjectUUID(), 30); output += "Parentabs: x: " + zone.parent.absX + ", y: " + zone.parent.absY + ", z: " + zone.parent.absZ; @@ -127,7 +127,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { for (Zone child : nodes) { output += newline; - output += child.zoneName + " (" + child.template + ')'; + output += child.zoneName + " (" + child.templateID + ')'; } } throwbackInfo(player, output); diff --git a/src/engine/devcmd/cmds/ZoneSetCmd.java b/src/engine/devcmd/cmds/ZoneSetCmd.java index 4d949134..eb8be8b1 100644 --- a/src/engine/devcmd/cmds/ZoneSetCmd.java +++ b/src/engine/devcmd/cmds/ZoneSetCmd.java @@ -40,7 +40,7 @@ public class ZoneSetCmd extends AbstractDevCmd { zone = ZoneManager.findSmallestZone(playerCharacter.getLoc()); - throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.template + ") " + zone.getObjectUUID()); + throwbackInfo(playerCharacter, zone.zoneName + " (" + zone.templateID + ") " + zone.getObjectUUID()); // NPC diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 86081dd5..de34e5c4 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -169,7 +169,7 @@ public enum ZoneManager { // collections for quick access // based upon their type. - ZoneManager.zonesByID.put(zone.template, zone); + ZoneManager.zonesByID.put(zone.templateID, zone); ZoneManager.zonesByUUID.put(zone.getObjectUUID(), zone); diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 207cff18..942b3eef 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -39,7 +39,7 @@ public class Zone extends AbstractWorldObject { public final float xOffset; public final float zOffset; public final float yOffset; - public final int template; + public final int templateID; public final byte peace_zone; public final String icon1; public final String icon2; @@ -86,7 +86,7 @@ public class Zone extends AbstractWorldObject { this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); - this.template = rs.getInt("template"); + this.templateID = rs.getInt("template"); this.peace_zone = rs.getByte("peace_zone"); this.icon1 = rs.getString("icon1"); this.icon2 = rs.getString("icon2"); @@ -123,7 +123,7 @@ public class Zone extends AbstractWorldObject { public static void serializeForClientMsg(Zone zone, ByteBufferWriter writer) { - if (zone.template == 0 && zone.playerCityUUID == 0) + if (zone.templateID == 0 && zone.playerCityUUID == 0) Logger.warn("Warning! WorldServerMap with ID " + zone.getObjectUUID() + " has a loadnum of 0 (player city) and no city linked. This will probably crash the client!"); // Player City Terraform values serialized here. @@ -141,7 +141,7 @@ public class Zone extends AbstractWorldObject { writer.putInt(0); writer.putInt(0); - writer.putInt(zone.template); + writer.putInt(zone.templateID); if (zone.playerCityUUID > 0) { City k = City.getCity(zone.playerCityUUID); From 5bcc0ed84df9f39a305bc034279e1a42acaa7317 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 15:42:06 -0400 Subject: [PATCH 277/289] Template class created --- src/engine/objects/ZoneTemplate.java | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/engine/objects/ZoneTemplate.java diff --git a/src/engine/objects/ZoneTemplate.java b/src/engine/objects/ZoneTemplate.java new file mode 100644 index 00000000..d73e01d0 --- /dev/null +++ b/src/engine/objects/ZoneTemplate.java @@ -0,0 +1,54 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.objects; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ZoneTemplate { + + public int templateID; + public String zone_type; + public String zone_name; + public String peace_zone; + + public float major_radius; + public float minor_radius; + public float min_blend; + public float max_blend; + public String has_water; + public float sea_level; + public String has_terrain; + public String terrain_type; + public float terrain_max_y; + public int terrain_image; + + /** + * ResultSet Constructor + */ + + public ZoneTemplate(ResultSet rs) throws SQLException { + this.templateID = rs.getInt("template"); + this.zone_type = rs.getString("zone_type"); + this.zone_name = rs.getString("zone_name"); + this.peace_zone = rs.getString("peace_zone"); + this.major_radius = rs.getFloat("major_radius"); + this.minor_radius = rs.getFloat("minor_radius"); + this.min_blend = rs.getFloat("min_blend"); + this.max_blend = rs.getFloat("max_blend"); + this.has_water = rs.getString("has_water"); + this.sea_level = rs.getFloat("sea_level"); + this.has_terrain = rs.getString("has_terrain"); + this.terrain_type = rs.getString("terrain_type"); + this.terrain_max_y = rs.getFloat("terrain_max_y"); + this.terrain_image = rs.getInt("terrain_image"); + } + +} From 5a8508c16cee97618da9618ca7960460f3ff19b1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 15:50:04 -0400 Subject: [PATCH 278/289] Template collection created --- src/engine/gameManager/ZoneManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index de34e5c4..a9b32463 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -17,16 +17,14 @@ import engine.math.Vector3fImmutable; import engine.objects.Building; import engine.objects.City; import engine.objects.Zone; +import engine.objects.ZoneTemplate; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -38,6 +36,8 @@ public enum ZoneManager { ZONEMANAGER; + public static HashMap _zone_templates = new HashMap<>(); + public static final Set macroZones = Collections.newSetFromMap(new ConcurrentHashMap<>()); private static final ConcurrentHashMap zonesByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD); private static final ConcurrentHashMap zonesByUUID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD); From cf2bf2dacf30d615aaf6ad10e3aa7622429f0898 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 16:11:55 -0400 Subject: [PATCH 279/289] DBhandler created for templates --- src/engine/db/handlers/dbZoneHandler.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 64b5754f..ac948589 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -11,7 +11,9 @@ package engine.db.handlers; import engine.Enum; import engine.gameManager.DbManager; +import engine.gameManager.ZoneManager; import engine.objects.Zone; +import engine.objects.ZoneTemplate; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -66,6 +68,24 @@ public class dbZoneHandler extends dbHandlerBase { return zone; } + public void LOAD_ALL_ZONE_TEMPLATES() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_building_blueprint")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + ZoneTemplate zoneTemplate = new ZoneTemplate(rs); + ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate); + } + + } catch (SQLException e) { + Logger.error(e); + } + + } + public boolean DELETE_ZONE(final Zone zone) { try (Connection connection = DbManager.getConnection(); From 930aa73657fbe4968f5da28e5fa62744927d1b22 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 16:30:41 -0400 Subject: [PATCH 280/289] rs constructor completed --- src/engine/objects/ZoneTemplate.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/objects/ZoneTemplate.java b/src/engine/objects/ZoneTemplate.java index d73e01d0..345b0999 100644 --- a/src/engine/objects/ZoneTemplate.java +++ b/src/engine/objects/ZoneTemplate.java @@ -38,14 +38,14 @@ public class ZoneTemplate { this.templateID = rs.getInt("template"); this.zone_type = rs.getString("zone_type"); this.zone_name = rs.getString("zone_name"); - this.peace_zone = rs.getString("peace_zone"); - this.major_radius = rs.getFloat("major_radius"); - this.minor_radius = rs.getFloat("minor_radius"); - this.min_blend = rs.getFloat("min_blend"); - this.max_blend = rs.getFloat("max_blend"); - this.has_water = rs.getString("has_water"); - this.sea_level = rs.getFloat("sea_level"); - this.has_terrain = rs.getString("has_terrain"); + this.peace_zone = rs.getString("zone_peace_zone"); + this.major_radius = rs.getFloat("zone_major_radius"); + this.minor_radius = rs.getFloat("zone_minor_radius"); + this.min_blend = rs.getFloat("zone_min_blend"); + this.max_blend = rs.getFloat("zone_max_blend"); + this.has_water = rs.getString("zone_has_water"); + this.sea_level = rs.getFloat("zone_sea_level"); + this.has_terrain = rs.getString("zone_has_terrain"); this.terrain_type = rs.getString("terrain_type"); this.terrain_max_y = rs.getFloat("terrain_max_y"); this.terrain_image = rs.getInt("terrain_image"); From ec9bc437f3799741a754187c6edb7c025d957c24 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 16:33:33 -0400 Subject: [PATCH 281/289] Templates loaded at bootstrap --- src/engine/server/world/WorldServer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index b5a8f883..627d495b 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -309,6 +309,9 @@ public class WorldServer { Logger.info("Initializing Errant Guild"); Guild.getErrantGuild(); + Logger.info("Loading zone template data"); + DbManager.ZoneQueries.LOAD_ALL_ZONE_TEMPLATES(); + Logger.info("Initializing PowersManager."); PowersManager.initPowersManager(true); @@ -390,7 +393,7 @@ public class WorldServer { Blueprint.loadAllDoorNumbers(); Blueprint.loadAllBlueprints(); - Logger.info("Initializing Heightmap data"); + Logger.info("Loading Heightmap Pixel data"); MapLoader.loadAlHeightMaps(); Logger.info("Loading Race data"); From 14ba9d0f7f0d99cb7f6138cf94a94dadcd2a2a79 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 16:36:08 -0400 Subject: [PATCH 282/289] SQL statement set. --- src/engine/db/handlers/dbZoneHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index ac948589..3300cd76 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -71,7 +71,7 @@ public class dbZoneHandler extends dbHandlerBase { public void LOAD_ALL_ZONE_TEMPLATES() { try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_building_blueprint")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_zone_templates")) { ResultSet rs = preparedStatement.executeQuery(); From cb0ba901de8a9bf3d79d47b0942d44a8b291de2f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 16:37:42 -0400 Subject: [PATCH 283/289] fix in column name --- src/engine/objects/ZoneTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/ZoneTemplate.java b/src/engine/objects/ZoneTemplate.java index 345b0999..017dc121 100644 --- a/src/engine/objects/ZoneTemplate.java +++ b/src/engine/objects/ZoneTemplate.java @@ -45,7 +45,7 @@ public class ZoneTemplate { this.max_blend = rs.getFloat("zone_max_blend"); this.has_water = rs.getString("zone_has_water"); this.sea_level = rs.getFloat("zone_sea_level"); - this.has_terrain = rs.getString("zone_has_terrain"); + this.has_terrain = rs.getString("zone_has_terrain_gen"); this.terrain_type = rs.getString("terrain_type"); this.terrain_max_y = rs.getFloat("terrain_max_y"); this.terrain_image = rs.getInt("terrain_image"); From 091b1a1d5b842c1de9e1edd5119e4bed99c767fa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 17:01:42 -0400 Subject: [PATCH 284/289] Start refactor to use templates --- src/engine/InterestManagement/Terrain.java | 22 +++++----- src/engine/db/handlers/dbZoneHandler.java | 2 + src/engine/devcmd/cmds/GetHeightCmd.java | 4 +- src/engine/devcmd/cmds/ZoneInfoCmd.java | 4 +- src/engine/gameManager/ZoneManager.java | 2 +- src/engine/objects/PlayerCharacter.java | 22 +++++----- src/engine/objects/Zone.java | 48 +++++----------------- src/engine/objects/ZoneTemplate.java | 6 +++ 8 files changed, 46 insertions(+), 64 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 1bf98daa..2cf5eda6 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -32,12 +32,12 @@ public class Terrain { public Terrain(Zone zone) { this.zone = zone; - this.heightmap = this.zone.terrain_image; + this.heightmap = this.zone.template.terrain_image; // Configure PLANAR zones to use the same 16x16 pixel image // that all similar terrains share. (See JSON) - if (this.zone.terrain_type.equals("PLANAR")) + if (this.zone.template.terrain_type.equals("PLANAR")) this.heightmap = 1006300; // all 0 // Load pixel data for this terrain from cache @@ -49,8 +49,8 @@ public class Terrain { // Configure terrain based on zone properties - this.terrain_size.x = this.zone.major_radius * 2; - this.terrain_size.y = this.zone.minor_radius * 2; + this.terrain_size.x = this.zone.template.major_radius * 2; + this.terrain_size.y = this.zone.template.minor_radius * 2; this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; @@ -62,11 +62,11 @@ public class Terrain { // the blending area between child and parent terrains when // they are stitched together. - Vector2f major_blend = new Vector2f(this.zone.max_blend / this.zone.major_radius, - this.zone.min_blend / this.zone.major_radius); + Vector2f major_blend = new Vector2f(this.zone.template.max_blend / this.zone.template.major_radius, + this.zone.template.min_blend / this.zone.template.major_radius); - Vector2f minor_blend = new Vector2f(this.zone.max_blend / this.zone.minor_radius, - this.zone.min_blend / this.zone.minor_radius); + Vector2f minor_blend = new Vector2f(this.zone.template.max_blend / this.zone.template.minor_radius, + this.zone.template.min_blend / this.zone.template.minor_radius); if (major_blend.y > 0.4f) blend_ratio.x = major_blend.y; @@ -80,7 +80,7 @@ public class Terrain { // Scale coefficient for this terrain - this.terrain_scale = this.zone.terrain_max_y / 255f; + this.terrain_scale = this.zone.template.terrain_max_y / 255f; } public static Zone getNextZoneWithTerrain(Zone zone) { @@ -205,8 +205,8 @@ public class Terrain { // Normalize terrain offset - Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.major_radius, - Math.abs(zone_offset.y) / this.zone.minor_radius); + Vector2f normalizedOffset = new Vector2f(Math.abs(zone_offset.x) / this.zone.template.major_radius, + Math.abs(zone_offset.y) / this.zone.template.minor_radius); float blendCoefficient; diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 3300cd76..497c8917 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -80,6 +80,8 @@ public class dbZoneHandler extends dbHandlerBase { ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate); } + // Add player city + } catch (SQLException e) { Logger.error(e); } diff --git a/src/engine/devcmd/cmds/GetHeightCmd.java b/src/engine/devcmd/cmds/GetHeightCmd.java index 01f43e6a..4c48abf8 100644 --- a/src/engine/devcmd/cmds/GetHeightCmd.java +++ b/src/engine/devcmd/cmds/GetHeightCmd.java @@ -37,8 +37,8 @@ public class GetHeightCmd extends AbstractDevCmd { Vector2f childZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), heightmapZone); Vector2f childZoneOffset = ZoneManager.worldToZoneOffset(playerCharacter.getLoc(), heightmapZone); - Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.major_radius, - Math.abs(childZoneOffset.y) / heightmapZone.minor_radius); + Vector2f normalizedOffset = new Vector2f(Math.abs(childZoneOffset.x) / heightmapZone.template.major_radius, + Math.abs(childZoneOffset.y) / heightmapZone.template.minor_radius); Vector2f parentZoneLoc = ZoneManager.worldToTerrainSpace(playerCharacter.getLoc(), parentZone); float childHeight = heightmapZone.terrain.getInterpolatedTerrainHeight(childZoneLoc); diff --git a/src/engine/devcmd/cmds/ZoneInfoCmd.java b/src/engine/devcmd/cmds/ZoneInfoCmd.java index 46650c2a..dfd476df 100644 --- a/src/engine/devcmd/cmds/ZoneInfoCmd.java +++ b/src/engine/devcmd/cmds/ZoneInfoCmd.java @@ -91,7 +91,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; if (zone.terrain != null) { - output += "Terrain image: " + zone.terrain_image; + output += "Terrain image: " + zone.template.terrain_image; output += newline; } @@ -99,7 +99,7 @@ public class ZoneInfoCmd extends AbstractDevCmd { output += newline; // output += "minLvl = " + zone.getMinLvl() + " | maxLvl = " + zone.getMaxLvl(); output += newline; - output += "Sea Level = " + zone.seaLevel; + output += "Sea Level = " + zone.sea_level; output += newline; output += "World Altitude = " + zone.global_height; throwbackInfo(player, output); diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index a9b32463..f0bc0a4b 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -431,6 +431,6 @@ public enum ZoneManager { float localAltitude = Terrain.getWorldHeight(currentLoc); Zone zone = findSmallestZone(currentLoc); - return localAltitude < zone.seaLevel; + return localAltitude < zone.sea_level; } } diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index a063df6f..d68c16cd 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -1507,16 +1507,16 @@ public class PlayerCharacter extends AbstractCharacter { return true; Zone zone = ZoneManager.findSmallestZone(breather.getLoc()); - if (zone.seaLevel != 0) { + if (zone.sea_level != 0) { float localAltitude = breather.getLoc().y; - if (localAltitude + breather.characterHeight < zone.seaLevel - 2) + if (localAltitude + breather.characterHeight < zone.sea_level - 2) return false; if (breather.isMoving()) { - if (localAltitude + breather.characterHeight < zone.seaLevel) + if (localAltitude + breather.characterHeight < zone.sea_level) return false; } } else { @@ -1547,12 +1547,12 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(enterer.getLoc()); - if (zone.seaLevel != 0) { + if (zone.sea_level != 0) { float localAltitude = enterer.getLoc().y + enterer.characterHeight; - if (localAltitude < zone.seaLevel) + if (localAltitude < zone.sea_level) return true; } else { if (enterer.getLoc().y + enterer.characterHeight < 0) @@ -1579,12 +1579,12 @@ public class PlayerCharacter extends AbstractCharacter { leaveWater = 1f; - if (zone.seaLevel != 0) { + if (zone.sea_level != 0) { float localAltitude = leaver.getLoc().y; - if (localAltitude + leaveWater < zone.seaLevel) + if (localAltitude + leaveWater < zone.sea_level) return false; } else { if (leaver.getLoc().y + leaveWater < 0) @@ -4739,10 +4739,10 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(this.getLoc()); - if (zone.seaLevel != 0) { + if (zone.sea_level != 0) { float localAltitude = this.getLoc().y + this.centerHeight; - if (localAltitude < zone.seaLevel) + if (localAltitude < zone.sea_level) return true; } else { if (this.getLoc().y + this.centerHeight < 0) @@ -4764,9 +4764,9 @@ public class PlayerCharacter extends AbstractCharacter { Zone zone = ZoneManager.findSmallestZone(currentLoc); - if (zone.seaLevel != 0) { + if (zone.sea_level != 0) { - if (localAltitude < zone.seaLevel) + if (localAltitude < zone.sea_level) return true; } else { if (localAltitude < 0) diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 942b3eef..07488b5a 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -34,6 +34,8 @@ public class Zone extends AbstractWorldObject { public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); + public ZoneTemplate template; + public final int playerCityUUID; public final String zoneName; public final float xOffset; @@ -58,17 +60,7 @@ public class Zone extends AbstractWorldObject { public boolean guild_zone; public String hash; public float global_height = 0; - public float seaLevel = 0f; - public float sea_level_offset = 0; - public float major_radius; - public float minor_radius; - public float min_blend; - public float max_blend; - public String sea_level_type; public float sea_level; - public String terrain_type; - public float terrain_max_y; - public int terrain_image; public Terrain terrain = null; @@ -93,26 +85,6 @@ public class Zone extends AbstractWorldObject { this.icon3 = rs.getString("icon3"); this.min_level = rs.getInt("min_level"); this.max_level = rs.getInt("max_level"); - this.major_radius = rs.getFloat("major_radius"); - this.minor_radius = rs.getFloat("minor_radius"); - this.min_blend = rs.getFloat("min_blend"); - this.max_blend = rs.getFloat("max_blend"); - this.sea_level_type = rs.getString("sea_level_type"); - this.sea_level_offset = rs.getFloat("sea_level"); - this.terrain_type = rs.getString("terrain_type"); - this.terrain_max_y = rs.getFloat("terrain_max_y"); - this.terrain_image = rs.getInt("terrain_image"); - - // Configuration for player cities - - if (this.guild_zone) { - this.max_blend = 128; - this.min_blend = 128; - this.terrain_max_y = 5; - this.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; - this.terrain_type = "PLANAR"; - } // If zone doesn't yet hava a hash then write it back to the zone table @@ -177,12 +149,14 @@ public class Zone extends AbstractWorldObject { @Override public void runAfterLoad() { + this.template = ZoneManager._zone_templates.get(this.templateID); + // First zone is always the seafloor if (ZoneManager.seaFloor == null) ZoneManager.seaFloor = this; - if (this.terrain_type.equals("NONE")) + if (this.template.terrain_type.equals("NONE")) this.terrain = null; else this.terrain = new Terrain(this); @@ -207,7 +181,7 @@ public class Zone extends AbstractWorldObject { // Set initial bounds object this.bounds = Bounds.borrow(); - this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.major_radius, this.minor_radius), 0.0f); + this.bounds.setBounds(new Vector2f(this.absX, this.absZ), new Vector2f(this.template.major_radius, this.template.minor_radius), 0.0f); } @@ -225,7 +199,7 @@ public class Zone extends AbstractWorldObject { this.absY = MBServerStatics.SEA_FLOOR_ALTITUDE; this.global_height = MBServerStatics.SEA_FLOOR_ALTITUDE; this.absZ = this.zOffset; - this.seaLevel = 0; + this.sea_level = 0; this.setBounds(); return; } @@ -253,15 +227,15 @@ public class Zone extends AbstractWorldObject { return; } - switch (this.sea_level_type) { + switch (this.template.sea_level_type) { case "WORLD": - this.sea_level = world_sea_level + this.sea_level_offset; + this.sea_level = world_sea_level + this.template.sea_level; break; case "PARENT": - this.sea_level = this.parent.sea_level + this.sea_level_offset; + this.sea_level = this.parent.sea_level + this.template.sea_level; break; case "SELF": - this.sea_level = this.global_height + this.sea_level_offset; + this.sea_level = this.global_height + this.template.sea_level; break; } } diff --git a/src/engine/objects/ZoneTemplate.java b/src/engine/objects/ZoneTemplate.java index 017dc121..03ad9619 100644 --- a/src/engine/objects/ZoneTemplate.java +++ b/src/engine/objects/ZoneTemplate.java @@ -24,6 +24,7 @@ public class ZoneTemplate { public float min_blend; public float max_blend; public String has_water; + public String sea_level_type; public float sea_level; public String has_terrain; public String terrain_type; @@ -34,6 +35,10 @@ public class ZoneTemplate { * ResultSet Constructor */ + public ZoneTemplate() { + + } + public ZoneTemplate(ResultSet rs) throws SQLException { this.templateID = rs.getInt("template"); this.zone_type = rs.getString("zone_type"); @@ -44,6 +49,7 @@ public class ZoneTemplate { this.min_blend = rs.getFloat("zone_min_blend"); this.max_blend = rs.getFloat("zone_max_blend"); this.has_water = rs.getString("zone_has_water"); + this.sea_level_type = rs.getString("zone_sea_level_type"); this.sea_level = rs.getFloat("zone_sea_level"); this.has_terrain = rs.getString("zone_has_terrain_gen"); this.terrain_type = rs.getString("terrain_type"); From 59190e33c99aa734be918be78e35427fc07c252f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 17:09:27 -0400 Subject: [PATCH 285/289] Template added for player cities (0) --- src/engine/db/handlers/dbZoneHandler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/engine/db/handlers/dbZoneHandler.java b/src/engine/db/handlers/dbZoneHandler.java index 497c8917..136385f9 100644 --- a/src/engine/db/handlers/dbZoneHandler.java +++ b/src/engine/db/handlers/dbZoneHandler.java @@ -82,6 +82,20 @@ public class dbZoneHandler extends dbHandlerBase { // Add player city + ZoneTemplate zoneTemplate = new ZoneTemplate(); + + zoneTemplate.templateID = 0; + zoneTemplate.sea_level_type = "PARENT"; + zoneTemplate.sea_level = 0; + zoneTemplate.max_blend = 128; + zoneTemplate.min_blend = 128; + zoneTemplate.terrain_max_y = 5; + zoneTemplate.major_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + zoneTemplate.minor_radius = (int) Enum.CityBoundsType.ZONE.halfExtents; + zoneTemplate.terrain_type = "PLANAR"; + + ZoneManager._zone_templates.put(zoneTemplate.templateID, zoneTemplate); + } catch (SQLException e) { Logger.error(e); } From 3986dc06865943cbb26d8e5d066790db1c5750ce Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 17:22:57 -0400 Subject: [PATCH 286/289] Peace zone needs to come from zone tree --- src/engine/InterestManagement/Terrain.java | 12 ++++++------ src/engine/objects/Zone.java | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index 2cf5eda6..4db671ab 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -49,8 +49,8 @@ public class Terrain { // Configure terrain based on zone properties - this.terrain_size.x = this.zone.template.major_radius * 2; - this.terrain_size.y = this.zone.template.minor_radius * 2; + this.terrain_size.x = this.zone.major_radius * 2; + this.terrain_size.y = this.zone.minor_radius * 2; this.cell_count.x = this.terrain_pixel_data.length - 1; this.cell_count.y = this.terrain_pixel_data[0].length - 1; @@ -62,11 +62,11 @@ public class Terrain { // the blending area between child and parent terrains when // they are stitched together. - Vector2f major_blend = new Vector2f(this.zone.template.max_blend / this.zone.template.major_radius, - this.zone.template.min_blend / this.zone.template.major_radius); + Vector2f major_blend = new Vector2f(this.zone.template.max_blend / this.zone.major_radius, + this.zone.template.min_blend / this.zone.major_radius); - Vector2f minor_blend = new Vector2f(this.zone.template.max_blend / this.zone.template.minor_radius, - this.zone.template.min_blend / this.zone.template.minor_radius); + Vector2f minor_blend = new Vector2f(this.zone.template.max_blend / this.zone.minor_radius, + this.zone.template.min_blend / this.zone.minor_radius); if (major_blend.y > 0.4f) blend_ratio.x = major_blend.y; diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 07488b5a..32fb9c72 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -34,10 +34,13 @@ public class Zone extends AbstractWorldObject { public final Set zoneBuildingSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneNPCSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); public final Set zoneMobSet = Collections.newSetFromMap(new ConcurrentHashMap<>()); + public ZoneTemplate template; public final int playerCityUUID; public final String zoneName; + public final float major_radius; + public final float minor_radius; public final float xOffset; public final float zOffset; public final float yOffset; @@ -72,17 +75,23 @@ public class Zone extends AbstractWorldObject { super(rs); this.parentZoneID = rs.getInt("parent"); - this.playerCityUUID = rs.getInt("playerCityUUID"); - this.guild_zone = this.playerCityUUID != 0; + this.templateID = rs.getInt("template"); this.zoneName = rs.getString("zone_name"); + this.peace_zone = rs.getByte("peace_zone"); + + this.major_radius = rs.getFloat("major_radius"); + this.minor_radius = rs.getFloat("minor_radius"); this.xOffset = rs.getFloat("xOffset"); this.zOffset = rs.getFloat("zOffset"); this.yOffset = rs.getFloat("yOffset"); - this.templateID = rs.getInt("template"); - this.peace_zone = rs.getByte("peace_zone"); + + this.playerCityUUID = rs.getInt("playerCityUUID"); + this.guild_zone = this.playerCityUUID != 0; + this.icon1 = rs.getString("icon1"); this.icon2 = rs.getString("icon2"); this.icon3 = rs.getString("icon3"); + this.min_level = rs.getInt("min_level"); this.max_level = rs.getInt("max_level"); From 29b5955e9e63553d91cbc997324bbf5f95f2eab9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 17:33:53 -0400 Subject: [PATCH 287/289] Peace zone needs to come from zone tree --- src/engine/objects/ZoneTemplate.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/objects/ZoneTemplate.java b/src/engine/objects/ZoneTemplate.java index 03ad9619..5cb16c9b 100644 --- a/src/engine/objects/ZoneTemplate.java +++ b/src/engine/objects/ZoneTemplate.java @@ -43,7 +43,6 @@ public class ZoneTemplate { this.templateID = rs.getInt("template"); this.zone_type = rs.getString("zone_type"); this.zone_name = rs.getString("zone_name"); - this.peace_zone = rs.getString("zone_peace_zone"); this.major_radius = rs.getFloat("zone_major_radius"); this.minor_radius = rs.getFloat("zone_minor_radius"); this.min_blend = rs.getFloat("zone_min_blend"); From b1e79284e4a5828709db080be8bd693591ee5a29 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 17:49:29 -0400 Subject: [PATCH 288/289] Thread count test --- src/engine/gameManager/DbManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index cbd52a3d..60f8e214 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -297,7 +297,7 @@ public enum DbManager { // Magicbane requires at least 15 db connections min to boot. - int connectionCount = Math.max(15, Runtime.getRuntime().availableProcessors() * 2) + 1; + int connectionCount = Math.min(10, Runtime.getRuntime().availableProcessors() * 2) + 1; config.setMaximumPoolSize(connectionCount); config.setJdbcUrl("jdbc:mysql://" + ConfigManager.MB_DATABASE_ADDRESS.getValue() + From 737327fa8ae4f8e2806ebe27160d0eab8daa3de7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 20 Oct 2023 17:52:23 -0400 Subject: [PATCH 289/289] Revert after test --- src/engine/gameManager/DbManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/DbManager.java b/src/engine/gameManager/DbManager.java index 60f8e214..cbd52a3d 100644 --- a/src/engine/gameManager/DbManager.java +++ b/src/engine/gameManager/DbManager.java @@ -297,7 +297,7 @@ public enum DbManager { // Magicbane requires at least 15 db connections min to boot. - int connectionCount = Math.min(10, Runtime.getRuntime().availableProcessors() * 2) + 1; + int connectionCount = Math.max(15, Runtime.getRuntime().availableProcessors() * 2) + 1; config.setMaximumPoolSize(connectionCount); config.setJdbcUrl("jdbc:mysql://" + ConfigManager.MB_DATABASE_ADDRESS.getValue() +