From f1f8ccfc2bbdde9dda83f5955aa5e23983d0be20 Mon Sep 17 00:00:00 2001
From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com>
Date: Sun, 26 Jan 2020 19:25:27 +0000
Subject: [PATCH] Replaced static object CSV data with aCis free version XML
data.
---
.../dist/game/data/StaticObjects.xml | 32 ++++
.../dist/game/data/csv/staticobjects.csv | 30 ----
.../dist/game/data/xsd/StaticObjects.xsd | 24 +++
.../org/l2jmobius/gameserver/GameServer.java | 4 +-
.../datatables/csv/StaticObjects.java | 154 ------------------
.../gameserver/datatables/xml/FishData.java | 1 +
.../datatables/xml/StaticObjectData.java | 104 ++++++++++++
7 files changed, 163 insertions(+), 186 deletions(-)
create mode 100644 L2J_Mobius_C6_Interlude/dist/game/data/StaticObjects.xml
delete mode 100644 L2J_Mobius_C6_Interlude/dist/game/data/csv/staticobjects.csv
create mode 100644 L2J_Mobius_C6_Interlude/dist/game/data/xsd/StaticObjects.xsd
delete mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/csv/StaticObjects.java
create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/StaticObjectData.java
diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/StaticObjects.xml b/L2J_Mobius_C6_Interlude/dist/game/data/StaticObjects.xml
new file mode 100644
index 0000000000..18ad131e9f
--- /dev/null
+++ b/L2J_Mobius_C6_Interlude/dist/game/data/StaticObjects.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/csv/staticobjects.csv b/L2J_Mobius_C6_Interlude/dist/game/data/csv/staticobjects.csv
deleted file mode 100644
index b211e21a21..0000000000
--- a/L2J_Mobius_C6_Interlude/dist/game/data/csv/staticobjects.csv
+++ /dev/null
@@ -1,30 +0,0 @@
-darkelf_village_001;20180001;15258;15631;-4366;0;town_map_darkelf_t00;1;1
-darkelf_village_002;20180002;7557;18055;-4366;0;town_map_darkelf_t00;1;1
-dwarven_village_001;23120001;115462;-177295;-880;0;town_map_dwarf_t00;1;1
-dwarven_village_002;23120002;117450;-182299;-1488;0;town_map_dwarf_t00;1;1
-dwarven_village_003;23120003;116657;-183997;-1550;0;town_map_dwarf_t00;1;1
-elf_village_001;21190001;47616;51349;-2968;0;town_map_elf_t00;1;1
-elf_village_002;21190002;45915;46695;-2969;0;town_map_elf_t00;1;1
-elf_village_003;21190003;43175;51424;-2968;0;town_map_elf_t00;1;1
-human_village_001;17250001;-82873;244808;-3717;0;town_map_talking_t00;1;1
-human_village_002;17250002;-82765;241439;-3718;0;town_map_talking_t00;1;1
-human_village_003;17250003;-86121;241452;-3719;0;town_map_talking_t00;1;1
-orc_village_001;18140001;-45824;-116764;-219;0;town_map_orc_t00;1;1
-orc_village_002;18140002;-46504;-110394;-220;0;town_map_orc_t00;1;1
-orc_village_003;18140003;-47332;-113246;-220;0;town_map_orc_t00;1;1
-aden_castle_throne;24180017;147456;3272;-42;1;none;0;0
-oren_castle_throne;22190010;83237;37192;-2286;1;none;0;0
-dion_castle_throne;20220010;22073;160989;-2686;1;none;0;0
-giran_castle_throne;23220010;117161;145097;-2559;1;none;0;0
-gludio_castle_throne;19210010;-18112;108761;-2492;1;none;0;0
-innadril_castle_throne;23250010;116024;249768;-782;1;none;0;0
-goddard_castle_throne;24160024;147464;-49339;-2123;1;none;0;0
-schuttgart_castle_throne;22130016;77551;-153410;-389;1;none;0;0
-rune_castle_throne;20160010;10103;-49153;-272;1;none;0;0
-floran_arena_001;20230001;12110;182771;-3538;2;none;0;0
-floran_arena_002;20230002;12979;183365;-3538;2;none;0;0
-giran_arena_001;22220001;73766;142489;-3748;2;none;0;0
-giran_arena_002;22220002;72200;143102;-3748;2;none;0;0
-gludin_arena_001;17220015;-88697;142316;-3621;2;none;0;0
-gludin_arena_002;17220016;-87136;142491;-3623;2;none;0;0
-Dragonspine_flagpole;20200500;11546;95030;-2498;3;none;0;0
\ No newline at end of file
diff --git a/L2J_Mobius_C6_Interlude/dist/game/data/xsd/StaticObjects.xsd b/L2J_Mobius_C6_Interlude/dist/game/data/xsd/StaticObjects.xsd
new file mode 100644
index 0000000000..835c793093
--- /dev/null
+++ b/L2J_Mobius_C6_Interlude/dist/game/data/xsd/StaticObjects.xsd
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
index 060e76737c..04136d7d76 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java
@@ -51,7 +51,6 @@ import org.l2jmobius.gameserver.datatables.csv.ExtractableItemsData;
import org.l2jmobius.gameserver.datatables.csv.MapRegionTable;
import org.l2jmobius.gameserver.datatables.csv.NpcWalkerRoutesTable;
import org.l2jmobius.gameserver.datatables.csv.RecipeTable;
-import org.l2jmobius.gameserver.datatables.csv.StaticObjects;
import org.l2jmobius.gameserver.datatables.csv.SummonItemsData;
import org.l2jmobius.gameserver.datatables.sql.ArmorSetsTable;
import org.l2jmobius.gameserver.datatables.sql.CharNameTable;
@@ -73,6 +72,7 @@ import org.l2jmobius.gameserver.datatables.xml.ExperienceData;
import org.l2jmobius.gameserver.datatables.xml.FenceData;
import org.l2jmobius.gameserver.datatables.xml.FishData;
import org.l2jmobius.gameserver.datatables.xml.HennaData;
+import org.l2jmobius.gameserver.datatables.xml.StaticObjectData;
import org.l2jmobius.gameserver.datatables.xml.ZoneData;
import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.AdminCommandHandler;
@@ -210,7 +210,7 @@ public class GameServer
Announcements.getInstance();
AutoAnnouncementHandler.getInstance();
GlobalVariablesManager.getInstance();
- StaticObjects.getInstance();
+ StaticObjectData.getInstance();
TeleportLocationTable.getInstance();
PartyMatchWaitingList.getInstance();
PartyMatchRoomList.getInstance();
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/csv/StaticObjects.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/csv/StaticObjects.java
deleted file mode 100644
index 629b0f3a6c..0000000000
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/csv/StaticObjects.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * This file is part of the L2J Mobius project.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.l2jmobius.gameserver.datatables.csv;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.LineNumberReader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.logging.Logger;
-
-import org.l2jmobius.Config;
-import org.l2jmobius.gameserver.idfactory.IdFactory;
-import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
-
-public class StaticObjects
-{
- private static final Logger LOGGER = Logger.getLogger(StaticObjects.class.getName());
-
- private final Map _staticObjects;
-
- public StaticObjects()
- {
- _staticObjects = new HashMap<>();
- parseData();
- LOGGER.info("StaticObject: Loaded " + _staticObjects.size() + " StaticObject Templates.");
- }
-
- private void parseData()
- {
- FileReader reader = null;
- BufferedReader buff = null;
- LineNumberReader lnr = null;
-
- try
- {
- final File doorData = new File(Config.DATAPACK_ROOT, "data/csv/staticobjects.csv");
-
- reader = new FileReader(doorData);
- buff = new BufferedReader(reader);
- lnr = new LineNumberReader(buff);
-
- String line = null;
- while ((line = lnr.readLine()) != null)
- {
- if ((line.trim().length() == 0) || line.startsWith("#"))
- {
- continue;
- }
-
- final StaticObjectInstance obj = parse(line);
- _staticObjects.put(obj.getStaticObjectId(), obj);
- }
- }
- catch (FileNotFoundException e)
- {
- LOGGER.warning("staticobjects.csv is missing in data csv folder");
- }
- catch (Exception e)
- {
- LOGGER.warning("Error while creating StaticObjects table " + e);
- }
- finally
- {
- if (lnr != null)
- {
- try
- {
- lnr.close();
- }
- catch (Exception e1)
- {
- LOGGER.warning("Problem with StaticObjects: " + e1.getMessage());
- }
- }
-
- if (buff != null)
- {
- try
- {
- buff.close();
- }
- catch (Exception e1)
- {
- LOGGER.warning("Problem with StaticObjects: " + e1.getMessage());
- }
- }
-
- if (reader != null)
- {
- try
- {
- reader.close();
- }
- catch (Exception e1)
- {
- LOGGER.warning("Problem with StaticObjects: " + e1.getMessage());
- }
- }
- }
- }
-
- public static StaticObjectInstance parse(String line)
- {
- final StringTokenizer st = new StringTokenizer(line, ";");
-
- st.nextToken(); // Pass over static object name (not used in server)
-
- final int id = Integer.parseInt(st.nextToken());
- final int x = Integer.parseInt(st.nextToken());
- final int y = Integer.parseInt(st.nextToken());
- final int z = Integer.parseInt(st.nextToken());
- final int type = Integer.parseInt(st.nextToken());
- final String texture = st.nextToken();
- final int map_x = Integer.parseInt(st.nextToken());
- final int map_y = Integer.parseInt(st.nextToken());
-
- final StaticObjectInstance obj = new StaticObjectInstance(IdFactory.getInstance().getNextId());
- obj.setType(type);
- obj.setStaticObjectId(id);
- obj.setXYZ(x, y, z);
- obj.setMap(texture, map_x, map_y);
- obj.spawnMe();
-
- return obj;
- }
-
- public static StaticObjects getInstance()
- {
- return SingletonHolder.INSTANCE;
- }
-
- private static class SingletonHolder
- {
- protected static final StaticObjects INSTANCE = new StaticObjects();
- }
-}
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/FishData.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/FishData.java
index f75ab4fb2e..aa25209d24 100644
--- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/FishData.java
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/FishData.java
@@ -57,6 +57,7 @@ public class FishData implements IXmlReader
// First element is never read.
final Node n = doc.getFirstChild();
+
for (Node node = n.getFirstChild(); node != null; node = node.getNextSibling())
{
if (!"fish".equalsIgnoreCase(node.getNodeName()))
diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/StaticObjectData.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/StaticObjectData.java
new file mode 100644
index 0000000000..9f9e16ae86
--- /dev/null
+++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/datatables/xml/StaticObjectData.java
@@ -0,0 +1,104 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.l2jmobius.gameserver.datatables.xml;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import org.l2jmobius.commons.util.IXmlReader;
+import org.l2jmobius.gameserver.idfactory.IdFactory;
+import org.l2jmobius.gameserver.model.StatSet;
+import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance;
+import org.l2jmobius.gameserver.network.serverpackets.StaticObject;
+
+/**
+ * This class loads, stores and spawns {@link StaticObject}s.
+ */
+public class StaticObjectData implements IXmlReader
+{
+ private final Map _objects = new HashMap<>();
+
+ protected StaticObjectData()
+ {
+ load();
+ }
+
+ @Override
+ public void load()
+ {
+ parseDatapackFile("data/StaticObjects.xml");
+ LOGGER.info(getClass().getSimpleName() + ": Loaded " + _objects.size() + " static objects.");
+ }
+
+ @Override
+ public void parseDocument(Document doc, File f)
+ {
+ // StatsSet used to feed informations. Cleaned on every entry.
+ final StatSet set = new StatSet();
+
+ // First element is never read.
+ final Node n = doc.getFirstChild();
+
+ for (Node node = n.getFirstChild(); node != null; node = node.getNextSibling())
+ {
+ if (!"object".equalsIgnoreCase(node.getNodeName()))
+ {
+ continue;
+ }
+
+ // Parse and feed content.
+ final NamedNodeMap attrs = node.getAttributes();
+ for (int i = 0; i < attrs.getLength(); i++)
+ {
+ final Node attr = attrs.item(i);
+ set.set(attr.getNodeName(), attr.getNodeValue());
+ }
+
+ // Create and spawn the StaticObject instance.
+ final StaticObjectInstance obj = new StaticObjectInstance(IdFactory.getInstance().getNextId());
+ obj.setType(set.getInt("type"));
+ obj.setStaticObjectId(set.getInt("id"));
+ obj.setXYZ(set.getInt("x"), set.getInt("y"), set.getInt("z"));
+ obj.setMap(set.getString("texture"), set.getInt("mapX"), set.getInt("mapY"));
+ obj.spawnMe();
+
+ // Feed the map with new data.
+ _objects.put(obj.getObjectId(), obj);
+ }
+ }
+
+ public Collection getStaticObjects()
+ {
+ return _objects.values();
+ }
+
+ public static StaticObjectData getInstance()
+ {
+ return SingletonHolder.INSTANCE;
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final StaticObjectData INSTANCE = new StaticObjectData();
+ }
+}
\ No newline at end of file