Skip to content

Commit 2b4840c

Browse files
committed
Fix grass on other levels.
1 parent 83b1336 commit 2b4840c

File tree

4 files changed

+19
-32
lines changed

4 files changed

+19
-32
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { xteaRegions } from '@engine/config';
1414
import { world } from '@engine/game-server';
1515
import { ConstructedMap } from '@engine/world/map/region';
1616
import { map } from 'rxjs/operators';
17+
import { Room } from '@plugins/skills/construction/con-house';
1718

1819
/**
1920
* A helper class for sending various network packets back to the game client.
@@ -606,14 +607,15 @@ export class OutboundPackets {
606607
if(mapTileOffsetY > 12) {
607608
mapTileOffsetY = 12;
608609
}
609-
610-
const tileData: number | null = mapData.tileData[level][mapTileOffsetX][mapTileOffsetY];
611-
packet.putBits(1, tileData === null && !mapData.emptySpace ? 0 : 1);
612-
613-
if(tileData !== null) {
614-
packet.putBits(26, tileData);
615-
} else if(mapData.emptySpace) {
616-
packet.putBits(26, mapData.emptySpace);
610+
611+
const room: Room | null = mapData.rooms[level][x][y];
612+
packet.putBits(1, room === null ? 0 : 1)
613+
if (room !== null) {
614+
packet.putBits(2, room.position.level & 0x3)
615+
packet.putBits(10, room.position.x / 8)
616+
packet.putBits(11, room.position.y / 8)
617+
packet.putBits(2, room.rotation)
618+
packet.putBits(1, 0) //unused
617619
}
618620
}
619621
}

src/game-engine/world/map/region.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* chunk: 8x8 tile chunk within a map.
55
*/
66
import { Position } from '@engine/world/position';
7+
import { Room } from '@plugins/skills/construction/con-house';
78

89
export type RegionType = 'map' | 'chunk';
910

@@ -25,8 +26,7 @@ export const regionSizes: RegionSizeMap = {
2526

2627
export interface ConstructedMap {
2728
position: Position;
28-
emptySpace?: number;
29-
tileData: number[][][];
29+
rooms: Room[][][];
3030
centerOffsetX?: number;
3131
centerOffsetY?: number;
3232
}

src/plugins/skills/construction/con-house.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ export class House {
1616
}
1717
}
1818

19-
public getRoomData(): number[][][] {
20-
const roomData = new Array(4);
21-
for(let level = 0; level < 4; level++) {
22-
roomData[level] = new Array(MAP_SIZE);
23-
for(let x = 0; x < MAP_SIZE; x++) {
24-
roomData[level][x] = new Array(MAP_SIZE);
25-
for(let y = 0; y < MAP_SIZE; y++) {
26-
roomData[level][x][y] = this.rooms[level][x][y]?.roomData || null;
27-
}
28-
}
29-
}
30-
31-
return roomData;
32-
}
33-
3419
public getRoom(position: Position): Room {
3520
return this.rooms[position.level][position.x][position.y];
3621
}
@@ -42,16 +27,15 @@ export class Room {
4227

4328
public readonly type: RoomType;
4429

45-
public orientation: number;
30+
public rotation: number;
4631

4732
public constructor(type: RoomType, orientation: number = 0) {
4833
this.type = type;
49-
this.orientation = orientation;
34+
this.rotation = orientation;
5035
}
5136

52-
public get roomData(): number {
53-
const { x, y, level } = roomTemplates[this.type];
54-
return x / 8 << 14 | y / 8 << 3 | level % 4 << 24 | this.orientation % 4 << 1;
37+
public get position(): Position {
38+
return roomTemplates[this.type];
5539
}
5640

5741
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const openHouse = (player: Player): void => {
3030
house.rooms[0][x][y] = thirdParlor;
3131
} else if(x === 6 && y === 7) {
3232
house.rooms[0][x][y] = fourthParlor;
33+
} else {
34+
house.rooms[0][x][y] = emptySpace;
3335
}
3436
}
3537
}
@@ -48,8 +50,7 @@ const openHouse = (player: Player): void => {
4850

4951
player.metadata.customMap = {
5052
position: pohPosition,
51-
emptySpace: emptySpace.roomData,
52-
tileData: house.getRoomData()
53+
rooms: house.rooms
5354
} as ConstructedMap;
5455

5556
player.sendMessage(`Welcome home.`);

0 commit comments

Comments
 (0)