Fix issue preventing chunks from being loaded from disk
This commit is contained in:
parent
ad240d3598
commit
aea8c440d9
|
@ -13,7 +13,7 @@ import { IQueuedUpdate } from "./queuedUpdateTypes/IQueuedUpdate";
|
||||||
|
|
||||||
export class World {
|
export class World {
|
||||||
public static ENTITY_MAX_SEND_DISTANCE = 50;
|
public static ENTITY_MAX_SEND_DISTANCE = 50;
|
||||||
private static READ_CHUNKS_FROM_DISK = false;
|
private static READ_CHUNKS_FROM_DISK = true;
|
||||||
|
|
||||||
private readonly saveManager;
|
private readonly saveManager;
|
||||||
|
|
||||||
|
@ -88,10 +88,7 @@ export class World {
|
||||||
if (!(existingChunk instanceof Chunk)) {
|
if (!(existingChunk instanceof Chunk)) {
|
||||||
if (World.READ_CHUNKS_FROM_DISK && this.saveManager.chunksOnDisk.includes(coordPair)) {
|
if (World.READ_CHUNKS_FROM_DISK && this.saveManager.chunksOnDisk.includes(coordPair)) {
|
||||||
return this.saveManager.readChunkFromDisk(this, x, z)
|
return this.saveManager.readChunkFromDisk(this, x, z)
|
||||||
.then(chunk => {
|
.then(chunk => resolve(this.chunks.set(coordPair, chunk)));
|
||||||
//console.log("Loaded " + x + "," + z + " from disk");
|
|
||||||
resolve(this.chunks.set(coordPair, chunk));
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
resolve(this.chunks.set(coordPair, new Chunk(this, x, z, true)));
|
resolve(this.chunks.set(coordPair, new Chunk(this, x, z, true)));
|
||||||
if (World.READ_CHUNKS_FROM_DISK) {
|
if (World.READ_CHUNKS_FROM_DISK) {
|
||||||
|
|
|
@ -49,8 +49,8 @@ export class WorldSaveManager {
|
||||||
const chunkFiles = readdirSync(this.worldChunksFolderPath);
|
const chunkFiles = readdirSync(this.worldChunksFolderPath);
|
||||||
for (const file of chunkFiles) {
|
for (const file of chunkFiles) {
|
||||||
if (file.endsWith(".hwc")) {
|
if (file.endsWith(".hwc")) {
|
||||||
const numbers = file.split(".")[0].split(",");
|
const name = file.split(".")[0];
|
||||||
this.chunksOnDisk.push(Chunk.CreateCoordPair(parseInt(numbers[0]), parseInt(numbers[1])));
|
this.chunksOnDisk.push(parseInt(name.startsWith("-") ? name.replace("-", "-0x") : `0x${name}`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue