Skip to content

Commit 4330781

Browse files
authored
Merge pull request #379 from Jameskmonger/fix-typechecks
fix: fix typing issues uncovered by typecheck
2 parents fb623b9 + bce1270 commit 4330781

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

src/engine/net/inbound-packets/npc-interaction.packet.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { logger } from '@runejs/common';
2-
import { DataType, Endianness, Signedness } from '@runejs/common';
32

43
import { PacketData } from '@engine/net';
54
import { activeWorld, World } from '@engine/world';
@@ -8,14 +7,14 @@ import { Player } from '@engine/world/actor';
87
const npcInteractionPacket = (player: Player, packet: PacketData) => {
98
const { buffer, packetId } = packet;
109

11-
const args: { [key: number]: [ DataType, Signedness?, Endianness? ] } = {
12-
63: [ 'short', 'u', 'le' ],
13-
116: [ 'short', 'u', 'le' ],
14-
57: [ 'short', 'u' ],
10+
const packetReaders: Record<number, () => number> = {
11+
63: () => buffer.get('short', 'u', 'le'),
12+
116: () => buffer.get('short', 'u', 'le'),
13+
57: () => buffer.get('short', 'u'),
1514
/*42: 'readUnsignedShortLE',
1615
8: 'readUnsignedShortLE'*/
1716
};
18-
const npcIndex = buffer.get(...args[packetId]);
17+
const npcIndex = packetReaders[packetId]();
1918

2019
if (npcIndex < 0 || npcIndex > World.MAX_NPCS - 1) {
2120
return;

src/engine/net/inbound-packets/player-interaction.packet.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ import { logger } from '@runejs/common';
33
import { activeWorld, World } from '@engine/world';
44
import { Player, playerOptions } from '@engine/world/actor';
55
import { PacketData } from '@engine/net';
6-
import { DataType, Endianness, Signedness } from '@runejs/common';
76

87
const playerInteractionPacket = (player: Player, packet: PacketData) => {
98
const { buffer, packetId } = packet;
10-
const args: { [key: number]: [ DataType, Signedness?, Endianness? ] } = {
11-
68: [ 'short', 'u', 'le' ],
12-
211: [ 'short', 'u', 'le' ]
9+
10+
const packetReaders: Record<number, () => number> = {
11+
68: () => buffer.get('short', 'u', 'le'),
12+
211: () => buffer.get('short', 'u', 'le'),
1313
};
14-
const playerIndex = buffer.get(...args[packetId]) - 1;
14+
15+
const playerIndex = packetReaders[packetId]() - 1;
1516

1617
if(playerIndex < 0 || playerIndex > World.MAX_PLAYERS - 1) {
1718
return;

src/engine/util/strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const VALID_CHARS = ['_', 'a', 'b', 'c', 'd',
171171
'*', '(', ')', '-', '+', '=', ':', ';', '.', '>', '<', ',', '"',
172172
'[', ']', '|', '?', '/', '`'];
173173

174-
export function longToString(nameLong: BigInt): string {
174+
export function longToString(nameLong: bigint): string {
175175
let ac: string = '';
176176
while(nameLong !== BigInt(0)) {
177177
const l1 = nameLong;

src/plugins/objects/ladders/ladder.plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export const action: objectInteractionActionHandler = (details) => {
2121
]))
2222
.then(d => {
2323
d.close();
24-
switch (d._action.data) {
24+
switch (d.action) {
2525
case 1:
2626
case 2:
27-
action({ ...details, option: `climb-${(d._action.data === 1 ? 'up' : 'down')}` });
27+
action({ ...details, option: `climb-${(d.action === 1 ? 'up' : 'down')}` });
2828
return;
2929
}
3030
});

src/server/game/game-server.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ export let serverConfig: GameServerConfig;
2222
export let filestore: Filestore;
2323

2424

25-
export const openGatewayServer = (host: string, port: number): void =>
25+
export const openGatewayServer = (host: string, port: number): void => {
2626
SocketServer.launch<GatewayServer>(
2727
'Game Gateway Server',
2828
host, port, socket => new GatewayServer(socket));
29+
};
2930

3031

3132
/**
@@ -57,6 +58,3 @@ export async function launchGameServer(): Promise<void> {
5758
watchSource('src/').subscribe(() => world.saveOnlinePlayers());
5859
watchForChanges('dist/plugins/', /[/\\]plugins[/\\]/);
5960
}
60-
61-
62-

0 commit comments

Comments
 (0)