Skip to content

Commit 22be598

Browse files
committed
Fixing 255/255 issue and 1.1.1 bump
1 parent 3122b43 commit 22be598

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@runejs/update-server",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "RuneJS Game Update Server",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/update-server.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { logger } from '@runejs/core';
22
import { ByteBuffer } from '@runejs/core/buffer';
33
import { openServer, SocketConnectionHandler, parseServerConfig } from '@runejs/core/net';
4-
import { Filestore, readDataChunk, readIndexedDataChunk } from '@runejs/filestore';
4+
import { Filestore, readIndexedDataChunk } from '@runejs/filestore';
55
import { Socket } from 'net';
66
import * as CRC32 from 'crc-32';
77

@@ -50,9 +50,9 @@ class UpdateServerConnection extends SocketConnectionHandler {
5050
break;
5151
case ConnectionStage.ACTIVE:
5252
while(buffer.readable >= 4) {
53-
const type = buffer.get('BYTE', 'UNSIGNED');
54-
const index = buffer.get('BYTE', 'UNSIGNED');
55-
const file = buffer.get('SHORT', 'UNSIGNED');
53+
const type = buffer.get('byte', 'u');
54+
const index = buffer.get('byte', 'u');
55+
const file = buffer.get('short', 'u');
5656

5757
switch(type) {
5858
case 0: // queue
@@ -86,13 +86,17 @@ class UpdateServerConnection extends SocketConnectionHandler {
8686
}
8787

8888
private generateFile(index: number, file: number): Buffer {
89-
let cacheFile: ByteBuffer | any; // @todo remove any when cache parser is using @runejs/core
90-
91-
if(index === 255 && file === 255) {
92-
cacheFile = new ByteBuffer(this.updateServer.crcTable.length);
93-
this.updateServer.crcTable.copy(cacheFile, 0, 0);
94-
} else {
95-
cacheFile = this.updateServer.filestore.getIndex(index)?.getFile(file)?.content;
89+
let cacheFile: ByteBuffer;
90+
91+
try {
92+
if(index === 255 && file === 255) {
93+
cacheFile = new ByteBuffer(this.updateServer.crcTable.length);
94+
this.updateServer.crcTable.copy(cacheFile, 0, 0);
95+
} else {
96+
cacheFile = readIndexedDataChunk(file, index, this.updateServer.filestore.channels).dataFile;
97+
}
98+
} catch(error) {
99+
logger.warn(`Unable to load filestore file for update server request`, index, file);
96100
}
97101

98102
if(!cacheFile || cacheFile.length === 0) {

0 commit comments

Comments
 (0)