Skip to content

Commit

Permalink
forgot these
Browse files Browse the repository at this point in the history
didn't stage all the refactored files, oops :(
  • Loading branch information
EricSoftTM committed Dec 26, 2019
1 parent 8a66e7a commit fde26ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 38 deletions.
68 changes: 36 additions & 32 deletions src/main/java/game/user/item/ItemInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
*/
public class ItemInfo {

private static WzPackage characterDir;
private static WzPackage itemDir;
private static WzPackage fieldDir;
protected static final Map<Integer, BundleItem> bundleItem;
protected static final Map<Integer, EquipItem> equipItem;
protected static final Map<Integer, StateChangeItem> statChangeItem;
Expand All @@ -58,11 +55,6 @@ public class ItemInfo {
protected static final Map<Integer, String> 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<>();
Expand Down Expand Up @@ -283,23 +275,23 @@ public static boolean isTwoHanded(int itemID) {

public static void load() {
Logger.logReport("Loading Equip Info");
for (Entry<String, WzPackage> 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<String, WzPackage> 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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
*/
}
}
12 changes: 6 additions & 6 deletions src/main/java/shop/ShopApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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() {
Expand Down

0 comments on commit fde26ee

Please sign in to comment.