runejs / server

RuneJS is a RuneScape game server written in TypeScript and JavaScript. The goal of the project is to create a comprehensive game engine, while also providing simple and easy to use content development systems and APIs.
GNU General Public License v3.0
242 stars 83 forks source link

[BUG] Default item spawn bug #292

Open hallowatcher opened 3 years ago

hallowatcher commented 3 years ago

Describe the bug If you move far enough away from a default item spawn, it will throw the following out of range exception: image

To Reproduce Steps to reproduce the behavior:

  1. Go to the wilderness
  2. Log out
  3. Log back in
  4. See error

Expected behavior No error should be thrown

Desktop (please complete the following information):

Here's a video of it happening, right on the chunk where it breaks: Video

From what I dug up, it seems to be this calculation that is generating an out of range X and Y (outbound-packets.ts) image

Maybe such items shouldn't spawn for the player instance when they are so far away?

Jameskmonger commented 2 years ago

Can confirm this is still an issue

gruckion commented 2 years ago

In case anyone else is searching for this issue

[2] [2022-09-07T15:02:25.898Z] ERROR (5468 on Sigexs-MBP.broadband): The value of "value" is out of range. It must be >= 0 and <= 255. Received 583
[2]     RangeError: The value of "value" is out of range. It must be >= 0 and <= 255. Received 583
[2]         at new NodeError (node:internal/errors:371:5)
[2]         at writeU_Int8 (node:internal/buffer:738:11)
[2]         at Packet.writeUInt8 (node:internal/buffer:748:10)
[2]         at Packet.put (/Users/sigex/workdir/rsps/server/node_modules/@runejs/src/buffer/byte-buffer.ts:158:40)
[2]         at OutboundPacketHandler.updateReferencePosition (/Users/sigex/workdir/rsps/server/src/engine/net/outbound-packet-handler.ts:228:16)
[2]         at OutboundPacketHandler.setWorldItem (/Users/sigex/workdir/rsps/server/src/engine/net/outbound-packet-handler.ts:181:14)
[2]         at WorldInstance.spawnWorldItem (/Users/sigex/workdir/rsps/server/src/engine/world/instances.ts:132:39)
[2]         at forEach (/Users/sigex/workdir/rsps/server/src/engine/world/world.ts:370:30)
[2]         at Array.forEach (<anonymous>)
[2]         at World.spawnWorldItems (/Users/sigex/workdir/rsps/server/src/engine/world/world.ts:367:14)