From fde26ee62d5d418f9ea7ef1105649479e9693b83 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 26 Dec 2019 15:38:29 -0600 Subject: [PATCH] forgot these didn't stage all the refactored files, oops :( --- src/main/java/game/user/item/ItemInfo.java | 68 ++++++++++++---------- src/main/java/shop/ShopApp.java | 12 ++-- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/src/main/java/game/user/item/ItemInfo.java b/src/main/java/game/user/item/ItemInfo.java index 4189776e..a3a4db34 100644 --- a/src/main/java/game/user/item/ItemInfo.java +++ b/src/main/java/game/user/item/ItemInfo.java @@ -45,9 +45,6 @@ */ public class ItemInfo { - private static WzPackage characterDir; - private static WzPackage itemDir; - private static WzPackage fieldDir; protected static final Map bundleItem; protected static final Map equipItem; protected static final Map statChangeItem; @@ -58,11 +55,6 @@ public class ItemInfo { protected static final Map itemString; static { - // Initialize Packages - characterDir = new WzFileSystem().init("Character").getPackage(); - itemDir = new WzFileSystem().init("Item").getPackage(); - fieldDir = new WzFileSystem().init("Map/Map").getPackage(); - // Initialize Item Containers bundleItem = new HashMap<>(); equipItem = new HashMap<>(); @@ -283,23 +275,23 @@ public static boolean isTwoHanded(int itemID) { public static void load() { Logger.logReport("Loading Equip Info"); - for (Entry category : characterDir.getChildren().entrySet()) { - if (!category.getKey().equals("Afterimage")) { - for (WzProperty itemData : category.getValue().getEntries().values()) { - registerEquipItemInfo(itemData); + WzPackage characterDir = new WzFileSystem().init("Character").getPackage(); + if (characterDir != null) { + for (Entry category : characterDir.getChildren().entrySet()) { + if (!category.getKey().equals("Afterimage")) { + for (WzProperty itemData : category.getValue().getEntries().values()) { + registerEquipItemInfo(itemData); + } } + category.getValue().release(); } - category.getValue().release(); + characterDir.release(); } - characterDir.release(); + characterDir = null; Logger.logReport("Loading Bundle Info"); iterateBundleItem(); iterateMapString(); - - characterDir = null; - itemDir = null; - fieldDir = null; } private static void registerEquipItemInfo(WzProperty itemData) { @@ -348,17 +340,21 @@ private static void registerEquipItemInfo(WzProperty itemData) { } private static void iterateBundleItem() { - String[] category = {"Consume", "Etc"}; - for (String cat : category) { - WzPackage pack = itemDir.getChildren().get(cat); - for (WzProperty itemSection : pack.getEntries().values()) { - for (WzProperty itemData : itemSection.getChildNodes()) { - loadBundleItem(itemData); + WzPackage itemDir = new WzFileSystem().init("Item").getPackage(); + if (itemDir != null) { + String[] category = {"Consume", "Etc"}; + for (String cat : category) { + WzPackage pack = itemDir.getChildren().get(cat); + for (WzProperty itemSection : pack.getEntries().values()) { + for (WzProperty itemData : itemSection.getChildNodes()) { + loadBundleItem(itemData); + } } + pack.release(); } - pack.release(); + itemDir.release(); } - itemDir.release(); + itemDir = null; } private static void loadBundleItem(WzProperty itemData) { @@ -498,14 +494,22 @@ private static void registerUpgradeItem(int itemID, WzProperty itemData) { upgradeItem.put(item.getItemID(), item); } + // Disabled since this is just eating up memory and isn't even used yet. private static void iterateMapString() { - for (WzProperty map : fieldDir.getEntries().values()) { - int mapid = Integer.parseInt(map.getNodeName().replace(".img", "")); - WzProperty info = map.getNode("info"); - if (info != null) { - mapString.put(mapid, WzUtil.getString(info.getNode("mapName"), "NULL")); + /* + WzPackage fieldDir = new WzFileSystem().init("Map/Map").getPackage(); + if (fieldDir != null) { + for (WzProperty map : fieldDir.getEntries().values()) { + WzProperty info = map.getNode("info"); + if (info != null) { + int mapID = Integer.parseInt(map.getNodeName().replace(".img", "")); + mapString.put(mapID, WzUtil.getString(info.getNode("mapName"), "NULL")); + } + map.release(); } + fieldDir.release(); } - fieldDir.release(); + fieldDir = null; + */ } } diff --git a/src/main/java/shop/ShopApp.java b/src/main/java/shop/ShopApp.java index 9e208a57..8806af9d 100644 --- a/src/main/java/shop/ShopApp.java +++ b/src/main/java/shop/ShopApp.java @@ -43,7 +43,6 @@ * @author Eric */ public class ShopApp implements Runnable { - private static final WzPackage etcDir = new WzFileSystem().init("Etc").getPackage(); private static final ShopApp instance = new ShopApp(); private String addr; @@ -180,10 +179,11 @@ private void initializeCommodity() { time = System.currentTimeMillis(); ItemInfo.load(); Logger.logReport("Loaded Item Info in " + ((System.currentTimeMillis() - time) / 1000.0) + " seconds."); - - try { - time = System.currentTimeMillis(); + + WzPackage etcDir = new WzFileSystem().init("Etc").getPackage(); + if (etcDir != null) { WzProperty img = etcDir.getItem("Commodity.img"); + time = System.currentTimeMillis(); for (WzProperty imgDir : img.getChildNodes()) { Commodity comm = new Commodity(); comm.setSN(WzUtil.getInt32(imgDir.getNode("SN"), 0)); @@ -194,10 +194,10 @@ private void initializeCommodity() { comm.setPriority(WzUtil.getByte(imgDir.getNode("Priority"), 0)); commodity.put(comm.getSN(), comm); } + etcDir.release(); Logger.logReport("Loaded Commodity in " + ((System.currentTimeMillis() - time) / 1000.0) + " seconds."); - } catch (Exception ex) { - ex.printStackTrace(System.err); } + etcDir = null; } private void initializeDB() {