RuneWiki Old Engine/On Demand Protocol

Old Engine/On Demand Protocol

From RuneWiki
Revision as of 12:18, 8 September 2021 by Pazaz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The client beginning to load extra files via on demand


Data Types

Old Engine/File Store


The client begins by sending a single byte, 15.

The server should respond with eight bytes. Their values are ignored, but send 0s here anyways.

After this point the client stream is dedicated to on demand requests and will begin requesting missing data from the server.


Each request looks like this, and there may be multiple requests appended in a single read:

  • First byte is the index
  • Second word is the entry
  • Third byte is the priority

The priority field has 3 possible values:

  • 2: loading core files
  • 1: preloading extra files
  • 0: loading file in-game


The client will read up to 506-bytes from the server at a time. 6 bytes are used for the file part header and up to 500 bytes are used for the file data. If a file is longer than 500 bytes (very likely) then the file must be sent in 500-byte increments.

File parts may be sent over time and do not need to be sent sequentially. This helps decrease the load on the server assuming it gets processed over time.

The response looks like this:

  • First byte is the index
  • Second and third byte is the entry
  • Fourth and fifth byte is the total file size
  • Sixth byte is the part number
  • The remaining (up to) 500 bytes is the file part data


while (data.length() > data.offset) {
    let index = data.readByte();
    let entry = data.readWord();
    let priority = data.readByte();

    if (priority === 2) {
        coreQueue.push({ socket, index, entry, priority });
    } else if (priority == 1) {
        preloadQueue.push({ socket, index, entry, priority });
    } else if (priority == 0) {
        ingameQueue.push({ socket, index, entry, priority });


let sendBuffer = Buffer.alloc(6);
sendBuffer.writeUInt8(request.index, 0);
sendBuffer.writeUInt16BE(request.entry, 1);
sendBuffer.writeUInt16BE(file.length, 3);
sendBuffer.writeUInt8(request.part, 5);
let offset = i * 500;
if (offset + 500 < file.length) {
    sendBuffer = Buffer.concat([sendBuffer, file.slice(offset, offset + 500)]);
} else {
    sendBuffer = Buffer.concat([sendBuffer, file.slice(offset)]);