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