Fixed reading pathnode files.

This commit is contained in:
MobiusDev 2015-05-13 04:45:06 +00:00
parent 6d98405053
commit 70842dfabd
3 changed files with 7 additions and 17 deletions

View File

@ -9,9 +9,9 @@
# Default: 0
PathFinding = 0
# Pathnode directory
# Pathnode file directory
# Default: pathnode
PathnodeDirectory = pathnode
PathnodePath = pathnode
# Pathfinding array buffers configuration
PathFindBuffers = 100x6;128x6;192x6;256x4;320x4;384x4;500x2
@ -57,7 +57,7 @@ ForceGeoData = True
# Default: -1
CoordSynchronize = -1
# Geodata files folder
# Geodata file directory
GeoDataPath = geodata
# True: Try to load regions not specified below(won't disturb server startup when file does not exist)

View File

@ -1137,7 +1137,7 @@ public final class Config
// GeoData Settings
public static int PATHFINDING;
public static File PATHNODE_DIR;
public static Path PATHNODE_PATH;
public static String PATHFIND_BUFFERS;
public static float LOW_WEIGHT;
public static float MEDIUM_WEIGHT;
@ -2880,16 +2880,7 @@ public final class Config
final PropertiesParser geoData = new PropertiesParser(GEODATA_FILE);
try
{
PATHNODE_DIR = new File(geoData.getString("PathnodeDirectory", "pathnode").replaceAll("\\\\", "/")).getCanonicalFile();
}
catch (IOException e)
{
_log.log(Level.WARNING, "Error setting pathnode directory!", e);
PATHNODE_DIR = new File("pathnode");
}
PATHNODE_PATH = Paths.get(Config.DATAPACK_ROOT.getPath() + "/" + geoData.getString("PathnodePath", "pathnode"));
PATHFINDING = geoData.getInt("PathFinding", 0);
PATHFIND_BUFFERS = geoData.getString("PathFindBuffers", "100x6;128x6;192x6;256x4;320x4;384x4;500x2");
LOW_WEIGHT = geoData.getFloat("LowWeight", 0.5f);

View File

@ -27,7 +27,6 @@ import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
@ -399,7 +398,7 @@ public class GeoPathFinding extends PathFinding
{
_log.info("Path Engine: - Loading Path Nodes...");
//@formatter:off
Files.lines(Paths.get(Config.PATHNODE_DIR.getPath(), "pn_index.txt"), StandardCharsets.UTF_8)
Files.lines(Config.PATHNODE_PATH.resolve("pn_index.txt"), StandardCharsets.UTF_8)
.map(String::trim)
.filter(l -> !l.isEmpty())
.forEach(line -> {
@ -434,7 +433,7 @@ public class GeoPathFinding extends PathFinding
return;
}
short regionoffset = getRegionOffset(rx, ry);
File file = new File(Config.PATHNODE_DIR, rx + "_" + ry + ".pn");
File file = new File(Config.PATHNODE_PATH.toString(), rx + "_" + ry + ".pn");
_log.info("Path Engine: - Loading: " + file.getName() + " -> region offset: " + regionoffset + " X: " + rx + " Y: " + ry);
int node = 0, size, index = 0;