From 7d655bc44beb92b37631f110cddbb671fe1a526d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 28 Feb 2023 10:43:49 -0500 Subject: [PATCH 1/3] Mine serialized loc is the tower loc. No need to store offsets in a table to reconstruct this loc. --- src/engine/objects/Mine.java | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index d58b46ad..0d5802bd 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -54,11 +54,6 @@ public class Mine extends AbstractGameObject { public GuildTag nationTag; private final String zoneName; private Resource production; - private final float latitude; - private final float longitude; - - //flags 1: never been claimed (make active). - private final float altitude; private Guild owningGuild; private int flags; private int buildingID; @@ -80,21 +75,7 @@ public class Mine extends AbstractGameObject { this.flags = rs.getInt("flags"); int parent = rs.getInt("parent"); this.parentZone = ZoneManager.getZoneByUUID(parent); - if (parentZone != null) { - this.latitude = parentZone.getLoc().x + offsetX; - this.longitude = parentZone.getLoc().z + offsetZ; - this.altitude = parentZone.getLoc().y; - if (this.parentZone.getParent() != null) - this.zoneName = this.parentZone.getParent().getName(); - else - this.zoneName = this.parentZone.getName(); - } else { - Logger.error("Missing parentZone of ID " + parent); - this.latitude = -1000; - this.longitude = 1000; - this.altitude = 0; - this.zoneName = "Unknown Mine"; - } + this.zoneName = this.parentZone.getParent().getName(); this.owningGuild = Guild.getGuild(ownerUID); Guild nation = null; @@ -230,9 +211,11 @@ public class Mine extends AbstractGameObject { writer.putLocalDateTime(mineOpenTime.plusHours(1)); writer.put(mine.isActive ? (byte) 0x01 : (byte) 0x00); - writer.putFloat(mine.latitude); - writer.putFloat(mine.altitude); - writer.putFloat(mine.longitude); + Building mineTower = BuildingManager.getBuilding(mine.buildingID); + writer.putFloat(mineTower.getLoc().x); + writer.putFloat(mineTower.getParentZone().getLoc().y); + writer.putFloat(mineTower.getLoc().z); + writer.putInt(mine.isExpansion() ? mine.mineType.xpacHash : mine.mineType.hash); writer.putString(mine.guildName); @@ -369,10 +352,6 @@ public class Mine extends AbstractGameObject { return this.isActive; } - public float getAltitude() { - return this.altitude; - } - public Guild getOwningGuild() { if (this.owningGuild == null) return Guild.getErrantGuild(); From 110a05d5a4061c4746b1779d7193421e61319333 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 1 Mar 2023 16:12:17 -0500 Subject: [PATCH 2/3] bugfix-merge issue in constructor. --- src/engine/objects/Mine.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 0d5802bd..85d61b80 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -68,8 +68,6 @@ public class Mine extends AbstractGameObject { this.mineType = MineProduction.getByName(rs.getString("mine_type")); - float offsetX = rs.getFloat("mine_offsetX"); - float offsetZ = rs.getFloat("mine_offsetZ"); int ownerUID = rs.getInt("mine_ownerUID"); this.buildingID = rs.getInt("mine_buildingUID"); this.flags = rs.getInt("flags"); From 0ce94360f79d14f0515620451a98ada710bf468a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 2 Mar 2023 08:06:17 -0500 Subject: [PATCH 3/3] Magicbox channel support added. --- src/discord/ChatChannel.java | 2 +- src/discord/MagicBot.java | 3 +++ src/engine/gameManager/ConfigManager.java | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/discord/ChatChannel.java b/src/discord/ChatChannel.java index de86cd1d..1540dfce 100644 --- a/src/discord/ChatChannel.java +++ b/src/discord/ChatChannel.java @@ -20,7 +20,7 @@ public enum ChatChannel { GENERAL("MB_MAGICBOT_GENERAL"), FORTOFIX("MB_MAGICBOT_FORTOFIX"), RECRUIT("MB_MAGICBOT_RECRUIT"), - + MAGICBOX("MB_MAGICBOT_MAGICBOX"), ADMINLOG("MB_MAGICBOT_ADMINLOG"); public final String configName; diff --git a/src/discord/MagicBot.java b/src/discord/MagicBot.java index 93eb189f..0ada6f9e 100644 --- a/src/discord/MagicBot.java +++ b/src/discord/MagicBot.java @@ -209,6 +209,9 @@ public class MagicBot extends ListenerAdapter { case "#recruit": ChatChannelHandler.handleRequest(ChatChannel.RECRUIT, event, args); break; + case "#magicbox": + ChatChannelHandler.handleRequest(ChatChannel.MAGICBOX, event, args); + break; case "#lookup": LookupRequestHandler.handleRequest(event, args); break; diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index b23ca660..658f6c33 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -88,6 +88,7 @@ public enum ConfigManager { MB_MAGICBOT_GENERAL, MB_MAGICBOT_FORTOFIX, MB_MAGICBOT_RECRUIT, + MB_MAGICBOT_MAGICBOX, MB_MAGICBOT_ADMINLOG; // Map to hold our config pulled in from the environment