Skip to content

Commit 7f25e8d

Browse files
committed
Fixing some little issues with the game engine changes
1 parent 4eb453c commit 7f25e8d

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/game-engine/net/outbound-packets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ export class OutboundPackets {
608608
mapTileOffsetY = 12;
609609
}
610610

611-
const constructedChunk: ConstructedChunk | null = mapData.chunks[level][x][y];
611+
const constructedChunk: ConstructedChunk | null = mapData.chunks[level][mapTileOffsetX][mapTileOffsetY];
612612
packet.putBits(1, constructedChunk === null ? 0 : 1)
613613
if (constructedChunk !== null) {
614614
const { templatePosition, rotation } = constructedChunk;

src/game-engine/world/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ export class World {
8686

8787
const objectChunk = this.chunkManager.getChunkForWorldPosition(objectPosition);
8888

89+
let customMap = false;
8990
if(actor instanceof Player && actor.metadata.customMap) {
91+
customMap = true;
9092
const templateMapObject = this.findCustomMapObject(actor, objectId, objectPosition);
9193
if(templateMapObject) {
9294
return { object: templateMapObject, cacheOriginal: true };
9395
}
94-
95-
return { object: null, cacheOriginal: false };
9696
}
9797

9898
let cacheOriginal = true;
@@ -107,7 +107,7 @@ export class World {
107107
tileModifications = this.globalInstance.getTileModifications(objectPosition);
108108
}
109109

110-
let landscapeObject = objectChunk.getFilestoreLandscapeObject(objectId, objectPosition);
110+
let landscapeObject = customMap ? null : objectChunk.getFilestoreLandscapeObject(objectId, objectPosition);
111111
if(!landscapeObject) {
112112
const tileObjects = [ ...tileModifications.mods.spawnedObjects ];
113113

@@ -174,10 +174,21 @@ export class World {
174174
const mapTemplateWorldY = tileY;
175175
const mapTemplateChunk = world.chunkManager.getChunkForWorldPosition(new Position(mapTemplateWorldX, mapTemplateWorldY, objectPosition.level));
176176

177-
const templateObjectPosition = new Position(mapTemplateWorldX + getTemplateLocalX(tileOrientation, objectLocalX, objectLocalY),
178-
mapTemplateWorldY + getTemplateLocalY(tileOrientation, objectLocalX, objectLocalY), objectPosition.level);
177+
const templateLocalX = getTemplateLocalX(tileOrientation, objectLocalX, objectLocalY);
178+
const templateLocalY = getTemplateLocalY(tileOrientation, objectLocalX, objectLocalY);
179+
180+
if(actor instanceof Player) {
181+
actor.sendMessage(`Tile Orientation ${tileOrientation}, Local ${templateLocalX},${templateLocalY}`);
182+
}
183+
184+
const templateObjectPosition = new Position(mapTemplateWorldX + templateLocalX,
185+
mapTemplateWorldY + templateLocalY, objectPosition.level);
179186
const realObject = mapTemplateChunk.getFilestoreLandscapeObject(objectId, templateObjectPosition);
180187

188+
if(!realObject) {
189+
return null;
190+
}
191+
181192
realObject.x = objectPosition.x;
182193
realObject.y = objectPosition.y;
183194
realObject.level = objectPosition.level;

src/plugins/skills/construction/construction.plugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ const openHouse = (player: Player): void => {
5959
for(let chunkX = 0; chunkX < 13; chunkX++) {
6060
for(let chunkY = 0; chunkY < 13; chunkY++) {
6161
const room = house.rooms[plane][chunkX][chunkY];
62+
if(!room) {
63+
continue;
64+
}
6265
const templatePosition = room.templatePosition;
6366
const templateChunk = world.chunkManager.getChunk(templatePosition);
64-
67+
// ??? think this is just loading the template chunks into memory
6568
}
6669
}
6770
}

0 commit comments

Comments
 (0)