From 39e06994d95edf76f037c455f7813821b540c984 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 5 Apr 2024 20:13:16 -0400 Subject: [PATCH 001/378] Workorder and Forgemanger classes created --- src/engine/gameManager/ForgeManager.java | 67 ++++++++++++++++++++++++ src/engine/loot/WorkOrder.java | 52 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 src/engine/gameManager/ForgeManager.java create mode 100644 src/engine/loot/WorkOrder.java diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java new file mode 100644 index 00000000..6c536134 --- /dev/null +++ b/src/engine/gameManager/ForgeManager.java @@ -0,0 +1,67 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.gameManager; + +import engine.loot.WorkOrder; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.DelayQueue; +import java.util.concurrent.atomic.AtomicInteger; + +public enum ForgeManager implements Runnable { + + FORGE_MANAGER; + + private final BlockingQueue workQueue = new DelayQueue(); + public static final AtomicInteger workOrder = new AtomicInteger(0); + + @Override + public void run() { + + while (true) { + + try { + + WorkOrder workOrder = workQueue.take(); + + // Fulfill workOrder + + for (int i = 0; i < workOrder.slotCount; ++i) { + + // Create workOrder items; one for each slot + // assigned to this workOrder. + + // if Prefix and suffix are null random roll item + // otherwise roll what was asked for + + workOrder.itemCount = workOrder.itemCount - 1; + + } + + if (workOrder.itemCount == 0) { + + workOrder.runCompleted = true; + + // Remove this workOrder from any slots on vendor + + continue; + } + + // Resubmit workOrder + + workOrder.completionTime = System.currentTimeMillis() + 10000; + + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + + } +} diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java new file mode 100644 index 00000000..bc040c42 --- /dev/null +++ b/src/engine/loot/WorkOrder.java @@ -0,0 +1,52 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.loot; + +import engine.gameManager.ForgeManager; +import engine.objects.NPC; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.Delayed; +import java.util.concurrent.TimeUnit; + +import static java.lang.Math.toIntExact; + +public class WorkOrder implements Delayed { + + public int workOrder; + public NPC vendor; + public int slotCount; + public int itemCount; + public int itemBase; + public String itemName; + public int prefixToken; + public int suffixToken; + public boolean isRandom; + public long completionTime; + public boolean runCompleted; + + public WorkOrder() { + + this.workOrder = ForgeManager.workOrder.incrementAndGet(); + this.completionTime = System.currentTimeMillis() + 10000; + } + + @Override + public long getDelay(TimeUnit unit) { + + long timeRemaining = completionTime - System.currentTimeMillis(); + return unit.convert(timeRemaining, TimeUnit.MILLISECONDS); + + } + + @Override + public int compareTo(@NotNull Delayed o) { + return toIntExact(this.completionTime - ((WorkOrder) o).completionTime); + } +} From ffd41101c3fbc589d8aa6a6f508474b0bc988a34 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 5 Apr 2024 20:14:29 -0400 Subject: [PATCH 002/378] variable renamed --- src/engine/loot/WorkOrder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index bc040c42..0dcebcba 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -23,7 +23,7 @@ public class WorkOrder implements Delayed { public NPC vendor; public int slotCount; public int itemCount; - public int itemBase; + public int templateID; public String itemName; public int prefixToken; public int suffixToken; From 993abfbf6fba445646585a1c24afa62bb09fce65 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 07:26:17 -0400 Subject: [PATCH 003/378] variable renamed --- src/engine/gameManager/ForgeManager.java | 6 +++--- src/engine/loot/WorkOrder.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6c536134..f973e544 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -18,8 +18,8 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; - private final BlockingQueue workQueue = new DelayQueue(); - public static final AtomicInteger workOrder = new AtomicInteger(0); + private final BlockingQueue workOrders = new DelayQueue(); + public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); @Override public void run() { @@ -28,7 +28,7 @@ public enum ForgeManager implements Runnable { try { - WorkOrder workOrder = workQueue.take(); + WorkOrder workOrder = workOrders.take(); // Fulfill workOrder diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 0dcebcba..9d71d792 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -33,7 +33,7 @@ public class WorkOrder implements Delayed { public WorkOrder() { - this.workOrder = ForgeManager.workOrder.incrementAndGet(); + this.workOrder = ForgeManager.wordOrderCounter.incrementAndGet(); this.completionTime = System.currentTimeMillis() + 10000; } From b86ca330878383f37448d4713a01f6d8b6dad2a5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 10:56:31 -0400 Subject: [PATCH 004/378] Unused variables removed --- src/engine/net/client/msg/ItemProductionMsg.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 08d3abda..251e0a9d 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -23,7 +23,6 @@ import engine.objects.MobLoot; import engine.objects.NPC; import engine.powers.EffectsBase; -import java.util.ArrayList; import java.util.HashMap; public class ItemProductionMsg extends ClientNetMsg { @@ -40,7 +39,6 @@ public class ItemProductionMsg extends ClientNetMsg { private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client private static final int ACTION_CONFIRM_PRODUCE = 8; - private ArrayList ItemList; private int size; private int buildingUUID; private int unknown01; @@ -458,19 +456,6 @@ public class ItemProductionMsg extends ClientNetMsg { return itemType; } - // TODO fix ArrayList Accessability. - public ArrayList getItemList() { - return this.ItemList; - } - - public void setItemList(ArrayList value) { - this.ItemList = value; - } - - public void addItem(Long item) { - this.ItemList.add(item); - } - public int getUnknown01() { return unknown01; } From b979fbb1bcbee579c72316850fbe42892b82143b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 14:01:23 -0400 Subject: [PATCH 005/378] Begin message rewrite --- .../net/client/handlers/ItemProductionMsgHandler.java | 2 +- src/engine/net/client/msg/ItemProductionMsg.java | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index e54001f0..8a1ecd31 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -459,7 +459,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0) isRandom = true; //Create Multiple Item Function.. Fill all empty slots - if (msg.isMultiple()) { + if (msg.getSize() > 0) { int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); if (emptySlots > 0) { for (int i = 0; i < emptySlots; i++) { diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 251e0a9d..e65d0bf4 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -53,7 +53,6 @@ public class ItemProductionMsg extends ClientNetMsg { private int npcUUID; private boolean add; private int itemPrice; - private boolean isMultiple; private HashMap itemIDtoTypeMap; /** @@ -440,7 +439,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.pToken = reader.getInt(); this.sToken = reader.getInt(); this.name = reader.getString(); - this.isMultiple = reader.getInt() != 0 ? true : false; + this.size = reader.getInt(); reader.getInt(); if (this.actionType == ACTION_COMPLETE || this.actionType == ACTION_JUNK) @@ -543,11 +542,4 @@ public class ItemProductionMsg extends ClientNetMsg { return itemPrice; } - public boolean isMultiple() { - return isMultiple; - } - - public void setMultiple(boolean isMultiple) { - this.isMultiple = isMultiple; - } } From 10805a7d3783bb7da4e16df8ad9940f490b216fc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 15:30:35 -0400 Subject: [PATCH 006/378] Class moved up in package --- src/engine/net/AbstractConnection.java | 1 - src/engine/net/AbstractNetMsg.java | 1 - src/engine/net/CheckNetMsgFactoryJob.java | 1 - src/engine/net/NetMsgFactory.java | 1 - src/engine/net/NetMsgStat.java | 2 -- src/engine/net/{client => }/Protocol.java | 4 +--- src/engine/net/client/ClientConnection.java | 1 + .../net/client/handlers/AbstractChatMsgHandler.java | 2 +- src/engine/net/client/msg/AbandonAssetMsg.java | 2 +- src/engine/net/client/msg/AcceptFriendMsg.java | 2 +- src/engine/net/client/msg/AcceptTradeRequestMsg.java | 2 +- src/engine/net/client/msg/ActivateNPCMessage.java | 6 +----- src/engine/net/client/msg/AddFriendMessage.java | 2 +- src/engine/net/client/msg/AddGoldToTradeWindowMsg.java | 2 +- src/engine/net/client/msg/AddItemToTradeWindowMsg.java | 2 +- src/engine/net/client/msg/AllianceChangeMsg.java | 2 +- src/engine/net/client/msg/AllyEnemyListMsg.java | 2 +- src/engine/net/client/msg/ApplyBuildingEffectMsg.java | 2 +- src/engine/net/client/msg/ApplyEffectMsg.java | 2 +- src/engine/net/client/msg/ApplyRuneMsg.java | 1 - src/engine/net/client/msg/ArcLoginNotifyMsg.java | 2 +- src/engine/net/client/msg/ArcMineChangeProductionMsg.java | 2 +- .../net/client/msg/ArcMineWindowAvailableTimeMsg.java | 2 +- src/engine/net/client/msg/ArcMineWindowChangeMsg.java | 2 +- src/engine/net/client/msg/ArcOwnedMinesListMsg.java | 2 +- src/engine/net/client/msg/ArcSiegeSpireMsg.java | 2 +- .../net/client/msg/ArcViewAssetTransactionsMsg.java | 2 +- src/engine/net/client/msg/AssetSupportMsg.java | 2 +- src/engine/net/client/msg/AttackCmdMsg.java | 2 +- src/engine/net/client/msg/ChangeAltitudeMsg.java | 2 +- src/engine/net/client/msg/ChangeGuildLeaderMsg.java | 2 +- src/engine/net/client/msg/ChatFilterMsg.java | 2 +- src/engine/net/client/msg/CityAssetMsg.java | 2 +- src/engine/net/client/msg/CityChoiceMsg.java | 6 +----- src/engine/net/client/msg/CityDataMsg.java | 6 +----- src/engine/net/client/msg/CityZoneMsg.java | 2 +- src/engine/net/client/msg/ClaimAssetMsg.java | 2 +- src/engine/net/client/msg/ClaimGuildTreeMsg.java | 2 +- src/engine/net/client/msg/ClientNetMsg.java | 6 +----- src/engine/net/client/msg/CloseTradeWindowMsg.java | 2 +- src/engine/net/client/msg/CommitToTradeMsg.java | 2 +- src/engine/net/client/msg/ConfirmPromoteMsg.java | 2 +- src/engine/net/client/msg/CostOpenBankMsg.java | 2 +- src/engine/net/client/msg/DeclineFriendMsg.java | 2 +- src/engine/net/client/msg/DeleteItemMsg.java | 2 +- src/engine/net/client/msg/DestroyBuildingMsg.java | 2 +- src/engine/net/client/msg/DoorTryOpenMsg.java | 2 +- src/engine/net/client/msg/DropGoldMsg.java | 2 +- src/engine/net/client/msg/EnterWorldReceivedMsg.java | 2 +- src/engine/net/client/msg/ErrorPopupMsg.java | 1 - src/engine/net/client/msg/FriendRequestMsg.java | 2 +- src/engine/net/client/msg/FurnitureMsg.java | 4 ++-- src/engine/net/client/msg/GoldFromVaultMsg.java | 2 +- src/engine/net/client/msg/GoldToVaultMsg.java | 4 ++-- src/engine/net/client/msg/GrantExperienceMsg.java | 2 +- src/engine/net/client/msg/GuildTreeStatusMsg.java | 2 +- src/engine/net/client/msg/HirelingServiceMsg.java | 2 +- src/engine/net/client/msg/HotzoneChangeMsg.java | 2 +- src/engine/net/client/msg/IgnoreListMsg.java | 2 +- src/engine/net/client/msg/IgnoreMsg.java | 2 +- src/engine/net/client/msg/InvalidTradeRequestMsg.java | 2 +- src/engine/net/client/msg/ItemEffectMsg.java | 2 +- src/engine/net/client/msg/ItemFromVaultMsg.java | 2 +- src/engine/net/client/msg/ItemHealthUpdateMsg.java | 2 +- src/engine/net/client/msg/ItemProductionMsg.java | 6 +----- src/engine/net/client/msg/ItemToVaultMsg.java | 2 +- src/engine/net/client/msg/KeepAliveServerClientMsg.java | 2 +- src/engine/net/client/msg/LeaderboardMessage.java | 2 +- src/engine/net/client/msg/LeaveWorldMsg.java | 2 +- src/engine/net/client/msg/LoadCharacterMsg.java | 6 +----- src/engine/net/client/msg/LoadStructureMsg.java | 6 +----- src/engine/net/client/msg/LockUnlockDoorMsg.java | 2 +- src/engine/net/client/msg/LoginToGameServerMsg.java | 2 +- src/engine/net/client/msg/LootMsg.java | 2 +- src/engine/net/client/msg/LootWindowRequestMsg.java | 2 +- src/engine/net/client/msg/LootWindowResponseMsg.java | 2 +- src/engine/net/client/msg/ManageCityAssetsMsg.java | 2 +- src/engine/net/client/msg/ManageNPCMsg.java | 2 +- src/engine/net/client/msg/MerchantMsg.java | 2 +- src/engine/net/client/msg/MinionTrainingMessage.java | 2 +- src/engine/net/client/msg/ModifyCommitToTradeMsg.java | 2 +- src/engine/net/client/msg/ModifyHealthKillMsg.java | 2 +- src/engine/net/client/msg/ModifyHealthMsg.java | 2 +- src/engine/net/client/msg/ModifyStatMsg.java | 2 +- src/engine/net/client/msg/MoveCorrectionMsg.java | 2 +- src/engine/net/client/msg/MoveToPointMsg.java | 2 +- src/engine/net/client/msg/ObjectActionMsg.java | 2 +- src/engine/net/client/msg/OpenFriendsCondemnListMsg.java | 2 +- src/engine/net/client/msg/OpenTradeWindowMsg.java | 2 +- src/engine/net/client/msg/OpenVaultMsg.java | 2 +- src/engine/net/client/msg/OrderNPCMsg.java | 2 +- src/engine/net/client/msg/PassiveMessageTriggerMsg.java | 2 +- src/engine/net/client/msg/PerformActionMsg.java | 2 +- src/engine/net/client/msg/PetAttackMsg.java | 2 +- src/engine/net/client/msg/PetCmdMsg.java | 2 +- src/engine/net/client/msg/PetMsg.java | 2 +- src/engine/net/client/msg/PetitionReceivedMsg.java | 2 +- src/engine/net/client/msg/PlaceAssetMsg.java | 1 - src/engine/net/client/msg/PowerProjectileMsg.java | 2 +- src/engine/net/client/msg/PromptRecallMsg.java | 2 +- src/engine/net/client/msg/RandomMsg.java | 2 +- src/engine/net/client/msg/RecommendNationMsg.java | 2 +- src/engine/net/client/msg/RecvSummonsMsg.java | 2 +- src/engine/net/client/msg/RecyclePowerMsg.java | 2 +- src/engine/net/client/msg/RefineMsg.java | 2 +- src/engine/net/client/msg/RefinerScreenMsg.java | 2 +- src/engine/net/client/msg/RejectTradeRequestMsg.java | 2 +- src/engine/net/client/msg/RemoveFriendMessage.java | 2 +- src/engine/net/client/msg/RepairBuildingMsg.java | 2 +- src/engine/net/client/msg/RepairMsg.java | 2 +- src/engine/net/client/msg/ReqBankInventoryMsg.java | 2 +- src/engine/net/client/msg/RequestBallListMessage.java | 2 +- src/engine/net/client/msg/RequestEnterWorldMsg.java | 2 +- src/engine/net/client/msg/RespawnMsg.java | 2 +- src/engine/net/client/msg/RespondLeaveWorldMsg.java | 2 +- src/engine/net/client/msg/RotateObjectMsg.java | 2 +- src/engine/net/client/msg/SafeModeMsg.java | 2 +- src/engine/net/client/msg/ScaleObjectMsg.java | 2 +- src/engine/net/client/msg/SelectCityMsg.java | 6 +----- src/engine/net/client/msg/SendBallEntryMessage.java | 2 +- src/engine/net/client/msg/SendOwnPlayerMsg.java | 6 +----- src/engine/net/client/msg/SendSummonsMsg.java | 2 +- src/engine/net/client/msg/ServerInfoMsg.java | 2 +- src/engine/net/client/msg/SetCombatModeMsg.java | 2 +- src/engine/net/client/msg/SetObjectValueMsg.java | 2 +- src/engine/net/client/msg/ShowBankInventoryMsg.java | 2 +- src/engine/net/client/msg/ShowMsg.java | 2 +- src/engine/net/client/msg/ShowVaultInventoryMsg.java | 2 +- src/engine/net/client/msg/SocialMsg.java | 2 +- src/engine/net/client/msg/StuckMsg.java | 2 +- src/engine/net/client/msg/TargetObjectMsg.java | 2 +- src/engine/net/client/msg/TargetedActionMsg.java | 2 +- src/engine/net/client/msg/TaxCityMsg.java | 4 ++-- src/engine/net/client/msg/TaxResourcesMsg.java | 4 ++-- src/engine/net/client/msg/TeleportRepledgeListMsg.java | 6 +----- src/engine/net/client/msg/TeleportToPointMsg.java | 2 +- src/engine/net/client/msg/TerritoryChangeMessage.java | 2 +- src/engine/net/client/msg/ToggleCombatMsg.java | 2 +- src/engine/net/client/msg/ToggleLfgRecruitingMsg.java | 2 +- src/engine/net/client/msg/ToggleSitStandMsg.java | 2 +- src/engine/net/client/msg/TrackArrowMsg.java | 2 +- src/engine/net/client/msg/TrackWindowMsg.java | 6 +----- src/engine/net/client/msg/TradeRequestMsg.java | 2 +- src/engine/net/client/msg/TrainMsg.java | 2 +- src/engine/net/client/msg/TrainerInfoMsg.java | 2 +- src/engine/net/client/msg/TransferAssetMsg.java | 2 +- src/engine/net/client/msg/TransferBuildingMsg.java | 2 +- .../net/client/msg/TransferGoldToFromBuildingMsg.java | 2 +- src/engine/net/client/msg/TransferItemFromBankMsg.java | 2 +- .../client/msg/TransferItemFromEquipToInventoryMsg.java | 4 ++-- .../client/msg/TransferItemFromInventoryToEquipMsg.java | 4 ++-- src/engine/net/client/msg/TransferItemToBankMsg.java | 2 +- src/engine/net/client/msg/UncommitToTradeMsg.java | 2 +- src/engine/net/client/msg/Unknown1Msg.java | 2 +- src/engine/net/client/msg/UnknownMsg.java | 2 +- src/engine/net/client/msg/UnloadObjectsMsg.java | 2 +- src/engine/net/client/msg/UpdateCharOrMobMessage.java | 2 +- src/engine/net/client/msg/UpdateClientAlliancesMsg.java | 4 ++-- src/engine/net/client/msg/UpdateEffectsMsg.java | 2 +- src/engine/net/client/msg/UpdateFriendStatusMessage.java | 4 ++-- src/engine/net/client/msg/UpdateGoldMsg.java | 4 ++-- src/engine/net/client/msg/UpdateInventoryMsg.java | 2 +- src/engine/net/client/msg/UpdateObjectMsg.java | 2 +- src/engine/net/client/msg/UpdateStateMsg.java | 2 +- src/engine/net/client/msg/UpdateTradeWindowMsg.java | 2 +- src/engine/net/client/msg/UpdateVaultMsg.java | 2 +- src/engine/net/client/msg/UpgradeAssetMessage.java | 6 +----- src/engine/net/client/msg/UseCharterMsg.java | 2 +- src/engine/net/client/msg/VendorBuyMsg.java | 2 +- src/engine/net/client/msg/VendorBuyWindowMsg.java | 8 ++------ src/engine/net/client/msg/VendorDialogMsg.java | 2 +- src/engine/net/client/msg/VendorSellMsg.java | 2 +- src/engine/net/client/msg/VendorSellWindowMsg.java | 2 +- src/engine/net/client/msg/ViewResourcesMsg.java | 4 ++-- src/engine/net/client/msg/VisualUpdateMessage.java | 4 ++-- src/engine/net/client/msg/WhoRequestMsg.java | 2 +- src/engine/net/client/msg/WhoResponseMsg.java | 3 +-- src/engine/net/client/msg/WorldDataMsg.java | 8 ++------ src/engine/net/client/msg/WorldRealmMsg.java | 2 +- src/engine/net/client/msg/chat/AbstractChatMsg.java | 2 +- src/engine/net/client/msg/chat/ChatCSRMsg.java | 2 +- src/engine/net/client/msg/chat/ChatCityMsg.java | 2 +- src/engine/net/client/msg/chat/ChatGlobalMsg.java | 2 +- src/engine/net/client/msg/chat/ChatGroupMsg.java | 2 +- src/engine/net/client/msg/chat/ChatGuildMsg.java | 2 +- src/engine/net/client/msg/chat/ChatICMsg.java | 2 +- src/engine/net/client/msg/chat/ChatInfoMsg.java | 2 +- src/engine/net/client/msg/chat/ChatLeaderMsg.java | 2 +- src/engine/net/client/msg/chat/ChatPvPMsg.java | 2 +- src/engine/net/client/msg/chat/ChatSayMsg.java | 2 +- src/engine/net/client/msg/chat/ChatShoutMsg.java | 2 +- src/engine/net/client/msg/chat/ChatSystemChannelMsg.java | 2 +- src/engine/net/client/msg/chat/ChatSystemMsg.java | 2 +- src/engine/net/client/msg/chat/ChatTellMsg.java | 2 +- src/engine/net/client/msg/chat/GuildEnterWorldMsg.java | 2 +- .../net/client/msg/commands/ClientAdminCommandMsg.java | 2 +- .../net/client/msg/group/AppointGroupLeaderMsg.java | 2 +- src/engine/net/client/msg/group/DisbandGroupMsg.java | 2 +- src/engine/net/client/msg/group/FormationFollowMsg.java | 2 +- src/engine/net/client/msg/group/GroupInviteMsg.java | 2 +- .../net/client/msg/group/GroupInviteResponseMsg.java | 2 +- src/engine/net/client/msg/group/GroupUpdateMsg.java | 4 ++-- src/engine/net/client/msg/group/LeaveGroupMsg.java | 2 +- src/engine/net/client/msg/group/RemoveFromGroupMsg.java | 2 +- src/engine/net/client/msg/group/ToggleGroupSplitMsg.java | 2 +- .../net/client/msg/guild/AcceptInviteToGuildMsg.java | 2 +- src/engine/net/client/msg/guild/AcceptSubInviteMsg.java | 2 +- src/engine/net/client/msg/guild/BanishUnbanishMsg.java | 2 +- src/engine/net/client/msg/guild/BreakFealtyMsg.java | 2 +- src/engine/net/client/msg/guild/ChangeRankMsg.java | 2 +- src/engine/net/client/msg/guild/DisbandGuildMsg.java | 2 +- src/engine/net/client/msg/guild/DismissGuildMsg.java | 2 +- src/engine/net/client/msg/guild/GuildControlMsg.java | 2 +- .../net/client/msg/guild/GuildCreationCloseMsg.java | 2 +- .../net/client/msg/guild/GuildCreationFinalizeMsg.java | 2 +- .../net/client/msg/guild/GuildCreationOptionsMsg.java | 2 +- src/engine/net/client/msg/guild/GuildInfoMsg.java | 2 +- src/engine/net/client/msg/guild/GuildListMsg.java | 2 +- src/engine/net/client/msg/guild/GuildUnknownMsg.java | 2 +- src/engine/net/client/msg/guild/InviteToGuildMsg.java | 2 +- src/engine/net/client/msg/guild/InviteToSubMsg.java | 2 +- src/engine/net/client/msg/guild/LeaveGuildMsg.java | 2 +- src/engine/net/client/msg/guild/MOTDCommitMsg.java | 2 +- src/engine/net/client/msg/guild/MOTDMsg.java | 2 +- src/engine/net/client/msg/guild/ReqGuildListMsg.java | 2 +- src/engine/net/client/msg/guild/SendGuildEntryMsg.java | 2 +- src/engine/net/client/msg/guild/SwearInGuildMsg.java | 2 +- src/engine/net/client/msg/guild/SwearInMsg.java | 2 +- src/engine/net/client/msg/login/CharSelectScreenMsg.java | 6 +----- src/engine/net/client/msg/login/ClientLoginInfoMsg.java | 2 +- .../net/client/msg/login/CommitNewCharacterMsg.java | 2 +- src/engine/net/client/msg/login/DeleteCharacterMsg.java | 2 +- .../net/client/msg/login/GameServerIPRequestMsg.java | 2 +- .../net/client/msg/login/GameServerIPResponseMsg.java | 2 +- src/engine/net/client/msg/login/InvalidNameMsg.java | 2 +- src/engine/net/client/msg/login/LoginErrorMsg.java | 2 +- src/engine/net/client/msg/login/ServerStatusMsg.java | 2 +- src/engine/net/client/msg/login/VersionInfoMsg.java | 2 +- src/engine/server/login/LoginServer.java | 2 +- src/engine/server/world/WorldServer.java | 2 +- 240 files changed, 246 insertions(+), 317 deletions(-) rename src/engine/net/{client => }/Protocol.java (99%) diff --git a/src/engine/net/AbstractConnection.java b/src/engine/net/AbstractConnection.java index 8fb86d11..c5bcf4cd 100644 --- a/src/engine/net/AbstractConnection.java +++ b/src/engine/net/AbstractConnection.java @@ -10,7 +10,6 @@ package engine.net; import engine.job.JobManager; -import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/AbstractNetMsg.java b/src/engine/net/AbstractNetMsg.java index eb7e7095..8a00f4b2 100644 --- a/src/engine/net/AbstractNetMsg.java +++ b/src/engine/net/AbstractNetMsg.java @@ -10,7 +10,6 @@ package engine.net; import engine.exception.SerializationException; -import engine.net.client.Protocol; import engine.server.MBServerStatics; import engine.util.StringUtils; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/CheckNetMsgFactoryJob.java b/src/engine/net/CheckNetMsgFactoryJob.java index 18ec9e7d..29529fce 100644 --- a/src/engine/net/CheckNetMsgFactoryJob.java +++ b/src/engine/net/CheckNetMsgFactoryJob.java @@ -9,7 +9,6 @@ package engine.net; import engine.job.AbstractJob; -import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/NetMsgFactory.java b/src/engine/net/NetMsgFactory.java index c1cbba91..79799d8a 100644 --- a/src/engine/net/NetMsgFactory.java +++ b/src/engine/net/NetMsgFactory.java @@ -12,7 +12,6 @@ package engine.net; import engine.exception.FactoryBuildException; import engine.gameManager.ChatManager; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; import org.joda.time.DateTime; diff --git a/src/engine/net/NetMsgStat.java b/src/engine/net/NetMsgStat.java index eef4b0b2..4f57bffe 100644 --- a/src/engine/net/NetMsgStat.java +++ b/src/engine/net/NetMsgStat.java @@ -9,8 +9,6 @@ package engine.net; -import engine.net.client.Protocol; - import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/Protocol.java similarity index 99% rename from src/engine/net/client/Protocol.java rename to src/engine/net/Protocol.java index fef9b5da..67adc7e1 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/Protocol.java @@ -1,11 +1,9 @@ -package engine.net.client; +package engine.net; /* This class defines Magicbane's application network protocol. --> Name / Opcode / Message / Handler */ -import engine.net.AbstractConnection; -import engine.net.ByteBufferReader; import engine.net.client.handlers.*; import engine.net.client.msg.*; import engine.net.client.msg.chat.*; diff --git a/src/engine/net/client/ClientConnection.java b/src/engine/net/client/ClientConnection.java index b2ec544a..142f324f 100644 --- a/src/engine/net/client/ClientConnection.java +++ b/src/engine/net/client/ClientConnection.java @@ -17,6 +17,7 @@ import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.AbstractNetMsg; import engine.net.Network; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.login.LoginErrorMsg; import engine.objects.Account; diff --git a/src/engine/net/client/handlers/AbstractChatMsgHandler.java b/src/engine/net/client/handlers/AbstractChatMsgHandler.java index 0b33adf0..d1bba7e3 100644 --- a/src/engine/net/client/handlers/AbstractChatMsgHandler.java +++ b/src/engine/net/client/handlers/AbstractChatMsgHandler.java @@ -10,8 +10,8 @@ package engine.net.client.handlers; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; +import engine.net.Protocol; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.chat.*; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AbandonAssetMsg.java b/src/engine/net/client/msg/AbandonAssetMsg.java index 51e1b19a..c33ca990 100644 --- a/src/engine/net/client/msg/AbandonAssetMsg.java +++ b/src/engine/net/client/msg/AbandonAssetMsg.java @@ -13,7 +13,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class AbandonAssetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/AcceptFriendMsg.java b/src/engine/net/client/msg/AcceptFriendMsg.java index b309e78e..b9ed8024 100644 --- a/src/engine/net/client/msg/AcceptFriendMsg.java +++ b/src/engine/net/client/msg/AcceptFriendMsg.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AcceptTradeRequestMsg.java b/src/engine/net/client/msg/AcceptTradeRequestMsg.java index e0f63f5e..3b0da8d4 100644 --- a/src/engine/net/client/msg/AcceptTradeRequestMsg.java +++ b/src/engine/net/client/msg/AcceptTradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/ActivateNPCMessage.java b/src/engine/net/client/msg/ActivateNPCMessage.java index 985acbf9..45dd7ecd 100644 --- a/src/engine/net/client/msg/ActivateNPCMessage.java +++ b/src/engine/net/client/msg/ActivateNPCMessage.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Item; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/AddFriendMessage.java b/src/engine/net/client/msg/AddFriendMessage.java index 0ed159fb..051eb4a2 100644 --- a/src/engine/net/client/msg/AddFriendMessage.java +++ b/src/engine/net/client/msg/AddFriendMessage.java @@ -10,7 +10,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java b/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java index ee1ab4ff..818abbce 100644 --- a/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java +++ b/src/engine/net/client/msg/AddGoldToTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class AddGoldToTradeWindowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/AddItemToTradeWindowMsg.java b/src/engine/net/client/msg/AddItemToTradeWindowMsg.java index c66c4b9b..d2f6c91b 100644 --- a/src/engine/net/client/msg/AddItemToTradeWindowMsg.java +++ b/src/engine/net/client/msg/AddItemToTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; public class AddItemToTradeWindowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/AllianceChangeMsg.java b/src/engine/net/client/msg/AllianceChangeMsg.java index 97ff500b..a132a028 100644 --- a/src/engine/net/client/msg/AllianceChangeMsg.java +++ b/src/engine/net/client/msg/AllianceChangeMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/AllyEnemyListMsg.java b/src/engine/net/client/msg/AllyEnemyListMsg.java index 95f5b756..242427cc 100644 --- a/src/engine/net/client/msg/AllyEnemyListMsg.java +++ b/src/engine/net/client/msg/AllyEnemyListMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Guild; import engine.objects.GuildAlliances; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/ApplyBuildingEffectMsg.java b/src/engine/net/client/msg/ApplyBuildingEffectMsg.java index f1b221fa..8a8df691 100644 --- a/src/engine/net/client/msg/ApplyBuildingEffectMsg.java +++ b/src/engine/net/client/msg/ApplyBuildingEffectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ApplyBuildingEffectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ApplyEffectMsg.java b/src/engine/net/client/msg/ApplyEffectMsg.java index b0179ce6..c4e1cb3e 100644 --- a/src/engine/net/client/msg/ApplyEffectMsg.java +++ b/src/engine/net/client/msg/ApplyEffectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ApplyEffectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ApplyRuneMsg.java b/src/engine/net/client/msg/ApplyRuneMsg.java index 22b88fab..aea94c6b 100644 --- a/src/engine/net/client/msg/ApplyRuneMsg.java +++ b/src/engine/net/client/msg/ApplyRuneMsg.java @@ -13,7 +13,6 @@ import engine.gameManager.DbManager; import engine.mbEnums; import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.CharacterRune; import engine.objects.PlayerCharacter; import engine.objects.RuneBase; diff --git a/src/engine/net/client/msg/ArcLoginNotifyMsg.java b/src/engine/net/client/msg/ArcLoginNotifyMsg.java index fd4f48df..37bdeab2 100644 --- a/src/engine/net/client/msg/ArcLoginNotifyMsg.java +++ b/src/engine/net/client/msg/ArcLoginNotifyMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcLoginNotifyMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcMineChangeProductionMsg.java b/src/engine/net/client/msg/ArcMineChangeProductionMsg.java index 0799a9ce..ad8207be 100644 --- a/src/engine/net/client/msg/ArcMineChangeProductionMsg.java +++ b/src/engine/net/client/msg/ArcMineChangeProductionMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcMineChangeProductionMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java b/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java index 249600cd..118fa551 100644 --- a/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java +++ b/src/engine/net/client/msg/ArcMineWindowAvailableTimeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.Guild; import engine.server.MBServerStatics; diff --git a/src/engine/net/client/msg/ArcMineWindowChangeMsg.java b/src/engine/net/client/msg/ArcMineWindowChangeMsg.java index f8b6d309..9c6011af 100644 --- a/src/engine/net/client/msg/ArcMineWindowChangeMsg.java +++ b/src/engine/net/client/msg/ArcMineWindowChangeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcMineWindowChangeMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcOwnedMinesListMsg.java b/src/engine/net/client/msg/ArcOwnedMinesListMsg.java index 202dc621..24d0b70f 100644 --- a/src/engine/net/client/msg/ArcOwnedMinesListMsg.java +++ b/src/engine/net/client/msg/ArcOwnedMinesListMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Mine; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/ArcSiegeSpireMsg.java b/src/engine/net/client/msg/ArcSiegeSpireMsg.java index 2942fce6..71155876 100644 --- a/src/engine/net/client/msg/ArcSiegeSpireMsg.java +++ b/src/engine/net/client/msg/ArcSiegeSpireMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ArcSiegeSpireMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java b/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java index f9ab6df8..924f0e5c 100644 --- a/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java +++ b/src/engine/net/client/msg/ArcViewAssetTransactionsMsg.java @@ -16,7 +16,7 @@ import engine.mbEnums.TransactionType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/AssetSupportMsg.java b/src/engine/net/client/msg/AssetSupportMsg.java index 7c92a009..3a35a18e 100644 --- a/src/engine/net/client/msg/AssetSupportMsg.java +++ b/src/engine/net/client/msg/AssetSupportMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/AttackCmdMsg.java b/src/engine/net/client/msg/AttackCmdMsg.java index f2c41b4e..66dd1379 100644 --- a/src/engine/net/client/msg/AttackCmdMsg.java +++ b/src/engine/net/client/msg/AttackCmdMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class AttackCmdMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ChangeAltitudeMsg.java b/src/engine/net/client/msg/ChangeAltitudeMsg.java index 924a7031..f5cc95dc 100644 --- a/src/engine/net/client/msg/ChangeAltitudeMsg.java +++ b/src/engine/net/client/msg/ChangeAltitudeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; public class ChangeAltitudeMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ChangeGuildLeaderMsg.java b/src/engine/net/client/msg/ChangeGuildLeaderMsg.java index 6443ad86..071e385d 100644 --- a/src/engine/net/client/msg/ChangeGuildLeaderMsg.java +++ b/src/engine/net/client/msg/ChangeGuildLeaderMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ChangeGuildLeaderMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ChatFilterMsg.java b/src/engine/net/client/msg/ChatFilterMsg.java index cd3e8bcd..84570168 100644 --- a/src/engine/net/client/msg/ChatFilterMsg.java +++ b/src/engine/net/client/msg/ChatFilterMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ChatFilterMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/CityAssetMsg.java b/src/engine/net/client/msg/CityAssetMsg.java index 5000ba92..7af6d02f 100644 --- a/src/engine/net/client/msg/CityAssetMsg.java +++ b/src/engine/net/client/msg/CityAssetMsg.java @@ -17,7 +17,7 @@ import engine.mbEnums.ProtectionState; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.City; import engine.objects.Zone; diff --git a/src/engine/net/client/msg/CityChoiceMsg.java b/src/engine/net/client/msg/CityChoiceMsg.java index 1e89ec07..d43f26fa 100644 --- a/src/engine/net/client/msg/CityChoiceMsg.java +++ b/src/engine/net/client/msg/CityChoiceMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/CityDataMsg.java b/src/engine/net/client/msg/CityDataMsg.java index 673a2dfc..62f27363 100644 --- a/src/engine/net/client/msg/CityDataMsg.java +++ b/src/engine/net/client/msg/CityDataMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg; import engine.gameManager.DbManager; import engine.mbEnums; -import engine.net.AbstractConnection; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.Network; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.AbstractGameObject; import engine.objects.City; import engine.objects.Mine; diff --git a/src/engine/net/client/msg/CityZoneMsg.java b/src/engine/net/client/msg/CityZoneMsg.java index b5e19696..7b80ea4c 100644 --- a/src/engine/net/client/msg/CityZoneMsg.java +++ b/src/engine/net/client/msg/CityZoneMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Zone; public class CityZoneMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ClaimAssetMsg.java b/src/engine/net/client/msg/ClaimAssetMsg.java index 5e41afae..590a4d8a 100644 --- a/src/engine/net/client/msg/ClaimAssetMsg.java +++ b/src/engine/net/client/msg/ClaimAssetMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ClaimAssetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ClaimGuildTreeMsg.java b/src/engine/net/client/msg/ClaimGuildTreeMsg.java index de4d2767..221d808d 100644 --- a/src/engine/net/client/msg/ClaimGuildTreeMsg.java +++ b/src/engine/net/client/msg/ClaimGuildTreeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/ClientNetMsg.java b/src/engine/net/client/msg/ClientNetMsg.java index 250d810c..a521f5e4 100644 --- a/src/engine/net/client/msg/ClientNetMsg.java +++ b/src/engine/net/client/msg/ClientNetMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; public abstract class ClientNetMsg extends AbstractNetMsg { diff --git a/src/engine/net/client/msg/CloseTradeWindowMsg.java b/src/engine/net/client/msg/CloseTradeWindowMsg.java index 322d9c4b..b34629a6 100644 --- a/src/engine/net/client/msg/CloseTradeWindowMsg.java +++ b/src/engine/net/client/msg/CloseTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/CommitToTradeMsg.java b/src/engine/net/client/msg/CommitToTradeMsg.java index f0bd2e71..cc871155 100644 --- a/src/engine/net/client/msg/CommitToTradeMsg.java +++ b/src/engine/net/client/msg/CommitToTradeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/ConfirmPromoteMsg.java b/src/engine/net/client/msg/ConfirmPromoteMsg.java index 0031d0e3..ff3a9a6f 100644 --- a/src/engine/net/client/msg/ConfirmPromoteMsg.java +++ b/src/engine/net/client/msg/ConfirmPromoteMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ConfirmPromoteMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/CostOpenBankMsg.java b/src/engine/net/client/msg/CostOpenBankMsg.java index e854f7dc..5831816d 100644 --- a/src/engine/net/client/msg/CostOpenBankMsg.java +++ b/src/engine/net/client/msg/CostOpenBankMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; /** diff --git a/src/engine/net/client/msg/DeclineFriendMsg.java b/src/engine/net/client/msg/DeclineFriendMsg.java index d1d52f2c..0e1a7258 100644 --- a/src/engine/net/client/msg/DeclineFriendMsg.java +++ b/src/engine/net/client/msg/DeclineFriendMsg.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/DeleteItemMsg.java b/src/engine/net/client/msg/DeleteItemMsg.java index fd6ea26d..289cedd1 100644 --- a/src/engine/net/client/msg/DeleteItemMsg.java +++ b/src/engine/net/client/msg/DeleteItemMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DeleteItemMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/DestroyBuildingMsg.java b/src/engine/net/client/msg/DestroyBuildingMsg.java index d5df7216..7bdfa851 100644 --- a/src/engine/net/client/msg/DestroyBuildingMsg.java +++ b/src/engine/net/client/msg/DestroyBuildingMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DestroyBuildingMsg extends ClientNetMsg { private int pad = 0; diff --git a/src/engine/net/client/msg/DoorTryOpenMsg.java b/src/engine/net/client/msg/DoorTryOpenMsg.java index d9766b7f..daf32760 100644 --- a/src/engine/net/client/msg/DoorTryOpenMsg.java +++ b/src/engine/net/client/msg/DoorTryOpenMsg.java @@ -22,7 +22,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DoorTryOpenMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/DropGoldMsg.java b/src/engine/net/client/msg/DropGoldMsg.java index 667916a5..fbde49dc 100644 --- a/src/engine/net/client/msg/DropGoldMsg.java +++ b/src/engine/net/client/msg/DropGoldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class DropGoldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/EnterWorldReceivedMsg.java b/src/engine/net/client/msg/EnterWorldReceivedMsg.java index b300a16a..d93b170f 100644 --- a/src/engine/net/client/msg/EnterWorldReceivedMsg.java +++ b/src/engine/net/client/msg/EnterWorldReceivedMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class EnterWorldReceivedMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ErrorPopupMsg.java b/src/engine/net/client/msg/ErrorPopupMsg.java index d01204f3..6c995f1b 100644 --- a/src/engine/net/client/msg/ErrorPopupMsg.java +++ b/src/engine/net/client/msg/ErrorPopupMsg.java @@ -11,7 +11,6 @@ package engine.net.client.msg; import engine.mbEnums; import engine.net.*; -import engine.net.client.Protocol; import engine.objects.PlayerCharacter; public class ErrorPopupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/FriendRequestMsg.java b/src/engine/net/client/msg/FriendRequestMsg.java index ad735157..7f6c0aa3 100644 --- a/src/engine/net/client/msg/FriendRequestMsg.java +++ b/src/engine/net/client/msg/FriendRequestMsg.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/FurnitureMsg.java b/src/engine/net/client/msg/FurnitureMsg.java index 202db069..c682a8ff 100644 --- a/src/engine/net/client/msg/FurnitureMsg.java +++ b/src/engine/net/client/msg/FurnitureMsg.java @@ -9,13 +9,13 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; import engine.math.Vector3fImmutable; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class FurnitureMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/GoldFromVaultMsg.java b/src/engine/net/client/msg/GoldFromVaultMsg.java index cc55ecde..0357a44d 100644 --- a/src/engine/net/client/msg/GoldFromVaultMsg.java +++ b/src/engine/net/client/msg/GoldFromVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer gold from vault to inventory diff --git a/src/engine/net/client/msg/GoldToVaultMsg.java b/src/engine/net/client/msg/GoldToVaultMsg.java index b927ba63..8acef2a6 100644 --- a/src/engine/net/client/msg/GoldToVaultMsg.java +++ b/src/engine/net/client/msg/GoldToVaultMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer gold from inventory to vault diff --git a/src/engine/net/client/msg/GrantExperienceMsg.java b/src/engine/net/client/msg/GrantExperienceMsg.java index cdff6397..c8e43551 100644 --- a/src/engine/net/client/msg/GrantExperienceMsg.java +++ b/src/engine/net/client/msg/GrantExperienceMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; public class GrantExperienceMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/GuildTreeStatusMsg.java b/src/engine/net/client/msg/GuildTreeStatusMsg.java index 8b108589..ca304f53 100644 --- a/src/engine/net/client/msg/GuildTreeStatusMsg.java +++ b/src/engine/net/client/msg/GuildTreeStatusMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import java.time.LocalDateTime; diff --git a/src/engine/net/client/msg/HirelingServiceMsg.java b/src/engine/net/client/msg/HirelingServiceMsg.java index 8a428dab..1b63a48d 100644 --- a/src/engine/net/client/msg/HirelingServiceMsg.java +++ b/src/engine/net/client/msg/HirelingServiceMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class HirelingServiceMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/HotzoneChangeMsg.java b/src/engine/net/client/msg/HotzoneChangeMsg.java index b779e3ac..9239ce18 100644 --- a/src/engine/net/client/msg/HotzoneChangeMsg.java +++ b/src/engine/net/client/msg/HotzoneChangeMsg.java @@ -15,7 +15,7 @@ import engine.gameManager.ZoneManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.time.Duration; import java.time.Instant; diff --git a/src/engine/net/client/msg/IgnoreListMsg.java b/src/engine/net/client/msg/IgnoreListMsg.java index cbfb0991..7f4c268d 100644 --- a/src/engine/net/client/msg/IgnoreListMsg.java +++ b/src/engine/net/client/msg/IgnoreListMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/IgnoreMsg.java b/src/engine/net/client/msg/IgnoreMsg.java index 6c86cf1b..f7bca0f4 100644 --- a/src/engine/net/client/msg/IgnoreMsg.java +++ b/src/engine/net/client/msg/IgnoreMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class IgnoreMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/InvalidTradeRequestMsg.java b/src/engine/net/client/msg/InvalidTradeRequestMsg.java index 4e97395b..0c9d917c 100644 --- a/src/engine/net/client/msg/InvalidTradeRequestMsg.java +++ b/src/engine/net/client/msg/InvalidTradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/ItemEffectMsg.java b/src/engine/net/client/msg/ItemEffectMsg.java index 5408118c..4600fb2a 100644 --- a/src/engine/net/client/msg/ItemEffectMsg.java +++ b/src/engine/net/client/msg/ItemEffectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ItemEffectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ItemFromVaultMsg.java b/src/engine/net/client/msg/ItemFromVaultMsg.java index c1aee4c9..75cec72f 100644 --- a/src/engine/net/client/msg/ItemFromVaultMsg.java +++ b/src/engine/net/client/msg/ItemFromVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from Vault to inventory diff --git a/src/engine/net/client/msg/ItemHealthUpdateMsg.java b/src/engine/net/client/msg/ItemHealthUpdateMsg.java index ba818e3d..fdd93c82 100644 --- a/src/engine/net/client/msg/ItemHealthUpdateMsg.java +++ b/src/engine/net/client/msg/ItemHealthUpdateMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ItemHealthUpdateMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index e65d0bf4..6d4df1ed 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -12,11 +12,7 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; import engine.gameManager.PowersManager; import engine.mbEnums.GameObjectType; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Building; import engine.objects.Item; import engine.objects.MobLoot; diff --git a/src/engine/net/client/msg/ItemToVaultMsg.java b/src/engine/net/client/msg/ItemToVaultMsg.java index b4e3eb11..2c0ef59e 100644 --- a/src/engine/net/client/msg/ItemToVaultMsg.java +++ b/src/engine/net/client/msg/ItemToVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from inventory to vault diff --git a/src/engine/net/client/msg/KeepAliveServerClientMsg.java b/src/engine/net/client/msg/KeepAliveServerClientMsg.java index e674d1b5..96d35334 100644 --- a/src/engine/net/client/msg/KeepAliveServerClientMsg.java +++ b/src/engine/net/client/msg/KeepAliveServerClientMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class KeepAliveServerClientMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LeaderboardMessage.java b/src/engine/net/client/msg/LeaderboardMessage.java index b5179f64..0026c456 100644 --- a/src/engine/net/client/msg/LeaderboardMessage.java +++ b/src/engine/net/client/msg/LeaderboardMessage.java @@ -15,7 +15,7 @@ import engine.mbEnums.ShrineType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.Guild; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/LeaveWorldMsg.java b/src/engine/net/client/msg/LeaveWorldMsg.java index 0711c881..45b622bd 100644 --- a/src/engine/net/client/msg/LeaveWorldMsg.java +++ b/src/engine/net/client/msg/LeaveWorldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LeaveWorldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LoadCharacterMsg.java b/src/engine/net/client/msg/LoadCharacterMsg.java index 50399a6f..e4efc1b3 100644 --- a/src/engine/net/client/msg/LoadCharacterMsg.java +++ b/src/engine/net/client/msg/LoadCharacterMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.AbstractCharacter; import engine.objects.Corpse; diff --git a/src/engine/net/client/msg/LoadStructureMsg.java b/src/engine/net/client/msg/LoadStructureMsg.java index fe8014d2..a59a8064 100644 --- a/src/engine/net/client/msg/LoadStructureMsg.java +++ b/src/engine/net/client/msg/LoadStructureMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Building; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/LockUnlockDoorMsg.java b/src/engine/net/client/msg/LockUnlockDoorMsg.java index b644be14..99fe3750 100644 --- a/src/engine/net/client/msg/LockUnlockDoorMsg.java +++ b/src/engine/net/client/msg/LockUnlockDoorMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LockUnlockDoorMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LoginToGameServerMsg.java b/src/engine/net/client/msg/LoginToGameServerMsg.java index e77639aa..f1f17db8 100644 --- a/src/engine/net/client/msg/LoginToGameServerMsg.java +++ b/src/engine/net/client/msg/LoginToGameServerMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LoginToGameServerMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LootMsg.java b/src/engine/net/client/msg/LootMsg.java index 86c49c03..84b0024a 100644 --- a/src/engine/net/client/msg/LootMsg.java +++ b/src/engine/net/client/msg/LootMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; public class LootMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LootWindowRequestMsg.java b/src/engine/net/client/msg/LootWindowRequestMsg.java index 94832bec..cd938df8 100644 --- a/src/engine/net/client/msg/LootWindowRequestMsg.java +++ b/src/engine/net/client/msg/LootWindowRequestMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class LootWindowRequestMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/LootWindowResponseMsg.java b/src/engine/net/client/msg/LootWindowResponseMsg.java index c6d42530..e18fe1f2 100644 --- a/src/engine/net/client/msg/LootWindowResponseMsg.java +++ b/src/engine/net/client/msg/LootWindowResponseMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/ManageCityAssetsMsg.java b/src/engine/net/client/msg/ManageCityAssetsMsg.java index 5f640f05..85620300 100644 --- a/src/engine/net/client/msg/ManageCityAssetsMsg.java +++ b/src/engine/net/client/msg/ManageCityAssetsMsg.java @@ -16,7 +16,7 @@ import engine.mbEnums.*; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import org.joda.time.DateTime; import org.joda.time.Period; diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index a13620b9..2ec99f38 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -16,7 +16,7 @@ import engine.mbEnums.MinionType; import engine.mbEnums.ProtectionState; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import engine.powers.EffectsBase; import org.joda.time.DateTime; diff --git a/src/engine/net/client/msg/MerchantMsg.java b/src/engine/net/client/msg/MerchantMsg.java index d14d0692..fd14a2f7 100644 --- a/src/engine/net/client/msg/MerchantMsg.java +++ b/src/engine/net/client/msg/MerchantMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class MerchantMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/MinionTrainingMessage.java b/src/engine/net/client/msg/MinionTrainingMessage.java index 507db953..d9e3cf84 100644 --- a/src/engine/net/client/msg/MinionTrainingMessage.java +++ b/src/engine/net/client/msg/MinionTrainingMessage.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class MinionTrainingMessage extends ClientNetMsg { private int npcID; diff --git a/src/engine/net/client/msg/ModifyCommitToTradeMsg.java b/src/engine/net/client/msg/ModifyCommitToTradeMsg.java index dad76a06..18b83439 100644 --- a/src/engine/net/client/msg/ModifyCommitToTradeMsg.java +++ b/src/engine/net/client/msg/ModifyCommitToTradeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/ModifyHealthKillMsg.java b/src/engine/net/client/msg/ModifyHealthKillMsg.java index e0de0498..30e705f3 100644 --- a/src/engine/net/client/msg/ModifyHealthKillMsg.java +++ b/src/engine/net/client/msg/ModifyHealthKillMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class ModifyHealthKillMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ModifyHealthMsg.java b/src/engine/net/client/msg/ModifyHealthMsg.java index 39a9a94b..7e79efc6 100644 --- a/src/engine/net/client/msg/ModifyHealthMsg.java +++ b/src/engine/net/client/msg/ModifyHealthMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.Building; diff --git a/src/engine/net/client/msg/ModifyStatMsg.java b/src/engine/net/client/msg/ModifyStatMsg.java index f01ff56c..318c2242 100644 --- a/src/engine/net/client/msg/ModifyStatMsg.java +++ b/src/engine/net/client/msg/ModifyStatMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ModifyStatMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/MoveCorrectionMsg.java b/src/engine/net/client/msg/MoveCorrectionMsg.java index 67618bd8..b23b6b42 100644 --- a/src/engine/net/client/msg/MoveCorrectionMsg.java +++ b/src/engine/net/client/msg/MoveCorrectionMsg.java @@ -14,7 +14,7 @@ import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class MoveCorrectionMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/MoveToPointMsg.java b/src/engine/net/client/msg/MoveToPointMsg.java index e9f83de7..6f9253fc 100644 --- a/src/engine/net/client/msg/MoveToPointMsg.java +++ b/src/engine/net/client/msg/MoveToPointMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.Building; diff --git a/src/engine/net/client/msg/ObjectActionMsg.java b/src/engine/net/client/msg/ObjectActionMsg.java index c3922440..2e64dafc 100644 --- a/src/engine/net/client/msg/ObjectActionMsg.java +++ b/src/engine/net/client/msg/ObjectActionMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java index 4082d469..6b130bd9 100644 --- a/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java +++ b/src/engine/net/client/msg/OpenFriendsCondemnListMsg.java @@ -15,8 +15,8 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; +import engine.net.Protocol; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/OpenTradeWindowMsg.java b/src/engine/net/client/msg/OpenTradeWindowMsg.java index 05af29b5..35931622 100644 --- a/src/engine/net/client/msg/OpenTradeWindowMsg.java +++ b/src/engine/net/client/msg/OpenTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/OpenVaultMsg.java b/src/engine/net/client/msg/OpenVaultMsg.java index 61aca7e9..3238008d 100644 --- a/src/engine/net/client/msg/OpenVaultMsg.java +++ b/src/engine/net/client/msg/OpenVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/OrderNPCMsg.java b/src/engine/net/client/msg/OrderNPCMsg.java index dac9ea5b..f2e7f103 100644 --- a/src/engine/net/client/msg/OrderNPCMsg.java +++ b/src/engine/net/client/msg/OrderNPCMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/PassiveMessageTriggerMsg.java b/src/engine/net/client/msg/PassiveMessageTriggerMsg.java index 87070bdf..e6374948 100644 --- a/src/engine/net/client/msg/PassiveMessageTriggerMsg.java +++ b/src/engine/net/client/msg/PassiveMessageTriggerMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PassiveMessageTriggerMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PerformActionMsg.java b/src/engine/net/client/msg/PerformActionMsg.java index 0c838b09..e7301a05 100644 --- a/src/engine/net/client/msg/PerformActionMsg.java +++ b/src/engine/net/client/msg/PerformActionMsg.java @@ -15,7 +15,7 @@ import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PerformActionMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetAttackMsg.java b/src/engine/net/client/msg/PetAttackMsg.java index 40ae985b..86295028 100644 --- a/src/engine/net/client/msg/PetAttackMsg.java +++ b/src/engine/net/client/msg/PetAttackMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PetAttackMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetCmdMsg.java b/src/engine/net/client/msg/PetCmdMsg.java index 64095719..1c13adf5 100644 --- a/src/engine/net/client/msg/PetCmdMsg.java +++ b/src/engine/net/client/msg/PetCmdMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PetCmdMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetMsg.java b/src/engine/net/client/msg/PetMsg.java index ca378aae..886ba0bd 100644 --- a/src/engine/net/client/msg/PetMsg.java +++ b/src/engine/net/client/msg/PetMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Mob; public class PetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/PetitionReceivedMsg.java b/src/engine/net/client/msg/PetitionReceivedMsg.java index fa66f1a9..5019632c 100644 --- a/src/engine/net/client/msg/PetitionReceivedMsg.java +++ b/src/engine/net/client/msg/PetitionReceivedMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.stream.IntStream; diff --git a/src/engine/net/client/msg/PlaceAssetMsg.java b/src/engine/net/client/msg/PlaceAssetMsg.java index 9991590f..15d0f14c 100644 --- a/src/engine/net/client/msg/PlaceAssetMsg.java +++ b/src/engine/net/client/msg/PlaceAssetMsg.java @@ -13,7 +13,6 @@ import engine.math.Vector3fImmutable; import engine.mbEnums; import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.Zone; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/PowerProjectileMsg.java b/src/engine/net/client/msg/PowerProjectileMsg.java index 0a7f46c2..1f31dd06 100644 --- a/src/engine/net/client/msg/PowerProjectileMsg.java +++ b/src/engine/net/client/msg/PowerProjectileMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/PromptRecallMsg.java b/src/engine/net/client/msg/PromptRecallMsg.java index d550bed4..fb4e716b 100644 --- a/src/engine/net/client/msg/PromptRecallMsg.java +++ b/src/engine/net/client/msg/PromptRecallMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class PromptRecallMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RandomMsg.java b/src/engine/net/client/msg/RandomMsg.java index e2b12421..1c12f9a1 100644 --- a/src/engine/net/client/msg/RandomMsg.java +++ b/src/engine/net/client/msg/RandomMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RandomMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RecommendNationMsg.java b/src/engine/net/client/msg/RecommendNationMsg.java index d5b86184..5efc2de8 100644 --- a/src/engine/net/client/msg/RecommendNationMsg.java +++ b/src/engine/net/client/msg/RecommendNationMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/RecvSummonsMsg.java b/src/engine/net/client/msg/RecvSummonsMsg.java index bf37bf96..e84caa10 100644 --- a/src/engine/net/client/msg/RecvSummonsMsg.java +++ b/src/engine/net/client/msg/RecvSummonsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RecvSummonsMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RecyclePowerMsg.java b/src/engine/net/client/msg/RecyclePowerMsg.java index 015e5164..e91b626e 100644 --- a/src/engine/net/client/msg/RecyclePowerMsg.java +++ b/src/engine/net/client/msg/RecyclePowerMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RecyclePowerMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RefineMsg.java b/src/engine/net/client/msg/RefineMsg.java index 1e6e6eba..aa12f22c 100644 --- a/src/engine/net/client/msg/RefineMsg.java +++ b/src/engine/net/client/msg/RefineMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RefineMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RefinerScreenMsg.java b/src/engine/net/client/msg/RefinerScreenMsg.java index 54f5e8e3..674e63a3 100644 --- a/src/engine/net/client/msg/RefinerScreenMsg.java +++ b/src/engine/net/client/msg/RefinerScreenMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RefinerScreenMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RejectTradeRequestMsg.java b/src/engine/net/client/msg/RejectTradeRequestMsg.java index 1305a3a6..9fdb282e 100644 --- a/src/engine/net/client/msg/RejectTradeRequestMsg.java +++ b/src/engine/net/client/msg/RejectTradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/RemoveFriendMessage.java b/src/engine/net/client/msg/RemoveFriendMessage.java index be34be10..42c88a98 100644 --- a/src/engine/net/client/msg/RemoveFriendMessage.java +++ b/src/engine/net/client/msg/RemoveFriendMessage.java @@ -10,7 +10,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RemoveFriendMessage extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RepairBuildingMsg.java b/src/engine/net/client/msg/RepairBuildingMsg.java index fdf86960..1cb03004 100644 --- a/src/engine/net/client/msg/RepairBuildingMsg.java +++ b/src/engine/net/client/msg/RepairBuildingMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RepairBuildingMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RepairMsg.java b/src/engine/net/client/msg/RepairMsg.java index cd3712b5..08a51023 100644 --- a/src/engine/net/client/msg/RepairMsg.java +++ b/src/engine/net/client/msg/RepairMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Contract; import engine.objects.NPC; diff --git a/src/engine/net/client/msg/ReqBankInventoryMsg.java b/src/engine/net/client/msg/ReqBankInventoryMsg.java index a2941cef..fd5f14bd 100644 --- a/src/engine/net/client/msg/ReqBankInventoryMsg.java +++ b/src/engine/net/client/msg/ReqBankInventoryMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/RequestBallListMessage.java b/src/engine/net/client/msg/RequestBallListMessage.java index 3e4a689e..1c29dc71 100644 --- a/src/engine/net/client/msg/RequestBallListMessage.java +++ b/src/engine/net/client/msg/RequestBallListMessage.java @@ -10,7 +10,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/RequestEnterWorldMsg.java b/src/engine/net/client/msg/RequestEnterWorldMsg.java index 217eb375..28c1eb9e 100644 --- a/src/engine/net/client/msg/RequestEnterWorldMsg.java +++ b/src/engine/net/client/msg/RequestEnterWorldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RequestEnterWorldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RespawnMsg.java b/src/engine/net/client/msg/RespawnMsg.java index ebf5eaa5..368f18e5 100644 --- a/src/engine/net/client/msg/RespawnMsg.java +++ b/src/engine/net/client/msg/RespawnMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RespawnMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RespondLeaveWorldMsg.java b/src/engine/net/client/msg/RespondLeaveWorldMsg.java index a2c646dc..a75a1cb2 100644 --- a/src/engine/net/client/msg/RespondLeaveWorldMsg.java +++ b/src/engine/net/client/msg/RespondLeaveWorldMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class RespondLeaveWorldMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/RotateObjectMsg.java b/src/engine/net/client/msg/RotateObjectMsg.java index 090a9b8c..ed19cfa8 100644 --- a/src/engine/net/client/msg/RotateObjectMsg.java +++ b/src/engine/net/client/msg/RotateObjectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Mob; public class RotateObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/SafeModeMsg.java b/src/engine/net/client/msg/SafeModeMsg.java index 8dfb9de5..9aecaeab 100644 --- a/src/engine/net/client/msg/SafeModeMsg.java +++ b/src/engine/net/client/msg/SafeModeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class SafeModeMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ScaleObjectMsg.java b/src/engine/net/client/msg/ScaleObjectMsg.java index 877fbcef..cd78d77b 100644 --- a/src/engine/net/client/msg/ScaleObjectMsg.java +++ b/src/engine/net/client/msg/ScaleObjectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ScaleObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/SelectCityMsg.java b/src/engine/net/client/msg/SelectCityMsg.java index 4e13af87..07c199eb 100644 --- a/src/engine/net/client/msg/SelectCityMsg.java +++ b/src/engine/net/client/msg/SelectCityMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/SendBallEntryMessage.java b/src/engine/net/client/msg/SendBallEntryMessage.java index 9b431841..447bbc11 100644 --- a/src/engine/net/client/msg/SendBallEntryMessage.java +++ b/src/engine/net/client/msg/SendBallEntryMessage.java @@ -9,7 +9,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/SendOwnPlayerMsg.java b/src/engine/net/client/msg/SendOwnPlayerMsg.java index f83f0dc1..bd43ba20 100644 --- a/src/engine/net/client/msg/SendOwnPlayerMsg.java +++ b/src/engine/net/client/msg/SendOwnPlayerMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.Building; import engine.objects.PlayerCharacter; import engine.objects.Regions; diff --git a/src/engine/net/client/msg/SendSummonsMsg.java b/src/engine/net/client/msg/SendSummonsMsg.java index 6b5723b5..64942b23 100644 --- a/src/engine/net/client/msg/SendSummonsMsg.java +++ b/src/engine/net/client/msg/SendSummonsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class SendSummonsMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ServerInfoMsg.java b/src/engine/net/client/msg/ServerInfoMsg.java index 33320c0f..4d2f57f1 100644 --- a/src/engine/net/client/msg/ServerInfoMsg.java +++ b/src/engine/net/client/msg/ServerInfoMsg.java @@ -14,7 +14,7 @@ import engine.gameManager.ConfigManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.server.MBServerStatics; import engine.server.login.LoginServer; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/SetCombatModeMsg.java b/src/engine/net/client/msg/SetCombatModeMsg.java index 7ae0f3f5..2dab8536 100644 --- a/src/engine/net/client/msg/SetCombatModeMsg.java +++ b/src/engine/net/client/msg/SetCombatModeMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/SetObjectValueMsg.java b/src/engine/net/client/msg/SetObjectValueMsg.java index a7ea9e68..74cd0a16 100644 --- a/src/engine/net/client/msg/SetObjectValueMsg.java +++ b/src/engine/net/client/msg/SetObjectValueMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; public class SetObjectValueMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ShowBankInventoryMsg.java b/src/engine/net/client/msg/ShowBankInventoryMsg.java index c85801d6..f739f47a 100644 --- a/src/engine/net/client/msg/ShowBankInventoryMsg.java +++ b/src/engine/net/client/msg/ShowBankInventoryMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.Item; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/ShowMsg.java b/src/engine/net/client/msg/ShowMsg.java index 93686ce8..730bd234 100644 --- a/src/engine/net/client/msg/ShowMsg.java +++ b/src/engine/net/client/msg/ShowMsg.java @@ -14,7 +14,7 @@ import engine.math.Vector3fImmutable; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ShowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ShowVaultInventoryMsg.java b/src/engine/net/client/msg/ShowVaultInventoryMsg.java index 5df29795..04692531 100644 --- a/src/engine/net/client/msg/ShowVaultInventoryMsg.java +++ b/src/engine/net/client/msg/ShowVaultInventoryMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/SocialMsg.java b/src/engine/net/client/msg/SocialMsg.java index be748357..cc9c7f21 100644 --- a/src/engine/net/client/msg/SocialMsg.java +++ b/src/engine/net/client/msg/SocialMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class SocialMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/StuckMsg.java b/src/engine/net/client/msg/StuckMsg.java index b598cb15..2ae240ca 100644 --- a/src/engine/net/client/msg/StuckMsg.java +++ b/src/engine/net/client/msg/StuckMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class StuckMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TargetObjectMsg.java b/src/engine/net/client/msg/TargetObjectMsg.java index 55d6f28f..d124a8de 100644 --- a/src/engine/net/client/msg/TargetObjectMsg.java +++ b/src/engine/net/client/msg/TargetObjectMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TargetObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TargetedActionMsg.java b/src/engine/net/client/msg/TargetedActionMsg.java index c60d7056..6c06c56c 100644 --- a/src/engine/net/client/msg/TargetedActionMsg.java +++ b/src/engine/net/client/msg/TargetedActionMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/TaxCityMsg.java b/src/engine/net/client/msg/TaxCityMsg.java index e2e80e22..d0030bf7 100644 --- a/src/engine/net/client/msg/TaxCityMsg.java +++ b/src/engine/net/client/msg/TaxCityMsg.java @@ -9,13 +9,13 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; import engine.gameManager.BuildingManager; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/TaxResourcesMsg.java b/src/engine/net/client/msg/TaxResourcesMsg.java index a14639f8..f6ca4e28 100644 --- a/src/engine/net/client/msg/TaxResourcesMsg.java +++ b/src/engine/net/client/msg/TaxResourcesMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Building; import java.util.HashMap; diff --git a/src/engine/net/client/msg/TeleportRepledgeListMsg.java b/src/engine/net/client/msg/TeleportRepledgeListMsg.java index a76f2abf..d48fc751 100644 --- a/src/engine/net/client/msg/TeleportRepledgeListMsg.java +++ b/src/engine/net/client/msg/TeleportRepledgeListMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.City; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/TeleportToPointMsg.java b/src/engine/net/client/msg/TeleportToPointMsg.java index 61fcd6a6..78d888df 100644 --- a/src/engine/net/client/msg/TeleportToPointMsg.java +++ b/src/engine/net/client/msg/TeleportToPointMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class TeleportToPointMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TerritoryChangeMessage.java b/src/engine/net/client/msg/TerritoryChangeMessage.java index 87e811b0..ff42b87a 100644 --- a/src/engine/net/client/msg/TerritoryChangeMessage.java +++ b/src/engine/net/client/msg/TerritoryChangeMessage.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; import engine.objects.Realm; diff --git a/src/engine/net/client/msg/ToggleCombatMsg.java b/src/engine/net/client/msg/ToggleCombatMsg.java index 613ee1f0..170016df 100644 --- a/src/engine/net/client/msg/ToggleCombatMsg.java +++ b/src/engine/net/client/msg/ToggleCombatMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ToggleCombatMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java b/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java index 8b443240..1ce26b80 100644 --- a/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java +++ b/src/engine/net/client/msg/ToggleLfgRecruitingMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ToggleLfgRecruitingMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/ToggleSitStandMsg.java b/src/engine/net/client/msg/ToggleSitStandMsg.java index e7e94898..db55f3c8 100644 --- a/src/engine/net/client/msg/ToggleSitStandMsg.java +++ b/src/engine/net/client/msg/ToggleSitStandMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class ToggleSitStandMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TrackArrowMsg.java b/src/engine/net/client/msg/TrackArrowMsg.java index b66056de..872f5995 100644 --- a/src/engine/net/client/msg/TrackArrowMsg.java +++ b/src/engine/net/client/msg/TrackArrowMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TrackArrowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TrackWindowMsg.java b/src/engine/net/client/msg/TrackWindowMsg.java index 61256bfb..07751e55 100644 --- a/src/engine/net/client/msg/TrackWindowMsg.java +++ b/src/engine/net/client/msg/TrackWindowMsg.java @@ -10,11 +10,7 @@ package engine.net.client.msg; import engine.mbEnums.GameObjectType; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.objects.*; import java.util.HashSet; diff --git a/src/engine/net/client/msg/TradeRequestMsg.java b/src/engine/net/client/msg/TradeRequestMsg.java index bf9ace62..bfcbd30a 100644 --- a/src/engine/net/client/msg/TradeRequestMsg.java +++ b/src/engine/net/client/msg/TradeRequestMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; /** diff --git a/src/engine/net/client/msg/TrainMsg.java b/src/engine/net/client/msg/TrainMsg.java index 7cd3213f..9fd4ce7d 100644 --- a/src/engine/net/client/msg/TrainMsg.java +++ b/src/engine/net/client/msg/TrainMsg.java @@ -12,7 +12,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.NPC; diff --git a/src/engine/net/client/msg/TrainerInfoMsg.java b/src/engine/net/client/msg/TrainerInfoMsg.java index ea8c5630..4f751aea 100644 --- a/src/engine/net/client/msg/TrainerInfoMsg.java +++ b/src/engine/net/client/msg/TrainerInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TrainerInfoMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferAssetMsg.java b/src/engine/net/client/msg/TransferAssetMsg.java index 1ea61d0a..bfa55504 100644 --- a/src/engine/net/client/msg/TransferAssetMsg.java +++ b/src/engine/net/client/msg/TransferAssetMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TransferAssetMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferBuildingMsg.java b/src/engine/net/client/msg/TransferBuildingMsg.java index 7a04c25c..83886f5da 100644 --- a/src/engine/net/client/msg/TransferBuildingMsg.java +++ b/src/engine/net/client/msg/TransferBuildingMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class TransferBuildingMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java b/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java index 60011884..0681c9f4 100644 --- a/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java +++ b/src/engine/net/client/msg/TransferGoldToFromBuildingMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/TransferItemFromBankMsg.java b/src/engine/net/client/msg/TransferItemFromBankMsg.java index e330984f..3ee1da26 100644 --- a/src/engine/net/client/msg/TransferItemFromBankMsg.java +++ b/src/engine/net/client/msg/TransferItemFromBankMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from bank to inventory diff --git a/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java b/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java index 48ba28c2..dce19863 100644 --- a/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java +++ b/src/engine/net/client/msg/TransferItemFromEquipToInventoryMsg.java @@ -10,12 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.exception.SerializationException; +import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; public class TransferItemFromEquipToInventoryMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java b/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java index 9aeb8ff3..8b734f3c 100644 --- a/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java +++ b/src/engine/net/client/msg/TransferItemFromInventoryToEquipMsg.java @@ -10,12 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.exception.SerializationException; +import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/TransferItemToBankMsg.java b/src/engine/net/client/msg/TransferItemToBankMsg.java index 617befdb..deda39f6 100644 --- a/src/engine/net/client/msg/TransferItemToBankMsg.java +++ b/src/engine/net/client/msg/TransferItemToBankMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Transfer item from inventory to bank diff --git a/src/engine/net/client/msg/UncommitToTradeMsg.java b/src/engine/net/client/msg/UncommitToTradeMsg.java index 7a175350..abc38e61 100644 --- a/src/engine/net/client/msg/UncommitToTradeMsg.java +++ b/src/engine/net/client/msg/UncommitToTradeMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** diff --git a/src/engine/net/client/msg/Unknown1Msg.java b/src/engine/net/client/msg/Unknown1Msg.java index 4c92abf1..25a48584 100644 --- a/src/engine/net/client/msg/Unknown1Msg.java +++ b/src/engine/net/client/msg/Unknown1Msg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class Unknown1Msg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UnknownMsg.java b/src/engine/net/client/msg/UnknownMsg.java index 7d57ea49..c0501f8e 100644 --- a/src/engine/net/client/msg/UnknownMsg.java +++ b/src/engine/net/client/msg/UnknownMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class UnknownMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UnloadObjectsMsg.java b/src/engine/net/client/msg/UnloadObjectsMsg.java index e300e646..a1caed51 100644 --- a/src/engine/net/client/msg/UnloadObjectsMsg.java +++ b/src/engine/net/client/msg/UnloadObjectsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/UpdateCharOrMobMessage.java b/src/engine/net/client/msg/UpdateCharOrMobMessage.java index 5eae48ed..de5ab270 100644 --- a/src/engine/net/client/msg/UpdateCharOrMobMessage.java +++ b/src/engine/net/client/msg/UpdateCharOrMobMessage.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; public class UpdateCharOrMobMessage extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UpdateClientAlliancesMsg.java b/src/engine/net/client/msg/UpdateClientAlliancesMsg.java index a872c431..c2b23970 100644 --- a/src/engine/net/client/msg/UpdateClientAlliancesMsg.java +++ b/src/engine/net/client/msg/UpdateClientAlliancesMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Guild; diff --git a/src/engine/net/client/msg/UpdateEffectsMsg.java b/src/engine/net/client/msg/UpdateEffectsMsg.java index aa7a1f8b..0537b019 100644 --- a/src/engine/net/client/msg/UpdateEffectsMsg.java +++ b/src/engine/net/client/msg/UpdateEffectsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; import engine.objects.Effect; diff --git a/src/engine/net/client/msg/UpdateFriendStatusMessage.java b/src/engine/net/client/msg/UpdateFriendStatusMessage.java index ecb34248..32444398 100644 --- a/src/engine/net/client/msg/UpdateFriendStatusMessage.java +++ b/src/engine/net/client/msg/UpdateFriendStatusMessage.java @@ -6,12 +6,12 @@ HashSet playerFriendSet = PlayerFriendsMap.get(playerUID); package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.gameManager.SessionManager; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/UpdateGoldMsg.java b/src/engine/net/client/msg/UpdateGoldMsg.java index 604014fa..4c706581 100644 --- a/src/engine/net/client/msg/UpdateGoldMsg.java +++ b/src/engine/net/client/msg/UpdateGoldMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; import engine.objects.CharacterItemManager; import engine.objects.Item; diff --git a/src/engine/net/client/msg/UpdateInventoryMsg.java b/src/engine/net/client/msg/UpdateInventoryMsg.java index 2e458f9e..3eb03447 100644 --- a/src/engine/net/client/msg/UpdateInventoryMsg.java +++ b/src/engine/net/client/msg/UpdateInventoryMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.ItemType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/UpdateObjectMsg.java b/src/engine/net/client/msg/UpdateObjectMsg.java index aae3ea64..9b16e475 100644 --- a/src/engine/net/client/msg/UpdateObjectMsg.java +++ b/src/engine/net/client/msg/UpdateObjectMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; public class UpdateObjectMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UpdateStateMsg.java b/src/engine/net/client/msg/UpdateStateMsg.java index 775fcafc..1496d432 100644 --- a/src/engine/net/client/msg/UpdateStateMsg.java +++ b/src/engine/net/client/msg/UpdateStateMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/UpdateTradeWindowMsg.java b/src/engine/net/client/msg/UpdateTradeWindowMsg.java index 9bf0d9d9..80937e16 100644 --- a/src/engine/net/client/msg/UpdateTradeWindowMsg.java +++ b/src/engine/net/client/msg/UpdateTradeWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/UpdateVaultMsg.java b/src/engine/net/client/msg/UpdateVaultMsg.java index 0ef84124..9a8a278c 100644 --- a/src/engine/net/client/msg/UpdateVaultMsg.java +++ b/src/engine/net/client/msg/UpdateVaultMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Account; /** diff --git a/src/engine/net/client/msg/UpgradeAssetMessage.java b/src/engine/net/client/msg/UpgradeAssetMessage.java index d0366928..2f69180d 100644 --- a/src/engine/net/client/msg/UpgradeAssetMessage.java +++ b/src/engine/net/client/msg/UpgradeAssetMessage.java @@ -10,11 +10,7 @@ package engine.net.client.msg; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; public class UpgradeAssetMessage extends ClientNetMsg { diff --git a/src/engine/net/client/msg/UseCharterMsg.java b/src/engine/net/client/msg/UseCharterMsg.java index 8b80ca23..1fe5f91f 100644 --- a/src/engine/net/client/msg/UseCharterMsg.java +++ b/src/engine/net/client/msg/UseCharterMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.ItemType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/VendorBuyMsg.java b/src/engine/net/client/msg/VendorBuyMsg.java index 58183e53..643865b6 100644 --- a/src/engine/net/client/msg/VendorBuyMsg.java +++ b/src/engine/net/client/msg/VendorBuyMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Item; public class VendorBuyMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/VendorBuyWindowMsg.java b/src/engine/net/client/msg/VendorBuyWindowMsg.java index acbb835d..9c5517a3 100644 --- a/src/engine/net/client/msg/VendorBuyWindowMsg.java +++ b/src/engine/net/client/msg/VendorBuyWindowMsg.java @@ -9,14 +9,10 @@ package engine.net.client.msg; -import engine.mbEnums.ItemType; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; +import engine.mbEnums.ItemType; +import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.*; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/VendorDialogMsg.java b/src/engine/net/client/msg/VendorDialogMsg.java index f694a5a4..e91c7c34 100644 --- a/src/engine/net/client/msg/VendorDialogMsg.java +++ b/src/engine/net/client/msg/VendorDialogMsg.java @@ -12,7 +12,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.MenuOption; import engine.objects.VendorDialog; diff --git a/src/engine/net/client/msg/VendorSellMsg.java b/src/engine/net/client/msg/VendorSellMsg.java index 830400e4..630f8a60 100644 --- a/src/engine/net/client/msg/VendorSellMsg.java +++ b/src/engine/net/client/msg/VendorSellMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; /** * Buy from NPC msg diff --git a/src/engine/net/client/msg/VendorSellWindowMsg.java b/src/engine/net/client/msg/VendorSellWindowMsg.java index 5a81f731..152a3c74 100644 --- a/src/engine/net/client/msg/VendorSellWindowMsg.java +++ b/src/engine/net/client/msg/VendorSellWindowMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import java.util.ArrayList; diff --git a/src/engine/net/client/msg/ViewResourcesMsg.java b/src/engine/net/client/msg/ViewResourcesMsg.java index cbaaaa94..b3e5acff 100644 --- a/src/engine/net/client/msg/ViewResourcesMsg.java +++ b/src/engine/net/client/msg/ViewResourcesMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.gameManager.DbManager; +import engine.mbEnums; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.*; diff --git a/src/engine/net/client/msg/VisualUpdateMessage.java b/src/engine/net/client/msg/VisualUpdateMessage.java index 94e79894..fa88e585 100644 --- a/src/engine/net/client/msg/VisualUpdateMessage.java +++ b/src/engine/net/client/msg/VisualUpdateMessage.java @@ -10,12 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums.GameObjectType; import engine.exception.SerializationException; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractGameObject; import engine.objects.Building; diff --git a/src/engine/net/client/msg/WhoRequestMsg.java b/src/engine/net/client/msg/WhoRequestMsg.java index 93433461..13849af0 100644 --- a/src/engine/net/client/msg/WhoRequestMsg.java +++ b/src/engine/net/client/msg/WhoRequestMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; public class WhoRequestMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/WhoResponseMsg.java b/src/engine/net/client/msg/WhoResponseMsg.java index 02cb59db..c89fe630 100644 --- a/src/engine/net/client/msg/WhoResponseMsg.java +++ b/src/engine/net/client/msg/WhoResponseMsg.java @@ -9,11 +9,10 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.gameManager.SessionManager; +import engine.mbEnums; import engine.net.*; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.Guild; import engine.objects.GuildStatusController; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/WorldDataMsg.java b/src/engine/net/client/msg/WorldDataMsg.java index 025a30fe..bd526df0 100644 --- a/src/engine/net/client/msg/WorldDataMsg.java +++ b/src/engine/net/client/msg/WorldDataMsg.java @@ -10,16 +10,12 @@ package engine.net.client.msg; -import engine.mbEnums; import engine.exception.SerializationException; import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.mbEnums; +import engine.net.*; import engine.objects.Zone; import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/WorldRealmMsg.java b/src/engine/net/client/msg/WorldRealmMsg.java index fde56eb5..3959504b 100644 --- a/src/engine/net/client/msg/WorldRealmMsg.java +++ b/src/engine/net/client/msg/WorldRealmMsg.java @@ -12,7 +12,7 @@ package engine.net.client.msg; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.Realm; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/AbstractChatMsg.java b/src/engine/net/client/msg/chat/AbstractChatMsg.java index 5b69e03a..bdb17057 100644 --- a/src/engine/net/client/msg/chat/AbstractChatMsg.java +++ b/src/engine/net/client/msg/chat/AbstractChatMsg.java @@ -14,7 +14,7 @@ import engine.exception.SerializationException; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/chat/ChatCSRMsg.java b/src/engine/net/client/msg/chat/ChatCSRMsg.java index 1aff5bbd..b9e7a537 100644 --- a/src/engine/net/client/msg/chat/ChatCSRMsg.java +++ b/src/engine/net/client/msg/chat/ChatCSRMsg.java @@ -14,8 +14,8 @@ import engine.gameManager.SessionManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; +import engine.net.Protocol; import engine.net.client.ClientConnection; -import engine.net.client.Protocol; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; import engine.session.Session; diff --git a/src/engine/net/client/msg/chat/ChatCityMsg.java b/src/engine/net/client/msg/chat/ChatCityMsg.java index 20956c9a..68cff1ea 100644 --- a/src/engine/net/client/msg/chat/ChatCityMsg.java +++ b/src/engine/net/client/msg/chat/ChatCityMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractGameObject; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/chat/ChatGlobalMsg.java b/src/engine/net/client/msg/chat/ChatGlobalMsg.java index f7658ddd..b11f26fe 100644 --- a/src/engine/net/client/msg/chat/ChatGlobalMsg.java +++ b/src/engine/net/client/msg/chat/ChatGlobalMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/ChatGroupMsg.java b/src/engine/net/client/msg/chat/ChatGroupMsg.java index 15bbe6a1..90fea319 100644 --- a/src/engine/net/client/msg/chat/ChatGroupMsg.java +++ b/src/engine/net/client/msg/chat/ChatGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatGroupMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatGuildMsg.java b/src/engine/net/client/msg/chat/ChatGuildMsg.java index 8974654e..5bf73048 100644 --- a/src/engine/net/client/msg/chat/ChatGuildMsg.java +++ b/src/engine/net/client/msg/chat/ChatGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatGuildMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatICMsg.java b/src/engine/net/client/msg/chat/ChatICMsg.java index b2d3dfe4..8b73f1cc 100644 --- a/src/engine/net/client/msg/chat/ChatICMsg.java +++ b/src/engine/net/client/msg/chat/ChatICMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatICMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatInfoMsg.java b/src/engine/net/client/msg/chat/ChatInfoMsg.java index 5645e8d0..f5cd1df9 100644 --- a/src/engine/net/client/msg/chat/ChatInfoMsg.java +++ b/src/engine/net/client/msg/chat/ChatInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatInfoMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatLeaderMsg.java b/src/engine/net/client/msg/chat/ChatLeaderMsg.java index 7f83f1ed..0c59c615 100644 --- a/src/engine/net/client/msg/chat/ChatLeaderMsg.java +++ b/src/engine/net/client/msg/chat/ChatLeaderMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatLeaderMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatPvPMsg.java b/src/engine/net/client/msg/chat/ChatPvPMsg.java index a84610af..5f7eaf59 100644 --- a/src/engine/net/client/msg/chat/ChatPvPMsg.java +++ b/src/engine/net/client/msg/chat/ChatPvPMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatPvPMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatSayMsg.java b/src/engine/net/client/msg/chat/ChatSayMsg.java index 03826d7c..08f915f9 100644 --- a/src/engine/net/client/msg/chat/ChatSayMsg.java +++ b/src/engine/net/client/msg/chat/ChatSayMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractGameObject; import engine.objects.AbstractWorldObject; diff --git a/src/engine/net/client/msg/chat/ChatShoutMsg.java b/src/engine/net/client/msg/chat/ChatShoutMsg.java index 761f13dd..c5169445 100644 --- a/src/engine/net/client/msg/chat/ChatShoutMsg.java +++ b/src/engine/net/client/msg/chat/ChatShoutMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java b/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java index 30e1f1a9..a3581b39 100644 --- a/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java +++ b/src/engine/net/client/msg/chat/ChatSystemChannelMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; public class ChatSystemChannelMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/chat/ChatSystemMsg.java b/src/engine/net/client/msg/chat/ChatSystemMsg.java index 29b412fa..785c38e1 100644 --- a/src/engine/net/client/msg/chat/ChatSystemMsg.java +++ b/src/engine/net/client/msg/chat/ChatSystemMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractWorldObject; import engine.server.MBServerStatics; diff --git a/src/engine/net/client/msg/chat/ChatTellMsg.java b/src/engine/net/client/msg/chat/ChatTellMsg.java index fe60e679..3170b47a 100644 --- a/src/engine/net/client/msg/chat/ChatTellMsg.java +++ b/src/engine/net/client/msg/chat/ChatTellMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.chat; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.AbstractCharacter; import engine.objects.AbstractWorldObject; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java b/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java index 6b6b5918..52867810 100644 --- a/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java +++ b/src/engine/net/client/msg/chat/GuildEnterWorldMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.objects.PlayerCharacter; public class GuildEnterWorldMsg extends AbstractChatMsg { diff --git a/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java b/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java index a24be476..f6635c93 100644 --- a/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java +++ b/src/engine/net/client/msg/commands/ClientAdminCommandMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.AbstractGameObject; diff --git a/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java b/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java index d3d4013b..f04d2180 100644 --- a/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java +++ b/src/engine/net/client/msg/group/AppointGroupLeaderMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class AppointGroupLeaderMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/DisbandGroupMsg.java b/src/engine/net/client/msg/group/DisbandGroupMsg.java index b23ae529..0f0ac390 100644 --- a/src/engine/net/client/msg/group/DisbandGroupMsg.java +++ b/src/engine/net/client/msg/group/DisbandGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DisbandGroupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/FormationFollowMsg.java b/src/engine/net/client/msg/group/FormationFollowMsg.java index afd2acc4..f98abb7c 100644 --- a/src/engine/net/client/msg/group/FormationFollowMsg.java +++ b/src/engine/net/client/msg/group/FormationFollowMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class FormationFollowMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/GroupInviteMsg.java b/src/engine/net/client/msg/group/GroupInviteMsg.java index f6afdf00..5748a440 100644 --- a/src/engine/net/client/msg/group/GroupInviteMsg.java +++ b/src/engine/net/client/msg/group/GroupInviteMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GroupInviteMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/GroupInviteResponseMsg.java b/src/engine/net/client/msg/group/GroupInviteResponseMsg.java index c9e26bf9..bb5b92d8 100644 --- a/src/engine/net/client/msg/group/GroupInviteResponseMsg.java +++ b/src/engine/net/client/msg/group/GroupInviteResponseMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GroupInviteResponseMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/GroupUpdateMsg.java b/src/engine/net/client/msg/group/GroupUpdateMsg.java index f09f063c..bd57f065 100644 --- a/src/engine/net/client/msg/group/GroupUpdateMsg.java +++ b/src/engine/net/client/msg/group/GroupUpdateMsg.java @@ -9,12 +9,12 @@ package engine.net.client.msg.group; -import engine.mbEnums.GameObjectType; import engine.gameManager.GroupManager; +import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.Group; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/group/LeaveGroupMsg.java b/src/engine/net/client/msg/group/LeaveGroupMsg.java index f477de3b..8cbcb3b7 100644 --- a/src/engine/net/client/msg/group/LeaveGroupMsg.java +++ b/src/engine/net/client/msg/group/LeaveGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class LeaveGroupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/RemoveFromGroupMsg.java b/src/engine/net/client/msg/group/RemoveFromGroupMsg.java index 7ff6586a..da78c30a 100644 --- a/src/engine/net/client/msg/group/RemoveFromGroupMsg.java +++ b/src/engine/net/client/msg/group/RemoveFromGroupMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class RemoveFromGroupMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java b/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java index 1becdabb..2a27444c 100644 --- a/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java +++ b/src/engine/net/client/msg/group/ToggleGroupSplitMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.group; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ToggleGroupSplitMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java b/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java index d8ef71d0..7fb2969d 100644 --- a/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java +++ b/src/engine/net/client/msg/guild/AcceptInviteToGuildMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class AcceptInviteToGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java b/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java index 42f99620..d83a4158 100644 --- a/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java +++ b/src/engine/net/client/msg/guild/AcceptSubInviteMsg.java @@ -22,7 +22,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class AcceptSubInviteMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/BanishUnbanishMsg.java b/src/engine/net/client/msg/guild/BanishUnbanishMsg.java index d06af36c..f0413e5d 100644 --- a/src/engine/net/client/msg/guild/BanishUnbanishMsg.java +++ b/src/engine/net/client/msg/guild/BanishUnbanishMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class BanishUnbanishMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/BreakFealtyMsg.java b/src/engine/net/client/msg/guild/BreakFealtyMsg.java index 7a003f63..77da9596 100644 --- a/src/engine/net/client/msg/guild/BreakFealtyMsg.java +++ b/src/engine/net/client/msg/guild/BreakFealtyMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class BreakFealtyMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/ChangeRankMsg.java b/src/engine/net/client/msg/guild/ChangeRankMsg.java index f3a9c46d..0803a00c 100644 --- a/src/engine/net/client/msg/guild/ChangeRankMsg.java +++ b/src/engine/net/client/msg/guild/ChangeRankMsg.java @@ -22,7 +22,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ChangeRankMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/DisbandGuildMsg.java b/src/engine/net/client/msg/guild/DisbandGuildMsg.java index f9f7cfd3..2b7f34f5 100644 --- a/src/engine/net/client/msg/guild/DisbandGuildMsg.java +++ b/src/engine/net/client/msg/guild/DisbandGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DisbandGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/DismissGuildMsg.java b/src/engine/net/client/msg/guild/DismissGuildMsg.java index 5d67a966..30dec40b 100644 --- a/src/engine/net/client/msg/guild/DismissGuildMsg.java +++ b/src/engine/net/client/msg/guild/DismissGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DismissGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/GuildControlMsg.java b/src/engine/net/client/msg/guild/GuildControlMsg.java index 8d938a1d..d744134c 100644 --- a/src/engine/net/client/msg/guild/GuildControlMsg.java +++ b/src/engine/net/client/msg/guild/GuildControlMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GuildControlMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java b/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java index 3a259238..28b43e6d 100644 --- a/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java +++ b/src/engine/net/client/msg/guild/GuildCreationCloseMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import org.pmw.tinylog.Logger; diff --git a/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java b/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java index acfe60a9..9ba812e9 100644 --- a/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java +++ b/src/engine/net/client/msg/guild/GuildCreationFinalizeMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; import engine.objects.Item; diff --git a/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java b/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java index c22979b0..0a4fb9b4 100644 --- a/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java +++ b/src/engine/net/client/msg/guild/GuildCreationOptionsMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/GuildInfoMsg.java b/src/engine/net/client/msg/guild/GuildInfoMsg.java index 938c2732..fc692299 100644 --- a/src/engine/net/client/msg/guild/GuildInfoMsg.java +++ b/src/engine/net/client/msg/guild/GuildInfoMsg.java @@ -14,7 +14,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.*; import org.joda.time.DateTime; diff --git a/src/engine/net/client/msg/guild/GuildListMsg.java b/src/engine/net/client/msg/guild/GuildListMsg.java index 1a225cb5..821745a7 100644 --- a/src/engine/net/client/msg/guild/GuildListMsg.java +++ b/src/engine/net/client/msg/guild/GuildListMsg.java @@ -15,7 +15,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.Guild; import engine.objects.GuildHistory; diff --git a/src/engine/net/client/msg/guild/GuildUnknownMsg.java b/src/engine/net/client/msg/guild/GuildUnknownMsg.java index 87ff4020..940b53b9 100644 --- a/src/engine/net/client/msg/guild/GuildUnknownMsg.java +++ b/src/engine/net/client/msg/guild/GuildUnknownMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GuildUnknownMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/InviteToGuildMsg.java b/src/engine/net/client/msg/guild/InviteToGuildMsg.java index 48d9369f..192288ee 100644 --- a/src/engine/net/client/msg/guild/InviteToGuildMsg.java +++ b/src/engine/net/client/msg/guild/InviteToGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/InviteToSubMsg.java b/src/engine/net/client/msg/guild/InviteToSubMsg.java index d9c325e7..abe743cd 100644 --- a/src/engine/net/client/msg/guild/InviteToSubMsg.java +++ b/src/engine/net/client/msg/guild/InviteToSubMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/LeaveGuildMsg.java b/src/engine/net/client/msg/guild/LeaveGuildMsg.java index f8a56216..cfd69d3d 100644 --- a/src/engine/net/client/msg/guild/LeaveGuildMsg.java +++ b/src/engine/net/client/msg/guild/LeaveGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class LeaveGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/MOTDCommitMsg.java b/src/engine/net/client/msg/guild/MOTDCommitMsg.java index 6f821824..39736fc1 100644 --- a/src/engine/net/client/msg/guild/MOTDCommitMsg.java +++ b/src/engine/net/client/msg/guild/MOTDCommitMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class MOTDCommitMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/MOTDMsg.java b/src/engine/net/client/msg/guild/MOTDMsg.java index 16060ae5..441b4a33 100644 --- a/src/engine/net/client/msg/guild/MOTDMsg.java +++ b/src/engine/net/client/msg/guild/MOTDMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class MOTDMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/ReqGuildListMsg.java b/src/engine/net/client/msg/guild/ReqGuildListMsg.java index 8dbe382a..00b652a1 100644 --- a/src/engine/net/client/msg/guild/ReqGuildListMsg.java +++ b/src/engine/net/client/msg/guild/ReqGuildListMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ReqGuildListMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/SendGuildEntryMsg.java b/src/engine/net/client/msg/guild/SendGuildEntryMsg.java index 6398c14c..3cca297b 100644 --- a/src/engine/net/client/msg/guild/SendGuildEntryMsg.java +++ b/src/engine/net/client/msg/guild/SendGuildEntryMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.objects.Guild; import engine.objects.GuildTag; diff --git a/src/engine/net/client/msg/guild/SwearInGuildMsg.java b/src/engine/net/client/msg/guild/SwearInGuildMsg.java index a9051f59..d32c0e4e 100644 --- a/src/engine/net/client/msg/guild/SwearInGuildMsg.java +++ b/src/engine/net/client/msg/guild/SwearInGuildMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class SwearInGuildMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/guild/SwearInMsg.java b/src/engine/net/client/msg/guild/SwearInMsg.java index aa9c239e..8ae6e113 100644 --- a/src/engine/net/client/msg/guild/SwearInMsg.java +++ b/src/engine/net/client/msg/guild/SwearInMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.guild; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class SwearInMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/CharSelectScreenMsg.java b/src/engine/net/client/msg/login/CharSelectScreenMsg.java index 34fd3f32..fec17ef2 100644 --- a/src/engine/net/client/msg/login/CharSelectScreenMsg.java +++ b/src/engine/net/client/msg/login/CharSelectScreenMsg.java @@ -11,11 +11,7 @@ package engine.net.client.msg.login; import engine.exception.SerializationException; -import engine.net.AbstractConnection; -import engine.net.AbstractNetMsg; -import engine.net.ByteBufferReader; -import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.*; import engine.net.client.msg.ClientNetMsg; import engine.objects.Account; import engine.objects.PlayerCharacter; diff --git a/src/engine/net/client/msg/login/ClientLoginInfoMsg.java b/src/engine/net/client/msg/login/ClientLoginInfoMsg.java index 419360f5..0b2e0c3a 100644 --- a/src/engine/net/client/msg/login/ClientLoginInfoMsg.java +++ b/src/engine/net/client/msg/login/ClientLoginInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ClientLoginInfoMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/CommitNewCharacterMsg.java b/src/engine/net/client/msg/login/CommitNewCharacterMsg.java index 673656cf..2e17797a 100644 --- a/src/engine/net/client/msg/login/CommitNewCharacterMsg.java +++ b/src/engine/net/client/msg/login/CommitNewCharacterMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class CommitNewCharacterMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/DeleteCharacterMsg.java b/src/engine/net/client/msg/login/DeleteCharacterMsg.java index 0763c989..71a6be29 100644 --- a/src/engine/net/client/msg/login/DeleteCharacterMsg.java +++ b/src/engine/net/client/msg/login/DeleteCharacterMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class DeleteCharacterMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/GameServerIPRequestMsg.java b/src/engine/net/client/msg/login/GameServerIPRequestMsg.java index 19798412..678d9ee7 100644 --- a/src/engine/net/client/msg/login/GameServerIPRequestMsg.java +++ b/src/engine/net/client/msg/login/GameServerIPRequestMsg.java @@ -13,7 +13,7 @@ import engine.mbEnums.GameObjectType; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GameServerIPRequestMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/GameServerIPResponseMsg.java b/src/engine/net/client/msg/login/GameServerIPResponseMsg.java index fe258fc9..7f07359c 100644 --- a/src/engine/net/client/msg/login/GameServerIPResponseMsg.java +++ b/src/engine/net/client/msg/login/GameServerIPResponseMsg.java @@ -14,7 +14,7 @@ import engine.gameManager.ConfigManager; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class GameServerIPResponseMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/InvalidNameMsg.java b/src/engine/net/client/msg/login/InvalidNameMsg.java index 0547abea..d3acc843 100644 --- a/src/engine/net/client/msg/login/InvalidNameMsg.java +++ b/src/engine/net/client/msg/login/InvalidNameMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; import engine.server.world.WorldServer; diff --git a/src/engine/net/client/msg/login/LoginErrorMsg.java b/src/engine/net/client/msg/login/LoginErrorMsg.java index d5247d96..c1cf76fa 100644 --- a/src/engine/net/client/msg/login/LoginErrorMsg.java +++ b/src/engine/net/client/msg/login/LoginErrorMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class LoginErrorMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/ServerStatusMsg.java b/src/engine/net/client/msg/login/ServerStatusMsg.java index 32d96198..6ff31558 100644 --- a/src/engine/net/client/msg/login/ServerStatusMsg.java +++ b/src/engine/net/client/msg/login/ServerStatusMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class ServerStatusMsg extends ClientNetMsg { diff --git a/src/engine/net/client/msg/login/VersionInfoMsg.java b/src/engine/net/client/msg/login/VersionInfoMsg.java index 81852009..5718cec9 100644 --- a/src/engine/net/client/msg/login/VersionInfoMsg.java +++ b/src/engine/net/client/msg/login/VersionInfoMsg.java @@ -13,7 +13,7 @@ package engine.net.client.msg.login; import engine.net.AbstractConnection; import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; -import engine.net.client.Protocol; +import engine.net.Protocol; import engine.net.client.msg.ClientNetMsg; public class VersionInfoMsg extends ClientNetMsg { diff --git a/src/engine/server/login/LoginServer.java b/src/engine/server/login/LoginServer.java index 1c951e81..341221b7 100644 --- a/src/engine/server/login/LoginServer.java +++ b/src/engine/server/login/LoginServer.java @@ -17,9 +17,9 @@ import engine.mbEnums; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.Network; +import engine.net.Protocol; import engine.net.client.ClientConnection; import engine.net.client.ClientConnectionManager; -import engine.net.client.Protocol; import engine.net.client.msg.login.*; import engine.objects.*; import engine.server.MBServerStatics; diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 25a63082..446e9122 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -28,9 +28,9 @@ import engine.mobileAI.Threads.Respawner; import engine.net.DispatchMessage; import engine.net.ItemProductionManager; import engine.net.Network; +import engine.net.Protocol; import engine.net.client.ClientConnection; import engine.net.client.ClientConnectionManager; -import engine.net.client.Protocol; import engine.net.client.msg.UpdateStateMsg; import engine.net.client.msg.chat.ChatSystemMsg; import engine.objects.*; From f10141eddbc7f387fef03a4c380a1ee79299aabb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 15:45:45 -0400 Subject: [PATCH 007/378] Variable removed from city --- .../net/client/handlers/DestroyBuildingHandler.java | 7 ++++--- .../net/client/handlers/PlaceAssetMsgHandler.java | 2 -- .../net/client/handlers/ViewResourcesMsgHandler.java | 12 +++++++----- src/engine/objects/City.java | 9 --------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/engine/net/client/handlers/DestroyBuildingHandler.java b/src/engine/net/client/handlers/DestroyBuildingHandler.java index ddebbd07..a4a6141c 100644 --- a/src/engine/net/client/handlers/DestroyBuildingHandler.java +++ b/src/engine/net/client/handlers/DestroyBuildingHandler.java @@ -1,10 +1,10 @@ package engine.net.client.handlers; -import engine.mbEnums; -import engine.mbEnums.BuildingGroup; import engine.InterestManagement.WorldGrid; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; +import engine.mbEnums; +import engine.mbEnums.BuildingGroup; import engine.net.client.ClientConnection; import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.DestroyBuildingMsg; @@ -91,8 +91,9 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler { building.disableSpire(true); if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) { + if (city != null) - city.setWarehouseBuildingID(0); + city.warehouse = null; } BuildingManager.setRank(building, -1); diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index d6b0ad59..582a8e74 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -1358,8 +1358,6 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { if (city == null) return true; - city.setWarehouseBuildingID(newMesh.getObjectUUID()); - return true; } } \ No newline at end of file diff --git a/src/engine/net/client/handlers/ViewResourcesMsgHandler.java b/src/engine/net/client/handlers/ViewResourcesMsgHandler.java index 731e47e2..61bbe598 100644 --- a/src/engine/net/client/handlers/ViewResourcesMsgHandler.java +++ b/src/engine/net/client/handlers/ViewResourcesMsgHandler.java @@ -8,9 +8,8 @@ package engine.net.client.handlers; -import engine.mbEnums.DispatchChannel; import engine.exception.MsgSendException; -import engine.gameManager.BuildingManager; +import engine.mbEnums.DispatchChannel; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -46,13 +45,16 @@ public class ViewResourcesMsgHandler extends AbstractClientMsgHandler { if (city == null) return true; - Building warehouse = BuildingManager.getBuilding(city.getWarehouseBuildingID()); + if (city.warehouse == null) + return true; + + Building warehouseBuilding = city.warehouse.building; - if (warehouse == null) + if (warehouseBuilding == null) return true; ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter); - vrm.setWarehouseBuilding(warehouse); + vrm.setWarehouseBuilding(warehouseBuilding); vrm.setGuild(playerCharacter.getGuild()); vrm.configure(); diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index 92feb734..74cb81dd 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -78,7 +78,6 @@ public class City extends AbstractWorldObject { 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 String hash; public Warehouse warehouse; @@ -1060,14 +1059,6 @@ public class City extends AbstractWorldObject { } } - public int getWarehouseBuildingID() { - return warehouseBuildingID; - } - - public void setWarehouseBuildingID(int warehouseBuildingID) { - this.warehouseBuildingID = warehouseBuildingID; - } - public final void destroy() { Thread destroyCityThread = new Thread(new DestroyCityThread(this)); From 679c7afe0e91b7be2d31b1f322881e9ecf7a7d0d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 16:05:52 -0400 Subject: [PATCH 008/378] field is templateID not item uuid. --- .../handlers/ItemProductionMsgHandler.java | 12 ++--- .../net/client/msg/ItemProductionMsg.java | 48 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 8a1ecd31..2b5ded3f 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -463,14 +463,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); if (emptySlots > 0) { for (int i = 0; i < emptySlots; i++) { - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getItemUUID()); + vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); } } } else - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getItemUUID()); + vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); break; case ACTION_JUNK: - junkItem(msg.getItemUUID(), vendorNPC, origin); + junkItem(msg.getTemplateID(), vendorNPC, origin); break; case ACTION_RECYCLE: recycleItem(msg.getItemIDtoTypeMap(), vendorNPC, origin); @@ -480,7 +480,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { break; case ACTION_COMPLETE: - vendorNPC.completeItem(msg.getItemUUID()); + vendorNPC.completeItem(msg.getTemplateID()); // ManageNPCMsg outMsg = new ManageNPCMsg(vendorNPC); // outMsg.setMessageType(1); @@ -491,10 +491,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { break; case ACTION_DEPOSIT: - depositItem(msg.getItemUUID(), vendorNPC, origin); + depositItem(msg.getTemplateID(), vendorNPC, origin); break; case ACTION_SETPRICE: - setItemPrice(msg.getItemType(), msg.getItemUUID(), msg.getItemPrice(), vendorNPC, origin); + setItemPrice(msg.getItemType(), msg.getTemplateID(), msg.getItemPrice(), vendorNPC, origin); break; case ACTION_TAKE: takeItem(msg.getItemIDtoTypeMap(), vendorNPC, origin); diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 6d4df1ed..f461e741 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -38,7 +38,7 @@ public class ItemProductionMsg extends ClientNetMsg { private int size; private int buildingUUID; private int unknown01; - private int itemUUID; + private int templateID; private int itemType; private int totalProduction; private int unknown03; @@ -61,7 +61,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.size = 0; this.buildingUUID = 0; this.unknown01 = 0; - this.itemUUID = 0; + this.templateID = 0; this.totalProduction = 0; this.unknown03 = 0; this.pToken = 0; @@ -81,7 +81,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.buildingUUID = building.getObjectUUID(); this.npcUUID = vendor.getObjectUUID(); this.itemType = item.getObjectType().ordinal(); - this.itemUUID = item.getObjectUUID(); + this.templateID = item.getObjectUUID(); this.unknown01 = 0; this.totalProduction = 0; this.unknown03 = 0; @@ -139,7 +139,7 @@ public class ItemProductionMsg extends ClientNetMsg { if (!add) { writer.put((byte) 1); - Item item = Item.getFromCache(this.itemUUID); + Item item = Item.getFromCache(this.templateID); if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); @@ -154,9 +154,9 @@ public class ItemProductionMsg extends ClientNetMsg { writer.put((byte) 1); Item item; if (this.itemType == GameObjectType.Item.ordinal()) - item = Item.getFromCache(this.itemUUID); + item = Item.getFromCache(this.templateID); else - item = MobLoot.getFromCache(this.itemUUID); + item = MobLoot.getFromCache(this.templateID); if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); @@ -166,7 +166,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_CONFIRM_TAKE: writer.putInt(this.itemType); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -178,7 +178,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_SETPRICE: writer.putInt(this.itemType); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -191,7 +191,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_CONFIRM_SETPRICE: writer.putInt(this.itemType); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -205,7 +205,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_DEPOSIT: writer.putInt(this.itemType); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -246,7 +246,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.putInt(1); - MobLoot toRoll = MobLoot.getFromCache(this.itemUUID); + MobLoot toRoll = MobLoot.getFromCache(this.templateID); writer.putInt(-1497023830); if (toRoll != null && toRoll.getPrefix() != null && !toRoll.getPrefix().isEmpty()) { EffectsBase eb = PowersManager.getEffectByIDString(toRoll.getPrefix()); @@ -273,7 +273,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putString(toRoll.name); writer.putInt(GameObjectType.MobLoot.ordinal()); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(0); //items left to produce? if (toRoll != null) { @@ -322,7 +322,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_COMPLETE: writer.putInt(this.itemType); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(this.totalProduction); writer.putInt(this.unknown03); writer.putInt(this.pToken); @@ -334,7 +334,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_JUNK: writer.putInt(this.itemType); - writer.putInt(this.itemUUID); + writer.putInt(this.templateID); writer.putInt(this.totalProduction); writer.putInt(this.unknown03); writer.putInt(this.pToken); @@ -372,7 +372,7 @@ public class ItemProductionMsg extends ClientNetMsg { switch (this.actionType) { case ACTION_SETPRICE: this.itemType = reader.getInt(); - this.itemUUID = reader.getInt(); + this.templateID = reader.getInt(); reader.getInt(); reader.getInt(); reader.getInt(); @@ -397,15 +397,15 @@ public class ItemProductionMsg extends ClientNetMsg { HashMap tempIDs = new HashMap<>(); for (int i = 0; i < this.size; i++) { int type = reader.getInt(); // Item type padding - this.itemUUID = reader.getInt(); - tempIDs.put(this.itemUUID, type); + this.templateID = reader.getInt(); + tempIDs.put(this.templateID, type); } reader.getInt(); this.itemIDtoTypeMap = tempIDs; break; case ACTION_DEPOSIT: this.itemType = reader.getInt(); - this.itemUUID = reader.getInt(); + this.templateID = reader.getInt(); reader.getInt(); reader.getInt(); reader.getInt(); @@ -417,7 +417,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case ACTION_JUNK: this.itemType = reader.getInt(); - this.itemUUID = reader.getInt(); + this.templateID = reader.getInt(); this.totalProduction = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); @@ -429,7 +429,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; default: this.itemType = reader.getInt(); - this.itemUUID = reader.getInt(); + this.templateID = reader.getInt(); this.totalProduction = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); @@ -475,12 +475,12 @@ public class ItemProductionMsg extends ClientNetMsg { this.unknown03 = unknown03; } - public int getItemUUID() { - return itemUUID; + public int getTemplateID() { + return templateID; } - public void setItemUUID(int itemUUID) { - this.itemUUID = itemUUID; + public void setTemplateID(int templateID) { + this.templateID = templateID; } public int getpToken() { From 16d17798be6f76235ddbd93e07b7c835f3ed16e1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 16:06:55 -0400 Subject: [PATCH 009/378] Mirror field in client --- .../handlers/ItemProductionMsgHandler.java | 4 ++-- .../net/client/msg/ItemProductionMsg.java | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 2b5ded3f..e47d7596 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -463,11 +463,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); if (emptySlots > 0) { for (int i = 0; i < emptySlots; i++) { - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); + vendorNPC.produceItem(player.getObjectUUID(), msg.getTotal_to_produce(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); } } } else - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); + vendorNPC.produceItem(player.getObjectUUID(), msg.getTotal_to_produce(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); break; case ACTION_JUNK: junkItem(msg.getTemplateID(), vendorNPC, origin); diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index f461e741..c5ae5df3 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -40,7 +40,7 @@ public class ItemProductionMsg extends ClientNetMsg { private int unknown01; private int templateID; private int itemType; - private int totalProduction; + private int total_to_produce; private int unknown03; private int pToken; private int sToken; @@ -62,7 +62,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.buildingUUID = 0; this.unknown01 = 0; this.templateID = 0; - this.totalProduction = 0; + this.total_to_produce = 0; this.unknown03 = 0; this.pToken = 0; this.sToken = 0; @@ -83,7 +83,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.itemType = item.getObjectType().ordinal(); this.templateID = item.getObjectUUID(); this.unknown01 = 0; - this.totalProduction = 0; + this.total_to_produce = 0; this.unknown03 = 0; this.pToken = 0; this.sToken = 0; @@ -323,7 +323,7 @@ public class ItemProductionMsg extends ClientNetMsg { case ACTION_COMPLETE: writer.putInt(this.itemType); writer.putInt(this.templateID); - writer.putInt(this.totalProduction); + writer.putInt(this.total_to_produce); writer.putInt(this.unknown03); writer.putInt(this.pToken); writer.putInt(this.sToken); @@ -335,7 +335,7 @@ public class ItemProductionMsg extends ClientNetMsg { case ACTION_JUNK: writer.putInt(this.itemType); writer.putInt(this.templateID); - writer.putInt(this.totalProduction); + writer.putInt(this.total_to_produce); writer.putInt(this.unknown03); writer.putInt(this.pToken); writer.putInt(this.sToken); @@ -418,7 +418,7 @@ public class ItemProductionMsg extends ClientNetMsg { case ACTION_JUNK: this.itemType = reader.getInt(); this.templateID = reader.getInt(); - this.totalProduction = reader.getInt(); + this.total_to_produce = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); this.sToken = reader.getInt(); @@ -430,7 +430,7 @@ public class ItemProductionMsg extends ClientNetMsg { default: this.itemType = reader.getInt(); this.templateID = reader.getInt(); - this.totalProduction = reader.getInt(); + this.total_to_produce = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); this.sToken = reader.getInt(); @@ -459,12 +459,12 @@ public class ItemProductionMsg extends ClientNetMsg { this.unknown01 = unknown01; } - public int getTotalProduction() { - return totalProduction; + public int getTotal_to_produce() { + return total_to_produce; } - public void setTotalProduction(int unknown02) { - this.totalProduction = unknown02; + public void setTotal_to_produce(int unknown02) { + this.total_to_produce = unknown02; } public int getUnknown03() { From 9bbe9b399ee463d57e4f1c96d67f36d26176b440 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 6 Apr 2024 16:08:06 -0400 Subject: [PATCH 010/378] Better name for map --- .../handlers/ItemProductionMsgHandler.java | 4 ++-- src/engine/net/client/msg/ItemProductionMsg.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index e47d7596..c5a32c33 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -473,7 +473,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { junkItem(msg.getTemplateID(), vendorNPC, origin); break; case ACTION_RECYCLE: - recycleItem(msg.getItemIDtoTypeMap(), vendorNPC, origin); + recycleItem(msg.getItems(), vendorNPC, origin); msg.setActionType(7); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -497,7 +497,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { setItemPrice(msg.getItemType(), msg.getTemplateID(), msg.getItemPrice(), vendorNPC, origin); break; case ACTION_TAKE: - takeItem(msg.getItemIDtoTypeMap(), vendorNPC, origin); + takeItem(msg.getItems(), vendorNPC, origin); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index c5ae5df3..ea684a7a 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -49,7 +49,7 @@ public class ItemProductionMsg extends ClientNetMsg { private int npcUUID; private boolean add; private int itemPrice; - private HashMap itemIDtoTypeMap; + private HashMap items; /** * This is the general purpose constructor. @@ -228,11 +228,11 @@ public class ItemProductionMsg extends ClientNetMsg { writer.put((byte) 1); writer.putInt(building.getStrongboxValue()); - if (this.itemIDtoTypeMap != null) { - writer.putInt(this.itemIDtoTypeMap.size()); + if (this.items != null) { + writer.putInt(this.items.size()); - for (int itemID : this.itemIDtoTypeMap.keySet()) { - writer.putInt(this.itemIDtoTypeMap.get(itemID)); + for (int itemID : this.items.keySet()) { + writer.putInt(this.items.get(itemID)); writer.putInt(itemID); } @@ -401,7 +401,7 @@ public class ItemProductionMsg extends ClientNetMsg { tempIDs.put(this.templateID, type); } reader.getInt(); - this.itemIDtoTypeMap = tempIDs; + this.items = tempIDs; break; case ACTION_DEPOSIT: this.itemType = reader.getInt(); @@ -527,8 +527,8 @@ public class ItemProductionMsg extends ClientNetMsg { return npcUUID; } - public HashMap getItemIDtoTypeMap() { - return itemIDtoTypeMap; + public HashMap getItems() { + return items; } /** From 30800478f20b981a42ad03726cc717e9f54d1122 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 12:04:15 -0400 Subject: [PATCH 011/378] Message now uses enum --- src/engine/mbEnums.java | 15 +++++ .../net/client/msg/ItemProductionMsg.java | 59 ++++++++----------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index 251aee27..0196d136 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -3024,5 +3024,20 @@ public class mbEnums { } } + + public enum ProductionActionType { + NONE, + PRODUCE, + JUNK, + RECYCLE, + COMPLETE, + SETPRICE, + DEPOSIT, + TAKE, + CONFIRM_PRODUCE, + CONFIRM_SETPRICE, + CONFIRM_DEPOSIT, + CONFIRM_TAKE; + } } diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index ea684a7a..fafd075c 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -11,6 +11,7 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; import engine.gameManager.PowersManager; +import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.net.*; import engine.objects.Building; @@ -23,18 +24,6 @@ import java.util.HashMap; public class ItemProductionMsg extends ClientNetMsg { - private static final int ACTION_PRODUCE = 1; - private static final int ACTION_JUNK = 2; - private static final int ACTION_RECYCLE = 3; - private static final int ACTION_COMPLETE = 4; - private static final int ACTION_DEPOSIT = 6; - private static final int ACTION_SETPRICE = 5; - private static final int ACTION_TAKE = 7; - private static final int ACTION_CONFIRM_SETPRICE = 9; - private static final int ACTION_CONFIRM_DEPOSIT = 10; - private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client - private static final int ACTION_CONFIRM_PRODUCE = 8; - private int size; private int buildingUUID; private int unknown01; @@ -45,7 +34,7 @@ public class ItemProductionMsg extends ClientNetMsg { private int pToken; private int sToken; private String name; - private int actionType; + private mbEnums.ProductionActionType actionType; private int npcUUID; private boolean add; private int itemPrice; @@ -57,7 +46,7 @@ public class ItemProductionMsg extends ClientNetMsg { public ItemProductionMsg() { super(Protocol.ITEMPRODUCTION); - this.actionType = 0; + this.actionType = mbEnums.ProductionActionType.NONE; this.size = 0; this.buildingUUID = 0; this.unknown01 = 0; @@ -76,7 +65,7 @@ public class ItemProductionMsg extends ClientNetMsg { public ItemProductionMsg(Building building, NPC vendor, Item item, int actionType, boolean add) { super(Protocol.ITEMPRODUCTION); - this.actionType = actionType; + this.actionType = mbEnums.ProductionActionType.values()[actionType]; this.size = 0; this.buildingUUID = building.getObjectUUID(); this.npcUUID = vendor.getObjectUUID(); @@ -123,7 +112,7 @@ public class ItemProductionMsg extends ClientNetMsg { return; // Common Header - writer.putInt(this.actionType); + writer.putInt(this.actionType.ordinal()); writer.putInt(GameObjectType.Building.ordinal()); writer.putInt(this.buildingUUID); writer.putInt(GameObjectType.NPC.ordinal()); @@ -131,7 +120,7 @@ public class ItemProductionMsg extends ClientNetMsg { switch (this.actionType) { - case ACTION_CONFIRM_DEPOSIT: + case CONFIRM_DEPOSIT: writer.putInt(0); // Not item ordinal? writer.putInt(0); // Not item uuid? writer.putInt(1); @@ -164,7 +153,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_CONFIRM_TAKE: + case CONFIRM_TAKE: writer.putInt(this.itemType); writer.putInt(this.templateID); writer.putInt(1); @@ -176,7 +165,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_SETPRICE: + case SETPRICE: writer.putInt(this.itemType); writer.putInt(this.templateID); writer.putInt(1); @@ -189,7 +178,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_CONFIRM_SETPRICE: + case CONFIRM_SETPRICE: writer.putInt(this.itemType); writer.putInt(this.templateID); writer.putInt(1); @@ -203,7 +192,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); //writer.put((byte) 0); break; - case ACTION_DEPOSIT: + case DEPOSIT: writer.putInt(this.itemType); writer.putInt(this.templateID); writer.putInt(1); @@ -215,8 +204,8 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_TAKE: - case ACTION_RECYCLE: + case TAKE: + case RECYCLE: writer.putInt(0); writer.putInt(0); @@ -242,7 +231,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); break; - case ACTION_CONFIRM_PRODUCE: + case CONFIRM_PRODUCE: writer.putInt(0); writer.putInt(0); writer.putInt(1); @@ -320,7 +309,7 @@ public class ItemProductionMsg extends ClientNetMsg { //writer.putInt(0); //error popup break; - case ACTION_COMPLETE: + case COMPLETE: writer.putInt(this.itemType); writer.putInt(this.templateID); writer.putInt(this.total_to_produce); @@ -332,7 +321,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 0); break; - case ACTION_JUNK: + case JUNK: writer.putInt(this.itemType); writer.putInt(this.templateID); writer.putInt(this.total_to_produce); @@ -363,14 +352,14 @@ public class ItemProductionMsg extends ClientNetMsg { // Common header - this.actionType = reader.getInt(); + this.actionType = mbEnums.ProductionActionType.values()[reader.getInt()]; reader.getInt(); // Building type padding this.buildingUUID = reader.getInt(); reader.getInt(); // NPC type padding this.npcUUID = reader.getInt(); switch (this.actionType) { - case ACTION_SETPRICE: + case SETPRICE: this.itemType = reader.getInt(); this.templateID = reader.getInt(); reader.getInt(); @@ -383,8 +372,8 @@ public class ItemProductionMsg extends ClientNetMsg { reader.getInt(); reader.get(); break; - case ACTION_RECYCLE: - case ACTION_TAKE: + case RECYCLE: + case TAKE: reader.getInt(); reader.getInt(); reader.getInt(); @@ -403,7 +392,7 @@ public class ItemProductionMsg extends ClientNetMsg { reader.getInt(); this.items = tempIDs; break; - case ACTION_DEPOSIT: + case DEPOSIT: this.itemType = reader.getInt(); this.templateID = reader.getInt(); reader.getInt(); @@ -415,7 +404,7 @@ public class ItemProductionMsg extends ClientNetMsg { reader.getInt(); reader.get(); break; - case ACTION_JUNK: + case JUNK: this.itemType = reader.getInt(); this.templateID = reader.getInt(); this.total_to_produce = reader.getInt(); @@ -438,7 +427,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.size = reader.getInt(); reader.getInt(); - if (this.actionType == ACTION_COMPLETE || this.actionType == ACTION_JUNK) + if (this.actionType == mbEnums.ProductionActionType.COMPLETE || this.actionType == mbEnums.ProductionActionType.JUNK) reader.get(); else reader.getShort(); @@ -516,11 +505,11 @@ public class ItemProductionMsg extends ClientNetMsg { } public int getActionType() { - return actionType; + return actionType.ordinal(); } public final void setActionType(int actionType) { - this.actionType = actionType; + this.actionType = mbEnums.ProductionActionType.values()[actionType]; } public int getNpcUUID() { From cf38362d84974943f9303bbb72b90c38216fe020 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 12:45:13 -0400 Subject: [PATCH 012/378] Handler uses enumeration --- .../handlers/ItemProductionMsgHandler.java | 55 ++++++------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index c5a32c33..cdce3cb7 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -34,17 +34,6 @@ import java.util.HashMap; */ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { - private static final int ACTION_PRODUCE = 1; - private static final int ACTION_JUNK = 2; - private static final int ACTION_RECYCLE = 3; - private static final int ACTION_COMPLETE = 4; - private static final int ACTION_DEPOSIT = 6; - private static final int ACTION_SETPRICE = 5; - private static final int ACTION_TAKE = 7; - private static final int ACTION_CONFIRM_SETPRICE = 9; // Unsure. Sent by client - private static final int ACTION_CONFIRM_DEPOSIT = 10; // Unsure. Sent by client - private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client - public ItemProductionMsgHandler() { super(ItemProductionMsg.class); } @@ -77,11 +66,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } else if (targetItem.getObjectType() == GameObjectType.MobLoot) { @@ -91,11 +80,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } @@ -158,11 +147,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_CONFIRM_DEPOSIT, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -218,7 +207,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { vendor.removeItemFromForge(targetItem); outMsg = new ManageNPCMsg(vendor); - outMsg.setMessageType(ACTION_PRODUCE); + outMsg.setMessageType(mbEnums.ProductionActionType.PRODUCE.ordinal()); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } finally { @@ -299,7 +288,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // ChatManager.chatSystemInfo(player, "Took " + timetook + " ms to finish"); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_TAKE, true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE.ordinal(), true); dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -452,9 +441,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Process Request - switch (msg.getActionType()) { + mbEnums.ProductionActionType actionType = mbEnums.ProductionActionType.values()[msg.getActionType()]; + + switch (actionType) { - case ACTION_PRODUCE: + case PRODUCE: boolean isRandom = false; if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0) isRandom = true; @@ -469,39 +460,29 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } else vendorNPC.produceItem(player.getObjectUUID(), msg.getTotal_to_produce(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); break; - case ACTION_JUNK: + case JUNK: junkItem(msg.getTemplateID(), vendorNPC, origin); break; - case ACTION_RECYCLE: + case RECYCLE: recycleItem(msg.getItems(), vendorNPC, origin); msg.setActionType(7); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; - case ACTION_COMPLETE: - + case COMPLETE: vendorNPC.completeItem(msg.getTemplateID()); - - // ManageNPCMsg outMsg = new ManageNPCMsg(vendorNPC); - // outMsg.setMessageType(1); - // - // dispatch = Dispatch.borrow(player, outMsg); - // DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); - - break; - case ACTION_DEPOSIT: + case DEPOSIT: depositItem(msg.getTemplateID(), vendorNPC, origin); break; - case ACTION_SETPRICE: + case SETPRICE: setItemPrice(msg.getItemType(), msg.getTemplateID(), msg.getItemPrice(), vendorNPC, origin); break; - case ACTION_TAKE: + case TAKE: takeItem(msg.getItems(), vendorNPC, origin); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; - } return true; } From 8b4eafebf3ede6ed50c66fd918cab59af006d389 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 12:48:56 -0400 Subject: [PATCH 013/378] Elevate access. It's a message... --- .../net/client/msg/ItemProductionMsg.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index fafd075c..f9ac05f2 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -24,21 +24,21 @@ import java.util.HashMap; public class ItemProductionMsg extends ClientNetMsg { - private int size; - private int buildingUUID; - private int unknown01; - private int templateID; - private int itemType; - private int total_to_produce; - private int unknown03; - private int pToken; - private int sToken; - private String name; - private mbEnums.ProductionActionType actionType; - private int npcUUID; - private boolean add; - private int itemPrice; - private HashMap items; + public int size; + public int buildingUUID; + public int unknown01; + public int templateID; + public int itemType; + public int total_to_produce; + public int unknown03; + public int pToken; + public int sToken; + public String name; + public mbEnums.ProductionActionType actionType; + public int npcUUID; + public boolean add; + public int itemPrice; + public HashMap items; /** * This is the general purpose constructor. From 31129493e5eb792f4e040484e8da77dbc2cee1db Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 12:51:58 -0400 Subject: [PATCH 014/378] ActionType Take --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 4 ++-- src/engine/net/client/msg/ItemProductionMsg.java | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index cdce3cb7..85978974 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -441,7 +441,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Process Request - mbEnums.ProductionActionType actionType = mbEnums.ProductionActionType.values()[msg.getActionType()]; + mbEnums.ProductionActionType actionType = mbEnums.ProductionActionType.values()[msg.actionType.ordinal()]; switch (actionType) { @@ -465,7 +465,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { break; case RECYCLE: recycleItem(msg.getItems(), vendorNPC, origin); - msg.setActionType(7); + msg.actionType = mbEnums.ProductionActionType.TAKE; dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index f9ac05f2..2710b80f 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -504,10 +504,6 @@ public class ItemProductionMsg extends ClientNetMsg { this.size = size; } - public int getActionType() { - return actionType.ordinal(); - } - public final void setActionType(int actionType) { this.actionType = mbEnums.ProductionActionType.values()[actionType]; } From fc71b8cb617df9e10195bcc221e9099f0dc12b90 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 12:53:55 -0400 Subject: [PATCH 015/378] Inline setter --- src/engine/net/client/msg/ItemProductionMsg.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 2710b80f..7165b952 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -504,10 +504,6 @@ public class ItemProductionMsg extends ClientNetMsg { this.size = size; } - public final void setActionType(int actionType) { - this.actionType = mbEnums.ProductionActionType.values()[actionType]; - } - public int getNpcUUID() { return npcUUID; } From 21b1dba84da582ae4d6f92159cb7176ad5fcb3f6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 13:01:43 -0400 Subject: [PATCH 016/378] Switch directly on actiontype --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 85978974..f21c44dc 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -441,9 +441,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Process Request - mbEnums.ProductionActionType actionType = mbEnums.ProductionActionType.values()[msg.actionType.ordinal()]; - - switch (actionType) { + switch (msg.actionType) { case PRODUCE: boolean isRandom = false; From b785d352318d030e4938e5422428d012bb3751bb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 13:03:24 -0400 Subject: [PATCH 017/378] Removed unused method --- .../handlers/ItemProductionMsgHandler.java | 59 ------------------- 1 file changed, 59 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index f21c44dc..dddb73d7 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -56,7 +56,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { else targetItem = null; - if (targetItem == null) return; @@ -88,10 +87,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } - - // Set item's price - - } // Method sets the price on an item in the vendor inventory @@ -119,7 +114,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; if (!vendor.charItemManager.hasRoomInventory(targetItem.template.item_wt)) { - ErrorPopupMsg.sendErrorPopup(player, 21); return; } @@ -146,7 +140,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -161,59 +154,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } finally { origin.sellLock.unlock(); } - } - - } - - // Method adds an item from the players inventory to the vendor. - - private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin, ItemProductionMsg msg) { - - Item targetItem; - ManageNPCMsg outMsg; - Dispatch dispatch; - - PlayerCharacter player = origin.getPlayerCharacter(); - - if (player == null) - return; - - if (origin.buyLock.tryLock()) { - try { - targetItem = Item.getFromCache(itemUUID); - - if (targetItem == null) - return; - - - if (!vendor.charItemManager.forgeContains(targetItem, vendor)) - return; - - boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem); - if (!worked) { - Guild guild = vendor.getGuild(); - if (guild == null) - return; - //ChatManager.chatGuildInfo(guild, "Failed to complete Item " + targetItem.getName()); - return; - } - - targetItem.containerType = mbEnums.ItemContainerType.INVENTORY; - targetItem.setOwner(vendor); - vendor.charItemManager.addItemToInventory(targetItem); - - vendor.removeItemFromForge(targetItem); - - outMsg = new ManageNPCMsg(vendor); - outMsg.setMessageType(mbEnums.ProductionActionType.PRODUCE.ordinal()); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - } finally { - origin.buyLock.unlock(); - } - } } // Method completes an item that has been previously rolled @@ -224,7 +166,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { Item targetItem; ItemProductionMsg outMsg; int totalValue = 0; - int currentStrongbox; Dispatch dispatch; if (vendor.getBuilding() == null) From 85a66339e2de8b3b402f3b981290b61981cc52dc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 13:08:00 -0400 Subject: [PATCH 018/378] inline accessors --- .../handlers/ItemProductionMsgHandler.java | 22 ++--- .../net/client/msg/ItemProductionMsg.java | 96 +------------------ 2 files changed, 14 insertions(+), 104 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index dddb73d7..7a0dce43 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -373,7 +373,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Grab reference to vendor we are interacting with - vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.getNpcUUID()); + vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); // Oops? @@ -386,39 +386,39 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { case PRODUCE: boolean isRandom = false; - if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0) + if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) isRandom = true; //Create Multiple Item Function.. Fill all empty slots - if (msg.getSize() > 0) { + if (msg.size > 0) { int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); if (emptySlots > 0) { for (int i = 0; i < emptySlots; i++) { - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotal_to_produce(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); + vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); } } } else - vendorNPC.produceItem(player.getObjectUUID(), msg.getTotal_to_produce(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getTemplateID()); + vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); break; case JUNK: - junkItem(msg.getTemplateID(), vendorNPC, origin); + junkItem(msg.templateID, vendorNPC, origin); break; case RECYCLE: - recycleItem(msg.getItems(), vendorNPC, origin); + recycleItem(msg.items, vendorNPC, origin); msg.actionType = mbEnums.ProductionActionType.TAKE; dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; case COMPLETE: - vendorNPC.completeItem(msg.getTemplateID()); + vendorNPC.completeItem(msg.templateID); break; case DEPOSIT: - depositItem(msg.getTemplateID(), vendorNPC, origin); + depositItem(msg.templateID, vendorNPC, origin); break; case SETPRICE: - setItemPrice(msg.getItemType(), msg.getTemplateID(), msg.getItemPrice(), vendorNPC, origin); + setItemPrice(msg.itemType, msg.templateID, msg.itemPrice, vendorNPC, origin); break; case TAKE: - takeItem(msg.getItems(), vendorNPC, origin); + takeItem(msg.items, vendorNPC, origin); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 7165b952..7dce78ff 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -206,7 +206,6 @@ public class ItemProductionMsg extends ClientNetMsg { break; case TAKE: case RECYCLE: - writer.putInt(0); writer.putInt(0); writer.putInt(1); @@ -237,6 +236,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(1); MobLoot toRoll = MobLoot.getFromCache(this.templateID); writer.putInt(-1497023830); + if (toRoll != null && toRoll.getPrefix() != null && !toRoll.getPrefix().isEmpty()) { EffectsBase eb = PowersManager.getEffectByIDString(toRoll.getPrefix()); if (eb == null) @@ -265,13 +265,8 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(this.templateID); writer.putInt(0); //items left to produce? - if (toRoll != null) { - writer.putInt(toRoll.templateID); - writer.putInt(toRoll.getValue()); - } else { - writer.putInt(0); - writer.putInt(0); - } + writer.putInt(toRoll.templateID); + writer.putInt(toRoll.getValue()); NPC vendor = NPC.getFromCache(this.npcUUID); if (vendor != null) { @@ -341,7 +336,6 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); break; } - } /** @@ -432,91 +426,7 @@ public class ItemProductionMsg extends ClientNetMsg { else reader.getShort(); break; - } } - public int getItemType() { - return itemType; - } - - public int getUnknown01() { - return unknown01; - } - - public void setUnknown01(int unknown01) { - this.unknown01 = unknown01; - } - - public int getTotal_to_produce() { - return total_to_produce; - } - - public void setTotal_to_produce(int unknown02) { - this.total_to_produce = unknown02; - } - - public int getUnknown03() { - return unknown03; - } - - public void setUnknown03(int unknown03) { - this.unknown03 = unknown03; - } - - public int getTemplateID() { - return templateID; - } - - public void setTemplateID(int templateID) { - this.templateID = templateID; - } - - public int getpToken() { - return pToken; - } - - public void setpToken(int pToken) { - this.pToken = pToken; - } - - public int getsToken() { - return sToken; - } - - public void setsToken(int sToken) { - this.sToken = sToken; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - public int getNpcUUID() { - return npcUUID; - } - - public HashMap getItems() { - return items; - } - - /** - * @return the itemPrice - */ - public int getItemPrice() { - return itemPrice; - } - } From 4a3a8d4b65d88b4cc2ab5b160f8d4d343fe7d07b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 13:10:58 -0400 Subject: [PATCH 019/378] Minor class cleanup --- .../handlers/ItemProductionMsgHandler.java | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 7a0dce43..b998f858 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -218,16 +218,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { case REALMCHARTER: case SCROLL: case POTION: - itemValue = 0; continue; } totalValue += itemValue; - long start = System.currentTimeMillis(); vendor.charItemManager.recycle(targetItem); - long end = System.currentTimeMillis(); - long timetook = end - start; - - // ChatManager.chatSystemInfo(player, "Took " + timetook + " ms to finish"); outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE.ordinal(), true); @@ -240,18 +234,12 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (!vendor.getBuilding().transferGold(totalValue, false)) return; - } catch (Exception e) { Logger.error(e); } finally { - origin.sellLock.unlock(); } - } - - // Refresh vendor's inventory to client - } // Method handles recycling of an item @@ -271,12 +259,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (player == null) return; - // Can't junk nothing! + // junk nothing? if (targetItem == null) return; - if (!vendor.charItemManager.forgeContains(targetItem, vendor)) return; @@ -296,7 +283,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { outMsg.setMessageType(1); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - ; } finally { origin.sellLock.unlock(); } @@ -304,34 +290,26 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } - // Method junks an item that has been rolled but not completed - private static void takeItem(HashMap itemList, NPC vendor, ClientConnection origin) { Item targetItem; - - PlayerCharacter player = origin.getPlayerCharacter(); if (player == null) return; - for (int itemUUID : itemList.keySet()) { int type = itemList.get(itemUUID); if (type == GameObjectType.Item.ordinal()) { targetItem = Item.getFromCache(itemUUID); - } else { + } else targetItem = MobLoot.getFromCache(itemUUID); - } - if (targetItem == null) return; - if (targetItem.template.item_type.equals(ItemType.GOLD)) return; if (vendor.charItemManager.inventoryContains(targetItem) == false) @@ -341,7 +319,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; player.charItemManager.buyFromNPC(targetItem, vendor); - } player.charItemManager.updateInventory(); From 97558b51c8b0f71dbcca116b4832c0ebcafd6980 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 13:23:22 -0400 Subject: [PATCH 020/378] Method moved to top of handler. --- .../handlers/ItemProductionMsgHandler.java | 153 +++++++++--------- 1 file changed, 73 insertions(+), 80 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index b998f858..0896acb8 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -38,6 +38,79 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { super(ItemProductionMsg.class); } + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + // Member variable declaration + + PlayerCharacter player; + NPC vendorNPC; + ItemProductionMsg msg; + Dispatch dispatch; + + // Member variable assignment + + msg = (ItemProductionMsg) baseMsg; + player = origin.getPlayerCharacter(); + + if (player == null) + return true; + + // Grab reference to vendor we are interacting with + + vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); + + // Oops? + + if (vendorNPC == null) + return true; + + // Process Request + + switch (msg.actionType) { + + case PRODUCE: + boolean isRandom = false; + if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) + isRandom = true; + //Create Multiple Item Function.. Fill all empty slots + if (msg.size > 0) { + int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); + if (emptySlots > 0) { + for (int i = 0; i < emptySlots; i++) { + vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); + } + } + } else + vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); + break; + case JUNK: + junkItem(msg.templateID, vendorNPC, origin); + break; + case RECYCLE: + recycleItem(msg.items, vendorNPC, origin); + msg.actionType = mbEnums.ProductionActionType.TAKE; + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + break; + case COMPLETE: + vendorNPC.completeItem(msg.templateID); + break; + case DEPOSIT: + depositItem(msg.templateID, vendorNPC, origin); + break; + case SETPRICE: + setItemPrice(msg.itemType, msg.templateID, msg.itemPrice, vendorNPC, origin); + break; + case TAKE: + takeItem(msg.items, vendorNPC, origin); + dispatch = Dispatch.borrow(player, msg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + break; + } + return true; + } + private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { Item targetItem; @@ -323,86 +396,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { player.charItemManager.updateInventory(); - // Update NPC inventory to client - - } - // Method removes item from an NPC's inventory and transferes it to a player - - @Override - protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { - - // Member variable declaration - - PlayerCharacter player; - NPC vendorNPC; - ItemProductionMsg msg; - Dispatch dispatch; - - // Member variable assignment - - msg = (ItemProductionMsg) baseMsg; - player = origin.getPlayerCharacter(); - - if (player == null) - return true; - - // Grab reference to vendor we are interacting with - - vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); - - // Oops? - - if (vendorNPC == null) - return true; - - // Process Request - - switch (msg.actionType) { - - case PRODUCE: - boolean isRandom = false; - if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) - isRandom = true; - //Create Multiple Item Function.. Fill all empty slots - if (msg.size > 0) { - int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); - if (emptySlots > 0) { - for (int i = 0; i < emptySlots; i++) { - vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); - } - } - } else - vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); - break; - case JUNK: - junkItem(msg.templateID, vendorNPC, origin); - break; - case RECYCLE: - recycleItem(msg.items, vendorNPC, origin); - msg.actionType = mbEnums.ProductionActionType.TAKE; - dispatch = Dispatch.borrow(player, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - break; - case COMPLETE: - vendorNPC.completeItem(msg.templateID); - break; - case DEPOSIT: - depositItem(msg.templateID, vendorNPC, origin); - break; - case SETPRICE: - setItemPrice(msg.itemType, msg.templateID, msg.itemPrice, vendorNPC, origin); - break; - case TAKE: - takeItem(msg.items, vendorNPC, origin); - dispatch = Dispatch.borrow(player, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - break; - } - return true; - } - - // Method handles rolling item requests from the client - } From ec5a8f52819510bca5b966bb52e7523cc67f3d4a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 13:25:42 -0400 Subject: [PATCH 021/378] Logic cleanup. --- .../net/client/handlers/ItemProductionMsgHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 0896acb8..587c8f5c 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -71,16 +71,18 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { case PRODUCE: boolean isRandom = false; + if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) isRandom = true; + //Create Multiple Item Function.. Fill all empty slots + if (msg.size > 0) { int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); - if (emptySlots > 0) { - for (int i = 0; i < emptySlots; i++) { + + if (emptySlots > 0) + for (int i = 0; i < emptySlots; i++) vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); - } - } } else vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); break; From d539e419feedce1ed8b8ea95e85e908985311acd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:15:06 -0400 Subject: [PATCH 022/378] Begin adding workOrder logic --- src/engine/gameManager/ForgeManager.java | 9 +++++++-- src/engine/loot/WorkOrder.java | 5 +---- .../net/client/handlers/ItemProductionMsgHandler.java | 5 +++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f973e544..05f05c35 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -18,7 +18,7 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; - private final BlockingQueue workOrders = new DelayQueue(); + private static final BlockingQueue workOrders = new DelayQueue(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); @Override @@ -60,8 +60,13 @@ public enum ForgeManager implements Runnable { } catch (InterruptedException e) { e.printStackTrace(); } - } + } + public static void submit(WorkOrder workOrder) { + workOrder.workOrderID = wordOrderCounter.incrementAndGet(); + workOrder.completionTime = System.currentTimeMillis() + 10000; + workOrders.add(workOrder); } + } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 9d71d792..b8943b86 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,7 +8,6 @@ package engine.loot; -import engine.gameManager.ForgeManager; import engine.objects.NPC; import org.jetbrains.annotations.NotNull; @@ -19,7 +18,7 @@ import static java.lang.Math.toIntExact; public class WorkOrder implements Delayed { - public int workOrder; + public int workOrderID; public NPC vendor; public int slotCount; public int itemCount; @@ -33,8 +32,6 @@ public class WorkOrder implements Delayed { public WorkOrder() { - this.workOrder = ForgeManager.wordOrderCounter.incrementAndGet(); - this.completionTime = System.currentTimeMillis() + 10000; } @Override diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 587c8f5c..8e2731ab 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -13,6 +13,7 @@ package engine.net.client.handlers; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.mbEnums.ItemType; @@ -75,6 +76,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) isRandom = true; + // Create new work order + + WorkOrder workOrder = new WorkOrder(); + //Create Multiple Item Function.. Fill all empty slots if (msg.size > 0) { From 46bf67672a13c81d6b5cefb8241e12b46c354e7d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:18:12 -0400 Subject: [PATCH 023/378] workorder fields assigned --- .../net/client/handlers/ItemProductionMsgHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 8e2731ab..9e5730e0 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -79,6 +79,12 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Create new work order WorkOrder workOrder = new WorkOrder(); + workOrder.itemCount = msg.total_to_produce; + workOrder.vendor = vendorNPC; + workOrder.templateID = msg.templateID; + workOrder.prefixToken = msg.pToken; + workOrder.suffixToken = msg.sToken; + workOrder.itemName = msg.name; //Create Multiple Item Function.. Fill all empty slots From 053c105c26a758ce5eb12f3b1f9e946117c8a7b4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:21:47 -0400 Subject: [PATCH 024/378] Method to validate workorder --- src/engine/gameManager/ForgeManager.java | 6 ++++++ .../net/client/handlers/ItemProductionMsgHandler.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 05f05c35..ba5017f5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -9,6 +9,7 @@ package engine.gameManager; import engine.loot.WorkOrder; +import engine.objects.PlayerCharacter; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; @@ -69,4 +70,9 @@ public enum ForgeManager implements Runnable { workOrders.add(workOrder); } + public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { + + + return true; + } } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 9e5730e0..6dc2750b 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -13,6 +13,7 @@ package engine.net.client.handlers; import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; +import engine.gameManager.ForgeManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; @@ -86,6 +87,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.suffixToken = msg.sToken; workOrder.itemName = msg.name; + // Validate vendor can roll this item + + if (ForgeManager.validate(player, workOrder) == false) + return true; + //Create Multiple Item Function.. Fill all empty slots if (msg.size > 0) { From 781053ab22cab726777d6c2fcc1fd9ba4562c493 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:28:07 -0400 Subject: [PATCH 025/378] Debug string added --- src/engine/gameManager/ForgeManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ba5017f5..f6632c2e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -10,6 +10,7 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.objects.PlayerCharacter; +import org.pmw.tinylog.Logger; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; @@ -42,7 +43,7 @@ public enum ForgeManager implements Runnable { // otherwise roll what was asked for workOrder.itemCount = workOrder.itemCount - 1; - + Logger.info("Workorder popped: " + workOrder.workOrderID); } if (workOrder.itemCount == 0) { From 4462f74f8ce333494b2757a90938f02de5333da6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:31:58 -0400 Subject: [PATCH 026/378] More workorder work. --- src/engine/gameManager/ForgeManager.java | 8 ++++++-- src/engine/loot/WorkOrder.java | 2 +- .../net/client/handlers/ItemProductionMsgHandler.java | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f6632c2e..3ab9d1a1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -42,11 +42,11 @@ public enum ForgeManager implements Runnable { // if Prefix and suffix are null random roll item // otherwise roll what was asked for - workOrder.itemCount = workOrder.itemCount - 1; + workOrder.total_to_produce = workOrder.total_to_produce - 1; Logger.info("Workorder popped: " + workOrder.workOrderID); } - if (workOrder.itemCount == 0) { + if (workOrder.total_to_produce == 0) { workOrder.runCompleted = true; @@ -68,6 +68,10 @@ public enum ForgeManager implements Runnable { public static void submit(WorkOrder workOrder) { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + 10000; + + // 0 signifies single item roll. > 0 signifies multiple item roll. + workOrder.total_to_produce = Math.max(1, workOrder.total_to_produce); + workOrders.add(workOrder); } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index b8943b86..3ba418ad 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -21,7 +21,7 @@ public class WorkOrder implements Delayed { public int workOrderID; public NPC vendor; public int slotCount; - public int itemCount; + public int total_to_produce; public int templateID; public String itemName; public int prefixToken; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 6dc2750b..4b7186ab 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -80,7 +80,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Create new work order WorkOrder workOrder = new WorkOrder(); - workOrder.itemCount = msg.total_to_produce; + workOrder.total_to_produce = msg.total_to_produce; workOrder.vendor = vendorNPC; workOrder.templateID = msg.templateID; workOrder.prefixToken = msg.pToken; From a5df674fbea1a9d4f2045057b9974f693eaebfe4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:34:06 -0400 Subject: [PATCH 027/378] Update to debug strings --- src/engine/gameManager/ForgeManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 3ab9d1a1..d298b4ea 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -43,13 +43,12 @@ public enum ForgeManager implements Runnable { // otherwise roll what was asked for workOrder.total_to_produce = workOrder.total_to_produce - 1; - Logger.info("Workorder popped: " + workOrder.workOrderID); } if (workOrder.total_to_produce == 0) { workOrder.runCompleted = true; - + Logger.info("Workorder has completed: " + workOrder.workOrderID); // Remove this workOrder from any slots on vendor continue; @@ -58,7 +57,7 @@ public enum ForgeManager implements Runnable { // Resubmit workOrder workOrder.completionTime = System.currentTimeMillis() + 10000; - + Logger.info("Workorder has cycled: " + workOrder.workOrderID); } catch (InterruptedException e) { e.printStackTrace(); } From 5e92bab977dff37d6d97be785031ae65dbc8326a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:40:14 -0400 Subject: [PATCH 028/378] submit workorder to forgemanager --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 4b7186ab..836fb0b1 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -92,6 +92,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (ForgeManager.validate(player, workOrder) == false) return true; + // Start rolling the item(s) + + ForgeManager.submit(workOrder); + //Create Multiple Item Function.. Fill all empty slots if (msg.size > 0) { From 92402097d425c0b534c22f6cbed0c3d9fce2c795 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 22:53:41 -0400 Subject: [PATCH 029/378] ForgeManager started at boot --- src/engine/gameManager/ForgeManager.java | 10 ++++++++++ src/engine/server/world/WorldServer.java | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d298b4ea..fa3dc66f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -64,11 +64,21 @@ public enum ForgeManager implements Runnable { } } + public static void start() { + + Thread messageDispatcher; + messageDispatcher = new Thread(FORGE_MANAGER); + + messageDispatcher.setName("Forge Manager"); + messageDispatcher.start(); + } + public static void submit(WorkOrder workOrder) { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + 10000; // 0 signifies single item roll. > 0 signifies multiple item roll. + workOrder.total_to_produce = Math.max(1, workOrder.total_to_produce); workOrders.add(workOrder); diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 446e9122..9895e271 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -455,6 +455,9 @@ public class WorldServer { Logger.info("Starting Mob Respawn Thread"); Respawner.start(); + Logger.info("Starting ForgeManager thread"); + ForgeManager.start(); + // Run maintenance MaintenanceManager.dailyMaintenance(); From 75d520831f95c19e161cb74ed2f4a10aa52eed27 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 23:00:37 -0400 Subject: [PATCH 030/378] More workorder logic work --- src/engine/gameManager/ForgeManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index fa3dc66f..545e4060 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -41,8 +41,6 @@ public enum ForgeManager implements Runnable { // if Prefix and suffix are null random roll item // otherwise roll what was asked for - - workOrder.total_to_produce = workOrder.total_to_produce - 1; } if (workOrder.total_to_produce == 0) { @@ -57,6 +55,9 @@ public enum ForgeManager implements Runnable { // Resubmit workOrder workOrder.completionTime = System.currentTimeMillis() + 10000; + workOrder.total_to_produce = workOrder.total_to_produce - 1; + workOrders.add(workOrder); + Logger.info("Workorder has cycled: " + workOrder.workOrderID); } catch (InterruptedException e) { e.printStackTrace(); From f5f92a1d8888f222572c0e5f3803bd2cfdd2b7d2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 7 Apr 2024 23:21:35 -0400 Subject: [PATCH 031/378] rollingDuration fleshed out --- src/engine/gameManager/ForgeManager.java | 22 +++++++++++++++++-- src/engine/loot/WorkOrder.java | 1 + .../handlers/ItemProductionMsgHandler.java | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 545e4060..0812058a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -54,7 +54,7 @@ public enum ForgeManager implements Runnable { // Resubmit workOrder - workOrder.completionTime = System.currentTimeMillis() + 10000; + workOrder.rollingDuration = System.currentTimeMillis() + 10000; workOrder.total_to_produce = workOrder.total_to_produce - 1; workOrders.add(workOrder); @@ -76,7 +76,7 @@ public enum ForgeManager implements Runnable { public static void submit(WorkOrder workOrder) { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); - workOrder.completionTime = System.currentTimeMillis() + 10000; + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; // 0 signifies single item roll. > 0 signifies multiple item roll. @@ -90,4 +90,22 @@ public enum ForgeManager implements Runnable { return true; } + + public static long calcRollingDuration(WorkOrder workOrder) { + + long rollingDuration; + float rank = workOrder.vendor.getBuilding().getRank() - 1; + float rate = (float) (2.5 * rank); + float baseTime = (20 - rate) * 60000; + + // Bane circles + + if (workOrder.templateID > 910010 && workOrder.templateID < 910019) { + rank = workOrder.templateID - 910010; + baseTime = rank * 60 * 60 * 3 * 1000; + } + + rollingDuration = (long) (baseTime * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); + return rollingDuration; + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 3ba418ad..c3677bf8 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -27,6 +27,7 @@ public class WorkOrder implements Delayed { public int prefixToken; public int suffixToken; public boolean isRandom; + public long rollingDuration; public long completionTime; public boolean runCompleted; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 836fb0b1..2da4d985 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -86,6 +86,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; workOrder.itemName = msg.name; + workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); // Validate vendor can roll this item From abd112035abd0bc28e8b56cd91d8036c8a699db7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 04:17:31 -0400 Subject: [PATCH 032/378] Track items and their workorders. --- src/engine/gameManager/ForgeManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0812058a..d3b32326 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -9,9 +9,11 @@ package engine.gameManager; import engine.loot.WorkOrder; +import engine.objects.Item; import engine.objects.PlayerCharacter; import org.pmw.tinylog.Logger; +import java.util.HashMap; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; import java.util.concurrent.atomic.AtomicInteger; @@ -22,6 +24,7 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue workOrders = new DelayQueue(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); + public static HashMap oven = new HashMap(); @Override public void run() { From 74a7a255be466ad5bebee31a7b8637c33f5fbb3f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 04:32:04 -0400 Subject: [PATCH 033/378] Track items and their workorders. --- src/engine/objects/NPC.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 38dee29c..9e38eff3 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -15,6 +15,7 @@ import engine.gameManager.*; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeNPCJob; +import engine.loot.WorkOrder; import engine.math.Bounds; import engine.math.Vector3f; import engine.math.Vector3fImmutable; @@ -78,6 +79,7 @@ public class NPC extends AbstractCharacter { public int parentZoneUUID; public int equipmentSetID = 0; private int repairCost = 5; + ArrayList workOrders = new ArrayList<>(); // New NPC constructor. Fill in the blanks and then call // PERSIST. From 652476fde88e953e99224b109f29a23ed946fd1d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 04:37:27 -0400 Subject: [PATCH 034/378] Track items and their workorders. --- src/engine/gameManager/ForgeManager.java | 3 +++ src/engine/objects/NPC.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d3b32326..347fe11d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -49,6 +49,8 @@ public enum ForgeManager implements Runnable { if (workOrder.total_to_produce == 0) { workOrder.runCompleted = true; + workOrder.vendor.workOrders.remove(workOrder); + Logger.info("Workorder has completed: " + workOrder.workOrderID); // Remove this workOrder from any slots on vendor @@ -85,6 +87,7 @@ public enum ForgeManager implements Runnable { workOrder.total_to_produce = Math.max(1, workOrder.total_to_produce); + workOrder.vendor.workOrders.add(workOrder); workOrders.add(workOrder); } diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 9e38eff3..95cafce1 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -79,7 +79,7 @@ public class NPC extends AbstractCharacter { public int parentZoneUUID; public int equipmentSetID = 0; private int repairCost = 5; - ArrayList workOrders = new ArrayList<>(); + public ArrayList workOrders = new ArrayList<>(); // New NPC constructor. Fill in the blanks and then call // PERSIST. From 8b38f1a695f1d45aeb5ebdf27d9fcef3c6d0634e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 04:42:44 -0400 Subject: [PATCH 035/378] Track items and their workorders. --- src/engine/loot/WorkOrder.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index c3677bf8..f06a8881 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,9 +8,11 @@ package engine.loot; +import engine.objects.Item; import engine.objects.NPC; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -30,6 +32,7 @@ public class WorkOrder implements Delayed { public long rollingDuration; public long completionTime; public boolean runCompleted; + public ArrayList cooking = new ArrayList<>(); public WorkOrder() { From 0645a93b9c368bd2dc389d9c677bb93a4e340025 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 04:46:54 -0400 Subject: [PATCH 036/378] Track items and their workorders. --- src/engine/loot/WorkOrder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index f06a8881..6905789b 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -28,10 +28,11 @@ public class WorkOrder implements Delayed { public String itemName; public int prefixToken; public int suffixToken; - public boolean isRandom; public long rollingDuration; public long completionTime; public boolean runCompleted; + public boolean runCanceled; + public ArrayList cooking = new ArrayList<>(); public WorkOrder() { From f088d2aa72b398da3edf610ab0c3af18184a092e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 13:06:22 -0400 Subject: [PATCH 037/378] More WorkOrder work --- src/engine/gameManager/ForgeManager.java | 14 ++++++++++++-- src/engine/loot/WorkOrder.java | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 347fe11d..814bba45 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -46,13 +46,13 @@ public enum ForgeManager implements Runnable { // otherwise roll what was asked for } - if (workOrder.total_to_produce == 0) { + if (workOrder.total_produced >= workOrder.total_to_produce) { workOrder.runCompleted = true; workOrder.vendor.workOrders.remove(workOrder); Logger.info("Workorder has completed: " + workOrder.workOrderID); - // Remove this workOrder from any slots on vendor + workOrder.vendor.workOrders.remove(workOrder); continue; } @@ -114,4 +114,14 @@ public enum ForgeManager implements Runnable { rollingDuration = (long) (baseTime * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); return rollingDuration; } + + public static int getAvailableSlots(WorkOrder workOrder) { + + int availableSlots = workOrder.vendor.getRank(); + + for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) { + + } + return availableSlots; + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 6905789b..49fbb2d1 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -24,14 +24,15 @@ public class WorkOrder implements Delayed { public NPC vendor; public int slotCount; public int total_to_produce; + public int total_produced; public int templateID; public String itemName; public int prefixToken; public int suffixToken; public long rollingDuration; public long completionTime; - public boolean runCompleted; - public boolean runCanceled; + public boolean runCompleted = false; + public boolean runCanceled = false; public ArrayList cooking = new ArrayList<>(); From 178bb3718a6d74fe0facf1f9a6c30099faf3a5d4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 13:10:23 -0400 Subject: [PATCH 038/378] Slot count calculated --- src/engine/gameManager/ForgeManager.java | 4 ++-- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 814bba45..c0193c68 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -119,9 +119,9 @@ public enum ForgeManager implements Runnable { int availableSlots = workOrder.vendor.getRank(); - for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) { + for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) + availableSlots = availableSlots - npcWorkOrder.slotCount; - } return availableSlots; } } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 2da4d985..c8a62ece 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -87,6 +87,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.suffixToken = msg.sToken; workOrder.itemName = msg.name; workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); + workOrder.slotCount = ForgeManager.getAvailableSlots(workOrder); // Validate vendor can roll this item From e01dc9b09c6feec6059a5bfffdf57966a475a798 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 13:15:40 -0400 Subject: [PATCH 039/378] More fleshing out of workorder usage --- src/engine/gameManager/ForgeManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c0193c68..d30e0a99 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -83,9 +83,10 @@ public enum ForgeManager implements Runnable { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - // 0 signifies single item roll. > 0 signifies multiple item roll. + // Single item rolls are total_to_produce of 0; - workOrder.total_to_produce = Math.max(1, workOrder.total_to_produce); + if (workOrder.slotCount > 1 && workOrder.total_to_produce == 0) + workOrder.slotCount = 1; workOrder.vendor.workOrders.add(workOrder); workOrders.add(workOrder); From 7c4f7f391ba861726a500ea070dd27bd30470a2d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 15:54:25 -0400 Subject: [PATCH 040/378] Method to calculate warehosue overflow. --- src/engine/objects/Warehouse.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 0f30940d..2b0576ad 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -640,4 +640,16 @@ public class Warehouse { return warehouse.locked.contains(resourceType); } + public static HashMap calcOverflow(Warehouse warehouse, HashMap cost_map) { + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : cost_map.keySet()) { + int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); + if (debit < 0) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } } \ No newline at end of file From 98c0712dea4ac9bd14809a5fdba33358f2f3e571 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 15:55:57 -0400 Subject: [PATCH 041/378] Method to calculate warehosue overflow. --- src/engine/objects/Warehouse.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 2b0576ad..bbb1900f 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -642,10 +642,14 @@ public class Warehouse { public static HashMap calcOverflow(Warehouse warehouse, HashMap cost_map) { + // Method returns a map of resourceType that a transaction overdrafts. + HashMap overflowMap = new HashMap<>(); for (mbEnums.ResourceType resourceType : cost_map.keySet()) { + int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); + if (debit < 0) overflowMap.put(resourceType, debit); } From c2f70c0f269d8b9151ee1dfab339b6cc49147446 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 15:58:48 -0400 Subject: [PATCH 042/378] Unused method removed --- src/engine/objects/Warehouse.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index bbb1900f..02ea37a1 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -616,13 +616,8 @@ public class Warehouse { return true; } - public static void loadAllTransactions(Warehouse warehouse) { - warehouse.transactions = DbManager.WarehouseQueries.GET_TRANSACTIONS_FOR_WAREHOUSE(warehouse.building.getObjectUUID()); - } - public static void AddTransactionToWarehouse(Warehouse warehouse, mbEnums.GameObjectType targetType, int targetUUID, mbEnums.TransactionType transactionType, mbEnums.ResourceType resource, int amount) { - if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now())) return; From a160fe1b00b564ef6bd1df1cef1a9f99f433612c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 15:58:48 -0400 Subject: [PATCH 043/378] Time recycle update --- src/engine/gameManager/ForgeManager.java | 7 +++---- src/engine/objects/Warehouse.java | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d30e0a99..755d3a19 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -48,18 +48,17 @@ public enum ForgeManager implements Runnable { if (workOrder.total_produced >= workOrder.total_to_produce) { + Logger.info("Workorder has completed: " + workOrder.workOrderID); + workOrder.runCompleted = true; workOrder.vendor.workOrders.remove(workOrder); - - Logger.info("Workorder has completed: " + workOrder.workOrderID); workOrder.vendor.workOrders.remove(workOrder); - continue; } // Resubmit workOrder - workOrder.rollingDuration = System.currentTimeMillis() + 10000; + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.total_to_produce = workOrder.total_to_produce - 1; workOrders.add(workOrder); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index bbb1900f..02ea37a1 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -616,13 +616,8 @@ public class Warehouse { return true; } - public static void loadAllTransactions(Warehouse warehouse) { - warehouse.transactions = DbManager.WarehouseQueries.GET_TRANSACTIONS_FOR_WAREHOUSE(warehouse.building.getObjectUUID()); - } - public static void AddTransactionToWarehouse(Warehouse warehouse, mbEnums.GameObjectType targetType, int targetUUID, mbEnums.TransactionType transactionType, mbEnums.ResourceType resource, int amount) { - if (!DbManager.WarehouseQueries.CREATE_TRANSACTION(warehouse.building.getObjectUUID(), targetType, targetUUID, transactionType, resource, amount, DateTime.now())) return; From 129bd4aaa6a3b8a2304e3071e65aef7b511731b1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:26:29 -0400 Subject: [PATCH 044/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 755d3a19..d61c36d2 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -71,11 +71,11 @@ public enum ForgeManager implements Runnable { public static void start() { - Thread messageDispatcher; - messageDispatcher = new Thread(FORGE_MANAGER); + Thread forgeManager; + forgeManager = new Thread(FORGE_MANAGER); - messageDispatcher.setName("Forge Manager"); - messageDispatcher.start(); + forgeManager.setName("Forge Manager"); + forgeManager.start(); } public static void submit(WorkOrder workOrder) { @@ -92,8 +92,7 @@ public enum ForgeManager implements Runnable { } public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { - - + return true; } From 533ed8732196b6fb5f9a2b84012c302dd7544ad8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:26:56 -0400 Subject: [PATCH 045/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d61c36d2..feaa38a7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -52,7 +52,6 @@ public enum ForgeManager implements Runnable { workOrder.runCompleted = true; workOrder.vendor.workOrders.remove(workOrder); - workOrder.vendor.workOrders.remove(workOrder); continue; } @@ -92,7 +91,7 @@ public enum ForgeManager implements Runnable { } public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { - + return true; } From bfa43823f683309a323dd2ce2298a5056682beaa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:42:44 -0400 Subject: [PATCH 046/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 4 +++- src/engine/loot/WorkOrder.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index feaa38a7..c9e1bbbf 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -58,7 +58,7 @@ public enum ForgeManager implements Runnable { // Resubmit workOrder workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - workOrder.total_to_produce = workOrder.total_to_produce - 1; + workOrder.total_produced = workOrder.total_produced - 1; workOrders.add(workOrder); Logger.info("Workorder has cycled: " + workOrder.workOrderID); @@ -86,6 +86,8 @@ public enum ForgeManager implements Runnable { if (workOrder.slotCount > 1 && workOrder.total_to_produce == 0) workOrder.slotCount = 1; + Logger.info(workOrder.toString()); + workOrder.vendor.workOrders.add(workOrder); workOrders.add(workOrder); } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 49fbb2d1..e4c51dfd 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -52,4 +52,23 @@ public class WorkOrder implements Delayed { public int compareTo(@NotNull Delayed o) { return toIntExact(this.completionTime - ((WorkOrder) o).completionTime); } + + public String toString() { + String outSTring = "wordOrderID" + this.workOrderID + "\r\n" + + "vendor" + this.vendor.getObjectUUID() + "\r\n" + + "slotCount" + this.slotCount + "\r\n" + + "total_to_produce" + this.total_to_produce + "\r\n" + + "total_produced" + this.total_produced + "\r\n" + + "templateID" + this.templateID + "\r\n" + + "itemName" + this.itemName + "\r\n" + + "prefixToken" + this.prefixToken + "\r\n" + + "suffixToken" + this.suffixToken + "\r\n" + + "rollingDuration" + this.rollingDuration + "\r\n" + + "completionTime" + this.completionTime + "\r\n" + + "runCompleted" + this.runCompleted + "\r\n" + + "runCanceled" + this.runCanceled + "\r\n"; + + return outSTring; + } + } From cafe0a0fe1aba57524dab406121397be7c4923d1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:49:19 -0400 Subject: [PATCH 047/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 4 ++-- src/engine/loot/WorkOrder.java | 26 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c9e1bbbf..023ff100 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -61,7 +61,7 @@ public enum ForgeManager implements Runnable { workOrder.total_produced = workOrder.total_produced - 1; workOrders.add(workOrder); - Logger.info("Workorder has cycled: " + workOrder.workOrderID); + Logger.info("workorder:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); } catch (InterruptedException e) { e.printStackTrace(); } @@ -83,7 +83,7 @@ public enum ForgeManager implements Runnable { // Single item rolls are total_to_produce of 0; - if (workOrder.slotCount > 1 && workOrder.total_to_produce == 0) + if (workOrder.slotCount > 0 && workOrder.total_to_produce == 0) workOrder.slotCount = 1; Logger.info(workOrder.toString()); diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index e4c51dfd..9071c5ab 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -54,19 +54,19 @@ public class WorkOrder implements Delayed { } public String toString() { - String outSTring = "wordOrderID" + this.workOrderID + "\r\n" + - "vendor" + this.vendor.getObjectUUID() + "\r\n" + - "slotCount" + this.slotCount + "\r\n" + - "total_to_produce" + this.total_to_produce + "\r\n" + - "total_produced" + this.total_produced + "\r\n" + - "templateID" + this.templateID + "\r\n" + - "itemName" + this.itemName + "\r\n" + - "prefixToken" + this.prefixToken + "\r\n" + - "suffixToken" + this.suffixToken + "\r\n" + - "rollingDuration" + this.rollingDuration + "\r\n" + - "completionTime" + this.completionTime + "\r\n" + - "runCompleted" + this.runCompleted + "\r\n" + - "runCanceled" + this.runCanceled + "\r\n"; + String outSTring = "wordOrderID: " + this.workOrderID + "\r\n" + + "vendor: " + this.vendor.getObjectUUID() + "\r\n" + + "slotCount: " + this.slotCount + "\r\n" + + "total_to_produce: " + this.total_to_produce + "\r\n" + + "total_produced: " + this.total_produced + "\r\n" + + "templateID: " + this.templateID + "\r\n" + + "itemName: " + this.itemName + "\r\n" + + "prefixToken: " + this.prefixToken + "\r\n" + + "suffixToken: " + this.suffixToken + "\r\n" + + "rollingDuration: " + this.rollingDuration + "\r\n" + + "completionTime: " + this.completionTime + "\r\n" + + "runCompleted: " + this.runCompleted + "\r\n" + + "runCanceled: " + this.runCanceled + "\r\n"; return outSTring; } From afa1b8478a4c704dd603b353f0d041392be6e35c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:53:53 -0400 Subject: [PATCH 048/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 023ff100..46e33c42 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -58,7 +58,7 @@ public enum ForgeManager implements Runnable { // Resubmit workOrder workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - workOrder.total_produced = workOrder.total_produced - 1; + workOrder.total_produced = workOrder.total_produced + 1; workOrders.add(workOrder); Logger.info("workorder:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); From 5650c0f05a16f0b4acd455c43e0d719cf7b5e642 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:54:33 -0400 Subject: [PATCH 049/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 46e33c42..32b9bbef 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -61,7 +61,7 @@ public enum ForgeManager implements Runnable { workOrder.total_produced = workOrder.total_produced + 1; workOrders.add(workOrder); - Logger.info("workorder:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + Logger.info("workOrder cycled:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); } catch (InterruptedException e) { e.printStackTrace(); } From b84de95865f30f3c73daf55b961adf2b1c0bb613 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 16:58:07 -0400 Subject: [PATCH 050/378] Minor class cleanup --- src/engine/loot/WorkOrder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 9071c5ab..3fe3508b 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -54,7 +54,7 @@ public class WorkOrder implements Delayed { } public String toString() { - String outSTring = "wordOrderID: " + this.workOrderID + "\r\n" + + String outSTring = "\r\nwordOrderID: " + this.workOrderID + "\r\n" + "vendor: " + this.vendor.getObjectUUID() + "\r\n" + "slotCount: " + this.slotCount + "\r\n" + "total_to_produce: " + this.total_to_produce + "\r\n" + From deb5b36309e354318e26b822cb3c50b2cc702399 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:02:20 -0400 Subject: [PATCH 051/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 32b9bbef..ca677b6d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -46,6 +46,8 @@ public enum ForgeManager implements Runnable { // otherwise roll what was asked for } + workOrder.total_produced = workOrder.total_produced + 1; + if (workOrder.total_produced >= workOrder.total_to_produce) { Logger.info("Workorder has completed: " + workOrder.workOrderID); @@ -58,7 +60,6 @@ public enum ForgeManager implements Runnable { // Resubmit workOrder workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - workOrder.total_produced = workOrder.total_produced + 1; workOrders.add(workOrder); Logger.info("workOrder cycled:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); From 27a37eba7968410b08b947eda223798cb623f2d8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:06:42 -0400 Subject: [PATCH 052/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ca677b6d..7726feb5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -47,6 +47,7 @@ public enum ForgeManager implements Runnable { } workOrder.total_produced = workOrder.total_produced + 1; + Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); if (workOrder.total_produced >= workOrder.total_to_produce) { @@ -62,7 +63,6 @@ public enum ForgeManager implements Runnable { workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrders.add(workOrder); - Logger.info("workOrder cycled:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); } catch (InterruptedException e) { e.printStackTrace(); } From 35fab889490ea053ebfec1069a66d30817927d3a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:15:56 -0400 Subject: [PATCH 053/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 7726feb5..9cd6b8d4 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -35,6 +35,12 @@ public enum ForgeManager implements Runnable { WorkOrder workOrder = workOrders.take(); + // Completed or canceled work orders are not re-enqueued + + if (workOrder.runCanceled || workOrder.runCompleted) + continue; + ; + // Fulfill workOrder for (int i = 0; i < workOrder.slotCount; ++i) { From d3e0146d8697ae15081f38c683f584c696745441 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:16:05 -0400 Subject: [PATCH 054/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9cd6b8d4..1682e9d5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -39,7 +39,6 @@ public enum ForgeManager implements Runnable { if (workOrder.runCanceled || workOrder.runCompleted) continue; - ; // Fulfill workOrder From 69416528b3ae1362cf798d01789bb2852265d82f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:40:38 -0400 Subject: [PATCH 055/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 1682e9d5..313eb0d7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -121,7 +121,7 @@ public enum ForgeManager implements Runnable { return rollingDuration; } - public static int getAvailableSlots(WorkOrder workOrder) { + public static int calcAvailableSlots(WorkOrder workOrder) { int availableSlots = workOrder.vendor.getRank(); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index c8a62ece..f07ecb0b 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -87,7 +87,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.suffixToken = msg.sToken; workOrder.itemName = msg.name; workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); - workOrder.slotCount = ForgeManager.getAvailableSlots(workOrder); + workOrder.slotCount = ForgeManager.calcAvailableSlots(workOrder); // Validate vendor can roll this item From 275644ec83d9d534c16e08470d8b4d067e1c37cf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:42:47 -0400 Subject: [PATCH 056/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 2 ++ src/engine/net/client/handlers/ItemProductionMsgHandler.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 313eb0d7..ea4bd637 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -84,8 +84,10 @@ public enum ForgeManager implements Runnable { } public static void submit(WorkOrder workOrder) { + workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; + workOrder.slotCount = calcAvailableSlots(workOrder); // Single item rolls are total_to_produce of 0; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index f07ecb0b..308a4209 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -87,7 +87,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.suffixToken = msg.sToken; workOrder.itemName = msg.name; workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); - workOrder.slotCount = ForgeManager.calcAvailableSlots(workOrder); + workOrder.slotCount = 0; // Validate vendor can roll this item From 1d0ab95b889f0c769dac22a611e0b95614caa582 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:52:35 -0400 Subject: [PATCH 057/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ea4bd637..778d9a1e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -102,6 +102,8 @@ public enum ForgeManager implements Runnable { public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { + // use Warehouse.caclulateOverdraft(workorder) method + return true; } From ba4648f8122972609154f2d166c4759dcd92dd90 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 8 Apr 2024 17:56:51 -0400 Subject: [PATCH 058/378] Minor class cleanup --- src/engine/gameManager/ForgeManager.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 778d9a1e..4053c126 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable { if (workOrder.runCanceled || workOrder.runCompleted) continue; - // Fulfill workOrder + // Create negative ID items to add to collections for (int i = 0; i < workOrder.slotCount; ++i) { @@ -94,8 +94,18 @@ public enum ForgeManager implements Runnable { if (workOrder.slotCount > 0 && workOrder.total_to_produce == 0) workOrder.slotCount = 1; - Logger.info(workOrder.toString()); + // Create negative ID items to add to collections + + for (int i = 0; i < workOrder.slotCount; ++i) { + + // Create workOrder items; one for each slot + // assigned to this workOrder. + // if Prefix and suffix are null random roll item + // otherwise roll what was asked for + } + + Logger.info(workOrder.toString()); workOrder.vendor.workOrders.add(workOrder); workOrders.add(workOrder); } From 1bff06cde00de842518c2b07ccd868b1ef643d15 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 8 Apr 2024 20:20:16 -0500 Subject: [PATCH 059/378] using building bounds and hitBox for mele range --- src/engine/gameManager/CombatManager.java | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index c621180d..56dc7890 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -12,6 +12,7 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.AttackJob; import engine.jobs.DeferredPowerJob; +import engine.math.Bounds; import engine.mbEnums; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -23,6 +24,8 @@ import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; @@ -109,7 +112,29 @@ public enum CombatManager { float distanceSquared = attacker.loc.distanceSquared(target.loc); - if (distanceSquared > attackRange * attackRange) + boolean inRange = false; + + float attackerHitbox = attacker.calcHitBox(); + switch(target.getObjectType()){ + case PlayerCharacter: + case Mob: + float targetHitbox = ((AbstractCharacter)target).calcHitBox(); + if(distanceSquared < ((attackRange + attackerHitbox + targetHitbox) * 2)) + inRange = true; + break; + case Building: + float locX = target.loc.x - target.getBounds().getHalfExtents().x; + float locZ = target.loc.z - target.getBounds().getHalfExtents().y; + float sizeX = (target.getBounds().getHalfExtents().x + attackRange + attackerHitbox) * 2; + float sizeZ = (target.getBounds().getHalfExtents().y + attackRange + attackerHitbox) * 2; + Rectangle2D.Float rect = new Rectangle2D.Float(locX,locZ,sizeX,sizeZ); + if(rect.contains(new Point2D.Float(attacker.loc.x,attacker.loc.z))) + inRange = true; + break; + } + + + if (!inRange) return; // take stamina away from attacker From 4a001179b568c0fff04d2ff017cf2c3dc82f286d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 8 Apr 2024 20:37:27 -0500 Subject: [PATCH 060/378] add hitbox to abs vs abs range checks --- src/engine/gameManager/CombatManager.java | 302 +++++++++++----------- 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 56dc7890..f5b2b75d 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -86,9 +86,9 @@ public enum CombatManager { // heck if character can even attack yet - if (attacker.getTimestamps().containsKey("Attack" + slot.name())) - if (System.currentTimeMillis() < attacker.getTimestamps().get("Attack" + slot.name())) - return; + //if (attacker.getTimestamps().containsKey("Attack" + slot.name())) + // if (System.currentTimeMillis() < attacker.getTimestamps().get("Attack" + slot.name())) + // return; // check if character is in range to attack target @@ -114,19 +114,19 @@ public enum CombatManager { boolean inRange = false; - float attackerHitbox = attacker.calcHitBox(); + attackRange += attacker.calcHitBox(); switch(target.getObjectType()){ case PlayerCharacter: case Mob: - float targetHitbox = ((AbstractCharacter)target).calcHitBox(); - if(distanceSquared < ((attackRange + attackerHitbox + targetHitbox) * 2)) + attackRange += ((AbstractCharacter)target).calcHitBox(); + if(distanceSquared < attackRange * 2) inRange = true; break; case Building: float locX = target.loc.x - target.getBounds().getHalfExtents().x; float locZ = target.loc.z - target.getBounds().getHalfExtents().y; - float sizeX = (target.getBounds().getHalfExtents().x + attackRange + attackerHitbox) * 2; - float sizeZ = (target.getBounds().getHalfExtents().y + attackRange + attackerHitbox) * 2; + float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; + float sizeZ = (target.getBounds().getHalfExtents().y + attackRange) * 2; Rectangle2D.Float rect = new Rectangle2D.Float(locX,locZ,sizeX,sizeZ); if(rect.contains(new Point2D.Float(attacker.loc.x,attacker.loc.z))) inRange = true; @@ -134,213 +134,213 @@ public enum CombatManager { } - if (!inRange) - return; + if (inRange) { - // take stamina away from attacker + // take stamina away from attacker - if (weapon != null) { - float stam = weapon.template.item_wt / 3f; - stam = (stam < 1) ? 1 : stam; - attacker.modifyStamina(-(stam), attacker, true); - } else - attacker.modifyStamina(-0.5f, attacker, true); + if (weapon != null) { + float stam = weapon.template.item_wt / 3f; + stam = (stam < 1) ? 1 : stam; + attacker.modifyStamina(-(stam), attacker, true); + } else + attacker.modifyStamina(-0.5f, attacker, true); - //cancel things that are cancelled by an attack + //cancel things that are cancelled by an attack - attacker.cancelOnAttackSwing(); + attacker.cancelOnAttackSwing(); - //declare relevant variables + //declare relevant variables - int min = attacker.minDamageHandOne; - int max = attacker.maxDamageHandOne; - int atr = attacker.atrHandOne; + int min = attacker.minDamageHandOne; + int max = attacker.maxDamageHandOne; + int atr = attacker.atrHandOne; - //get the proper stats based on which slot is attacking + //get the proper stats based on which slot is attacking - if (slot == mbEnums.EquipSlotType.LHELD) { - min = attacker.minDamageHandTwo; - max = attacker.maxDamageHandTwo; - atr = attacker.atrHandTwo; - } + if (slot == mbEnums.EquipSlotType.LHELD) { + min = attacker.minDamageHandTwo; + max = attacker.maxDamageHandTwo; + atr = attacker.atrHandTwo; + } - int def = 0; + int def = 0; - if (AbstractCharacter.IsAbstractCharacter(target)) - def = ((AbstractCharacter) target).defenseRating; + if (AbstractCharacter.IsAbstractCharacter(target)) + def = ((AbstractCharacter) target).defenseRating; - //calculate hit chance based off ATR and DEF + //calculate hit chance based off ATR and DEF - int hitChance; - if (def == 0) - def = 1; - float dif = atr / def; + int hitChance; + if (def == 0) + def = 1; + float dif = atr / def; - if (dif <= 0.8f) - hitChance = 4; - else - hitChance = ((int) (450 * (dif - 0.8f)) + 4); + if (dif <= 0.8f) + hitChance = 4; + else + hitChance = ((int) (450 * (dif - 0.8f)) + 4); - if (target.getObjectType() == mbEnums.GameObjectType.Building) - hitChance = 100; + if (target.getObjectType() == mbEnums.GameObjectType.Building) + hitChance = 100; - int passiveAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); - if (attacker.charItemManager.getEquipped().get(slot) != null) { - passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true); - } + int passiveAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + if (attacker.charItemManager.getEquipped().get(slot) != null) { + passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true); + } - if (ThreadLocalRandom.current().nextInt(100) > hitChance) { - TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim); + if (ThreadLocalRandom.current().nextInt(100) > hitChance) { + TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim); - if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) - DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - else - DispatchMessage.sendToAllInRange(attacker, msg); + if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) + DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); + else + DispatchMessage.sendToAllInRange(attacker, msg); - return; - } + return; + } - //calculate passive chances only if target is AbstractCharacter + //calculate passive chances only if target is AbstractCharacter - if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) { - mbEnums.PassiveType passiveType = mbEnums.PassiveType.None; - int hitRoll = ThreadLocalRandom.current().nextInt(100); + if (EnumSet.of(mbEnums.GameObjectType.PlayerCharacter, mbEnums.GameObjectType.NPC, mbEnums.GameObjectType.Mob).contains(target.getObjectType())) { + mbEnums.PassiveType passiveType = mbEnums.PassiveType.None; + int hitRoll = ThreadLocalRandom.current().nextInt(100); - float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true); - float blockChance = ((AbstractCharacter) target).getPassiveChance("Block", attacker.getLevel(), true); - float parryChance = ((AbstractCharacter) target).getPassiveChance("Parry", attacker.getLevel(), true); + float dodgeChance = ((AbstractCharacter) target).getPassiveChance("Dodge", attacker.getLevel(), true); + float blockChance = ((AbstractCharacter) target).getPassiveChance("Block", attacker.getLevel(), true); + float parryChance = ((AbstractCharacter) target).getPassiveChance("Parry", attacker.getLevel(), true); - // Passive chance clamped at 75 + // Passive chance clamped at 75 - dodgeChance = Math.max(0, Math.min(75, dodgeChance)); - blockChance = Math.max(0, Math.min(75, blockChance)); - parryChance = Math.max(0, Math.min(75, parryChance)); + dodgeChance = Math.max(0, Math.min(75, dodgeChance)); + blockChance = Math.max(0, Math.min(75, blockChance)); + parryChance = Math.max(0, Math.min(75, parryChance)); - if (hitRoll < dodgeChance) - passiveType = mbEnums.PassiveType.Dodge; - else if (hitRoll < blockChance) - passiveType = mbEnums.PassiveType.Block; - else if (hitRoll < parryChance) - passiveType = mbEnums.PassiveType.Parry; + if (hitRoll < dodgeChance) + passiveType = mbEnums.PassiveType.Dodge; + else if (hitRoll < blockChance) + passiveType = mbEnums.PassiveType.Block; + else if (hitRoll < parryChance) + passiveType = mbEnums.PassiveType.Parry; - if (passiveType.equals(mbEnums.PassiveType.None) == false) { - TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value); + if (passiveType.equals(mbEnums.PassiveType.None) == false) { + TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value); - if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) - DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - else - DispatchMessage.sendToAllInRange(attacker, msg); + if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) + DispatchMessage.dispatchMsgToInterestArea(target, msg, mbEnums.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); + else + DispatchMessage.sendToAllInRange(attacker, msg); - return; + return; + } } - } - //calculate the base damage - int damage = ThreadLocalRandom.current().nextInt(min, max + 1); - if (damage == 0) - return; + //calculate the base damage + int damage = ThreadLocalRandom.current().nextInt(min, max + 1); + if (damage == 0) + return; - //get the damage type + //get the damage type - mbEnums.DamageType damageType; + mbEnums.DamageType damageType; - if (attacker.charItemManager.getEquipped().get(slot) == null) { - damageType = mbEnums.DamageType.CRUSHING; - if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) - if (((Mob) attacker).isSiege()) - damageType = mbEnums.DamageType.SIEGE; - } else { - damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0]; - } + if (attacker.charItemManager.getEquipped().get(slot) == null) { + damageType = mbEnums.DamageType.CRUSHING; + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + if (((Mob) attacker).isSiege()) + damageType = mbEnums.DamageType.SIEGE; + } else { + damageType = (mbEnums.DamageType) attacker.charItemManager.getEquipped().get(slot).template.item_weapon_damage.keySet().toArray()[0]; + } - //get resists + //get resists - Resists resists; + Resists resists; - if (AbstractCharacter.IsAbstractCharacter(target) == false) - resists = ((Building) target).getResists(); //this is a building - else - resists = ((AbstractCharacter) target).getResists(); //this is a character + if (AbstractCharacter.IsAbstractCharacter(target) == false) + resists = ((Building) target).getResists(); //this is a building + else + resists = ((AbstractCharacter) target).getResists(); //this is a character - if (AbstractCharacter.IsAbstractCharacter(target)) { - AbstractCharacter absTarget = (AbstractCharacter) target; + if (AbstractCharacter.IsAbstractCharacter(target)) { + AbstractCharacter absTarget = (AbstractCharacter) target; - //check damage shields + //check damage shields - PlayerBonuses bonuses = absTarget.getBonuses(); + PlayerBonuses bonuses = absTarget.getBonuses(); - if (bonuses != null) { + if (bonuses != null) { - ConcurrentHashMap damageShields = bonuses.getDamageShields(); - float total = 0; + ConcurrentHashMap damageShields = bonuses.getDamageShields(); + float total = 0; - for (DamageShield ds : damageShields.values()) { + for (DamageShield ds : damageShields.values()) { - //get amount to damage back + //get amount to damage back - float amount; + float amount; - if (ds.usePercent()) - amount = damage * ds.getAmount() / 100; - else - amount = ds.getAmount(); + if (ds.usePercent()) + amount = damage * ds.getAmount() / 100; + else + amount = ds.getAmount(); - //get resisted damage for damagetype + //get resisted damage for damagetype - if (resists != null) - amount = resists.getResistedDamage(absTarget, attacker, ds.getDamageType(), amount, 0); - total += amount; - } + if (resists != null) + amount = resists.getResistedDamage(absTarget, attacker, ds.getDamageType(), amount, 0); + total += amount; + } - if (total > 0) { - //apply Damage back - attacker.modifyHealth(-total, absTarget, true); - TargetedActionMsg cmm = new TargetedActionMsg(attacker, attacker, total, 0); - DispatchMessage.sendToAllInRange(target, cmm); + if (total > 0) { + //apply Damage back + attacker.modifyHealth(-total, absTarget, true); + TargetedActionMsg cmm = new TargetedActionMsg(attacker, attacker, total, 0); + DispatchMessage.sendToAllInRange(target, cmm); + } } - } - if (resists != null) { + if (resists != null) { - //check for damage type immunities + //check for damage type immunities - if (resists.immuneTo(damageType)) - return; + if (resists.immuneTo(damageType)) + return; - //calculate resisted damage including fortitude + //calculate resisted damage including fortitude - damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0); + damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0); + } } - } - //remove damage from target health + //remove damage from target health - if (damage > 0) { + if (damage > 0) { - if (AbstractCharacter.IsAbstractCharacter(target)) - ((AbstractCharacter) target).modifyHealth(-damage, attacker, true); - else - ((Building) target).setCurrentHitPoints(target.getCurrentHitpoints() - damage); + if (AbstractCharacter.IsAbstractCharacter(target)) + ((AbstractCharacter) target).modifyHealth(-damage, attacker, true); + else + ((Building) target).setCurrentHitPoints(target.getCurrentHitpoints() - damage); - int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); - if (attacker.charItemManager.getEquipped().get(slot) != null) { - attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + if (attacker.charItemManager.getEquipped().get(slot) != null) { + attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + } + TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); + DispatchMessage.sendToAllInRange(target, cmm); } - TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); - DispatchMessage.sendToAllInRange(target, cmm); - } - DeferredPowerJob dpj = null; + DeferredPowerJob dpj = null; - if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { - dpj = ((PlayerCharacter) attacker).getWeaponPower(); + dpj = ((PlayerCharacter) attacker).getWeaponPower(); - if (dpj != null) { - dpj.attack(target, attackRange); + if (dpj != null) { + dpj.attack(target, attackRange); - if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) - ((PlayerCharacter) attacker).setWeaponPower(dpj); + if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) + ((PlayerCharacter) attacker).setWeaponPower(dpj); + } } } //calculate next allowed attack and update the timestamp From dc81ddaba78ec7a3ee9ab087b1236cd7ded5fe44 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 9 Apr 2024 21:23:29 -0500 Subject: [PATCH 061/378] handle retaliate when being attacked --- src/engine/gameManager/CombatManager.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index f5b2b75d..9f9566b2 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -136,6 +136,13 @@ public enum CombatManager { if (inRange) { + //handle retaliate + if(AbstractCharacter.IsAbstractCharacter(target)){ + if(((AbstractCharacter)target).combatTarget == null){ + ((AbstractCharacter)target).combatTarget = attacker; + } + } + // take stamina away from attacker if (weapon != null) { From 1429a3a4d55681b6c65c0d722a4f4b9547ad53ae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 10 Apr 2024 16:06:09 -0400 Subject: [PATCH 062/378] Configure upon submit() --- src/engine/gameManager/ForgeManager.java | 9 +++++++++ src/engine/loot/WorkOrder.java | 3 +++ .../net/client/handlers/ItemProductionMsgHandler.java | 1 - 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 4053c126..ee7993e8 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -9,6 +9,7 @@ package engine.gameManager; import engine.loot.WorkOrder; +import engine.mbEnums; import engine.objects.Item; import engine.objects.PlayerCharacter; import org.pmw.tinylog.Logger; @@ -88,6 +89,8 @@ public enum ForgeManager implements Runnable { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slotCount = calcAvailableSlots(workOrder); + workOrder.production_cost = calcProductionCost(workOrder); + workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); // Single item rolls are total_to_produce of 0; @@ -144,4 +147,10 @@ public enum ForgeManager implements Runnable { return availableSlots; } + + public static HashMap calcProductionCost(WorkOrder workOrder) { + HashMap production_cost = new HashMap<>(); + + return production_cost; + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 3fe3508b..87ca5455 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,11 +8,13 @@ package engine.loot; +import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +import java.util.HashMap; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -25,6 +27,7 @@ public class WorkOrder implements Delayed { public int slotCount; public int total_to_produce; public int total_produced; + public HashMap production_cost = new HashMap<>(); public int templateID; public String itemName; public int prefixToken; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 308a4209..953ff486 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -86,7 +86,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; workOrder.itemName = msg.name; - workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.slotCount = 0; // Validate vendor can roll this item From f6c53e51ed497ca375d2b97eb9609468aef5a1f4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 10 Apr 2024 16:47:02 -0400 Subject: [PATCH 063/378] Calculate cost of workOrder --- src/engine/gameManager/ForgeManager.java | 31 +++++++++++++++++++++++- src/engine/loot/WorkOrder.java | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ee7993e8..66599457 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -11,7 +11,9 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.Item; +import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; +import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -89,9 +91,15 @@ public enum ForgeManager implements Runnable { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slotCount = calcAvailableSlots(workOrder); - workOrder.production_cost = calcProductionCost(workOrder); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); + // Cost to execute this workOrder + + workOrder.production_cost = calcProductionCost(workOrder); + + for (mbEnums.ResourceType resourceType : workOrder.production_cost.keySet()) + workOrder.production_cost.compute(resourceType, (k, resourceValue) -> resourceValue * workOrder.total_to_produce); + // Single item rolls are total_to_produce of 0; if (workOrder.slotCount > 0 && workOrder.total_to_produce == 0) @@ -149,7 +157,28 @@ public enum ForgeManager implements Runnable { } public static HashMap calcProductionCost(WorkOrder workOrder) { + HashMap production_cost = new HashMap<>(); + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + // Add gold and resource costs from template + + production_cost.put(mbEnums.ResourceType.GOLD, template.item_value); + production_cost.putAll(template.item_resource_cost); + + // Calculate cost of prefix and suffix + + if (workOrder.prefixToken != 0) { + EffectsBase prefix = PowersManager.getEffectByToken(workOrder.prefixToken); + EffectsBase prefixValue = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); + production_cost.putAll(prefixValue.getResourcesForEffect()); + } + + if (workOrder.suffixToken != 0) { + EffectsBase suffix = PowersManager.getEffectByToken(workOrder.suffixToken); + EffectsBase suffixValue = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); + production_cost.putAll(suffixValue.getResourcesForEffect()); + } return production_cost; } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 87ca5455..dd4b20ab 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -28,6 +28,7 @@ public class WorkOrder implements Delayed { public int total_to_produce; public int total_produced; public HashMap production_cost = new HashMap<>(); + public HashMap production_cost_total = new HashMap<>(); public int templateID; public String itemName; public int prefixToken; From 7f579e526821a16d2ccc79901a559a0626c5ba94 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 10 Apr 2024 17:22:45 -0400 Subject: [PATCH 064/378] Bane rank loaded from template --- src/engine/gameManager/ForgeManager.java | 21 +++++++++++++++------ src/engine/objects/ItemTemplate.java | 7 +++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 66599457..99342648 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -131,16 +131,14 @@ public enum ForgeManager implements Runnable { public static long calcRollingDuration(WorkOrder workOrder) { long rollingDuration; - float rank = workOrder.vendor.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); + float rate = (float) (2.5 * (workOrder.vendor.getBuilding().getRank() - 1)); float baseTime = (20 - rate) * 60000; + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); // Bane circles - if (workOrder.templateID > 910010 && workOrder.templateID < 910019) { - rank = workOrder.templateID - 910010; - baseTime = rank * 60 * 60 * 3 * 1000; - } + if (template.item_bane_rank > 0) + baseTime = template.item_bane_rank * 60 * 60 * 3 * 1000; rollingDuration = (long) (baseTime * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); return rollingDuration; @@ -148,16 +146,27 @@ public enum ForgeManager implements Runnable { public static int calcAvailableSlots(WorkOrder workOrder) { + // Slots available in a forge are based on the npc rank + int availableSlots = workOrder.vendor.getRank(); + // Slots currently used up by the npc workOrders + for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) availableSlots = availableSlots - npcWorkOrder.slotCount; + // Slot count override for single item production + + if (workOrder.total_to_produce == 0 && availableSlots > 1) + availableSlots = 1; + return availableSlots; } public static HashMap calcProductionCost(WorkOrder workOrder) { + // Calculate the production cost for a single run of this workOrder + HashMap production_cost = new HashMap<>(); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index b186450e..a2d9f140 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -133,6 +133,7 @@ public class ItemTemplate { public final EnumSet rune_not_enemy_monster_types = EnumSet.noneOf(mbEnums.MonsterType.class); public final ArrayList rune_groupee_monster_types = new ArrayList<>(); public final ArrayList rune_helper_monster_types = new ArrayList<>(); + public int item_bane_rank; public ItemTemplate(JSONObject jsonObject) { @@ -178,6 +179,12 @@ public class ItemTemplate { obj_sparse_data.put(sparseType, sparseValue.toString()); } + // Banes are defined by their sparse data field + + if (obj_sparse_data.entrySet().contains("ACTIONRESPONSE")) + if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122")) + item_bane_rank = ((Long) jsonObject.get("item_bane_rank")).intValue(); + // Reading float values combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue(); From 4d18e71aa1d321e61e85b36b522ffb25318cbcf3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 10 Apr 2024 17:33:59 -0400 Subject: [PATCH 065/378] More info on template bootstrap --- src/engine/db/handlers/dbItemHandler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 040441e0..73162f9e 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -26,6 +26,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; @@ -181,6 +182,8 @@ public class dbItemHandler extends dbHandlerBase { JSONParser jsonParser = new JSONParser(); + HashMap templateTCountMap = new HashMap<>(); + try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_templates`;"); ResultSet rs = preparedStatement.executeQuery()) { @@ -191,8 +194,14 @@ public class dbItemHandler extends dbHandlerBase { ItemTemplate itemTemplate = new ItemTemplate(jsonObject); itemTemplate.template_id = templateID; ItemTemplate.templates.put(templateID, itemTemplate); + + if (templateTCountMap.entrySet().contains(itemTemplate.item_type)) + templateTCountMap.put(itemTemplate.item_type, templateTCountMap.get(itemTemplate.item_type) + 1); + else + templateTCountMap.put(itemTemplate.item_type, 1); } + Logger.info(templateTCountMap.toString()); } catch (Exception e) { Logger.error(e); } From df037a51f00e1c50a3fe60aec9eab39b74d4cc0b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 10 Apr 2024 17:40:00 -0400 Subject: [PATCH 066/378] More info on template bootstrap --- src/engine/db/handlers/dbItemHandler.java | 5 +---- src/engine/objects/ItemTemplate.java | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 73162f9e..83229178 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -195,10 +195,7 @@ public class dbItemHandler extends dbHandlerBase { itemTemplate.template_id = templateID; ItemTemplate.templates.put(templateID, itemTemplate); - if (templateTCountMap.entrySet().contains(itemTemplate.item_type)) - templateTCountMap.put(itemTemplate.item_type, templateTCountMap.get(itemTemplate.item_type) + 1); - else - templateTCountMap.put(itemTemplate.item_type, 1); + templateTCountMap.merge(itemTemplate.item_type, 1, Integer::sum); } Logger.info(templateTCountMap.toString()); diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index a2d9f140..0ac29787 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -181,7 +181,7 @@ public class ItemTemplate { // Banes are defined by their sparse data field - if (obj_sparse_data.entrySet().contains("ACTIONRESPONSE")) + if (obj_sparse_data.get("ACTIONRESPONSE") != null) if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122")) item_bane_rank = ((Long) jsonObject.get("item_bane_rank")).intValue(); From a7a1230f1ba4bb816027e01a3e51628747d28dd4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 10 Apr 2024 18:01:27 -0400 Subject: [PATCH 067/378] Work on wordOrder iteration --- src/engine/gameManager/ForgeManager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 99342648..5f7fc732 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -52,9 +52,10 @@ public enum ForgeManager implements Runnable { // if Prefix and suffix are null random roll item // otherwise roll what was asked for + + workOrder.total_produced = workOrder.total_produced + 1; } - workOrder.total_produced = workOrder.total_produced + 1; Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); if (workOrder.total_produced >= workOrder.total_to_produce) { @@ -66,6 +67,11 @@ public enum ForgeManager implements Runnable { continue; } + // Persist current items that are cooking + // after removing the negative id item from all collections. + + // Add new item to the vendors inventory + // Resubmit workOrder workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; @@ -114,6 +120,8 @@ public enum ForgeManager implements Runnable { // if Prefix and suffix are null random roll item // otherwise roll what was asked for + + workOrder.total_produced = workOrder.total_produced + 1; } Logger.info(workOrder.toString()); From af53859ba92aed193cd1ca27745cd877c3061fb0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 11 Apr 2024 13:46:24 -0400 Subject: [PATCH 068/378] Comment added --- src/engine/gameManager/ForgeManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 5f7fc732..ad5799b8 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -103,6 +103,8 @@ public enum ForgeManager implements Runnable { workOrder.production_cost = calcProductionCost(workOrder); + // Set total cost for this production run + for (mbEnums.ResourceType resourceType : workOrder.production_cost.keySet()) workOrder.production_cost.compute(resourceType, (k, resourceValue) -> resourceValue * workOrder.total_to_produce); From a16cda8a4ad79bb063313b553a84046af833deb2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 15:31:12 -0400 Subject: [PATCH 069/378] workerOrder cost updating --- src/engine/gameManager/ForgeManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ad5799b8..05f1560f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -105,8 +105,7 @@ public enum ForgeManager implements Runnable { // Set total cost for this production run - for (mbEnums.ResourceType resourceType : workOrder.production_cost.keySet()) - workOrder.production_cost.compute(resourceType, (k, resourceValue) -> resourceValue * workOrder.total_to_produce); + workOrder.production_cost.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); // Single item rolls are total_to_produce of 0; From 2200cb9bef6e28dc83d2891c371efe0bdf8e8490 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 15:41:15 -0400 Subject: [PATCH 070/378] workerOrder cost updating --- src/engine/gameManager/ForgeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 05f1560f..f1e04c43 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -105,6 +105,7 @@ public enum ForgeManager implements Runnable { // Set total cost for this production run + workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); // Single item rolls are total_to_produce of 0; From cc3d5fe0767e5fa4f20e70ed15e9891988eaacf3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 15:48:25 -0400 Subject: [PATCH 071/378] workerOrder cost updating --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f1e04c43..3fabf032 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -106,7 +106,7 @@ public enum ForgeManager implements Runnable { // Set total cost for this production run workOrder.production_cost_total.putAll(workOrder.production_cost); - workOrder.production_cost.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); + workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); // Single item rolls are total_to_produce of 0; From 97e0ada1a914077272df8b1a81131931eecf62d7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 16:16:34 -0400 Subject: [PATCH 072/378] workerOrder cost updating --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 3fabf032..9dd7dd67 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -141,7 +141,7 @@ public enum ForgeManager implements Runnable { public static long calcRollingDuration(WorkOrder workOrder) { long rollingDuration; - float rate = (float) (2.5 * (workOrder.vendor.getBuilding().getRank() - 1)); + float rate = (float) 2.5 * (workOrder.vendor.getBuilding().getRank() - 1); float baseTime = (20 - rate) * 60000; ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); From f7959a51bda29784c799e74472ada281b120e381 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 16:43:22 -0400 Subject: [PATCH 073/378] Rolling duration updated --- src/engine/gameManager/ForgeManager.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9dd7dd67..efd2cbc2 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -140,18 +140,20 @@ public enum ForgeManager implements Runnable { public static long calcRollingDuration(WorkOrder workOrder) { - long rollingDuration; - float rate = (float) 2.5 * (workOrder.vendor.getBuilding().getRank() - 1); - float baseTime = (20 - rate) * 60000; + float rollingDuration; + + rollingDuration = workOrder.vendor.getBuilding().getRank() * 5L + 40; + rollingDuration *= 60000; + rollingDuration *= Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()); + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); // Bane circles if (template.item_bane_rank > 0) - baseTime = template.item_bane_rank * 60 * 60 * 3 * 1000; + rollingDuration = (long) template.item_bane_rank * 60 * 60 * 3 * 1000 * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()); - rollingDuration = (long) (baseTime * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - return rollingDuration; + return (long) rollingDuration; } public static int calcAvailableSlots(WorkOrder workOrder) { From dd764281e8b423f2bc5979bb2dc4d230a91a236c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 16:52:43 -0400 Subject: [PATCH 074/378] Rolling duration updated --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index efd2cbc2..9a22f064 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -142,7 +142,7 @@ public enum ForgeManager implements Runnable { float rollingDuration; - rollingDuration = workOrder.vendor.getBuilding().getRank() * 5L + 40; + rollingDuration = workOrder.vendor.getBuilding().getRank() * -5L + 40; rollingDuration *= 60000; rollingDuration *= Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()); From 479e38e3f66508ca23b2a2c08e52237436428ba6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 17:06:42 -0400 Subject: [PATCH 075/378] Validation work --- src/engine/gameManager/ForgeManager.java | 15 +++++++++++++++ src/engine/net/Protocol.java | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9a22f064..2a78868f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -10,6 +10,7 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; +import engine.net.client.msg.ErrorPopupMsg; import engine.objects.Item; import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; @@ -133,6 +134,20 @@ public enum ForgeManager implements Runnable { public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) { + if (playerCharacter != null) + ErrorPopupMsg.sendErrorPopup(playerCharacter, 30); //30: That person cannot carry that item + return false; + } + + if (!workOrder.vendor.getItemModTable().contains(((byte) template.modTable))) { + if (playerCharacter != null) + ErrorPopupMsg.sendErrorPopup(playerCharacter, 59); //59: This hireling does not have this formula + return false; + } + // use Warehouse.caclulateOverdraft(workorder) method return true; diff --git a/src/engine/net/Protocol.java b/src/engine/net/Protocol.java index 67adc7e1..ec9ef72e 100644 --- a/src/engine/net/Protocol.java +++ b/src/engine/net/Protocol.java @@ -340,7 +340,6 @@ public enum Protocol { } } - public static int FindNextValidOpcode(ByteBufferReader reader) { int startPos = reader.position(); int bytesLeft = reader.remaining(); From dc18e71ee43bd03c6a9fb86432d2b8ca4d9cf239 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 17:15:04 -0400 Subject: [PATCH 076/378] Locked resources are always unavailable. --- src/engine/objects/Warehouse.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 02ea37a1..0bcdce7c 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -645,7 +645,9 @@ public class Warehouse { int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); - if (debit < 0) + // Locked resources are always unavailable + + if (debit < 0 || warehouse.locked.contains(resourceType)) overflowMap.put(resourceType, debit); } From 058887ff4d11aea6ffd41896c9bbcebcf0e5c9de Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 17:16:12 -0400 Subject: [PATCH 077/378] Locked resources are always unavailable. --- src/engine/gameManager/ForgeManager.java | 20 ++++++++++++++++++++ src/engine/objects/Warehouse.java | 18 ------------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 2a78868f..207de0cb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -14,6 +14,7 @@ import engine.net.client.msg.ErrorPopupMsg; import engine.objects.Item; import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; +import engine.objects.Warehouse; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -30,6 +31,25 @@ public enum ForgeManager implements Runnable { public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static HashMap oven = new HashMap(); + public static HashMap calcWarehouseOverflow(Warehouse warehouse, HashMap cost_map) { + + // Method returns a map of resourceType that a transaction overdrafts. + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : cost_map.keySet()) { + + int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); + + // Locked resources are always unavailable + + if (debit < 0 || warehouse.locked.contains(resourceType)) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } + @Override public void run() { diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 0bcdce7c..4891701e 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -635,22 +635,4 @@ public class Warehouse { return warehouse.locked.contains(resourceType); } - public static HashMap calcOverflow(Warehouse warehouse, HashMap cost_map) { - - // Method returns a map of resourceType that a transaction overdrafts. - - HashMap overflowMap = new HashMap<>(); - - for (mbEnums.ResourceType resourceType : cost_map.keySet()) { - - int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); - - // Locked resources are always unavailable - - if (debit < 0 || warehouse.locked.contains(resourceType)) - overflowMap.put(resourceType, debit); - } - - return overflowMap; - } } \ No newline at end of file From 29ce3537f703da841180ae3b11ef273b69620841 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 17:29:52 -0400 Subject: [PATCH 078/378] Work on cost overflow calculations --- src/engine/gameManager/ForgeManager.java | 56 ++++++++++++++++-------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 207de0cb..0f159c0a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -31,25 +31,6 @@ public enum ForgeManager implements Runnable { public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static HashMap oven = new HashMap(); - public static HashMap calcWarehouseOverflow(Warehouse warehouse, HashMap cost_map) { - - // Method returns a map of resourceType that a transaction overdrafts. - - HashMap overflowMap = new HashMap<>(); - - for (mbEnums.ResourceType resourceType : cost_map.keySet()) { - - int debit = warehouse.resources.get(resourceType) - cost_map.get(resourceType); - - // Locked resources are always unavailable - - if (debit < 0 || warehouse.locked.contains(resourceType)) - overflowMap.put(resourceType, debit); - } - - return overflowMap; - } - @Override public void run() { @@ -238,4 +219,41 @@ public enum ForgeManager implements Runnable { return production_cost; } + + public static HashMap calculateCostOverflow(WorkOrder workOrder) { + + HashMap costMap = new HashMap<>(); + Warehouse warehouse; + + // See if we can meet gold only requirements and early exit + + if (workOrder.production_cost_total.size() == 1) { + if (workOrder.vendor.building.getStrongboxValue() > workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)) + return costMap; + } + + // Gold deficit exists so a warehouse is required + + warehouse = workOrder.vendor.building.getCity() == null ? null : workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return workOrder.production_cost_total; + + // Method returns a map of resourceType that a transaction overdrafts. + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : workOrder.production_cost_total.keySet()) { + + int debit = warehouse.resources.get(resourceType) - workOrder.production_cost_total.get(resourceType); + + // Locked resources are always unavailable + + if (debit < 0 || warehouse.locked.contains(resourceType)) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } + } From 44eafc33450b4e863f0cff8bd113ac8c8c1e229c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 12 Apr 2024 17:41:08 -0400 Subject: [PATCH 079/378] Validation work --- src/engine/gameManager/ForgeManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0f159c0a..9d0ceca6 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -149,7 +149,11 @@ public enum ForgeManager implements Runnable { return false; } - // use Warehouse.caclulateOverdraft(workorder) method + if (calcCostOverflow(workOrder).isEmpty() == false) { + if (playerCharacter != null) + ErrorPopupMsg.sendErrorPopup(playerCharacter, 18); //18: You can't really afford that + return false; + } return true; } @@ -220,7 +224,7 @@ public enum ForgeManager implements Runnable { return production_cost; } - public static HashMap calculateCostOverflow(WorkOrder workOrder) { + public static HashMap calcCostOverflow(WorkOrder workOrder) { HashMap costMap = new HashMap<>(); Warehouse warehouse; From 2e83b8c693bc6e0888676ec2316f75a5a1d4a9ae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 06:42:21 -0400 Subject: [PATCH 080/378] Better context in name --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9d0ceca6..044c4cc5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -149,7 +149,7 @@ public enum ForgeManager implements Runnable { return false; } - if (calcCostOverflow(workOrder).isEmpty() == false) { + if (!calcCostOverrun(workOrder).isEmpty()) { if (playerCharacter != null) ErrorPopupMsg.sendErrorPopup(playerCharacter, 18); //18: You can't really afford that return false; @@ -224,7 +224,7 @@ public enum ForgeManager implements Runnable { return production_cost; } - public static HashMap calcCostOverflow(WorkOrder workOrder) { + public static HashMap calcCostOverrun(WorkOrder workOrder) { HashMap costMap = new HashMap<>(); Warehouse warehouse; From fc3a0eaf0cd90bfb189a52569dcdb6f5df299d30 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 06:48:58 -0400 Subject: [PATCH 081/378] Forge must be protected --- src/engine/gameManager/ForgeManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 044c4cc5..6f521887 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -155,7 +155,9 @@ public enum ForgeManager implements Runnable { return false; } - return true; + // Forge must be protected in order to access warehouse. + + return workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED); } public static long calcRollingDuration(WorkOrder workOrder) { From 5cb08c1dc0a35a81b76b2731fbe3b72b9284abd8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 06:53:36 -0400 Subject: [PATCH 082/378] Forge must be protected --- src/engine/gameManager/ForgeManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6f521887..2bae9023 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -157,7 +157,13 @@ public enum ForgeManager implements Runnable { // Forge must be protected in order to access warehouse. - return workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED); + if (workOrder.production_cost_total.size() > 1) + if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) { + if (playerCharacter != null) + ErrorPopupMsg.sendErrorPopup(playerCharacter, 193); //193: Production denied: This building must be protected to gain access to warehouse + } + + return true; } public static long calcRollingDuration(WorkOrder workOrder) { From 3fa4185b7f57d224086c24c3d7b8870e76f137ec Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 06:55:49 -0400 Subject: [PATCH 083/378] Debug comment update --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 2bae9023..edce8faa 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -62,7 +62,7 @@ public enum ForgeManager implements Runnable { if (workOrder.total_produced >= workOrder.total_to_produce) { - Logger.info("Workorder has completed: " + workOrder.workOrderID); + Logger.info("workOrder has completed: " + workOrder.workOrderID); workOrder.runCompleted = true; workOrder.vendor.workOrders.remove(workOrder); From 61a418fd8e0b7f8f5d9f1778abe06115d3d033df Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 07:18:55 -0400 Subject: [PATCH 084/378] Debug comment update --- src/engine/loot/WorkOrder.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index dd4b20ab..9e4bf829 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -13,6 +13,10 @@ import engine.objects.Item; import engine.objects.NPC; import org.jetbrains.annotations.NotNull; +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.Delayed; @@ -58,6 +62,11 @@ public class WorkOrder implements Delayed { } public String toString() { + + LocalDateTime localDateTime = Instant.ofEpochMilli(this.completionTime) + .atZone(ZoneId.systemDefault()).toLocalDateTime(); + Duration duration = Duration.ofMillis(38114000); + String outSTring = "\r\nwordOrderID: " + this.workOrderID + "\r\n" + "vendor: " + this.vendor.getObjectUUID() + "\r\n" + "slotCount: " + this.slotCount + "\r\n" + @@ -67,8 +76,8 @@ public class WorkOrder implements Delayed { "itemName: " + this.itemName + "\r\n" + "prefixToken: " + this.prefixToken + "\r\n" + "suffixToken: " + this.suffixToken + "\r\n" + - "rollingDuration: " + this.rollingDuration + "\r\n" + - "completionTime: " + this.completionTime + "\r\n" + + "rollingDuration: " + duration + "\r\n" + + "completionTime: " + localDateTime + "\r\n" + "runCompleted: " + this.runCompleted + "\r\n" + "runCanceled: " + this.runCanceled + "\r\n"; From 13ba31285e94825e5e969107ef6d9498e37e9d86 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 07:26:39 -0400 Subject: [PATCH 085/378] Logging on each cycle --- src/engine/gameManager/ForgeManager.java | 1 + src/engine/loot/WorkOrder.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index edce8faa..96279281 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -78,6 +78,7 @@ public enum ForgeManager implements Runnable { workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrders.add(workOrder); + Logger.info(workOrder.toString()); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 9e4bf829..6bd7bf53 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -65,7 +65,7 @@ public class WorkOrder implements Delayed { LocalDateTime localDateTime = Instant.ofEpochMilli(this.completionTime) .atZone(ZoneId.systemDefault()).toLocalDateTime(); - Duration duration = Duration.ofMillis(38114000); + Duration duration = Duration.ofMillis(this.rollingDuration); String outSTring = "\r\nwordOrderID: " + this.workOrderID + "\r\n" + "vendor: " + this.vendor.getObjectUUID() + "\r\n" + From 052867893cbc7f71c82e680df86d7590af5c5c40 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 07:31:17 -0400 Subject: [PATCH 086/378] Bugfix in delay override --- src/engine/loot/WorkOrder.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 6bd7bf53..d1b0903f 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,7 +11,6 @@ package engine.loot; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; -import org.jetbrains.annotations.NotNull; import java.time.Duration; import java.time.Instant; @@ -22,8 +21,6 @@ import java.util.HashMap; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; -import static java.lang.Math.toIntExact; - public class WorkOrder implements Delayed { public int workOrderID; @@ -57,8 +54,8 @@ public class WorkOrder implements Delayed { } @Override - public int compareTo(@NotNull Delayed o) { - return toIntExact(this.completionTime - ((WorkOrder) o).completionTime); + public int compareTo(Delayed o) { + return Long.compare(this.completionTime, ((WorkOrder) o).completionTime); } public String toString() { From 68f2af53069c37045a54fe1ed4221008249f3b3c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 07:44:16 -0400 Subject: [PATCH 087/378] Bugfix in delay override --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 96279281..36133d7b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -98,9 +98,9 @@ public enum ForgeManager implements Runnable { public static void submit(WorkOrder workOrder) { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); + workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slotCount = calcAvailableSlots(workOrder); - workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); // Cost to execute this workOrder From f076b380447654d61cdfd52d790c51761edc7c2a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 07:54:26 -0400 Subject: [PATCH 088/378] Contextual variable name updates --- src/engine/gameManager/ForgeManager.java | 12 ++++++------ src/engine/loot/WorkOrder.java | 8 ++++---- .../client/handlers/ItemProductionMsgHandler.java | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 36133d7b..6499ce59 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -47,7 +47,7 @@ public enum ForgeManager implements Runnable { // Create negative ID items to add to collections - for (int i = 0; i < workOrder.slotCount; ++i) { + for (int i = 0; i < workOrder.slots_used; ++i) { // Create workOrder items; one for each slot // assigned to this workOrder. @@ -100,7 +100,7 @@ public enum ForgeManager implements Runnable { workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - workOrder.slotCount = calcAvailableSlots(workOrder); + workOrder.slots_used = calcAvailableSlots(workOrder); // Cost to execute this workOrder @@ -113,12 +113,12 @@ public enum ForgeManager implements Runnable { // Single item rolls are total_to_produce of 0; - if (workOrder.slotCount > 0 && workOrder.total_to_produce == 0) - workOrder.slotCount = 1; + if (workOrder.slots_used > 0 && workOrder.total_to_produce == 0) + workOrder.slots_used = 1; // Create negative ID items to add to collections - for (int i = 0; i < workOrder.slotCount; ++i) { + for (int i = 0; i < workOrder.slots_used; ++i) { // Create workOrder items; one for each slot // assigned to this workOrder. @@ -194,7 +194,7 @@ public enum ForgeManager implements Runnable { // Slots currently used up by the npc workOrders for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) - availableSlots = availableSlots - npcWorkOrder.slotCount; + availableSlots = availableSlots - npcWorkOrder.slots_used; // Slot count override for single item production diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index d1b0903f..d301df3d 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -25,13 +25,13 @@ public class WorkOrder implements Delayed { public int workOrderID; public NPC vendor; - public int slotCount; + public int slots_used; public int total_to_produce; public int total_produced; public HashMap production_cost = new HashMap<>(); public HashMap production_cost_total = new HashMap<>(); public int templateID; - public String itemName; + public String item_name_override; public int prefixToken; public int suffixToken; public long rollingDuration; @@ -66,11 +66,11 @@ public class WorkOrder implements Delayed { String outSTring = "\r\nwordOrderID: " + this.workOrderID + "\r\n" + "vendor: " + this.vendor.getObjectUUID() + "\r\n" + - "slotCount: " + this.slotCount + "\r\n" + + "slots_used: " + this.slots_used + "\r\n" + "total_to_produce: " + this.total_to_produce + "\r\n" + "total_produced: " + this.total_produced + "\r\n" + "templateID: " + this.templateID + "\r\n" + - "itemName: " + this.itemName + "\r\n" + + "item_name_override: " + this.item_name_override + "\r\n" + "prefixToken: " + this.prefixToken + "\r\n" + "suffixToken: " + this.suffixToken + "\r\n" + "rollingDuration: " + duration + "\r\n" + diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 953ff486..67cbf5b7 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -85,8 +85,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.templateID = msg.templateID; workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; - workOrder.itemName = msg.name; - workOrder.slotCount = 0; + workOrder.item_name_override = msg.name; + workOrder.slots_used = 0; // Validate vendor can roll this item From a18785fb3de25c1d6f2e428cfbf46989af5dbc5b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 08:10:59 -0400 Subject: [PATCH 089/378] Begin work on forgeItem() --- src/engine/gameManager/ForgeManager.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6499ce59..f3455dab 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -11,10 +11,7 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.net.client.msg.ErrorPopupMsg; -import engine.objects.Item; -import engine.objects.ItemTemplate; -import engine.objects.PlayerCharacter; -import engine.objects.Warehouse; +import engine.objects.*; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -269,4 +266,17 @@ public enum ForgeManager implements Runnable { return overflowMap; } + public static Item forgeItem(WorkOrder workOrder) { + + Item forgedItem = new Item(workOrder.templateID); + forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); + forgedItem.containerType = mbEnums.ItemContainerType.FORGE; + forgedItem.ownerID = workOrder.vendor.getObjectUUID(); + + // Forged items are unidentified until completed + + forgedItem.flags.remove(mbEnums.ItemFlags.Identified); + + return forgedItem; + } } From 832b9947578bba648647fa552215ceeff63828a3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 08:19:09 -0400 Subject: [PATCH 090/378] Begin work on forgeItem() --- src/engine/gameManager/ForgeManager.java | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f3455dab..c7030fe4 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -113,18 +113,9 @@ public enum ForgeManager implements Runnable { if (workOrder.slots_used > 0 && workOrder.total_to_produce == 0) workOrder.slots_used = 1; - // Create negative ID items to add to collections + // Create in-memory items and add to collections - for (int i = 0; i < workOrder.slots_used; ++i) { - - // Create workOrder items; one for each slot - // assigned to this workOrder. - - // if Prefix and suffix are null random roll item - // otherwise roll what was asked for - - workOrder.total_produced = workOrder.total_produced + 1; - } + forgeItems(workOrder); Logger.info(workOrder.toString()); workOrder.vendor.workOrders.add(workOrder); @@ -279,4 +270,17 @@ public enum ForgeManager implements Runnable { return forgedItem; } + + public static void forgeItems(WorkOrder workOrder) { + + for (int i = 0; i < workOrder.slots_used; ++i) { + + Item forged_item = forgeItem(workOrder); + ForgeManager.oven.put(forged_item, workOrder); + workOrder.cooking.add(forged_item); + + workOrder.total_produced = workOrder.total_produced + 1; + Logger.info("Forged item: " + forged_item.objectUUID + " of template " + forged_item.templateID); + } + } } From 980dee2e146485cf2c63882d3c37ece53256e9c3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 08:31:36 -0400 Subject: [PATCH 091/378] Work on multiple slot support --- src/engine/loot/WorkOrder.java | 1 + src/engine/net/client/handlers/ItemProductionMsgHandler.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index d301df3d..0eee7b81 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -28,6 +28,7 @@ public class WorkOrder implements Delayed { public int slots_used; public int total_to_produce; public int total_produced; + public int msg_size; public HashMap production_cost = new HashMap<>(); public HashMap production_cost_total = new HashMap<>(); public int templateID; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 67cbf5b7..16df9139 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -87,6 +87,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.suffixToken = msg.sToken; workOrder.item_name_override = msg.name; workOrder.slots_used = 0; + workOrder.msg_size = msg.size; // Validate vendor can roll this item From ec80146117630c704194781a26ca851aded0a927 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 08:51:02 -0400 Subject: [PATCH 092/378] forge items each cycle --- src/engine/gameManager/ForgeManager.java | 32 ++++++++----------- .../handlers/ItemProductionMsgHandler.java | 2 +- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c7030fe4..40c3c85f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -34,7 +34,6 @@ public enum ForgeManager implements Runnable { while (true) { try { - WorkOrder workOrder = workOrders.take(); // Completed or canceled work orders are not re-enqueued @@ -42,36 +41,29 @@ public enum ForgeManager implements Runnable { if (workOrder.runCanceled || workOrder.runCompleted) continue; - // Create negative ID items to add to collections - - for (int i = 0; i < workOrder.slots_used; ++i) { - - // Create workOrder items; one for each slot - // assigned to this workOrder. - - // if Prefix and suffix are null random roll item - // otherwise roll what was asked for - - workOrder.total_produced = workOrder.total_produced + 1; - } + // Create in memory items to add to collections + forgeItems(workOrder); Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + if (workOrder.total_produced >= workOrder.total_to_produce) { Logger.info("workOrder has completed: " + workOrder.workOrderID); + // Persist current items that are cooking + // after removing the negative id item from all collections. + + // Add new item to the vendors inventory + workOrder.runCompleted = true; workOrder.vendor.workOrders.remove(workOrder); continue; } - // Persist current items that are cooking - // after removing the negative id item from all collections. - // Add new item to the vendors inventory - - // Resubmit workOrder + // enQueue this workOrder again; back into the oven + // until all items for this workOrder are completed. workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrders.add(workOrder); @@ -263,6 +255,7 @@ public enum ForgeManager implements Runnable { forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); + forgedItem.setDateToUpgrade(workOrder.completionTime); // Forged items are unidentified until completed @@ -277,10 +270,11 @@ public enum ForgeManager implements Runnable { Item forged_item = forgeItem(workOrder); ForgeManager.oven.put(forged_item, workOrder); + workOrder.cooking.add(forged_item); workOrder.total_produced = workOrder.total_produced + 1; - Logger.info("Forged item: " + forged_item.objectUUID + " of template " + forged_item.templateID); + Logger.info("Forging item: " + forged_item.objectUUID + " of template " + forged_item.templateID); } } } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 16df9139..832ca23e 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -9,7 +9,6 @@ package engine.net.client.handlers; - import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; @@ -34,6 +33,7 @@ import java.util.HashMap; * @Summary: Processes application protocol message which modifies * hireling inventory through rolling, junking or depositing. */ + public class ItemProductionMsgHandler extends AbstractClientMsgHandler { public ItemProductionMsgHandler() { From f6e1c78b0b5a3cfaef18c2f1222803f9fc6122ab Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 08:57:53 -0400 Subject: [PATCH 093/378] Debug string update --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 40c3c85f..5e2b2b0b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -274,7 +274,7 @@ public enum ForgeManager implements Runnable { workOrder.cooking.add(forged_item); workOrder.total_produced = workOrder.total_produced + 1; - Logger.info("Forging item: " + forged_item.objectUUID + " of template " + forged_item.templateID); + Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); } } } From 09c96c772e543c5e8d5acc79e0c57d31584267a9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 09:10:56 -0400 Subject: [PATCH 094/378] Multiple item workOrder work --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 5e2b2b0b..80e37890 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -100,9 +100,9 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); - // Single item rolls are total_to_produce of 0; + // Single item rolls are msg_size of 0; - if (workOrder.slots_used > 0 && workOrder.total_to_produce == 0) + if (workOrder.slots_used > 0 && workOrder.msg_size == 0) workOrder.slots_used = 1; // Create in-memory items and add to collections From d26214d032d90f76b01d47e25b4733d8d388d1b2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 09:20:25 -0400 Subject: [PATCH 095/378] Multiple item workOrder work --- src/engine/gameManager/ForgeManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 80e37890..f169ffe3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -105,6 +105,8 @@ public enum ForgeManager implements Runnable { if (workOrder.slots_used > 0 && workOrder.msg_size == 0) workOrder.slots_used = 1; + workOrder.total_to_produce *= workOrder.slots_used; + // Create in-memory items and add to collections forgeItems(workOrder); From 3c704d6b859a7185cf36ed7fd063ea547052abe8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 09:22:23 -0400 Subject: [PATCH 096/378] Multiple item workOrder work --- src/engine/gameManager/ForgeManager.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f169ffe3..db618591 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -100,11 +100,6 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); - // Single item rolls are msg_size of 0; - - if (workOrder.slots_used > 0 && workOrder.msg_size == 0) - workOrder.slots_used = 1; - workOrder.total_to_produce *= workOrder.slots_used; // Create in-memory items and add to collections @@ -178,9 +173,9 @@ public enum ForgeManager implements Runnable { for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) availableSlots = availableSlots - npcWorkOrder.slots_used; - // Slot count override for single item production + // Single item rolls are msg_size of 0; - if (workOrder.total_to_produce == 0 && availableSlots > 1) + if (workOrder.slots_used > 0 && workOrder.msg_size == 0) availableSlots = 1; return availableSlots; From a5bcdff216121e52c48ea23c6c29fc2586872d2a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 09:31:18 -0400 Subject: [PATCH 097/378] Multiple item workOrder work --- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/loot/WorkOrder.java | 2 +- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index db618591..9d24140b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -175,7 +175,7 @@ public enum ForgeManager implements Runnable { // Single item rolls are msg_size of 0; - if (workOrder.slots_used > 0 && workOrder.msg_size == 0) + if (workOrder.slots_used > 0 && workOrder.multiple_slot_request == 0) availableSlots = 1; return availableSlots; diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 0eee7b81..adb0de6c 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -28,7 +28,7 @@ public class WorkOrder implements Delayed { public int slots_used; public int total_to_produce; public int total_produced; - public int msg_size; + public int multiple_slot_request; public HashMap production_cost = new HashMap<>(); public HashMap production_cost_total = new HashMap<>(); public int templateID; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 832ca23e..0a4b8abd 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -87,7 +87,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.suffixToken = msg.sToken; workOrder.item_name_override = msg.name; workOrder.slots_used = 0; - workOrder.msg_size = msg.size; + workOrder.multiple_slot_request = msg.size; // Validate vendor can roll this item From 4aca075da60815a0b635db9105b61b0523fa29d4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 09:38:58 -0400 Subject: [PATCH 098/378] Multiple item workOrder work --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9d24140b..1ca9146d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -175,7 +175,7 @@ public enum ForgeManager implements Runnable { // Single item rolls are msg_size of 0; - if (workOrder.slots_used > 0 && workOrder.multiple_slot_request == 0) + if (availableSlots > 0 && workOrder.multiple_slot_request == 0) availableSlots = 1; return availableSlots; From 333fcc9d1438bb8d6c40caacdf36734031dce3a2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 09:53:20 -0400 Subject: [PATCH 099/378] Multiple item workOrder work --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 0a4b8abd..b42b5dd4 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -86,7 +86,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; workOrder.item_name_override = msg.name; - workOrder.slots_used = 0; workOrder.multiple_slot_request = msg.size; // Validate vendor can roll this item From 9c146fff4dc9f28971535dc39e5d0b22b69bc423 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 10:01:35 -0400 Subject: [PATCH 100/378] Only random rolled items are unidentified. --- src/engine/gameManager/ForgeManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 1ca9146d..32c39b04 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -254,9 +254,10 @@ public enum ForgeManager implements Runnable { forgedItem.ownerID = workOrder.vendor.getObjectUUID(); forgedItem.setDateToUpgrade(workOrder.completionTime); - // Forged items are unidentified until completed + // Forged random rolled items are unidentified until completed - forgedItem.flags.remove(mbEnums.ItemFlags.Identified); + if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) + forgedItem.flags.remove(mbEnums.ItemFlags.Identified); return forgedItem; } From cabbf8bf44df7b20c2d5bb4c66616203ef598ff0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 10:06:44 -0400 Subject: [PATCH 101/378] Java 8 TimeUnit --- src/engine/gameManager/ForgeManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 32c39b04..99d1b082 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -18,6 +18,7 @@ import org.pmw.tinylog.Logger; import java.util.HashMap; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public enum ForgeManager implements Runnable { @@ -149,7 +150,7 @@ public enum ForgeManager implements Runnable { float rollingDuration; rollingDuration = workOrder.vendor.getBuilding().getRank() * -5L + 40; - rollingDuration *= 60000; + rollingDuration = TimeUnit.MINUTES.toMillis((long) rollingDuration); rollingDuration *= Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); From f068e6891ed539ac827970701a72496983e0ddf2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 10:10:17 -0400 Subject: [PATCH 102/378] Collection declaration cleanup --- src/engine/gameManager/ForgeManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 99d1b082..57516224 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -25,9 +25,9 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; - private static final BlockingQueue workOrders = new DelayQueue(); + private static final BlockingQueue oven = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static HashMap oven = new HashMap(); + public static final HashMap workOrderMap = new HashMap(); @Override public void run() { @@ -35,7 +35,7 @@ public enum ForgeManager implements Runnable { while (true) { try { - WorkOrder workOrder = workOrders.take(); + WorkOrder workOrder = oven.take(); // Completed or canceled work orders are not re-enqueued @@ -67,7 +67,7 @@ public enum ForgeManager implements Runnable { // until all items for this workOrder are completed. workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - workOrders.add(workOrder); + oven.add(workOrder); Logger.info(workOrder.toString()); } catch (InterruptedException e) { @@ -109,7 +109,7 @@ public enum ForgeManager implements Runnable { Logger.info(workOrder.toString()); workOrder.vendor.workOrders.add(workOrder); - workOrders.add(workOrder); + oven.add(workOrder); } public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { @@ -268,7 +268,7 @@ public enum ForgeManager implements Runnable { for (int i = 0; i < workOrder.slots_used; ++i) { Item forged_item = forgeItem(workOrder); - ForgeManager.oven.put(forged_item, workOrder); + ForgeManager.workOrderMap.put(forged_item, workOrder); workOrder.cooking.add(forged_item); From 8fe7a6e8969a8b57a35aef66f04315d44c79319f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 11:28:48 -0400 Subject: [PATCH 103/378] Class cleanup --- src/engine/gameManager/ForgeManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 57516224..43809238 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -25,7 +25,7 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; - private static final BlockingQueue oven = new DelayQueue<>(); + private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static final HashMap workOrderMap = new HashMap(); @@ -35,7 +35,7 @@ public enum ForgeManager implements Runnable { while (true) { try { - WorkOrder workOrder = oven.take(); + WorkOrder workOrder = forge.take(); // Completed or canceled work orders are not re-enqueued @@ -52,8 +52,9 @@ public enum ForgeManager implements Runnable { Logger.info("workOrder has completed: " + workOrder.workOrderID); - // Persist current items that are cooking - // after removing the negative id item from all collections. + // Persist current items that are currently building for this + // worker after first removing the negative id item from all + // collections. // Add new item to the vendors inventory @@ -67,7 +68,7 @@ public enum ForgeManager implements Runnable { // until all items for this workOrder are completed. workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - oven.add(workOrder); + forge.add(workOrder); Logger.info(workOrder.toString()); } catch (InterruptedException e) { @@ -109,7 +110,7 @@ public enum ForgeManager implements Runnable { Logger.info(workOrder.toString()); workOrder.vendor.workOrders.add(workOrder); - oven.add(workOrder); + forge.add(workOrder); } public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { From ec47e245490194340bd517a684297946532a2a9d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 13 Apr 2024 12:26:39 -0400 Subject: [PATCH 104/378] Not yet set when validating. --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 43809238..fc507586 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -137,7 +137,7 @@ public enum ForgeManager implements Runnable { // Forge must be protected in order to access warehouse. - if (workOrder.production_cost_total.size() > 1) + if (calcProductionCost(workOrder).size() > 1) if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) { if (playerCharacter != null) ErrorPopupMsg.sendErrorPopup(playerCharacter, 193); //193: Production denied: This building must be protected to gain access to warehouse From 79f4a33b6efc87bc2f3db81ef02c3cbc9183ab47 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 13 Apr 2024 19:10:10 -0500 Subject: [PATCH 105/378] add half player character height to attack range in lieu of hitbox --- src/engine/gameManager/CombatManager.java | 40 ++++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 9f9566b2..0a61159c 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -113,13 +113,20 @@ public enum CombatManager { float distanceSquared = attacker.loc.distanceSquared(target.loc); boolean inRange = false; - - attackRange += attacker.calcHitBox(); + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)){ + attackRange += ((PlayerCharacter)attacker).getCharacterHeight() * 0.5f; + }else { + attackRange += attacker.calcHitBox(); + } switch(target.getObjectType()){ case PlayerCharacter: + attackRange += ((PlayerCharacter)target).getCharacterHeight() * 0.5f; + if(distanceSquared < attackRange * attackRange) + inRange = true; + break; case Mob: attackRange += ((AbstractCharacter)target).calcHitBox(); - if(distanceSquared < attackRange * 2) + if(distanceSquared < attackRange * attackRange) inRange = true; break; case Building: @@ -143,6 +150,20 @@ public enum CombatManager { } } + DeferredPowerJob dpj = null; + + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + + dpj = ((PlayerCharacter) attacker).getWeaponPower(); + + if (dpj != null) { + dpj.attack(target, attackRange); + + if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) + ((PlayerCharacter) attacker).setWeaponPower(dpj); + } + } + // take stamina away from attacker if (weapon != null) { @@ -336,19 +357,6 @@ public enum CombatManager { TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); DispatchMessage.sendToAllInRange(target, cmm); } - DeferredPowerJob dpj = null; - - if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { - - dpj = ((PlayerCharacter) attacker).getWeaponPower(); - - if (dpj != null) { - dpj.attack(target, attackRange); - - if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) - ((PlayerCharacter) attacker).setWeaponPower(dpj); - } - } } //calculate next allowed attack and update the timestamp From 3f27bae09958a23be6e1a5f0627dfe4fe103e1af Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 13 Apr 2024 19:12:09 -0500 Subject: [PATCH 106/378] mobs dont double tap when unarmed --- src/engine/gameManager/CombatManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 0a61159c..9b5561e1 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -62,7 +62,8 @@ public enum CombatManager { if (mainWeapon == null && offWeapon == null) { //no weapons equipped, punch with both fists processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) + processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); } else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { //no weapon equipped with a shield, punch with one hand processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); From 2aaca661e2cf6ae2d74882d08a5dd8cb028e46fb Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 13 Apr 2024 19:44:03 -0500 Subject: [PATCH 107/378] new combat finalized --- src/engine/gameManager/CombatManager.java | 115 ++++++++++++++++------ src/engine/mobileAI/MobAI.java | 13 +-- 2 files changed, 85 insertions(+), 43 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 9b5561e1..71c7fae3 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -41,6 +41,10 @@ public enum CombatManager { if (attacker == null || target == null || !attacker.isAlive() || !target.isAlive()) return; + if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + if (((Mob) attacker).nextAttackTime > System.currentTimeMillis()) + return; + switch (target.getObjectType()) { case Building: if (((Building) target).isVulnerable() == false) @@ -85,12 +89,6 @@ public enum CombatManager { public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, mbEnums.EquipSlotType slot) { - // heck if character can even attack yet - - //if (attacker.getTimestamps().containsKey("Attack" + slot.name())) - // if (System.currentTimeMillis() < attacker.getTimestamps().get("Attack" + slot.name())) - // return; - // check if character is in range to attack target PlayerBonuses bonus = attacker.getBonuses(); @@ -141,13 +139,36 @@ public enum CombatManager { break; } + //get delay for the auto attack job + long delay = 5000; + + if (weapon != null) { + + int wepSpeed = (int) (weapon.template.item_weapon_wepspeed); + + if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus + wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None)); + + if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus + wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None)); + + if (wepSpeed < 10) + wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. + + delay = wepSpeed * 100; + } + + if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + ((Mob)attacker).nextAttackTime = System.currentTimeMillis() + delay; if (inRange) { //handle retaliate if(AbstractCharacter.IsAbstractCharacter(target)){ - if(((AbstractCharacter)target).combatTarget == null){ + if(((AbstractCharacter)target).combatTarget == null || ((AbstractCharacter)target).combatTarget.isAlive() == false){ ((AbstractCharacter)target).combatTarget = attacker; + if(target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat()) + combatCycle((AbstractCharacter) target, attacker); } } @@ -225,6 +246,19 @@ public enum CombatManager { else DispatchMessage.sendToAllInRange(attacker, msg); + //calculate next allowed attack and update the timestamp + attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); + + //handle auto attack job creation + ConcurrentHashMap timers = attacker.getTimers(); + + if (timers != null) { + AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); + JobContainer job; + job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue + timers.put("Attack" + slot, job); + } else + Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); return; } @@ -260,15 +294,41 @@ public enum CombatManager { else DispatchMessage.sendToAllInRange(attacker, msg); + //calculate next allowed attack and update the timestamp + attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); + + //handle auto attack job creation + ConcurrentHashMap timers = attacker.getTimers(); + + if (timers != null) { + AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); + JobContainer job; + job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue + timers.put("Attack" + slot, job); + } else + Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); return; } } //calculate the base damage int damage = ThreadLocalRandom.current().nextInt(min, max + 1); - if (damage == 0) + if (damage == 0) { + //calculate next allowed attack and update the timestamp + attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); + + //handle auto attack job creation + ConcurrentHashMap timers = attacker.getTimers(); + + if (timers != null) { + AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); + JobContainer job; + job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue + timers.put("Attack" + slot, job); + } else + Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); return; - + } //get the damage type mbEnums.DamageType damageType; @@ -333,9 +393,22 @@ public enum CombatManager { //check for damage type immunities - if (resists.immuneTo(damageType)) - return; + if (resists.immuneTo(damageType)) { + //calculate next allowed attack and update the timestamp + attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); + + //handle auto attack job creation + ConcurrentHashMap timers = attacker.getTimers(); + if (timers != null) { + AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); + JobContainer job; + job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue + timers.put("Attack" + slot, job); + } else + Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + return; + } //calculate resisted damage including fortitude damage = (int) resists.getResistedDamage(attacker, (AbstractCharacter) target, damageType, damage, 0); @@ -360,29 +433,9 @@ public enum CombatManager { } } //calculate next allowed attack and update the timestamp - - long delay = 20 * 100; - - if (weapon != null) { - - int wepSpeed = (int) (weapon.template.item_weapon_wepspeed); - - if (weapon.getBonusPercent(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None) != 0f) //add weapon speed bonus - wepSpeed *= (1 + weapon.getBonus(mbEnums.ModType.WeaponSpeed, mbEnums.SourceType.None)); - - if (attacker.getBonuses() != null && attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None) != 0f) //add effects speed bonus - wepSpeed *= (1 + attacker.getBonuses().getFloatPercentAll(mbEnums.ModType.AttackDelay, mbEnums.SourceType.None)); - - if (wepSpeed < 10) - wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. - - delay = wepSpeed * 100; - } - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); //handle auto attack job creation - ConcurrentHashMap timers = attacker.getTimers(); if (timers != null) { diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index e51b7e34..27e9173a 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -764,19 +764,8 @@ public class MobAI { mob.setCombatTarget(null); return; } - if (System.currentTimeMillis() > mob.getNextAttackTime()) { - int delay = 3000; - if (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.RHELD) != null) { - delay = (int) (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.RHELD).template.item_weapon_wepspeed * 100); - } - if (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD) != null && mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD).template.item_type.equals(mbEnums.ItemType.WEAPON)) { - delay += (int) (mob.charItemManager.getEquipped().get(mbEnums.EquipSlotType.LHELD).template.item_weapon_wepspeed * 100); - } + AttackTarget(mob, mob.getCombatTarget()); - - mob.nextAttackTime = System.currentTimeMillis() + delay; - AttackTarget(mob, mob.getCombatTarget()); - } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage()); } From 2feba8ac50ae52a27601b9269466f52f994794b7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 12:08:51 -0400 Subject: [PATCH 108/378] Rework of error handling. --- src/engine/gameManager/ForgeManager.java | 49 ++++++++++--------- .../handlers/ItemProductionMsgHandler.java | 12 +++-- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index fc507586..b941d1f9 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -10,8 +10,10 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; -import engine.net.client.msg.ErrorPopupMsg; -import engine.objects.*; +import engine.objects.Item; +import engine.objects.ItemTemplate; +import engine.objects.MobLoot; +import engine.objects.Warehouse; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -86,7 +88,12 @@ public enum ForgeManager implements Runnable { forgeManager.start(); } - public static void submit(WorkOrder workOrder) { + public static int submit(WorkOrder workOrder) { + + int validation_result = ForgeManager.validate(workOrder); + + if (validation_result != 0) + return validation_result; workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); @@ -111,39 +118,33 @@ public enum ForgeManager implements Runnable { Logger.info(workOrder.toString()); workOrder.vendor.workOrders.add(workOrder); forge.add(workOrder); + + return validation_result; } - public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { + public static int validate(WorkOrder workOrder) { + + int validation_result = 0; ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); - if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) { - if (playerCharacter != null) - ErrorPopupMsg.sendErrorPopup(playerCharacter, 30); //30: That person cannot carry that item - return false; - } + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) + return 30; //30: That person cannot carry that item - if (!workOrder.vendor.getItemModTable().contains(((byte) template.modTable))) { - if (playerCharacter != null) - ErrorPopupMsg.sendErrorPopup(playerCharacter, 59); //59: This hireling does not have this formula - return false; - } + if (!workOrder.vendor.getItemModTable().contains(((byte) template.modTable))) + return 59; //59: This hireling does not have this formula - if (!calcCostOverrun(workOrder).isEmpty()) { - if (playerCharacter != null) - ErrorPopupMsg.sendErrorPopup(playerCharacter, 18); //18: You can't really afford that - return false; - } + + if (!calcCostOverrun(workOrder).isEmpty()) + return 10; //18: You can't really afford that // Forge must be protected in order to access warehouse. if (calcProductionCost(workOrder).size() > 1) - if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) { - if (playerCharacter != null) - ErrorPopupMsg.sendErrorPopup(playerCharacter, 193); //193: Production denied: This building must be protected to gain access to warehouse - } + if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) + return 193; //193: Production denied: This building must be protected to gain access to warehouse - return true; + return validation_result; } public static long calcRollingDuration(WorkOrder workOrder) { diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index b42b5dd4..99a5cdbf 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -88,14 +88,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.item_name_override = msg.name; workOrder.multiple_slot_request = msg.size; - // Validate vendor can roll this item + // Submit workOder to begin rolling items - if (ForgeManager.validate(player, workOrder) == false) - return true; + int validation_result = ForgeManager.submit(workOrder); - // Start rolling the item(s) + // workOrder cannot be completed - ForgeManager.submit(workOrder); + if (validation_result != 0) { + ErrorPopupMsg.sendErrorPopup(player, validation_result); + return true; + } //Create Multiple Item Function.. Fill all empty slots From 0653828fe39771da0a9774e7a0c13d8618ea097e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 12:13:51 -0400 Subject: [PATCH 109/378] Rework of error handling. --- src/engine/gameManager/ForgeManager.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b941d1f9..f27fdb60 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -36,10 +36,20 @@ public enum ForgeManager implements Runnable { while (true) { + WorkOrder workOrder = null; + try { - WorkOrder workOrder = forge.take(); + workOrder = forge.take(); + } catch (InterruptedException e) { + Logger.error(e); + } + + if (workOrder == null) { + Logger.error("NULL workOrder in queue"); + continue; + } - // Completed or canceled work orders are not re-enqueued + // Completed or canceled work orders are not re-enqueued if (workOrder.runCanceled || workOrder.runCompleted) continue; @@ -72,10 +82,6 @@ public enum ForgeManager implements Runnable { workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; forge.add(workOrder); Logger.info(workOrder.toString()); - - } catch (InterruptedException e) { - e.printStackTrace(); - } } } From bc195c27db0dd92f8c143078b394fa82c4f5f07a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 12:14:17 -0400 Subject: [PATCH 110/378] Rework of error handling. --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f27fdb60..276c1052 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable { try { workOrder = forge.take(); - } catch (InterruptedException e) { + } catch (Exception e) { Logger.error(e); } From eed25d8c168487772857e70fcfdbe5363a7dbd2c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 12:24:53 -0400 Subject: [PATCH 111/378] Minor cleanup --- src/engine/gameManager/LootManager.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index e70cf827..c3bd0151 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -80,17 +80,10 @@ public enum LootManager { RunBootySet(_bootySetMap.get(mob.bootySet), mob, inHotzone); //lastly, check mobs inventory for godly or disc runes to send a server announcement - for (Item it : mob.getInventory()) { + for (Item item : mob.getInventory()) { - ItemTemplate ib = it.template; - - if (ib == null) - break; - - ItemTemplate template = ItemTemplate.templates.get(it.templateID); - - if ((it.templateID > 2499 && it.templateID <= 3050) || template.item_base_name.toLowerCase().contains("of the gods")) { - ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?"); + if ((item.templateID > 2499 && item.templateID <= 3050) || item.template.item_base_name.toLowerCase().contains("of the gods")) { + ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + item.template.item_base_name + ". Are you tough enough to take it?"); chatMsg.setMessageType(10); chatMsg.setChannel(mbEnums.ChatChannelType.SYSTEM.getChannelID()); DispatchMessage.dispatchMsgToAll(chatMsg); From 74e97fb4357b5da37273e6c4b11617288f58efe4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 12:41:16 -0400 Subject: [PATCH 112/378] Minor cleanup --- src/engine/gameManager/LootManager.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/engine/gameManager/LootManager.java b/src/engine/gameManager/LootManager.java index c3bd0151..aa31e0bc 100644 --- a/src/engine/gameManager/LootManager.java +++ b/src/engine/gameManager/LootManager.java @@ -212,7 +212,7 @@ public enum LootManager { int prefixTableRoll = 0; - if (mob.getObjectType().ordinal() == 52) + if (mob.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) prefixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); else prefixTableRoll = TableRoll(mob.level, inHotzone); @@ -222,7 +222,7 @@ public enum LootManager { if (prefixMod == null) return inItem; - if (prefixMod.action.length() > 0) { + if (prefixMod.action.isEmpty() == false) { inItem.setPrefix(prefixMod.action); inItem.addPermanentEnchantment(prefixMod.action, 0, prefixMod.level, true); } @@ -246,7 +246,7 @@ public enum LootManager { int suffixTableRoll; - if (mob.getObjectType().ordinal() == 52) + if (mob.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) suffixTableRoll = ThreadLocalRandom.current().nextInt(1, 320 + 1); else suffixTableRoll = TableRoll(mob.level, inHotzone); @@ -256,7 +256,7 @@ public enum LootManager { if (suffixMod == null) return inItem; - if (suffixMod.action.length() > 0) { + if (suffixMod.action.isEmpty() == false) { inItem.setSuffix(suffixMod.action); inItem.addPermanentEnchantment(suffixMod.action, 0, suffixMod.level, false); } @@ -270,14 +270,10 @@ public enum LootManager { mobLevel = 65; int max = (int) (4.882 * mobLevel + 127.0); - - if (max > 319) - max = 319; - int min = (int) (4.469 * mobLevel - 3.469); - if (min < 70) - min = 70; + min = Math.max(min, 70); + max = Math.min(max, 319); if (inHotzone) min += mobLevel; From ea555be08ed4c811a1c6b47a166fe9f97fed0441 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 13:13:28 -0400 Subject: [PATCH 113/378] Mobtype work related to ForgeManager --- src/engine/gameManager/ForgeManager.java | 16 ++++++++++++---- src/engine/mbEnums.java | 5 +++++ src/engine/net/client/msg/ManageNPCMsg.java | 8 ++++---- src/engine/objects/Contract.java | 6 +++--- src/engine/objects/ItemFactory.java | 2 +- src/engine/objects/NPC.java | 4 ++-- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 276c1052..010164eb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -10,10 +10,7 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; -import engine.objects.Item; -import engine.objects.ItemTemplate; -import engine.objects.MobLoot; -import engine.objects.Warehouse; +import engine.objects.*; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -284,4 +281,15 @@ public enum ForgeManager implements Runnable { Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); } } + + public static void calsRandomModType(NPC vendor, mbEnums.ItemModType itemModType, Item item) { + + int modifier; + + if (itemModType.equals(mbEnums.ItemModType.PREFIX)) + modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); + else + modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); + + } } diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index 0196d136..720ede75 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -3039,5 +3039,10 @@ public class mbEnums { CONFIRM_DEPOSIT, CONFIRM_TAKE; } + + public enum ItemModType { + PREFIX, + SUFFIX; + } } diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 2ec99f38..3be1d778 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -523,10 +523,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.putInt(2); writer.putInt(0); writer.putInt(1); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt)); - writer.put(npc.getItemModTable().get(imt));//writer.putInt(-916801465); effectItemType + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue()); + writer.put(npc.getItemModTable().get(imt).byteValue());//writer.putInt(-916801465); effectItemType writer.putInt(mtp); //prefix int mts = modPrefixList.indexOf(mtp); writer.putInt(npc.getModSuffixTable().get(mts)); //suffix diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index 5defef35..c094f9c6 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -34,7 +34,7 @@ public class Contract extends AbstractGameObject { private ArrayList npcMenuOptions = new ArrayList<>(); private ArrayList npcModTypeTable = new ArrayList<>(); private ArrayList npcModSuffixTable = new ArrayList<>(); - private ArrayList itemModTable = new ArrayList<>(); + private ArrayList itemModTable = new ArrayList<>(); private ArrayList sellInventory = new ArrayList<>(); public EnumSet allowedBuildings; private ArrayList buyItemType = new ArrayList<>(); @@ -122,7 +122,7 @@ public class Contract extends AbstractGameObject { if (!itemMod.isEmpty()) { String[] data2 = itemMod.split(" "); for (byte i = 0; i < data2.length; i++) { - this.itemModTable.add(Byte.parseByte(data2[i])); + this.itemModTable.add(Integer.parseInt(data2[i])); } } @@ -193,7 +193,7 @@ public class Contract extends AbstractGameObject { return npcModSuffixTable; } - public ArrayList getItemModTable() { + public ArrayList getItemModTable() { return itemModTable; } diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java index 4ae1b050..b5d937e6 100644 --- a/src/engine/objects/ItemFactory.java +++ b/src/engine/objects/ItemFactory.java @@ -663,7 +663,7 @@ public class ItemFactory { return null; } - for (byte temp : vendor.getItemModTable()) { + for (int temp : vendor.getItemModTable()) { if (itemModTable != temp) continue; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 95cafce1..58556907 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -70,7 +70,7 @@ public class NPC extends AbstractCharacter { protected int vendorID; protected ArrayList modTypeTable; protected ArrayList modSuffixTable; - protected ArrayList itemModTable; + protected ArrayList itemModTable; protected int symbol; // Variables NOT to be stored in db protected boolean isStatic = false; @@ -805,7 +805,7 @@ public class NPC extends AbstractCharacter { return modSuffixTable; } - public ArrayList getItemModTable() { + public ArrayList getItemModTable() { return itemModTable; } From a8d5521dd83c8ba771b4264ffe3397de54f73c3b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 13:51:37 -0400 Subject: [PATCH 114/378] Mobtype work related to ForgeManager --- src/engine/gameManager/ForgeManager.java | 51 +++++++++++++++++++++--- src/engine/objects/Item.java | 2 + 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 010164eb..9c57db89 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -8,15 +8,19 @@ package engine.gameManager; +import engine.loot.ModTableEntry; +import engine.loot.ModTypeTableEntry; import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.*; import engine.powers.EffectsBase; +import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; import java.util.HashMap; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; +import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -254,12 +258,22 @@ public enum ForgeManager implements Runnable { public static Item forgeItem(WorkOrder workOrder) { + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + Item forgedItem = new Item(workOrder.templateID); forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); forgedItem.setDateToUpgrade(workOrder.completionTime); + // Give prefix and suffix to this item if random rolled + + if (workOrder.prefixToken == 0) + forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); + + if (workOrder.suffixToken == 0) + forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable); + // Forged random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) @@ -282,14 +296,39 @@ public enum ForgeManager implements Runnable { } } - public static void calsRandomModType(NPC vendor, mbEnums.ItemModType itemModType, Item item) { + public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) { + + int modifier = 0; + ModTypeTableEntry modTypeTableEntry = null; + ModTableEntry modRollEntry = null; + int modifierRoll; + + switch (itemModType) { + case PREFIX: + modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(modTable)); + modTypeTableEntry = ModTypeTableEntry.rollTable(modifier, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + break; + case SUFFIX: + modifier = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(modTable)); + modTypeTableEntry = ModTypeTableEntry.rollTable(modifier, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + break; + } + + if (modTypeTableEntry == null) + return 0; - int modifier; + modifierRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (itemModType.equals(mbEnums.ItemModType.PREFIX)) - modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); - else - modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(item.template.modTable)); + if (modifierRoll < 80) { + modifierRoll = LootManager.TableRoll(vendor.getLevel(), false); + modRollEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, modifierRoll); + } + + if (modRollEntry != null) { + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modRollEntry.action); + modifier = abstractPowerAction.getEffectsBase().getToken(); + } + return modifier; } } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 134d9e7d..d5b7ddd5 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -59,6 +59,8 @@ public class Item extends AbstractWorldObject { public int magicValue; public ItemTemplate template; public String name = ""; + public int prefixToken; // Forge support + public int suffixToken; // Forge support /** * In Memory constructor From fae81a0263ef0b2aed13c1bbd877e4539cea29fc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 13:58:25 -0400 Subject: [PATCH 115/378] Removed cast in validation --- src/engine/gameManager/ForgeManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9c57db89..537806ab 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -138,10 +138,9 @@ public enum ForgeManager implements Runnable { if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) return 30; //30: That person cannot carry that item - if (!workOrder.vendor.getItemModTable().contains(((byte) template.modTable))) + if (!workOrder.vendor.getItemModTable().contains((template.modTable))) return 59; //59: This hireling does not have this formula - if (!calcCostOverrun(workOrder).isEmpty()) return 10; //18: You can't really afford that From 2c89509fa23562138b01abc7dec5408653c965d0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 14:07:06 -0400 Subject: [PATCH 116/378] Moved logging message up --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 537806ab..6821a198 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -290,8 +290,8 @@ public enum ForgeManager implements Runnable { workOrder.cooking.add(forged_item); - workOrder.total_produced = workOrder.total_produced + 1; Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); + workOrder.total_produced = workOrder.total_produced + 1; } } From 94ab64d629a899751c2c159d720d4e036ef7aec9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 14:11:22 -0400 Subject: [PATCH 117/378] reformat class --- src/engine/gameManager/ForgeManager.java | 47 ++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6821a198..363d908f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -45,44 +45,45 @@ public enum ForgeManager implements Runnable { Logger.error(e); } - if (workOrder == null) { - Logger.error("NULL workOrder in queue"); + // Null workOrders should not exist. + // Perhaps log? + + if (workOrder == null) continue; - } // Completed or canceled work orders are not re-enqueued - if (workOrder.runCanceled || workOrder.runCompleted) - continue; + if (workOrder.runCanceled || workOrder.runCompleted) + continue; - // Create in memory items to add to collections - forgeItems(workOrder); + // Create in memory items to add to collections - Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + forgeItems(workOrder); + Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); - if (workOrder.total_produced >= workOrder.total_to_produce) { - Logger.info("workOrder has completed: " + workOrder.workOrderID); + if (workOrder.total_produced >= workOrder.total_to_produce) { - // Persist current items that are currently building for this - // worker after first removing the negative id item from all - // collections. + Logger.info("workOrder has completed: " + workOrder.workOrderID); - // Add new item to the vendors inventory + // Persist current items that are currently building for this + // worker after first removing the negative id item from all + // collections. - workOrder.runCompleted = true; - workOrder.vendor.workOrders.remove(workOrder); - continue; - } + // Add new item to the vendors inventory + workOrder.runCompleted = true; + workOrder.vendor.workOrders.remove(workOrder); + continue; + } - // enQueue this workOrder again; back into the oven - // until all items for this workOrder are completed. + // enQueue this workOrder again; back into the oven + // until all items for this workOrder are completed. - workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - forge.add(workOrder); - Logger.info(workOrder.toString()); + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; + forge.add(workOrder); + Logger.info(workOrder.toString()); } } From 5e5b9884ef81520f8bf03f684b9d64932d44ffd2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 14:13:10 -0400 Subject: [PATCH 118/378] Begin integration --- .../client/handlers/ItemProductionMsgHandler.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 99a5cdbf..f7386b54 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -92,23 +92,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { int validation_result = ForgeManager.submit(workOrder); - // workOrder cannot be completed + // workOrder could not be completed + // Report back to the user the reason why if (validation_result != 0) { ErrorPopupMsg.sendErrorPopup(player, validation_result); return true; } - - //Create Multiple Item Function.. Fill all empty slots - - if (msg.size > 0) { - int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size(); - - if (emptySlots > 0) - for (int i = 0; i < emptySlots; i++) - vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); - } else - vendorNPC.produceItem(player.getObjectUUID(), msg.total_to_produce, isRandom, msg.pToken, msg.sToken, msg.name, msg.templateID); break; case JUNK: junkItem(msg.templateID, vendorNPC, origin); From 9464500e953e8b957c9a8521c4639e006a3ac9d5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 14:48:59 -0400 Subject: [PATCH 119/378] More integration work --- src/engine/db/handlers/dbNPCHandler.java | 83 +- src/engine/devcmd/cmds/CreateItemCmd.java | 3 +- src/engine/gameManager/ForgeManager.java | 15 +- src/engine/net/ItemProductionManager.java | 135 --- src/engine/net/ItemQueue.java | 86 -- .../handlers/ItemProductionMsgHandler.java | 12 +- .../net/client/msg/ItemProductionMsg.java | 45 +- src/engine/net/client/msg/ManageNPCMsg.java | 3 +- src/engine/objects/CharacterItemManager.java | 32 +- src/engine/objects/ItemFactory.java | 1029 ----------------- src/engine/objects/NPC.java | 188 --- src/engine/objects/ProducedItem.java | 225 ---- src/engine/server/world/WorldServer.java | 6 - 13 files changed, 59 insertions(+), 1803 deletions(-) delete mode 100644 src/engine/net/ItemProductionManager.java delete mode 100644 src/engine/net/ItemQueue.java delete mode 100644 src/engine/objects/ItemFactory.java delete mode 100644 src/engine/objects/ProducedItem.java diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index edf1005f..9e0a18ff 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -9,13 +9,12 @@ package engine.db.handlers; -import engine.mbEnums; -import engine.mbEnums.ProfitType; import engine.gameManager.DbManager; import engine.math.Vector3fImmutable; +import engine.mbEnums; +import engine.mbEnums.ProfitType; import engine.objects.NPC; import engine.objects.NPCProfits; -import engine.objects.ProducedItem; import org.joda.time.DateTime; import org.pmw.tinylog.Logger; @@ -346,29 +345,6 @@ public class dbNPCHandler extends dbHandlerBase { + NPC._pirateNames.size() + " mobBases"); } - public boolean ADD_TO_PRODUCTION_LIST(final long ID, final long npcUID, final long templateID, DateTime dateTime, String prefix, String suffix, String name, boolean isRandom, int playerID) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_npc_production` (`ID`,`npcUID`, `templateID`,`dateToUpgrade`, `isRandom`, `prefix`, `suffix`, `name`,`playerID`) VALUES (?,?,?,?,?,?,?,?,?)")) { - - preparedStatement.setLong(1, ID); - preparedStatement.setLong(2, npcUID); - preparedStatement.setLong(3, templateID); - preparedStatement.setTimestamp(4, new java.sql.Timestamp(dateTime.getMillis())); - preparedStatement.setBoolean(5, isRandom); - preparedStatement.setString(6, prefix); - preparedStatement.setString(7, suffix); - preparedStatement.setString(8, name); - preparedStatement.setInt(9, playerID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - public boolean REMOVE_FROM_PRODUCTION_LIST(final long ID, final long npcUID) { try (Connection connection = DbManager.getConnection(); @@ -385,23 +361,6 @@ public class dbNPCHandler extends dbHandlerBase { } } - public boolean UPDATE_ITEM_TO_INVENTORY(final long ID, final long npcUID) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_production` SET `inForge`=? WHERE `ID`=? AND `npcUID`=?;")) { - - preparedStatement.setByte(1, (byte) 0); - preparedStatement.setLong(2, ID); - preparedStatement.setLong(3, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - public boolean UPDATE_ITEM_PRICE(final long ID, final long npcUID, int value) { try (Connection connection = DbManager.getConnection(); @@ -419,44 +378,6 @@ public class dbNPCHandler extends dbHandlerBase { } } - public boolean UPDATE_ITEM_ID(final long ID, final long npcUID, final long value) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_production` SET `ID`=? WHERE `ID`=? AND `npcUID`=? LIMIT 1;")) { - - preparedStatement.setLong(1, value); - preparedStatement.setLong(2, ID); - preparedStatement.setLong(3, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public void LOAD_ALL_ITEMS_TO_PRODUCE(NPC npc) { - - if (npc == null) - return; - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_npc_production` WHERE `npcUID` = ?")) { - - preparedStatement.setInt(1, npc.getObjectUUID()); - ResultSet rs = preparedStatement.executeQuery(); - - while (rs.next()) { - ProducedItem producedItem = new ProducedItem(rs); - npc.forgedItems.add(producedItem); - } - - } catch (SQLException e) { - Logger.error(e); - } - } - public boolean UPDATE_PROFITS(NPC npc, ProfitType profitType, float value) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/devcmd/cmds/CreateItemCmd.java b/src/engine/devcmd/cmds/CreateItemCmd.java index 5e0bfdf9..c5acefab 100644 --- a/src/engine/devcmd/cmds/CreateItemCmd.java +++ b/src/engine/devcmd/cmds/CreateItemCmd.java @@ -11,7 +11,6 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; import engine.objects.AbstractGameObject; -import engine.objects.ItemFactory; import engine.objects.PlayerCharacter; /** @@ -39,7 +38,7 @@ public class CreateItemCmd extends AbstractDevCmd { if (words.length == 2) size = Integer.parseInt(words[1]); - ItemFactory.fillInventory(pc, templateID, size); + } @Override diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 363d908f..ba456e29 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -17,6 +17,7 @@ import engine.powers.EffectsBase; import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; +import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; @@ -30,9 +31,12 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final HashMap workOrderMap = new HashMap(); + public static final HashMap inMemoryItemLookup = new HashMap<>(); + public static final HashMap> vendorItemLookup = new HashMap<>(); + public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); @Override + public void run() { while (true) { @@ -71,10 +75,7 @@ public enum ForgeManager implements Runnable { // worker after first removing the negative id item from all // collections. - // Add new item to the vendors inventory - workOrder.runCompleted = true; - workOrder.vendor.workOrders.remove(workOrder); continue; } @@ -124,7 +125,6 @@ public enum ForgeManager implements Runnable { forgeItems(workOrder); Logger.info(workOrder.toString()); - workOrder.vendor.workOrders.add(workOrder); forge.add(workOrder); return validation_result; @@ -180,7 +180,7 @@ public enum ForgeManager implements Runnable { // Slots currently used up by the npc workOrders - for (WorkOrder npcWorkOrder : workOrder.vendor.workOrders) + for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) availableSlots = availableSlots - npcWorkOrder.slots_used; // Single item rolls are msg_size of 0; @@ -287,9 +287,10 @@ public enum ForgeManager implements Runnable { for (int i = 0; i < workOrder.slots_used; ++i) { Item forged_item = forgeItem(workOrder); - ForgeManager.workOrderMap.put(forged_item, workOrder); + ForgeManager.inMemoryItemLookup.put(forged_item.objectUUID, forged_item); workOrder.cooking.add(forged_item); + vendorItemLookup.get(workOrder.vendor).add(forged_item); Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); workOrder.total_produced = workOrder.total_produced + 1; diff --git a/src/engine/net/ItemProductionManager.java b/src/engine/net/ItemProductionManager.java deleted file mode 100644 index 1e8c8ec1..00000000 --- a/src/engine/net/ItemProductionManager.java +++ /dev/null @@ -1,135 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.net; - -import engine.mbEnums.DispatchChannel; -import engine.objects.ProducedItem; -import org.pmw.tinylog.Logger; - -import java.util.HashSet; -import java.util.concurrent.DelayQueue; -import java.util.concurrent.atomic.LongAdder; - -/** - * Thread blocks until MagicBane dispatch messages are - * enqueued then processes them in FIFO order. The collection - * is thread safe. - *

- * Any large messages not time sensitive such as load object - * sent to more than a single individual should be spawned - * individually on a DispatchMessageThread. - */ - - -public enum ItemProductionManager implements Runnable { - - ITEMPRODUCTIONMANAGER; - - - // Instance variables - - @SuppressWarnings("unchecked") // Cannot have arrays of generics in java. - private static final DelayQueue producedQueue = new DelayQueue<>(); - public static volatile long[] messageCount = new long[DispatchChannel.values().length]; - - // Class variables - public static LongAdder[] dispatchCount = new LongAdder[DispatchChannel.values().length]; - - - // Performance metrics - public static volatile long[] maxRecipients = new long[DispatchChannel.values().length]; - public static LongAdder dispatchPoolSize = new LongAdder(); - public static HashSet FailedItems = new HashSet<>(); - public Thread itemProductionThread = null; - private ItemQueue itemQueue; - private long nextFailedItemAudit; - - // Thread constructor - - public static void send(ItemQueue item) { - - // Don't queue up empty dispatches! - - if (item == null) - return; - - producedQueue.add(item); - - } - - public static String getNetstatString() { - - String outString = null; - String newLine = System.getProperty("line.separator"); - outString = "[LUA_NETSTA()]" + newLine; - outString += "poolSize: " + dispatchPoolSize.longValue() + '\n'; - - for (DispatchChannel dispatchChannel : DispatchChannel.values()) { - - outString += "Channel: " + dispatchChannel.name() + '\n'; - outString += "Dispatches: " + dispatchCount[dispatchChannel.getChannelID()].longValue() + '\n'; - outString += "Messages: " + messageCount[dispatchChannel.getChannelID()] + '\n'; - outString += "maxRecipients: " + maxRecipients[dispatchChannel.getChannelID()] + '\n'; - } - return outString; - } - - public void startMessagePump() { - - itemProductionThread = new Thread(this); - itemProductionThread.setName("ItemProductionManager"); - - } - - public void initialize() { - itemProductionThread.start(); - } - - @Override - public void run() { - - - while (true) { - try { - - this.itemQueue = producedQueue.take(); - - if (this.itemQueue == null) { - return; - } - - if (this.itemQueue != null) { - if (this.itemQueue.item == null) { - this.itemQueue.release(); - return; - } - - - boolean created = this.itemQueue.item.finishProduction(); - - if (!created) - FailedItems.add(this.itemQueue.item); - - this.itemQueue.release(); - - - } - - - } catch (Exception e) { - Logger.error(e); - } - - } - } - - // For Debugging: - //Logger.error("MessageDispatcher", messageDispatch.msg.getOpcodeAsString() + " sent to " + messageDispatch.playerList.size() + " players"); -} diff --git a/src/engine/net/ItemQueue.java b/src/engine/net/ItemQueue.java deleted file mode 100644 index e5373324..00000000 --- a/src/engine/net/ItemQueue.java +++ /dev/null @@ -1,86 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.net; - -import engine.objects.ProducedItem; - -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.Delayed; -import java.util.concurrent.TimeUnit; - -import static engine.net.MessageDispatcher.itemPoolSize; - -/** - * Data class holds a message and a distribution list - */ - -public class ItemQueue implements Delayed { - - private static final ConcurrentLinkedQueue itemPool = new ConcurrentLinkedQueue<>(); - - public ProducedItem item; - public long delayTime; - - - public ItemQueue(ProducedItem item, long delayTime) { - this.item = item; - this.delayTime = System.currentTimeMillis() + delayTime; - - } - - public static ItemQueue borrow(ProducedItem item, long delayTime) { - - ItemQueue itemQueue; - - itemQueue = itemPool.poll(); - - if (itemQueue == null) { - itemQueue = new ItemQueue(item, delayTime); - } else { - itemQueue.item = item; - itemQueue.delayTime = System.currentTimeMillis() + delayTime; - itemPoolSize.decrement(); - } - - return itemQueue; - } - - public void reset() { - this.item = null; - this.delayTime = 0; - } - - public void release() { - this.reset(); - itemPool.add(this); - itemPoolSize.increment(); - } - - @Override - public int compareTo(Delayed another) { - ItemQueue anotherTask = (ItemQueue) another; - - if (this.delayTime < anotherTask.delayTime) { - return -1; - } - - if (this.delayTime > anotherTask.delayTime) { - return 1; - } - - return 0; - } - - @Override - public long getDelay(TimeUnit unit) { - long difference = delayTime - System.currentTimeMillis(); - return unit.convert(difference, TimeUnit.MILLISECONDS); - } -} diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index f7386b54..ad926368 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -82,7 +82,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { WorkOrder workOrder = new WorkOrder(); workOrder.total_to_produce = msg.total_to_produce; workOrder.vendor = vendorNPC; - workOrder.templateID = msg.templateID; + workOrder.templateID = msg.itemUUID; workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; workOrder.item_name_override = msg.name; @@ -101,7 +101,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } break; case JUNK: - junkItem(msg.templateID, vendorNPC, origin); + junkItem(msg.itemUUID, vendorNPC, origin); break; case RECYCLE: recycleItem(msg.items, vendorNPC, origin); @@ -110,13 +110,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; case COMPLETE: - vendorNPC.completeItem(msg.templateID); + // todo fix vendorNPC.completeItem(msg.itemUUID); break; case DEPOSIT: - depositItem(msg.templateID, vendorNPC, origin); + depositItem(msg.itemUUID, vendorNPC, origin); break; case SETPRICE: - setItemPrice(msg.itemType, msg.templateID, msg.itemPrice, vendorNPC, origin); + setItemPrice(msg.itemType, msg.itemUUID, msg.itemPrice, vendorNPC, origin); break; case TAKE: takeItem(msg.items, vendorNPC, origin); @@ -364,7 +364,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Delete the item and cancel any pending rolling timer jobs targetItem.recycle(vendor); - vendor.removeItemFromForge(targetItem); + // todo fix vendor.removeItemFromForge(targetItem); // Refresh vendor's inventory to client diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 7dce78ff..98ea5320 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -10,6 +10,7 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; +import engine.gameManager.ForgeManager; import engine.gameManager.PowersManager; import engine.mbEnums; import engine.mbEnums.GameObjectType; @@ -27,7 +28,7 @@ public class ItemProductionMsg extends ClientNetMsg { public int size; public int buildingUUID; public int unknown01; - public int templateID; + public int itemUUID; public int itemType; public int total_to_produce; public int unknown03; @@ -50,7 +51,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.size = 0; this.buildingUUID = 0; this.unknown01 = 0; - this.templateID = 0; + this.itemUUID = 0; this.total_to_produce = 0; this.unknown03 = 0; this.pToken = 0; @@ -70,7 +71,7 @@ public class ItemProductionMsg extends ClientNetMsg { this.buildingUUID = building.getObjectUUID(); this.npcUUID = vendor.getObjectUUID(); this.itemType = item.getObjectType().ordinal(); - this.templateID = item.getObjectUUID(); + this.itemUUID = item.getObjectUUID(); this.unknown01 = 0; this.total_to_produce = 0; this.unknown03 = 0; @@ -128,7 +129,7 @@ public class ItemProductionMsg extends ClientNetMsg { if (!add) { writer.put((byte) 1); - Item item = Item.getFromCache(this.templateID); + Item item = Item.getFromCache(this.itemUUID); if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); @@ -142,12 +143,14 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 1); Item item; - if (this.itemType == GameObjectType.Item.ordinal()) - item = Item.getFromCache(this.templateID); + if (this.itemUUID > 0) + item = Item.getFromCache(this.itemUUID); else - item = MobLoot.getFromCache(this.templateID); + item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); + writer.putInt(building.getStrongboxValue()); writer.putInt(0); writer.putInt(0); @@ -155,7 +158,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case CONFIRM_TAKE: writer.putInt(this.itemType); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -167,7 +170,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case SETPRICE: writer.putInt(this.itemType); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -180,7 +183,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case CONFIRM_SETPRICE: writer.putInt(this.itemType); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -194,7 +197,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case DEPOSIT: writer.putInt(this.itemType); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(1); writer.putInt(0); writer.putInt(0); @@ -234,7 +237,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.putInt(1); - MobLoot toRoll = MobLoot.getFromCache(this.templateID); + MobLoot toRoll = MobLoot.getFromCache(this.itemUUID); writer.putInt(-1497023830); if (toRoll != null && toRoll.getPrefix() != null && !toRoll.getPrefix().isEmpty()) { @@ -262,7 +265,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putString(toRoll.name); writer.putInt(GameObjectType.MobLoot.ordinal()); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(0); //items left to produce? writer.putInt(toRoll.templateID); @@ -306,7 +309,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case COMPLETE: writer.putInt(this.itemType); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(this.total_to_produce); writer.putInt(this.unknown03); writer.putInt(this.pToken); @@ -318,7 +321,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case JUNK: writer.putInt(this.itemType); - writer.putInt(this.templateID); + writer.putInt(this.itemUUID); writer.putInt(this.total_to_produce); writer.putInt(this.unknown03); writer.putInt(this.pToken); @@ -355,7 +358,7 @@ public class ItemProductionMsg extends ClientNetMsg { switch (this.actionType) { case SETPRICE: this.itemType = reader.getInt(); - this.templateID = reader.getInt(); + this.itemUUID = reader.getInt(); reader.getInt(); reader.getInt(); reader.getInt(); @@ -380,15 +383,15 @@ public class ItemProductionMsg extends ClientNetMsg { HashMap tempIDs = new HashMap<>(); for (int i = 0; i < this.size; i++) { int type = reader.getInt(); // Item type padding - this.templateID = reader.getInt(); - tempIDs.put(this.templateID, type); + this.itemUUID = reader.getInt(); + tempIDs.put(this.itemUUID, type); } reader.getInt(); this.items = tempIDs; break; case DEPOSIT: this.itemType = reader.getInt(); - this.templateID = reader.getInt(); + this.itemUUID = reader.getInt(); reader.getInt(); reader.getInt(); reader.getInt(); @@ -400,7 +403,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; case JUNK: this.itemType = reader.getInt(); - this.templateID = reader.getInt(); + this.itemUUID = reader.getInt(); this.total_to_produce = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); @@ -412,7 +415,7 @@ public class ItemProductionMsg extends ClientNetMsg { break; default: this.itemType = reader.getInt(); - this.templateID = reader.getInt(); + this.itemUUID = reader.getInt(); this.total_to_produce = reader.getInt(); this.unknown03 = reader.getInt(); this.pToken = reader.getInt(); diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 3be1d778..c4898efa 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -9,6 +9,7 @@ package engine.net.client.msg; +import engine.gameManager.ForgeManager; import engine.gameManager.NPCManager; import engine.gameManager.PowersManager; import engine.mbEnums.GameObjectType; @@ -435,7 +436,7 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - List itemList = npc.getRolling(); + List itemList = ForgeManager.vendorItemLookup.get(npc); itemList = itemList.stream().limit(npc.getRank()).collect(Collectors.toList()); writer.putInt(itemList.size()); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 4003ff5d..70f2e7d5 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1341,28 +1341,28 @@ public class CharacterItemManager { /* * Delegates */ - public synchronized boolean bankContains(Item i) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == i.getObjectUUID()); - return bank.contains(i); + public synchronized boolean bankContains(Item item) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == item.getObjectUUID()); + return bank.contains(item); } - public synchronized boolean inventoryContains(Item i) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); - return inventory.contains(i); + public synchronized boolean inventoryContains(Item item) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == item.getObjectUUID()); + return inventory.contains(item); } - public synchronized boolean forgeContains(Item i, NPC vendor) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID()); - return vendor.getRolling().contains(i); + public synchronized boolean forgeContains(Item item, NPC vendor) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == item.getObjectUUID()); + return ForgeManager.vendorItemLookup.get(vendor).contains(item); } - public synchronized boolean vaultContains(Item i) { - if (i.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == i.getObjectUUID()); - return this.account.getVault().contains(i); + public synchronized boolean vaultContains(Item item) { + if (item.template.item_type.equals(ItemType.GOLD)) + return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == item.getObjectUUID()); + return this.account.getVault().contains(item); } public synchronized boolean equippedContains(Item i) { diff --git a/src/engine/objects/ItemFactory.java b/src/engine/objects/ItemFactory.java deleted file mode 100644 index b5d937e6..00000000 --- a/src/engine/objects/ItemFactory.java +++ /dev/null @@ -1,1029 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.gameManager.*; -import engine.loot.ModTableEntry; -import engine.loot.ModTypeTableEntry; -import engine.mbEnums; -import engine.mbEnums.ItemContainerType; -import engine.mbEnums.ItemType; -import engine.mbEnums.OwnerType; -import engine.net.ItemProductionManager; -import engine.net.ItemQueue; -import engine.net.client.ClientConnection; -import engine.net.client.msg.ErrorPopupMsg; -import engine.powers.EffectsBase; -import engine.server.MBServerStatics; -import org.joda.time.DateTime; -import org.pmw.tinylog.Logger; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ThreadLocalRandom; - -public class ItemFactory { - - public static void fillInventory(PlayerCharacter pc, int templateID, int count) { - - if (pc == null) - return; - - int max = 20; - CharacterItemManager itemManager = pc.charItemManager; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - if (count > max) - count = max; - - ClientConnection cc = pc.getClientConnection(); - - if (itemManager == null || template == null || cc == null) - return; - - boolean worked; - - for (int i = 0; i < count; i++) { - worked = false; - - if (!itemManager.hasRoomInventory(template.item_wt)) { - if (pc != null) - ChatManager.chatSystemInfo(pc, "You can not carry any more of that item."); - break; - } - - Item item = new Item(templateID); - item.ownerID = pc.getObjectUUID(); - item.ownerType = OwnerType.PlayerCharacter; - item.containerType = ItemContainerType.INVENTORY; - - try { - item = DbManager.ItemQueries.PERSIST(item); - worked = true; - } catch (Exception e) { - Logger.error(e); - } - if (worked) { - itemManager.addItemToInventory(item); - } - } - itemManager.updateInventory(); - } - - public static Item fillForge(NPC npc, PlayerCharacter pc, int itemsToRoll, int templateID, int pToken, int sToken, String customName) { - - String prefixString = ""; - String suffixString = ""; - if (npc == null) - return null; - - boolean useWarehouse = false; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - if (template == null) - return null; - - Building forge = npc.getBuilding(); - - if (forge == null) - return null; - - if (!npc.charItemManager.hasRoomInventory(template.item_wt)) { - if (pc != null) - ErrorPopupMsg.sendErrorPopup(pc, 21); - return null; - } - - Zone zone = npc.getBuilding().getParentZone(); - - if (zone == null) - return null; - - City city = City.getCity(zone.playerCityUUID); - - if (city == null) - return null; - - MobLoot ml = null; - city.transactionLock.writeLock().lock(); - - try { - Warehouse cityWarehouse = city.warehouse; - - if (cityWarehouse != null && forge.assetIsProtected()) - useWarehouse = true; - // ROLL BANE SCROLL. - - if (templateID > 910010 && templateID < 910019) { - ConcurrentHashMap resources = cityWarehouse.resources; - - - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value); - int overdraft = BuildingManager.GetOverdraft(forge, template.item_value); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + template.item_base_name); - return null; - } - - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + " " + template.item_base_name); - return null; - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0) - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - - ml = new MobLoot(npc, template, false); - - ml.containerType = mbEnums.ItemContainerType.FORGE; - ml.setValue(0); - ml.loadEnchantments(); - - float time; - float rank = npc.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); - time = (20 - rate); - time *= MBServerStatics.ONE_MINUTE; - - if (ml.templateID > 910010 && ml.templateID < 910019) { - rank = ml.templateID - 910010; - time = rank * 60 * 60 * 3 * 1000; - - } - - // No job is submitted, as object's upgradetime field - // is used to determin whether or not an object has - // compelted rolling. The game object exists previously - // to this, not when 'compelte' is pressed. - long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - - DateTime dateTime = new DateTime(); - dateTime = dateTime.withMillis(upgradeTime); - ml.setDateToUpgrade(upgradeTime); - - npc.addItemToForge(ml); - - int playerID = 0; - - if (pc != null) - playerID = pc.getObjectUUID(); - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, "", "", "", false, playerID); - ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, false, "", "", "", playerID); - pi.setProducedItemID(ml.getObjectUUID()); - pi.setAmount(itemsToRoll); - pi.setRandom(false); - - ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); - ItemProductionManager.send(produced); - - return ml; - } - - int galvorAmount = 0; - int wormwoodAmount = 0; - int prefixCost = 0; - int suffixCost = 0; - - if (template.item_type.equals(ItemType.WEAPON) && template.item_skill_required.isEmpty() == false && - template.item_skill_required.values().iterator().next() == 110) { - switch (template.item_skill_used) { - case "Bow": - case "Crossbow": - case "Spear": - case "Pole Arm": - case "Staff": - wormwoodAmount = 20; - break; - case "Axe": - case "Dagger": - case "Sword": - case "Hammer": - case "Unarmed Combat": - - if (ItemManager.isTwoHanded(template)) - galvorAmount = 20; - else - galvorAmount = 10; - break; - } - } - - if (galvorAmount > 0 || wormwoodAmount > 0) - if (!useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "This item requires resources to roll! Please make sure the forge is protected to access the warehouse." + template.item_base_name); - return null; - - } - - if (galvorAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GALVOR)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.GALVOR) < galvorAmount) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name); - return null; - } - } - - if (wormwoodAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.WORMWOOD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.WORMWOOD) < wormwoodAmount) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + template.item_base_name); - return null; - } - } - ConcurrentHashMap suffixResourceCosts = null; - ConcurrentHashMap prefixResourceCosts = null; - - EffectsBase prefix = null; - - if (pToken != 0) { - - if (!useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + template.item_base_name); - return null; - } - prefix = PowersManager.getEffectByToken(pToken); - if (prefix == null) - return null; - EffectsBase prefixValue = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); - if (prefixValue == null) - return null; - - int baseCost = template.item_value; - int effectCost = (int) prefixValue.getValue(); - int total = baseCost * 10 + effectCost; - - prefixCost = effectCost; - int overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - prefixResourceCosts = prefix.getResourcesForEffect(); - - for (mbEnums.ResourceType ibResources : prefixResourceCosts.keySet()) { - int warehouseAmount = cityWarehouse.resources.get(ibResources); - int creationAmount = prefixResourceCosts.get(ibResources); - - if (warehouseAmount < creationAmount) - return null; - } - } - EffectsBase suffix = null; - - if (sToken != 0) { - - if (!useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Forge cannot access warehouse! Check to make sure forge is protected." + template.item_base_name); - return null; - } - suffix = PowersManager.getEffectByToken(sToken); - if (suffix == null) - return null; - EffectsBase suffixValue = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); - if (suffixValue == null) - return null; - suffixResourceCosts = suffix.getResourcesForEffect(); - int baseCost = template.item_value; - int effectCost = (int) suffixValue.getValue(); - suffixCost = effectCost; - int total = baseCost * 10 + effectCost; - - - // int buildingWithdraw = Building.GetWithdrawAmountForRolling(forge, total); - int overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - - for (mbEnums.ResourceType ibResources : suffixResourceCosts.keySet()) { - int warehouseAmount = cityWarehouse.resources.get(ibResources); - int creationAmount = suffixResourceCosts.get(ibResources); - - if (warehouseAmount < creationAmount) - return null; - } - } - - //Check if Total suffix and prefix costs + itemCost can be withdrawn. - - int costToCreate = suffixCost + prefixCost + template.item_value; - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate); - - int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); - - if (overdraft > 0 && !useWarehouse) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - // if (pc != null){ - // ChatManager.chatGuildInfo(pc.getGuild(), "Building withdraw = " + buildingWithdraw); - // ChatManager.chatGuildInfo(pc.getGuild(), "Warehouse overdraft withdraw = " + overdraft); - // - // ChatManager.chatGuildInfo(pc.getGuild(), "total withdraw = " + (overdraft + buildingWithdraw)); - // } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0 && useWarehouse) - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - - - if (prefix != null) { - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Cannot Resource Roll without access to the warehouse! Make sure the forge is currently protected." + template.item_base_name); - return null; - } - - - for (mbEnums.ResourceType ibResources : prefixResourceCosts.keySet()) { - - int creationAmount = prefixResourceCosts.get(ibResources); - - if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) - return null; - - int oldAmount = cityWarehouse.resources.get(ibResources); - int amount = creationAmount; - - if (oldAmount < amount) - amount = oldAmount; - - if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) { - //ChatManager.chatGuildError(pc, "Failed to create Item"); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - } - } - - if (suffix != null) { - - for (mbEnums.ResourceType ibResources : suffixResourceCosts.keySet()) { - int creationAmount = suffixResourceCosts.get(ibResources); - - if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) { - ChatManager.chatSystemError(pc, "Resource is locked!" + template.item_base_name); - return null; - } - - int oldAmount = cityWarehouse.resources.get(ibResources); - int amount = creationAmount; - - if (oldAmount < amount) - amount = oldAmount; - - if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) { - //ChatManager.chatGuildError(pc, "Failed to create Item"); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - } - } - - if (prefix == null && suffix == null) { - - int baseCost = template.item_value; - int total = (int) (baseCost + baseCost * (float) .10); - - buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total); - - overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > cityWarehouse.resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0) - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - //ChatManager.chatGuildError(pc, "Failed to create Item"); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + " Failed to Create Item." + template.item_base_name); - return null; - } - - // ChatManager.chatGuildInfo(pc, "Gold Cost = " + total); - - if (galvorAmount > 0) { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GALVOR, galvorAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - - if (wormwoodAmount > 0) { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.WORMWOOD, wormwoodAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - - ml = new MobLoot(npc, template, false); - - ml.containerType = mbEnums.ItemContainerType.FORGE; - - if (customName.isEmpty() == false) - ml.name = customName; - - if (prefix != null) { - ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true); - ml.setPrefix(prefix.getIDString()); - prefixString = prefix.getIDString(); - } - - if (suffix != null) { - ml.addPermanentEnchantment(suffix.getIDString(), 0, 0, false); - ml.setSuffix(suffix.getIDString()); - suffixString = suffix.getIDString(); - } - - ml.loadEnchantments(); - //set value to 0 so magicvalue can be recalculated in getValue. - ml.setValue(0); - - float time; - float rank = npc.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); - time = (20 - rate); - time *= MBServerStatics.ONE_MINUTE; - - if (ml.templateID > 910010 && ml.templateID < 910019) { - rank = ml.templateID - 910010; - time = rank * 60 * 60 * 3 * 1000; - } - - - // No job is submitted, as object's upgradetime field - // is used to determin whether or not an object has - // compelted rolling. The game object exists previously - // to this, not when 'compelte' is pressed. - long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - - DateTime dateTime = new DateTime(); - dateTime = dateTime.withMillis(upgradeTime); - ml.setDateToUpgrade(upgradeTime); - - npc.addItemToForge(ml); - int playerID = 0; - - if (pc != null) - playerID = pc.getObjectUUID(); - - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.templateID, dateTime, prefixString, suffixString, ml.name, false, playerID); - ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.templateID, dateTime, false, prefixString, suffixString, ml.name, playerID); - pi.setProducedItemID(ml.getObjectUUID()); - pi.setAmount(itemsToRoll); - - ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); - ItemProductionManager.send(produced); - } catch (Exception e) { - Logger.error(e); - } finally { - city.transactionLock.writeLock().unlock(); - } - - - // npc.addItemToForge(item); - return ml; - - } - - - public static Item randomRoll(NPC vendor, PlayerCharacter playerCharacter, int itemsToRoll, int templateID) { - byte itemModTable; - int prefixMod = 0; - int suffixMod = 0; - String prefix = ""; - String suffix = ""; - - ModTableEntry prefixEntry = null; - ModTableEntry suffixEntry = null; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - if (template == null) - return null; - - if (!vendor.charItemManager.hasRoomInventory(template.item_wt)) { - - if (playerCharacter != null) - ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full."); - - return null; - } - - itemModTable = (byte) template.modTable; - - if (!vendor.getItemModTable().contains(itemModTable)) { - - if (playerCharacter != null) - ErrorPopupMsg.sendErrorPopup(playerCharacter, 59); - - return null; - } - - for (int temp : vendor.getItemModTable()) { - - if (itemModTable != temp) - continue; - - prefixMod = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(temp)); - suffixMod = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(temp)); - } - - if (prefixMod == 0 && suffixMod == 0) { - Logger.info("Failed to find modTables for item " + template.item_base_name); - return null; - } - - // Roll on the tables for this vendor - - ModTypeTableEntry prefixTypeTable = ModTypeTableEntry.rollTable(prefixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - ModTypeTableEntry suffixTypeTable = ModTypeTableEntry.rollTable(suffixMod, ThreadLocalRandom.current().nextInt(1, 100 + 1)); - - // Sanity check. - - if (prefixTypeTable == null || suffixTypeTable == null) - return null; - - int rollPrefix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - - if (rollPrefix < 80) { - - int randomPrefix = LootManager.TableRoll(vendor.getLevel(), false); - prefixEntry = ModTableEntry.rollTable(prefixTypeTable.modTableID, randomPrefix); - - if (prefixEntry != null) - prefix = prefixEntry.action; - - } - - int rollSuffix = ThreadLocalRandom.current().nextInt(1, 100 + 1); - - // Always have at least one mod on a magic rolled item. - // Suffix will be our backup plan. - - if (rollSuffix < 80 || prefixEntry == null) { - - int randomSuffix = LootManager.TableRoll(vendor.getLevel(), false); - suffixEntry = ModTableEntry.rollTable(suffixTypeTable.modTableID, randomSuffix); - - if (suffixEntry != null) - suffix = suffixEntry.action; - } - - MobLoot toRoll = ItemFactory.produceRandomRoll(vendor, playerCharacter, prefix, suffix, templateID); - - if (toRoll == null) - return null; - - toRoll.setValue(0); - - float time; - float rank = vendor.getBuilding().getRank() - 1; - float rate = (float) (2.5 * rank); - time = (20 - rate); - time *= MBServerStatics.ONE_MINUTE; - - // Bane circles - - if (toRoll.templateID > 910010 && toRoll.templateID < 910019) { - rank = toRoll.templateID - 910010; - time = rank * 60 * 60 * 3 * 1000; - } - - // No job is submitted, as object's upgradetime field - // is used to determine whether an object has - // completed rolling. The game object exists previously - // to this, not when 'complete' is pressed. - - long upgradeTime = System.currentTimeMillis() + (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())); - - DateTime dateTime = new DateTime(); - dateTime = dateTime.withMillis(upgradeTime); - toRoll.setDateToUpgrade(upgradeTime); - - int playerID = 0; - - if (playerCharacter != null) - playerID = playerCharacter.getObjectUUID(); - - DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.templateID, dateTime, prefix, suffix, toRoll.name, true, playerID); - - ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.templateID, dateTime, true, prefix, suffix, toRoll.name, playerID); - pi.setProducedItemID(toRoll.getObjectUUID()); - pi.setAmount(itemsToRoll); - ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); - ItemProductionManager.send(produced); - - return toRoll; - } - - public static MobLoot produceRandomRoll(NPC npc, PlayerCharacter pc, String prefixString, String suffixString, int templateID) { - - boolean useWarehouse = false; - - if (npc == null) - return null; - - ItemTemplate template = ItemTemplate.templates.get(templateID); - - Building forge = npc.getBuilding(); - - if (forge == null) - return null; - - Zone zone = npc.getBuilding().getParentZone(); - - if (zone == null) - return null; - - City city = City.getCity(zone.playerCityUUID); - - if (city == null) - return null; - - MobLoot ml = null; - city.transactionLock.writeLock().lock(); - - try { - - - Warehouse cityWarehouse = city.warehouse; - - if (cityWarehouse != null && forge.assetIsProtected()) - useWarehouse = true; - - ConcurrentHashMap resources = null; - - if (useWarehouse) - resources = cityWarehouse.resources; - - int galvorAmount = 0; - int wormwoodAmount = 0; - - if (template.item_type.equals(ItemType.WEAPON) && template.item_skill_required.isEmpty() == false && - template.item_skill_required.values().iterator().next() == 110) { - switch (template.item_skill_used) { - case "Bow": - case "Crossbow": - case "Spear": - case "Pole Arm": - case "Staff": - wormwoodAmount = 22; - break; - case "Axe": - case "Dagger": - case "Sword": - case "Hammer": - case "Unarmed Combat": - - if (ItemManager.isTwoHanded(template)) - galvorAmount = 22; - else - galvorAmount = 11; - break; - } - } - - //Cant roll 110% weapons that require resources if not allowed to use warehouse. - if (galvorAmount > 0 || wormwoodAmount > 0) - if (!useWarehouse) - return null; - - if (galvorAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GALVOR)) { - ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.GALVOR) < galvorAmount) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name); - return null; - } - } - - if (wormwoodAmount > 0) { - if (Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.WORMWOOD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name); - return null; - } - - if (cityWarehouse.resources.get(mbEnums.ResourceType.WORMWOOD) < wormwoodAmount) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name); - return null; - } - } - - EffectsBase prefix = null; - - if (!prefixString.isEmpty()) { - prefix = PowersManager.getEffectByIDString(prefixString); - if (prefix == null) - return null; - } - - int baseCost = template.item_value; - int total = (int) (baseCost + baseCost * .10); - - EffectsBase suffix = null; - - if (!suffixString.isEmpty()) { - suffix = PowersManager.getEffectByIDString(suffixString); - - if (suffix == null) - return null; - } - - //calculate gold costs and remove from the warehouse - if (prefix != null || suffix != null) { - int costToCreate = (int) (template.item_value + template.item_value * .10f); - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate); - int overdraft = BuildingManager.GetOverdraft(forge, costToCreate); - - if (overdraft > 0 && !useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - // there was an overdraft, withdraw the rest from warehouse. - if (overdraft > 0) { - if (pc != null) { - if (!Warehouse.withdraw(cityWarehouse, pc, mbEnums.ResourceType.GOLD, overdraft, false, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } else { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - } - } - - if (prefix == null && suffix == null) { - - int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total); - int overdraft = BuildingManager.GetOverdraft(forge, total); - - if (overdraft > 0 && !useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, mbEnums.ResourceType.GOLD)) { - if (pc != null) - ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name); - return null; - } - - if (useWarehouse && overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name); - return null; - } - - if (!forge.transferGold(-buildingWithdraw, false)) { - overdraft += buildingWithdraw; - - if (!useWarehouse) { - ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name); - return null; - } else { - if (overdraft > resources.get(mbEnums.ResourceType.GOLD)) { - ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name); - return null; - } - } - } - - if (overdraft > 0 && useWarehouse) { - - if (pc != null) { - if (!Warehouse.withdraw(cityWarehouse, pc, mbEnums.ResourceType.GOLD, overdraft, false, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } else { - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GOLD, overdraft, true)) { - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - } - } - - if (galvorAmount > 0 && useWarehouse) { - //ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse"); - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.GALVOR, galvorAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - return null; - } - } - - if (wormwoodAmount > 0 && useWarehouse) { - //ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse"); - if (!Warehouse.withdraw(cityWarehouse, npc, mbEnums.ResourceType.WORMWOOD, wormwoodAmount, true)) { - ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + template.item_base_name); - Logger.error("Warehouse for city " + cityWarehouse.city.getName() + "Failed to Withdrawl "); - - return null; - } - } - - ml = new MobLoot(npc, template, false); - - ml.containerType = mbEnums.ItemContainerType.FORGE; - - if (prefix != null) { - ml.addPermanentEnchantment(prefix.getIDString(), 0, 0, true); - ml.setPrefix(prefix.getIDString()); - } - - if (suffix != null) { - ml.addPermanentEnchantment(suffix.getIDString(), 0, 0, false); - ml.setSuffix(suffix.getIDString()); - } - - ml.loadEnchantments(); - - - ml.setValue(0); - ml.setRandom(true); - npc.addItemToForge(ml); - } catch (Exception e) { - Logger.error(e); - } finally { - city.transactionLock.writeLock().unlock(); - } - return ml; - - } -} diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 58556907..6fd40f84 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -15,7 +15,6 @@ import engine.gameManager.*; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeNPCJob; -import engine.loot.WorkOrder; import engine.math.Bounds; import engine.math.Vector3f; import engine.math.Vector3fImmutable; @@ -24,8 +23,6 @@ import engine.mbEnums.*; import engine.net.ByteBufferWriter; import engine.net.Dispatch; import engine.net.DispatchMessage; -import engine.net.client.msg.ErrorPopupMsg; -import engine.net.client.msg.ItemProductionMsg; import engine.net.client.msg.PetMsg; import engine.net.client.msg.PlaceAssetMsg; import engine.server.MBServerStatics; @@ -50,9 +47,7 @@ public class NPC extends AbstractCharacter { public static HashMap> _pirateNames = new HashMap<>(); // Used for thread safety public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - private final ArrayList rolling = new ArrayList<>(); public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock(); - public ArrayList forgedItems = new ArrayList<>(); public int runeSetID = 0; public int extraRune2 = 0; protected int loadID; @@ -79,7 +74,6 @@ public class NPC extends AbstractCharacter { public int parentZoneUUID; public int equipmentSetID = 0; private int repairCost = 5; - public ArrayList workOrders = new ArrayList<>(); // New NPC constructor. Fill in the blanks and then call // PERSIST. @@ -915,58 +909,6 @@ public class NPC extends AbstractCharacter { this.charItemManager.equipped = loadEquipmentSet(this.equipmentSetID); - try { - - DbManager.NPCQueries.LOAD_ALL_ITEMS_TO_PRODUCE(this); - - for (ProducedItem producedItem : this.forgedItems) { - MobLoot ml = new MobLoot(this, ItemTemplate.templates.get(producedItem.getTemplateID()), false); - - DbManager.NPCQueries.UPDATE_ITEM_ID(producedItem.getID(), currentID, ml.getObjectUUID()); - - if (producedItem.isInForge()) { - - if (producedItem.getPrefix() != null && !producedItem.getPrefix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getPrefix(), 0, 0, true); - ml.setPrefix(producedItem.getPrefix()); - } - - if (producedItem.getSuffix() != null && !producedItem.getSuffix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getSuffix(), 0, 0, false); - ml.setSuffix(producedItem.getSuffix()); - } - - if (!producedItem.isRandom()) - ml.flags.add(ItemFlags.Identified); - - ml.loadEnchantments(); - - ml.setValue(producedItem.getValue()); - ml.setDateToUpgrade(producedItem.getDateToUpgrade().getMillis()); - ml.containerType = mbEnums.ItemContainerType.FORGE; - this.addItemToForge(ml); - - } else { - - if (producedItem.getPrefix() != null && !producedItem.getPrefix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getPrefix(), 0, 0, true); - ml.setPrefix(producedItem.getPrefix()); - } - - if (producedItem.getSuffix() != null && !producedItem.getSuffix().isEmpty()) { - ml.addPermanentEnchantment(producedItem.getSuffix(), 0, 0, false); - ml.setSuffix(producedItem.getSuffix()); - } - - ml.setDateToUpgrade(producedItem.getDateToUpgrade().getMillis()); - ml.containerType = mbEnums.ItemContainerType.INVENTORY; - ml.flags.add(ItemFlags.Identified); - - this.charItemManager.addItemToInventory(ml); - } - ml.setValue(producedItem.getValue()); - } - // Create NPC bounds object Bounds npcBounds = Bounds.borrow(); npcBounds.setBounds(this.getLoc()); @@ -975,9 +917,6 @@ public class NPC extends AbstractCharacter { NPCManager.applyRunesForNPC(this); this.resists.setImmuneToAll(true); - } catch (Exception e) { - Logger.error(e.getMessage()); - } } public void removeFromZone() { @@ -1008,30 +947,6 @@ public class NPC extends AbstractCharacter { this.upgradeDateTime = upgradeDateTime; } - public ArrayList getRolling() { - synchronized (rolling) { - return rolling; - } - } - - public int getRollingCount() { - synchronized (this.rolling) { - return rolling.size(); - } - } - - public void addItemToForge(MobLoot item) { - synchronized (this.rolling) { - this.rolling.add(item); - } - } - - public void removeItemFromForge(Item item) { - synchronized (this.rolling) { - this.rolling.remove(item); - } - } - @Override public Guild getGuild() { if (this.building != null) @@ -1166,109 +1081,6 @@ public class NPC extends AbstractCharacter { return 0; } - public synchronized Item produceItem(int playerID, int amount, boolean isRandom, int pToken, int sToken, String customName, int itemID) { - - Zone serverZone; - City city; - Item item = null; - - PlayerCharacter player = null; - - if (playerID != 0) - player = SessionManager.getPlayerCharacterByID(playerID); - - try { - - if (this.getRollingCount() >= this.getRank()) { - - if (player != null) - ChatManager.chatSystemInfo(player, this.getName() + " " + this.getContract().getName() + " slots are full"); - - return null; - } - - // Cannot roll items without a warehouse. - // Due to the fact fillForge references the - // warehouse and early exits. *** Refactor??? - - serverZone = this.building.getParentZone(); - - if (serverZone == null) - return null; - - city = City.GetCityFromCache(serverZone.playerCityUUID); - - if (city == null) { - - if (player != null) - ErrorPopupMsg.sendErrorMsg(player, "Could not find city."); // Production denied: This building must be protected to gain access to warehouse resources. - - return null; - } - - if (this.building == null) { - - if (player != null) - ErrorPopupMsg.sendErrorMsg(player, "Could not find building."); // Production denied: This building must be protected to gain ac - - return null; - } - - //TODO create Normal Items. - - if (amount == 0) - amount = 1; - - if (isRandom) - item = ItemFactory.randomRoll(this, player, amount, itemID); - else - item = ItemFactory.fillForge(this, player, amount, itemID, pToken, sToken, customName); - - if (item == null) - return null; - - ItemProductionMsg outMsg = new ItemProductionMsg(this.building, this, item, 8, true); - DispatchMessage.dispatchMsgToInterestArea(this, outMsg, DispatchChannel.SECONDARY, 700, false, false); - - } catch (Exception e) { - Logger.error(e); - } - return item; - } - - public synchronized boolean completeItem(int itemUUID) { - - MobLoot targetItem; - - try { - targetItem = MobLoot.getFromCache(itemUUID); - - if (targetItem == null) - return false; - - if (!this.charItemManager.forgeContains(targetItem, this)) - return false; - - if (!DbManager.NPCQueries.UPDATE_ITEM_TO_INVENTORY(targetItem.getObjectUUID(), currentID)) - return false; - - targetItem.flags.add(ItemFlags.Identified); - - this.rolling.remove(targetItem); - this.charItemManager.addItemToInventory(targetItem); - - //remove from client forge window - - ItemProductionMsg outMsg1 = new ItemProductionMsg(this.building, this, targetItem, 9, true); - DispatchMessage.dispatchMsgToInterestArea(this, outMsg1, DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); - ItemProductionMsg outMsg = new ItemProductionMsg(this.building, this, targetItem, 10, true); - DispatchMessage.dispatchMsgToInterestArea(this, outMsg, DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); - - } catch (Exception e) { - Logger.error(e.getMessage()); - } - return true; - } public int getEquipmentSetID() { return equipmentSetID; diff --git a/src/engine/objects/ProducedItem.java b/src/engine/objects/ProducedItem.java deleted file mode 100644 index e999fb44..00000000 --- a/src/engine/objects/ProducedItem.java +++ /dev/null @@ -1,225 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.objects; - -import engine.gameManager.PowersManager; -import engine.mbEnums.DispatchChannel; -import engine.net.DispatchMessage; -import engine.net.client.msg.ItemProductionMsg; -import engine.powers.EffectsBase; -import org.joda.time.DateTime; -import org.pmw.tinylog.Logger; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Date; - -public class ProducedItem { - - private int ID; - private int npcUID; - private int templateID; - private DateTime dateToUpgrade; - private boolean isRandom; - - private String prefix; - private String suffix; - private String name; - private int amount; - private int producedItemID = 0; - private boolean inForge; - private int value; - - private int playerID; - - - /** - * ResultSet Constructor - */ - - public ProducedItem(ResultSet rs) throws SQLException { - this.ID = rs.getInt("ID"); - this.npcUID = rs.getInt("npcUID"); - this.templateID = rs.getInt("templateID"); - - Date sqlDateTime = rs.getTimestamp("dateToUpgrade"); - - if (sqlDateTime != null) - this.dateToUpgrade = new DateTime(sqlDateTime); - else - dateToUpgrade = null; - this.isRandom = rs.getBoolean("isRandom"); - this.prefix = rs.getString("prefix"); - this.suffix = rs.getString("suffix"); - this.name = rs.getString("name"); - this.inForge = rs.getBoolean("inForge"); - this.value = rs.getInt("value"); - this.playerID = rs.getInt("playerID"); - } - - public ProducedItem(int ID, int npcUID, int templateID, DateTime dateToUpgrade, boolean isRandom, String prefix, String suffix, String name, int playerID) { - super(); - this.ID = ID; - this.npcUID = npcUID; - this.templateID = templateID; - this.dateToUpgrade = dateToUpgrade; - this.isRandom = isRandom; - this.prefix = prefix; - this.suffix = suffix; - this.name = name; - this.value = 0; - this.playerID = playerID; - - - } - - public int getNpcUID() { - return npcUID; - } - - public DateTime getDateToUpgrade() { - return dateToUpgrade; - } - - public int getTemplateID() { - return templateID; - } - - public void setTemplateID(int templateID) { - this.templateID = templateID; - } - - public boolean isRandom() { - return isRandom; - } - - public void setRandom(boolean isRandom) { - this.isRandom = isRandom; - } - - public String getPrefix() { - return prefix; - } - - public String getSuffix() { - return suffix; - } - - public void setSuffix(String suffix) { - this.suffix = suffix; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getID() { - return ID; - } - - public void setID(int iD) { - ID = iD; - } - - public int getAmount() { - return amount; - } - - public void setAmount(int amount) { - this.amount = amount; - } - - - public int getProducedItemID() { - return producedItemID; - } - - public void setProducedItemID(int producedItemID) { - this.producedItemID = producedItemID; - } - - public boolean isInForge() { - return inForge; - } - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - - public boolean finishProduction() { - NPC npc = NPC.getFromCache(this.getNpcUID()); - - if (npc == null) - return false; - - - //update the client to ID the item in the window when item finishes rolling. - //If there is more than 1 item left to roll, complete the item and throw it in inventory - //and reproduce next item. - - try { - - if (this.getAmount() > 1) { - this.setAmount(this.getAmount() - 1); - npc.completeItem(this.getProducedItemID()); - - int pToken = 0; - int sToken = 0; - - if (!this.isRandom()) { - EffectsBase eb = PowersManager.getEffectByIDString(this.getPrefix()); - if (eb != null) - pToken = eb.getToken(); - eb = PowersManager.getEffectByIDString(this.getSuffix()); - if (eb != null) - sToken = eb.getToken(); - - } - - Item item = npc.produceItem(0, this.getAmount(), this.isRandom(), pToken, sToken, this.getName(), this.getTemplateID()); - - if (item == null) - return false; - - } else { - - //update item to complete - MobLoot targetItem = MobLoot.getFromCache(this.getProducedItemID()); - - if (targetItem == null) - return false; - - ItemProductionMsg outMsg = new ItemProductionMsg(npc.getBuilding(), npc, targetItem, 8, true); - - - DispatchMessage.dispatchMsgToInterestArea(npc, outMsg, DispatchChannel.SECONDARY, 700, false, false); - } - - } catch (Exception e) { - Logger.error(e); - return false; - } - return true; - } - - public int getPlayerID() { - return playerID; - } - - -} diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 9895e271..ed45878a 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -26,7 +26,6 @@ import engine.mbEnums.SupportMsgType; import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.Respawner; import engine.net.DispatchMessage; -import engine.net.ItemProductionManager; import engine.net.Network; import engine.net.Protocol; import engine.net.client.ClientConnection; @@ -267,9 +266,6 @@ public class WorldServer { Logger.info("Setting cross server session behavior"); SessionManager.setCrossServerBehavior(1); // Sets cross server behavior - Logger.info("Starting Item Production thread"); - ItemProductionManager.ITEMPRODUCTIONMANAGER.startMessagePump(); - Logger.info("Initializing Errant Guild"); Guild.getErrantGuild(); @@ -427,8 +423,6 @@ public class WorldServer { //pick a startup Hotzone ZoneManager.generateAndSetRandomHotzone(); - ItemProductionManager.ITEMPRODUCTIONMANAGER.initialize(); - Logger.info("Loading Player Heraldries"); DbManager.PlayerCharacterQueries.LOAD_HERALDY(); From 673f606de8a95bbbb041fb176be85700b899c9da Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:00:25 -0400 Subject: [PATCH 120/378] Cleanup of cache usage --- src/engine/gameManager/ForgeManager.java | 8 +++++++- src/engine/loot/WorkOrder.java | 4 ---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ba456e29..93fc2b19 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -287,10 +287,16 @@ public enum ForgeManager implements Runnable { for (int i = 0; i < workOrder.slots_used; ++i) { Item forged_item = forgeItem(workOrder); + + // Add item to in-memory caches + ForgeManager.inMemoryItemLookup.put(forged_item.objectUUID, forged_item); - workOrder.cooking.add(forged_item); + ForgeManager.vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); + + ForgeManager.vendorItemLookup.get(workOrder.vendor).add(forged_item); vendorItemLookup.get(workOrder.vendor).add(forged_item); + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); workOrder.total_produced = workOrder.total_produced + 1; diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index adb0de6c..0cae3497 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -9,14 +9,12 @@ package engine.loot; import engine.mbEnums; -import engine.objects.Item; import engine.objects.NPC; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -40,8 +38,6 @@ public class WorkOrder implements Delayed { public boolean runCompleted = false; public boolean runCanceled = false; - public ArrayList cooking = new ArrayList<>(); - public WorkOrder() { } From 139998eaa15b6edb75ae75119469379b24ce2b30 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:02:52 -0400 Subject: [PATCH 121/378] Moved declaration outside of loop --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 93fc2b19..b500535e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -39,9 +39,9 @@ public enum ForgeManager implements Runnable { public void run() { - while (true) { + WorkOrder workOrder = null; - WorkOrder workOrder = null; + while (true) { try { workOrder = forge.take(); From 48f88ec819e2550acd24e53c868f7868ebcaaa68 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:11:10 -0400 Subject: [PATCH 122/378] Serialization update --- src/engine/net/client/msg/ManageNPCMsg.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index c4898efa..b0c9f5e8 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -27,8 +27,6 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashSet; -import java.util.List; -import java.util.stream.Collectors; /** * Order NPC @@ -436,12 +434,13 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - List itemList = ForgeManager.vendorItemLookup.get(npc); - itemList = itemList.stream().limit(npc.getRank()).collect(Collectors.toList()); + // Sanity check. - writer.putInt(itemList.size()); + ForgeManager.vendorItemLookup.computeIfAbsent(npc, k -> new ArrayList<>()); // Forge lookup - for (Item item : itemList) { + writer.putInt(ForgeManager.vendorItemLookup.get(npc).size()); + + for (Item item : ForgeManager.vendorItemLookup.get(npc)) { writer.put((byte) 0); // ? Unknown45 writer.putInt(item.getObjectType().ordinal()); From 85e5e2a7e35beabbc0f8024a9bb903bbcb7cb66a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:17:32 -0400 Subject: [PATCH 123/378] Init forge support only for valid contracts --- src/engine/net/client/msg/ManageNPCMsg.java | 4 ---- src/engine/objects/NPC.java | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index b0c9f5e8..2b54b69d 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -434,10 +434,6 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - // Sanity check. - - ForgeManager.vendorItemLookup.computeIfAbsent(npc, k -> new ArrayList<>()); // Forge lookup - writer.putInt(ForgeManager.vendorItemLookup.get(npc).size()); for (Item item : ForgeManager.vendorItemLookup.get(npc)) { diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 6fd40f84..7bca7160 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -869,6 +869,11 @@ public class NPC extends AbstractCharacter { if (this.building != null) NPCManager.slotCharacterInBuilding(this); + // If NPC is a vendor create arraylist for forge + + if (this.contract.isTrainer() == false) + ForgeManager.vendorItemLookup.computeIfAbsent(this, k -> new ArrayList<>()); // Forge lookup + this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); this.modSuffixTable = this.contract.getNpcModSuffixTable(); From 73fa5b5c7e374d09ca5d6abe9a79d484d15878b0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:19:55 -0400 Subject: [PATCH 124/378] Support for non-random rolling --- src/engine/gameManager/ForgeManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b500535e..a4c251e4 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -270,9 +270,13 @@ public enum ForgeManager implements Runnable { if (workOrder.prefixToken == 0) forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); + else + forgedItem.prefixToken = workOrder.prefixToken; if (workOrder.suffixToken == 0) forgedItem.suffixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.SUFFIX, template.modTable); + else + forgedItem.suffixToken = workOrder.suffixToken; // Forged random rolled items are unidentified until completed From d95bc5c261b7c784e6fec2e63f8822fe2c282370 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:30:10 -0400 Subject: [PATCH 125/378] Initialize all collections for npc --- src/engine/objects/NPC.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 7bca7160..5c22b4db 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -869,10 +869,12 @@ public class NPC extends AbstractCharacter { if (this.building != null) NPCManager.slotCharacterInBuilding(this); - // If NPC is a vendor create arraylist for forge + // If NPC is a vendor then configure ForgeManager support - if (this.contract.isTrainer() == false) + if (this.contract.isTrainer() == false) { ForgeManager.vendorItemLookup.computeIfAbsent(this, k -> new ArrayList<>()); // Forge lookup + ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new ArrayList<>()); + } this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); From 114aeb9f642d18ef0a03796616804227219f1934 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:38:24 -0400 Subject: [PATCH 126/378] Update NPC window --- src/engine/gameManager/ForgeManager.java | 7 +++++++ .../net/client/handlers/ItemProductionMsgHandler.java | 1 + 2 files changed, 8 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a4c251e4..56efd89c 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -12,6 +12,8 @@ import engine.loot.ModTableEntry; import engine.loot.ModTypeTableEntry; import engine.loot.WorkOrder; import engine.mbEnums; +import engine.net.DispatchMessage; +import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; import engine.powers.poweractions.AbstractPowerAction; @@ -302,6 +304,11 @@ public enum ForgeManager implements Runnable { vendorItemLookup.get(workOrder.vendor).add(forged_item); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); + // Update NPC window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, forged_item, 8, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); workOrder.total_produced = workOrder.total_produced + 1; } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index ad926368..b5645cf9 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -99,6 +99,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ErrorPopupMsg.sendErrorPopup(player, validation_result); return true; } + break; case JUNK: junkItem(msg.itemUUID, vendorNPC, origin); From e195d86fb662066c331970ae8a9d3a33825c08af Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 15:49:08 -0400 Subject: [PATCH 127/378] Serialization update --- .../net/client/msg/ItemProductionMsg.java | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 98ea5320..78371605 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -11,15 +11,12 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; import engine.gameManager.ForgeManager; -import engine.gameManager.PowersManager; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.net.*; import engine.objects.Building; import engine.objects.Item; -import engine.objects.MobLoot; import engine.objects.NPC; -import engine.powers.EffectsBase; import java.util.HashMap; @@ -237,25 +234,13 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.putInt(1); - MobLoot toRoll = MobLoot.getFromCache(this.itemUUID); + Item toRoll = ForgeManager.inMemoryItemLookup.get(this.itemUUID); writer.putInt(-1497023830); - if (toRoll != null && toRoll.getPrefix() != null && !toRoll.getPrefix().isEmpty()) { - EffectsBase eb = PowersManager.getEffectByIDString(toRoll.getPrefix()); - if (eb == null) - this.pToken = 0; - else - this.pToken = eb.getToken(); - } + this.pToken = toRoll.prefixToken; + this.sToken = toRoll.suffixToken; - if (toRoll != null && toRoll.getSuffix() != null && !toRoll.getSuffix().isEmpty()) { - EffectsBase eb = PowersManager.getEffectByIDString(toRoll.getSuffix()); - if (eb == null) - this.sToken = 0; - else - this.sToken = eb.getToken(); - } - if (toRoll.isRandom() == false || (toRoll != null && toRoll.isComplete())) { + if (toRoll.isComplete()) { writer.putInt(this.pToken); writer.putInt(this.sToken); } else { From d5bd500f39203090fbfd8feedb106073a7f73a2e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 16:29:17 -0400 Subject: [PATCH 128/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 41 ++++++++++++++++-------- src/engine/loot/WorkOrder.java | 3 ++ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 56efd89c..5b699ef4 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -62,25 +62,40 @@ public enum ForgeManager implements Runnable { if (workOrder.runCanceled || workOrder.runCompleted) continue; - // Create in memory items to add to collections + // Persist current items that are currently cooking for this + // workOrder - forgeItems(workOrder); + ArrayList toRemove = new ArrayList<>(); - Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + for (Item cooked_item : workOrder.cooking) { + toRemove.add(cooked_item); + cooked_item.containerType = mbEnums.ItemContainerType.INVENTORY; + Item completed_item = DbManager.ItemQueries.PERSIST(cooked_item); + workOrder.vendor.charItemManager.addItemToInventory(completed_item); + } - if (workOrder.total_produced >= workOrder.total_to_produce) { + // Remove the fake negativeID item from all collections. - Logger.info("workOrder has completed: " + workOrder.workOrderID); + for (Item memoryItem : toRemove) { + workOrder.cooking.remove(memoryItem); + inMemoryItemLookup.remove(memoryItem.objectUUID); + vendorItemLookup.get(workOrder.vendor).remove(memoryItem); + } + + Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); - // Persist current items that are currently building for this - // worker after first removing the negative id item from all - // collections. + if (workOrder.total_produced >= workOrder.total_to_produce) { + Logger.info("workOrder has completed: " + workOrder.workOrderID); workOrder.runCompleted = true; continue; } + // Create new set in memory items + + forgeItems(workOrder); + // enQueue this workOrder again; back into the oven // until all items for this workOrder are completed. @@ -296,13 +311,13 @@ public enum ForgeManager implements Runnable { // Add item to in-memory caches - ForgeManager.inMemoryItemLookup.put(forged_item.objectUUID, forged_item); - - ForgeManager.vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); + workOrder.cooking.add(forged_item); - ForgeManager.vendorItemLookup.get(workOrder.vendor).add(forged_item); + inMemoryItemLookup.put(forged_item.objectUUID, forged_item); + vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); + vendorItemLookup.get(workOrder.vendor).add(forged_item); vendorItemLookup.get(workOrder.vendor).add(forged_item); - ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); + vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); // Update NPC window diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 0cae3497..5bfc1f84 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -9,12 +9,14 @@ package engine.loot; import engine.mbEnums; +import engine.objects.Item; import engine.objects.NPC; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; +import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -37,6 +39,7 @@ public class WorkOrder implements Delayed { public long completionTime; public boolean runCompleted = false; public boolean runCanceled = false; + public ArrayList cooking = new ArrayList<>(); public WorkOrder() { From 692ee51608c94ebd8ecfc7b0815d6a9111601054 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 16:31:05 -0400 Subject: [PATCH 129/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 5b699ef4..3f73fe54 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -21,6 +21,7 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; +import java.util.Objects; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; import java.util.concurrent.ThreadLocalRandom; @@ -51,15 +52,9 @@ public enum ForgeManager implements Runnable { Logger.error(e); } - // Null workOrders should not exist. - // Perhaps log? - - if (workOrder == null) - continue; - // Completed or canceled work orders are not re-enqueued - if (workOrder.runCanceled || workOrder.runCompleted) + if (Objects.requireNonNull(workOrder).runCanceled || workOrder.runCompleted) continue; // Persist current items that are currently cooking for this From 8b4b3b971a7bbce97feb0ac626cbe7df4e77285c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 16:46:31 -0400 Subject: [PATCH 130/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 3f73fe54..0fbb5ae3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -61,11 +61,12 @@ public enum ForgeManager implements Runnable { // workOrder ArrayList toRemove = new ArrayList<>(); + Item completed_item = null; for (Item cooked_item : workOrder.cooking) { toRemove.add(cooked_item); cooked_item.containerType = mbEnums.ItemContainerType.INVENTORY; - Item completed_item = DbManager.ItemQueries.PERSIST(cooked_item); + completed_item = DbManager.ItemQueries.PERSIST(cooked_item); workOrder.vendor.charItemManager.addItemToInventory(completed_item); } @@ -78,8 +79,12 @@ public enum ForgeManager implements Runnable { vendorItemLookup.get(workOrder.vendor).remove(memoryItem); } - Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + // Update vendor window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completed_item, 8, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); if (workOrder.total_produced >= workOrder.total_to_produce) { Logger.info("workOrder has completed: " + workOrder.workOrderID); From a16bef418bb3856dba84d13cc34b59cc7bc07a80 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 17:02:36 -0400 Subject: [PATCH 131/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0fbb5ae3..b9de1aa7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -72,18 +72,20 @@ public enum ForgeManager implements Runnable { } // Remove the fake negativeID item from all collections. + // set the items as 'completed' for (Item memoryItem : toRemove) { + + // Update vendor window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completed_item, 8, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.cooking.remove(memoryItem); inMemoryItemLookup.remove(memoryItem.objectUUID); vendorItemLookup.get(workOrder.vendor).remove(memoryItem); } - // Update vendor window - - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completed_item, 8, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); if (workOrder.total_produced >= workOrder.total_to_produce) { From aac7e46ae88b28f5da0c221619ee8943be2bb7ed Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 17:04:59 -0400 Subject: [PATCH 132/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b9de1aa7..a5199a16 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -78,7 +78,7 @@ public enum ForgeManager implements Runnable { // Update vendor window - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completed_item, 8, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, 8, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.cooking.remove(memoryItem); From 2690c3212bf01b81450955a13b2a05b7f992f22f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 17:18:58 -0400 Subject: [PATCH 133/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a5199a16..0437e955 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -17,6 +17,7 @@ import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; import engine.powers.poweractions.AbstractPowerAction; +import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -76,10 +77,12 @@ public enum ForgeManager implements Runnable { for (Item memoryItem : toRemove) { - // Update vendor window + // Update vendor windows - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, 8, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, 9, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, 10, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); workOrder.cooking.remove(memoryItem); inMemoryItemLookup.remove(memoryItem.objectUUID); From e1a9ddae8999251dd6e55c595082dba2e6f1f8e6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 17:30:35 -0400 Subject: [PATCH 134/378] forged items are persisted --- src/engine/gameManager/ForgeManager.java | 6 ++---- .../client/handlers/ItemProductionMsgHandler.java | 14 +++++++------- src/engine/net/client/msg/ItemProductionMsg.java | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0437e955..c4a8f085 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -79,10 +79,8 @@ public enum ForgeManager implements Runnable { // Update vendor windows - ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, 9, true); + ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.COMPLETE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, 10, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); workOrder.cooking.remove(memoryItem); inMemoryItemLookup.remove(memoryItem.objectUUID); @@ -326,7 +324,7 @@ public enum ForgeManager implements Runnable { // Update NPC window - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, forged_item, 8, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, forged_item, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index b5645cf9..54471192 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -155,11 +155,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } else if (targetItem.getObjectType() == GameObjectType.MobLoot) { @@ -169,11 +169,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } @@ -230,11 +230,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; } - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); @@ -313,7 +313,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { totalValue += itemValue; vendor.charItemManager.recycle(targetItem); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE.ordinal(), true); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.TAKE, true); dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 78371605..4651ffba 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -61,9 +61,9 @@ public class ItemProductionMsg extends ClientNetMsg { ; - public ItemProductionMsg(Building building, NPC vendor, Item item, int actionType, boolean add) { + public ItemProductionMsg(Building building, NPC vendor, Item item, mbEnums.ProductionActionType actionType, boolean add) { super(Protocol.ITEMPRODUCTION); - this.actionType = mbEnums.ProductionActionType.values()[actionType]; + this.actionType = actionType; this.size = 0; this.buildingUUID = building.getObjectUUID(); this.npcUUID = vendor.getObjectUUID(); From 9dbefcd830505d2e71f6fb25fa16d693db62dde3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:01:53 -0400 Subject: [PATCH 135/378] Unused variable removed --- src/engine/gameManager/ForgeManager.java | 36 ++++--------------- .../handlers/ItemProductionMsgHandler.java | 4 --- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c4a8f085..f97450bb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -17,7 +17,6 @@ import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; import engine.powers.poweractions.AbstractPowerAction; -import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -58,38 +57,18 @@ public enum ForgeManager implements Runnable { if (Objects.requireNonNull(workOrder).runCanceled || workOrder.runCompleted) continue; - // Persist current items that are currently cooking for this - // workOrder - - ArrayList toRemove = new ArrayList<>(); - Item completed_item = null; - - for (Item cooked_item : workOrder.cooking) { - toRemove.add(cooked_item); - cooked_item.containerType = mbEnums.ItemContainerType.INVENTORY; - completed_item = DbManager.ItemQueries.PERSIST(cooked_item); - - workOrder.vendor.charItemManager.addItemToInventory(completed_item); - } - - // Remove the fake negativeID item from all collections. - // set the items as 'completed' - - for (Item memoryItem : toRemove) { + Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); - // Update vendor windows + // Complete this workOrder. Persist items currently in memory + // and set the items as completed. - ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.COMPLETE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, MBServerStatics.STRUCTURE_LOAD_RANGE, false, false); + if (workOrder.total_produced >= workOrder.total_to_produce) { - workOrder.cooking.remove(memoryItem); - inMemoryItemLookup.remove(memoryItem.objectUUID); - vendorItemLookup.get(workOrder.vendor).remove(memoryItem); - } + for (Item workOrderItem : workOrder.cooking) { + workOrderItem.setDateToUpgrade(0); - Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); + } - if (workOrder.total_produced >= workOrder.total_to_produce) { Logger.info("workOrder has completed: " + workOrder.workOrderID); workOrder.runCompleted = true; continue; @@ -319,7 +298,6 @@ public enum ForgeManager implements Runnable { inMemoryItemLookup.put(forged_item.objectUUID, forged_item); vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); vendorItemLookup.get(workOrder.vendor).add(forged_item); - vendorItemLookup.get(workOrder.vendor).add(forged_item); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); // Update NPC window diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 54471192..ae2dd5cb 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -72,10 +72,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { switch (msg.actionType) { case PRODUCE: - boolean isRandom = false; - - if (msg.unknown03 != 0 && msg.pToken == 0 && msg.sToken == 0) - isRandom = true; // Create new work order From 1be657d3ef0b194ce03b7a91485a21ad7d696fd5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:07:26 -0400 Subject: [PATCH 136/378] Persist item work --- src/engine/gameManager/ForgeManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f97450bb..a4a9048a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -59,11 +59,11 @@ public enum ForgeManager implements Runnable { Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); - // Complete this workOrder. Persist items currently in memory - // and set the items as completed. - if (workOrder.total_produced >= workOrder.total_to_produce) { + // Complete this workOrder. Persist items currently in memory + // and set the items as completed. + for (Item workOrderItem : workOrder.cooking) { workOrderItem.setDateToUpgrade(0); From 5ade37f7a4d36665aa8adb3ca3aa2e8b12049117 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:15:34 -0400 Subject: [PATCH 137/378] Persist item work --- src/engine/gameManager/ForgeManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a4a9048a..0bf3562f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -66,7 +66,8 @@ public enum ForgeManager implements Runnable { for (Item workOrderItem : workOrder.cooking) { workOrderItem.setDateToUpgrade(0); - + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } Logger.info("workOrder has completed: " + workOrder.workOrderID); From 2b670ea53a7ab06941460d3f30a47dd11a736ab5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:17:10 -0400 Subject: [PATCH 138/378] Persist item work --- src/engine/gameManager/ForgeManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0bf3562f..ed43815c 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -65,7 +65,6 @@ public enum ForgeManager implements Runnable { // and set the items as completed. for (Item workOrderItem : workOrder.cooking) { - workOrderItem.setDateToUpgrade(0); ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } From 9ba697c3106ef553d5514c219da3ec9deb911e3a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:30:56 -0400 Subject: [PATCH 139/378] Persist item work --- src/engine/gameManager/ForgeManager.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ed43815c..616aeea7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -61,8 +61,7 @@ public enum ForgeManager implements Runnable { if (workOrder.total_produced >= workOrder.total_to_produce) { - // Complete this workOrder. Persist items currently in memory - // and set the items as completed. + // Complete this workOrder. for (Item workOrderItem : workOrder.cooking) { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); @@ -71,7 +70,22 @@ public enum ForgeManager implements Runnable { Logger.info("workOrder has completed: " + workOrder.workOrderID); workOrder.runCompleted = true; + } + + if (workOrder.runCompleted == true) continue; + ; + + // Persist items that were currently cooking + + for (Item workOrderItem : workOrder.cooking) { + // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + } // Create new set in memory items From a4af39cab7ef937c5cb0d6bfc6bd2eb51666e9a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:45:38 -0400 Subject: [PATCH 140/378] Window serialization work --- src/engine/gameManager/ForgeManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 616aeea7..9b247041 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -79,8 +79,6 @@ public enum ForgeManager implements Runnable { // Persist items that were currently cooking for (Item workOrderItem : workOrder.cooking) { - // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); - // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); From d71c65702d470534553495f7b881503580d2c0c9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:49:42 -0400 Subject: [PATCH 141/378] Window serialization work --- src/engine/gameManager/ForgeManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9b247041..75a4c0e5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -79,9 +79,7 @@ public enum ForgeManager implements Runnable { // Persist items that were currently cooking for (Item workOrderItem : workOrder.cooking) { - ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.TAKE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } From 0c9ec31fa3b54eb274d42477e5ba13c7aa88dab3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 11:53:24 -0400 Subject: [PATCH 142/378] Window serialization work --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 75a4c0e5..8f93dd2e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -79,8 +79,8 @@ public enum ForgeManager implements Runnable { // Persist items that were currently cooking for (Item workOrderItem : workOrder.cooking) { - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.TAKE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.TAKE, true); + // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } From 5505d7bc613305b0a7660cc562533464dedad9ed Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:12:40 -0400 Subject: [PATCH 143/378] Items are persisted and moved to vendor inventory --- src/engine/gameManager/ForgeManager.java | 38 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 8f93dd2e..8fb7340e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -74,15 +74,10 @@ public enum ForgeManager implements Runnable { if (workOrder.runCompleted == true) continue; - ; // Persist items that were currently cooking - for (Item workOrderItem : workOrder.cooking) { - // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.TAKE, true); - // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - } + persistItems(workOrder); // Create new set in memory items @@ -295,6 +290,37 @@ public enum ForgeManager implements Runnable { return forgedItem; } + public static void persistItems(WorkOrder workOrder) { + + ArrayList toRemove = new ArrayList<>(); + Item completed_item; + + for (Item workOrderItem : workOrder.cooking) { + + toRemove.add(workOrderItem); + workOrderItem.containerType = mbEnums.ItemContainerType.INVENTORY; + completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); + + workOrder.vendor.charItemManager.addItemToInventory(completed_item); + + // Remove the fake negativeID item from all collections. + // set the items as 'completed' + + for (Item memoryItem : toRemove) { + + workOrder.cooking.remove(memoryItem); + inMemoryItemLookup.remove(memoryItem.objectUUID); + vendorItemLookup.get(workOrder.vendor).remove(memoryItem); + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + } + + } + + } public static void forgeItems(WorkOrder workOrder) { for (int i = 0; i < workOrder.slots_used; ++i) { From 963df074a41bb6fe66465030491e45f8c319848d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:17:57 -0400 Subject: [PATCH 144/378] More persist work --- src/engine/gameManager/ForgeManager.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 8fb7340e..a19f284b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -302,22 +302,20 @@ public enum ForgeManager implements Runnable { completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); workOrder.vendor.charItemManager.addItemToInventory(completed_item); - + } // Remove the fake negativeID item from all collections. // set the items as 'completed' - for (Item memoryItem : toRemove) { + for (Item memoryItem : toRemove) { - workOrder.cooking.remove(memoryItem); - inMemoryItemLookup.remove(memoryItem.objectUUID); - vendorItemLookup.get(workOrder.vendor).remove(memoryItem); - - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - } + workOrder.cooking.remove(memoryItem); + inMemoryItemLookup.remove(memoryItem.objectUUID); + vendorItemLookup.get(workOrder.vendor).remove(memoryItem); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } } From 7f3873b63fbf6a6f7cee5d5594deb8807425fe8d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:23:01 -0400 Subject: [PATCH 145/378] fail fast on null --- src/engine/net/client/msg/ItemProductionMsg.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 4651ffba..8e7a4d8e 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -145,8 +145,7 @@ public class ItemProductionMsg extends ClientNetMsg { else item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); - if (item != null) - Item.serializeForClientMsgWithoutSlot(item, writer); + Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); writer.putInt(0); From d007850afec26b4bc4a080f04364843b827b7264 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:23:46 -0400 Subject: [PATCH 146/378] Clear collections last --- src/engine/gameManager/ForgeManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a19f284b..708fd902 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -308,14 +308,14 @@ public enum ForgeManager implements Runnable { for (Item memoryItem : toRemove) { - workOrder.cooking.remove(memoryItem); - inMemoryItemLookup.remove(memoryItem.objectUUID); - vendorItemLookup.get(workOrder.vendor).remove(memoryItem); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + workOrder.cooking.remove(memoryItem); + inMemoryItemLookup.remove(memoryItem.objectUUID); + vendorItemLookup.get(workOrder.vendor).remove(memoryItem); } } From cd8b91026251e8bceea3e5621b136dc367a44600 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:31:16 -0400 Subject: [PATCH 147/378] Clear collections last --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 708fd902..321cf334 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -314,7 +314,7 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.cooking.remove(memoryItem); - inMemoryItemLookup.remove(memoryItem.objectUUID); + // inMemoryItemLookup.remove(memoryItem.objectUUID); vendorItemLookup.get(workOrder.vendor).remove(memoryItem); } From b80b3a81b558cb9237e37b173cf0a763026d5f79 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:34:35 -0400 Subject: [PATCH 148/378] Message sent early --- src/engine/gameManager/ForgeManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 321cf334..2fb06bb1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -299,6 +299,12 @@ public enum ForgeManager implements Runnable { toRemove.add(workOrderItem); workOrderItem.containerType = mbEnums.ItemContainerType.INVENTORY; + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); workOrder.vendor.charItemManager.addItemToInventory(completed_item); @@ -307,14 +313,8 @@ public enum ForgeManager implements Runnable { // set the items as 'completed' for (Item memoryItem : toRemove) { - - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - workOrder.cooking.remove(memoryItem); - // inMemoryItemLookup.remove(memoryItem.objectUUID); + inMemoryItemLookup.remove(memoryItem.objectUUID); vendorItemLookup.get(workOrder.vendor).remove(memoryItem); } From 250afe3bbacabf337da07ffa817320ba9ad46208 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:41:05 -0400 Subject: [PATCH 149/378] Serialization update --- src/engine/net/client/msg/ItemProductionMsg.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 8e7a4d8e..df25ccca 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -59,8 +59,6 @@ public class ItemProductionMsg extends ClientNetMsg { } - ; - public ItemProductionMsg(Building building, NPC vendor, Item item, mbEnums.ProductionActionType actionType, boolean add) { super(Protocol.ITEMPRODUCTION); this.actionType = actionType; @@ -126,9 +124,14 @@ public class ItemProductionMsg extends ClientNetMsg { if (!add) { writer.put((byte) 1); - Item item = Item.getFromCache(this.itemUUID); - if (item != null) - Item.serializeForClientMsgWithoutSlot(item, writer); + + Item item; + if (this.itemUUID > 0) + item = Item.getFromCache(this.itemUUID); + else + item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + + Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); writer.putInt(0); writer.putInt(0); @@ -139,6 +142,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.put((byte) 1); + Item item; if (this.itemUUID > 0) item = Item.getFromCache(this.itemUUID); From 03fb180f023fbd08ce818517ab379fa690c827db Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 12:49:37 -0400 Subject: [PATCH 150/378] Set variable on submit --- src/engine/gameManager/ForgeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 2fb06bb1..d70b4ab8 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -122,6 +122,7 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); + workOrder.total_produced = 0; workOrder.total_to_produce *= workOrder.slots_used; // Create in-memory items and add to collections From b4824c69b8974a64e182603159723e30d9ef2b6f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 14:24:50 -0400 Subject: [PATCH 151/378] Window work --- src/engine/gameManager/ForgeManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d70b4ab8..3487615d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -301,10 +301,10 @@ public enum ForgeManager implements Runnable { toRemove.add(workOrderItem); workOrderItem.containerType = mbEnums.ItemContainerType.INVENTORY; - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); From a2484f94eb47be293918b920423cffbf5e705328 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 14:33:33 -0400 Subject: [PATCH 152/378] Bugfix in forge contains --- .../net/client/handlers/ItemProductionMsgHandler.java | 2 +- src/engine/objects/CharacterItemManager.java | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index ae2dd5cb..9f96a484 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -350,7 +350,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem == null) return; - if (!vendor.charItemManager.forgeContains(targetItem, vendor)) + if (!ForgeManager.vendorItemLookup.get(vendor).contains(targetItem)) return; // Cannot junk items without a forge! diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 70f2e7d5..0ba04ba4 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1353,12 +1353,6 @@ public class CharacterItemManager { return inventory.contains(item); } - public synchronized boolean forgeContains(Item item, NPC vendor) { - if (item.template.item_type.equals(ItemType.GOLD)) - return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == item.getObjectUUID()); - return ForgeManager.vendorItemLookup.get(vendor).contains(item); - } - public synchronized boolean vaultContains(Item item) { if (item.template.item_type.equals(ItemType.GOLD)) return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == item.getObjectUUID()); From 12b6e414323134781bceb6b825fba8f0f2d5cb3e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 14:45:34 -0400 Subject: [PATCH 153/378] Fixing Junk functionality --- src/engine/gameManager/ForgeManager.java | 3 +++ .../handlers/ItemProductionMsgHandler.java | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 3487615d..8a283caa 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -37,6 +37,7 @@ public enum ForgeManager implements Runnable { public static final HashMap inMemoryItemLookup = new HashMap<>(); public static final HashMap> vendorItemLookup = new HashMap<>(); public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); + public static final HashMap itemWorkOrderLookup = new HashMap<>(); @Override @@ -317,6 +318,7 @@ public enum ForgeManager implements Runnable { workOrder.cooking.remove(memoryItem); inMemoryItemLookup.remove(memoryItem.objectUUID); vendorItemLookup.get(workOrder.vendor).remove(memoryItem); + itemWorkOrderLookup.remove(memoryItem); } } @@ -334,6 +336,7 @@ public enum ForgeManager implements Runnable { vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); vendorItemLookup.get(workOrder.vendor).add(forged_item); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); + itemWorkOrderLookup.put(forged_item, workOrder); // Update NPC window diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 9f96a484..c9526bea 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -332,13 +332,15 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void junkItem(int itemUUID, NPC vendor, ClientConnection origin) { - MobLoot targetItem; + Item targetItem; ManageNPCMsg outMsg; Dispatch dispatch; if (origin.sellLock.tryLock()) { + try { - targetItem = MobLoot.getFromCache(itemUUID); + + targetItem = ForgeManager.inMemoryItemLookup.get(itemUUID); PlayerCharacter player = origin.getPlayerCharacter(); @@ -350,18 +352,17 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem == null) return; - if (!ForgeManager.vendorItemLookup.get(vendor).contains(targetItem)) - return; - // Cannot junk items without a forge! if (vendor.getBuilding() == null) return; - // Delete the item and cancel any pending rolling timer jobs + // Delete the item - targetItem.recycle(vendor); - // todo fix vendor.removeItemFromForge(targetItem); + ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); + workOrder.cooking.remove(targetItem); + ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(targetItem); // Refresh vendor's inventory to client From b0c0c507e584ba4180f8a5364e78770df48e1a44 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 14:59:07 -0400 Subject: [PATCH 154/378] More window work --- src/engine/gameManager/ForgeManager.java | 9 ++++----- .../net/client/handlers/ItemProductionMsgHandler.java | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 8a283caa..2da142aa 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -300,12 +300,11 @@ public enum ForgeManager implements Runnable { for (Item workOrderItem : workOrder.cooking) { toRemove.add(workOrderItem); - workOrderItem.containerType = mbEnums.ItemContainerType.INVENTORY; - // ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - // ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - // DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index c9526bea..c77283b6 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -364,6 +364,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.cooking.remove(targetItem); ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(targetItem); + // Update workOrder to reflect canceled slot + + workOrder.slots_used = workOrder.slots_used - 1; + + if (workOrder.slots_used == 0) + workOrder.runCanceled = true; + // Refresh vendor's inventory to client outMsg = new ManageNPCMsg(vendor); From 315c2abfb9701f24e71130548c6947d29dc2844a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 15:15:08 -0400 Subject: [PATCH 155/378] Remove workorder when completed --- src/engine/gameManager/ForgeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 2da142aa..16c24e70 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -70,6 +70,7 @@ public enum ForgeManager implements Runnable { } Logger.info("workOrder has completed: " + workOrder.workOrderID); + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); workOrder.runCompleted = true; } From c1b0bcedf44fb205b05c4cf9f4a38e587ee9bea2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 15:22:11 -0400 Subject: [PATCH 156/378] Remove workorder when completed --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 16c24e70..0f173bcb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -304,7 +304,7 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_TAKE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); From 0727361933597bcdfc686e98d93d4a102780d5cf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 15:29:13 -0400 Subject: [PATCH 157/378] More window work --- src/engine/gameManager/ForgeManager.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0f173bcb..001dc2c6 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -302,11 +302,8 @@ public enum ForgeManager implements Runnable { toRemove.add(workOrderItem); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_TAKE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); workOrder.vendor.charItemManager.addItemToInventory(completed_item); From d47643e730a30f0b617bebd005069aa71d091320 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 15 Apr 2024 15:48:15 -0400 Subject: [PATCH 158/378] Error logging added --- src/engine/net/client/msg/ItemProductionMsg.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index df25ccca..7d1ae595 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -17,6 +17,7 @@ import engine.net.*; import engine.objects.Building; import engine.objects.Item; import engine.objects.NPC; +import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -126,12 +127,17 @@ public class ItemProductionMsg extends ClientNetMsg { writer.put((byte) 1); Item item; + if (this.itemUUID > 0) item = Item.getFromCache(this.itemUUID); else item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); - Item.serializeForClientMsgWithoutSlot(item, writer); + if (item == null) + Logger.error("Null item serialized"); + else + Item.serializeForClientMsgWithoutSlot(item, writer); + writer.putInt(building.getStrongboxValue()); writer.putInt(0); writer.putInt(0); @@ -149,7 +155,10 @@ public class ItemProductionMsg extends ClientNetMsg { else item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); - Item.serializeForClientMsgWithoutSlot(item, writer); + if (item == null) + Logger.error("Null item serialized"); + else + Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); writer.putInt(0); From 862e75cd4c10215055cec2f9f382aa91e685f321 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 14:01:46 -0400 Subject: [PATCH 159/378] Serialization updated. Collection adds slot. --- src/engine/net/client/msg/ItemProductionMsg.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 7d1ae595..148fed95 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -127,11 +127,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.put((byte) 1); Item item; - - if (this.itemUUID > 0) - item = Item.getFromCache(this.itemUUID); - else - item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + item = Item.getFromCache(this.itemUUID); // If sent to rolling window adds a new slot. if (item == null) Logger.error("Null item serialized"); From e879c588dc904c343d82ec8d6e6eca160150c64a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 14:21:29 -0400 Subject: [PATCH 160/378] More window work. --- src/engine/gameManager/ForgeManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 001dc2c6..16c24e70 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -302,8 +302,11 @@ public enum ForgeManager implements Runnable { toRemove.add(workOrderItem); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); workOrder.vendor.charItemManager.addItemToInventory(completed_item); From c5dfb3ad81da1cb31394d1282b8c4d2d023b85e7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 14:47:35 -0400 Subject: [PATCH 161/378] Serialization work --- src/engine/net/client/msg/ItemProductionMsg.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 148fed95..565d441a 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -17,7 +17,6 @@ import engine.net.*; import engine.objects.Building; import engine.objects.Item; import engine.objects.NPC; -import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -129,9 +128,7 @@ public class ItemProductionMsg extends ClientNetMsg { Item item; item = Item.getFromCache(this.itemUUID); // If sent to rolling window adds a new slot. - if (item == null) - Logger.error("Null item serialized"); - else + if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); @@ -151,9 +148,7 @@ public class ItemProductionMsg extends ClientNetMsg { else item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); - if (item == null) - Logger.error("Null item serialized"); - else + if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); writer.putInt(building.getStrongboxValue()); From a86d90ef414ecf2558fa58391a65a28ce78010cb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 14:55:03 -0400 Subject: [PATCH 162/378] serialization work --- src/engine/net/client/msg/ItemProductionMsg.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 565d441a..bc813d64 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -126,7 +126,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.put((byte) 1); Item item; - item = Item.getFromCache(this.itemUUID); // If sent to rolling window adds a new slot. + item = Item.getFromCache(this.itemUUID); // Negative ID items not sent here. Deposit virtual item? if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); @@ -252,7 +252,7 @@ public class ItemProductionMsg extends ClientNetMsg { } writer.putString(toRoll.name); - writer.putInt(GameObjectType.MobLoot.ordinal()); + writer.putInt(toRoll.getObjectType().ordinal()); writer.putInt(this.itemUUID); writer.putInt(0); //items left to produce? From d42bc3520d1168b3d320e1412ba33b232873d85f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:03:59 -0400 Subject: [PATCH 163/378] Single runs are set to complete. Multiple item runs are dumped to inventory. --- src/engine/gameManager/ForgeManager.java | 15 +++++++++++---- src/engine/loot/WorkOrder.java | 2 +- .../client/handlers/ItemProductionMsgHandler.java | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 16c24e70..a424cf26 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -64,11 +64,18 @@ public enum ForgeManager implements Runnable { // Complete this workOrder. - for (Item workOrderItem : workOrder.cooking) { - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + if (workOrder.multiple_slot_request == false) { + + // Single4 item runs are just set to complete + + for (Item workOrderItem : workOrder.cooking) { + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + } + continue; } + persistItems(workOrder); Logger.info("workOrder has completed: " + workOrder.workOrderID); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); workOrder.runCompleted = true; @@ -192,7 +199,7 @@ public enum ForgeManager implements Runnable { // Single item rolls are msg_size of 0; - if (availableSlots > 0 && workOrder.multiple_slot_request == 0) + if (availableSlots > 0 && workOrder.multiple_slot_request == false) availableSlots = 1; return availableSlots; diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 5bfc1f84..17a0eb4c 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -28,7 +28,7 @@ public class WorkOrder implements Delayed { public int slots_used; public int total_to_produce; public int total_produced; - public int multiple_slot_request; + public boolean multiple_slot_request; public HashMap production_cost = new HashMap<>(); public HashMap production_cost_total = new HashMap<>(); public int templateID; diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index c77283b6..bac40739 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -82,7 +82,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; workOrder.item_name_override = msg.name; - workOrder.multiple_slot_request = msg.size; + workOrder.multiple_slot_request = (msg.size != 0); // Submit workOder to begin rolling items From 7c855afbe7a7148e4db76844567fd72f0423fdc3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:11:03 -0400 Subject: [PATCH 164/378] All runs set to complete --- src/engine/gameManager/ForgeManager.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a424cf26..54571cea 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -65,17 +65,12 @@ public enum ForgeManager implements Runnable { // Complete this workOrder. if (workOrder.multiple_slot_request == false) { - - // Single4 item runs are just set to complete - for (Item workOrderItem : workOrder.cooking) { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } - continue; } - persistItems(workOrder); Logger.info("workOrder has completed: " + workOrder.workOrderID); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); workOrder.runCompleted = true; From a944f7342a951627125305a29a744dd5487091ed Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:17:15 -0400 Subject: [PATCH 165/378] All rolls treated equally --- src/engine/gameManager/ForgeManager.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 54571cea..e81276f5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -64,12 +64,10 @@ public enum ForgeManager implements Runnable { // Complete this workOrder. - if (workOrder.multiple_slot_request == false) { - for (Item workOrderItem : workOrder.cooking) { - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + for (Item workOrderItem : workOrder.cooking) { + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } - } Logger.info("workOrder has completed: " + workOrder.workOrderID); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); From 197df90a21257379459d3a114ba2f5442094b1d1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:33:39 -0400 Subject: [PATCH 166/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e81276f5..859fd580 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -265,12 +265,22 @@ public enum ForgeManager implements Runnable { public static Item forgeItem(WorkOrder workOrder) { - ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + // Create new item from specified template + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); Item forgedItem = new Item(workOrder.templateID); + + // Item gets a negative id; a virtual in-memory only item + // which is not persisted or added to the game cache. + forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); + forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); + + // The UpgradeDate for the item is serialized for the + // vendor forge window + forgedItem.setDateToUpgrade(workOrder.completionTime); // Give prefix and suffix to this item if random rolled @@ -302,17 +312,19 @@ public enum ForgeManager implements Runnable { toRemove.add(workOrderItem); + // Remove the virtual items from the forge window + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); + // Turn the virtual item into a real one and add to the vendor inventory + completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); workOrder.vendor.charItemManager.addItemToInventory(completed_item); } - // Remove the fake negativeID item from all collections. - // set the items as 'completed' + // Remove the fake negativeID virtual item from all collections. for (Item memoryItem : toRemove) { workOrder.cooking.remove(memoryItem); @@ -328,7 +340,7 @@ public enum ForgeManager implements Runnable { Item forged_item = forgeItem(workOrder); - // Add item to in-memory caches + // Add virtual item to in-memory caches workOrder.cooking.add(forged_item); From 946a150db1c8fab18fb51facc00f28a248ff7a81 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:34:14 -0400 Subject: [PATCH 167/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 859fd580..984ed7e1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -81,7 +81,7 @@ public enum ForgeManager implements Runnable { persistItems(workOrder); - // Create new set in memory items + // Create new set of in-memory virtual items forgeItems(workOrder); From 3484802a24201a34f22c857a001591ebc66eb251 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:34:39 -0400 Subject: [PATCH 168/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 984ed7e1..f25279a8 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -77,11 +77,11 @@ public enum ForgeManager implements Runnable { if (workOrder.runCompleted == true) continue; - // Persist items that were currently cooking + // Persist virtual items that were currently cooking persistItems(workOrder); - // Create new set of in-memory virtual items + // Create new set of in-memory only virtual items forgeItems(workOrder); From 9804a0fc8971629200f9c7b25a21d51a02d27aa9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:35:55 -0400 Subject: [PATCH 169/378] Debug strings were removed --- src/engine/gameManager/ForgeManager.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f25279a8..839d1ccb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -58,8 +58,6 @@ public enum ForgeManager implements Runnable { if (Objects.requireNonNull(workOrder).runCanceled || workOrder.runCompleted) continue; - Logger.info("item forged:" + workOrder.workOrderID + " (" + workOrder.total_produced + "/" + workOrder.total_to_produce + ")"); - if (workOrder.total_produced >= workOrder.total_to_produce) { // Complete this workOrder. @@ -69,7 +67,6 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } - Logger.info("workOrder has completed: " + workOrder.workOrderID); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); workOrder.runCompleted = true; } @@ -354,8 +351,6 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, forged_item, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - Logger.info("Forging item: " + forged_item.objectUUID + " (" + forged_item.templateID + ") " + forged_item.template.item_base_name); workOrder.total_produced = workOrder.total_produced + 1; } } From 93aec63f7819e7ad469f82a617c4df264286fda3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:40:10 -0400 Subject: [PATCH 170/378] File reformat --- src/engine/gameManager/ForgeManager.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 839d1ccb..67a5af98 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -65,13 +65,13 @@ public enum ForgeManager implements Runnable { for (Item workOrderItem : workOrder.cooking) { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - } + } ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); workOrder.runCompleted = true; } - if (workOrder.runCompleted == true) + if (workOrder.runCompleted) continue; // Persist virtual items that were currently cooking @@ -95,7 +95,6 @@ public enum ForgeManager implements Runnable { Thread forgeManager; forgeManager = new Thread(FORGE_MANAGER); - forgeManager.setName("Forge Manager"); forgeManager.start(); } @@ -189,7 +188,7 @@ public enum ForgeManager implements Runnable { // Single item rolls are msg_size of 0; - if (availableSlots > 0 && workOrder.multiple_slot_request == false) + if (availableSlots > 0 && !workOrder.multiple_slot_request) availableSlots = 1; return availableSlots; @@ -321,7 +320,8 @@ public enum ForgeManager implements Runnable { completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); workOrder.vendor.charItemManager.addItemToInventory(completed_item); } - // Remove the fake negativeID virtual item from all collections. + + // Remove the negativeID virtual item from all collections. for (Item memoryItem : toRemove) { workOrder.cooking.remove(memoryItem); @@ -329,8 +329,8 @@ public enum ForgeManager implements Runnable { vendorItemLookup.get(workOrder.vendor).remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); } - } + public static void forgeItems(WorkOrder workOrder) { for (int i = 0; i < workOrder.slots_used; ++i) { @@ -340,7 +340,6 @@ public enum ForgeManager implements Runnable { // Add virtual item to in-memory caches workOrder.cooking.add(forged_item); - inMemoryItemLookup.put(forged_item.objectUUID, forged_item); vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); vendorItemLookup.get(workOrder.vendor).add(forged_item); From a4a9a26ac4df9b6b882a6a4373249f34023cbd13 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 15:53:13 -0400 Subject: [PATCH 171/378] Complete is complete --- .../handlers/ItemProductionMsgHandler.java | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index bac40739..82f2285e 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -46,7 +46,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Member variable declaration PlayerCharacter player; - NPC vendorNPC; + NPC vendor; ItemProductionMsg msg; Dispatch dispatch; @@ -60,11 +60,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Grab reference to vendor we are interacting with - vendorNPC = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); + vendor = (NPC) DbManager.getObject(mbEnums.GameObjectType.NPC, msg.npcUUID); // Oops? - if (vendorNPC == null) + if (vendor == null) return true; // Process Request @@ -77,7 +77,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { WorkOrder workOrder = new WorkOrder(); workOrder.total_to_produce = msg.total_to_produce; - workOrder.vendor = vendorNPC; + workOrder.vendor = vendor; workOrder.templateID = msg.itemUUID; workOrder.prefixToken = msg.pToken; workOrder.suffixToken = msg.sToken; @@ -98,25 +98,42 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { break; case JUNK: - junkItem(msg.itemUUID, vendorNPC, origin); + junkItem(msg.itemUUID, vendor, origin); break; case RECYCLE: - recycleItem(msg.items, vendorNPC, origin); + recycleItem(msg.items, vendor, origin); msg.actionType = mbEnums.ProductionActionType.TAKE; dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; case COMPLETE: - // todo fix vendorNPC.completeItem(msg.itemUUID); + Item virtualItem = ForgeManager.inMemoryItemLookup.get(msg.itemUUID); + + if (virtualItem == null) + return true; + + //remove from client forge window + + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); + vendor.charItemManager.addItemToInventory(completedItem); + + ForgeManager.inMemoryItemLookup.remove(virtualItem.objectUUID); + ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); break; case DEPOSIT: - depositItem(msg.itemUUID, vendorNPC, origin); + depositItem(msg.itemUUID, vendor, origin); break; case SETPRICE: - setItemPrice(msg.itemType, msg.itemUUID, msg.itemPrice, vendorNPC, origin); + setItemPrice(msg.itemType, msg.itemUUID, msg.itemPrice, vendor, origin); break; case TAKE: - takeItem(msg.items, vendorNPC, origin); + takeItem(msg.items, vendor, origin); dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; From 6e95ae524532595ef96badc099518a886be0ff66 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 16 Apr 2024 16:01:17 -0400 Subject: [PATCH 172/378] Variable naming update --- src/engine/gameManager/ForgeManager.java | 4 ++-- .../net/client/handlers/ItemProductionMsgHandler.java | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 67a5af98..c8ad259e 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -312,8 +312,8 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); // Turn the virtual item into a real one and add to the vendor inventory diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 82f2285e..6f62d093 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -114,10 +114,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { //remove from client forge window - ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + // Completed items are identified + + virtualItem.flags.add(mbEnums.ItemFlags.Identified); Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); vendor.charItemManager.addItemToInventory(completedItem); From dda98318ebff6d4653857d78beed266c6508a19b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 11:56:23 -0400 Subject: [PATCH 173/378] Work on virtual item handling --- src/engine/gameManager/ForgeManager.java | 30 +++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c8ad259e..e4f0a962 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -74,19 +74,22 @@ public enum ForgeManager implements Runnable { if (workOrder.runCompleted) continue; - // Persist virtual items that were currently cooking + // Move current cooking batch to vendor inventory - persistItems(workOrder); + completeWorkOrderBatch(workOrder); // Create new set of in-memory only virtual items - forgeItems(workOrder); + forgeWorkerOrderBatch(workOrder); // enQueue this workOrder again; back into the oven // until all items for this workOrder are completed. workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; forge.add(workOrder); + + // Debugging + Logger.info(workOrder.toString()); } } @@ -125,7 +128,7 @@ public enum ForgeManager implements Runnable { // Create in-memory items and add to collections - forgeItems(workOrder); + forgeWorkerOrderBatch(workOrder); Logger.info(workOrder.toString()); forge.add(workOrder); @@ -299,15 +302,12 @@ public enum ForgeManager implements Runnable { return forgedItem; } - public static void persistItems(WorkOrder workOrder) { + public static void completeWorkOrderBatch(WorkOrder workOrder) { ArrayList toRemove = new ArrayList<>(); - Item completed_item; for (Item workOrderItem : workOrder.cooking) { - toRemove.add(workOrderItem); - // Remove the virtual items from the forge window ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); @@ -315,23 +315,25 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - // Turn the virtual item into a real one and add to the vendor inventory + // add to the vendor inventory + + workOrder.vendor.charItemManager.addItemToInventory(workOrderItem); - completed_item = DbManager.ItemQueries.PERSIST(workOrderItem); - workOrder.vendor.charItemManager.addItemToInventory(completed_item); + toRemove.add(workOrderItem); } - // Remove the negativeID virtual item from all collections. + // Remove the negativeID virtual item from all collections + // other than the virtual item lookup map. Item will be + // persisted when bought/taken from vendor. for (Item memoryItem : toRemove) { workOrder.cooking.remove(memoryItem); - inMemoryItemLookup.remove(memoryItem.objectUUID); vendorItemLookup.get(workOrder.vendor).remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); } } - public static void forgeItems(WorkOrder workOrder) { + public static void forgeWorkerOrderBatch(WorkOrder workOrder) { for (int i = 0; i < workOrder.slots_used; ++i) { From 8cada05424545ac61a51127f62e9a64a6c5e7a1d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 12:04:41 -0400 Subject: [PATCH 174/378] Completion time reset before new batch --- src/engine/gameManager/ForgeManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e4f0a962..f98c7565 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -85,7 +85,6 @@ public enum ForgeManager implements Runnable { // enQueue this workOrder again; back into the oven // until all items for this workOrder are completed. - workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; forge.add(workOrder); // Debugging @@ -335,6 +334,10 @@ public enum ForgeManager implements Runnable { public static void forgeWorkerOrderBatch(WorkOrder workOrder) { + // New completion time for this batch + + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; + for (int i = 0; i < workOrder.slots_used; ++i) { Item forged_item = forgeItem(workOrder); From 1e003c28abc74c528e8c3a6d04a86702db932ee7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 12:20:45 -0400 Subject: [PATCH 175/378] Completion work --- .../net/client/handlers/ItemProductionMsgHandler.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 6f62d093..27a87c3b 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -119,14 +119,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - // Completed items are identified + // Add to NPC inventory - virtualItem.flags.add(mbEnums.ItemFlags.Identified); + vendor.charItemManager.addItemToInventory(virtualItem); - Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); - vendor.charItemManager.addItemToInventory(completedItem); - - ForgeManager.inMemoryItemLookup.remove(virtualItem.objectUUID); ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); break; From 1a27a549267f448a9bb46d0f4a1416ebc5126d46 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 12:24:17 -0400 Subject: [PATCH 176/378] Not right place for this perhaps --- .../net/client/handlers/ItemProductionMsgHandler.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 27a87c3b..b64e1d94 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -381,13 +381,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.cooking.remove(targetItem); ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(targetItem); - // Update workOrder to reflect canceled slot - - workOrder.slots_used = workOrder.slots_used - 1; - - if (workOrder.slots_used == 0) - workOrder.runCanceled = true; - // Refresh vendor's inventory to client outMsg = new ManageNPCMsg(vendor); From f9825900cc399e60a3cabc36cf86e8fcb7007464 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 12:36:23 -0400 Subject: [PATCH 177/378] More completion work --- .../handlers/ItemProductionMsgHandler.java | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index b64e1d94..734dbd6f 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -107,24 +107,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; case COMPLETE: - Item virtualItem = ForgeManager.inMemoryItemLookup.get(msg.itemUUID); - - if (virtualItem == null) - return true; - - //remove from client forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - // Add to NPC inventory - - vendor.charItemManager.addItemToInventory(virtualItem); - - ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); - ForgeManager.itemWorkOrderLookup.remove(virtualItem); + completeItem(msg.itemUUID, vendor, origin); break; case DEPOSIT: depositItem(msg.itemUUID, vendor, origin); @@ -141,6 +124,29 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return true; } + private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin) { + + + Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + + if (virtualItem == null) + return; + + //remove from client forge window + + ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + // Add to NPC inventory + + vendor.charItemManager.addItemToInventory(virtualItem); + + ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); + } + private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { Item targetItem; From 8df0c838cce5f804f059267392eb22f8c32d3ae7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 12:47:28 -0400 Subject: [PATCH 178/378] More completion work --- .../net/client/handlers/ItemProductionMsgHandler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 734dbd6f..e475e8e1 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -107,7 +107,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); break; case COMPLETE: - completeItem(msg.itemUUID, vendor, origin); + completeItem(msg.itemUUID, vendor); break; case DEPOSIT: depositItem(msg.itemUUID, vendor, origin); @@ -124,7 +124,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return true; } - private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin) { + private static void completeItem(int itemUUID, NPC vendor) { Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); @@ -143,8 +143,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { vendor.charItemManager.addItemToInventory(virtualItem); + // Remove from collections + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + workOrder.cooking.remove(virtualItem); + ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + } private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { From 689fc142d00e331c5397843055fe041c9ee903bc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 13:46:10 -0400 Subject: [PATCH 179/378] Persisted items belong in vendor inventory not virtual ones. --- src/engine/gameManager/ForgeManager.java | 11 ++++++++--- .../net/client/handlers/ItemProductionMsgHandler.java | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f98c7565..d7c455fc 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -311,12 +311,17 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); // add to the vendor inventory - workOrder.vendor.charItemManager.addItemToInventory(workOrderItem); + workOrder.vendor.charItemManager.addItemToInventory(completedItem); + + ItemProductionMsg outMsg1 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); toRemove.add(workOrderItem); } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index e475e8e1..28d31f08 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -136,20 +136,19 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); // Add to NPC inventory vendor.charItemManager.addItemToInventory(virtualItem); // Remove from collections + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); workOrder.cooking.remove(virtualItem); - ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + } private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { From d7ba42f4da12d2f577f1dcc631dd5d5729f45af3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 13:48:39 -0400 Subject: [PATCH 180/378] Update to batch completion --- src/engine/gameManager/ForgeManager.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d7c455fc..c5180464 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -307,10 +307,7 @@ public enum ForgeManager implements Runnable { for (Item workOrderItem : workOrder.cooking) { - // Remove the virtual items from the forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); @@ -331,6 +328,12 @@ public enum ForgeManager implements Runnable { // persisted when bought/taken from vendor. for (Item memoryItem : toRemove) { + + // Remove the virtual items from the forge window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.cooking.remove(memoryItem); vendorItemLookup.get(workOrder.vendor).remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); From 8d1561cd29f6c02335a5a7cca25abd93b5d98fb7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 13:58:25 -0400 Subject: [PATCH 181/378] Update to completion --- .../handlers/ItemProductionMsgHandler.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 28d31f08..2d274623 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -126,26 +126,26 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void completeItem(int itemUUID, NPC vendor) { - Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - if (virtualItem == null) - return; - - //remove from client forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - // Add to NPC inventory + // Persist item and add to vendor inventory + Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); vendor.charItemManager.addItemToInventory(virtualItem); + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Remove from collections - WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.cooking.remove(virtualItem); - ForgeManager.vendorItemLookup.get(vendor).remove(virtualItem); + ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); From a522eeb823000b95d646491914a95aa0cfc9fa54 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 13:59:34 -0400 Subject: [PATCH 182/378] Update to completion --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 2d274623..a28959a6 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -132,7 +132,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Persist item and add to vendor inventory Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); - vendor.charItemManager.addItemToInventory(virtualItem); + vendor.charItemManager.addItemToInventory(completedItem); ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); From e6d83ca36c8f988afcab0fb8535ea245de51e98e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 14:07:42 -0400 Subject: [PATCH 183/378] Mobloot vestiges removed --- .../handlers/ItemProductionMsgHandler.java | 55 +++++-------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index a28959a6..fdf173cc 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -15,7 +15,6 @@ import engine.gameManager.DbManager; import engine.gameManager.ForgeManager; import engine.loot.WorkOrder; import engine.mbEnums; -import engine.mbEnums.GameObjectType; import engine.mbEnums.ItemType; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -24,7 +23,10 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ItemProductionMsg; import engine.net.client.msg.ManageNPCMsg; -import engine.objects.*; +import engine.objects.CharacterItemManager; +import engine.objects.Item; +import engine.objects.NPC; +import engine.objects.PlayerCharacter; import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -113,7 +115,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { depositItem(msg.itemUUID, vendor, origin); break; case SETPRICE: - setItemPrice(msg.itemType, msg.itemUUID, msg.itemPrice, vendor, origin); + setItemPrice(msg.itemUUID, msg.itemPrice, vendor, origin); break; case TAKE: takeItem(msg.items, vendor, origin); @@ -151,7 +153,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { } - private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { + private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { Item targetItem; ItemProductionMsg outMsg; @@ -162,35 +164,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (player == null) return; - if (itemType == GameObjectType.Item.ordinal()) - targetItem = Item.getFromCache(itemUUID); - else if (itemType == GameObjectType.MobLoot.ordinal()) - targetItem = MobLoot.getFromCache(itemUUID); - else - targetItem = null; + targetItem = Item.getFromCache(itemUUID); if (targetItem == null) return; - if (targetItem.getObjectType() == GameObjectType.Item) { - if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) { + if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) { ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); return; } - targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - } else if (targetItem.getObjectType() == GameObjectType.MobLoot) { - MobLoot mobLoot = (MobLoot) targetItem; - if (!DbManager.NPCQueries.UPDATE_ITEM_PRICE(mobLoot.getObjectUUID(), vendor.getObjectUUID(), itemPrice)) { - ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); - return; - } targetItem.setValue(itemPrice); outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); dispatch = Dispatch.borrow(player, outMsg); @@ -199,7 +182,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); dispatch = Dispatch.borrow(player, outMsg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - } + } // Method sets the price on an item in the vendor inventory @@ -299,12 +282,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { for (int itemUUID : itemList.keySet()) { int itemValue = 0; - int type = itemList.get(itemUUID); - - if (type == GameObjectType.Item.ordinal()) - targetItem = Item.getFromCache(itemUUID); - else - targetItem = MobLoot.getFromCache(itemUUID); + targetItem = Item.getFromCache(itemUUID); if (targetItem == null) continue; @@ -314,6 +292,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) continue; + if (vendor.charItemManager.inventoryContains(targetItem) == false) continue; @@ -333,6 +312,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { case POTION: continue; } + totalValue += itemValue; vendor.charItemManager.recycle(targetItem); @@ -344,8 +324,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Refund a portion of the gold - if (!vendor.getBuilding().transferGold(totalValue, false)) - return; + vendor.getBuilding().transferGold(totalValue, false); } catch (Exception e) { Logger.error(e); @@ -414,18 +393,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { for (int itemUUID : itemList.keySet()) { - int type = itemList.get(itemUUID); - if (type == GameObjectType.Item.ordinal()) { - targetItem = Item.getFromCache(itemUUID); - - } else - targetItem = MobLoot.getFromCache(itemUUID); + targetItem = Item.getFromCache(itemUUID); if (targetItem == null) return; if (targetItem.template.item_type.equals(ItemType.GOLD)) return; + if (vendor.charItemManager.inventoryContains(targetItem) == false) return; From b9627e164332054b076a15cae547a6798c83c396 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 14:15:12 -0400 Subject: [PATCH 184/378] Class cleanup --- src/engine/objects/CharacterItemManager.java | 140 +++++-------------- 1 file changed, 32 insertions(+), 108 deletions(-) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 0ba04ba4..ffd8f672 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -9,7 +9,10 @@ package engine.objects; -import engine.gameManager.*; +import engine.gameManager.BuildingManager; +import engine.gameManager.ConfigManager; +import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.math.Vector3fImmutable; import engine.mbEnums; import engine.mbEnums.GameObjectType; @@ -152,9 +155,7 @@ public class CharacterItemManager { i.junk(); break; } - } - this.goldVault = this.account.vaultGold; //check all gold is created @@ -305,11 +306,9 @@ public class CharacterItemManager { ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.absCharacter, 203); return false; } - } break; - } return true; } @@ -370,44 +369,6 @@ public class CharacterItemManager { return success; } - public synchronized boolean tradeRequest(TradeRequestMsg msg) { - - PlayerCharacter source = (PlayerCharacter) this.getOwner(); - PlayerCharacter target = PlayerCharacter.getFromCache(msg.getPlayerID()); - Dispatch dispatch; - - if (!canTrade(source, target)) { - ChatManager.chatSystemError(source, "Can't currently trade with target player"); - return false; - } - - // TODO uncomment this block after we determine when we - // setBankOpen(false) and setVaultOpen(false) - CharacterItemManager cim1 = source.charItemManager; - CharacterItemManager cim2 = target.charItemManager; - - if (cim1 == null) - return false; - - if (cim2 == null) - return false; - - dispatch = Dispatch.borrow(target, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - return true; - - } - - public synchronized boolean invalidTradeRequest(InvalidTradeRequestMsg msg) { - PlayerCharacter requester = PlayerCharacter.getFromCache(msg.getRequesterID()); - Dispatch dispatch; - - dispatch = Dispatch.borrow(requester, msg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - return true; - - } - public static synchronized boolean canTrade(PlayerCharacter playerA, PlayerCharacter playerB) { if (playerA == null || playerB == null) @@ -449,6 +410,7 @@ public class CharacterItemManager { if (this.getTradingWith().getPlayerCharacter() == null) return false; + CharacterItemManager man2 = this.getTradingWith().getPlayerCharacter().charItemManager; Dispatch dispatch; @@ -469,11 +431,10 @@ public class CharacterItemManager { } public synchronized boolean closeTradeWindow(CloseTradeWindowMsg msg, boolean sourceTrade) { - - Dispatch dispatch; PlayerCharacter source = (PlayerCharacter) this.getOwner(); + if (source == null) return false; @@ -501,11 +462,8 @@ public class CharacterItemManager { } sourceItemMan.endTrade(); - - cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false); - return true; } @@ -697,17 +655,19 @@ public class CharacterItemManager { // add to Bank this.bank.add(i); i.addToCache(); - calculateWeights(); return true; } public synchronized boolean moveGoldToBank(Item from, int amt) { + if (from == null) return false; + if (from.getNumOfItems() - amt < 0) return false; + if (this.goldBank.getNumOfItems() + amt > MBServerStatics.BANK_GOLD_LIMIT) { if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pc = (PlayerCharacter) this.absCharacter; @@ -719,26 +679,33 @@ public class CharacterItemManager { if (!DbManager.ItemQueries.MOVE_GOLD(from, this.getGoldBank(), amt)) return false; + from.setNumOfItems(from.getNumOfItems() - amt); this.goldBank.setNumOfItems(this.goldBank.getNumOfItems() + amt); return true; } public synchronized boolean moveGoldToVault(Item from, int amt) { + if (from == null) return false; + if (from.getNumOfItems() - amt < 0) return false; + if (!DbManager.ItemQueries.MOVE_GOLD(from, this.account.vaultGold, amt)) return false; + from.setNumOfItems(from.getNumOfItems() - amt); this.account.vaultGold.setNumOfItems(this.goldVault.getNumOfItems() + amt); return true; } public synchronized boolean moveGoldToInventory(Item from, int amt) { + if (from == null) return false; + if (from.getNumOfItems() - amt < 0 || amt < 1) return false; @@ -841,7 +808,6 @@ public class CharacterItemManager { // add to Vault i.addToCache(); - calculateWeights(); return true; @@ -893,20 +859,12 @@ public class CharacterItemManager { this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - if (i.template != null) this.inventoryWeight += i.template.item_wt; return true; } - //called for adding gold of a specified amount - public synchronized boolean addItemToInventory(Item i, int amount) { - if (i.template.item_type.equals(ItemType.GOLD)) - return DbManager.ItemQueries.UPDATE_GOLD(this.getGoldInventory(), this.goldInventory.getNumOfItems() + amount); - return false; - } - public boolean equipItem(Item i, mbEnums.EquipSlotType slot) { synchronized (this) { @@ -955,6 +913,7 @@ public class CharacterItemManager { } //Apply Bonuses and update player + if (this.absCharacter != null) { this.absCharacter.applyBonuses(); if (this.absCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)) @@ -971,7 +930,6 @@ public class CharacterItemManager { if (cost <= 0 || (gold.getNumOfItems() - cost) < 0) return false; - if (this.getOwner() != null && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { if (this.goldTradingAmount > 0) { ErrorPopupMsg.sendErrorPopup((PlayerCharacter) this.getOwner(), 195); @@ -982,25 +940,20 @@ public class CharacterItemManager { // Create gold from screatch instead of building strongbox // if the NPC is not slotted. - if (vendorBuilding == null) { - + if (vendorBuilding == null) return this.modifyInventoryGold(-cost); - } - if (vendorBuilding.getStrongboxValue() + cost > vendorBuilding.getMaxGold()) { - if (this.absCharacter.getObjectType() == GameObjectType.PlayerCharacter) { PlayerCharacter pc = (PlayerCharacter) this.absCharacter; if (pc.getClientConnection() != null) ErrorPopupMsg.sendErrorPopup(pc, 206); } - return false; } - // Update strongbox and inventory gold + if (!this.modifyInventoryGold(-cost)) return false; @@ -1026,7 +979,7 @@ public class CharacterItemManager { //Used for selling items to NPC public synchronized boolean sellToNPC(Building building, int cost, Item item) { - // Create gold from screatch instead of building strongbox + // Create gold from scratch instead of building strongbox // if the NPC is not slotted. if (this.getGoldInventory().getNumOfItems() + cost < 0) @@ -1063,11 +1016,6 @@ public class CharacterItemManager { return this.modifyInventoryGold(cost); } - /** - * This sells an item to an npc - * - * @return True on success - */ public synchronized boolean sellToNPC(Item itemToSell, NPC npc) { CharacterItemManager itemMan; @@ -1127,12 +1075,6 @@ public class CharacterItemManager { return true; } - /** - * This buys an item from an npc - * Handles transfer of item. - * - * @return True on success - */ public synchronized boolean buyFromNPC(Item purchasedItem, NPC npc) { CharacterItemManager itemMan; @@ -1162,45 +1104,27 @@ public class CharacterItemManager { // attempt to transfer item in db - if (purchasedItem.getObjectType() == GameObjectType.MobLoot) { - - Item newItem = ((MobLoot) purchasedItem).promoteToItem((PlayerCharacter) this.absCharacter); - if (newItem == null) - return false; - - if (!itemMan.removeItemFromInventory(purchasedItem)) - return false; - - if (!addItemToInventory(newItem)) - return false; - //Item was created and still a mobloot item, remove from npc production list in db. - - DbManager.NPCQueries.REMOVE_FROM_PRODUCTION_LIST(purchasedItem.getObjectUUID(), npc.getObjectUUID()); - - - } else { - if (!purchasedItem.moveItemToInventory((PlayerCharacter) this.absCharacter)) - return false; - - // Reset value + if (!purchasedItem.moveItemToInventory((PlayerCharacter) this.absCharacter)) + return false; - purchasedItem.value = (int) (purchasedItem.template.item_value * (purchasedItem.combat_health_current / purchasedItem.template.combat_health_full)); + // Reset value - // db transfer successfully, remove from this character - // skip this check if this is a mobLoot item (which is not in any inventory) - if (!itemMan.removeItemFromInventory(purchasedItem)) - return false; + purchasedItem.value = (int) (purchasedItem.template.item_value * (purchasedItem.combat_health_current / purchasedItem.template.combat_health_full)); - // add item to looter. + // db transfer successfully, remove from this character + // skip this check if this is a mobLoot item (which is not in any inventory) + if (!itemMan.removeItemFromInventory(purchasedItem)) + return false; - if (!addItemToInventory(purchasedItem)) - return false; - } + // add item to looter. + if (!addItemToInventory(purchasedItem)) + return false; } } // calculate new weights + calculateInventoryWeight(); itemMan.calculateInventoryWeight(); return true; From 01113fc3a695a089d1b0410a3a8e235d7b466e2d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 17 Apr 2024 14:24:05 -0400 Subject: [PATCH 185/378] Configure before setting cost --- src/engine/gameManager/ForgeManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c5180464..9a29a29f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -113,8 +113,10 @@ public enum ForgeManager implements Runnable { workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slots_used = calcAvailableSlots(workOrder); - // Cost to execute this workOrder + // Configure this production run. + workOrder.total_produced = 0; + workOrder.total_to_produce *= workOrder.slots_used; workOrder.production_cost = calcProductionCost(workOrder); // Set total cost for this production run @@ -122,9 +124,6 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); - workOrder.total_produced = 0; - workOrder.total_to_produce *= workOrder.slots_used; - // Create in-memory items and add to collections forgeWorkerOrderBatch(workOrder); From 919b29c38fe0ba06957778fdff5c8c1fbf5d63ec Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 08:15:17 -0400 Subject: [PATCH 186/378] Deduct cost from warehouse --- src/engine/gameManager/ForgeManager.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9a29a29f..0cd17868 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -124,6 +124,28 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); + // Deduct gold cost from building + + int strongbox = workOrder.vendor.building.getStrongboxValue(); + int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD); + + if (overflow > 1 || workOrder.production_cost_total.size() > 1) { + + // Deduct total cost from warehouse + + City city = workOrder.vendor.building.getCity(); + + if (city == null) + return 1; + + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return 1; + + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); + } + // Create in-memory items and add to collections forgeWorkerOrderBatch(workOrder); From dbd4c5d2461fc2e98cd41667d19eb6117a8d7df5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 08:59:10 -0400 Subject: [PATCH 187/378] Method added to replace collection --- src/engine/gameManager/ForgeManager.java | 1 + src/engine/gameManager/NPCManager.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0cd17868..b33cb3ca 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -423,4 +423,5 @@ public enum ForgeManager implements Runnable { return modifier; } + } diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 54efa093..960bcc6b 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -9,6 +9,7 @@ package engine.gameManager; import engine.InterestManagement.WorldGrid; +import engine.loot.WorkOrder; import engine.math.Quaternion; import engine.math.Vector3f; import engine.math.Vector3fImmutable; @@ -516,4 +517,14 @@ public enum NPCManager { return true; } + + public static ArrayList getAllCookingForVendor(NPC npc) { + + ArrayList itemList = new ArrayList<>(); + + for (WorkOrder workOrder : ForgeManager.vendorWorkOrderLookup.get(npc)) + itemList.addAll(workOrder.cooking); + + return itemList; + } } From 18587e281fbf05ae8def233605cc5835eff818f3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:03:35 -0400 Subject: [PATCH 188/378] refactored out collection --- src/engine/gameManager/ForgeManager.java | 4 ---- .../net/client/handlers/ItemProductionMsgHandler.java | 2 -- src/engine/net/client/msg/ManageNPCMsg.java | 6 +++--- src/engine/objects/NPC.java | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b33cb3ca..e57db32f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -35,7 +35,6 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static final HashMap inMemoryItemLookup = new HashMap<>(); - public static final HashMap> vendorItemLookup = new HashMap<>(); public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); public static final HashMap itemWorkOrderLookup = new HashMap<>(); @@ -356,7 +355,6 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.cooking.remove(memoryItem); - vendorItemLookup.get(workOrder.vendor).remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); } } @@ -375,8 +373,6 @@ public enum ForgeManager implements Runnable { workOrder.cooking.add(forged_item); inMemoryItemLookup.put(forged_item.objectUUID, forged_item); - vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); - vendorItemLookup.get(workOrder.vendor).add(forged_item); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); itemWorkOrderLookup.put(forged_item, workOrder); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index fdf173cc..088d2888 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -147,7 +147,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.cooking.remove(virtualItem); - ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); @@ -368,7 +367,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); workOrder.cooking.remove(targetItem); - ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(targetItem); // Refresh vendor's inventory to client diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 2b54b69d..4e422bcd 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -9,7 +9,6 @@ package engine.net.client.msg; -import engine.gameManager.ForgeManager; import engine.gameManager.NPCManager; import engine.gameManager.PowersManager; import engine.mbEnums.GameObjectType; @@ -434,9 +433,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - writer.putInt(ForgeManager.vendorItemLookup.get(npc).size()); + ArrayList cooking = NPCManager.getAllCookingForVendor(npc); + writer.putInt(cooking.size()); - for (Item item : ForgeManager.vendorItemLookup.get(npc)) { + for (Item item : cooking) { writer.put((byte) 0); // ? Unknown45 writer.putInt(item.getObjectType().ordinal()); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 5c22b4db..b567c200 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -871,10 +871,8 @@ public class NPC extends AbstractCharacter { // If NPC is a vendor then configure ForgeManager support - if (this.contract.isTrainer() == false) { - ForgeManager.vendorItemLookup.computeIfAbsent(this, k -> new ArrayList<>()); // Forge lookup + if (this.contract.isTrainer() == false) ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new ArrayList<>()); - } this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); From c1939075cdc11ebf54f4019c30931bf1bad43e64 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:07:23 -0400 Subject: [PATCH 189/378] Window refresh update --- .../client/handlers/ItemProductionMsgHandler.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 088d2888..afa3eb39 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -131,6 +131,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + // Remove from collections + + workOrder.cooking.remove(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); + // Persist item and add to vendor inventory Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); @@ -141,15 +146,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - // Remove from collections - - ItemProductionMsg outMsg = new ItemProductionMsg(vendor.building, vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - workOrder.cooking.remove(virtualItem); - ForgeManager.itemWorkOrderLookup.remove(virtualItem); - - } private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { From 6ecaa4dc0c110a594e8e35bfcd1bcac6ff8d684f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:07:49 -0400 Subject: [PATCH 190/378] Window refresh update --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index afa3eb39..fc23be25 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -128,11 +128,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void completeItem(int itemUUID, NPC vendor) { + // Remove virtualItem from collections + Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - // Remove from collections - workOrder.cooking.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); From adf686974d15fc70ddb78db2b3ffb2481ce8c5a3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:16:01 -0400 Subject: [PATCH 191/378] Window refresh update --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index fc23be25..1ff9d76d 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -133,6 +133,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + // Refresh the window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.cooking.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); From ca71079106eeb12fe684f4bd550b551ee65fa9d0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:16:38 -0400 Subject: [PATCH 192/378] Window refresh update --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 1ff9d76d..7dadb446 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -128,8 +128,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void completeItem(int itemUUID, NPC vendor) { - // Remove virtualItem from collections - Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); @@ -138,6 +136,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Remove virtualItem from collections + workOrder.cooking.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); From d76b670b75450bdefbfb32bf4b3a56dac104a59e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:18:30 -0400 Subject: [PATCH 193/378] Window refresh update --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 7dadb446..e4a1e28e 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -131,7 +131,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - // Refresh the window + // Refresh the window. SetPrice is used only to force a window refresh. + // What controls items displayed are the contents of the workOrders. (ManageNPCMsg) ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); From 0f2b46b898147c49ba4078cf24d9d4eb4396d2bd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:20:01 -0400 Subject: [PATCH 194/378] Window refresh update --- src/engine/gameManager/ForgeManager.java | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e57db32f..7dd46661 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -323,10 +323,13 @@ public enum ForgeManager implements Runnable { public static void completeWorkOrderBatch(WorkOrder workOrder) { - ArrayList toRemove = new ArrayList<>(); - for (Item workOrderItem : workOrder.cooking) { + // Remove the virtual items from the forge window + + workOrder.cooking.remove(workOrderItem); + itemWorkOrderLookup.remove(workOrderItem); + // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); @@ -339,23 +342,6 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - toRemove.add(workOrderItem); - } - - // Remove the negativeID virtual item from all collections - // other than the virtual item lookup map. Item will be - // persisted when bought/taken from vendor. - - for (Item memoryItem : toRemove) { - - // Remove the virtual items from the forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - workOrder.cooking.remove(memoryItem); - itemWorkOrderLookup.remove(memoryItem); } } From cba7ee4066a97e8c0e12c169a08e369fe1c03633 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:23:34 -0400 Subject: [PATCH 195/378] Window refresh update --- src/engine/gameManager/ForgeManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 7dd46661..869d2f8a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -330,6 +330,9 @@ public enum ForgeManager implements Runnable { workOrder.cooking.remove(workOrderItem); itemWorkOrderLookup.remove(workOrderItem); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); From b673ca963635155d652503b66f01adf7117e7817 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:27:50 -0400 Subject: [PATCH 196/378] Window refresh update --- src/engine/gameManager/ForgeManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 869d2f8a..ecee0905 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -327,12 +327,12 @@ public enum ForgeManager implements Runnable { // Remove the virtual items from the forge window - workOrder.cooking.remove(workOrderItem); - itemWorkOrderLookup.remove(workOrderItem); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + workOrder.cooking.remove(workOrderItem); + itemWorkOrderLookup.remove(workOrderItem); + // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); From f36239a67ee82d304aefe8f0e5cf89adb5811a69 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:30:59 -0400 Subject: [PATCH 197/378] Window refresh update --- src/engine/gameManager/ForgeManager.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ecee0905..49354b69 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -325,14 +325,6 @@ public enum ForgeManager implements Runnable { for (Item workOrderItem : workOrder.cooking) { - // Remove the virtual items from the forge window - - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - - workOrder.cooking.remove(workOrderItem); - itemWorkOrderLookup.remove(workOrderItem); - // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); @@ -345,6 +337,14 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + // Remove the virtual items from the forge window + + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + workOrder.cooking.remove(workOrderItem); + itemWorkOrderLookup.remove(workOrderItem); } } From 0ec2b436de8693937dcaa9f4fda472402c3a9527 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:38:01 -0400 Subject: [PATCH 198/378] Window refresh update --- src/engine/gameManager/ForgeManager.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 49354b69..e57db32f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -323,6 +323,8 @@ public enum ForgeManager implements Runnable { public static void completeWorkOrderBatch(WorkOrder workOrder) { + ArrayList toRemove = new ArrayList<>(); + for (Item workOrderItem : workOrder.cooking) { // Persist item @@ -338,13 +340,22 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + toRemove.add(workOrderItem); + } + + // Remove the negativeID virtual item from all collections + // other than the virtual item lookup map. Item will be + // persisted when bought/taken from vendor. + + for (Item memoryItem : toRemove) { + // Remove the virtual items from the forge window - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - workOrder.cooking.remove(workOrderItem); - itemWorkOrderLookup.remove(workOrderItem); + workOrder.cooking.remove(memoryItem); + itemWorkOrderLookup.remove(memoryItem); } } From 264094924b2f65afefa7533ffafdcbc47bf2f238 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:50:29 -0400 Subject: [PATCH 199/378] Proper accounting for workOrder removal post completion --- .../handlers/ItemProductionMsgHandler.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index e4a1e28e..4b92c693 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -142,6 +142,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.cooking.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + // WorkOrder exists until all items are completed or junked + // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) + + workOrder.slots_used = workOrder.slots_used - 1; + + if (workOrder.slots_used == 0) + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); + // Persist item and add to vendor inventory Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); @@ -364,12 +372,19 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (vendor.getBuilding() == null) return; - // Delete the item ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); workOrder.cooking.remove(targetItem); + // WorkOrder exists until all items are completed or junked + // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) + + workOrder.slots_used = workOrder.slots_used - 1; + + if (workOrder.slots_used == 0) + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); + // Refresh vendor's inventory to client outMsg = new ManageNPCMsg(vendor); From c03c1f4057c80c7461837f0f3d0974cfa32e8b54 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:11:27 -0400 Subject: [PATCH 200/378] Update to item effect serialization --- src/engine/net/client/msg/ManageNPCMsg.java | 30 +++++++++++++++------ src/engine/objects/Item.java | 9 ------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 4e422bcd..2aaaa484 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -476,15 +476,29 @@ public class ManageNPCMsg extends ClientNetMsg { else writer.putInt(-1497023830); - if ((prefix != null && !item.isRandom()) || (prefix != null && item.isComplete())) - writer.putInt(prefix.getToken()); - else - writer.putInt(0); + if (item.prefixToken == 0) { + if (!item.isComplete()) + writer.putInt(0); + else + writer.putInt(prefix.getToken()); + } else { + if (prefix != null) + writer.putInt(prefix.getToken()); + else + writer.putInt(0); + } - if ((suffix != null && !item.isRandom()) || (suffix != null && item.isComplete())) - writer.putInt(suffix.getToken()); - else - writer.putInt(0); + if (item.suffixToken == 0) { + if (!item.isComplete()) + writer.putInt(0); + else + writer.putInt(suffix.getToken()); + } else { + if (suffix != null) + writer.putInt(suffix.getToken()); + else + writer.putInt(0); + } writer.putString(item.name); } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index d5b7ddd5..bc437ea7 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -51,7 +51,6 @@ public class Item extends AbstractWorldObject { public int chargesRemaining; public mbEnums.EquipSlotType equipSlot; private boolean canDestroy; - private boolean isRandom = false; public int value; public OwnerType ownerType; public int templateID; @@ -1129,14 +1128,6 @@ public class Item extends AbstractWorldObject { this.value = value; } - public boolean isRandom() { - return isRandom; - } - - public void setRandom(boolean isRandom) { - this.isRandom = isRandom; - } - public boolean isCustomValue() { if (this.value == 0) return false; From 1a7f63ce051dba7e9ec65e6516b1805c587d1c58 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:32:36 -0400 Subject: [PATCH 201/378] lastNegativeId moved to ItemManager --- src/engine/db/handlers/dbContractHandler.java | 4 ++-- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/gameManager/ItemManager.java | 17 +++++++++++++++++ src/engine/objects/MobBase.java | 3 ++- src/engine/objects/MobLoot.java | 7 ++----- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/engine/db/handlers/dbContractHandler.java b/src/engine/db/handlers/dbContractHandler.java index 5cdb69f5..223417dd 100644 --- a/src/engine/db/handlers/dbContractHandler.java +++ b/src/engine/db/handlers/dbContractHandler.java @@ -10,10 +10,10 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.mbEnums; import engine.objects.Contract; import engine.objects.Item; -import engine.objects.MobLoot; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -66,7 +66,7 @@ public class dbContractHandler extends dbHandlerBase { int templateID = rs.getInt("templateID"); Item item = new Item(templateID); - item.objectUUID = MobLoot.lastNegativeID.decrementAndGet(); + item.objectUUID = ItemManager.lastNegativeID.decrementAndGet(); contract.getSellInventory().add(item); } diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e57db32f..dc74b877 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -291,7 +291,7 @@ public enum ForgeManager implements Runnable { // Item gets a negative id; a virtual in-memory only item // which is not persisted or added to the game cache. - forgedItem.objectUUID = MobLoot.lastNegativeID.getAndDecrement(); + forgedItem.objectUUID = ItemManager.lastNegativeID.getAndDecrement(); forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 149aa121..1e1d23f7 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -2,10 +2,13 @@ package engine.gameManager; import engine.mbEnums; import engine.objects.*; +import engine.powers.EffectsBase; +import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; import java.util.EnumSet; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; // • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ @@ -17,6 +20,8 @@ import java.util.concurrent.ConcurrentHashMap; public enum ItemManager { ITEMMANAGER; + public static final AtomicInteger lastNegativeID = new AtomicInteger(0); + public static Boolean ValidRace(Item item, mbEnums.MonsterType race) { if (item.template.item_race_req.isEmpty() && item.template.item_race_res.isEmpty()) @@ -220,4 +225,16 @@ public enum ItemManager { return true; } + + public static void addPrefixOrSuffix(Item item, int token) { + + EffectsBase effectsBase = PowersManager.getEffectByToken(token); + AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effectsBase.getIDString()); + + if (apa == null) + return; + + apa.applyEffectForItem(item, 0); + item.getEffectNames().add(effectsBase.getIDString()); + } } diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index fe573a4a..ee54309b 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -10,6 +10,7 @@ package engine.objects; import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.gameManager.LootManager; import engine.loot.BootySetEntry; import engine.mbEnums; @@ -126,7 +127,7 @@ public class MobBase extends AbstractGameObject { for (BootySetEntry equipmentSetEntry : equipList) { Item item = new Item(equipmentSetEntry.templateID); - item.objectUUID = MobLoot.lastNegativeID.decrementAndGet(); + item.objectUUID = ItemManager.lastNegativeID.decrementAndGet(); item.drop_chance = equipmentSetEntry.dropChance; item.equipSlot = item.template.item_eq_slots_or.iterator().next(); equip.put(item.equipSlot, item); diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index b24a8798..db718610 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -10,6 +10,7 @@ package engine.objects; import engine.gameManager.DbManager; +import engine.gameManager.ItemManager; import engine.gameManager.PowersManager; import engine.mbEnums; import engine.mbEnums.ItemType; @@ -17,8 +18,6 @@ import engine.mbEnums.OwnerType; import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; -import java.util.concurrent.atomic.AtomicInteger; - /** * An immutable, non-persistant implementation of Item * @@ -26,8 +25,6 @@ import java.util.concurrent.atomic.AtomicInteger; */ public final class MobLoot extends Item { - public static final AtomicInteger lastNegativeID = new AtomicInteger(0); - private boolean isDeleted = false; private boolean noSteal; private String prefix = ""; @@ -77,7 +74,7 @@ public final class MobLoot extends Item { * @return Id number */ private static int generateId() { - int id = lastNegativeID.decrementAndGet(); + int id = ItemManager.lastNegativeID.decrementAndGet(); //TODO Add a way to reclaim disposed IDs if this becomes a problem if (id == (-10000)) From 3071cb5847a4855eef06703f610dcafb59526022 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:40:03 -0400 Subject: [PATCH 202/378] Apply effects to item --- src/engine/gameManager/ForgeManager.java | 8 ++++++++ src/engine/gameManager/ItemManager.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index dc74b877..797866fd 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -313,6 +313,14 @@ public enum ForgeManager implements Runnable { else forgedItem.suffixToken = workOrder.suffixToken; + // Apple effects + + if (forgedItem.prefixToken != 0) + ItemManager.applyPrefixOrSuffix(forgedItem, forgedItem.prefixToken); + + if (forgedItem.suffixToken != 0) + ItemManager.applyPrefixOrSuffix(forgedItem, forgedItem.prefixToken); + // Forged random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 1e1d23f7..6c8aeebb 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -226,7 +226,7 @@ public enum ItemManager { return true; } - public static void addPrefixOrSuffix(Item item, int token) { + public static void applyPrefixOrSuffix(Item item, int token) { EffectsBase effectsBase = PowersManager.getEffectByToken(token); AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effectsBase.getIDString()); From 412ef0f642c6d1230af3a53adeee7dbc1a594c4f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:45:28 -0400 Subject: [PATCH 203/378] Do not remove until complete pressed --- src/engine/gameManager/ForgeManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 797866fd..db80987b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -66,7 +66,6 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } - ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); workOrder.runCompleted = true; } From 7309fdc62f725846192c28aaec8fbba8d5bee5f4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:46:31 -0400 Subject: [PATCH 204/378] Method moved to Warehouse --- src/engine/gameManager/ForgeManager.java | 38 +----------------------- src/engine/objects/Warehouse.java | 36 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index db80987b..75c627fa 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -166,7 +166,7 @@ public enum ForgeManager implements Runnable { if (!workOrder.vendor.getItemModTable().contains((template.modTable))) return 59; //59: This hireling does not have this formula - if (!calcCostOverrun(workOrder).isEmpty()) + if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) return 10; //18: You can't really afford that // Forge must be protected in order to access warehouse. @@ -244,42 +244,6 @@ public enum ForgeManager implements Runnable { return production_cost; } - public static HashMap calcCostOverrun(WorkOrder workOrder) { - - HashMap costMap = new HashMap<>(); - Warehouse warehouse; - - // See if we can meet gold only requirements and early exit - - if (workOrder.production_cost_total.size() == 1) { - if (workOrder.vendor.building.getStrongboxValue() > workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)) - return costMap; - } - - // Gold deficit exists so a warehouse is required - - warehouse = workOrder.vendor.building.getCity() == null ? null : workOrder.vendor.building.getCity().warehouse; - - if (warehouse == null) - return workOrder.production_cost_total; - - // Method returns a map of resourceType that a transaction overdrafts. - - HashMap overflowMap = new HashMap<>(); - - for (mbEnums.ResourceType resourceType : workOrder.production_cost_total.keySet()) { - - int debit = warehouse.resources.get(resourceType) - workOrder.production_cost_total.get(resourceType); - - // Locked resources are always unavailable - - if (debit < 0 || warehouse.locked.contains(resourceType)) - overflowMap.put(resourceType, debit); - } - - return overflowMap; - } - public static Item forgeItem(WorkOrder workOrder) { // Create new item from specified template diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 4891701e..53eebeba 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -11,6 +11,7 @@ package engine.objects; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.net.Dispatch; import engine.net.DispatchMessage; @@ -635,4 +636,39 @@ public class Warehouse { return warehouse.locked.contains(resourceType); } + public static HashMap calcCostOverrun(WorkOrder workOrder) { + + HashMap costMap = new HashMap<>(); + Warehouse warehouse; + + // See if we can meet gold only requirements and early exit + + if (workOrder.production_cost_total.size() == 1) { + if (workOrder.vendor.building.getStrongboxValue() > workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)) + return costMap; + } + + // Gold deficit exists so a warehouse is required + + warehouse = workOrder.vendor.building.getCity() == null ? null : workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return workOrder.production_cost_total; + + // Method returns a map of resourceType that a transaction overdrafts. + + HashMap overflowMap = new HashMap<>(); + + for (mbEnums.ResourceType resourceType : workOrder.production_cost_total.keySet()) { + + int debit = warehouse.resources.get(resourceType) - workOrder.production_cost_total.get(resourceType); + + // Locked resources are always unavailable + + if (debit < 0 || warehouse.locked.contains(resourceType)) + overflowMap.put(resourceType, debit); + } + + return overflowMap; + } } \ No newline at end of file From b1b635380a6388251061dc79e65942362111808b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:49:19 -0400 Subject: [PATCH 205/378] Completed items are identified --- src/engine/gameManager/ForgeManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 75c627fa..1cec29be 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -62,6 +62,7 @@ public enum ForgeManager implements Runnable { // Complete this workOrder. for (Item workOrderItem : workOrder.cooking) { + workOrderItem.flags.add(mbEnums.ItemFlags.Identified); ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); } @@ -298,6 +299,10 @@ public enum ForgeManager implements Runnable { for (Item workOrderItem : workOrder.cooking) { + // Identify completed items + + workOrderItem.flags.add(mbEnums.ItemFlags.Identified); + // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); From 0a6e40eb74821bac8b8f3b45088aca914511a98c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 10:55:07 -0400 Subject: [PATCH 206/378] removed for testing --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 1cec29be..bdaab742 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -278,13 +278,13 @@ public enum ForgeManager implements Runnable { forgedItem.suffixToken = workOrder.suffixToken; // Apple effects - +/* if (forgedItem.prefixToken != 0) ItemManager.applyPrefixOrSuffix(forgedItem, forgedItem.prefixToken); if (forgedItem.suffixToken != 0) ItemManager.applyPrefixOrSuffix(forgedItem, forgedItem.prefixToken); - +*/ // Forged random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) From 4549688ad7b64ac1f54b7f42697b158b824c4dcc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 08:43:12 -0400 Subject: [PATCH 207/378] Update to modifier returned --- src/engine/gameManager/ForgeManager.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index bdaab742..6bbce613 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -8,7 +8,6 @@ package engine.gameManager; -import engine.loot.ModTableEntry; import engine.loot.ModTypeTableEntry; import engine.loot.WorkOrder; import engine.mbEnums; @@ -16,7 +15,6 @@ import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; -import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -364,7 +362,6 @@ public enum ForgeManager implements Runnable { int modifier = 0; ModTypeTableEntry modTypeTableEntry = null; - ModTableEntry modRollEntry = null; int modifierRoll; switch (itemModType) { @@ -383,15 +380,8 @@ public enum ForgeManager implements Runnable { modifierRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (modifierRoll < 80) { - modifierRoll = LootManager.TableRoll(vendor.getLevel(), false); - modRollEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, modifierRoll); - } - - if (modRollEntry != null) { - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modRollEntry.action); - modifier = abstractPowerAction.getEffectsBase().getToken(); - } + if (modifierRoll < 80) + modifier = LootManager.TableRoll(vendor.getLevel(), false); return modifier; } From ac10b78d68f118d2fd1806f51d25a42a9d994a7c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 08:54:28 -0400 Subject: [PATCH 208/378] Work on adding modifiers --- src/engine/gameManager/ForgeManager.java | 28 ++++++++++++++++++------ src/engine/gameManager/ItemManager.java | 12 +++++----- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6bbce613..f475fc56 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -275,14 +275,10 @@ public enum ForgeManager implements Runnable { else forgedItem.suffixToken = workOrder.suffixToken; - // Apple effects -/* - if (forgedItem.prefixToken != 0) - ItemManager.applyPrefixOrSuffix(forgedItem, forgedItem.prefixToken); + // Apply Item effects for Prefix and Suffix tokens + + applyItemEffects(forgedItem); - if (forgedItem.suffixToken != 0) - ItemManager.applyPrefixOrSuffix(forgedItem, forgedItem.prefixToken); -*/ // Forged random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) @@ -291,6 +287,24 @@ public enum ForgeManager implements Runnable { return forgedItem; } + private static void applyItemEffects(Item forgedItem) { + + String prefixString; + String suffixString; + + EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); + EffectsBase prefixEffect = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); + + EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); + EffectsBase suffixEffect = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); + + if (forgedItem.prefixToken != 0) +// ItemManager.applyPrefixOrSuffix(forgedItem, prefixEffect.ac); + + if (forgedItem.suffixToken != 0) + // ItemManager.applyPrefixOrSuffix(forgedItem, suffixEffect); + } + public static void completeWorkOrderBatch(WorkOrder workOrder) { ArrayList toRemove = new ArrayList<>(); diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 6c8aeebb..e37a2a91 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -2,7 +2,6 @@ package engine.gameManager; import engine.mbEnums; import engine.objects.*; -import engine.powers.EffectsBase; import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; @@ -226,15 +225,14 @@ public enum ItemManager { return true; } - public static void applyPrefixOrSuffix(Item item, int token) { + public static void applyPrefixOrSuffix(Item item, String powerAction) { - EffectsBase effectsBase = PowersManager.getEffectByToken(token); - AbstractPowerAction apa = PowersManager.getPowerActionByIDString(effectsBase.getIDString()); + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(powerAction); - if (apa == null) + if (abstractPowerAction == null) return; - apa.applyEffectForItem(item, 0); - item.getEffectNames().add(effectsBase.getIDString()); + abstractPowerAction.applyEffectForItem(item, 0); + item.getEffectNames().add(powerAction); } } From 2c87e4817845c481706e9f9aaf7d40070f285884 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 08:55:04 -0400 Subject: [PATCH 209/378] Work on adding modifiers --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f475fc56..8e044786 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -298,10 +298,10 @@ public enum ForgeManager implements Runnable { EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); EffectsBase suffixEffect = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); - if (forgedItem.prefixToken != 0) + // if (forgedItem.prefixToken != 0) // ItemManager.applyPrefixOrSuffix(forgedItem, prefixEffect.ac); - if (forgedItem.suffixToken != 0) + // if (forgedItem.suffixToken != 0) // ItemManager.applyPrefixOrSuffix(forgedItem, suffixEffect); } From 13a75fcd5de811daa4a8bb142920ee8931a2c610 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 09:10:31 -0400 Subject: [PATCH 210/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 8e044786..e9a668f3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -15,6 +15,7 @@ import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; +import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -289,20 +290,21 @@ public enum ForgeManager implements Runnable { private static void applyItemEffects(Item forgedItem) { - String prefixString; - String suffixString; - EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); - EffectsBase prefixEffect = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); - EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); - EffectsBase suffixEffect = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); - // if (forgedItem.prefixToken != 0) -// ItemManager.applyPrefixOrSuffix(forgedItem, prefixEffect.ac); + if (forgedItem.prefixToken != 0) { + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(prefix.getIDString()); + abstractPowerAction.applyEffectForItem(forgedItem, 0); + forgedItem.getEffectNames().add(prefix.getName()); + } + + if (forgedItem.suffixToken != 0) { + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(suffix.getIDString()); + abstractPowerAction.applyEffectForItem(forgedItem, 0); + forgedItem.getEffectNames().add(suffix.getName()); + } - // if (forgedItem.suffixToken != 0) - // ItemManager.applyPrefixOrSuffix(forgedItem, suffixEffect); } public static void completeWorkOrderBatch(WorkOrder workOrder) { From 501c68b1e36fc1e73841bdc417763cdf1b993992 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 09:34:49 -0400 Subject: [PATCH 211/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e9a668f3..e36fda80 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -8,6 +8,7 @@ package engine.gameManager; +import engine.loot.ModTableEntry; import engine.loot.ModTypeTableEntry; import engine.loot.WorkOrder; import engine.mbEnums; @@ -290,16 +291,18 @@ public enum ForgeManager implements Runnable { private static void applyItemEffects(Item forgedItem) { - EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); - EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); + ModTableEntry prefixEntry = ModTableEntry.rollTable(forgedItem.template.modTable, forgedItem.prefixToken); + ModTableEntry suffixEntry = ModTableEntry.rollTable(forgedItem.template.modTable, forgedItem.suffixToken); if (forgedItem.prefixToken != 0) { + EffectsBase prefix = PowersManager.getEffectByIDString(prefixEntry.action); AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(prefix.getIDString()); abstractPowerAction.applyEffectForItem(forgedItem, 0); forgedItem.getEffectNames().add(prefix.getName()); } - if (forgedItem.suffixToken != 0) { + if (forgedItem.prefixToken != 0) { + EffectsBase suffix = PowersManager.getEffectByIDString(suffixEntry.action); AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(suffix.getIDString()); abstractPowerAction.applyEffectForItem(forgedItem, 0); forgedItem.getEffectNames().add(suffix.getName()); From 225dc2af18d75e4fdfd564475629639490690e37 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 09:42:48 -0400 Subject: [PATCH 212/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e36fda80..9607ecea 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -401,6 +401,8 @@ public enum ForgeManager implements Runnable { if (modifierRoll < 80) modifier = LootManager.TableRoll(vendor.getLevel(), false); + else + modifier = 0; return modifier; } From 90271890d746010a902d411002acf5049a5e472e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 09:59:04 -0400 Subject: [PATCH 213/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9607ecea..64f3873a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -399,8 +399,12 @@ public enum ForgeManager implements Runnable { modifierRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (modifierRoll < 80) + if (modifierRoll < 80) { modifier = LootManager.TableRoll(vendor.getLevel(), false); + ModTableEntry modTableEntry = ModTableEntry.rollTable(modTable, modifier); + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modTableEntry.action); + modifier = abstractPowerAction.getEffectsBase().getToken(); + } else modifier = 0; From 24a05543c8fa44a46ffc2cb842fe4971794b2941 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 10:11:56 -0400 Subject: [PATCH 214/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 64f3873a..75d96b86 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -381,6 +381,7 @@ public enum ForgeManager implements Runnable { int modifier = 0; ModTypeTableEntry modTypeTableEntry = null; + ModTableEntry modRollEntry = null; int modifierRoll; switch (itemModType) { @@ -400,13 +401,14 @@ public enum ForgeManager implements Runnable { modifierRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (modifierRoll < 80) { - modifier = LootManager.TableRoll(vendor.getLevel(), false); - ModTableEntry modTableEntry = ModTableEntry.rollTable(modTable, modifier); - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modTableEntry.action); + modifierRoll = LootManager.TableRoll(vendor.getLevel(), false); + modRollEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, modifierRoll); + } + + if (modRollEntry != null) { + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modRollEntry.action); modifier = abstractPowerAction.getEffectsBase().getToken(); } - else - modifier = 0; return modifier; } From c133b2da5c3cdf1f91abd9a7b60ca8e5685700ae Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 10:20:02 -0400 Subject: [PATCH 215/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 75d96b86..12f15ee5 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -291,18 +291,15 @@ public enum ForgeManager implements Runnable { private static void applyItemEffects(Item forgedItem) { - ModTableEntry prefixEntry = ModTableEntry.rollTable(forgedItem.template.modTable, forgedItem.prefixToken); - ModTableEntry suffixEntry = ModTableEntry.rollTable(forgedItem.template.modTable, forgedItem.suffixToken); - if (forgedItem.prefixToken != 0) { - EffectsBase prefix = PowersManager.getEffectByIDString(prefixEntry.action); + EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(prefix.getIDString()); abstractPowerAction.applyEffectForItem(forgedItem, 0); forgedItem.getEffectNames().add(prefix.getName()); } if (forgedItem.prefixToken != 0) { - EffectsBase suffix = PowersManager.getEffectByIDString(suffixEntry.action); + EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(suffix.getIDString()); abstractPowerAction.applyEffectForItem(forgedItem, 0); forgedItem.getEffectNames().add(suffix.getName()); From 589ea1bce83632c1a962dbc66d319cd17f70d35f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 10:26:21 -0400 Subject: [PATCH 216/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 12f15ee5..99110089 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -295,14 +295,12 @@ public enum ForgeManager implements Runnable { EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(prefix.getIDString()); abstractPowerAction.applyEffectForItem(forgedItem, 0); - forgedItem.getEffectNames().add(prefix.getName()); } if (forgedItem.prefixToken != 0) { EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(suffix.getIDString()); abstractPowerAction.applyEffectForItem(forgedItem, 0); - forgedItem.getEffectNames().add(suffix.getName()); } } From c19c5166695cd42fd6e4808d5025b8c25edf16ca Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 10:39:45 -0400 Subject: [PATCH 217/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 99110089..4580b6af 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -293,14 +293,12 @@ public enum ForgeManager implements Runnable { if (forgedItem.prefixToken != 0) { EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(prefix.getIDString()); - abstractPowerAction.applyEffectForItem(forgedItem, 0); + forgedItem.addPermanentEnchantment(prefix.getIDString(), 0); } if (forgedItem.prefixToken != 0) { EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(suffix.getIDString()); - abstractPowerAction.applyEffectForItem(forgedItem, 0); + forgedItem.addPermanentEnchantment(suffix.getIDString(), 0); } } From c0ed59f14fdbf89142309f837db931f49e3d5c6d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 10:43:39 -0400 Subject: [PATCH 218/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 4580b6af..b7cd48d3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -296,7 +296,7 @@ public enum ForgeManager implements Runnable { forgedItem.addPermanentEnchantment(prefix.getIDString(), 0); } - if (forgedItem.prefixToken != 0) { + if (forgedItem.suffixToken != 0) { EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); forgedItem.addPermanentEnchantment(suffix.getIDString(), 0); } From 726d471e956ae16d59d2a4f7543ff7e81c660a79 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 10:57:51 -0400 Subject: [PATCH 219/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b7cd48d3..af12f74a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -400,7 +400,7 @@ public enum ForgeManager implements Runnable { if (modRollEntry != null) { AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modRollEntry.action); - modifier = abstractPowerAction.getEffectsBase().getToken(); + modifier = abstractPowerAction.getParent().token; } return modifier; From 171c79dcf6a9540117db4751a98cef0b4bca253a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 11:02:35 -0400 Subject: [PATCH 220/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index af12f74a..78dd0ba4 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -374,8 +374,8 @@ public enum ForgeManager implements Runnable { int modifier = 0; ModTypeTableEntry modTypeTableEntry = null; - ModTableEntry modRollEntry = null; - int modifierRoll; + ModTableEntry modTableEntry = null; + int rollForModifier; switch (itemModType) { case PREFIX: @@ -391,16 +391,16 @@ public enum ForgeManager implements Runnable { if (modTypeTableEntry == null) return 0; - modifierRoll = ThreadLocalRandom.current().nextInt(1, 100 + 1); + rollForModifier = ThreadLocalRandom.current().nextInt(1, 100 + 1); - if (modifierRoll < 80) { - modifierRoll = LootManager.TableRoll(vendor.getLevel(), false); - modRollEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, modifierRoll); + if (rollForModifier < 80) { + rollForModifier = LootManager.TableRoll(vendor.getLevel(), false); + modTableEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, rollForModifier); } - if (modRollEntry != null) { - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modRollEntry.action); - modifier = abstractPowerAction.getParent().token; + if (modTableEntry != null) { + AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modTableEntry.action); + modifier = abstractPowerAction.getEffectsBase().getToken(); } return modifier; From 99671697ba1d807c2a5f3d67df725c5c44053110 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 11:05:30 -0400 Subject: [PATCH 221/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 78dd0ba4..a59ebc66 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -394,8 +394,8 @@ public enum ForgeManager implements Runnable { rollForModifier = ThreadLocalRandom.current().nextInt(1, 100 + 1); if (rollForModifier < 80) { - rollForModifier = LootManager.TableRoll(vendor.getLevel(), false); - modTableEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, rollForModifier); + int randomModifier = LootManager.TableRoll(vendor.getLevel(), false); + modTableEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, randomModifier); } if (modTableEntry != null) { From 92c8430031c4c027000999e39b5894a5cb267a7c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 11:13:31 -0400 Subject: [PATCH 222/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a59ebc66..86ffc095 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -379,12 +379,12 @@ public enum ForgeManager implements Runnable { switch (itemModType) { case PREFIX: - modifier = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(modTable)); - modTypeTableEntry = ModTypeTableEntry.rollTable(modifier, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + int randomPrefix = vendor.getModTypeTable().get(vendor.getItemModTable().indexOf(modTable)); + modTypeTableEntry = ModTypeTableEntry.rollTable(randomPrefix, ThreadLocalRandom.current().nextInt(1, 100 + 1)); break; case SUFFIX: - modifier = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(modTable)); - modTypeTableEntry = ModTypeTableEntry.rollTable(modifier, ThreadLocalRandom.current().nextInt(1, 100 + 1)); + int randomSuffix = vendor.getModSuffixTable().get(vendor.getItemModTable().indexOf(modTable)); + modTypeTableEntry = ModTypeTableEntry.rollTable(randomSuffix, ThreadLocalRandom.current().nextInt(1, 100 + 1)); break; } @@ -396,9 +396,6 @@ public enum ForgeManager implements Runnable { if (rollForModifier < 80) { int randomModifier = LootManager.TableRoll(vendor.getLevel(), false); modTableEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, randomModifier); - } - - if (modTableEntry != null) { AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modTableEntry.action); modifier = abstractPowerAction.getEffectsBase().getToken(); } From d0df4062361ab521b2e374b20900c775e4869fcb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 11:53:53 -0400 Subject: [PATCH 223/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 86ffc095..85b92d1f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -16,7 +16,6 @@ import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; -import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -396,8 +395,8 @@ public enum ForgeManager implements Runnable { if (rollForModifier < 80) { int randomModifier = LootManager.TableRoll(vendor.getLevel(), false); modTableEntry = ModTableEntry.rollTable(modTypeTableEntry.modTableID, randomModifier); - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(modTableEntry.action); - modifier = abstractPowerAction.getEffectsBase().getToken(); + EffectsBase effectsBase = PowersManager.getEffectByIDString(modTableEntry.action); + modifier = effectsBase.getToken(); } return modifier; From d64bd193d8296ff3b129da968d008856e3494d33 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 12:13:33 -0400 Subject: [PATCH 224/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 85b92d1f..dd09bbde 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -276,10 +276,6 @@ public enum ForgeManager implements Runnable { else forgedItem.suffixToken = workOrder.suffixToken; - // Apply Item effects for Prefix and Suffix tokens - - applyItemEffects(forgedItem); - // Forged random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) @@ -316,6 +312,10 @@ public enum ForgeManager implements Runnable { Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); + // Apply Item effects for Prefix and Suffix tokens + + applyItemEffects(workOrderItem); + // add to the vendor inventory workOrder.vendor.charItemManager.addItemToInventory(completedItem); From a859150a207cb09a8755f0d771faac462b1371b1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 12:17:37 -0400 Subject: [PATCH 225/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index dd09bbde..ae3ad916 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -314,7 +314,7 @@ public enum ForgeManager implements Runnable { // Apply Item effects for Prefix and Suffix tokens - applyItemEffects(workOrderItem); + applyItemEffects(completedItem); // add to the vendor inventory From cca4521c939a1458189857ae13549dbeb3465edd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 12:28:30 -0400 Subject: [PATCH 226/378] Item prefix and suffix applied --- src/engine/gameManager/ForgeManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ae3ad916..0ddbbe65 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -314,6 +314,9 @@ public enum ForgeManager implements Runnable { // Apply Item effects for Prefix and Suffix tokens + completedItem.prefixToken = workOrderItem.prefixToken; + completedItem.suffixToken = workOrderItem.suffixToken; + applyItemEffects(completedItem); // add to the vendor inventory From 98d03620bc895d99ab7b025f549c48b7ea0ebaeb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 12:33:55 -0400 Subject: [PATCH 227/378] Persisting effects in complete item --- src/engine/gameManager/ForgeManager.java | 28 ++----------------- src/engine/gameManager/ItemManager.java | 25 +++++++++++++++++ .../handlers/ItemProductionMsgHandler.java | 8 ++++++ 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 0ddbbe65..15596b37 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -101,7 +101,7 @@ public enum ForgeManager implements Runnable { public static int submit(WorkOrder workOrder) { - int validation_result = ForgeManager.validate(workOrder); + int validation_result = ItemManager.validate(workOrder); if (validation_result != 0) return validation_result; @@ -154,30 +154,6 @@ public enum ForgeManager implements Runnable { return validation_result; } - public static int validate(WorkOrder workOrder) { - - int validation_result = 0; - - ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); - - if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) - return 30; //30: That person cannot carry that item - - if (!workOrder.vendor.getItemModTable().contains((template.modTable))) - return 59; //59: This hireling does not have this formula - - if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) - return 10; //18: You can't really afford that - - // Forge must be protected in order to access warehouse. - - if (calcProductionCost(workOrder).size() > 1) - if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) - return 193; //193: Production denied: This building must be protected to gain access to warehouse - - return validation_result; - } - public static long calcRollingDuration(WorkOrder workOrder) { float rollingDuration; @@ -284,7 +260,7 @@ public enum ForgeManager implements Runnable { return forgedItem; } - private static void applyItemEffects(Item forgedItem) { + public static void applyItemEffects(Item forgedItem) { if (forgedItem.prefixToken != 0) { EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index e37a2a91..fc461cb2 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -1,5 +1,6 @@ package engine.gameManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.*; import engine.powers.poweractions.AbstractPowerAction; @@ -235,4 +236,28 @@ public enum ItemManager { abstractPowerAction.applyEffectForItem(item, 0); item.getEffectNames().add(powerAction); } + + public static int validate(WorkOrder workOrder) { + + int validation_result = 0; + + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) + return 30; //30: That person cannot carry that item + + if (!workOrder.vendor.getItemModTable().contains((template.modTable))) + return 59; //59: This hireling does not have this formula + + if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) + return 10; //18: You can't really afford that + + // Forge must be protected in order to access warehouse. + + if (ForgeManager.calcProductionCost(workOrder).size() > 1) + if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) + return 193; //193: Production denied: This building must be protected to gain access to warehouse + + return validation_result; + } } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 4b92c693..0dfdfd3f 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -153,6 +153,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Persist item and add to vendor inventory Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); + + // Apply Item effects for Prefix and Suffix tokens + + completedItem.prefixToken = virtualItem.prefixToken; + completedItem.suffixToken = virtualItem.suffixToken; + + ForgeManager.applyItemEffects(completedItem); + vendor.charItemManager.addItemToInventory(completedItem); ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); From 80aa413ea808973ed0bdeeae8a2c66a73c68c720 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 12:37:55 -0400 Subject: [PATCH 228/378] Methods moved to itemmanger --- src/engine/gameManager/ForgeManager.java | 22 ++++--------------- src/engine/gameManager/ItemManager.java | 15 +++++++++++++ .../handlers/ItemProductionMsgHandler.java | 3 ++- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 15596b37..dfa6b57d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -78,7 +78,7 @@ public enum ForgeManager implements Runnable { // Create new set of in-memory only virtual items - forgeWorkerOrderBatch(workOrder); + forgeWorkOrderBatch(workOrder); // enQueue this workOrder again; back into the oven // until all items for this workOrder are completed. @@ -146,7 +146,7 @@ public enum ForgeManager implements Runnable { // Create in-memory items and add to collections - forgeWorkerOrderBatch(workOrder); + forgeWorkOrderBatch(workOrder); Logger.info(workOrder.toString()); forge.add(workOrder); @@ -260,20 +260,6 @@ public enum ForgeManager implements Runnable { return forgedItem; } - public static void applyItemEffects(Item forgedItem) { - - if (forgedItem.prefixToken != 0) { - EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); - forgedItem.addPermanentEnchantment(prefix.getIDString(), 0); - } - - if (forgedItem.suffixToken != 0) { - EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); - forgedItem.addPermanentEnchantment(suffix.getIDString(), 0); - } - - } - public static void completeWorkOrderBatch(WorkOrder workOrder) { ArrayList toRemove = new ArrayList<>(); @@ -293,7 +279,7 @@ public enum ForgeManager implements Runnable { completedItem.prefixToken = workOrderItem.prefixToken; completedItem.suffixToken = workOrderItem.suffixToken; - applyItemEffects(completedItem); + ItemManager.applyItemEffects(completedItem); // add to the vendor inventory @@ -323,7 +309,7 @@ public enum ForgeManager implements Runnable { } } - public static void forgeWorkerOrderBatch(WorkOrder workOrder) { + public static void forgeWorkOrderBatch(WorkOrder workOrder) { // New completion time for this batch diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index fc461cb2..83e8213f 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -3,6 +3,7 @@ package engine.gameManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.*; +import engine.powers.EffectsBase; import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; @@ -260,4 +261,18 @@ public enum ItemManager { return validation_result; } + + public static void applyItemEffects(Item forgedItem) { + + if (forgedItem.prefixToken != 0) { + EffectsBase prefix = PowersManager.getEffectByToken(forgedItem.prefixToken); + forgedItem.addPermanentEnchantment(prefix.getIDString(), 0); + } + + if (forgedItem.suffixToken != 0) { + EffectsBase suffix = PowersManager.getEffectByToken(forgedItem.suffixToken); + forgedItem.addPermanentEnchantment(suffix.getIDString(), 0); + } + + } } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 0dfdfd3f..f4984f13 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -13,6 +13,7 @@ import engine.exception.MsgSendException; import engine.gameManager.ChatManager; import engine.gameManager.DbManager; import engine.gameManager.ForgeManager; +import engine.gameManager.ItemManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.ItemType; @@ -159,7 +160,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { completedItem.prefixToken = virtualItem.prefixToken; completedItem.suffixToken = virtualItem.suffixToken; - ForgeManager.applyItemEffects(completedItem); + ItemManager.applyItemEffects(completedItem); vendor.charItemManager.addItemToInventory(completedItem); From a46205b67bf093f90e266d4ea0ce9d66185f2ffc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 12:45:05 -0400 Subject: [PATCH 229/378] Uses mainline cache for virtual items --- src/engine/gameManager/ForgeManager.java | 4 ++-- .../net/client/handlers/ItemProductionMsgHandler.java | 8 ++++---- src/engine/net/client/msg/ItemProductionMsg.java | 9 ++------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index dfa6b57d..ecd90360 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -33,7 +33,6 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final HashMap inMemoryItemLookup = new HashMap<>(); public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); public static final HashMap itemWorkOrderLookup = new HashMap<>(); @@ -306,6 +305,7 @@ public enum ForgeManager implements Runnable { workOrder.cooking.remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); + DbManager.removeFromCache(memoryItem); } } @@ -322,7 +322,7 @@ public enum ForgeManager implements Runnable { // Add virtual item to in-memory caches workOrder.cooking.add(forged_item); - inMemoryItemLookup.put(forged_item.objectUUID, forged_item); + DbManager.addToCache(forged_item); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); itemWorkOrderLookup.put(forged_item, workOrder); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index f4984f13..7c9116ef 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -129,7 +129,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void completeItem(int itemUUID, NPC vendor) { - Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + Item virtualItem = Item.getFromCache(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); // Refresh the window. SetPrice is used only to force a window refresh. @@ -142,6 +142,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.cooking.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + DbManager.removeFromCache(virtualItem); // WorkOrder exists until all items are completed or junked // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) @@ -364,7 +365,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { try { - targetItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + targetItem = Item.getFromCache(itemUUID); PlayerCharacter player = origin.getPlayerCharacter(); @@ -381,10 +382,9 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (vendor.getBuilding() == null) return; - - ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); workOrder.cooking.remove(targetItem); + DbManager.removeFromCache(targetItem); // WorkOrder exists until all items are completed or junked // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index bc813d64..76f851ac 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -10,7 +10,6 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; -import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.net.*; @@ -142,11 +141,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 1); - Item item; - if (this.itemUUID > 0) - item = Item.getFromCache(this.itemUUID); - else - item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + Item item = Item.getFromCache(this.itemUUID); if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); @@ -237,7 +232,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.putInt(1); - Item toRoll = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + Item toRoll = Item.getFromCache(this.itemUUID); writer.putInt(-1497023830); this.pToken = toRoll.prefixToken; From 70e6756651d9cdda7bd2b7f2c671b3b09bca3a9e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 13:01:21 -0400 Subject: [PATCH 230/378] debitWorkOrderCost method created --- src/engine/gameManager/ForgeManager.java | 31 +++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ecd90360..989b5cab 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -123,6 +123,23 @@ public enum ForgeManager implements Runnable { // Deduct gold cost from building + debitWorkOrderCost(workOrder); + + // Create in-memory items and add to collections + + forgeWorkOrderBatch(workOrder); + + // Submit workOrder for next completion cycle + + forge.add(workOrder); + + Logger.info(workOrder.toString()); + + return validation_result; + } + + public static boolean debitWorkOrderCost(WorkOrder workOrder) { + int strongbox = workOrder.vendor.building.getStrongboxValue(); int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD); @@ -133,24 +150,16 @@ public enum ForgeManager implements Runnable { City city = workOrder.vendor.building.getCity(); if (city == null) - return 1; + return false; Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; if (warehouse == null) - return 1; + return false; workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); } - - // Create in-memory items and add to collections - - forgeWorkOrderBatch(workOrder); - - Logger.info(workOrder.toString()); - forge.add(workOrder); - - return validation_result; + return true; } public static long calcRollingDuration(WorkOrder workOrder) { From ac347db0c8367dc330eb9a75f90949494926ccf6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 13:05:19 -0400 Subject: [PATCH 231/378] debitWorkOrderCost method created --- src/engine/gameManager/ForgeManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 989b5cab..7ca3ca0d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -123,7 +123,8 @@ public enum ForgeManager implements Runnable { // Deduct gold cost from building - debitWorkOrderCost(workOrder); + if (debitWorkOrderCost(workOrder) == false) + return 58; //58: The formula is beyond the means of this facility // Create in-memory items and add to collections From f3e266cf46d2ebbff9b0f83c647794b1e760022d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 13:21:53 -0400 Subject: [PATCH 232/378] Class cleanup --- src/engine/gameManager/ForgeManager.java | 60 +++++++++++++----------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 7ca3ca0d..2101f3a1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -14,7 +14,10 @@ import engine.loot.WorkOrder; import engine.mbEnums; import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; -import engine.objects.*; +import engine.objects.Item; +import engine.objects.ItemTemplate; +import engine.objects.NPC; +import engine.objects.Warehouse; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -100,18 +103,24 @@ public enum ForgeManager implements Runnable { public static int submit(WorkOrder workOrder) { + // Make sure vendor can roll the formulae, warehouse can afford + // the wordOrder and other related checks. + int validation_result = ItemManager.validate(workOrder); + // The return code is used by the submitter as a + // popup error message to the player. + if (validation_result != 0) return validation_result; + // Configure this production run. + workOrder.workOrderID = wordOrderCounter.incrementAndGet(); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slots_used = calcAvailableSlots(workOrder); - // Configure this production run. - workOrder.total_produced = 0; workOrder.total_to_produce *= workOrder.slots_used; workOrder.production_cost = calcProductionCost(workOrder); @@ -139,30 +148,6 @@ public enum ForgeManager implements Runnable { return validation_result; } - public static boolean debitWorkOrderCost(WorkOrder workOrder) { - - int strongbox = workOrder.vendor.building.getStrongboxValue(); - int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD); - - if (overflow > 1 || workOrder.production_cost_total.size() > 1) { - - // Deduct total cost from warehouse - - City city = workOrder.vendor.building.getCity(); - - if (city == null) - return false; - - Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; - - if (warehouse == null) - return false; - - workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); - } - return true; - } - public static long calcRollingDuration(WorkOrder workOrder) { float rollingDuration; @@ -377,4 +362,25 @@ public enum ForgeManager implements Runnable { return modifier; } + public static boolean debitWorkOrderCost(WorkOrder workOrder) { + + int strongbox = workOrder.vendor.building.getStrongboxValue(); + int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD); + + if (overflow > 1 || workOrder.production_cost_total.size() > 1) { + + // Deduct total cost from warehouse + + if (workOrder.vendor.building.getCity() == null) + return false; + + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return false; + + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); + } + return true; + } } From 6cba850af58fcc09fe98291412dc31ae6c4724a2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 13:26:44 -0400 Subject: [PATCH 233/378] Class cleanup and comment fixes --- src/engine/gameManager/ForgeManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 2101f3a1..b207e776 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -103,13 +103,13 @@ public enum ForgeManager implements Runnable { public static int submit(WorkOrder workOrder) { - // Make sure vendor can roll the formulae, warehouse can afford - // the wordOrder and other related checks. + // Make sure vendor can roll the formulae, warehouse can + // afford this wordOrder and other related checks. int validation_result = ItemManager.validate(workOrder); // The return code is used by the submitter as a - // popup error message to the player. + // popup error message for the player. if (validation_result != 0) return validation_result; @@ -172,12 +172,12 @@ public enum ForgeManager implements Runnable { int availableSlots = workOrder.vendor.getRank(); - // Slots currently used up by the npc workOrders + // Subtract slots currently being used by npc workOrders for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) availableSlots = availableSlots - npcWorkOrder.slots_used; - // Single item rolls are msg_size of 0; + // Single item rolls are always a single slot if (availableSlots > 0 && !workOrder.multiple_slot_request) availableSlots = 1; From 692e7ec4165b43a25d5553c4b9e910fdb33c3ff7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 13:35:04 -0400 Subject: [PATCH 234/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b207e776..59bdb421 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -288,8 +288,6 @@ public enum ForgeManager implements Runnable { } // Remove the negativeID virtual item from all collections - // other than the virtual item lookup map. Item will be - // persisted when bought/taken from vendor. for (Item memoryItem : toRemove) { From cc324777d10b550f32bb1f14afeb3b1e3da3a379 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 15:54:31 -0400 Subject: [PATCH 235/378] Warehouse withdraws are persisted --- src/engine/gameManager/ForgeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 59bdb421..4057df99 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -378,6 +378,7 @@ public enum ForgeManager implements Runnable { return false; workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); + DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); } return true; } From 89f672e0b06b5b491f419cf0acb0bd5886759027 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 15:58:01 -0400 Subject: [PATCH 236/378] json constructor for workOrders --- src/engine/loot/WorkOrder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 17a0eb4c..d5f5b2da 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -45,6 +45,10 @@ public class WorkOrder implements Delayed { } + public WorkOrder(String json) { + + } + @Override public long getDelay(TimeUnit unit) { From a83008ea4f35f1bbeb0319cd6f0807a9283c3b6a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 16:00:58 -0400 Subject: [PATCH 237/378] Removed bypass in prep for db load. --- src/engine/gameManager/ForgeManager.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 4057df99..b02ce744 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -23,7 +23,6 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; -import java.util.Objects; import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; import java.util.concurrent.ThreadLocalRandom; @@ -53,11 +52,6 @@ public enum ForgeManager implements Runnable { Logger.error(e); } - // Completed or canceled work orders are not re-enqueued - - if (Objects.requireNonNull(workOrder).runCanceled || workOrder.runCompleted) - continue; - if (workOrder.total_produced >= workOrder.total_to_produce) { // Complete this workOrder. From 6a72a83076897cf55f9be73b992d59c4ebc22d95 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 16:22:22 -0400 Subject: [PATCH 238/378] Must be in a building and in city --- src/engine/gameManager/ItemManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 83e8213f..eeb28808 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -244,6 +244,12 @@ public enum ItemManager { ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + if (workOrder.vendor.getBuilding() == null) + return 58; //58: The formula is beyond the means of this facility + + if (workOrder.vendor.getBuilding().getCity() == null) + return 58; //58: The formula is beyond the means of this facility + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) return 30; //30: That person cannot carry that item From 364fb40e0bb7c7ee7c87c40357223f9df3be911d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 16:52:24 -0400 Subject: [PATCH 239/378] junk, complete and produce wrapped with same lock as warehouse. --- src/engine/gameManager/ForgeManager.java | 16 +- .../handlers/ItemProductionMsgHandler.java | 148 ++++++++++-------- 2 files changed, 89 insertions(+), 75 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b02ce744..6250ce78 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -14,10 +14,7 @@ import engine.loot.WorkOrder; import engine.mbEnums; import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; -import engine.objects.Item; -import engine.objects.ItemTemplate; -import engine.objects.NPC; -import engine.objects.Warehouse; +import engine.objects.*; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -108,6 +105,10 @@ public enum ForgeManager implements Runnable { if (validation_result != 0) return validation_result; + City city = workOrder.vendor.building.getCity(); + city.transactionLock.writeLock().lock(); + + try { // Configure this production run. workOrder.workOrderID = wordOrderCounter.incrementAndGet(); @@ -137,8 +138,11 @@ public enum ForgeManager implements Runnable { forge.add(workOrder); - Logger.info(workOrder.toString()); - + } catch (Exception e) { + Logger.error(e); + } finally { + city.transactionLock.writeLock().unlock(); + } return validation_result; } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 7c9116ef..48a7eea7 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -24,10 +24,7 @@ import engine.net.client.msg.ClientNetMsg; import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.ItemProductionMsg; import engine.net.client.msg.ManageNPCMsg; -import engine.objects.CharacterItemManager; -import engine.objects.Item; -import engine.objects.NPC; -import engine.objects.PlayerCharacter; +import engine.objects.*; import org.pmw.tinylog.Logger; import java.util.HashMap; @@ -132,44 +129,54 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { Item virtualItem = Item.getFromCache(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - // Refresh the window. SetPrice is used only to force a window refresh. - // What controls items displayed are the contents of the workOrders. (ManageNPCMsg) + City city = workOrder.vendor.building.getCity(); + city.transactionLock.writeLock().lock(); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + try { - // Remove virtualItem from collections + // Refresh the window. SetPrice is used only to force a window refresh. + // What controls items displayed are the contents of the workOrders. (ManageNPCMsg) - workOrder.cooking.remove(virtualItem); - ForgeManager.itemWorkOrderLookup.remove(virtualItem); - DbManager.removeFromCache(virtualItem); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - // WorkOrder exists until all items are completed or junked - // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) + // Remove virtualItem from collections - workOrder.slots_used = workOrder.slots_used - 1; + workOrder.cooking.remove(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); + DbManager.removeFromCache(virtualItem); - if (workOrder.slots_used == 0) - ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); + // WorkOrder exists until all items are completed or junked + // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) - // Persist item and add to vendor inventory + workOrder.slots_used = workOrder.slots_used - 1; - Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); + if (workOrder.slots_used == 0) + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); - // Apply Item effects for Prefix and Suffix tokens + // Persist item and add to vendor inventory - completedItem.prefixToken = virtualItem.prefixToken; - completedItem.suffixToken = virtualItem.suffixToken; + Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); - ItemManager.applyItemEffects(completedItem); + // Apply Item effects for Prefix and Suffix tokens - vendor.charItemManager.addItemToInventory(completedItem); + completedItem.prefixToken = virtualItem.prefixToken; + completedItem.suffixToken = virtualItem.suffixToken; - ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); - DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemManager.applyItemEffects(completedItem); + vendor.charItemManager.addItemToInventory(completedItem); + + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); + DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + + } catch (Exception e) { + Logger.error(e); + } finally { + city.transactionLock.writeLock().unlock(); + } } private static void setItemPrice(int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) { @@ -189,18 +196,18 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { return; if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) { - ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); - return; - } + ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help."); + return; + } - targetItem.setValue(itemPrice); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + targetItem.setValue(itemPrice); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.DEPOSIT, true); + dispatch = Dispatch.borrow(player, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, mbEnums.ProductionActionType.SETPRICE, true); + dispatch = Dispatch.borrow(player, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); } @@ -312,7 +319,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (!vendor.charItemManager.doesCharOwnThisItem(targetItem.getObjectUUID())) continue; - if (vendor.charItemManager.inventoryContains(targetItem) == false) + if (!vendor.charItemManager.inventoryContains(targetItem)) continue; itemValue = targetItem.template.item_value; @@ -361,48 +368,51 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ManageNPCMsg outMsg; Dispatch dispatch; - if (origin.sellLock.tryLock()) { + targetItem = Item.getFromCache(itemUUID); - try { + PlayerCharacter player = origin.getPlayerCharacter(); - targetItem = Item.getFromCache(itemUUID); + if (player == null) + return; - PlayerCharacter player = origin.getPlayerCharacter(); + // junk nothing? - if (player == null) - return; + if (targetItem == null) + return; - // junk nothing? + // Cannot junk items without a forge! - if (targetItem == null) - return; + if (vendor.getBuilding() == null) + return; - // Cannot junk items without a forge! + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); - if (vendor.getBuilding() == null) - return; + City city = workOrder.vendor.building.getCity(); + city.transactionLock.writeLock().lock(); - WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); - workOrder.cooking.remove(targetItem); - DbManager.removeFromCache(targetItem); + try { - // WorkOrder exists until all items are completed or junked - // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) + workOrder.cooking.remove(targetItem); + DbManager.removeFromCache(targetItem); - workOrder.slots_used = workOrder.slots_used - 1; + // WorkOrder exists until all items are completed or junked + // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) - if (workOrder.slots_used == 0) - ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); + workOrder.slots_used = workOrder.slots_used - 1; - // Refresh vendor's inventory to client + if (workOrder.slots_used == 0) + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); - outMsg = new ManageNPCMsg(vendor); - outMsg.setMessageType(1); - dispatch = Dispatch.borrow(player, outMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); - } finally { - origin.sellLock.unlock(); - } + // Refresh vendor's inventory to client + + outMsg = new ManageNPCMsg(vendor); + outMsg.setMessageType(1); + dispatch = Dispatch.borrow(player, outMsg); + DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); + } catch (Exception e) { + Logger.error(e); + } finally { + city.transactionLock.writeLock().unlock(); } } @@ -425,10 +435,10 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (targetItem.template.item_type.equals(ItemType.GOLD)) return; - if (vendor.charItemManager.inventoryContains(targetItem) == false) + if (!vendor.charItemManager.inventoryContains(targetItem)) return; - if (player.charItemManager.hasRoomInventory(targetItem.template.item_wt) == false) + if (!player.charItemManager.hasRoomInventory(targetItem.template.item_wt)) return; player.charItemManager.buyFromNPC(targetItem, vendor); From 1e5790e6b9af2568679c258f78421d02bd5f3568 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 08:23:58 -0400 Subject: [PATCH 240/378] Rework of item forge method collection usage --- src/engine/gameManager/ForgeManager.java | 39 +++++++++++------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6250ce78..9aa853a1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -219,11 +219,9 @@ public enum ForgeManager implements Runnable { ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); Item forgedItem = new Item(workOrder.templateID); - // Item gets a negative id; a virtual in-memory only item - // which is not persisted or added to the game cache. + // forgedItem gets a negative id; a virtual item which is not persisted forgedItem.objectUUID = ItemManager.lastNegativeID.getAndDecrement(); - forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); @@ -249,6 +247,12 @@ public enum ForgeManager implements Runnable { if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) forgedItem.flags.remove(mbEnums.ItemFlags.Identified); + // Add virtual item to in-memory caches + + workOrder.cooking.add(forgedItem); + DbManager.addToCache(forgedItem); + itemWorkOrderLookup.put(forgedItem, workOrder); + return forgedItem; } @@ -256,20 +260,20 @@ public enum ForgeManager implements Runnable { ArrayList toRemove = new ArrayList<>(); - for (Item workOrderItem : workOrder.cooking) { + for (Item virutalItem : workOrder.cooking) { // Identify completed items - workOrderItem.flags.add(mbEnums.ItemFlags.Identified); + virutalItem.flags.add(mbEnums.ItemFlags.Identified); // Persist item - Item completedItem = DbManager.ItemQueries.PERSIST(workOrderItem); + Item completedItem = DbManager.ItemQueries.PERSIST(virutalItem); // Apply Item effects for Prefix and Suffix tokens - completedItem.prefixToken = workOrderItem.prefixToken; - completedItem.suffixToken = workOrderItem.suffixToken; + completedItem.prefixToken = virutalItem.prefixToken; + completedItem.suffixToken = virutalItem.suffixToken; ItemManager.applyItemEffects(completedItem); @@ -282,21 +286,21 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - toRemove.add(workOrderItem); + toRemove.add(virutalItem); } // Remove the negativeID virtual item from all collections - for (Item memoryItem : toRemove) { + for (Item virtualItem : toRemove) { // Remove the virtual items from the forge window - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - workOrder.cooking.remove(memoryItem); - itemWorkOrderLookup.remove(memoryItem); - DbManager.removeFromCache(memoryItem); + workOrder.cooking.remove(virtualItem); + itemWorkOrderLookup.remove(virtualItem); + DbManager.removeFromCache(virtualItem); } } @@ -310,13 +314,6 @@ public enum ForgeManager implements Runnable { Item forged_item = forgeItem(workOrder); - // Add virtual item to in-memory caches - - workOrder.cooking.add(forged_item); - DbManager.addToCache(forged_item); - vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); - itemWorkOrderLookup.put(forged_item, workOrder); - // Update NPC window ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, forged_item, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); From 3ff7414fb4a8c9288c3acfcb96fb45ec947555bf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 11:39:59 -0400 Subject: [PATCH 241/378] Rework of item forge method collection usage --- src/engine/gameManager/ForgeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 9aa853a1..966da112 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -136,6 +136,7 @@ public enum ForgeManager implements Runnable { // Submit workOrder for next completion cycle + vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); } catch (Exception e) { From dc83bee2270fee49894af84fae3c70e649f9964b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 11:40:27 -0400 Subject: [PATCH 242/378] File reformat --- src/engine/gameManager/ForgeManager.java | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 966da112..edcd26e7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -109,35 +109,35 @@ public enum ForgeManager implements Runnable { city.transactionLock.writeLock().lock(); try { - // Configure this production run. + // Configure this production run. - workOrder.workOrderID = wordOrderCounter.incrementAndGet(); - workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); - workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; - workOrder.slots_used = calcAvailableSlots(workOrder); + workOrder.workOrderID = wordOrderCounter.incrementAndGet(); + workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); + workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; + workOrder.slots_used = calcAvailableSlots(workOrder); - workOrder.total_produced = 0; - workOrder.total_to_produce *= workOrder.slots_used; - workOrder.production_cost = calcProductionCost(workOrder); + workOrder.total_produced = 0; + workOrder.total_to_produce *= workOrder.slots_used; + workOrder.production_cost = calcProductionCost(workOrder); - // Set total cost for this production run + // Set total cost for this production run - workOrder.production_cost_total.putAll(workOrder.production_cost); - workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); + workOrder.production_cost_total.putAll(workOrder.production_cost); + workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); - // Deduct gold cost from building + // Deduct gold cost from building - if (debitWorkOrderCost(workOrder) == false) - return 58; //58: The formula is beyond the means of this facility + if (!debitWorkOrderCost(workOrder)) + return 58; //58: The formula is beyond the means of this facility - // Create in-memory items and add to collections + // Create in-memory items and add to collections - forgeWorkOrderBatch(workOrder); + forgeWorkOrderBatch(workOrder); - // Submit workOrder for next completion cycle + // Submit workOrder for next completion cycle vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); - forge.add(workOrder); + forge.add(workOrder); } catch (Exception e) { Logger.error(e); From 2391bd660642ecee407c322fe8fbb78068a659d9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 11:54:17 -0400 Subject: [PATCH 243/378] Unused method removed --- src/engine/gameManager/ItemManager.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index eeb28808..4c41e11b 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -4,7 +4,6 @@ import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.*; import engine.powers.EffectsBase; -import engine.powers.poweractions.AbstractPowerAction; import org.pmw.tinylog.Logger; import java.util.EnumSet; @@ -227,17 +226,6 @@ public enum ItemManager { return true; } - public static void applyPrefixOrSuffix(Item item, String powerAction) { - - AbstractPowerAction abstractPowerAction = PowersManager.getPowerActionByIDString(powerAction); - - if (abstractPowerAction == null) - return; - - abstractPowerAction.applyEffectForItem(item, 0); - item.getEffectNames().add(powerAction); - } - public static int validate(WorkOrder workOrder) { int validation_result = 0; From bb5d257ae89070e42d64a363dae09c4adc3eb21c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 11:14:10 -0500 Subject: [PATCH 244/378] early exit for out of stam when attacking --- src/engine/gameManager/CombatManager.java | 101 ++++++++-------------- 1 file changed, 35 insertions(+), 66 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 71c7fae3..138c7135 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -186,8 +186,15 @@ public enum CombatManager { } } + //check if Out of Stamina + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + if (attacker.getStamina() < (weapon.template.item_wt / 3f)) { + //set auto attack job + setAutoAttackJob(attacker,slot,delay); + return; + } + } // take stamina away from attacker - if (weapon != null) { float stam = weapon.template.item_wt / 3f; stam = (stam < 1) ? 1 : stam; @@ -246,19 +253,8 @@ public enum CombatManager { else DispatchMessage.sendToAllInRange(attacker, msg); - //calculate next allowed attack and update the timestamp - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - - //handle auto attack job creation - ConcurrentHashMap timers = attacker.getTimers(); - - if (timers != null) { - AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); - JobContainer job; - job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue - timers.put("Attack" + slot, job); - } else - Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + //set auto attack job + setAutoAttackJob(attacker,slot,delay); return; } @@ -294,19 +290,8 @@ public enum CombatManager { else DispatchMessage.sendToAllInRange(attacker, msg); - //calculate next allowed attack and update the timestamp - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - - //handle auto attack job creation - ConcurrentHashMap timers = attacker.getTimers(); - - if (timers != null) { - AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); - JobContainer job; - job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue - timers.put("Attack" + slot, job); - } else - Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + //set auto attack job + setAutoAttackJob(attacker,slot,delay); return; } } @@ -314,19 +299,8 @@ public enum CombatManager { //calculate the base damage int damage = ThreadLocalRandom.current().nextInt(min, max + 1); if (damage == 0) { - //calculate next allowed attack and update the timestamp - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - - //handle auto attack job creation - ConcurrentHashMap timers = attacker.getTimers(); - - if (timers != null) { - AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); - JobContainer job; - job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue - timers.put("Attack" + slot, job); - } else - Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + //set auto attack job + setAutoAttackJob(attacker,slot,delay); return; } //get the damage type @@ -394,19 +368,8 @@ public enum CombatManager { //check for damage type immunities if (resists.immuneTo(damageType)) { - //calculate next allowed attack and update the timestamp - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - - //handle auto attack job creation - ConcurrentHashMap timers = attacker.getTimers(); - - if (timers != null) { - AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); - JobContainer job; - job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue - timers.put("Attack" + slot, job); - } else - Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + //set auto attack job + setAutoAttackJob(attacker,slot,delay); return; } //calculate resisted damage including fortitude @@ -432,19 +395,8 @@ public enum CombatManager { DispatchMessage.sendToAllInRange(target, cmm); } } - //calculate next allowed attack and update the timestamp - attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); - - //handle auto attack job creation - ConcurrentHashMap timers = attacker.getTimers(); - - if (timers != null) { - AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); - JobContainer job; - job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue - timers.put("Attack" + slot, job); - } else - Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + //set auto attack job + setAutoAttackJob(attacker,slot,delay); } @@ -617,4 +569,21 @@ public enum CombatManager { return 100; } } + + public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay){ + //calculate next allowed attack and update the timestamp + attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); + + //handle auto attack job creation + ConcurrentHashMap timers = attacker.getTimers(); + + if (timers != null) { + AttackJob aj = new AttackJob(attacker, slot.ordinal(), true); + JobContainer job; + job = JobScheduler.getInstance().scheduleJob(aj, (System.currentTimeMillis() + delay)); // offset 1 millisecond so no overlap issue + timers.put("Attack" + slot, job); + } else + Logger.error("Unable to find Timers for Character " + attacker.getObjectUUID()); + + } } \ No newline at end of file From b8dbcb62dbcb9cf9f83d44fc3a5c5b0cbf4d3f32 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 11:21:40 -0500 Subject: [PATCH 245/378] early exit for combat cycle --- src/engine/gameManager/CombatManager.java | 37 +++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 138c7135..a7884fb8 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -68,22 +68,39 @@ public enum CombatManager { processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - } else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { + return; + } + + if (mainWeapon != null && offWeapon == null) { + //swing right hand only + processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); + return; + } + + if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { + //swing left hand only + processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); + return; + } + + if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { //no weapon equipped with a shield, punch with one hand processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - } else if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { + return; + } + + if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block")) { //one weapon equipped with a shield, swing with one hand processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - } else if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { + return; + } + + if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { //two weapons equipped, swing both hands processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - } else if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { - //swing left hand only - processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - } else if (mainWeapon != null && offWeapon == null) { - //swing left hand only - processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) + processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); + return; } } From 67bf8c2b110167c0c6935e505cdf1abe4b910b88 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 11:46:45 -0500 Subject: [PATCH 246/378] animation combat cleanup --- src/engine/gameManager/CombatManager.java | 110 ++-------------------- 1 file changed, 8 insertions(+), 102 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index a7884fb8..4fe19694 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -476,114 +476,20 @@ public enum CombatManager { int token = 0; - if (dpj != null) + if (dpj != null) { token = (dpj.getPower() != null) ? dpj.getPower().getToken() : 0; - if (token == 563721004) //kick animation - return 79; - - if (wb == null) - return 75; - - ItemTemplate template = wb; - - if (mainHand) { - if (template.weapon_attack_anim_right.size() > 0) { - - int animation; - - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_right.size()); - - try { - animation = template.weapon_attack_anim_right.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; - } - - } else if (template.weapon_attack_anim_left.size() > 0) { - - int animation; - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size()); - - try { - animation = template.weapon_attack_anim_left.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; - } - } - } else { - if (template.weapon_attack_anim_left.size() > 0) { - - int animation; - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size()); - - try { - animation = template.weapon_attack_anim_left.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; - - } - } else if (template.weapon_attack_anim_left.size() > 0) { - - int animation; - int random = ThreadLocalRandom.current().nextInt(template.weapon_attack_anim_left.size()); - - try { - animation = template.weapon_attack_anim_left.get(random)[0]; - return animation; - } catch (Exception e) { - Logger.error(e.getMessage()); - return template.weapon_attack_anim_right.get(0)[0]; - - } - - } + if (token == 563721004) //kick animation + return 79; } - String required = template.item_skill_used; - String mastery = wb.item_skill_mastery_used; - - if (required.equals("Unarmed Combat")) + if (wb == null) return 75; - else if (required.equals("Sword")) { - if (ItemManager.isTwoHanded(template)) - return 105; - else - return 98; - - } else if (required.equals("Staff") || required.equals("Pole Arm")) { - return 85; - } else if (required.equals("Spear")) { - return 92; - } else if (required.equals("Hammer") || required.equals("Axe")) { - if (ItemManager.isTwoHanded(template)) { - return 105; - } else if (mastery.equals("Throwing")) { - return 115; - } else { - return 100; - } - } else if (required.equals("Dagger")) { - if (mastery.equals("Throwing")) { - return 117; - } else { - return 81; - } - } else if (required.equals("Crossbow")) { - return 110; - } else if (required.equals("Bow")) { - return 109; - } else if (ItemManager.isTwoHanded(template)) { - return 105; - } else { - return 100; + if(mainHand){ + return wb.weapon_attack_anim_right.get(0)[0]; + } else{ + return wb.weapon_attack_anim_left.get(0)[0]; } } From 8e93e82526d96bd191571b6000ab2117f40dc963 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 11:50:04 -0500 Subject: [PATCH 247/378] random animation for weapon powers --- src/engine/gameManager/CombatManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 4fe19694..7a89ef59 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -481,6 +481,11 @@ public enum CombatManager { if (token == 563721004) //kick animation return 79; + if(mainHand && wb != null){ + return wb.weapon_attack_anim_right.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()))[0]; + } else{ + return wb.weapon_attack_anim_left.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()))[0]; + } } if (wb == null) From a84c712110286dc6503537ce2dbcdad41bdf901b Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 11:52:47 -0500 Subject: [PATCH 248/378] random animation for weapon powers --- src/engine/gameManager/CombatManager.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 7a89ef59..1bd981dd 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -481,10 +481,12 @@ public enum CombatManager { if (token == 563721004) //kick animation return 79; - if(mainHand && wb != null){ - return wb.weapon_attack_anim_right.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()))[0]; - } else{ - return wb.weapon_attack_anim_left.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()))[0]; + if(wb != null) { + if (mainHand) { + return wb.weapon_attack_anim_right.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()))[0]; + } else { + return wb.weapon_attack_anim_left.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()))[0]; + } } } From 0286b63a8ead86ccc3ba8a7860457cbcce53623c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 12:56:41 -0400 Subject: [PATCH 249/378] Class reformat --- src/engine/gameManager/CombatManager.java | 86 +++++++++++------------ 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 1bd981dd..a932179d 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -12,7 +12,6 @@ import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.AttackJob; import engine.jobs.DeferredPowerJob; -import engine.math.Bounds; import engine.mbEnums; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; @@ -41,13 +40,13 @@ public enum CombatManager { if (attacker == null || target == null || !attacker.isAlive() || !target.isAlive()) return; - if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) if (((Mob) attacker).nextAttackTime > System.currentTimeMillis()) return; switch (target.getObjectType()) { case Building: - if (((Building) target).isVulnerable() == false) + if (!((Building) target).isVulnerable()) return; break; case PlayerCharacter: @@ -66,7 +65,7 @@ public enum CombatManager { if (mainWeapon == null && offWeapon == null) { //no weapons equipped, punch with both fists processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); return; } @@ -77,7 +76,7 @@ public enum CombatManager { return; } - if (mainWeapon == null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { + if (mainWeapon == null && offWeapon != null && !offWeapon.template.item_skill_required.containsKey("Block")) { //swing left hand only processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); return; @@ -95,12 +94,11 @@ public enum CombatManager { return; } - if (mainWeapon != null && offWeapon != null && offWeapon.template.item_skill_required.containsKey("Block") == false) { + if (mainWeapon != null && offWeapon != null && !offWeapon.template.item_skill_required.containsKey("Block")) { //two weapons equipped, swing both hands processAttack(attacker, target, mbEnums.EquipSlotType.RHELD); - if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) processAttack(attacker, target, mbEnums.EquipSlotType.LHELD); - return; } } @@ -129,20 +127,20 @@ public enum CombatManager { float distanceSquared = attacker.loc.distanceSquared(target.loc); boolean inRange = false; - if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)){ - attackRange += ((PlayerCharacter)attacker).getCharacterHeight() * 0.5f; - }else { + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + attackRange += ((PlayerCharacter) attacker).getCharacterHeight() * 0.5f; + } else { attackRange += attacker.calcHitBox(); } - switch(target.getObjectType()){ + switch (target.getObjectType()) { case PlayerCharacter: - attackRange += ((PlayerCharacter)target).getCharacterHeight() * 0.5f; - if(distanceSquared < attackRange * attackRange) + attackRange += ((PlayerCharacter) target).getCharacterHeight() * 0.5f; + if (distanceSquared < attackRange * attackRange) inRange = true; break; case Mob: - attackRange += ((AbstractCharacter)target).calcHitBox(); - if(distanceSquared < attackRange * attackRange) + attackRange += ((AbstractCharacter) target).calcHitBox(); + if (distanceSquared < attackRange * attackRange) inRange = true; break; case Building: @@ -150,8 +148,8 @@ public enum CombatManager { float locZ = target.loc.z - target.getBounds().getHalfExtents().y; float sizeX = (target.getBounds().getHalfExtents().x + attackRange) * 2; float sizeZ = (target.getBounds().getHalfExtents().y + attackRange) * 2; - Rectangle2D.Float rect = new Rectangle2D.Float(locX,locZ,sizeX,sizeZ); - if(rect.contains(new Point2D.Float(attacker.loc.x,attacker.loc.z))) + Rectangle2D.Float rect = new Rectangle2D.Float(locX, locZ, sizeX, sizeZ); + if (rect.contains(new Point2D.Float(attacker.loc.x, attacker.loc.z))) inRange = true; break; } @@ -172,19 +170,19 @@ public enum CombatManager { if (wepSpeed < 10) wepSpeed = 10; //Old was 10, but it can be reached lower with legit buffs,effects. - delay = wepSpeed * 100; + delay = wepSpeed * 100L; } - if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) - ((Mob)attacker).nextAttackTime = System.currentTimeMillis() + delay; + if (attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)) + ((Mob) attacker).nextAttackTime = System.currentTimeMillis() + delay; if (inRange) { //handle retaliate - if(AbstractCharacter.IsAbstractCharacter(target)){ - if(((AbstractCharacter)target).combatTarget == null || ((AbstractCharacter)target).combatTarget.isAlive() == false){ - ((AbstractCharacter)target).combatTarget = attacker; - if(target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat()) + if (AbstractCharacter.IsAbstractCharacter(target)) { + if (((AbstractCharacter) target).combatTarget == null || !((AbstractCharacter) target).combatTarget.isAlive()) { + ((AbstractCharacter) target).combatTarget = attacker; + if (target.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter) && ((AbstractCharacter) target).isCombat()) combatCycle((AbstractCharacter) target, attacker); } } @@ -204,10 +202,10 @@ public enum CombatManager { } //check if Out of Stamina - if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { if (attacker.getStamina() < (weapon.template.item_wt / 3f)) { //set auto attack job - setAutoAttackJob(attacker,slot,delay); + setAutoAttackJob(attacker, slot, delay); return; } } @@ -271,7 +269,7 @@ public enum CombatManager { DispatchMessage.sendToAllInRange(attacker, msg); //set auto attack job - setAutoAttackJob(attacker,slot,delay); + setAutoAttackJob(attacker, slot, delay); return; } @@ -299,7 +297,7 @@ public enum CombatManager { passiveType = mbEnums.PassiveType.Parry; - if (passiveType.equals(mbEnums.PassiveType.None) == false) { + if (!passiveType.equals(mbEnums.PassiveType.None)) { TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value); if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter) @@ -308,7 +306,7 @@ public enum CombatManager { DispatchMessage.sendToAllInRange(attacker, msg); //set auto attack job - setAutoAttackJob(attacker,slot,delay); + setAutoAttackJob(attacker, slot, delay); return; } } @@ -317,7 +315,7 @@ public enum CombatManager { int damage = ThreadLocalRandom.current().nextInt(min, max + 1); if (damage == 0) { //set auto attack job - setAutoAttackJob(attacker,slot,delay); + setAutoAttackJob(attacker, slot, delay); return; } //get the damage type @@ -337,7 +335,7 @@ public enum CombatManager { Resists resists; - if (AbstractCharacter.IsAbstractCharacter(target) == false) + if (!AbstractCharacter.IsAbstractCharacter(target)) resists = ((Building) target).getResists(); //this is a building else resists = ((AbstractCharacter) target).getResists(); //this is a character @@ -386,7 +384,7 @@ public enum CombatManager { if (resists.immuneTo(damageType)) { //set auto attack job - setAutoAttackJob(attacker,slot,delay); + setAutoAttackJob(attacker, slot, delay); return; } //calculate resisted damage including fortitude @@ -413,7 +411,7 @@ public enum CombatManager { } } //set auto attack job - setAutoAttackJob(attacker,slot,delay); + setAutoAttackJob(attacker, slot, delay); } @@ -474,33 +472,33 @@ public enum CombatManager { public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, boolean mainHand) { - int token = 0; + int token; if (dpj != null) { + token = (dpj.getPower() != null) ? dpj.getPower().getToken() : 0; if (token == 563721004) //kick animation return 79; - if(wb != null) { - if (mainHand) { + + if (wb != null) + if (mainHand) return wb.weapon_attack_anim_right.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()))[0]; - } else { + else return wb.weapon_attack_anim_left.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()))[0]; - } - } } if (wb == null) return 75; - if(mainHand){ + if (mainHand) return wb.weapon_attack_anim_right.get(0)[0]; - } else{ + else return wb.weapon_attack_anim_left.get(0)[0]; - } + } - public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay){ + public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) { //calculate next allowed attack and update the timestamp attacker.getTimestamps().put("Attack" + slot.name(), System.currentTimeMillis() + delay); From e00871324e74f362500db9bc07c169fa81c0fa07 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 13:21:00 -0400 Subject: [PATCH 250/378] Float fix --- src/engine/gameManager/CombatManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index a932179d..09f885a9 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -245,7 +245,7 @@ public enum CombatManager { int hitChance; if (def == 0) def = 1; - float dif = atr / def; + float dif = atr * 1f / def; if (dif <= 0.8f) hitChance = 4; From 1911de0757aad3e6e68eba12dab7571f25700b40 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 12:21:34 -0500 Subject: [PATCH 251/378] random animation for weapon powers --- src/engine/gameManager/CombatManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index a932179d..fd706471 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -404,7 +404,12 @@ public enum CombatManager { int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD)); if (attacker.charItemManager.getEquipped().get(slot) != null) { - attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + DeferredPowerJob weaponPower = ((PlayerCharacter) attacker).getWeaponPower(); + attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, weaponPower, slot.equals(mbEnums.EquipSlotType.RHELD)); + }else { + attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD)); + } } TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim); DispatchMessage.sendToAllInRange(target, cmm); From 84233ecdd6fe2e359870ec82f76069613fc3d9df Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 12:43:23 -0500 Subject: [PATCH 252/378] use of proper animations --- src/engine/gameManager/CombatManager.java | 42 +++++++++++-------- .../net/client/msg/TargetedActionMsg.java | 10 ++--- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index 63f8d1ab..d5fc4b56 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -187,19 +187,7 @@ public enum CombatManager { } } - DeferredPowerJob dpj = null; - if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { - - dpj = ((PlayerCharacter) attacker).getWeaponPower(); - - if (dpj != null) { - dpj.attack(target, attackRange); - - if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) - ((PlayerCharacter) attacker).setWeaponPower(dpj); - } - } //check if Out of Stamina if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { @@ -415,6 +403,21 @@ public enum CombatManager { DispatchMessage.sendToAllInRange(target, cmm); } } + + DeferredPowerJob dpj = null; + + if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + + dpj = ((PlayerCharacter) attacker).getWeaponPower(); + + if (dpj != null) { + dpj.attack(target, attackRange); + + if (dpj.getPower() != null && (dpj.getPowerToken() == -1851459567 || dpj.getPowerToken() == -1851489518)) + ((PlayerCharacter) attacker).setWeaponPower(dpj); + } + } + //set auto attack job setAutoAttackJob(attacker, slot, delay); @@ -486,11 +489,16 @@ public enum CombatManager { if (token == 563721004) //kick animation return 79; - if (wb != null) - if (mainHand) - return wb.weapon_attack_anim_right.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()))[0]; - else - return wb.weapon_attack_anim_left.get(ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()))[0]; + if (wb != null) { + if (mainHand) { + int random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size()); + int anim = wb.weapon_attack_anim_right.get(random)[0]; + return anim; + }else { + int random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size()); + return wb.weapon_attack_anim_left.get(random)[0]; + } + } } if (wb == null) diff --git a/src/engine/net/client/msg/TargetedActionMsg.java b/src/engine/net/client/msg/TargetedActionMsg.java index 6c06c56c..25736d37 100644 --- a/src/engine/net/client/msg/TargetedActionMsg.java +++ b/src/engine/net/client/msg/TargetedActionMsg.java @@ -81,7 +81,7 @@ public class TargetedActionMsg extends ClientNetMsg { private float locX; private float locZ; private int unknown01 = 14; - private int unknown02 = 100; //source animation + private int animationID = 100; //source animation private float unknown03 = 1f; private float sourceStamina = 1f; // attackers stamina after attack private int unknown05 = 6; //signify passive defense @@ -164,7 +164,7 @@ public class TargetedActionMsg extends ClientNetMsg { this.newHealth = 1f; this.damage = damage; } - this.unknown02 = swingAnimation; + this.animationID = swingAnimation; //this.unknown02 = TargetedActionMsg.un2cnt; } @@ -196,7 +196,7 @@ public class TargetedActionMsg extends ClientNetMsg { this.newHealth = 1f; this.damage = damage; } - this.unknown02 = swingAnimation; + this.animationID = swingAnimation; //this.unknown02 = TargetedActionMsg.un2cnt; } @@ -247,7 +247,7 @@ public class TargetedActionMsg extends ClientNetMsg { writer.putFloat(this.locX); writer.putFloat(this.locZ); writer.putInt(this.unknown01); - writer.putInt(this.unknown02); + writer.putInt(this.animationID); writer.putFloat(this.unknown03); writer.putFloat(this.sourceStamina); writer.putInt(this.unknown05); @@ -275,7 +275,7 @@ public class TargetedActionMsg extends ClientNetMsg { this.locX = reader.getFloat(); this.locZ = reader.getFloat(); this.unknown01 = reader.getInt(); - this.unknown02 = reader.getInt(); + this.animationID = reader.getInt(); this.unknown03 = reader.getFloat(); this.sourceStamina = reader.getFloat(); this.unknown05 = reader.getInt(); From 35945f75429420ddf1745037090b9aec1e72ffb9 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 12:53:38 -0500 Subject: [PATCH 253/378] equipping bug --- src/engine/gameManager/ItemManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 4c41e11b..825843b1 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -32,7 +32,7 @@ public enum ItemManager { return true; if (item.template.item_race_res.isEmpty() == false) - if (item.template.item_class_res.contains(race) == false) + if (item.template.item_race_res.contains(race) == false) return true; return false; From 979cd70d65cfe07edc17d9bebf04d277c290869c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 13:04:47 -0500 Subject: [PATCH 254/378] update class type when promoting --- src/engine/gameManager/ItemManager.java | 5 ++++- src/engine/objects/PlayerCharacter.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index 825843b1..e90d8b62 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -190,7 +190,10 @@ public enum ItemManager { if (!validForSkills(item, abstractCharacter.getSkills())) return false; - if (canCharacterEquip(item, abstractCharacter) == false) + if (!ValidRace(item, abstractCharacter.absRace)) + return false; + + if (!ValidClass(item, abstractCharacter.absBaseClass,abstractCharacter.absPromotionClass)) return false; //players can't wear 0 value items. diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 6b4c35db..07f50a0d 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2193,7 +2193,7 @@ public class PlayerCharacter extends AbstractCharacter { public boolean setPromotionClass(int value) { PromotionClass promotionClass = PromotionClass.GetPromtionClassFromCache(value); - + this.absPromotionClass = mbEnums.ClassType.valueOf(this.getPromotionClass().getName()); if (promotionClass == null) return false; From 7f8c297ae265cf2cc464a9ced84f9e5a901c31ef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 14:08:27 -0400 Subject: [PATCH 255/378] City check moved outside of validation --- src/engine/gameManager/ForgeManager.java | 6 ++++++ src/engine/gameManager/ItemManager.java | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index edcd26e7..b79264d3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -105,7 +105,13 @@ public enum ForgeManager implements Runnable { if (validation_result != 0) return validation_result; + // Concurrency is managed by same lock as warehouse + City city = workOrder.vendor.building.getCity(); + + if (city == null) + return 58; //58: The formula is beyond the means of this facility + city.transactionLock.writeLock().lock(); try { diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index e90d8b62..c9634ad8 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -238,9 +238,6 @@ public enum ItemManager { if (workOrder.vendor.getBuilding() == null) return 58; //58: The formula is beyond the means of this facility - if (workOrder.vendor.getBuilding().getCity() == null) - return 58; //58: The formula is beyond the means of this facility - if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) return 30; //30: That person cannot carry that item From d3b1cf9928cee313c507d724d64a42f3a52500eb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 14:10:35 -0400 Subject: [PATCH 256/378] Comment update --- src/engine/gameManager/ForgeManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b79264d3..80ad2da3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -49,6 +49,11 @@ public enum ForgeManager implements Runnable { Logger.error(e); } + // Do not process null workOrders + + if (workOrder == null) + continue; + if (workOrder.total_produced >= workOrder.total_to_produce) { // Complete this workOrder. From 41b1718df12edf3aaa54911d84df9314a18a671c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 21 Apr 2024 13:19:50 -0500 Subject: [PATCH 257/378] use delay for attacks for players --- src/engine/gameManager/CombatManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java index d5fc4b56..e1558930 100644 --- a/src/engine/gameManager/CombatManager.java +++ b/src/engine/gameManager/CombatManager.java @@ -104,6 +104,16 @@ public enum CombatManager { public static void processAttack(AbstractCharacter attacker, AbstractWorldObject target, mbEnums.EquipSlotType slot) { + if(attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { + if (!attacker.isCombat()) + return; + + if (attacker.getTimestamps().get("Attack" + slot.name()) != null && attacker.getTimestamps().get("Attack" + slot.name()) < System.currentTimeMillis()) { + setAutoAttackJob(attacker, slot, 1000); + return; + } + } + // check if character is in range to attack target PlayerBonuses bonus = attacker.getBonuses(); From 127f80054fae3019ea0f5aaec8cd81cb0f088898 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 00:03:03 -0400 Subject: [PATCH 258/378] Slot tracking update --- .../net/client/handlers/ItemProductionMsgHandler.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 48a7eea7..3ea16423 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -146,14 +146,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.itemWorkOrderLookup.remove(virtualItem); DbManager.removeFromCache(virtualItem); - // WorkOrder exists until all items are completed or junked - // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) - - workOrder.slots_used = workOrder.slots_used - 1; - - if (workOrder.slots_used == 0) - ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); - // Persist item and add to vendor inventory Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); @@ -400,9 +392,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.slots_used = workOrder.slots_used - 1; - if (workOrder.slots_used == 0) - ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder); - // Refresh vendor's inventory to client outMsg = new ManageNPCMsg(vendor); From 5a62361edd3f16352d7f949155cbd5f2dfce0912 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 00:10:32 -0400 Subject: [PATCH 259/378] Slot tracking update --- .../handlers/ItemProductionMsgHandler.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 3ea16423..59d840df 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -356,11 +356,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void junkItem(int itemUUID, NPC vendor, ClientConnection origin) { - Item targetItem; + Item virtualItem; ManageNPCMsg outMsg; Dispatch dispatch; - targetItem = Item.getFromCache(itemUUID); + virtualItem = Item.getFromCache(itemUUID); PlayerCharacter player = origin.getPlayerCharacter(); @@ -369,7 +369,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // junk nothing? - if (targetItem == null) + if (virtualItem == null) return; // Cannot junk items without a forge! @@ -377,20 +377,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (vendor.getBuilding() == null) return; - WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); City city = workOrder.vendor.building.getCity(); city.transactionLock.writeLock().lock(); try { - workOrder.cooking.remove(targetItem); - DbManager.removeFromCache(targetItem); - - // WorkOrder exists until all items are completed or junked - // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) - - workOrder.slots_used = workOrder.slots_used - 1; + workOrder.cooking.remove(virtualItem); + DbManager.removeFromCache(virtualItem); + ForgeManager.itemWorkOrderLookup.remove(virtualItem); // Refresh vendor's inventory to client From 98b73d978a286260fbb51b419f8484c3c13e3518 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 00:19:29 -0400 Subject: [PATCH 260/378] Slot tracking update --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 80ad2da3..80bceeff 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -185,7 +185,7 @@ public enum ForgeManager implements Runnable { // Subtract slots currently being used by npc workOrders for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) - availableSlots = availableSlots - npcWorkOrder.slots_used; + availableSlots = availableSlots - npcWorkOrder.cooking.size(); // Single item rolls are always a single slot From 2de1f78f22bce715c4c59d52ef34025bbebe20cd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 00:25:16 -0400 Subject: [PATCH 261/378] Slot tracking update --- src/engine/gameManager/ForgeManager.java | 9 +++------ .../net/client/handlers/ItemProductionMsgHandler.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 80bceeff..25e13db0 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -20,10 +20,7 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.DelayQueue; -import java.util.concurrent.ThreadLocalRandom; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; public enum ForgeManager implements Runnable { @@ -32,8 +29,8 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); - public static final HashMap itemWorkOrderLookup = new HashMap<>(); + public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); @Override diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 59d840df..eb922feb 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -146,6 +146,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.itemWorkOrderLookup.remove(virtualItem); DbManager.removeFromCache(virtualItem); + // If this is the last item then remove the workOrder from the game + + if (workOrder.cooking.isEmpty()) + ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); + // Persist item and add to vendor inventory Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); @@ -388,6 +393,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DbManager.removeFromCache(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + // If this is the last item then remove the workOrder from the game + + if (workOrder.cooking.isEmpty()) + ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); + // Refresh vendor's inventory to client outMsg = new ManageNPCMsg(vendor); From 6f39767fb48bb8ec359b45d44f33b28afcf01515 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 00:37:49 -0400 Subject: [PATCH 262/378] Concurrency update --- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/loot/WorkOrder.java | 4 ++-- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 2 ++ src/engine/objects/NPC.java | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 25e13db0..7d2241b8 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -29,7 +29,7 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); @Override diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index d5f5b2da..88c67c24 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -16,8 +16,8 @@ import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; -import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -39,7 +39,7 @@ public class WorkOrder implements Delayed { public long completionTime; public boolean runCompleted = false; public boolean runCanceled = false; - public ArrayList cooking = new ArrayList<>(); + public CopyOnWriteArrayList cooking = new CopyOnWriteArrayList<>(); public WorkOrder() { diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index eb922feb..f165c447 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -164,6 +164,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { vendor.charItemManager.addItemToInventory(completedItem); + // Refresh the vendor inventory window + ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index b567c200..1d463ae6 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.ReentrantReadWriteLock; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; @@ -872,7 +873,7 @@ public class NPC extends AbstractCharacter { // If NPC is a vendor then configure ForgeManager support if (this.contract.isTrainer() == false) - ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new ArrayList<>()); + ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new CopyOnWriteArrayList<>()); this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); From 63c7fb08e0f1aca06fa6dbbeb3d3431e2368b0c9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 00:46:59 -0400 Subject: [PATCH 263/378] Concurrency update --- src/engine/loot/WorkOrder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 88c67c24..72baeab5 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -17,7 +17,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.HashMap; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Delayed; import java.util.concurrent.TimeUnit; @@ -39,7 +39,7 @@ public class WorkOrder implements Delayed { public long completionTime; public boolean runCompleted = false; public boolean runCanceled = false; - public CopyOnWriteArrayList cooking = new CopyOnWriteArrayList<>(); + public ConcurrentHashMap.KeySetView cooking = ConcurrentHashMap.newKeySet(); public WorkOrder() { From 11013bcd074b45ac25a3fc3d3c177a76f777b986 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 01:13:26 -0400 Subject: [PATCH 264/378] Reformat for easier debugging --- src/engine/gameManager/NPCManager.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 960bcc6b..7e5acf18 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -27,6 +27,7 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.acos; @@ -522,7 +523,9 @@ public enum NPCManager { ArrayList itemList = new ArrayList<>(); - for (WorkOrder workOrder : ForgeManager.vendorWorkOrderLookup.get(npc)) + List vendorWorkOrders = ForgeManager.vendorWorkOrderLookup.get(npc); + + for (WorkOrder workOrder : vendorWorkOrders) itemList.addAll(workOrder.cooking); return itemList; From 0e7336b8c6c104dd602584d2f1469d7b5a6b8d47 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 07:35:59 -0400 Subject: [PATCH 265/378] Concurrency update --- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/gameManager/NPCManager.java | 4 ++-- src/engine/objects/NPC.java | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 7d2241b8..e35d4007 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -29,7 +29,7 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); + public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); @Override diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index 7e5acf18..59e348e0 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -27,7 +27,7 @@ import org.pmw.tinylog.Logger; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.acos; @@ -523,7 +523,7 @@ public enum NPCManager { ArrayList itemList = new ArrayList<>(); - List vendorWorkOrders = ForgeManager.vendorWorkOrderLookup.get(npc); + ConcurrentHashMap.KeySetView vendorWorkOrders = ForgeManager.vendorWorkOrderLookup.get(npc); for (WorkOrder workOrder : vendorWorkOrders) itemList.addAll(workOrder.cooking); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 1d463ae6..ddb12851 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -35,7 +35,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.ReentrantReadWriteLock; import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup; @@ -873,7 +872,7 @@ public class NPC extends AbstractCharacter { // If NPC is a vendor then configure ForgeManager support if (this.contract.isTrainer() == false) - ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new CopyOnWriteArrayList<>()); + ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> ConcurrentHashMap.newKeySet()); this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable(); From 746a95e7d57e54d241f4f5021023dc6efc00016f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 07:44:47 -0400 Subject: [PATCH 266/378] Overflow calc updated --- src/engine/gameManager/ForgeManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index e35d4007..b9bc3d7a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -367,9 +367,8 @@ public enum ForgeManager implements Runnable { public static boolean debitWorkOrderCost(WorkOrder workOrder) { int strongbox = workOrder.vendor.building.getStrongboxValue(); - int overflow = strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD); - if (overflow > 1 || workOrder.production_cost_total.size() > 1) { + if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) > strongbox) { // Deduct total cost from warehouse From 28c6953c3d33396b8e7b7c09a19c30873484418e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 07:54:03 -0400 Subject: [PATCH 267/378] Serialization update. --- src/engine/net/client/msg/ManageNPCMsg.java | 44 +++------------------ 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 2aaaa484..1b33d6d7 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -10,7 +10,6 @@ package engine.net.client.msg; import engine.gameManager.NPCManager; -import engine.gameManager.PowersManager; import engine.mbEnums.GameObjectType; import engine.mbEnums.MinionType; import engine.mbEnums.ProtectionState; @@ -18,7 +17,6 @@ import engine.net.ByteBufferReader; import engine.net.ByteBufferWriter; import engine.net.Protocol; import engine.objects.*; -import engine.powers.EffectsBase; import org.joda.time.DateTime; import org.joda.time.Period; import org.joda.time.Seconds; @@ -458,48 +456,18 @@ public class ManageNPCMsg extends ClientNetMsg { else writer.put((byte) 0); - ArrayList effectsList = item.getEffectNames(); - EffectsBase prefix = null; - EffectsBase suffix = null; - - for (String effectName : effectsList) { - - if (effectName.contains("PRE")) - prefix = PowersManager.getEffectByIDString(effectName); - - if (effectName.contains("SUF")) - suffix = PowersManager.getEffectByIDString(effectName); - } - - if ((prefix == null && suffix == null)) + if ((item.prefixToken == 0 && item.suffixToken == 0)) writer.putInt(0); else writer.putInt(-1497023830); - if (item.prefixToken == 0) { - if (!item.isComplete()) - writer.putInt(0); - else - writer.putInt(prefix.getToken()); - } else { - if (prefix != null) - writer.putInt(prefix.getToken()); - else - writer.putInt(0); - } - - if (item.suffixToken == 0) { - if (!item.isComplete()) - writer.putInt(0); - else - writer.putInt(suffix.getToken()); + if (!item.isComplete()) { + writer.putInt(0); + writer.putInt(0); } else { - if (suffix != null) - writer.putInt(suffix.getToken()); - else - writer.putInt(0); + writer.putInt(item.prefixToken); + writer.putInt(item.suffixToken); } - writer.putString(item.name); } From 4723eb4bf2e0ce817716953b12aea8e8ba160a11 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 07:56:25 -0400 Subject: [PATCH 268/378] Serialization update. --- src/engine/net/client/msg/ManageNPCMsg.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 1b33d6d7..7c4d6647 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -461,13 +461,9 @@ public class ManageNPCMsg extends ClientNetMsg { else writer.putInt(-1497023830); - if (!item.isComplete()) { - writer.putInt(0); - writer.putInt(0); - } else { - writer.putInt(item.prefixToken); - writer.putInt(item.suffixToken); - } + writer.putInt(item.prefixToken); + writer.putInt(item.suffixToken); + writer.putString(item.name); } From 41aefa4a480e240d28cfaf8b9756d250edb3ffc2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 08:20:02 -0400 Subject: [PATCH 269/378] Comment cleanup --- .../net/client/handlers/ItemProductionMsgHandler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index f165c447..e8810c48 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -134,8 +134,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { try { - // Refresh the window. SetPrice is used only to force a window refresh. - // What controls items displayed are the contents of the workOrders. (ManageNPCMsg) + // Remove virtual item from the vendor rolling window + // (Add / Completed / Remove) ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); @@ -164,7 +164,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { vendor.charItemManager.addItemToInventory(completedItem); - // Refresh the vendor inventory window + // Add persisted items to the vendor inventory window ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); From 27d140f70393f6430ccb21e4e9c0ed463ba7b8a7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 08:28:43 -0400 Subject: [PATCH 270/378] Junk or completion removes slot from workOrder --- src/engine/gameManager/ForgeManager.java | 5 ----- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b9bc3d7a..b0e3ee61 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -46,11 +46,6 @@ public enum ForgeManager implements Runnable { Logger.error(e); } - // Do not process null workOrders - - if (workOrder == null) - continue; - if (workOrder.total_produced >= workOrder.total_to_produce) { // Complete this workOrder. diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index e8810c48..05528578 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -146,6 +146,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.itemWorkOrderLookup.remove(virtualItem); DbManager.removeFromCache(virtualItem); + workOrder.slots_used = workOrder.slots_used - 1; + // If this is the last item then remove the workOrder from the game if (workOrder.cooking.isEmpty()) @@ -395,6 +397,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DbManager.removeFromCache(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + workOrder.slots_used = workOrder.slots_used - 1; + // If this is the last item then remove the workOrder from the game if (workOrder.cooking.isEmpty()) From c09ae5d32fa5ac8507d3870df7d164d2f186efc4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 08:35:58 -0400 Subject: [PATCH 271/378] Workorder to json work --- src/engine/gameManager/ForgeManager.java | 3 +++ src/engine/loot/WorkOrder.java | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b0e3ee61..a7ae3dbb 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -142,6 +142,9 @@ public enum ForgeManager implements Runnable { vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); + String jsonWorkOrder = workOrder.toString(); + jsonWorkOrder = jsonWorkOrder.trim(); + } catch (Exception e) { Logger.error(e); } finally { diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 72baeab5..c90f9a15 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,6 +11,7 @@ package engine.loot; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; +import org.json.simple.JSONValue; import java.time.Duration; import java.time.Instant; @@ -49,6 +50,12 @@ public class WorkOrder implements Delayed { } + public static String toJson(WorkOrder workOrder) { + + String jsonString = JSONValue.toJSONString(workOrder); + return jsonString; + } + @Override public long getDelay(TimeUnit unit) { From a851d9a6ec3767832c030960653c2099d1cc60df Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 08:40:20 -0400 Subject: [PATCH 272/378] Workorder to json work --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a7ae3dbb..5ddf3064 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -142,7 +142,7 @@ public enum ForgeManager implements Runnable { vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); - String jsonWorkOrder = workOrder.toString(); + String jsonWorkOrder = WorkOrder.toJson(workOrder); jsonWorkOrder = jsonWorkOrder.trim(); } catch (Exception e) { From 6499a16cc2907752a6cbdecf87fb3043d890b9d8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 08:53:33 -0400 Subject: [PATCH 273/378] Workorder to json work --- src/engine/gameManager/ForgeManager.java | 5 ++-- src/engine/loot/WorkOrder.java | 34 +++++++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 5ddf3064..6e796582 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -16,6 +16,7 @@ import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; +import org.json.simple.JSONObject; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -142,8 +143,8 @@ public enum ForgeManager implements Runnable { vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); - String jsonWorkOrder = WorkOrder.toJson(workOrder); - jsonWorkOrder = jsonWorkOrder.trim(); + JSONObject jsonWorkOrder = WorkOrder.toJson(workOrder); + String stringOrder = jsonWorkOrder.toString(); } catch (Exception e) { Logger.error(e); diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index c90f9a15..76586f00 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,12 +11,13 @@ package engine.loot; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; -import org.json.simple.JSONValue; +import org.json.simple.JSONObject; import java.time.Duration; import java.time.Instant; 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.Delayed; @@ -50,10 +51,35 @@ public class WorkOrder implements Delayed { } - public static String toJson(WorkOrder workOrder) { + public static JSONObject toJson(WorkOrder workOrder) { - String jsonString = JSONValue.toJSONString(workOrder); - return jsonString; + JSONObject jsonWorkOrder = new JSONObject(); + + jsonWorkOrder.put("jsonWorkOrder", workOrder.workOrderID); + jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); + jsonWorkOrder.put("slots_used", workOrder.slots_used); + jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); + jsonWorkOrder.put("total_produced", workOrder.total_produced); + jsonWorkOrder.put("multiple_slot_request", workOrder.multiple_slot_request); + jsonWorkOrder.put("production_cost", workOrder.production_cost); + jsonWorkOrder.put("production_cost_total", workOrder.production_cost_total); + jsonWorkOrder.put("templateID", workOrder.templateID); + jsonWorkOrder.put("item_name_override", workOrder.item_name_override); + jsonWorkOrder.put("prefixToken", workOrder.prefixToken); + jsonWorkOrder.put("suffixToken", workOrder.suffixToken); + jsonWorkOrder.put("rollingDuration", workOrder.rollingDuration); + jsonWorkOrder.put("completionTime", workOrder.completionTime); + jsonWorkOrder.put("runCompleted", workOrder.runCompleted); + + ArrayList cookingTokens = new ArrayList<>(); + + for (Item item : workOrder.cooking) + cookingTokens.add(new Integer[]{item.prefixToken, item.suffixToken}); + + jsonWorkOrder.put("cookingTokens", cookingTokens); + + + return jsonWorkOrder; } @Override From d557e30716fb11a10dab0d1aa18efcfd2b0367cc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 08:57:02 -0400 Subject: [PATCH 274/378] Workorder to json work --- src/engine/gameManager/ForgeManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6e796582..23f28f90 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -145,6 +145,7 @@ public enum ForgeManager implements Runnable { JSONObject jsonWorkOrder = WorkOrder.toJson(workOrder); String stringOrder = jsonWorkOrder.toString(); + stringOrder = stringOrder.trim(); } catch (Exception e) { Logger.error(e); From ba47b30673bbd591e87771ba28ac86b3908cc98f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 09:21:46 -0400 Subject: [PATCH 275/378] Migration to org.json --- src/engine/db/handlers/dbItemHandler.java | 7 ++----- src/engine/db/handlers/dbWarehouseHandler.java | 13 +++++-------- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/loot/WorkOrder.java | 4 ++-- src/engine/objects/ItemTemplate.java | 8 ++++---- src/engine/objects/Warehouse.java | 8 ++++---- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/engine/db/handlers/dbItemHandler.java b/src/engine/db/handlers/dbItemHandler.java index 83229178..008ca9e9 100644 --- a/src/engine/db/handlers/dbItemHandler.java +++ b/src/engine/db/handlers/dbItemHandler.java @@ -17,8 +17,7 @@ import engine.objects.AbstractCharacter; import engine.objects.CharacterItemManager; import engine.objects.Item; import engine.objects.ItemTemplate; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -180,8 +179,6 @@ public class dbItemHandler extends dbHandlerBase { public void LOAD_ITEM_TEMPLATES() { - JSONParser jsonParser = new JSONParser(); - HashMap templateTCountMap = new HashMap<>(); try (Connection connection = DbManager.getConnection(); @@ -190,7 +187,7 @@ public class dbItemHandler extends dbHandlerBase { while (rs.next()) { int templateID = rs.getInt("id"); - JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("template")); + JSONObject jsonObject = new JSONObject(rs.getString("template")); ItemTemplate itemTemplate = new ItemTemplate(jsonObject); itemTemplate.template_id = templateID; ItemTemplate.templates.put(templateID, itemTemplate); diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index f70cb5ff..03033d4b 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -9,19 +9,18 @@ package engine.db.handlers; +import engine.gameManager.DbManager; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.mbEnums.TransactionType; -import engine.gameManager.DbManager; import engine.objects.Building; import engine.objects.City; import engine.objects.Transaction; import engine.objects.Warehouse; import engine.server.MBServerStatics; import org.joda.time.DateTime; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; +import org.json.JSONArray; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -106,7 +105,7 @@ public class dbWarehouseHandler extends dbHandlerBase { JSONArray locks = new JSONArray(); for (mbEnums.ResourceType resource : warehouse.locked) - locks.add(resource.name()); + locks.put(resource.name()); warehouseJSON.put("locked", locks); @@ -127,15 +126,13 @@ public class dbWarehouseHandler extends dbHandlerBase { public void LOAD_WAREHOUSES() { - JSONParser jsonParser = new JSONParser(); - try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_warehouse`;"); ResultSet rs = preparedStatement.executeQuery()) { while (rs.next()) { int cityUID = rs.getInt("cityUUID"); - JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("warehouse")); + JSONObject jsonObject = new JSONObject(rs.getString("warehouse")); City city = City.getCity(cityUID); city.warehouse = new Warehouse(jsonObject); city.warehouse.city = city; diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 23f28f90..f38ff8e0 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -16,7 +16,7 @@ import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; -import org.json.simple.JSONObject; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.util.ArrayList; diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 76586f00..971ebf74 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,7 +11,7 @@ package engine.loot; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; -import org.json.simple.JSONObject; +import org.json.JSONObject; import java.time.Duration; import java.time.Instant; @@ -55,7 +55,7 @@ public class WorkOrder implements Delayed { JSONObject jsonWorkOrder = new JSONObject(); - jsonWorkOrder.put("jsonWorkOrder", workOrder.workOrderID); + jsonWorkOrder.put("workOrderID", workOrder.workOrderID); jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); jsonWorkOrder.put("slots_used", workOrder.slots_used); jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 0ac29787..e4c2d2e3 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -10,8 +10,8 @@ package engine.objects; import engine.math.Vector3fImmutable; import engine.mbEnums; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -194,7 +194,7 @@ public class ItemTemplate { JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist"); - for (Object key : resist_json.keySet()) { + for (String key : resist_json.keySet()) { float resist = ((Double) resist_json.get(key)).floatValue(); combat_attack_resist.put((String) key, resist); } @@ -488,7 +488,7 @@ public class ItemTemplate { JSONObject rune_speed_json = (JSONObject) jsonObject.get("rune_speed"); - for (Object key : rune_speed_json.keySet()) { + for (String key : rune_speed_json.keySet()) { mbEnums.MovementType movementType = mbEnums.MovementType.valueOf((String) key); float speed = ((Double) rune_speed_json.get(key)).floatValue(); rune_speed.put(movementType, speed); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 53eebeba..f15a6611 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -19,8 +19,8 @@ import engine.net.client.ClientConnection; import engine.net.client.msg.*; import engine.server.MBServerStatics; import org.joda.time.DateTime; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; +import org.json.JSONArray; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.SQLException; @@ -56,8 +56,8 @@ public class Warehouse { JSONObject resources = (JSONObject) warehouse.get("resources"); - for (Object key : resources.keySet()) { - mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf((String) key); + for (String key : resources.keySet()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); int value = ((Long) resources.get(key)).intValue(); this.resources.put(resourceType, value); } From 475ccaff0cb68e88115b5452a36c1b04632cd706 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 09:32:20 -0400 Subject: [PATCH 276/378] Migration to org.json --- src/engine/objects/ItemTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index e4c2d2e3..d7d8a39a 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -547,8 +547,8 @@ public class ItemTemplate { JSONObject rune_sparse_json = (JSONObject) jsonObject.get("rune_sparse_data"); - for (Object key : rune_sparse_json.keySet()) { - String sparseType = (String) key; + for (String key : rune_sparse_json.keySet()) { + String sparseType = key; Object sparseValue = rune_sparse_json.get(sparseType); rune_sparse_data.put(sparseType, sparseValue.toString()); } From 8818282341e5fc1155de1c2c2f8422e1270e9cfc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 11:49:41 -0400 Subject: [PATCH 277/378] Migration to org.json --- src/engine/objects/ItemTemplate.java | 53 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index d7d8a39a..9ef56d90 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -140,69 +140,68 @@ public class ItemTemplate { try { // Reading a String - obj_name = (String) jsonObject.get("obj_name"); + obj_name = jsonObject.getString("obj_name"); // Reading a boolean - obj_pickable = (boolean) jsonObject.get("obj_pickable"); + obj_pickable = jsonObject.getBoolean("obj_pickable"); // Reading floats from an array (note always check for empty arrays) - JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale"); + JSONArray scaleData = jsonObject.getJSONArray("obj_scale"); if (scaleData.isEmpty() == false) - obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(), - ((Double) scaleData.get(2)).floatValue()); + obj_scale = new Vector3fImmutable(scaleData.getFloat(0), scaleData.getFloat(1), + scaleData.getFloat(2)); - JSONArray forwardVector = (JSONArray) jsonObject.get("obj_forward_vector"); + JSONArray forwardVector = jsonObject.getJSONArray("obj_forward_vector"); if (forwardVector.isEmpty() == false) - obj_forward_vector = new Vector3fImmutable(((Double) forwardVector.get(0)).floatValue(), ((Double) forwardVector.get(1)).floatValue(), - ((Double) forwardVector.get(2)).floatValue()); + obj_forward_vector = new Vector3fImmutable(forwardVector.getFloat(0), forwardVector.getFloat(1), + forwardVector.getFloat(2)); - JSONArray defaultAlighment = (JSONArray) jsonObject.get("obj_default_alignment"); + JSONArray defaultAlignment = jsonObject.getJSONArray("obj_default_alignment"); - if (defaultAlighment.isEmpty() == false) - obj_default_alignment = new Vector3fImmutable(((Double) defaultAlighment.get(0)).floatValue(), ((Double) defaultAlighment.get(1)).floatValue(), - ((Double) defaultAlighment.get(2)).floatValue()); + if (defaultAlignment.isEmpty() == false) + obj_default_alignment = new Vector3fImmutable(defaultAlignment.getFloat(0), defaultAlignment.getFloat(1), + defaultAlignment.getFloat(2)); // Reading an integer value - obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue(); - obj_icon = ((Long) jsonObject.get("obj_icon")).intValue(); + obj_render_object = jsonObject.getInt("obj_render_object"); + obj_icon = jsonObject.getInt("obj_icon"); - JSONObject obj_sparse_json = (JSONObject) jsonObject.get("obj_sparse_data"); + JSONObject obj_sparse_json = jsonObject.getJSONObject("obj_sparse_data"); - for (Object key : obj_sparse_json.keySet()) { - String sparseType = (String) key; - Object sparseValue = obj_sparse_json.get(sparseType); - obj_sparse_data.put(sparseType, sparseValue.toString()); + for (String key : obj_sparse_json.keySet()) { + String sparseValue = obj_sparse_json.getString(key); + obj_sparse_data.put(key, sparseValue); } // Banes are defined by their sparse data field if (obj_sparse_data.get("ACTIONRESPONSE") != null) if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122")) - item_bane_rank = ((Long) jsonObject.get("item_bane_rank")).intValue(); + item_bane_rank = jsonObject.getInt("item_bane_rank"); // Reading float values - combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue(); - combat_health_full = ((Double) jsonObject.get("combat_health_full")).floatValue(); + combat_health_current = jsonObject.getFloat("combat_health_current"); + combat_health_full = jsonObject.getFloat("combat_health_full"); // Reading a hashmap of floats - JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist"); + JSONObject resist_json = jsonObject.getJSONObject("combat_attack_resist"); for (String key : resist_json.keySet()) { - float resist = ((Double) resist_json.get(key)).floatValue(); - combat_attack_resist.put((String) key, resist); + float resist = resist_json.getFloat(key); + combat_attack_resist.put(key, resist); } // Parsing an enum - item_type = mbEnums.ItemType.valueOf((String) jsonObject.get("item_type")); - item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue(); + item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type")); + item_eq_slots_value = jsonObject.getInt("item_eq_slots_value"); item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type"); // Parsing an enumset From 7604b7b07f3725b8ac1863432f8358ce0f7384b9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 12:20:53 -0400 Subject: [PATCH 278/378] Migration to org.json --- src/engine/objects/ItemTemplate.java | 268 +++++++++++++-------------- 1 file changed, 133 insertions(+), 135 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 9ef56d90..e4a7c6fd 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -202,30 +202,30 @@ public class ItemTemplate { item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type")); item_eq_slots_value = jsonObject.getInt("item_eq_slots_value"); - item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type"); + item_eq_slots_type = jsonObject.getBoolean("item_eq_slots_type"); // Parsing an enumset - JSONArray eq_slots_or = (JSONArray) jsonObject.get("item_eq_slots_or"); + JSONArray eq_slots_or = jsonObject.getJSONArray("item_eq_slots_or"); if (eq_slots_or.isEmpty() == false) for (Object o : eq_slots_or) item_eq_slots_or.add(mbEnums.EquipSlotType.valueOf((String) o)); - JSONArray eq_slots_and = (JSONArray) jsonObject.get("item_eq_slots_and"); + JSONArray eq_slots_and = jsonObject.getJSONArray("item_eq_slots_and"); if (eq_slots_and.isEmpty() == false) for (Object o : eq_slots_and) item_eq_slots_and.add(mbEnums.EquipSlotType.valueOf((String) o)); - item_takeable = (boolean) jsonObject.get("item_takeable"); - item_value = ((Long) jsonObject.get("item_value")).intValue(); - item_wt = ((Long) jsonObject.get("item_wt")).intValue(); - item_passive_defense_mod = ((Double) jsonObject.get("item_passive_defense_mod")).floatValue(); - item_base_name = (String) jsonObject.get("item_base_name"); - item_dsc = (String) jsonObject.get("item_dsc"); - item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue(); - item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue(); + item_takeable = jsonObject.getBoolean("item_takeable"); + item_value = (jsonObject.getInt("item_value")); + item_wt = jsonObject.getInt("item_wt"); + item_passive_defense_mod = jsonObject.getFloat("item_passive_defense_mod"); + item_base_name = jsonObject.getString("item_base_name"); + item_dsc = jsonObject.getString("item_dsc"); + item_render_object_female = jsonObject.getInt("item_render_object_female"); + item_health_full = jsonObject.getFloat("item_health_full"); Object skill_used = jsonObject.get("item_skill_used"); @@ -239,74 +239,74 @@ public class ItemTemplate { if (mastery_used instanceof String) item_skill_mastery_used = (String) mastery_used; - item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue(); + item_parry_anim_id = jsonObject.getInt("item_parry_anim_id"); // Reading offering data - JSONArray offering_data = (JSONArray) jsonObject.get("item_offering_info"); + JSONArray offering_data = jsonObject.getJSONArray("item_offering_info"); for (Object entry : offering_data) { JSONObject offering_entry = (JSONObject) entry; - String offering_type = ((String) offering_entry.get("offering_type")).replaceAll("-", ""); - int offering_value = ((Long) offering_entry.get("offering_value")).intValue(); + String offering_type = offering_entry.getString("offering_type").replaceAll("-", ""); + int offering_value = offering_entry.getInt("offering_value"); item_offering_info.put(mbEnums.ShrineType.valueOf(offering_type), offering_value); } // Fields only present for ARMOR if (item_type.equals(mbEnums.ItemType.ARMOR)) { - item_bulk_factor = ((Double) jsonObject.get("item_bulk_factor")).floatValue(); - item_defense_rating = ((Long) jsonObject.get("item_defense_rating")).intValue(); + item_bulk_factor = jsonObject.getFloat("item_bulk_factor"); + item_defense_rating = jsonObject.getInt("item_defense_rating"); } // Fields only present for WEAPON if (item_type.equals(mbEnums.ItemType.WEAPON)) { - JSONObject item_weapon = (JSONObject) jsonObject.get("item_weapon"); - item_weapon_wepspeed = ((Double) item_weapon.get("weapon_wepspeed")).floatValue(); - item_weapon_max_range = ((Double) item_weapon.get("weapon_max_range")).floatValue(); - item_weapon_projectile_id = ((Long) item_weapon.get("weapon_projectile_id")).intValue(); - item_weapon_projectile_speed = ((Double) item_weapon.get("weapon_projectile_speed")).floatValue(); - item_weapon_combat_idle_anim = ((Long) item_weapon.get("weapon_combat_idle_anim")).intValue(); + JSONObject item_weapon = jsonObject.getJSONObject("item_weapon"); + item_weapon_wepspeed = item_weapon.getFloat("weapon_wepspeed"); + item_weapon_max_range = item_weapon.getFloat("weapon_max_range"); + item_weapon_projectile_id = item_weapon.getInt("weapon_projectile_id"); + item_weapon_projectile_speed = item_weapon.getFloat("weapon_projectile_speed"); + item_weapon_combat_idle_anim = item_weapon.getInt("weapon_combat_idle_anim"); - JSONArray weapon_damage = (JSONArray) item_weapon.get("weapon_damage"); + JSONArray weapon_damage = item_weapon.getJSONArray("weapon_damage"); if (weapon_damage.isEmpty() == false) for (Object o : weapon_damage) { JSONObject damage_entry = (JSONObject) o; - mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(((String) damage_entry.get("damage_type"))); - int min = ((Long) damage_entry.get("damage_min")).intValue(); - int max = ((Long) damage_entry.get("damage_max")).intValue(); + mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(damage_entry.getString("damage_type")); + int min = damage_entry.getInt("damage_min"); + int max = damage_entry.getInt("damage_max"); int[] minMax = {min, max}; item_weapon_damage.put(damageType, minMax); } - JSONArray attack_anim_right = (JSONArray) item_weapon.get("weapon_attack_anim_right"); + JSONArray attack_anim_right = item_weapon.getJSONArray("weapon_attack_anim_right"); if (attack_anim_right.isEmpty() == false) for (Object o : attack_anim_right) { JSONArray animationEntry = (JSONArray) o; - int animation = ((Long) animationEntry.get(0)).intValue(); - int duration = ((Long) animationEntry.get(1)).intValue(); + int animation = animationEntry.getInt(0); + int duration = animationEntry.getInt(1); weapon_attack_anim_right.add(new int[]{animation, duration}); } - JSONArray attack_anim_left = (JSONArray) item_weapon.get("weapon_attack_anim_left"); + JSONArray attack_anim_left = item_weapon.getJSONArray("weapon_attack_anim_left"); if (attack_anim_left.isEmpty() == false) for (Object o : attack_anim_left) { JSONArray animationEntry = (JSONArray) o; - int animation = ((Long) animationEntry.get(0)).intValue(); - int duration = ((Long) animationEntry.get(1)).intValue(); + int animation = animationEntry.getInt(0); + int duration = animationEntry.getInt(1); weapon_attack_anim_left.add(new int[]{animation, duration}); } - item_primary_attr = mbEnums.AttributeType.valueOf((String) jsonObject.get("item_primary_attr")); - item_secondary_attr = mbEnums.AttributeType.valueOf((String) jsonObject.get("item_secondary_attr")); + item_primary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_primary_attr")); + item_secondary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_secondary_attr")); } - JSONArray itemflags = (JSONArray) jsonObject.get("item_flags"); + JSONArray itemflags = jsonObject.getJSONArray("item_flags"); if (itemflags.isEmpty() == false) for (Object o : itemflags) { @@ -315,29 +315,29 @@ public class ItemTemplate { item_flags.add(mbEnums.ItemFlags.valueOf((String) o)); } - JSONArray itemUseflags = (JSONArray) jsonObject.get("item_use_flags"); + JSONArray itemUseflags = jsonObject.getJSONArray("item_use_flags"); if (itemUseflags.isEmpty() == false) for (Object o : itemUseflags) item_use_flags.add(mbEnums.ItemUseFlags.valueOf((String) o)); - item_initial_charges = ((Long) jsonObject.get("item_initial_charges")).intValue(); + item_initial_charges = jsonObject.getInt("item_initial_charges"); - JSONArray skill_required = (JSONArray) jsonObject.get("item_skill_req"); + JSONArray skill_required = jsonObject.getJSONArray("item_skill_req"); if (skill_required.isEmpty() == false) for (Object o : skill_required) { JSONObject skill_req = (JSONObject) o; - String skill_type = (String) skill_req.get("skill_type"); - int skill_level = ((Long) skill_req.get("skill_level")).intValue(); + String skill_type = skill_req.getString("skill_type"); + int skill_level = skill_req.getInt("skill_level"); if (skill_type.equals("Cloth") == false) item_skill_required.put(skill_type, skill_level); } - JSONObject race_required = (JSONObject) jsonObject.get("item_race_req"); - boolean restrict = ((Boolean) race_required.get("restrict")); - JSONArray races = (JSONArray) race_required.get("races"); + JSONObject race_required = jsonObject.getJSONObject("item_race_req"); + boolean restrict = race_required.getBoolean("restrict"); + JSONArray races = race_required.getJSONArray("races"); if (races.isEmpty() == false) for (Object o : races) { @@ -352,9 +352,9 @@ public class ItemTemplate { item_race_req.add(mbEnums.MonsterType.valueOf(race)); } - JSONObject class_required = (JSONObject) jsonObject.get("item_class_req"); - restrict = ((Boolean) class_required.get("restrict")); - JSONArray classes = (JSONArray) class_required.get("classes"); + JSONObject class_required = jsonObject.getJSONObject("item_class_req"); + restrict = class_required.getBoolean("restrict"); + JSONArray classes = class_required.getJSONArray("classes"); if (classes.isEmpty() == false) for (Object o : classes) { @@ -368,9 +368,9 @@ public class ItemTemplate { item_class_req.add(mbEnums.ClassType.valueOf(classEntry)); } - JSONObject disc_required = (JSONObject) jsonObject.get("item_disc_req"); - restrict = ((Boolean) disc_required.get("restrict")); - JSONArray discs = (JSONArray) disc_required.get("discs"); + JSONObject disc_required = jsonObject.getJSONObject("item_disc_req"); + restrict = disc_required.getBoolean("restrict"); + JSONArray discs = disc_required.getJSONArray("discs"); if (discs.isEmpty() == false) for (Object o : discs) { @@ -384,62 +384,61 @@ public class ItemTemplate { item_disc_req.add(mbEnums.DisciplineType.valueOf(disc)); } - item_level_req = ((Long) jsonObject.get("item_level_req")).intValue(); - item_sex_req = mbEnums.SexType.valueOf((String) jsonObject.get("item_sex_req")); + item_level_req = jsonObject.getInt("item_level_req"); + item_sex_req = mbEnums.SexType.valueOf(jsonObject.getString("item_sex_req")); - JSONArray userPowerActions = (JSONArray) jsonObject.get("item_user_power_action"); + JSONArray userPowerActions = jsonObject.getJSONArray("item_user_power_action"); if (userPowerActions.isEmpty() == false) for (Object o : userPowerActions) { JSONObject powerActionEntry = (JSONObject) o; - String power = (String) powerActionEntry.get("power"); - JSONArray args = (JSONArray) powerActionEntry.get("arguments"); - int[] arguments = {((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()}; + String power = powerActionEntry.getString("power"); + JSONArray args = powerActionEntry.getJSONArray("arguments"); + int[] arguments = {args.getInt(0), args.getInt(1)}; item_user_power_action.put(power, arguments); } - JSONArray powerGrantsArray = (JSONArray) jsonObject.get("item_power_grant"); + JSONArray powerGrantsArray = jsonObject.getJSONArray("item_power_grant"); if (powerGrantsArray.isEmpty() == false) { for (Object grantArrayEntry : powerGrantsArray) { JSONObject powerGrantEntry = (JSONObject) grantArrayEntry; - String power_type = (String) powerGrantEntry.get("power_type"); - int power_value = ((Long) powerGrantEntry.get("power_value")).intValue(); + String power_type = powerGrantEntry.getString("power_type"); + int power_value = powerGrantEntry.getInt("power_value"); item_power_grant.put(power_type, power_value); - JSONArray skill_granted_array = (JSONArray) powerGrantEntry.get("power_granted_skills"); + JSONArray skill_granted_array = powerGrantEntry.getJSONArray("power_granted_skills"); for (Object skillGrantEntry : skill_granted_array) { JSONArray skill_entry = (JSONArray) skillGrantEntry; - String skill_type = (String) skill_entry.get(0); - int skill_level = ((Long) skill_entry.get(1)).intValue(); + String skill_type = skill_entry.getString(0); + int skill_level = skill_entry.getInt(1); power_granted_skills.put(skill_type, skill_level); } } - } - JSONArray item_power_actions = (JSONArray) jsonObject.get("item_power_action"); + JSONArray item_power_actions = jsonObject.getJSONArray("item_power_action"); if (item_power_actions.isEmpty() == false) for (Object o : item_power_actions) { JSONObject powerActionEntry = (JSONObject) o; - String power = (String) powerActionEntry.get("power_type"); - JSONArray power_actions = (JSONArray) powerActionEntry.get("power_actions"); - JSONObject argument_entry = (JSONObject) power_actions.get(0); - JSONArray power_args = (JSONArray) argument_entry.get("power_arguments"); - int[] power_arguments = {((Long) power_args.get(0)).intValue(), ((Long) power_args.get(1)).intValue()}; + String power = powerActionEntry.getString("power_type"); + JSONArray power_actions = powerActionEntry.getJSONArray("power_actions"); + JSONObject argument_entry = power_actions.getJSONObject(0); + JSONArray power_args = argument_entry.getJSONArray("power_arguments"); + int[] power_arguments = {power_args.getInt(0), power_args.getInt(1)}; item_power_action.put(power, power_arguments); } - JSONArray resource_costs = (JSONArray) jsonObject.get("item_resource_costs"); + JSONArray resource_costs = jsonObject.getJSONArray("item_resource_costs"); if (resource_costs.isEmpty() == false) for (Object o : resource_costs) { JSONObject resource_entry = (JSONObject) o; - mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(((String) resource_entry.get("resource_type")).toUpperCase()); - int resource_value = ((Long) resource_entry.get("resource_value")).intValue(); + mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(resource_entry.getString("resource_type").toUpperCase()); + int resource_value = resource_entry.getInt("resource_value"); item_resource_cost.put(resource_type, resource_value); } @@ -447,69 +446,69 @@ public class ItemTemplate { if (item_type.equals(mbEnums.ItemType.DEED)) { - deed_type = ((Long) jsonObject.get("deed_type")).intValue(); - deed_furniture_id = ((Long) jsonObject.get("deed_furniture_id")).intValue(); - deed_target_id = ((Long) jsonObject.get("deed_target_id")).intValue(); - deed_employment = ((Long) jsonObject.get("deed_employment")).intValue(); - deed_start_rank = ((Long) jsonObject.get("deed_start_rank")).intValue(); - deed_name_lookup = ((Long) jsonObject.get("deed_name_lookup")).intValue(); - deed_indoors = ((Boolean) jsonObject.get("deed_indoors")); - deed_is_fortress = ((Boolean) jsonObject.get("deed_is_fortress")); - deed_namelookup_val = ((Double) jsonObject.get("deed_namelookup_val")).floatValue(); - deed_custom_city = ((Boolean) jsonObject.get("deed_custom_city")); - deed_structure_id = ((Long) jsonObject.get("deed_structure_id")).intValue(); + deed_type = jsonObject.getInt("deed_type"); + deed_furniture_id = jsonObject.getInt("deed_furniture_id"); + deed_target_id = jsonObject.getInt("deed_target_id"); + deed_employment = jsonObject.getInt("deed_employment"); + deed_start_rank = jsonObject.getInt("deed_start_rank"); + deed_name_lookup = jsonObject.getInt("deed_name_lookup"); + deed_indoors = jsonObject.getBoolean("deed_indoors"); + deed_is_fortress = jsonObject.getBoolean("deed_is_fortress"); + deed_namelookup_val = jsonObject.getFloat("deed_namelookup_val"); + deed_custom_city = jsonObject.getBoolean("deed_custom_city"); + deed_structure_id = jsonObject.getInt("deed_structure_id"); } if (item_type.equals(mbEnums.ItemType.RUNE)) { - rune_type = (String) jsonObject.get("rune_type"); + rune_type = jsonObject.getString("rune_type"); Object subType = jsonObject.get("rune_sub_type"); if (subType instanceof String) rune_sub_type = (String) subType; - rune_is_standard_character_creation = ((Boolean) jsonObject.get("rune_is_standard_character_creation")); - rune_creation_cost = ((Long) jsonObject.get("rune_creation_cost")).intValue(); - rune_rank = ((Long) jsonObject.get("rune_rank")).intValue(); - rune_pracs_per_level = ((Long) jsonObject.get("rune_pracs_per_level")).intValue(); - rune_exp_req_to_level = ((Double) jsonObject.get("rune_exp_req_to_level")).floatValue(); - rune_sex = mbEnums.SexType.valueOf((String) jsonObject.get("rune_sex")); - rune_class_icon = ((Long) jsonObject.get("rune_class_icon")).intValue(); - rune_health = ((Long) jsonObject.get("rune_health")).intValue(); - rune_mana = ((Long) jsonObject.get("rune_mana")).intValue(); - rune_stamina = ((Long) jsonObject.get("rune_stamina")).intValue(); - rune_min_damage = ((Double) jsonObject.get("rune_min_damage")).floatValue(); - rune_max_damage = ((Double) jsonObject.get("rune_max_damage")).floatValue(); - rune_attack = ((Long) jsonObject.get("rune_attack")).intValue(); - rune_defense = ((Long) jsonObject.get("rune_defense")).intValue(); - rune_level = ((Long) jsonObject.get("rune_level")).intValue(); - - JSONObject rune_speed_json = (JSONObject) jsonObject.get("rune_speed"); + rune_is_standard_character_creation = jsonObject.getBoolean("rune_is_standard_character_creation"); + rune_creation_cost = jsonObject.getInt("rune_creation_cost"); + rune_rank = jsonObject.getInt("rune_rank"); + rune_pracs_per_level = jsonObject.getInt("rune_pracs_per_level"); + rune_exp_req_to_level = jsonObject.getFloat("rune_exp_req_to_level"); + rune_sex = mbEnums.SexType.valueOf(jsonObject.getString("rune_sex")); + rune_class_icon = jsonObject.getInt("rune_class_icon"); + rune_health = jsonObject.getInt("rune_health"); + rune_mana = jsonObject.getInt("rune_mana"); + rune_stamina = jsonObject.getInt("rune_stamina"); + rune_min_damage = jsonObject.getFloat("rune_min_damage"); + rune_max_damage = jsonObject.getFloat("rune_max_damage"); + rune_attack = jsonObject.getInt("rune_attack"); + rune_defense = jsonObject.getInt("rune_defense"); + rune_level = jsonObject.getInt("rune_level"); + + JSONObject rune_speed_json = jsonObject.getJSONObject("rune_speed"); for (String key : rune_speed_json.keySet()) { - mbEnums.MovementType movementType = mbEnums.MovementType.valueOf((String) key); - float speed = ((Double) rune_speed_json.get(key)).floatValue(); + mbEnums.MovementType movementType = mbEnums.MovementType.valueOf(key); + float speed = rune_speed_json.getFloat(key); rune_speed.put(movementType, speed); } - JSONObject rune_group = (JSONObject) jsonObject.get("rune_group"); + JSONObject rune_group = jsonObject.getJSONObject("rune_group"); - rune_group_type = ((Long) rune_group.get("group_type")).intValue(); - rune_group_is_faction = ((Boolean) rune_group.get("group_is_faction")); - rune_group_is_guild = ((Boolean) rune_group.get("group_is_guild")); - rune_dsc = (String) jsonObject.get("rune_dsc"); - rune_fx_txt = (String) jsonObject.get("rune_fx_txt"); + rune_group_type = rune_group.getInt("group_type"); + rune_group_is_faction = rune_group.getBoolean("group_is_faction"); + rune_group_is_guild = rune_group.getBoolean("group_is_guild"); + rune_dsc = jsonObject.getString("rune_dsc"); + rune_fx_txt = jsonObject.getString("rune_fx_txt"); - int group_tactics_bitvector = ((Long) jsonObject.get("rune_group_tactics")).intValue(); + int group_tactics_bitvector = jsonObject.getInt("rune_group_tactics"); rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); - int group_role_bitvector = ((Long) jsonObject.get("rune_group_role_set")).intValue(); + int group_role_bitvector = jsonObject.getInt("rune_group_role_set"); rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class)); - JSONArray enemy_types_json = (JSONArray) jsonObject.get("rune_enemy_monster_types"); + JSONArray enemy_types_json = jsonObject.getJSONArray("rune_enemy_monster_types"); for (Object o : enemy_types_json) { String enemy = (String) o; @@ -518,7 +517,7 @@ public class ItemTemplate { rune_enemy_monster_types.add(monsterType); } - JSONArray not_enemy_types_json = (JSONArray) jsonObject.get("rune_not_enemy_monster_types"); + JSONArray not_enemy_types_json = jsonObject.getJSONArray("rune_not_enemy_monster_types"); for (Object o : not_enemy_types_json) { String notenemy = (String) o; @@ -527,27 +526,26 @@ public class ItemTemplate { rune_not_enemy_monster_types.add(monsterType); } - JSONArray groupee_types_json = (JSONArray) jsonObject.get("rune_groupee_monster_types"); + JSONArray groupee_types_json = jsonObject.getJSONArray("rune_groupee_monster_types"); for (Object o : groupee_types_json) { int groupeeId = ((Long) o).intValue(); rune_groupee_monster_types.add(groupeeId); } - JSONArray helper_types_json = (JSONArray) jsonObject.get("rune_helper_monster_types"); + JSONArray helper_types_json = jsonObject.getJSONArray("rune_helper_monster_types"); for (Object o : helper_types_json) { int helperId = ((Long) o).intValue(); rune_helper_monster_types.add(helperId); } - rune_renderable = ((Boolean) jsonObject.get("rune_renderable")); - rune_natural_power_attack = ((Long) jsonObject.get("rune_natural_power_attack")).intValue(); + rune_renderable = jsonObject.getBoolean("rune_renderable"); + rune_natural_power_attack = jsonObject.getInt("rune_natural_power_attack"); - JSONObject rune_sparse_json = (JSONObject) jsonObject.get("rune_sparse_data"); + JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data"); - for (String key : rune_sparse_json.keySet()) { - String sparseType = key; + for (String sparseType : rune_sparse_json.keySet()) { Object sparseValue = rune_sparse_json.get(sparseType); rune_sparse_data.put(sparseType, sparseValue.toString()); } @@ -556,51 +554,51 @@ public class ItemTemplate { for (Object skillEntry : skill_adj_json) { JSONObject skill = (JSONObject) skillEntry; - String typeString = (String) skill.get("skill_type"); - JSONArray adjArray = (JSONArray) skill.get("skill_adjusts"); + String typeString = skill.getString("skill_type"); + JSONArray adjArray = skill.getJSONArray("skill_adjusts"); for (Object adjustList : adjArray) { JSONArray adjustEntry = (JSONArray) adjustList; - int[] adjust = {((Long) adjustEntry.get(0)).intValue(), ((Long) adjustEntry.get(1)).intValue()}; + int[] adjust = {adjustEntry.getInt(0), adjustEntry.getInt(1)}; rune_skill_adj.put(typeString, adjust); } } - JSONArray attr_adj_json = (JSONArray) jsonObject.get("rune_attr_adj"); + JSONArray attr_adj_json = jsonObject.getJSONArray("rune_attr_adj"); for (Object attributeEntry : attr_adj_json) { JSONObject attribute = (JSONObject) attributeEntry; - String typeString = (String) attribute.get("attr_type"); + String typeString = attribute.getString("attr_type"); mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString); - int attributeValue = ((Long) attribute.get("attr_value")).intValue(); + int attributeValue = attribute.getInt("attr_value"); rune_attr_adj.put(attributeType, attributeValue); } - JSONArray max_attr_adj_json = (JSONArray) jsonObject.get("rune_max_attr_adj"); + JSONArray max_attr_adj_json = jsonObject.getJSONArray("rune_max_attr_adj"); for (Object attributeEntry : max_attr_adj_json) { JSONObject attribute = (JSONObject) attributeEntry; - String typeString = (String) attribute.get("attr_type"); + String typeString = attribute.getString("attr_type"); mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString); - int attributeValue = ((Long) attribute.get("attr_value")).intValue(); + int attributeValue = attribute.getInt("attr_value"); rune_max_attr_adj.put(attributeType, attributeValue); } - JSONArray skill_grant_json = (JSONArray) jsonObject.get("rune_skill_grant"); + JSONArray skill_grant_json = jsonObject.getJSONArray("rune_skill_grant"); if (skill_grant_json.isEmpty() == false) for (Object runeSkillEntry : skill_grant_json) { JSONObject skill_granted = (JSONObject) runeSkillEntry; - String typeString = (String) skill_granted.get("skill_type"); - int skill_level = ((Long) skill_granted.get("skill_value")).intValue(); + String typeString = skill_granted.getString("skill_type"); + int skill_level = skill_granted.getInt("skill_value"); rune_skill_grant.put(typeString, skill_level); - JSONArray skill_granted_array = (JSONArray) skill_granted.get("skill_granted_skills"); + JSONArray skill_granted_array = skill_granted.getJSONArray("skill_granted_skills"); for (Object skillGrantEntry : skill_granted_array) { JSONArray skill_entry = (JSONArray) skillGrantEntry; - typeString = (String) skill_entry.get(0); - skill_level = ((Long) skill_entry.get(1)).intValue(); + typeString = skill_entry.getString(0); + skill_level = skill_entry.getInt(1); skill_granted_skills.put(typeString, skill_level); } } From 1d847d781bedbc034b861e6cb8edd7c434302554 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 12:34:57 -0400 Subject: [PATCH 279/378] Migration to org.json --- src/engine/objects/ItemTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index e4a7c6fd..e70be021 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -546,8 +546,8 @@ public class ItemTemplate { JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data"); for (String sparseType : rune_sparse_json.keySet()) { - Object sparseValue = rune_sparse_json.get(sparseType); - rune_sparse_data.put(sparseType, sparseValue.toString()); + String sparseValue = rune_sparse_json.getString(sparseType); + rune_sparse_data.put(sparseType, sparseValue); } JSONArray skill_adj_json = (JSONArray) jsonObject.get("rune_skill_adj"); From dbab8f66dabbe35127325c48c3dc8a0f83b2c880 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 12:42:52 -0400 Subject: [PATCH 280/378] Migration to org.json --- src/engine/objects/ItemTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index e70be021..3df9b590 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -546,8 +546,8 @@ public class ItemTemplate { JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data"); for (String sparseType : rune_sparse_json.keySet()) { - String sparseValue = rune_sparse_json.getString(sparseType); - rune_sparse_data.put(sparseType, sparseValue); + Object sparseValue = rune_sparse_json.getString(sparseType); + rune_sparse_data.put(sparseType, sparseValue.toString()); } JSONArray skill_adj_json = (JSONArray) jsonObject.get("rune_skill_adj"); From 79079e200a932a7b34aa9dceb360bcf4468aeedc Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 12:48:03 -0400 Subject: [PATCH 281/378] Bitvectors use int not long for mb --- src/engine/mbEnums.java | 4 ++-- src/engine/objects/ItemTemplate.java | 4 ++-- src/engine/objects/Mob.java | 4 ++-- src/engine/objects/MobBase.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index 720ede75..98f5b8dc 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -44,7 +44,7 @@ public class mbEnums { return bitvector; } - public static > EnumSet fromLong(long bitVector, Class enumClass) { + public static > EnumSet fromInt(int bitVector, Class enumClass) { // Bitvector -> EnumSet without the EnumBitvector dependency @@ -56,7 +56,7 @@ public class mbEnums { return enumSet; for (E enumValue : enumClass.getEnumConstants()) { - if ((bitVector & (1L << enumValue.ordinal())) != 0) { + if ((bitVector & (1 << enumValue.ordinal())) != 0) { enumSet.add(enumValue); } } diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 3df9b590..b6a6392b 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -502,11 +502,11 @@ public class ItemTemplate { int group_tactics_bitvector = jsonObject.getInt("rune_group_tactics"); - rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); + rune_group_tactics.addAll(mbEnums.fromInt(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); int group_role_bitvector = jsonObject.getInt("rune_group_role_set"); - rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class)); + rune_group_role_set.addAll(mbEnums.fromInt(group_role_bitvector, mbEnums.MobBehaviourType.class)); JSONArray enemy_types_json = jsonObject.getJSONArray("rune_enemy_monster_types"); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 3c68ddc9..025a57b1 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -143,8 +143,8 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { this.runeSet = rs.getInt("runeSet"); this.bootySet = rs.getInt("bootySet"); - this.notEnemy = mbEnums.fromLong(rs.getLong("notEnemy"), mbEnums.MonsterType.class); - this.enemy = mbEnums.fromLong(rs.getLong("enemy"), mbEnums.MonsterType.class); + this.notEnemy = mbEnums.fromInt(rs.getInt("notEnemy"), mbEnums.MonsterType.class); + this.enemy = mbEnums.fromInt(rs.getInt("enemy"), mbEnums.MonsterType.class); this.firstName = rs.getString("mob_name"); if (rs.getString("fsm").length() > 1) diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index ee54309b..c7c3669c 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -77,9 +77,9 @@ public class MobBase extends AbstractGameObject { this.fsm = mbEnums.MobBehaviourType.valueOf(rs.getString("fsm")); - this.flags = mbEnums.fromLong(rs.getLong("flags"), mbEnums.MobFlagType.class); - this.notEnemy = mbEnums.fromLong(rs.getLong("notEnemy"), mbEnums.MonsterType.class); - this.enemy = mbEnums.fromLong(rs.getLong("enemy"), mbEnums.MonsterType.class); + this.flags = mbEnums.fromInt(rs.getInt("flags"), mbEnums.MobFlagType.class); + this.notEnemy = mbEnums.fromInt(rs.getInt("notEnemy"), mbEnums.MonsterType.class); + this.enemy = mbEnums.fromInt(rs.getInt("enemy"), mbEnums.MonsterType.class); this.seeInvis = rs.getInt("seeInvis"); this.scale = rs.getFloat("scale"); From 4f115291eb93d87fe4941216ab3059c82de458a9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 12:50:45 -0400 Subject: [PATCH 282/378] No some are longs --- src/engine/mbEnums.java | 4 ++-- src/engine/objects/ItemTemplate.java | 8 ++++---- src/engine/objects/Mob.java | 4 ++-- src/engine/objects/MobBase.java | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/engine/mbEnums.java b/src/engine/mbEnums.java index 98f5b8dc..720ede75 100644 --- a/src/engine/mbEnums.java +++ b/src/engine/mbEnums.java @@ -44,7 +44,7 @@ public class mbEnums { return bitvector; } - public static > EnumSet fromInt(int bitVector, Class enumClass) { + public static > EnumSet fromLong(long bitVector, Class enumClass) { // Bitvector -> EnumSet without the EnumBitvector dependency @@ -56,7 +56,7 @@ public class mbEnums { return enumSet; for (E enumValue : enumClass.getEnumConstants()) { - if ((bitVector & (1 << enumValue.ordinal())) != 0) { + if ((bitVector & (1L << enumValue.ordinal())) != 0) { enumSet.add(enumValue); } } diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index b6a6392b..95174741 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -500,13 +500,13 @@ public class ItemTemplate { rune_dsc = jsonObject.getString("rune_dsc"); rune_fx_txt = jsonObject.getString("rune_fx_txt"); - int group_tactics_bitvector = jsonObject.getInt("rune_group_tactics"); + long group_tactics_bitvector = jsonObject.getLong("rune_group_tactics"); - rune_group_tactics.addAll(mbEnums.fromInt(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); + rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class)); - int group_role_bitvector = jsonObject.getInt("rune_group_role_set"); + long group_role_bitvector = jsonObject.getLong("rune_group_role_set"); - rune_group_role_set.addAll(mbEnums.fromInt(group_role_bitvector, mbEnums.MobBehaviourType.class)); + rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class)); JSONArray enemy_types_json = jsonObject.getJSONArray("rune_enemy_monster_types"); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 025a57b1..3c68ddc9 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -143,8 +143,8 @@ public class Mob extends AbstractIntelligenceAgent implements Delayed { this.runeSet = rs.getInt("runeSet"); this.bootySet = rs.getInt("bootySet"); - this.notEnemy = mbEnums.fromInt(rs.getInt("notEnemy"), mbEnums.MonsterType.class); - this.enemy = mbEnums.fromInt(rs.getInt("enemy"), mbEnums.MonsterType.class); + this.notEnemy = mbEnums.fromLong(rs.getLong("notEnemy"), mbEnums.MonsterType.class); + this.enemy = mbEnums.fromLong(rs.getLong("enemy"), mbEnums.MonsterType.class); this.firstName = rs.getString("mob_name"); if (rs.getString("fsm").length() > 1) diff --git a/src/engine/objects/MobBase.java b/src/engine/objects/MobBase.java index c7c3669c..ee54309b 100644 --- a/src/engine/objects/MobBase.java +++ b/src/engine/objects/MobBase.java @@ -77,9 +77,9 @@ public class MobBase extends AbstractGameObject { this.fsm = mbEnums.MobBehaviourType.valueOf(rs.getString("fsm")); - this.flags = mbEnums.fromInt(rs.getInt("flags"), mbEnums.MobFlagType.class); - this.notEnemy = mbEnums.fromInt(rs.getInt("notEnemy"), mbEnums.MonsterType.class); - this.enemy = mbEnums.fromInt(rs.getInt("enemy"), mbEnums.MonsterType.class); + this.flags = mbEnums.fromLong(rs.getLong("flags"), mbEnums.MobFlagType.class); + this.notEnemy = mbEnums.fromLong(rs.getLong("notEnemy"), mbEnums.MonsterType.class); + this.enemy = mbEnums.fromLong(rs.getLong("enemy"), mbEnums.MonsterType.class); this.seeInvis = rs.getInt("seeInvis"); this.scale = rs.getFloat("scale"); From fcbb9b0cf1abc843fac9047f7ab07de561454a32 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 12:56:01 -0400 Subject: [PATCH 283/378] Update to sparsetype parsing --- src/engine/objects/ItemTemplate.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 95174741..8f61fb9d 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -545,9 +545,10 @@ public class ItemTemplate { JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data"); - for (String sparseType : rune_sparse_json.keySet()) { - Object sparseValue = rune_sparse_json.getString(sparseType); - rune_sparse_data.put(sparseType, sparseValue.toString()); + for (Object key : rune_sparse_json.keySet()) { + String sparseType = key.toString(); + String sparseValue = (String) rune_sparse_json.get(sparseType); + rune_sparse_data.put(sparseType, sparseValue); } JSONArray skill_adj_json = (JSONArray) jsonObject.get("rune_skill_adj"); From 8ce81b144af576cd6d5b2098bd4037853b7080b7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 13:01:25 -0400 Subject: [PATCH 284/378] Update to sparsetype parsing --- src/engine/objects/ItemTemplate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 8f61fb9d..e4f54e5b 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -547,7 +547,7 @@ public class ItemTemplate { for (Object key : rune_sparse_json.keySet()) { String sparseType = key.toString(); - String sparseValue = (String) rune_sparse_json.get(sparseType); + String sparseValue = rune_sparse_json.getString(sparseType); rune_sparse_data.put(sparseType, sparseValue); } From 576f4af433609cc03d152848818227e6ea2b543c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 13:18:41 -0400 Subject: [PATCH 285/378] Update to sparsetype parsing --- src/engine/objects/ItemTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index e4f54e5b..ca49d591 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -547,8 +547,8 @@ public class ItemTemplate { for (Object key : rune_sparse_json.keySet()) { String sparseType = key.toString(); - String sparseValue = rune_sparse_json.getString(sparseType); - rune_sparse_data.put(sparseType, sparseValue); + Object sparseValue = rune_sparse_json.get(sparseType); + rune_sparse_data.put(sparseType, sparseValue.toString()); } JSONArray skill_adj_json = (JSONArray) jsonObject.get("rune_skill_adj"); From d0a837783e21f7de18c9084a203e00170f550593 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 13:23:18 -0400 Subject: [PATCH 286/378] Update to sparsetype parsing --- src/engine/objects/ItemTemplate.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index ca49d591..09c26d9d 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -173,9 +173,10 @@ public class ItemTemplate { JSONObject obj_sparse_json = jsonObject.getJSONObject("obj_sparse_data"); - for (String key : obj_sparse_json.keySet()) { - String sparseValue = obj_sparse_json.getString(key); - obj_sparse_data.put(key, sparseValue); + for (Object key : obj_sparse_json.keySet()) { + String sparseType = key.toString(); + Object sparseValue = obj_sparse_json.get(sparseType); + obj_sparse_data.put(sparseType, sparseValue.toString()); } // Banes are defined by their sparse data field From 07a5de2c57672bfbc3bfda6595776529cf1d7613 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 13:33:03 -0400 Subject: [PATCH 287/378] Helpee and groupee parsing --- src/engine/objects/ItemTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 09c26d9d..2f159242 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -530,14 +530,14 @@ public class ItemTemplate { JSONArray groupee_types_json = jsonObject.getJSONArray("rune_groupee_monster_types"); for (Object o : groupee_types_json) { - int groupeeId = ((Long) o).intValue(); + int groupeeId = Long.valueOf((int) o).intValue(); rune_groupee_monster_types.add(groupeeId); } JSONArray helper_types_json = jsonObject.getJSONArray("rune_helper_monster_types"); for (Object o : helper_types_json) { - int helperId = ((Long) o).intValue(); + int helperId = Long.valueOf((int) o).intValue(); rune_helper_monster_types.add(helperId); } From d92b1c74732d12ff959be10286e8d4c407f3d920 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 13:38:04 -0400 Subject: [PATCH 288/378] Helpee and groupee parsing --- src/engine/objects/ItemTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 2f159242..2afec01c 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -530,14 +530,14 @@ public class ItemTemplate { JSONArray groupee_types_json = jsonObject.getJSONArray("rune_groupee_monster_types"); for (Object o : groupee_types_json) { - int groupeeId = Long.valueOf((int) o).intValue(); + int groupeeId = (int) o; rune_groupee_monster_types.add(groupeeId); } JSONArray helper_types_json = jsonObject.getJSONArray("rune_helper_monster_types"); for (Object o : helper_types_json) { - int helperId = Long.valueOf((int) o).intValue(); + int helperId = (int) o; rune_helper_monster_types.add(helperId); } From 19c6cd76a95afb4200e5d0d68356ab8e3d258a4d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 13:43:22 -0400 Subject: [PATCH 289/378] Warehouse updated for org.json --- src/engine/gameManager/ForgeManager.java | 2 -- src/engine/objects/Warehouse.java | 18 +----------------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f38ff8e0..5423d5b7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -144,8 +144,6 @@ public enum ForgeManager implements Runnable { forge.add(workOrder); JSONObject jsonWorkOrder = WorkOrder.toJson(workOrder); - String stringOrder = jsonWorkOrder.toString(); - stringOrder = stringOrder.trim(); } catch (Exception e) { Logger.error(e); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index f15a6611..58c3a06f 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -58,7 +58,7 @@ public class Warehouse { for (String key : resources.keySet()) { mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); - int value = ((Long) resources.get(key)).intValue(); + int value = resources.getInt(key); this.resources.put(resourceType, value); } @@ -70,22 +70,6 @@ public class Warehouse { } - public static HashMap - calculateWarehouseOverdraft(Warehouse warehouse, HashMap costMap) { - - HashMap overdraft = new HashMap<>(); - - for (mbEnums.ResourceType resourceType : costMap.keySet()) { - - int cost = costMap.get(resourceType); - - if (cost > warehouse.resources.get(resourceType)) - overdraft.put(resourceType, cost - warehouse.resources.get(resourceType)); - } - - return overdraft; - } - public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { Building warehouseBuilding; From a53848334f5181186886f63742cb8caa4ab1b608 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 14:47:42 -0400 Subject: [PATCH 290/378] id is key not saved in json --- src/engine/loot/WorkOrder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 971ebf74..6f054a61 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -55,7 +55,6 @@ public class WorkOrder implements Delayed { JSONObject jsonWorkOrder = new JSONObject(); - jsonWorkOrder.put("workOrderID", workOrder.workOrderID); jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); jsonWorkOrder.put("slots_used", workOrder.slots_used); jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); From fb9d65b54d948b88154dce38175de082b23e8674 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 14:55:46 -0400 Subject: [PATCH 291/378] Method to save workorders to disk created --- .../db/handlers/dbWarehouseHandler.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 03033d4b..032cbfc1 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -10,6 +10,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.mbEnums.TransactionType; @@ -151,4 +152,23 @@ public class dbWarehouseHandler extends dbHandlerBase { Logger.error(e); } } + + public boolean UPDATE_WORKORDER(WorkOrder workOrder) { + + JSONObject warehouseJSON = WorkOrder.toJson(workOrder); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_workorders` (`workorderID`, `workorder`) VALUES (?, ?) " + + "ON DUPLICATE KEY UPDATE `workoder` = VALUES(`workoder`)")) { + + preparedStatement.setInt(1, workOrder.workOrderID); + preparedStatement.setString(2, warehouseJSON.toString()); + + return (preparedStatement.executeUpdate() > 0); + + } catch (SQLException e) { + Logger.error(e); + } + return false; + } } From bb5904552aafa70c438c94ecc687d95b2a87dbc2 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 14:57:00 -0400 Subject: [PATCH 292/378] Worker saved upon submit --- src/engine/gameManager/ForgeManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 5423d5b7..bef56746 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -16,7 +16,6 @@ import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; import engine.objects.*; import engine.powers.EffectsBase; -import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -143,7 +142,9 @@ public enum ForgeManager implements Runnable { vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); - JSONObject jsonWorkOrder = WorkOrder.toJson(workOrder); + // Save workOrder to disk + + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); } catch (Exception e) { Logger.error(e); From 684a5459b39ede4a53d6d916ca3af4d9d92d814d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:02:15 -0400 Subject: [PATCH 293/378] Worker saved upon submit --- src/engine/db/handlers/dbWarehouseHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 032cbfc1..f9976885 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -159,7 +159,7 @@ public class dbWarehouseHandler extends dbHandlerBase { try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_workorders` (`workorderID`, `workorder`) VALUES (?, ?) " + - "ON DUPLICATE KEY UPDATE `workoder` = VALUES(`workoder`)")) { + "ON DUPLICATE KEY UPDATE `workorder` = VALUES(`workorder`)")) { preparedStatement.setInt(1, workOrder.workOrderID); preparedStatement.setString(2, warehouseJSON.toString()); From 7b7492b5cc9f2b7539651f3a529d5c92f515b757 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:09:43 -0400 Subject: [PATCH 294/378] Workokrders updates as they cycle --- src/engine/db/handlers/dbWarehouseHandler.java | 12 ++++++++++++ src/engine/gameManager/ForgeManager.java | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index f9976885..843113d0 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -171,4 +171,16 @@ public class dbWarehouseHandler extends dbHandlerBase { } return false; } + + public void DELETE_WORKORDER(WorkOrder workOrder) { + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_workorders` WHERE `workorderID` = ?;")) { + preparedStatement.setInt(1, workOrder.workOrderID); + preparedStatement.executeUpdate(); + + } catch (SQLException e) { + Logger.error(e); + } + + } } diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index bef56746..6f17cfab 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -57,6 +57,10 @@ public enum ForgeManager implements Runnable { } workOrder.runCompleted = true; + + // Update workorder to disk + + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); } if (workOrder.runCompleted) @@ -328,6 +332,11 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.total_produced = workOrder.total_produced + 1; } + + // Save updated status to disk + + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + } public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) { From c03f4640430fd22fb0507a3fa073086a93b95085 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:12:46 -0400 Subject: [PATCH 295/378] More workorder db work --- .../client/handlers/ItemProductionMsgHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 05528578..61657863 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -148,10 +148,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.slots_used = workOrder.slots_used - 1; - // If this is the last item then remove the workOrder from the game + // Update workOrder on disk - if (workOrder.cooking.isEmpty()) + if (workOrder.cooking.isEmpty()) { ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + } else + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); // Persist item and add to vendor inventory @@ -399,10 +402,13 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.slots_used = workOrder.slots_used - 1; - // If this is the last item then remove the workOrder from the game + // Update workOrder on disk - if (workOrder.cooking.isEmpty()) + if (workOrder.cooking.isEmpty()) { ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + } else + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); // Refresh vendor's inventory to client From 89c3eb4d476911aaf101c917250a46163bdf4c6f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:34:57 -0400 Subject: [PATCH 296/378] New workorder constructor --- src/engine/loot/WorkOrder.java | 35 ++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 6f054a61..82fa1441 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,6 +8,7 @@ package engine.loot; +import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; @@ -47,8 +48,38 @@ public class WorkOrder implements Delayed { } - public WorkOrder(String json) { - + public WorkOrder(JSONObject jsonWorkOrder) { + + this.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); + this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); + this.slots_used = jsonWorkOrder.getInt("slots_used"); + this.total_to_produce = jsonWorkOrder.getInt("total_to_produce"); + this.total_produced = jsonWorkOrder.getInt("total_produced"); + this.multiple_slot_request = jsonWorkOrder.getBoolean("multiple_slot_request"); + this.templateID = jsonWorkOrder.getInt("templateID"); + this.item_name_override = jsonWorkOrder.getString("item_name_override"); + this.prefixToken = jsonWorkOrder.getInt("prefixToken"); + this.suffixToken = jsonWorkOrder.getInt("suffixToken"); + this.slots_used = jsonWorkOrder.getInt("slots_used"); + this.rollingDuration = jsonWorkOrder.getLong("rollingDuration"); + this.completionTime = jsonWorkOrder.getLong("completionTime"); + this.runCompleted = jsonWorkOrder.getBoolean("runCompleted"); + + JSONObject productionCostMap = jsonWorkOrder.getJSONObject("production_cost"); + + for (String key : productionCostMap.keySet()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); + int value = productionCostMap.getInt(key); + this.production_cost.put(resourceType, value); + } + + JSONObject productionTotalCostMap = jsonWorkOrder.getJSONObject("production_cost"); + + for (String key : productionTotalCostMap.keySet()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); + int value = productionTotalCostMap.getInt(key); + this.production_cost_total.put(resourceType, value); + } } public static JSONObject toJson(WorkOrder workOrder) { From 2a2b61bc0f2af6cd27028f1588c63a0f9c348822 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:43:13 -0400 Subject: [PATCH 297/378] Method to load workorders on bootstrap --- .../db/handlers/dbWarehouseHandler.java | 19 +++++++++++++++++++ src/engine/loot/WorkOrder.java | 2 -- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 843113d0..139303e8 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -183,4 +183,23 @@ public class dbWarehouseHandler extends dbHandlerBase { } } + + public void LOAD_WORKORDERS() { + + ArrayList deleteList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;"); + ResultSet rs = preparedStatement.executeQuery()) { + + while (rs.next()) { + int workOrderID = rs.getInt("workOrderID"); + JSONObject jsonObject = new JSONObject(rs.getString("workorder")); + WorkOrder workOrder = new WorkOrder(jsonObject); + deleteList.add(workOrder); + } + } catch (Exception e) { + Logger.error(e); + } + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 82fa1441..bc2a0dfd 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,7 +8,6 @@ package engine.loot; -import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; @@ -50,7 +49,6 @@ public class WorkOrder implements Delayed { public WorkOrder(JSONObject jsonWorkOrder) { - this.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.slots_used = jsonWorkOrder.getInt("slots_used"); this.total_to_produce = jsonWorkOrder.getInt("total_to_produce"); From 7300af9073f60478fdc9318281a39541ced4399e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 15:49:57 -0400 Subject: [PATCH 298/378] Method to load workorders on bootstrap --- src/engine/db/handlers/dbWarehouseHandler.java | 13 ++++++++++--- src/engine/loot/WorkOrder.java | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 139303e8..49ec1e8b 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -186,20 +186,27 @@ public class dbWarehouseHandler extends dbHandlerBase { public void LOAD_WORKORDERS() { - ArrayList deleteList = new ArrayList<>(); + ArrayList submitList = new ArrayList<>(); try (Connection connection = DbManager.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_workorders`;"); ResultSet rs = preparedStatement.executeQuery()) { while (rs.next()) { - int workOrderID = rs.getInt("workOrderID"); JSONObject jsonObject = new JSONObject(rs.getString("workorder")); WorkOrder workOrder = new WorkOrder(jsonObject); - deleteList.add(workOrder); + submitList.add(workOrder); } } catch (Exception e) { Logger.error(e); } + + // Delete the old records + + for (WorkOrder workOrder : submitList) + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + + // Pass the new workOrders to the ForgeManager + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index bc2a0dfd..f1fc288f 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -49,6 +49,7 @@ public class WorkOrder implements Delayed { public WorkOrder(JSONObject jsonWorkOrder) { + this.workOrderID = jsonWorkOrder.getInt("workOrderID"); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.slots_used = jsonWorkOrder.getInt("slots_used"); this.total_to_produce = jsonWorkOrder.getInt("total_to_produce"); From 73e30062ea550b50084ac8323133a7220b1bd2a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:02:22 -0400 Subject: [PATCH 299/378] Method to load workorders on bootstrap --- src/engine/db/handlers/dbWarehouseHandler.java | 14 +++++++++++++- src/engine/loot/WorkOrder.java | 10 ++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 49ec1e8b..f353a046 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -10,6 +10,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.gameManager.ForgeManager; import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; @@ -201,12 +202,23 @@ public class dbWarehouseHandler extends dbHandlerBase { Logger.error(e); } - // Delete the old records + // Process workOrder records for (WorkOrder workOrder : submitList) DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + for (WorkOrder workOrder : submitList) { + + // WorkOrder needs a new ID + + workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); + + // Reconstruct cooking items + + + } // Pass the new workOrders to the ForgeManager + } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index f1fc288f..59eec45f 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,6 +11,7 @@ package engine.loot; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; +import org.json.JSONArray; import org.json.JSONObject; import java.time.Duration; @@ -79,6 +80,15 @@ public class WorkOrder implements Delayed { int value = productionTotalCostMap.getInt(key); this.production_cost_total.put(resourceType, value); } + + // Reconstruct cooking items + + JSONArray tokenList = jsonWorkOrder.getJSONArray("cookingTokens"); + + for (Object o : tokenList) { + int prefix = tokenList.getInt(0); + int suffix = tokenList.getInt(1); + } } public static JSONObject toJson(WorkOrder workOrder) { From 286a76b1def1bc048317ab76e6eb89e44ed6fd5f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:07:25 -0400 Subject: [PATCH 300/378] More workorder loading work --- src/engine/db/handlers/dbWarehouseHandler.java | 14 ++++---------- src/engine/loot/WorkOrder.java | 4 ++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index f353a046..32b25399 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -202,23 +202,17 @@ public class dbWarehouseHandler extends dbHandlerBase { Logger.error(e); } - // Process workOrder records + // Remove the old workOrder records for (WorkOrder workOrder : submitList) DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); - for (WorkOrder workOrder : submitList) { - - // WorkOrder needs a new ID + // Submit the new workOrders to the ForgeManager + for (WorkOrder workOrder : submitList) { workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); - - // Reconstruct cooking items - + ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); } - // Pass the new workOrders to the ForgeManager - - } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 59eec45f..b3a19031 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,6 +8,7 @@ package engine.loot; +import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; import engine.objects.NPC; @@ -88,6 +89,9 @@ public class WorkOrder implements Delayed { for (Object o : tokenList) { int prefix = tokenList.getInt(0); int suffix = tokenList.getInt(1); + Item cookingItem = ForgeManager.forgeItem(this); + cookingItem.prefixToken = prefix; + cookingItem.suffixToken = suffix; } } From e710cf0930e9f6bab91bf6d79ce8c66f08f916e7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:12:26 -0400 Subject: [PATCH 301/378] Loading workorders at bootstrap --- src/engine/server/world/WorldServer.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index ed45878a..821c9463 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -452,6 +452,9 @@ public class WorldServer { Logger.info("Starting ForgeManager thread"); ForgeManager.start(); + Logger.info("Restoring NPC workOrders"); + DbManager.WarehouseQueries.LOAD_WORKORDERS(); + // Run maintenance MaintenanceManager.dailyMaintenance(); From e8032f65d1b203b1934f4c4380f7882204790f1c Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:14:10 -0400 Subject: [PATCH 302/378] Loading workorders at bootstrap --- src/engine/loot/WorkOrder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index b3a19031..36fa5f5f 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -92,6 +92,7 @@ public class WorkOrder implements Delayed { Item cookingItem = ForgeManager.forgeItem(this); cookingItem.prefixToken = prefix; cookingItem.suffixToken = suffix; + cookingItem.setDateToUpgrade(this.completionTime); } } From 2adaff8f6626920cd9fefa1a3fcb57eab24d6789 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:21:00 -0400 Subject: [PATCH 303/378] workOrderID added to output --- src/engine/loot/WorkOrder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 36fa5f5f..60a62453 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -100,6 +100,7 @@ public class WorkOrder implements Delayed { JSONObject jsonWorkOrder = new JSONObject(); + jsonWorkOrder.put("workOrderID", workOrder.workOrderID); jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); jsonWorkOrder.put("slots_used", workOrder.slots_used); jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); From de65f6bcefebfbab43b948fbb291c2b664cc09d6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:28:02 -0400 Subject: [PATCH 304/378] Bugfix in pre/suf parsing --- src/engine/loot/WorkOrder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 60a62453..b10addfb 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -87,8 +87,8 @@ public class WorkOrder implements Delayed { JSONArray tokenList = jsonWorkOrder.getJSONArray("cookingTokens"); for (Object o : tokenList) { - int prefix = tokenList.getInt(0); - int suffix = tokenList.getInt(1); + int prefix = ((JSONArray) o).getInt(0); + int suffix = ((JSONArray) o).getInt(1); Item cookingItem = ForgeManager.forgeItem(this); cookingItem.prefixToken = prefix; cookingItem.suffixToken = suffix; From 50a169149f0995e59dac1208318230b23ecbb21b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 22 Apr 2024 16:33:29 -0400 Subject: [PATCH 305/378] Resubmit unfinished workorders --- src/engine/db/handlers/dbWarehouseHandler.java | 5 +++++ src/engine/gameManager/ForgeManager.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 32b25399..c58cb10e 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -213,6 +213,11 @@ public class dbWarehouseHandler extends dbHandlerBase { workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); + // If workorder is not yet complete process it + + if (workOrder.runCompleted == false) + ForgeManager.forge.add(workOrder); + } } } diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6f17cfab..5221498c 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -27,7 +27,7 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; - private static final BlockingQueue forge = new DelayQueue<>(); + public static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); From d7ac838b6d786e1ca217f4cf6c1aa2a1c6ba35b3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:11:04 -0400 Subject: [PATCH 306/378] Simplified lambda function --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 5221498c..756cbbae 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -130,7 +130,7 @@ public enum ForgeManager implements Runnable { // Set total cost for this production run workOrder.production_cost_total.putAll(workOrder.production_cost); - workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.compute(key, (k, v) -> v * workOrder.total_to_produce)); + workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); // Deduct gold cost from building From 9efba13b03549eff01fa1bafec3c2d3ecd3f6b4a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:14:31 -0400 Subject: [PATCH 307/378] Simplified lambda function --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 756cbbae..b546fac0 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -388,7 +388,7 @@ public enum ForgeManager implements Runnable { if (warehouse == null) return false; - workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.compute(key, (k, v) -> warehouse.resources.get(key) - value)); + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); } return true; From 9de1afa0fd3f6f1326a7e48b1d4cce13f145084a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:15:26 -0400 Subject: [PATCH 308/378] Comment update --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b546fac0..b84c2ac2 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -378,8 +378,6 @@ public enum ForgeManager implements Runnable { if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) > strongbox) { - // Deduct total cost from warehouse - if (workOrder.vendor.building.getCity() == null) return false; @@ -388,6 +386,8 @@ public enum ForgeManager implements Runnable { if (warehouse == null) return false; + // Deduct total cost from warehouse + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); } From 30787f7ae2d86e85c3fdd4208c3f4357cf7fedc7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:25:26 -0400 Subject: [PATCH 309/378] Remnants of old garbage system removed --- src/engine/db/handlers/dbNPCHandler.java | 33 ------------------------ src/engine/objects/MobLoot.java | 1 - 2 files changed, 34 deletions(-) diff --git a/src/engine/db/handlers/dbNPCHandler.java b/src/engine/db/handlers/dbNPCHandler.java index 9e0a18ff..38ec0fee 100644 --- a/src/engine/db/handlers/dbNPCHandler.java +++ b/src/engine/db/handlers/dbNPCHandler.java @@ -345,39 +345,6 @@ public class dbNPCHandler extends dbHandlerBase { + NPC._pirateNames.size() + " mobBases"); } - public boolean REMOVE_FROM_PRODUCTION_LIST(final long ID, final long npcUID) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("DELETE FROM `dyn_npc_production` WHERE `ID`=? AND `npcUID`=?;")) { - - preparedStatement.setLong(1, ID); - preparedStatement.setLong(2, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - - public boolean UPDATE_ITEM_PRICE(final long ID, final long npcUID, int value) { - - try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("UPDATE `dyn_npc_production` SET `value`=? WHERE `ID`=? AND `npcUID`=?;")) { - - preparedStatement.setInt(1, value); - preparedStatement.setLong(2, ID); - preparedStatement.setLong(3, npcUID); - - return (preparedStatement.executeUpdate() > 0); - - } catch (SQLException e) { - Logger.error(e); - return false; - } - } - public boolean UPDATE_PROFITS(NPC npc, ProfitType profitType, float value) { try (Connection connection = DbManager.getConnection(); diff --git a/src/engine/objects/MobLoot.java b/src/engine/objects/MobLoot.java index db718610..643e53eb 100644 --- a/src/engine/objects/MobLoot.java +++ b/src/engine/objects/MobLoot.java @@ -139,7 +139,6 @@ public final class MobLoot extends Item { //remove from production list for npc in db - DbManager.NPCQueries.REMOVE_FROM_PRODUCTION_LIST(this.getObjectUUID(), vendor.getObjectUUID()); this.removeFromCache(); isDeleted = true; } From 46b4c110e51f91fe00e0e258346019de5ebf1348 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:38:49 -0400 Subject: [PATCH 310/378] Rebuild of ./createitem --- src/engine/devcmd/cmds/CreateItemCmd.java | 39 +++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/engine/devcmd/cmds/CreateItemCmd.java b/src/engine/devcmd/cmds/CreateItemCmd.java index c5acefab..4e2d0b87 100644 --- a/src/engine/devcmd/cmds/CreateItemCmd.java +++ b/src/engine/devcmd/cmds/CreateItemCmd.java @@ -10,8 +10,14 @@ package engine.devcmd.cmds; import engine.devcmd.AbstractDevCmd; +import engine.gameManager.ChatManager; +import engine.gameManager.DbManager; +import engine.mbEnums; import engine.objects.AbstractGameObject; +import engine.objects.Item; +import engine.objects.ItemTemplate; import engine.objects.PlayerCharacter; +import org.pmw.tinylog.Logger; /** * @author Eighty @@ -23,22 +29,51 @@ public class CreateItemCmd extends AbstractDevCmd { } @Override - protected void _doCmd(PlayerCharacter pc, String[] words, + protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { + boolean worked = false; if (words.length < 2) { - this.sendUsage(pc); + this.sendUsage(playerCharacter); return; } int templateID = Integer.parseInt(words[0]); + ItemTemplate template = ItemTemplate.templates.get(templateID); + + if (template == null) + return; + ; int size = 1; if (words.length == 2) size = Integer.parseInt(words[1]); + for (int i = 0; i < size; i++) { + worked = false; + + if (!playerCharacter.charItemManager.hasRoomInventory(template.item_wt)) { + ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item."); + break; + } + Item item = new Item(templateID); + item.ownerID = playerCharacter.getObjectUUID(); + item.ownerType = mbEnums.OwnerType.PlayerCharacter; + item.containerType = mbEnums.ItemContainerType.INVENTORY; + + try { + item = DbManager.ItemQueries.PERSIST(item); + worked = true; + } catch (Exception e) { + Logger.error(e); + } + if (worked) { + playerCharacter.charItemManager.addItemToInventory(item); + } + } + playerCharacter.charItemManager.updateInventory(); } @Override From a7e953ac20f0f37ba47531dc997429b3dee6e9bb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:41:10 -0400 Subject: [PATCH 311/378] Rebuild of ./createitem --- src/engine/devcmd/cmds/CreateItemCmd.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/engine/devcmd/cmds/CreateItemCmd.java b/src/engine/devcmd/cmds/CreateItemCmd.java index 4e2d0b87..d934c6d4 100644 --- a/src/engine/devcmd/cmds/CreateItemCmd.java +++ b/src/engine/devcmd/cmds/CreateItemCmd.java @@ -31,7 +31,6 @@ public class CreateItemCmd extends AbstractDevCmd { @Override protected void _doCmd(PlayerCharacter playerCharacter, String[] words, AbstractGameObject target) { - boolean worked = false; if (words.length < 2) { this.sendUsage(playerCharacter); @@ -43,7 +42,6 @@ public class CreateItemCmd extends AbstractDevCmd { if (template == null) return; - ; int size = 1; @@ -51,7 +49,6 @@ public class CreateItemCmd extends AbstractDevCmd { size = Integer.parseInt(words[1]); for (int i = 0; i < size; i++) { - worked = false; if (!playerCharacter.charItemManager.hasRoomInventory(template.item_wt)) { ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item."); @@ -65,13 +62,10 @@ public class CreateItemCmd extends AbstractDevCmd { try { item = DbManager.ItemQueries.PERSIST(item); - worked = true; + playerCharacter.charItemManager.addItemToInventory(item); } catch (Exception e) { Logger.error(e); } - if (worked) { - playerCharacter.charItemManager.addItemToInventory(item); - } } playerCharacter.charItemManager.updateInventory(); } From d999d00755bc8f0614e46f62f6ccf3501c02b8c1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 12:42:12 -0400 Subject: [PATCH 312/378] Rebuild of ./createitem --- src/engine/devcmd/cmds/CreateItemCmd.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/engine/devcmd/cmds/CreateItemCmd.java b/src/engine/devcmd/cmds/CreateItemCmd.java index d934c6d4..07c2f1f5 100644 --- a/src/engine/devcmd/cmds/CreateItemCmd.java +++ b/src/engine/devcmd/cmds/CreateItemCmd.java @@ -40,9 +40,10 @@ public class CreateItemCmd extends AbstractDevCmd { int templateID = Integer.parseInt(words[0]); ItemTemplate template = ItemTemplate.templates.get(templateID); - if (template == null) + if (template == null) { + ChatManager.chatSystemInfo(playerCharacter, "No such template found."); return; - + } int size = 1; if (words.length == 2) @@ -51,7 +52,7 @@ public class CreateItemCmd extends AbstractDevCmd { for (int i = 0; i < size; i++) { if (!playerCharacter.charItemManager.hasRoomInventory(template.item_wt)) { - ChatManager.chatSystemInfo(playerCharacter, "You can not carry any more of that item."); + ChatManager.chatSystemInfo(playerCharacter, "You are encumbered!."); break; } From 9102fe1f6cf017f5ec6f0345b2bf741ef448e2eb Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:12:49 -0400 Subject: [PATCH 313/378] Update to single item rolling config --- src/engine/gameManager/ForgeManager.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b84c2ac2..76b95410 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -124,6 +124,13 @@ public enum ForgeManager implements Runnable { workOrder.slots_used = calcAvailableSlots(workOrder); workOrder.total_produced = 0; + + // Single item configuration + + if (workOrder.multiple_slot_request == false && + workOrder.total_to_produce == 0) + workOrder.total_to_produce = 1; + workOrder.total_to_produce *= workOrder.slots_used; workOrder.production_cost = calcProductionCost(workOrder); From 8d7d3227cbe986a9b3644d5b9973127a362e3945 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:15:15 -0400 Subject: [PATCH 314/378] Update to submit logging --- src/engine/gameManager/ForgeManager.java | 1 + src/engine/loot/WorkOrder.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 76b95410..f095dd8a 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -162,6 +162,7 @@ public enum ForgeManager implements Runnable { } finally { city.transactionLock.writeLock().unlock(); } + Logger.info(workOrder.toString()); return validation_result; } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index b10addfb..fc4e8a33 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -158,7 +158,9 @@ public class WorkOrder implements Delayed { "rollingDuration: " + duration + "\r\n" + "completionTime: " + localDateTime + "\r\n" + "runCompleted: " + this.runCompleted + "\r\n" + - "runCanceled: " + this.runCanceled + "\r\n"; + "runCanceled: " + this.runCanceled + "\r\n" + + "productionCost: " + this.production_cost.toString() + "\r\n" + + "totalProductionCost:: " + this.production_cost_total.toString(); return outSTring; } From a76fd9f319b391568dcbbe3a1909600e4a737e05 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:20:34 -0400 Subject: [PATCH 315/378] Update to identify assignment --- src/engine/gameManager/ForgeManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f095dd8a..55952874 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -266,6 +266,8 @@ public enum ForgeManager implements Runnable { if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) forgedItem.flags.remove(mbEnums.ItemFlags.Identified); + else + forgedItem.flags.add(mbEnums.ItemFlags.Identified); // Add virtual item to in-memory caches From 6cbcef00aaf8b2ba12476218d8ae0596f2a50829 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:27:01 -0400 Subject: [PATCH 316/378] Serialization update --- src/engine/net/client/msg/ItemProductionMsg.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index 76f851ac..eaf49f60 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -10,6 +10,8 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; +import engine.gameManager.ForgeManager; +import engine.loot.WorkOrder; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.net.*; @@ -235,10 +237,12 @@ public class ItemProductionMsg extends ClientNetMsg { Item toRoll = Item.getFromCache(this.itemUUID); writer.putInt(-1497023830); + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(toRoll); + this.pToken = toRoll.prefixToken; this.sToken = toRoll.suffixToken; - if (toRoll.isComplete()) { + if (toRoll.isComplete() || (workOrder.prefixToken != 0 && workOrder.suffixToken != 0)) { writer.putInt(this.pToken); writer.putInt(this.sToken); } else { From 4e05c2ab748aed03d0289e68f1b6b30221197517 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:38:35 -0400 Subject: [PATCH 317/378] Warehouse debit work --- src/engine/gameManager/ForgeManager.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 55952874..d0dd2781 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -127,8 +127,7 @@ public enum ForgeManager implements Runnable { // Single item configuration - if (workOrder.multiple_slot_request == false && - workOrder.total_to_produce == 0) + if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) workOrder.total_to_produce = 1; workOrder.total_to_produce *= workOrder.slots_used; @@ -386,21 +385,19 @@ public enum ForgeManager implements Runnable { int strongbox = workOrder.vendor.building.getStrongboxValue(); - if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) > strongbox) { + if (workOrder.vendor.building.getCity() == null) + return false; - if (workOrder.vendor.building.getCity() == null) - return false; + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; - Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; + if (warehouse == null) + return false; - if (warehouse == null) - return false; + // Deduct total cost from warehouse - // Deduct total cost from warehouse + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); + DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); - workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); - DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); - } return true; } } From 260796203849120500e6e4d71a8f2834dc0b60e6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 13:40:51 -0400 Subject: [PATCH 318/378] Minor cleanup --- src/engine/gameManager/ForgeManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d0dd2781..a74cc200 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -130,11 +130,11 @@ public enum ForgeManager implements Runnable { if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) workOrder.total_to_produce = 1; - workOrder.total_to_produce *= workOrder.slots_used; - workOrder.production_cost = calcProductionCost(workOrder); - // Set total cost for this production run + workOrder.total_to_produce *= workOrder.slots_used; + + workOrder.production_cost = calcProductionCost(workOrder); workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); From f48b9f10e168349b2de267e203bb36a49535a0a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 14:25:19 -0400 Subject: [PATCH 319/378] Code written to refactor db call out of effect costs. --- .../dbEffectsResourceCostHandler.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/engine/db/handlers/dbEffectsResourceCostHandler.java b/src/engine/db/handlers/dbEffectsResourceCostHandler.java index 8525144c..998cdc66 100644 --- a/src/engine/db/handlers/dbEffectsResourceCostHandler.java +++ b/src/engine/db/handlers/dbEffectsResourceCostHandler.java @@ -12,6 +12,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; import engine.mbEnums; import engine.objects.EffectsResourceCosts; +import org.json.JSONObject; import org.pmw.tinylog.Logger; import java.sql.Connection; @@ -19,6 +20,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.HashMap; public class dbEffectsResourceCostHandler extends dbHandlerBase { @@ -27,6 +29,67 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName()); } + public void GENERATE_COST_DATA() { + + } + + public JSONObject GET_EFFECT_COSTMAP(String effectID) { + HashMap costMap = new HashMap<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `IDString` FROM `static_power_effectcost` WHERE `IDString` = ?")) { + + preparedStatement.setString(1, effectID); + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + mbEnums.ResourceType resourceType = mbEnums.ResourceType.resourceLookup.get(rs.getInt("resource")); + int value = rs.getInt("amount"); + costMap.put(resourceType, value); + } + + } catch (SQLException e) { + Logger.error(e); + } + return new JSONObject(costMap); + } + + public ArrayList GET_EFFECTS_WITH_COST() { + + ArrayList effectList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `IDString` FROM `static_power_effectcost`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + effectList.add(rs.getString("IdString")); + } + + } catch (SQLException e) { + Logger.error(e); + } + return effectList; + } + + public boolean WRITE_COSTMAP(String effectID, JSONObject costmap) { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `static_effect_costmaps` (`effectID`, `costMap`) VALUES (?, ?) " + + "ON DUPLICATE KEY UPDATE `costmap` = VALUES(`costmap`)")) { + + preparedStatement.setString(1, effectID); + preparedStatement.setString(2, costmap.toString()); + + return (preparedStatement.executeUpdate() > 0); + + } catch (SQLException e) { + Logger.error(e); + } + return false; + } + public ArrayList GET_ALL_EFFECT_RESOURCES(String idString) { ArrayList effectsResourceCosts = new ArrayList<>(); From d59051103562585d2fc15ccc1857eaeaaa7dec14 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 14:27:12 -0400 Subject: [PATCH 320/378] Code written to refactor db call out of effect costs. --- src/engine/db/handlers/dbEffectsResourceCostHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/engine/db/handlers/dbEffectsResourceCostHandler.java b/src/engine/db/handlers/dbEffectsResourceCostHandler.java index 998cdc66..c06b686b 100644 --- a/src/engine/db/handlers/dbEffectsResourceCostHandler.java +++ b/src/engine/db/handlers/dbEffectsResourceCostHandler.java @@ -30,6 +30,12 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { } public void GENERATE_COST_DATA() { + ArrayList effectList = GET_EFFECTS_WITH_COST(); + + for (String effectID : effectList) { + JSONObject costMap = GET_EFFECT_COSTMAP(effectID); + WRITE_COSTMAP(effectID, costMap); + } } From e2dbc19adc18049b4d03294d9110787785f21027 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 14:31:08 -0400 Subject: [PATCH 321/378] Code written to refactor db call out of effect costs. --- src/engine/server/world/WorldServer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 821c9463..b8659649 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -455,6 +455,10 @@ public class WorldServer { Logger.info("Restoring NPC workOrders"); DbManager.WarehouseQueries.LOAD_WORKORDERS(); + Logger.info("Generating costmaps"); + DbManager.EffectsResourceCostsQueries.GENERATE_COST_DATA(); + ; + // Run maintenance MaintenanceManager.dailyMaintenance(); From 81f86ceca96db1ff049dc465a84aea5f5f5aa93a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 14:36:01 -0400 Subject: [PATCH 322/378] Code written to refactor db call out of effect costs. --- src/engine/db/handlers/dbEffectsResourceCostHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbEffectsResourceCostHandler.java b/src/engine/db/handlers/dbEffectsResourceCostHandler.java index c06b686b..dee88cf4 100644 --- a/src/engine/db/handlers/dbEffectsResourceCostHandler.java +++ b/src/engine/db/handlers/dbEffectsResourceCostHandler.java @@ -43,7 +43,7 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { HashMap costMap = new HashMap<>(); try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `IDString` FROM `static_power_effectcost` WHERE `IDString` = ?")) { + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_power_effectcost` WHERE `IDString` = ?")) { preparedStatement.setString(1, effectID); ResultSet rs = preparedStatement.executeQuery(); From 147b9a42c441d286f63484d07029722df76a1ce5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 14:41:34 -0400 Subject: [PATCH 323/378] Costmap data generated; removed from bootstrap --- src/engine/server/world/WorldServer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index b8659649..821c9463 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -455,10 +455,6 @@ public class WorldServer { Logger.info("Restoring NPC workOrders"); DbManager.WarehouseQueries.LOAD_WORKORDERS(); - Logger.info("Generating costmaps"); - DbManager.EffectsResourceCostsQueries.GENERATE_COST_DATA(); - ; - // Run maintenance MaintenanceManager.dailyMaintenance(); From bcb40fecbb19330693214af37f5c50f2926745f7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 14:56:30 -0400 Subject: [PATCH 324/378] Loading effect costmap data at bootsrap --- .../dbEffectsResourceCostHandler.java | 27 +++++++++++++++++++ src/engine/gameManager/PowersManager.java | 1 + src/engine/server/world/WorldServer.java | 3 +++ 3 files changed, 31 insertions(+) diff --git a/src/engine/db/handlers/dbEffectsResourceCostHandler.java b/src/engine/db/handlers/dbEffectsResourceCostHandler.java index dee88cf4..4ae2013a 100644 --- a/src/engine/db/handlers/dbEffectsResourceCostHandler.java +++ b/src/engine/db/handlers/dbEffectsResourceCostHandler.java @@ -10,6 +10,7 @@ package engine.db.handlers; import engine.gameManager.DbManager; +import engine.gameManager.PowersManager; import engine.mbEnums; import engine.objects.EffectsResourceCosts; import org.json.JSONObject; @@ -96,6 +97,32 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { return false; } + public void LOAD_ALL_COSTMAPS() { + + try (Connection connection = DbManager.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_effect_costmaps`")) { + + ResultSet rs = preparedStatement.executeQuery(); + + while (rs.next()) { + String effectID = rs.getString("effectID"); + String costString = rs.getString("costmap"); + JSONObject costJSON = new JSONObject(costString); + HashMap costmap = new HashMap<>(); + + for (String key : costJSON.keySet()) { + int value = costJSON.getInt(key); + costmap.put(mbEnums.ResourceType.valueOf(key), value); + } + + PowersManager._effect_costMaps.put(effectID, costmap); + } + + } catch (SQLException e) { + Logger.error(e); + } + } + public ArrayList GET_ALL_EFFECT_RESOURCES(String idString) { ArrayList effectsResourceCosts = new ArrayList<>(); diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java index 4578f79f..77c19da1 100644 --- a/src/engine/gameManager/PowersManager.java +++ b/src/engine/gameManager/PowersManager.java @@ -57,6 +57,7 @@ public enum PowersManager { public static HashMap AnimationOverrides = new HashMap<>(); public static HashMap> _allRunePowers; public static HashMap> _allRuneSkillAdjusts; + public static HashMap> _effect_costMaps = new HashMap<>(); private static JobScheduler js; public static void initPowersManager(boolean fullPowersLoad) { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 821c9463..48de8981 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -449,6 +449,9 @@ public class WorldServer { Logger.info("Starting Mob Respawn Thread"); Respawner.start(); + Logger.info("Loading effect cost maps"); + DbManager.EffectsResourceCostsQueries.LOAD_ALL_COSTMAPS(); + Logger.info("Starting ForgeManager thread"); ForgeManager.start(); From 4fa646ce94ec7a7eaf66fb06641a2b61593ca814 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 15:05:03 -0400 Subject: [PATCH 325/378] New costmap data implemented --- src/engine/gameManager/ForgeManager.java | 6 ++---- src/engine/powers/EffectsBase.java | 24 ++++++++---------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index a74cc200..b21a5eb7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -218,14 +218,12 @@ public enum ForgeManager implements Runnable { if (workOrder.prefixToken != 0) { EffectsBase prefix = PowersManager.getEffectByToken(workOrder.prefixToken); - EffectsBase prefixValue = PowersManager.getEffectByIDString(prefix.getIDString() + 'A'); - production_cost.putAll(prefixValue.getResourcesForEffect()); + production_cost.putAll(PowersManager._effect_costMaps.get(prefix.getIDString())); } if (workOrder.suffixToken != 0) { EffectsBase suffix = PowersManager.getEffectByToken(workOrder.suffixToken); - EffectsBase suffixValue = PowersManager.getEffectByIDString(suffix.getIDString() + 'A'); - production_cost.putAll(suffixValue.getResourcesForEffect()); + production_cost.putAll(PowersManager._effect_costMaps.get(suffix.getIDString())); } return production_cost; diff --git a/src/engine/powers/EffectsBase.java b/src/engine/powers/EffectsBase.java index dc72873a..24043173 100644 --- a/src/engine/powers/EffectsBase.java +++ b/src/engine/powers/EffectsBase.java @@ -9,10 +9,6 @@ package engine.powers; -import engine.mbEnums; -import engine.mbEnums.EffectSourceType; -import engine.mbEnums.GameObjectType; -import engine.mbEnums.PowerFailCondition; import engine.gameManager.DbManager; import engine.gameManager.PowersManager; import engine.job.JobContainer; @@ -20,11 +16,18 @@ import engine.jobs.AbstractEffectJob; import engine.jobs.DamageOverTimeJob; import engine.jobs.FinishSpireEffectJob; import engine.jobs.NoTimeJob; +import engine.mbEnums; +import engine.mbEnums.EffectSourceType; +import engine.mbEnums.GameObjectType; +import engine.mbEnums.PowerFailCondition; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ApplyEffectMsg; -import engine.objects.*; +import engine.objects.AbstractCharacter; +import engine.objects.AbstractWorldObject; +import engine.objects.Effect; +import engine.objects.PlayerCharacter; import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; @@ -718,15 +721,4 @@ public class EffectsBase { this.value = Value; } - public ConcurrentHashMap getResourcesForEffect() { - if (this.resourceCosts.isEmpty()) { - ArrayList effectsCostList = DbManager.EffectsResourceCostsQueries.GET_ALL_EFFECT_RESOURCES(this.IDString); - for (EffectsResourceCosts erc : effectsCostList) { - this.resourceCosts.put(mbEnums.ResourceType.resourceLookup.get(erc.getResourceID()), erc.getAmount()); - } - } - return this.resourceCosts; - } - - } From 911698a7e371119c729db9a36c3ac6ac3f3c0a18 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 15:11:56 -0400 Subject: [PATCH 326/378] Method moved to WorkOrder --- src/engine/gameManager/ForgeManager.java | 2 +- src/engine/gameManager/ItemManager.java | 28 ----------------------- src/engine/loot/WorkOrder.java | 29 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b21a5eb7..edc3c1c0 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -98,7 +98,7 @@ public enum ForgeManager implements Runnable { // Make sure vendor can roll the formulae, warehouse can // afford this wordOrder and other related checks. - int validation_result = ItemManager.validate(workOrder); + int validation_result = WorkOrder.validate(workOrder); // The return code is used by the submitter as a // popup error message for the player. diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index c9634ad8..76bd7f0f 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -1,6 +1,5 @@ package engine.gameManager; -import engine.loot.WorkOrder; import engine.mbEnums; import engine.objects.*; import engine.powers.EffectsBase; @@ -229,33 +228,6 @@ public enum ItemManager { return true; } - public static int validate(WorkOrder workOrder) { - - int validation_result = 0; - - ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); - - if (workOrder.vendor.getBuilding() == null) - return 58; //58: The formula is beyond the means of this facility - - if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) - return 30; //30: That person cannot carry that item - - if (!workOrder.vendor.getItemModTable().contains((template.modTable))) - return 59; //59: This hireling does not have this formula - - if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) - return 10; //18: You can't really afford that - - // Forge must be protected in order to access warehouse. - - if (ForgeManager.calcProductionCost(workOrder).size() > 1) - if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) - return 193; //193: Production denied: This building must be protected to gain access to warehouse - - return validation_result; - } - public static void applyItemEffects(Item forgedItem) { if (forgedItem.prefixToken != 0) { diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index fc4e8a33..815bf3d7 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -11,7 +11,9 @@ package engine.loot; import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; +import engine.objects.ItemTemplate; import engine.objects.NPC; +import engine.objects.Warehouse; import org.json.JSONArray; import org.json.JSONObject; @@ -127,6 +129,33 @@ public class WorkOrder implements Delayed { return jsonWorkOrder; } + public static int validate(WorkOrder workOrder) { + + int validation_result = 0; + + ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); + + if (workOrder.vendor.getBuilding() == null) + return 58; //58: The formula is beyond the means of this facility + + if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) + return 30; //30: That person cannot carry that item + + if (!workOrder.vendor.getItemModTable().contains((template.modTable))) + return 59; //59: This hireling does not have this formula + + if (!Warehouse.calcCostOverrun(workOrder).isEmpty()) + return 10; //18: You can't really afford that + + // Forge must be protected in order to access warehouse. + + if (ForgeManager.calcProductionCost(workOrder).size() > 1) + if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) + return 193; //193: Production denied: This building must be protected to gain access to warehouse + + return validation_result; + } + @Override public long getDelay(TimeUnit unit) { From 1edd4d681b8e821df378e0b326161f8616695750 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 23 Apr 2024 15:14:43 -0400 Subject: [PATCH 327/378] Update to protection check. --- src/engine/loot/WorkOrder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 815bf3d7..9f53f35c 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -22,6 +22,7 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Delayed; @@ -150,7 +151,7 @@ public class WorkOrder implements Delayed { // Forge must be protected in order to access warehouse. if (ForgeManager.calcProductionCost(workOrder).size() > 1) - if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) + if (!EnumSet.of(mbEnums.ProtectionState.PROTECTED, mbEnums.ProtectionState.CONTRACT).contains(workOrder.vendor.building.protectionState)) return 193; //193: Production denied: This building must be protected to gain access to warehouse return validation_result; From 6a17f93e419180c36266eb8bca359dae067b2afd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 24 Apr 2024 13:13:48 -0400 Subject: [PATCH 328/378] Setting containertype. --- src/engine/gameManager/ForgeManager.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index edc3c1c0..b720280b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -284,19 +284,22 @@ public enum ForgeManager implements Runnable { // Identify completed items virutalItem.flags.add(mbEnums.ItemFlags.Identified); + virutalItem.containerType = mbEnums.ItemContainerType.INVENTORY; // Persist item Item completedItem = DbManager.ItemQueries.PERSIST(virutalItem); - // Apply Item effects for Prefix and Suffix tokens + // Copy Prefix and Suffix tokens from virtual item. completedItem.prefixToken = virutalItem.prefixToken; completedItem.suffixToken = virutalItem.suffixToken; + // Add effects to these tokens. Writes to disk. + ItemManager.applyItemEffects(completedItem); - // add to the vendor inventory + // Add to the vendor inventory workOrder.vendor.charItemManager.addItemToInventory(completedItem); @@ -308,7 +311,7 @@ public enum ForgeManager implements Runnable { toRemove.add(virutalItem); } - // Remove the negativeID virtual item from all collections + // Remove the virtual item from all collections for (Item virtualItem : toRemove) { From a906e30931205943afebcfef79040f47389d9cc0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 24 Apr 2024 13:36:32 -0400 Subject: [PATCH 329/378] Setting containertype. --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 61657863..26237bf2 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -158,6 +158,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { // Persist item and add to vendor inventory + virtualItem.containerType = mbEnums.ItemContainerType.INVENTORY; Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); // Apply Item effects for Prefix and Suffix tokens From e1d43ce0d040687feec1b06ccab33d051669868b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 24 Apr 2024 13:44:22 -0400 Subject: [PATCH 330/378] Expand scope of try block. --- src/engine/gameManager/ForgeManager.java | 51 ++++++++++++------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b720280b..67b6ab1b 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -42,46 +42,47 @@ public enum ForgeManager implements Runnable { try { workOrder = forge.take(); - } catch (Exception e) { - Logger.error(e); - } - if (workOrder.total_produced >= workOrder.total_to_produce) { + if (workOrder.total_produced >= workOrder.total_to_produce) { - // Complete this workOrder. + // Complete this workOrder. - for (Item workOrderItem : workOrder.cooking) { - workOrderItem.flags.add(mbEnums.ItemFlags.Identified); - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); - DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - } + for (Item workOrderItem : workOrder.cooking) { + workOrderItem.flags.add(mbEnums.ItemFlags.Identified); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_PRODUCE, true); + DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + } - workOrder.runCompleted = true; + workOrder.runCompleted = true; - // Update workorder to disk + // Update workorder to disk - DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); - } + DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + } - if (workOrder.runCompleted) - continue; + if (workOrder.runCompleted) + continue; - // Move current cooking batch to vendor inventory + // Move current cooking batch to vendor inventory - completeWorkOrderBatch(workOrder); + completeWorkOrderBatch(workOrder); - // Create new set of in-memory only virtual items + // Create new set of in-memory only virtual items - forgeWorkOrderBatch(workOrder); + forgeWorkOrderBatch(workOrder); - // enQueue this workOrder again; back into the oven - // until all items for this workOrder are completed. + // enQueue this workOrder again; back into the oven + // until all items for this workOrder are completed. - forge.add(workOrder); + forge.add(workOrder); + + // Debugging - // Debugging + Logger.info(workOrder.toString()); - Logger.info(workOrder.toString()); + } catch (Exception e) { + Logger.error(e); + } } } From ff2e381999339f3f93c08fd080858f9c9e5b95e9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 24 Apr 2024 13:47:25 -0400 Subject: [PATCH 331/378] Update to validation order. --- src/engine/gameManager/ForgeManager.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 67b6ab1b..7e7320d1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -96,26 +96,28 @@ public enum ForgeManager implements Runnable { public static int submit(WorkOrder workOrder) { + // Must have a city to roll anything + + City city = workOrder.vendor.building.getCity(); + + if (city == null) + return 58; //58: The formula is beyond the means of this facility + + // Concurrency is rightly managed by same lock as warehouse + + city.transactionLock.writeLock().lock(); + // Make sure vendor can roll the formulae, warehouse can // afford this wordOrder and other related checks. int validation_result = WorkOrder.validate(workOrder); - // The return code is used by the submitter as a + // The return code is used by the ItemProductionMsgHandler as a // popup error message for the player. if (validation_result != 0) return validation_result; - // Concurrency is managed by same lock as warehouse - - City city = workOrder.vendor.building.getCity(); - - if (city == null) - return 58; //58: The formula is beyond the means of this facility - - city.transactionLock.writeLock().lock(); - try { // Configure this production run. From 81d60549827bbce5b53410cd2683e4034a9f735d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 07:44:19 -0400 Subject: [PATCH 332/378] Debit building first then warehouse --- src/engine/gameManager/ForgeManager.java | 29 ++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 7e7320d1..c13a21ff 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -141,7 +141,8 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); - // Deduct gold cost from building + // Debit gold and resource cost from forge + // and / or warehouse if (!debitWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility @@ -387,17 +388,37 @@ public enum ForgeManager implements Runnable { public static boolean debitWorkOrderCost(WorkOrder workOrder) { - int strongbox = workOrder.vendor.building.getStrongboxValue(); - if (workOrder.vendor.building.getCity() == null) return false; + int strongbox = workOrder.vendor.building.getStrongboxValue(); + + // Strongbox can cover total gold cost; + + if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) <= strongbox) { + + workOrder.vendor.building.setStrongboxValue(strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, 0); + + // Early exit for the forge covering gold only rolls + + if (workOrder.production_cost_total.size() == 1) + return true; + + } else { + int remainingAmount = workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - strongbox; + workOrder.vendor.building.setStrongboxValue(0); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - remainingAmount)); + } + + // There is an overflow at this point and a warehouse is required + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; if (warehouse == null) return false; - // Deduct total cost from warehouse + // Deduct total production cost from warehouse workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); From 9dd2e1d5e58189cf1adf559a6809c40450c89012 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 08:41:23 -0400 Subject: [PATCH 333/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 31 +++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c13a21ff..958685e1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -141,13 +141,12 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); - // Debit gold and resource cost from forge - // and / or warehouse + // Debit gold and resource costs if (!debitWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility - // Create in-memory items and add to collections + // Create new batch of virtual items forgeWorkOrderBatch(workOrder); @@ -193,7 +192,7 @@ public enum ForgeManager implements Runnable { int availableSlots = workOrder.vendor.getRank(); - // Subtract slots currently being used by npc workOrders + // Subtract slots currently assigned to npc workOrders for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) availableSlots = availableSlots - npcWorkOrder.cooking.size(); @@ -208,7 +207,7 @@ public enum ForgeManager implements Runnable { public static HashMap calcProductionCost(WorkOrder workOrder) { - // Calculate the production cost for a single run of this workOrder + // Calculate production cost for a single run of this workOrder HashMap production_cost = new HashMap<>(); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); @@ -235,7 +234,7 @@ public enum ForgeManager implements Runnable { public static Item forgeItem(WorkOrder workOrder) { - // Create new item from specified template + // Create new virtual item from specified template ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); Item forgedItem = new Item(workOrder.templateID); @@ -246,12 +245,12 @@ public enum ForgeManager implements Runnable { forgedItem.containerType = mbEnums.ItemContainerType.FORGE; forgedItem.ownerID = workOrder.vendor.getObjectUUID(); - // The UpgradeDate for the item is serialized for the - // vendor forge window + // item.upgradeDate is serialized (ItemProductionMsg) + // for vendor forge window completion time. forgedItem.setDateToUpgrade(workOrder.completionTime); - // Give prefix and suffix to this item if random rolled + // Assign a prefix and suffix to this item if random rolled if (workOrder.prefixToken == 0) forgedItem.prefixToken = calcRandomMod(workOrder.vendor, mbEnums.ItemModType.PREFIX, template.modTable); @@ -263,7 +262,7 @@ public enum ForgeManager implements Runnable { else forgedItem.suffixToken = workOrder.suffixToken; - // Forged random rolled items are unidentified until completed + // Random rolled items are unidentified until completed if (workOrder.prefixToken == 0 && workOrder.suffixToken == 0) forgedItem.flags.remove(mbEnums.ItemFlags.Identified); @@ -315,15 +314,17 @@ public enum ForgeManager implements Runnable { toRemove.add(virutalItem); } - // Remove the virtual item from all collections + for (Item virtualItem : toRemove) { - // Remove the virtual items from the forge window + // Remove virtual items from the forge window ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, virtualItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + // Remove virtual item from all collections + workOrder.cooking.remove(virtualItem); itemWorkOrderLookup.remove(virtualItem); DbManager.removeFromCache(virtualItem); @@ -332,7 +333,7 @@ public enum ForgeManager implements Runnable { public static void forgeWorkOrderBatch(WorkOrder workOrder) { - // New completion time for this batch + // Completion time for this batch is in the future workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; @@ -347,7 +348,7 @@ public enum ForgeManager implements Runnable { workOrder.total_produced = workOrder.total_produced + 1; } - // Save updated status to disk + // Save updated state to disk DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); @@ -355,6 +356,8 @@ public enum ForgeManager implements Runnable { public static int calcRandomMod(NPC vendor, mbEnums.ItemModType itemModType, int modTable) { + // Random prefix or suffix token based on item.template.modtable + int modifier = 0; ModTypeTableEntry modTypeTableEntry = null; ModTableEntry modTableEntry = null; From 0fe04041f6da5890262f5502179846d7bfe6974e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 08:42:20 -0400 Subject: [PATCH 334/378] Workorder method moved to workorder --- src/engine/gameManager/ForgeManager.java | 46 +++--------------------- src/engine/loot/WorkOrder.java | 41 +++++++++++++++++++++ 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 958685e1..cc1a5014 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -14,7 +14,10 @@ import engine.loot.WorkOrder; import engine.mbEnums; import engine.net.DispatchMessage; import engine.net.client.msg.ItemProductionMsg; -import engine.objects.*; +import engine.objects.City; +import engine.objects.Item; +import engine.objects.ItemTemplate; +import engine.objects.NPC; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; @@ -143,7 +146,7 @@ public enum ForgeManager implements Runnable { // Debit gold and resource costs - if (!debitWorkOrderCost(workOrder)) + if (!WorkOrder.debitWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility // Create new batch of virtual items @@ -389,43 +392,4 @@ public enum ForgeManager implements Runnable { return modifier; } - public static boolean debitWorkOrderCost(WorkOrder workOrder) { - - if (workOrder.vendor.building.getCity() == null) - return false; - - int strongbox = workOrder.vendor.building.getStrongboxValue(); - - // Strongbox can cover total gold cost; - - if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) <= strongbox) { - - workOrder.vendor.building.setStrongboxValue(strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)); - workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, 0); - - // Early exit for the forge covering gold only rolls - - if (workOrder.production_cost_total.size() == 1) - return true; - - } else { - int remainingAmount = workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - strongbox; - workOrder.vendor.building.setStrongboxValue(0); - workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - remainingAmount)); - } - - // There is an overflow at this point and a warehouse is required - - Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; - - if (warehouse == null) - return false; - - // Deduct total production cost from warehouse - - workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); - DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); - - return true; - } } diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 9f53f35c..e2d4feb2 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -8,6 +8,7 @@ package engine.loot; +import engine.gameManager.DbManager; import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.objects.Item; @@ -157,6 +158,46 @@ public class WorkOrder implements Delayed { return validation_result; } + public static boolean debitWorkOrderCost(WorkOrder workOrder) { + + if (workOrder.vendor.building.getCity() == null) + return false; + + int strongbox = workOrder.vendor.building.getStrongboxValue(); + + // Strongbox can cover total gold cost; + + if (workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) <= strongbox) { + + workOrder.vendor.building.setStrongboxValue(strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, 0); + + // Early exit for the forge covering gold only rolls + + if (workOrder.production_cost_total.size() == 1) + return true; + + } else { + int remainingAmount = workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - strongbox; + workOrder.vendor.building.setStrongboxValue(0); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - remainingAmount)); + } + + // There is an overflow at this point and a warehouse is required + + Warehouse warehouse = workOrder.vendor.building.getCity().warehouse; + + if (warehouse == null) + return false; + + // Deduct total production cost from warehouse + + workOrder.production_cost_total.forEach((key, value) -> warehouse.resources.put(key, warehouse.resources.get(key) - value)); + DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); + + return true; + } + @Override public long getDelay(TimeUnit unit) { From adaa521bf55e8f31a94c292d9fb8877de7f11a20 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 08:49:13 -0400 Subject: [PATCH 335/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index cc1a5014..8be55c54 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -28,6 +28,15 @@ import java.util.concurrent.atomic.AtomicInteger; public enum ForgeManager implements Runnable { + // MB Dev notes: + // Class handles all forge rolling requests for the game. + // + // WorkOrders may be submitted from any thread: usually (ItemProductionMsgHandler) + // as concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock) + // WorkOrders are persisted then reconstituted at bootstrap from table dyn.workorders + // + // p.s. this class replaces garbage that looked like it was written by a crack head. + FORGE_MANAGER; public static final BlockingQueue forge = new DelayQueue<>(); @@ -39,7 +48,7 @@ public enum ForgeManager implements Runnable { public void run() { - WorkOrder workOrder = null; + WorkOrder workOrder; while (true) { @@ -363,7 +372,7 @@ public enum ForgeManager implements Runnable { int modifier = 0; ModTypeTableEntry modTypeTableEntry = null; - ModTableEntry modTableEntry = null; + ModTableEntry modTableEntry; int rollForModifier; switch (itemModType) { From a9dcac0ad7f7865b9e0d5b818bc7da0889ceadba Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 08:49:59 -0400 Subject: [PATCH 336/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 8be55c54..cfbca6e4 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger; public enum ForgeManager implements Runnable { // MB Dev notes: - // Class handles all forge rolling requests for the game. + // Class handles all forge rolling mechanics for the game. // // WorkOrders may be submitted from any thread: usually (ItemProductionMsgHandler) // as concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock) From 4d0018b176cf18fb9faa10c74f76977af7349bf4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 08:51:33 -0400 Subject: [PATCH 337/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index cfbca6e4..ed35bf3d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -67,7 +67,7 @@ public enum ForgeManager implements Runnable { workOrder.runCompleted = true; - // Update workorder to disk + // Update workOrder on disk DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); } @@ -88,9 +88,7 @@ public enum ForgeManager implements Runnable { forge.add(workOrder); - // Debugging - - Logger.info(workOrder.toString()); + // Debugging: Logger.info(workOrder.toString()); } catch (Exception e) { Logger.error(e); @@ -326,8 +324,6 @@ public enum ForgeManager implements Runnable { toRemove.add(virutalItem); } - - for (Item virtualItem : toRemove) { // Remove virtual items from the forge window From a3a30f3f8a898f2a5547826ff993d67217337b04 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:02:52 -0400 Subject: [PATCH 338/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index ed35bf3d..c957ef1d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -35,7 +35,7 @@ public enum ForgeManager implements Runnable { // as concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock) // WorkOrders are persisted then reconstituted at bootstrap from table dyn.workorders // - // p.s. this class replaces garbage that looked like it was written by a crack head. + // p.s. replaces garbage code that looked like it was written by a crack head with face boils. FORGE_MANAGER; From 9850b54981a1baa28229e09e9808330fc53e3a16 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:22:50 -0400 Subject: [PATCH 339/378] Comment cleanup --- src/engine/db/handlers/dbWarehouseHandler.java | 2 +- src/engine/gameManager/ForgeManager.java | 11 ++++++----- src/engine/loot/WorkOrder.java | 14 +++++++++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index c58cb10e..31fb4a10 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -210,7 +210,7 @@ public class dbWarehouseHandler extends dbHandlerBase { // Submit the new workOrders to the ForgeManager for (WorkOrder workOrder : submitList) { - workOrder.workOrderID = ForgeManager.wordOrderCounter.incrementAndGet(); + workOrder.workOrderID = ForgeManager.workOrderCounter.incrementAndGet(); ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); // If workorder is not yet complete process it diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index c957ef1d..f91aec6f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -40,7 +40,7 @@ public enum ForgeManager implements Runnable { FORGE_MANAGER; public static final BlockingQueue forge = new DelayQueue<>(); - public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); + public static final AtomicInteger workOrderCounter = new AtomicInteger(0); public static final ConcurrentHashMap> vendorWorkOrderLookup = new ConcurrentHashMap<>(); public static final ConcurrentHashMap itemWorkOrderLookup = new ConcurrentHashMap<>(); @@ -131,7 +131,7 @@ public enum ForgeManager implements Runnable { try { // Configure this production run. - workOrder.workOrderID = wordOrderCounter.incrementAndGet(); + workOrder.workOrderID = workOrderCounter.incrementAndGet(); workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; workOrder.slots_used = calcAvailableSlots(workOrder); @@ -151,16 +151,17 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); - // Debit gold and resource costs + // Withdraw gold and resource costs - if (!WorkOrder.debitWorkOrderCost(workOrder)) + if (!WorkOrder.withdrawWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility // Create new batch of virtual items forgeWorkOrderBatch(workOrder); - // Submit workOrder for next completion cycle + // Enqueue workOrder for next completion cycle + // and assign it to the vendor vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index e2d4feb2..d1e534a9 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -31,6 +31,15 @@ import java.util.concurrent.TimeUnit; public class WorkOrder implements Delayed { + // MB Dev notes: + // Class defines a Forge rolling request made through a + // vendor and then passed to the ForgeManager singleton + // for completion. + // + // A workOrder once created will last until all items are + // either completed or junked. They are persisted in the + // table dyn_workorders. + public int workOrderID; public NPC vendor; public int slots_used; @@ -133,6 +142,9 @@ public class WorkOrder implements Delayed { public static int validate(WorkOrder workOrder) { + // Validate that a workOrder can be completed by both + // the vendor and the forge. + int validation_result = 0; ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); @@ -158,7 +170,7 @@ public class WorkOrder implements Delayed { return validation_result; } - public static boolean debitWorkOrderCost(WorkOrder workOrder) { + public static boolean withdrawWorkOrderCost(WorkOrder workOrder) { if (workOrder.vendor.building.getCity() == null) return false; From e80cdc192ded633266d97cbd739364b25c5996e6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:33:47 -0400 Subject: [PATCH 340/378] Update to withdraw calc --- src/engine/loot/WorkOrder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index d1e534a9..830791f1 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -192,7 +192,7 @@ public class WorkOrder implements Delayed { } else { int remainingAmount = workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - strongbox; workOrder.vendor.building.setStrongboxValue(0); - workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - remainingAmount)); + workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - remainingAmount); } // There is an overflow at this point and a warehouse is required From dbf42bfbefe9224d2d32fa665f6f13348d502238 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:39:03 -0400 Subject: [PATCH 341/378] json fix in constructor --- src/engine/loot/WorkOrder.java | 66 ++++++++++++++++------------------ 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 830791f1..19e8ce8d 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -87,7 +87,7 @@ public class WorkOrder implements Delayed { this.production_cost.put(resourceType, value); } - JSONObject productionTotalCostMap = jsonWorkOrder.getJSONObject("production_cost"); + JSONObject productionTotalCostMap = jsonWorkOrder.getJSONObject("production_cost_total"); for (String key : productionTotalCostMap.keySet()) { mbEnums.ResourceType resourceType = mbEnums.ResourceType.valueOf(key); @@ -109,37 +109,6 @@ public class WorkOrder implements Delayed { } } - public static JSONObject toJson(WorkOrder workOrder) { - - JSONObject jsonWorkOrder = new JSONObject(); - - jsonWorkOrder.put("workOrderID", workOrder.workOrderID); - jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); - jsonWorkOrder.put("slots_used", workOrder.slots_used); - jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); - jsonWorkOrder.put("total_produced", workOrder.total_produced); - jsonWorkOrder.put("multiple_slot_request", workOrder.multiple_slot_request); - jsonWorkOrder.put("production_cost", workOrder.production_cost); - jsonWorkOrder.put("production_cost_total", workOrder.production_cost_total); - jsonWorkOrder.put("templateID", workOrder.templateID); - jsonWorkOrder.put("item_name_override", workOrder.item_name_override); - jsonWorkOrder.put("prefixToken", workOrder.prefixToken); - jsonWorkOrder.put("suffixToken", workOrder.suffixToken); - jsonWorkOrder.put("rollingDuration", workOrder.rollingDuration); - jsonWorkOrder.put("completionTime", workOrder.completionTime); - jsonWorkOrder.put("runCompleted", workOrder.runCompleted); - - ArrayList cookingTokens = new ArrayList<>(); - - for (Item item : workOrder.cooking) - cookingTokens.add(new Integer[]{item.prefixToken, item.suffixToken}); - - jsonWorkOrder.put("cookingTokens", cookingTokens); - - - return jsonWorkOrder; - } - public static int validate(WorkOrder workOrder) { // Validate that a workOrder can be completed by both @@ -188,7 +157,6 @@ public class WorkOrder implements Delayed { if (workOrder.production_cost_total.size() == 1) return true; - } else { int remainingAmount = workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD) - strongbox; workOrder.vendor.building.setStrongboxValue(0); @@ -212,10 +180,8 @@ public class WorkOrder implements Delayed { @Override public long getDelay(TimeUnit unit) { - long timeRemaining = completionTime - System.currentTimeMillis(); return unit.convert(timeRemaining, TimeUnit.MILLISECONDS); - } @Override @@ -223,6 +189,36 @@ public class WorkOrder implements Delayed { return Long.compare(this.completionTime, ((WorkOrder) o).completionTime); } + public static JSONObject toJson(WorkOrder workOrder) { + + JSONObject jsonWorkOrder = new JSONObject(); + + jsonWorkOrder.put("workOrderID", workOrder.workOrderID); + jsonWorkOrder.put("vendor", workOrder.vendor.getObjectUUID()); + jsonWorkOrder.put("slots_used", workOrder.slots_used); + jsonWorkOrder.put("total_to_produce", workOrder.total_to_produce); + jsonWorkOrder.put("total_produced", workOrder.total_produced); + jsonWorkOrder.put("multiple_slot_request", workOrder.multiple_slot_request); + jsonWorkOrder.put("production_cost", workOrder.production_cost); + jsonWorkOrder.put("production_cost_total", workOrder.production_cost_total); + jsonWorkOrder.put("templateID", workOrder.templateID); + jsonWorkOrder.put("item_name_override", workOrder.item_name_override); + jsonWorkOrder.put("prefixToken", workOrder.prefixToken); + jsonWorkOrder.put("suffixToken", workOrder.suffixToken); + jsonWorkOrder.put("rollingDuration", workOrder.rollingDuration); + jsonWorkOrder.put("completionTime", workOrder.completionTime); + jsonWorkOrder.put("runCompleted", workOrder.runCompleted); + + ArrayList cookingTokens = new ArrayList<>(); + + for (Item item : workOrder.cooking) + cookingTokens.add(new Integer[]{item.prefixToken, item.suffixToken}); + + jsonWorkOrder.put("cookingTokens", cookingTokens); + + return jsonWorkOrder; + } + public String toString() { LocalDateTime localDateTime = Instant.ofEpochMilli(this.completionTime) From 2464deb3f3e7811d199437b5b2fa09f953b979fe Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:41:02 -0400 Subject: [PATCH 342/378] comment cleanup --- src/engine/loot/WorkOrder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 19e8ce8d..955a4e65 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -153,7 +153,7 @@ public class WorkOrder implements Delayed { workOrder.vendor.building.setStrongboxValue(strongbox - workOrder.production_cost_total.get(mbEnums.ResourceType.GOLD)); workOrder.production_cost_total.put(mbEnums.ResourceType.GOLD, 0); - // Early exit for the forge covering gold only rolls + // Early exit for Strongbox covering gold only rolls if (workOrder.production_cost_total.size() == 1) return true; From 31037c93243269e1f6bf685bd21a82a40d18f543 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:47:58 -0400 Subject: [PATCH 343/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index f91aec6f..6d8ce8fe 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -52,6 +52,10 @@ public enum ForgeManager implements Runnable { while (true) { + // ForgeManager.forge is a delayQueue (priority queue using an epoc sort) + // workOrders are popped and processed when the completion time has passed. + // workOrders can be enqueued from any thread. + try { workOrder = forge.take(); From c0b93ff8095ab4f54ca3bbf705169a36b60f5aa5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 09:51:34 -0400 Subject: [PATCH 344/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6d8ce8fe..41328ca2 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -54,7 +54,9 @@ public enum ForgeManager implements Runnable { // ForgeManager.forge is a delayQueue (priority queue using an epoc sort) // workOrders are popped and processed when the completion time has passed. - // workOrders can be enqueued from any thread. + // + // workOrders can be enqueued from any thread such as from a db handler + // however the interface is .submit(workOrder). try { workOrder = forge.take(); From 3a514dc771cb3a807f19206ef013b714f470c9d0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 10:03:37 -0400 Subject: [PATCH 345/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 12 ++++++------ src/engine/loot/WorkOrder.java | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 41328ca2..711e3468 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -128,8 +128,8 @@ public enum ForgeManager implements Runnable { int validation_result = WorkOrder.validate(workOrder); - // The return code is used by the ItemProductionMsgHandler as a - // popup error message for the player. + // The return code is used by the caller (ItemProductionMsgHandler) + // for display of a popup error message to the player. if (validation_result != 0) return validation_result; @@ -149,7 +149,7 @@ public enum ForgeManager implements Runnable { if (!workOrder.multiple_slot_request && workOrder.total_to_produce == 0) workOrder.total_to_produce = 1; - // Set total cost for this production run + // Set total cost for production run workOrder.total_to_produce *= workOrder.slots_used; @@ -157,7 +157,7 @@ public enum ForgeManager implements Runnable { workOrder.production_cost_total.putAll(workOrder.production_cost); workOrder.production_cost_total.forEach((key, value) -> workOrder.production_cost_total.put(key, value * workOrder.total_to_produce)); - // Withdraw gold and resource costs + // Withdraw gold and resource costs. Availability has previously been validated. if (!WorkOrder.withdrawWorkOrderCost(workOrder)) return 58; //58: The formula is beyond the means of this facility @@ -166,8 +166,8 @@ public enum ForgeManager implements Runnable { forgeWorkOrderBatch(workOrder); - // Enqueue workOrder for next completion cycle - // and assign it to the vendor + // Enqueue workOrder in the .forge and then + // add the workOrder to it's vendor vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 955a4e65..9b12f22e 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -56,6 +56,9 @@ public class WorkOrder implements Delayed { public long completionTime; public boolean runCompleted = false; public boolean runCanceled = false; + + // This collection is serialized to the vendor rolling window in ManageNPCMsg. + public ConcurrentHashMap.KeySetView cooking = ConcurrentHashMap.newKeySet(); public WorkOrder() { @@ -64,6 +67,9 @@ public class WorkOrder implements Delayed { public WorkOrder(JSONObject jsonWorkOrder) { + // This constructor is used to load workOrders from disk + // during bootstrap. (dyn_workorders) + this.workOrderID = jsonWorkOrder.getInt("workOrderID"); this.vendor = NPC.getNPC(jsonWorkOrder.getInt("vendor")); this.slots_used = jsonWorkOrder.getInt("slots_used"); @@ -191,6 +197,8 @@ public class WorkOrder implements Delayed { public static JSONObject toJson(WorkOrder workOrder) { + // Workorders are persisted in JSON format. + JSONObject jsonWorkOrder = new JSONObject(); jsonWorkOrder.put("workOrderID", workOrder.workOrderID); From 2e5f8701df8560b473185b48d9a73b3cdf9206a1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 10:04:58 -0400 Subject: [PATCH 346/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 711e3468..675e429d 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -172,7 +172,7 @@ public enum ForgeManager implements Runnable { vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); forge.add(workOrder); - // Save workOrder to disk + // PERSIST workOrder (dyn_workorders) DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); From 78480ca3dd3fe4404d4c49efae976832999f573b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 10:06:55 -0400 Subject: [PATCH 347/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 675e429d..61f2e353 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -52,8 +52,8 @@ public enum ForgeManager implements Runnable { while (true) { - // ForgeManager.forge is a delayQueue (priority queue using an epoc sort) - // workOrders are popped and processed when the completion time has passed. + // .forge is a delayQueue (blocking priority queue using an epoc sort) + // workOrders are popped and processed when their completion time has passed. // // workOrders can be enqueued from any thread such as from a db handler // however the interface is .submit(workOrder). From 320f06e1db7e4bfe3d27b18d96c8825e322f0de5 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 10:08:27 -0400 Subject: [PATCH 348/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 61f2e353..95de5453 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -56,7 +56,7 @@ public enum ForgeManager implements Runnable { // workOrders are popped and processed when their completion time has passed. // // workOrders can be enqueued from any thread such as from a db handler - // however the interface is .submit(workOrder). + // however the game's interface should always be .submit(workOrder). try { workOrder = forge.take(); From f03edf5c5d6aa2387cb056a7a01c82b3e1f90717 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 19:57:56 -0400 Subject: [PATCH 349/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 95de5453..14468084 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -31,9 +31,9 @@ public enum ForgeManager implements Runnable { // MB Dev notes: // Class handles all forge rolling mechanics for the game. // - // WorkOrders may be submitted from any thread: usually (ItemProductionMsgHandler) - // as concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock) - // WorkOrders are persisted then reconstituted at bootstrap from table dyn.workorders + // WorkOrders may be submitted from any thread: usually (ItemProductionMsgHandler). + // Concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock). + // WorkOrders are persisted then reconstituted at bootstrap from table dyn.workorders. // // p.s. replaces garbage code that looked like it was written by a crack head with face boils. @@ -53,10 +53,7 @@ public enum ForgeManager implements Runnable { while (true) { // .forge is a delayQueue (blocking priority queue using an epoc sort) - // workOrders are popped and processed when their completion time has passed. - // - // workOrders can be enqueued from any thread such as from a db handler - // however the game's interface should always be .submit(workOrder). + // workOrders are popped and processed when their completion time has passed.. try { workOrder = forge.take(); @@ -209,7 +206,7 @@ public enum ForgeManager implements Runnable { int availableSlots = workOrder.vendor.getRank(); - // Subtract slots currently assigned to npc workOrders + // Subtract the slots currently assigned to other workOrders for this vendor for (WorkOrder npcWorkOrder : ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor)) availableSlots = availableSlots - npcWorkOrder.cooking.size(); @@ -224,7 +221,7 @@ public enum ForgeManager implements Runnable { public static HashMap calcProductionCost(WorkOrder workOrder) { - // Calculate production cost for a single run of this workOrder + // Calculate production cost for a single run of the workOrder HashMap production_cost = new HashMap<>(); ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); @@ -363,7 +360,7 @@ public enum ForgeManager implements Runnable { workOrder.total_produced = workOrder.total_produced + 1; } - // Save updated state to disk + // Write updated workOrder to disk DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); From 17011de2014dd82e53fc67b69ecd941ad842d449 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 19:59:15 -0400 Subject: [PATCH 350/378] comment cleanup --- src/engine/gameManager/ForgeManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 14468084..6c811d34 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -53,7 +53,7 @@ public enum ForgeManager implements Runnable { while (true) { // .forge is a delayQueue (blocking priority queue using an epoc sort) - // workOrders are popped and processed when their completion time has passed.. + // workOrders are popped and processed when their completion time has passed. try { workOrder = forge.take(); From 3b1db51a5ef610b224a5d6864d16583d35a890dd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 20:22:29 -0400 Subject: [PATCH 351/378] comment cleanup --- src/engine/gameManager/ConfigManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index a3a7a258..25284548 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -8,9 +8,10 @@ package engine.gameManager; -/* This enumeration implements Magicbane's configuration data which - is loaded from environment variables. - */ +// Magicbane configuration is loaded from environment variables +// +// On boot the game first looks in mb.conf for the file magicbane.conf. +// If not found, a default is loaded from /mb.data to enable bootstrap. import engine.mbEnums; import engine.server.login.LoginServer; @@ -105,11 +106,11 @@ public enum ConfigManager { // and determine the server type at runtime. public static final String DEFAULT_DATA_DIR = "mb.data/"; - public static Map configMap = new HashMap(System.getenv()); + public static final Map configMap = new HashMap(System.getenv()); public static mbEnums.ServerType serverType = mbEnums.ServerType.NONE; public static WorldServer worldServer; public static LoginServer loginServer; - public static Map regex = new HashMap<>(); + public static final Map regex = new HashMap<>(); public static String currentRepoBranch = ""; @@ -124,7 +125,7 @@ public enum ConfigManager { Logger.info(configSetting.name() + ":" + configSetting.getValue()); else { Logger.error("Missing Config: " + configSetting.name()); - Logger.error("This codebase requires >= MagicBox v1.5.1"); + Logger.error("This codebase requires >= MagicBox v1.5.2"); Logger.error("docker pull magicbane/magicbox:latest"); return false; } From b3129045488638231ec6269605754d2e38c4ca52 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 20:22:55 -0400 Subject: [PATCH 352/378] comment cleanup --- src/engine/gameManager/ConfigManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index 25284548..f125024f 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -10,7 +10,7 @@ package engine.gameManager; // Magicbane configuration is loaded from environment variables // -// On boot the game first looks in mb.conf for the file magicbane.conf. +// On boot the game first looks in /mb.conf for the file magicbane.conf. // If not found, a default is loaded from /mb.data to enable bootstrap. import engine.mbEnums; From ef432111033f3cc7495572c070b1ad13f8d60681 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 20:24:15 -0400 Subject: [PATCH 353/378] comment cleanup --- src/engine/gameManager/ConfigManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index f125024f..16f86774 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -11,7 +11,9 @@ package engine.gameManager; // Magicbane configuration is loaded from environment variables // // On boot the game first looks in /mb.conf for the file magicbane.conf. -// If not found, a default is loaded from /mb.data to enable bootstrap. +// +// If not found, a default config is loaded from /mb.data to enable bootstrap. +// This version should never be modified. import engine.mbEnums; import engine.server.login.LoginServer; From 7b6f5f752bccb8e4c6a80ac2b668994778276354 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 20:25:16 -0400 Subject: [PATCH 354/378] comment cleanup --- src/engine/gameManager/ConfigManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index 16f86774..bb51d7c0 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -8,13 +8,6 @@ package engine.gameManager; -// Magicbane configuration is loaded from environment variables -// -// On boot the game first looks in /mb.conf for the file magicbane.conf. -// -// If not found, a default config is loaded from /mb.data to enable bootstrap. -// This version should never be modified. - import engine.mbEnums; import engine.server.login.LoginServer; import engine.server.world.WorldServer; @@ -30,6 +23,13 @@ import java.util.regex.Pattern; public enum ConfigManager { +// Magicbane configuration is loaded from environment variables +// +// On boot the game first looks in /mb.conf for the file magicbane.conf. +// +// If not found, a default config is loaded from /mb.data to enable bootstrap. +// This version should never be modified. + MB_BIND_ADDR, MB_EXTERNAL_ADDR, From 7d6407fbf535d0104600488c087777352c4d7e9d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 25 Apr 2024 20:26:13 -0400 Subject: [PATCH 355/378] comment cleanup --- src/engine/gameManager/ConfigManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index bb51d7c0..e49b0f2c 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -23,12 +23,13 @@ import java.util.regex.Pattern; public enum ConfigManager { -// Magicbane configuration is loaded from environment variables -// -// On boot the game first looks in /mb.conf for the file magicbane.conf. -// -// If not found, a default config is loaded from /mb.data to enable bootstrap. -// This version should never be modified. + // MB Dev notes: + // Magicbane configuration is loaded from environment variables + // + // On boot the game first looks in /mb.conf for the file magicbane.conf. + // + // If not found, a default config is loaded from /mb.data to enable bootstrap. + // This version should never be modified. MB_BIND_ADDR, MB_EXTERNAL_ADDR, From 67bc13dcde7698d911d92f15007c99540e2b6802 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 08:09:07 -0400 Subject: [PATCH 356/378] MB Dev Notes added to critical classes. --- src/engine/InterestManagement/RealmMap.java | 17 ++-- src/engine/InterestManagement/Terrain.java | 8 ++ src/engine/gameManager/SimulationManager.java | 21 +++-- src/engine/loot/WorkOrder.java | 2 +- src/engine/net/MessageDispatcher.java | 85 +++++++++---------- src/engine/net/Protocol.java | 21 +++-- 6 files changed, 89 insertions(+), 65 deletions(-) diff --git a/src/engine/InterestManagement/RealmMap.java b/src/engine/InterestManagement/RealmMap.java index 89d7b4ad..57b3c71c 100644 --- a/src/engine/InterestManagement/RealmMap.java +++ b/src/engine/InterestManagement/RealmMap.java @@ -8,10 +8,6 @@ package engine.InterestManagement; -/* This class is the main interface for Magicbane's - * Interest management facilities. - */ - import engine.math.Vector3fImmutable; import engine.mbEnums; import engine.net.Dispatch; @@ -31,10 +27,17 @@ import static engine.objects.Realm.getRealm; public enum RealmMap { - REALM_MAP; + // MB Dev Notes: + // This class loads and caches realm maps used by each + // map set for its realm overlay. The RealmMap loaded is + // controlled by config entry MB_WORLD_REALMMAP + // + // Unlike a Heightmap this is a just color lookup; identical to + // the old image maps used in 90s web technology. + // + // Realm Map images are stored on disk in /mb.data/realmmaps/ - // Spatial hashmap. Used for determining which Realm - // a player is currently located within. + REALM_MAP; private static final HashMap _rgbToIDMap = new HashMap<>(); public static int[][] _realmImageMap; diff --git a/src/engine/InterestManagement/Terrain.java b/src/engine/InterestManagement/Terrain.java index abd0e638..c52f84a7 100644 --- a/src/engine/InterestManagement/Terrain.java +++ b/src/engine/InterestManagement/Terrain.java @@ -18,6 +18,14 @@ import java.util.HashMap; import static java.lang.Math.PI; + +// MB Dev Notes: +// The Terrain class handles lookups into the Heightmap data. +// It supports all current maps along with the differences in +// their parenting configuration. +// +// Heightmap images are stored on disk in /mb.data/heightmaps/ + public class Terrain { public static final HashMap _heightmap_pixel_cache = new HashMap<>(); public short[][] terrain_pixel_data; diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index 1ac64199..cbe9f13d 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -24,10 +24,16 @@ import java.time.Duration; import java.time.Instant; import java.util.Collection; -/* - * This class contains all methods necessary to drive periodic - * updates of the game simulation from the main _exec loop. - */ +// MB Dev Notes: +// +// Class models timers that drive Magicbane simulation ticks used +// for movement updates, triggers and more. Eventually we hope to +// refactor to more of a traditional simulation appropriate for a +// mmo with a transform class and other bells and whistles. +// +// Do as little as possible in here. For any tick you do not want +// deltaTime to approach 1.0f. + public enum SimulationManager { SERVERHEARTBEAT; @@ -35,15 +41,14 @@ public enum SimulationManager { private static final long CITY_PULSE = 2000; private static final long RUNEGATE_PULSE = 3000; private static final long UPDATE_PULSE = 1000; - private static final long FlIGHT_PULSE = 100; + private static final long FLIGHT_PULSE = 100; public static Duration executionTime = Duration.ofNanos(1); public static Duration executionMax = Duration.ofNanos(1); - private static SimulationManager instance = null; private long _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; private long _runegatePulseTime = System.currentTimeMillis() + RUNEGATE_PULSE; private long _updatePulseTime = System.currentTimeMillis() + UPDATE_PULSE; - private long _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE; + private long _flightPulseTime = System.currentTimeMillis() + FLIGHT_PULSE; private SimulationManager() { @@ -181,7 +186,7 @@ public enum SimulationManager { player.updateFlight(); } - _flightPulseTime = System.currentTimeMillis() + FlIGHT_PULSE; + _flightPulseTime = System.currentTimeMillis() + FLIGHT_PULSE; } private void pulseCities() { diff --git a/src/engine/loot/WorkOrder.java b/src/engine/loot/WorkOrder.java index 9b12f22e..ebd2fc83 100644 --- a/src/engine/loot/WorkOrder.java +++ b/src/engine/loot/WorkOrder.java @@ -33,7 +33,7 @@ public class WorkOrder implements Delayed { // MB Dev notes: // Class defines a Forge rolling request made through a - // vendor and then passed to the ForgeManager singleton + // vendor; then passed to the ForgeManager singleton // for completion. // // A workOrder once created will last until all items are diff --git a/src/engine/net/MessageDispatcher.java b/src/engine/net/MessageDispatcher.java index 3466b161..6d774ae5 100644 --- a/src/engine/net/MessageDispatcher.java +++ b/src/engine/net/MessageDispatcher.java @@ -17,29 +17,31 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.atomic.LongAdder; import java.util.regex.Pattern; -/** - * Thread blocks until MagicBane dispatch messages are - * enqueued then processes them in FIFO order. The collection - * is thread safe. - *

- * Any large messages not time sensitive such as load object - * sent to more than a single individual should be spawned - * individually on a DispatchMessageThread. - */ +// MB Dev Notes: +// All outgoing Protocol messages to the player are managed through the MessageDispatcher.class. +// All incoming Protocol messages from the player are managed by the Protocol.class. +// +// A DispatchMessage is configured then wrapped in a Dispatch for a distribution list. +// A Dispatch can be submitted to the Dispatcher from any thread. +// +// Dispatches are interleaved between channels. This is to ensure +// a combat or movement message is not delayed by spam clicking a +// larger message. Choose your channel wisely. public class MessageDispatcher implements Runnable { // Instance variables - @SuppressWarnings("unchecked") // Cannot have arrays of generics in java. private static final ConcurrentLinkedQueue[] _messageQueue = new ConcurrentLinkedQueue[DispatchChannel.values().length]; private static final LinkedBlockingQueue _blockingQueue = new LinkedBlockingQueue<>(); // Class variables + public static volatile long[] messageCount = new long[DispatchChannel.values().length]; public static LongAdder[] dispatchCount = new LongAdder[DispatchChannel.values().length]; // Performance metrics + public static volatile long[] maxRecipients = new long[DispatchChannel.values().length]; public static LongAdder itemPoolSize = new LongAdder(); private final Pattern filterPattern; // Unused, but just in case @@ -61,6 +63,35 @@ public class MessageDispatcher implements Runnable { } + @Override + public void run() { + + boolean shouldBlock; + + while (true) { + try { + + shouldBlock = true; + + for (DispatchChannel dispatchChannel : DispatchChannel.values()) { + + this.messageDispatch = _messageQueue[dispatchChannel.getChannelID()].poll(); + + if (this.messageDispatch != null) { + DispatchMessage.serializeDispatch(this.messageDispatch); + shouldBlock = false; + } + } + + if (shouldBlock == true) + shouldBlock = _blockingQueue.take(); + } catch (Exception e) { + Logger.error(e); + } + + } + } + public static void send(Dispatch messageDispatch, DispatchChannel dispatchChannel) { // Don't queue up empty dispatches! @@ -74,12 +105,11 @@ public class MessageDispatcher implements Runnable { // Update performance metrics messageCount[dispatchChannel.getChannelID()]++; - } public static String getNetstatString() { - String outString = null; + String outString; String newLine = System.getProperty("line.separator"); outString = "[LUA_NETSTA()]" + newLine; outString += "poolSize: " + itemPoolSize.longValue() + '\n'; @@ -94,37 +124,6 @@ public class MessageDispatcher implements Runnable { return outString; } - @Override - public void run() { - - boolean shouldBlock; - - while (true) { - try { - - shouldBlock = true; - - for (DispatchChannel dispatchChannel : DispatchChannel.values()) { - - this.messageDispatch = _messageQueue[dispatchChannel.getChannelID()].poll(); - - if (this.messageDispatch != null) { - DispatchMessage.serializeDispatch(this.messageDispatch); - shouldBlock = false; - } - - } - - if (shouldBlock == true) - shouldBlock = _blockingQueue.take(); - - } catch (Exception e) { - Logger.error(e); - } - - } - } - // For Debugging: //Logger.error("MessageDispatcher", messageDispatch.msg.getOpcodeAsString() + " sent to " + messageDispatch.playerList.size() + " players"); } diff --git a/src/engine/net/Protocol.java b/src/engine/net/Protocol.java index ec9ef72e..a6e94ddd 100644 --- a/src/engine/net/Protocol.java +++ b/src/engine/net/Protocol.java @@ -1,8 +1,12 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com package engine.net; -/* This class defines Magicbane's application network protocol. ---> Name / Opcode / Message / Handler - */ import engine.net.client.handlers.*; import engine.net.client.msg.*; @@ -16,6 +20,13 @@ import org.pmw.tinylog.Logger; import java.lang.reflect.Constructor; import java.util.HashMap; +// MB Dev Notes: +// This class defines the application network protocol used by SB. +// --> Name / Opcode / Message / Handler +// +// All incoming Protocol messages from the player are managed by the Protocol.class. +// All outgoing Protocol messages to the player are managed through the MessageDispatcher.class. + public enum Protocol { NONE(0x0, null, null), @@ -286,9 +297,7 @@ public enum Protocol { public static boolean handleClientMsg(ClientNetMsg msg) { - // Main message handler for Magicbane. All messages - // incoming from the client are executed here for - // both the login and world servers. + // Process incoming Protocol message from client. if (msg == null) return false; From 2a9463be4e0618bd9c3fb6077591f3a6356c8bbf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 08:14:16 -0400 Subject: [PATCH 357/378] camelCase --- src/engine/mobileAI/MobAI.java | 114 +++++++++---------- src/engine/mobileAI/Threads/MobAIThread.java | 2 +- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 27e9173a..2f62fdfa 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -38,7 +38,7 @@ import static engine.math.FastMath.sqr; public class MobAI { - private static void AttackTarget(Mob mob, AbstractWorldObject target) { + private static void attackTarget(Mob mob, AbstractWorldObject target) { try { @@ -58,7 +58,7 @@ public class MobAI { if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter && canCast(mob)) { - if (MobCast(mob)) { + if (mobCast(mob)) { mob.updateLocation(); return; } @@ -71,15 +71,15 @@ public class MobAI { switch (target.getObjectType()) { case PlayerCharacter: PlayerCharacter targetPlayer = (PlayerCharacter) target; - AttackPlayer(mob, targetPlayer); + attackPlayer(mob, targetPlayer); break; case Building: Building targetBuilding = (Building) target; - AttackBuilding(mob, targetBuilding); + attackBuilding(mob, targetBuilding); break; case Mob: Mob targetMob = (Mob) target; - AttackMob(mob, targetMob); + attackMob(mob, targetMob); break; } @@ -90,7 +90,7 @@ public class MobAI { } } - public static void AttackPlayer(Mob mob, PlayerCharacter target) { + public static void attackPlayer(Mob mob, PlayerCharacter target) { try { @@ -100,7 +100,7 @@ public class MobAI { } if (mob.behaviourType.callsForHelp) - MobCallForHelp(mob); + mobCallForHelp(mob); if (!MovementUtilities.inRangeDropAggro(mob, target)) { mob.setCombatTarget(null); @@ -128,7 +128,7 @@ public class MobAI { } - public static void AttackBuilding(Mob mob, Building target) { + public static void attackBuilding(Mob mob, Building target) { try { @@ -162,7 +162,7 @@ public class MobAI { } } - public static void AttackMob(Mob mob, Mob target) { + public static void attackMob(Mob mob, Mob target) { try { @@ -179,7 +179,7 @@ public class MobAI { } } - private static void Patrol(Mob mob) { + private static void patrol(Mob mob) { try { @@ -230,7 +230,7 @@ public class MobAI { for (Integer minionUUID : mob.minions) { Mob minion = Mob.getMob(minionUUID); if (minion.isAlive() && minion.combatTarget == null) - MobAI.Patrol(minion); + MobAI.patrol(minion); } MovementUtilities.aiMove(mob, mob.destination, true); @@ -284,7 +284,7 @@ public class MobAI { return false; } - public static boolean MobCast(Mob mob) { + public static boolean mobCast(Mob mob) { try { // Method picks a random spell from a mobile's list of powers @@ -296,7 +296,7 @@ public class MobAI { AbstractCharacter target = (AbstractCharacter) mob.getCombatTarget(); if (mob.behaviourType.callsForHelp) - MobCallForHelp(mob); + mobCallForHelp(mob); // Generate a list of tokens from the mob powers for this mobile. @@ -410,7 +410,7 @@ public class MobAI { return powerRank; } - public static void MobCallForHelp(Mob mob) { + public static void mobCallForHelp(Mob mob) { try { @@ -445,7 +445,7 @@ public class MobAI { } } - public static void DetermineAction(Mob mob) { + public static void determineAction(Mob mob) { try { @@ -465,7 +465,7 @@ public class MobAI { //trebuchet spawn handler if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { - CheckForRespawn(mob); + checkForRespawn(mob); return; } @@ -486,12 +486,12 @@ public class MobAI { } } - CheckForRespawn(mob); + checkForRespawn(mob); //check to send mob home for player guards to prevent exploit of dragging guards away and then teleporting if (!mob.agentType.equals(mbEnums.AIAgentType.PET)) - CheckToSendMobHome(mob); + checkToSendMobHome(mob); return; } @@ -499,7 +499,7 @@ public class MobAI { //no need to continue if mob is dead, check for respawn and move on if (!mob.isAlive()) { - CheckForRespawn(mob); + checkForRespawn(mob); return; } @@ -520,7 +520,7 @@ public class MobAI { if (mob.agentType.equals(mbEnums.AIAgentType.PET) == false) - CheckToSendMobHome(mob); + checkToSendMobHome(mob); if (mob.getCombatTarget() != null) { @@ -550,17 +550,17 @@ public class MobAI { case GuardCaptain: case GuardMinion: case GuardWallArcher: - GuardLogic(mob); + guardLogic(mob); break; case Pet1: case SiegeEngine: - PetLogic(mob); + petLogic(mob); break; case HamletGuard: - HamletGuardLogic(mob); + hamletGuardLogic(mob); break; default: - DefaultLogic(mob); + defaultLogic(mob); break; } } catch (Exception e) { @@ -568,7 +568,7 @@ public class MobAI { } } - private static void CheckForAggro(Mob aiAgent) { + private static void checkForAggro(Mob aiAgent) { try { @@ -642,7 +642,7 @@ public class MobAI { } } - private static void CheckMobMovement(Mob mob) { + private static void checkMobMovement(Mob mob) { try { @@ -685,9 +685,9 @@ public class MobAI { // Minions only patrol on their own if captain is dead. if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION) == false) - Patrol(mob); + patrol(mob); else if (mob.guardCaptain.isAlive() == false) - Patrol(mob); + patrol(mob); } else mob.stopPatrolTime = System.currentTimeMillis(); } else { @@ -700,7 +700,7 @@ public class MobAI { } } - private static void CheckForRespawn(Mob aiAgent) { + private static void checkForRespawn(Mob aiAgent) { try { @@ -747,7 +747,7 @@ public class MobAI { } } - public static void CheckForAttack(Mob mob) { + public static void checkForAttack(Mob mob) { try { //checks if mob can attack based on attack timer and range @@ -764,14 +764,14 @@ public class MobAI { mob.setCombatTarget(null); return; } - AttackTarget(mob, mob.getCombatTarget()); + attackTarget(mob, mob.getCombatTarget()); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: CheckForAttack" + " " + e.getMessage()); } } - private static void CheckToSendMobHome(Mob mob) { + private static void checkToSendMobHome(Mob mob) { try { @@ -853,7 +853,7 @@ public class MobAI { } } - private static void SafeGuardAggro(Mob mob) { + private static void safeGuardAggro(Mob mob) { try { HashSet awoList = WorldGrid.getObjectsInRangePartial(mob, 100, MBServerStatics.MASK_MOB); @@ -885,19 +885,19 @@ public class MobAI { } } - public static void GuardLogic(Mob mob) { + public static void guardLogic(Mob mob) { try { if (mob.getCombatTarget() == null) { - CheckForPlayerGuardAggro(mob); + checkForPlayerGuardAggro(mob); } else { //do not need to look to change target if target is already null - AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); + AbstractWorldObject newTarget = changeTargetFromHateValue(mob); if (newTarget != null) { if (newTarget.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) { - if (GuardCanAggro(mob, (PlayerCharacter) newTarget)) + if (guardCanAggro(mob, (PlayerCharacter) newTarget)) mob.setCombatTarget(newTarget); } else mob.setCombatTarget(newTarget); @@ -905,17 +905,17 @@ public class MobAI { } if (mob.behaviourType.canRoam) - CheckMobMovement(mob);//all guards that can move check to move + checkMobMovement(mob);//all guards that can move check to move if (mob.combatTarget != null) - CheckForAttack(mob); //only check to attack if combat target is not null + checkForAttack(mob); //only check to attack if combat target is not null } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: GuardLogic" + " " + e.getMessage()); } } - private static void PetLogic(Mob mob) { + private static void petLogic(Mob mob) { try { @@ -924,9 +924,9 @@ public class MobAI { mob.killCharacter("no owner"); if (MovementUtilities.canMove(mob) && mob.behaviourType.canRoam) - CheckMobMovement(mob); + checkMobMovement(mob); - CheckForAttack(mob); + checkForAttack(mob); //recover health @@ -948,23 +948,23 @@ public class MobAI { } } - private static void HamletGuardLogic(Mob mob) { + private static void hamletGuardLogic(Mob mob) { try { //safehold guard if (mob.getCombatTarget() == null) - SafeGuardAggro(mob); + safeGuardAggro(mob); else if (mob.getCombatTarget().isAlive() == false) - SafeGuardAggro(mob); + safeGuardAggro(mob); - CheckForAttack(mob); + checkForAttack(mob); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: HamletGuardLogic" + " " + e.getMessage()); } } - private static void DefaultLogic(Mob mob) { + private static void defaultLogic(Mob mob) { try { @@ -975,16 +975,16 @@ public class MobAI { if (mob.behaviourType.isAgressive) { - AbstractWorldObject newTarget = ChangeTargetFromHateValue(mob); + AbstractWorldObject newTarget = changeTargetFromHateValue(mob); if (newTarget != null) mob.setCombatTarget(newTarget); else { if (mob.getCombatTarget() == null) { if (mob.behaviourType == mbEnums.MobBehaviourType.HamletGuard) - SafeGuardAggro(mob); //safehold guard + safeGuardAggro(mob); //safehold guard else - CheckForAggro(mob); //normal aggro + checkForAggro(mob); //normal aggro } } } @@ -992,19 +992,19 @@ public class MobAI { //check if mob can move for patrol or moving to target if (mob.behaviourType.canRoam) - CheckMobMovement(mob); + checkMobMovement(mob); //check if mob can attack if it isn't wimpy if (!mob.behaviourType.isWimpy && mob.getCombatTarget() != null) - CheckForAttack(mob); + checkForAttack(mob); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DefaultLogic" + " " + e.getMessage()); } } - public static void CheckForPlayerGuardAggro(Mob mob) { + public static void checkForPlayerGuardAggro(Mob mob) { try { @@ -1050,7 +1050,7 @@ public class MobAI { // No aggro for this player - if (GuardCanAggro(mob, loadedPlayer) == false) + if (guardCanAggro(mob, loadedPlayer) == false) continue; if (MovementUtilities.inRangeToAggro(mob, loadedPlayer) && mob.getCombatTarget() == null) { @@ -1068,7 +1068,7 @@ public class MobAI { Mob aggroMob = (Mob) awoMob; - if (GuardCanAggro(mob, aggroMob)) { + if (guardCanAggro(mob, aggroMob)) { mob.setCombatTarget(aggroMob); return; } @@ -1080,7 +1080,7 @@ public class MobAI { } } - public static Boolean GuardCanAggro(Mob mob, AbstractCharacter target) { + public static Boolean guardCanAggro(Mob mob, AbstractCharacter target) { try { @@ -1189,7 +1189,7 @@ public class MobAI { } } - public static AbstractWorldObject ChangeTargetFromHateValue(Mob mob) { + public static AbstractWorldObject changeTargetFromHateValue(Mob mob) { try { diff --git a/src/engine/mobileAI/Threads/MobAIThread.java b/src/engine/mobileAI/Threads/MobAIThread.java index 0a7c02d5..bc05affe 100644 --- a/src/engine/mobileAI/Threads/MobAIThread.java +++ b/src/engine/mobileAI/Threads/MobAIThread.java @@ -32,7 +32,7 @@ public class MobAIThread implements Runnable { try { if (mob != null) - MobAI.DetermineAction(mob); + MobAI.determineAction(mob); } catch (Exception e) { Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e); e.printStackTrace(); From 4b67f97dedd6819c5dc247e476a6b8aeac8ec27b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 08:21:15 -0400 Subject: [PATCH 358/378] MB Dev Notes added --- src/engine/mobileAI/Threads/Respawner.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/mobileAI/Threads/Respawner.java b/src/engine/mobileAI/Threads/Respawner.java index b5471c8a..73ca78f8 100644 --- a/src/engine/mobileAI/Threads/Respawner.java +++ b/src/engine/mobileAI/Threads/Respawner.java @@ -16,7 +16,15 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.DelayQueue; public enum Respawner implements Runnable { + + // MB Dev Notes: + // + // Thread acts as a throttle for messages to the client. Mobiles are + // respawned over a short time so as not to flood the client when + // an entire camp respawns at once. + RESPAWNER; + public static BlockingQueue respawnQueue = new DelayQueue(); @Override From 9348852e2cb3b9de7630fc9967d60bb9a9906ad7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 14:57:02 -0400 Subject: [PATCH 359/378] Comment cleanup --- src/engine/net/MessageDispatcher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/MessageDispatcher.java b/src/engine/net/MessageDispatcher.java index 6d774ae5..5242e6c0 100644 --- a/src/engine/net/MessageDispatcher.java +++ b/src/engine/net/MessageDispatcher.java @@ -21,8 +21,8 @@ import java.util.regex.Pattern; // All outgoing Protocol messages to the player are managed through the MessageDispatcher.class. // All incoming Protocol messages from the player are managed by the Protocol.class. // -// A DispatchMessage is configured then wrapped in a Dispatch for a distribution list. -// A Dispatch can be submitted to the Dispatcher from any thread. +// A DispatchMessage is configured (Protocol messsage) and wrapped in a Dispatch (distribution list). +// A Dispatch can be submitted to the MessageDispatcher for delivery from any thread. // // Dispatches are interleaved between channels. This is to ensure // a combat or movement message is not delayed by spam clicking a From c2152432ce5d1f4311943ae6cd47796a56a8633f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:00:03 -0400 Subject: [PATCH 360/378] Comment cleanup --- src/engine/net/MessageDispatcher.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/engine/net/MessageDispatcher.java b/src/engine/net/MessageDispatcher.java index 5242e6c0..e397d3fa 100644 --- a/src/engine/net/MessageDispatcher.java +++ b/src/engine/net/MessageDispatcher.java @@ -30,13 +30,10 @@ import java.util.regex.Pattern; public class MessageDispatcher implements Runnable { - // Instance variables + // Class variables private static final ConcurrentLinkedQueue[] _messageQueue = new ConcurrentLinkedQueue[DispatchChannel.values().length]; private static final LinkedBlockingQueue _blockingQueue = new LinkedBlockingQueue<>(); - - // Class variables - public static volatile long[] messageCount = new long[DispatchChannel.values().length]; public static LongAdder[] dispatchCount = new LongAdder[DispatchChannel.values().length]; @@ -47,8 +44,6 @@ public class MessageDispatcher implements Runnable { private final Pattern filterPattern; // Unused, but just in case private Dispatch messageDispatch; - // Thread constructor - public MessageDispatcher() { // Create new FIFO queues for this network thread @@ -94,6 +89,10 @@ public class MessageDispatcher implements Runnable { public static void send(Dispatch messageDispatch, DispatchChannel dispatchChannel) { + // A Dispatch should be borrowed from the local cache. + // They will automatically be released back to the queue + // once delivered. + // Don't queue up empty dispatches! if (messageDispatch.player == null) From 6b6be80fa8a3f08a00341dd50a5ab395cf65b91b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:02:19 -0400 Subject: [PATCH 361/378] Comment cleanup --- src/engine/net/MessageDispatcher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/net/MessageDispatcher.java b/src/engine/net/MessageDispatcher.java index e397d3fa..90b8fb96 100644 --- a/src/engine/net/MessageDispatcher.java +++ b/src/engine/net/MessageDispatcher.java @@ -89,8 +89,8 @@ public class MessageDispatcher implements Runnable { public static void send(Dispatch messageDispatch, DispatchChannel dispatchChannel) { - // A Dispatch should be borrowed from the local cache. - // They will automatically be released back to the queue + // Use Dispatch.borrow() for a new dispatch. + // The Dispatch will be released by the system // once delivered. // Don't queue up empty dispatches! From 9a8e0bd5c940c6acf18ec4cf7524e57051c5db78 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:10:49 -0400 Subject: [PATCH 362/378] Comment cleanup --- src/engine/objects/Blueprint.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index 3f5a76e1..dc6b70b0 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -18,11 +18,13 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; -/* @Summary - Blueprint class is used for determining - characteristics of instanced player owned - structures such as available slots, upgrade - cost/time and the target window symbol icon. - */ +// MB Dev Notes: +// This class is the building equivalent of an itemTemplate; +// +// DB table static_building_blueprint contains all the data +// required for ranking and planting player buildings from +// a contract. + public class Blueprint { public final static Vector2f IrikieForgeExtents = new Vector2f(32, 32); From 0d744d900c256b1d26e0a06fb6a16b988d6c3433 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:12:53 -0400 Subject: [PATCH 363/378] MB Dev note added --- src/engine/objects/Blueprint.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/Blueprint.java b/src/engine/objects/Blueprint.java index dc6b70b0..e6b803a7 100644 --- a/src/engine/objects/Blueprint.java +++ b/src/engine/objects/Blueprint.java @@ -20,10 +20,9 @@ import java.util.HashMap; // MB Dev Notes: // This class is the building equivalent of an itemTemplate; +// with helper methods to place, slot and rank buildings. // -// DB table static_building_blueprint contains all the data -// required for ranking and planting player buildings from -// a contract. +// DB table static_building_blueprint contains the data. public class Blueprint { From 1b20201f8d8d8d29ac1141722279739cab40f502 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:32:17 -0400 Subject: [PATCH 364/378] MB Dev note added --- src/engine/objects/ItemTemplate.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 2afec01c..f0a07cb3 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -20,11 +20,21 @@ import java.util.HashMap; public class ItemTemplate { + // MB Dev Notes: + // This class parses JSON data generated by mbEditor Pro 2.1. + // Cache definitions are loaded for ItemType.ITEM, ItemType,DEED + // and ItemType.RUNE. + // + // Always read never write! + // Use copies of fields to avoid side effects. + // Global template lookup + public static HashMap templates = new HashMap<>(); public int template_id; // Template Properties + public String obj_name; public boolean obj_pickable; public Vector3fImmutable obj_scale; @@ -121,10 +131,8 @@ public class ItemTemplate { public boolean rune_group_is_guild = false; public String rune_dsc; public String rune_fx_txt; - public EnumSet rune_group_tactics = EnumSet.noneOf(mbEnums.MobBehaviourType.class); - ; - public EnumSet rune_group_role_set = EnumSet.noneOf(mbEnums.MobBehaviourType.class); - ; + public final EnumSet rune_group_tactics = EnumSet.noneOf(mbEnums.MobBehaviourType.class); + public final EnumSet rune_group_role_set = EnumSet.noneOf(mbEnums.MobBehaviourType.class); public boolean rune_renderable = false; public int rune_natural_power_attack; public final HashMap rune_sparse_data = new HashMap<>(); From 46f35f0b10404f05abf667ee63a4d9ec948a2207 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:37:37 -0400 Subject: [PATCH 365/378] Minor update to keyset() usages --- src/engine/objects/ItemTemplate.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index f0a07cb3..206dde0f 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -181,8 +181,7 @@ public class ItemTemplate { JSONObject obj_sparse_json = jsonObject.getJSONObject("obj_sparse_data"); - for (Object key : obj_sparse_json.keySet()) { - String sparseType = key.toString(); + for (String sparseType : obj_sparse_json.keySet()) { Object sparseValue = obj_sparse_json.get(sparseType); obj_sparse_data.put(sparseType, sparseValue.toString()); } @@ -202,9 +201,9 @@ public class ItemTemplate { JSONObject resist_json = jsonObject.getJSONObject("combat_attack_resist"); - for (String key : resist_json.keySet()) { - float resist = resist_json.getFloat(key); - combat_attack_resist.put(key, resist); + for (String resistType : resist_json.keySet()) { + float resistValue = resist_json.getFloat(resistType); + combat_attack_resist.put(resistType, resistValue); } // Parsing an enum @@ -554,8 +553,7 @@ public class ItemTemplate { JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data"); - for (Object key : rune_sparse_json.keySet()) { - String sparseType = key.toString(); + for (String sparseType : rune_sparse_json.keySet()) { Object sparseValue = rune_sparse_json.get(sparseType); rune_sparse_data.put(sparseType, sparseValue.toString()); } From 79e86e0a6f49f6c61f7c86c793f6c14da5e69581 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:43:45 -0400 Subject: [PATCH 366/378] Comment cleanup --- src/engine/objects/ItemTemplate.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 206dde0f..2ce24d81 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -25,6 +25,9 @@ public class ItemTemplate { // Cache definitions are loaded for ItemType.ITEM, ItemType,DEED // and ItemType.RUNE. // + // Exported JSON data is stored in db table static_item_templates + // and can be easily mass updated using tooling available on the Wiki. + // // Always read never write! // Use copies of fields to avoid side effects. From ac0c11cb4656c1f3efeff761bcc61f8956b81260 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 15:56:04 -0400 Subject: [PATCH 367/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 6c811d34..d60f58e1 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -29,13 +29,13 @@ import java.util.concurrent.atomic.AtomicInteger; public enum ForgeManager implements Runnable { // MB Dev notes: - // Class handles all forge rolling mechanics for the game. + // Class handles all forge rolling mechanics for Magicbane. // - // WorkOrders may be submitted from any thread: usually (ItemProductionMsgHandler). + // .submit(workOrder) may be called from any thread: (ItemProductionMsgHandler). // Concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock). - // WorkOrders are persisted then reconstituted at bootstrap from table dyn.workorders. + // WorkOrders are persisted then reconstituted at bootstrap using table dyn.workorders. // - // p.s. replaces garbage code that looked like it was written by a crack head with face boils. + // p.s. replaces garbage code that looked like it was written by a mental patient with face boils. FORGE_MANAGER; @@ -58,9 +58,13 @@ public enum ForgeManager implements Runnable { try { workOrder = forge.take(); + // This workOrder has completed production. + if (workOrder.total_produced >= workOrder.total_to_produce) { - // Complete this workOrder. + // Set items as completed in the window. + // First CONFIRM_PRODUCE adds virtual item to the interface. + // Second CONFIRM_PRODUCE sets virtual item to complete. for (Item workOrderItem : workOrder.cooking) { workOrderItem.flags.add(mbEnums.ItemFlags.Identified); From c25f325f8724827f91e3f47e8854178c7f9b1f13 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 16:15:07 -0400 Subject: [PATCH 368/378] Null check added for city --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 26237bf2..8dda9592 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -393,6 +393,11 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); City city = workOrder.vendor.building.getCity(); + + if (city == null) + return; + ; + city.transactionLock.writeLock().lock(); try { From f294e48140b096636a1786e5c72944f34e6540cd Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 Apr 2024 16:15:16 -0400 Subject: [PATCH 369/378] Null check added for city --- src/engine/net/client/handlers/ItemProductionMsgHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 8dda9592..3c3da691 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -396,7 +396,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (city == null) return; - ; city.transactionLock.writeLock().lock(); From 6cc94e076db912598de902d0cf610c0478493b82 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 26 Apr 2024 19:00:12 -0500 Subject: [PATCH 370/378] promoting was attempting to use players promotion class (which is null) --- src/engine/objects/PlayerCharacter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index 07f50a0d..0d4704b5 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -2193,7 +2193,7 @@ public class PlayerCharacter extends AbstractCharacter { public boolean setPromotionClass(int value) { PromotionClass promotionClass = PromotionClass.GetPromtionClassFromCache(value); - this.absPromotionClass = mbEnums.ClassType.valueOf(this.getPromotionClass().getName()); + this.absPromotionClass = mbEnums.ClassType.valueOf(promotionClass.getName()); if (promotionClass == null) return false; From c99433c9bda050db2f2d87093684a6150143fe3c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 26 Apr 2024 19:07:33 -0500 Subject: [PATCH 371/378] missing case for type RUNE in ObjectActionMsgHandler --- src/engine/net/client/handlers/ObjectActionMsgHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 17033af2..144ab3a8 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -288,6 +288,9 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); player.cancelOnSpell(); break; + case RUNE: + ApplyRuneMsg.applyRune(uuid,origin,player); + break; default: //shouldn't be here, consume item dispatch = Dispatch.borrow(player, msg); DispatchMessage.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); From 39d04188b49dc87a07c85ba6c0bdd0435ae5d55a Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 26 Apr 2024 19:10:56 -0500 Subject: [PATCH 372/378] cleanup old rune handler in ObjectActionMsgHandler --- .../handlers/ObjectActionMsgHandler.java | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 144ab3a8..21c5ff0d 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -187,27 +187,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { case POTION: //potions, tears of saedron case SCROLL: //runes, petition, warrant, scrolls - if (uuid > 3000 && uuid < 3050) { //Discipline Runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 249999 && uuid < 250123) { //stat and mastery runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 250114 && uuid < 250123) { //mastery runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 252122 && uuid < 252128) { //mastery runes - if (ApplyRuneMsg.applyRune(uuid, origin, player)) { - itemMan.consume(item); - } - break; - } else if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here + if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here { break; } else if (uuid > 910010 && uuid < 910019) { @@ -290,6 +270,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { break; case RUNE: ApplyRuneMsg.applyRune(uuid,origin,player); + itemMan.consume(item); break; default: //shouldn't be here, consume item dispatch = Dispatch.borrow(player, msg); From 91016dd53c2b478e0846829a5efdd6491c96a8a8 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 27 Apr 2024 07:06:39 -0400 Subject: [PATCH 373/378] Cleanup in bane handling --- .../handlers/ObjectActionMsgHandler.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index 21c5ff0d..de82fb79 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -185,42 +185,42 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { case BUCKET: //water bucket case POTION: //potions, tears of saedron - case SCROLL: //runes, petition, warrant, scrolls if (uuid > 680069 && uuid < 680074) //Handle Charter, Deed, Petition, Warrant here - { break; - } else if (uuid > 910010 && uuid < 910019) { - int rank = uuid - 910010; + if (item.template.item_bane_rank > 0) { - if (rank < 1 || rank > 8) { - ChatManager.chatSystemError(player, "Invalid Rank for bane scroll!"); - return true; - } // Only one banestone at a time + lock.writeLock().lock(); try { - if (Bane.summonBanestone(player, origin, rank) == true) + if (Bane.summonBanestone(player, origin, item.template.item_bane_rank) == true) itemMan.consume(item); } finally { lock.writeLock().unlock(); } break; - } else if (uuid == 910010) { //tears of saedron + } + + if (uuid == 910010) { //tears of saedron if (comps.size() > 1) { AbstractCharacter.removeRune(player, origin, comps.get(1).intValue()); } break; - } else if ((byte) item.chargesRemaining > 0) { + } + + if (item.chargesRemaining > 0) { ArrayList tarList = msg.getTargetCompID(); AbstractWorldObject target = player; + if (tarList.size() > 1) { long tarID = tarList.get(1); + if (tarID != 0) { AbstractGameObject tarAgo = AbstractGameObject.getFromTypeAndID(tarID); - if (tarAgo != null && tarAgo instanceof AbstractWorldObject) { + if (tarAgo instanceof AbstractWorldObject) { target = (AbstractWorldObject) tarAgo; } } @@ -228,8 +228,6 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { // Bypass for waterbuckets - // test character targeted - if (item.template.item_type.equals(mbEnums.ItemType.BUCKET)) { // test for valid target type From f134f71695421631f3561b8591cd331e3a9c3865 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 27 Apr 2024 07:07:59 -0400 Subject: [PATCH 374/378] Squiggly removal --- src/engine/net/client/handlers/ObjectActionMsgHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/net/client/handlers/ObjectActionMsgHandler.java b/src/engine/net/client/handlers/ObjectActionMsgHandler.java index de82fb79..0e23dd32 100644 --- a/src/engine/net/client/handlers/ObjectActionMsgHandler.java +++ b/src/engine/net/client/handlers/ObjectActionMsgHandler.java @@ -205,9 +205,8 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler { } if (uuid == 910010) { //tears of saedron - if (comps.size() > 1) { + if (comps.size() > 1) AbstractCharacter.removeRune(player, origin, comps.get(1).intValue()); - } break; } From 743c897254271b5a7d96c998d623c58980b5aa2a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 27 Apr 2024 07:18:24 -0400 Subject: [PATCH 375/378] total_to_produce updated when slot removed from workOrder --- .../handlers/ItemProductionMsgHandler.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 3c3da691..28e66e58 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -373,24 +373,34 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ManageNPCMsg outMsg; Dispatch dispatch; - virtualItem = Item.getFromCache(itemUUID); - PlayerCharacter player = origin.getPlayerCharacter(); if (player == null) return; + // Cannot junk items without a forge! + + if (vendor.getBuilding() == null) + return; + // junk nothing? + virtualItem = Item.getFromCache(itemUUID); + if (virtualItem == null) return; - // Cannot junk items without a forge! + WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); - if (vendor.getBuilding() == null) + // If this virtual item was already processed then + // it will have been removed from the workOrder. + + if (workOrder == null) return; - WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); + if (workOrder.cooking.contains(virtualItem) == false) + return; + ; City city = workOrder.vendor.building.getCity(); @@ -405,6 +415,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DbManager.removeFromCache(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + // Update total_to_produce accounting for the slot being + // removed while workOrder is not completed. + + if (workOrder.runCompleted == false) { + int itemsPerSlot = workOrder.total_to_produce / workOrder.slots_used; + workOrder.total_to_produce = workOrder.total_to_produce - itemsPerSlot; + } + + // Slot is no longer allocated to this workOrder. + workOrder.slots_used = workOrder.slots_used - 1; // Update workOrder on disk From 4dce2e2aa24e4e7809baab6fd261c36036f62474 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 27 Apr 2024 07:22:20 -0400 Subject: [PATCH 376/378] Comment cleanup --- src/engine/gameManager/ForgeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d60f58e1..d95d4ef7 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -29,13 +29,13 @@ import java.util.concurrent.atomic.AtomicInteger; public enum ForgeManager implements Runnable { // MB Dev notes: - // Class handles all forge rolling mechanics for Magicbane. + // Class implements forge rolling mechanics for Magicbane. // // .submit(workOrder) may be called from any thread: (ItemProductionMsgHandler). // Concurrency is managed by the same lock used by the warehouse (city.cityTransactionLock). // WorkOrders are persisted then reconstituted at bootstrap using table dyn.workorders. // - // p.s. replaces garbage code that looked like it was written by a mental patient with face boils. + // Replaces garbage code that looked as if written by a mental patient with face boils. FORGE_MANAGER; From e1e72b71bde3602cf5cea8ed6a75a9cc9e73fb73 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 27 Apr 2024 07:24:57 -0400 Subject: [PATCH 377/378] Better name for context --- src/engine/db/handlers/dbWarehouseHandler.java | 2 +- src/engine/gameManager/ForgeManager.java | 6 +++--- .../net/client/handlers/ItemProductionMsgHandler.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 31fb4a10..10d391bb 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -154,7 +154,7 @@ public class dbWarehouseHandler extends dbHandlerBase { } } - public boolean UPDATE_WORKORDER(WorkOrder workOrder) { + public boolean WRITE_WORKORDER(WorkOrder workOrder) { JSONObject warehouseJSON = WorkOrder.toJson(workOrder); diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index d95d4ef7..c5e09219 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -76,7 +76,7 @@ public enum ForgeManager implements Runnable { // Update workOrder on disk - DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); } if (workOrder.runCompleted) @@ -175,7 +175,7 @@ public enum ForgeManager implements Runnable { // PERSIST workOrder (dyn_workorders) - DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); } catch (Exception e) { Logger.error(e); @@ -366,7 +366,7 @@ public enum ForgeManager implements Runnable { // Write updated workOrder to disk - DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); } diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index 28e66e58..622f61e7 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -154,7 +154,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); } else - DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); // Persist item and add to vendor inventory @@ -433,7 +433,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.vendorWorkOrderLookup.get(vendor).remove(workOrder); DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); } else - DbManager.WarehouseQueries.UPDATE_WORKORDER(workOrder); + DbManager.WarehouseQueries.WRITE_WORKORDER(workOrder); // Refresh vendor's inventory to client From f09a7d4d127fc1c9c1e35801cbe730232cdf281b Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 20 Apr 2024 08:57:42 -0400 Subject: [PATCH 378/378] Unused method removed --- .../powers/poweractions/ApplyEffectPowerAction.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/engine/powers/poweractions/ApplyEffectPowerAction.java b/src/engine/powers/poweractions/ApplyEffectPowerAction.java index b7e16e09..7f03842c 100644 --- a/src/engine/powers/poweractions/ApplyEffectPowerAction.java +++ b/src/engine/powers/poweractions/ApplyEffectPowerAction.java @@ -46,13 +46,6 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { this.effect = effects.get(this.effectID); } - public ApplyEffectPowerAction(ResultSet rs, EffectsBase effect) throws SQLException { - super(rs); - - this.effectID = rs.getString("effectID"); - this.effect = effect; - } - private static boolean blockInvul(PowersBase pb, AbstractCharacter source, AbstractWorldObject awo) { if (awo == null || pb == null || source == null) return false; @@ -65,7 +58,6 @@ public class ApplyEffectPowerAction extends AbstractPowerAction { AbstractCharacter ac = (AbstractCharacter) awo; - return false; }