Initial commit

This commit is contained in:
CekisSWG
2019-02-21 11:39:09 -08:00
commit 060da45ee0
7 changed files with 778 additions and 0 deletions

1
README.md Normal file
View File

@@ -0,0 +1 @@
"# Snapshot Reader"

74
ShapshotReader.fxml Normal file
View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.111">
<tabs>
<Tab text="Untitled Tab 1">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<TableView prefHeight="200.0" prefWidth="200.0">
<columns>
<TableColumn prefWidth="75.0" text="C1" />
<TableColumn prefWidth="75.0" text="C2" />
</columns>
</TableView>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="10.0" prefWidth="75.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="30.0" minWidth="0.0" prefWidth="30.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="0.0" prefWidth="75.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="30.0" minWidth="0.0" prefWidth="30.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="10.0" prefWidth="75.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Object ID:" />
<Label text="&lt;object_id&gt;" GridPane.columnIndex="1" />
<Label text="Parent:" GridPane.rowIndex="1" />
<Label text="&lt;parent_id&gt;" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Template:" GridPane.rowIndex="2" />
<Label text="&lt;template&gt;" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="X:" GridPane.columnIndex="2" />
<Label text="Y:" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Label text="Z:" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Label text="QW:" GridPane.columnIndex="4" />
<Label text="QX:" GridPane.columnIndex="4" GridPane.rowIndex="1" />
<Label text="QY:" GridPane.columnIndex="4" GridPane.rowIndex="2" />
<Label text="QZ:" GridPane.columnIndex="4" GridPane.rowIndex="3" />
<Label text="&lt;x_val&gt;" GridPane.columnIndex="3" />
<Label text="&lt;y_val&gt;" GridPane.columnIndex="3" GridPane.rowIndex="1" />
<Label text="&lt;z_val&gt;" GridPane.columnIndex="3" GridPane.rowIndex="2" />
<Label text="&lt;qw_val&gt;" GridPane.columnIndex="5" />
<Label text="&lt;qx_val&gt;" GridPane.columnIndex="5" GridPane.rowIndex="1" />
<Label text="&lt;qy_val&gt;" GridPane.columnIndex="5" GridPane.rowIndex="2" />
<Label text="&lt;qz_val&gt;" GridPane.columnIndex="5" GridPane.rowIndex="3" />
</children>
</GridPane>
</children>
</VBox>
</content>
</Tab>
<Tab text="Untitled Tab 2">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>

77
SnapshotReader.java Normal file
View File

@@ -0,0 +1,77 @@
/**
* Created by Cekis on 2/20/2017.
*/
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
import swg.WSFile;
import java.io.IOException;
public class SnapshotReader extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws IOException {
primaryStage.setTitle("SWG Snapshot Viewer");
TabPane tabView = new TabPane();
Tab tab = new Tab();
tab.closableProperty().setValue(false);
tab.setText("lok.ws");
TableView dataTable = new TableView();
ObservableList cols = dataTable.getColumns();
cols.add(makeColumn("Object ID", "id",75));
cols.add(makeColumn("Parent ID", "parentId", 75));
cols.add(makeColumn("Template", "template", dataTable, 550d));
cols.add(makeColumn("Index", "nodeIndex", 50));
cols.add(makeColumn("X", "x", 50));
cols.add(makeColumn("Y", "y", 50));
cols.add(makeColumn("Z", "z", 50));
cols.add(makeColumn("QW", "objW",50));
cols.add(makeColumn("QX", "objX",50));
cols.add(makeColumn("QY", "objY",50));
cols.add(makeColumn("QZ", "objZ",50));
tab.setContent(dataTable);
tabView.getTabs().add(tab);
WSFile wsFile = new WSFile();
wsFile.readFile("snapshot/lok.ws");
tab.setText(wsFile.getAreaName() + ".ws");
ObservableList data = FXCollections.observableArrayList(wsFile.getAllNodes().toArray());
dataTable.setItems(data);
Scene scene = new Scene(tabView, 300, 275);
primaryStage.setScene(scene);
primaryStage.show();
}
private TableColumn makeColumn(String name, String property, double width){
TableColumn newCol = new TableColumn();
newCol.setPrefWidth(width);
newCol.setText(name);
newCol.setCellValueFactory(new PropertyValueFactory(property));
return newCol;
}
private TableColumn makeColumn(String name, String property, TableView dt, double diff){
TableColumn newCol = new TableColumn();
newCol.prefWidthProperty().bind(dt.widthProperty().subtract(diff));
newCol.setText(name);
newCol.setCellValueFactory(new PropertyValueFactory(property));
return newCol;
}
}

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<AnchorPane xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0">
<children>
<TableView VBox.vgrow="ALWAYS">
<columns>
<TableColumn prefWidth="75.0" text="Object ID" />
<TableColumn prefWidth="75.0" text="Parent ID" />
<TableColumn maxWidth="1.7976931348623157E308" prefWidth="250.0" text="Template" />
<TableColumn prefWidth="50.0" text="Index" />
<TableColumn prefWidth="50.0" text="X" />
<TableColumn prefWidth="50.0" text="Y" />
<TableColumn prefWidth="50.0" text="Z" />
<TableColumn prefWidth="50.0" text="QW" />
<TableColumn prefWidth="50.0" text="QX" />
<TableColumn prefWidth="50.0" text="QY" />
<TableColumn prefWidth="50.0" text="QZ" />
</columns>
</TableView>
<GridPane minHeight="100.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="10.0" prefWidth="75.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="30.0" minWidth="0.0" prefWidth="30.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="0.0" prefWidth="75.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="30.0" minWidth="0.0" prefWidth="30.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="75.0" minWidth="10.0" prefWidth="75.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Object ID:" />
<Label text="&lt;object_id&gt;" GridPane.columnIndex="1" />
<Label text="Parent:" GridPane.rowIndex="1" />
<Label text="&lt;parent_id&gt;" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="Template:" GridPane.rowIndex="2" />
<Label text="&lt;template&gt;" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="X:" GridPane.columnIndex="2" />
<Label text="Y:" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Label text="Z:" GridPane.columnIndex="2" GridPane.rowIndex="2" />
<Label text="QW:" GridPane.columnIndex="4" />
<Label text="QX:" GridPane.columnIndex="4" GridPane.rowIndex="1" />
<Label text="QY:" GridPane.columnIndex="4" GridPane.rowIndex="2" />
<Label text="QZ:" GridPane.columnIndex="4" GridPane.rowIndex="3" />
<Label text="&lt;x_val&gt;" GridPane.columnIndex="3" />
<Label text="&lt;y_val&gt;" GridPane.columnIndex="3" GridPane.rowIndex="1" />
<Label text="&lt;z_val&gt;" GridPane.columnIndex="3" GridPane.rowIndex="2" />
<Label text="&lt;qw_val&gt;" GridPane.columnIndex="5" />
<Label text="&lt;qx_val&gt;" GridPane.columnIndex="5" GridPane.rowIndex="1" />
<Label text="&lt;qy_val&gt;" GridPane.columnIndex="5" GridPane.rowIndex="2" />
<Label text="&lt;qz_val&gt;" GridPane.columnIndex="5" GridPane.rowIndex="3" />
<Label text="Index:" GridPane.rowIndex="3" />
<Label text="&lt;index&gt;" GridPane.columnIndex="1" GridPane.rowIndex="3" />
</children>
<VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin>
</GridPane>
</children>
</VBox>
</children>
</AnchorPane>

29
main.java Normal file
View File

@@ -0,0 +1,29 @@
import swg.WSFile;
import java.io.File;
/**
* Created by Cekis on 2/18/2017.
*/
public class main {
public static void main(String[] args)
{
if(args != null){
switch(args.length){
case 0:
File f = new File("snapshot");
for(File file : f.listFiles()){
WSFile snapshot = new WSFile();
snapshot.readFile("snapshot/" + file.getName());
}
break;
case 1:
WSFile snapshot = new WSFile();
snapshot.readFile(args[0]);
break;
default:
break;
}
}
}
}

291
swg/WSFile.java Normal file
View File

@@ -0,0 +1,291 @@
package swg;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Cekis on 2/18/2017.
*/
public class WSFile {
private List<WSNode> _nodes;
private String[] _types;
private String _fileName;
private String _areaName;
public List<WSNode> getNodes() {
if(_nodes == null){
_nodes = new ArrayList<>();
}
return _nodes;
}
public void setNodes(List<WSNode> _nodes) {
this._nodes = _nodes;
}
public String[] getTypes() {
return _types;
}
public void setTypes(String[] _types) {
this._types = _types;
}
public String getFileName() {
return _fileName;
}
public void setFileName(String fileName) {
this._fileName = fileName;
}
public String getAreaName() {
return _areaName;
}
public void setAreaName(String area) {
this._areaName = area;
}
public void readFile(String filename){
try{
_areaName = filename.replaceAll("snapshot/","").replaceAll(".ws","");
parseFile(new File(filename));
}
catch(Exception e){
e.printStackTrace();
}
}
private void parseFile(File file) throws IOException {
FileInputStream fis = null;
BufferedInputStream bi = null;
try {
byte[] FORM = new byte[4];
byte[] WSNPFORM = new byte[8];
byte[] t0001FORM = new byte[8];
byte[] lengthBuff = new byte[4];
byte[] OTNL = new byte[4];
fis = new FileInputStream(file);
bi = new BufferedInputStream(fis);
bi.read(FORM);
bi.read(new byte[4]); // length of form
bi.read(WSNPFORM);
bi.read(new byte[4]); // length of wsnpform
bi.read(t0001FORM);
bi.read(lengthBuff); // length of t0001form
int buffLength = ByteBuffer.wrap(lengthBuff).getInt();
byte[] nodesBuffer = new byte[buffLength];
bi.read(nodesBuffer);
bi.read(OTNL); // OTNL
bi.read(new byte[4]); // length of OTNL
bi.read(new byte[4]); // count (string)
List<String> listTypes = new ArrayList<>();
String type = "";
while(bi.available() > 0){
byte[] ba = new byte[1];
bi.read(ba);
while(ba[0] != 0){
type += (char) ba[0];
bi.read(ba);
}
listTypes.add(type);
type = "";
}
_types = listTypes.toArray(new String[listTypes.size()]);
parseNodes(nodesBuffer);
//System.out.println("objid\tcontainer\tserver_template_crc\tcell_index\tpx\tpy\tpz\tqw\tqx\tqy\tqz\tscripts\tobjvars");
//System.out.println("i\ti\th\ti\tf\tf\tf\tf\tf\tf\tf\ts\tp");
//printNodes(_nodes);
//saveNodesToFiles(_nodes);
}
catch(Exception e){
e.printStackTrace();
}
finally{
if(bi != null){
bi.close();
}
if(fis != null){
fis.close();
}
}
}
private void parseNodes(byte[] data) throws IOException {
int remaining = 0;
byte[] FORM = new byte[4];
byte[] formBuffer = new byte[4];
byte[] NODEFORM = new byte[8];
byte[] t0000DATA = new byte[8];
byte[] value = new byte[4];
WSNode tempNode = null;
BufferedInputStream bis = new BufferedInputStream(new ByteArrayInputStream(data));
try {
while (remaining < data.length) {
// header data
bis.read(FORM);
bis.read(formBuffer); // length
if(WSFile.IsAlpha(formBuffer)){
bis.read(new byte[4]);
remaining += 4;
}
bis.read(NODEFORM);
bis.read(new byte[4]); // length
bis.read(t0000DATA);
bis.read(new byte[4]); // length
remaining += 32; // total of header data
// start reading actual node
WSNode node = new WSNode();
bis.read(value);
node.setId(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getInt());
bis.read(value);
node.setParentId(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getInt());
bis.read(value);
node.setObjIndex(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getInt());
node.setTemplate(getTypes()[node.getObjIndex()]);
bis.read(value); // no idea what this value is supposed to be.
bis.read(value);
node.setObjW(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setObjX(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setObjY(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setObjZ(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setX(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setY(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setZ(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setType(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getFloat());
bis.read(value);
node.setPOBCRC(ByteBuffer.wrap(value).order(ByteOrder.LITTLE_ENDIAN).getInt());
// 13 * 4 is 13 values read * 4 bytes each.
remaining += (13 * 4);
// add the node to our list of nodes.
if(node.getParentId() == 0) {
getNodes().add(node);
}
else{
tempNode = FindNodeById(node.getParentId());
if(tempNode == null){
throw new Exception("Parent Node " + node.getParentId() + " could not be found!");
}
tempNode.getNodes().add(node);
}
}
}
catch(Exception e){
System.out.println("EXCEPTION: " + e.getMessage());
e.printStackTrace();
}
finally {
bis.close();
}
}
// IsAlpha identifies if this is the first node or not. If so, we need to offset the read 4 bytes to make sure stuff lines up.
private static boolean IsAlpha(byte[] data) {
for (byte character : data) {
if ((((character <= 0x2f) || (character >= 0x3a)) && ((character <= 0x40) || (character >= 0x5c))) && (character != 0x20)) {
return false;
}
}
return true;
}
private WSNode FindNodeById(int parentId){
if(getNodes().size() > 0){
return FindChildren(parentId, getNodes().toArray(new WSNode[getNodes().size()]));
}
return null;
}
private WSNode FindChildren(int id, WSNode[] nodes){
for (WSNode node : nodes){
if(node == null) continue;
if(node.getId() == id){
return node;
}
else{
if(node.hasChildNodes()){
WSNode returnVal = FindChildren(id, node.getNodes().toArray(new WSNode[getNodes().size()]));
if(returnVal != null){
return returnVal;
}
}
}
}
return null;
}
private void saveNodesToFiles(List<WSNode> nodes) throws IOException {
String area = getAreaName();
String oldDir = "output/" + area;
File rmDir = new File(oldDir);
if(rmDir.exists()){
System.out.print("Removing files from folder " + area + "... ");
boolean result = false;
for(File f : rmDir.listFiles()){
result = f.delete();
if(!result) break;
}
System.out.println((result ? "removed." : "not removed."));
if(!result) System.exit(1);
System.out.print("Removing folder " + area + "... ");
System.out.println((rmDir.delete() ? "removed." : "not removed."));
}
boolean newFile = false;
for (WSNode node : nodes) {
int x = (int) Math.floor((double) (node.getX() + 8192) / 2048) + 1;
int y = (int) Math.floor((double) (node.getZ() + 8192) / 2048) + 1;
String fileName = "output/" + area + "/" + area + "_" + x + "_" + y + "_ws.tab";
File outFile = new File(fileName);
if(!outFile.exists()){
outFile.getParentFile().mkdirs();
newFile = true;
}
Writer writer;
try {
FileWriter fw = new FileWriter(outFile, true);
if(newFile){
fw.write("objid\tcontainer\tserver_template_crc\tcell_index\tpx\tpy\tpz\tqw\tqx\tqy\tqz\tscripts\tobjvars\n");
fw.write("i\ti\th\ti\tf\tf\tf\tf\tf\tf\tf\ts\tp\n");
}
fw.write(node.serialize(0,true));
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
newFile = false;
}
}
public List<WSNode> getAllNodes(){
List<WSNode> tmp = new ArrayList<>();
for (WSNode node : _nodes) {
tmp.add(node);
if(node.hasChildNodes()){
tmp.addAll(node.getAllNodes());
}
}
return tmp;
}
}

228
swg/WSNode.java Normal file
View File

@@ -0,0 +1,228 @@
package swg;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Cekis on 2/18/2017.
*/
public class WSNode {
private int _id;
private int _parentId;
private int _nodeIndex;
private int _objIndex;
private float _objX;
private float _objY;
private float _objZ;
private float _objW;
private float _objScale;
private float _x;
private float _y;
private float _z;
private float _type;
private int _POBCRC;
private WSNode _parent;
private List<WSNode> _childNodes;
private String template;
public WSNode(){}
public WSNode(int id, int parentId, int objIndex, byte ox, byte oy, byte oz, byte ow, byte scale, byte x, byte y, byte z, byte type, int unknown){
this._id = id;
this._parentId = parentId;
this._objIndex = objIndex;
this._objX = ox;
this._objY = oy;
this._objZ = oz;
this._objW = ow;
this._objScale = scale;
this._type = type;
this._x = x;
this._y = y;
this._z = z;
this._POBCRC = unknown;
}
public int getId(){
return _id;
}
public void setId(int id){
_id = id;
}
public int getParentId() {
return _parentId;
}
public void setParentId(int _parentId) {
this._parentId = _parentId;
}
public int getObjIndex() {
return _objIndex;
}
public void setObjIndex(int _oIndex) {
this._objIndex = _oIndex;
}
public float getObjX() {
return _objX;
}
public void setObjX(float _oX) {
this._objX = _oX;
}
public float getObjY() {
return _objY;
}
public void setObjY(float _objY) {
this._objY = _objY;
}
public float getObjZ() {
return _objZ;
}
public void setObjZ(float _objZ) {
this._objZ = _objZ;
}
public float getObjScale() {
return _objScale;
}
public void setObjScale(float _objScale) {
this._objScale = _objScale;
}
public float getX() {
return _x;
}
public void setX(float _x) {
this._x = _x;
}
public float getY() {
return _y;
}
public void setY(float _y) {
this._y = _y;
}
public float getZ() {
return _z;
}
public void setZ(float _z) {
this._z = _z;
}
public float getObjW() {
return _objW;
}
public void setObjW(float _objW) {
this._objW = _objW;
}
public float getType() {
return _type;
}
public void setType(float _type) {
this._type = _type;
}
public int getPOBCRC() {
return _POBCRC;
}
public void setPOBCRC(int _POBCRC) {
this._POBCRC = _POBCRC;
}
public WSNode getParent() {
return _parent;
}
public void setParent(WSNode _parent) {
this._parent = _parent;
}
public List<WSNode> getNodes() {
if(_childNodes == null){
_childNodes = new ArrayList<>();
}
return _childNodes;
}
public void setNodes(List<WSNode> _nodes) {
this._childNodes = _nodes;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
public int getNodeIndex() {
return _nodeIndex;
}
public void setNodeIndex(int _nodeIndex) {
this._nodeIndex = _nodeIndex;
}
public boolean hasChildNodes(){
return getNodes().size() > 0;
}
public String serialize(int index, boolean relative){
String outLine = "";
outLine += getId() + "\t";
outLine += getParentId() + "\t";
outLine += getTemplate() + "\t";
outLine += index + "\t";
outLine += (relative ? ((getX() + 8192) % 2048) : getX()) + "\t";
outLine += getY() + "\t";
outLine += (relative ? ((getZ() + 8192) % 2048) : getZ()) + "\t";
outLine += getObjW() + "\t";
outLine += getObjX() + "\t";
outLine += getObjY() + "\t";
outLine += getObjZ() + "\t";
outLine += "\t";
outLine += (getPOBCRC() != 0 ? "portalProperty.crc|0|" + getPOBCRC() + "|" : "");
outLine += "$|\n";
if(hasChildNodes()){
int nSize = _childNodes.size();
for(int j = 0; j < nSize; j++){
WSNode node = _childNodes.get(j);
outLine += node.serialize(j + 1, false);
}
}
return outLine;
}
public List<WSNode> getAllNodes(){
List<WSNode> tmp = new ArrayList<>();
int i = 1;
for (WSNode node : _childNodes) {
node.setNodeIndex(i++);
tmp.add(node);
if(node.hasChildNodes()){
tmp.addAll(node.getAllNodes());
}
}
return tmp;
}
}