Skip to content

Commit

Permalink
Fixing packet issues!
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlackParade committed Jun 26, 2020
1 parent 6cd3910 commit ecadcd2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/net/data-parser/inbound-packet-data-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ export class InboundPacketDataParser extends DataParser {
this.activePacketId = this.activeBuffer.get('BYTE', 'UNSIGNED');
this.activePacketId = (this.activePacketId - inCipher.rand()) & 0xff;
const incomingPacket = incomingPackets.get(this.activePacketId);
if(!incomingPacket) {
// throw new Error(`Unknown packet ${this.activePacketId} received - aborting session.`);
logger.warn(`Unknown packet ${this.activePacketId} received.`);
this.activePacketSize = 0;
} else {
if(incomingPacket) {
this.activePacketSize = incomingPacket.size;
} else {
this.activePacketSize = -3;
}
}

Expand Down
7 changes: 0 additions & 7 deletions src/net/inbound-packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { logger } from '@runejs/logger';
import { getFiles } from '../util/files';
import { ByteBuffer } from '@runejs/byte-buffer';

const ignore = [ 234, 160, 216, 13, 58 /* camera move */ ];

interface InboundPacket {
opcode: number;
size: number;
Expand Down Expand Up @@ -32,11 +30,6 @@ export async function loadPackets(): Promise<Map<number, InboundPacket>> {
}

export function handlePacket(player: Player, packetId: number, packetSize: number, buffer: ByteBuffer): void {
if(ignore.indexOf(packetId) !== -1) {
return;
}

// const packetFunction = packets[packetId];
const incomingPacket = incomingPackets.get(packetId);

if(!incomingPacket) {
Expand Down
33 changes: 33 additions & 0 deletions src/net/inbound-packets/junk-packets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const handler = () => {};

export default [
{
opcode: 234,
size: 4,
handler: handler
}, {
opcode: 160,
size: 1,
handler: handler
}, {
opcode: 216,
size: 0,
handler: handler
}, {
opcode: 13,
size: 0,
handler: handler
}, {
opcode: 58, // camera move
size: 4,
handler: handler
}, {
opcode: 121,
size: 4,
handler: handler
}, {
opcode: 178,
size: 0,
handler: handler
}
];

0 comments on commit ecadcd2

Please sign in to comment.