Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsbuf"
version = "225.1.7"
version = "225.1.8"
edition = "2021"
authors = ["2004Scape"]
description = "A RuneScape update info computer."
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@2004scape/rsbuf",
"version": "225.1.7",
"version": "225.1.8",
"description": "A RuneScape update info computer",
"main": "dist/rsbuf.js",
"types": "dist/rsbuf.d.ts",
Expand Down
16 changes: 8 additions & 8 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ impl BuildArea {
y: u8,
z: u16
) -> bool {
if let Some(other) = unsafe { &*players.as_ptr().add(player as usize) } {
return !(self.players.contains(player) || !CoordGrid::within_distance_sw(&other.coord, &CoordGrid::from(x, y, z), self.view_distance) || other.pid == -1 || other.pid == pid || other.coord.y() != y);
}
return false;
return match unsafe { &*players.as_ptr().add(player as usize) } {
None => false,
Some(other) => !(self.players.contains(player) || !CoordGrid::within_distance_sw(&other.coord, &CoordGrid::from(x, y, z), self.view_distance) || other.pid == -1 || other.pid == pid || other.coord.y() != y),
};
}

#[inline]
Expand All @@ -320,9 +320,9 @@ impl BuildArea {
y: u8,
z: u16
) -> bool {
if let Some(other) = unsafe { &*npcs.as_ptr().add(npc as usize) } {
return !(self.npcs.contains(npc) || !CoordGrid::within_distance_sw(&other.coord, &CoordGrid::from(x, y, z), BuildArea::PREFERRED_VIEW_DISTANCE) || other.nid == -1 || other.coord.y() != y || !other.active);
}
return false;
return match unsafe { &*npcs.as_ptr().add(npc as usize) } {
None => false,
Some(other) => !(self.npcs.contains(npc) || !CoordGrid::within_distance_sw(&other.coord, &CoordGrid::from(x, y, z), BuildArea::PREFERRED_VIEW_DISTANCE) || other.nid == -1 || other.coord.y() != y || !other.active),
};
}
}
23 changes: 23 additions & 0 deletions src/category.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![allow(non_camel_case_types)]

use wasm_bindgen::prelude::wasm_bindgen;

#[repr(u8)]
#[wasm_bindgen]
// todo: measure how many events we should expect to receive from the client
// osrs has this as 50/10 but we know that's not true in rs2
// todo: determine which packets belong in which category for this era
pub enum ClientProtCategory {
CLIENT_EVENT = 0,
USER_EVENT = 1,
RESTRICTED_EVENT = 2, // flood restricted events
}

#[repr(u8)]
#[wasm_bindgen]
// packet decoding limit per tick, exceeding this ends decoding and picks up where it left off on the next tick
pub enum ClientProtCategoryLimit {
CLIENT_EVENT = 20,
USER_EVENT = 5,
RESTRICTED_EVENT = 2,
}
10 changes: 10 additions & 0 deletions src/coord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ impl CoordGrid {
pub const fn zone(pos: u16) -> u16 {
return pos >> 3;
}

#[inline]
pub const fn origin(pos: u16) -> u16 {
return ((pos >> 3) - 6) << 3;
}

#[inline]
pub const fn pack_zone_coord(x: u16, z: u16) -> u8 {
return (((x & 0x7) as u8) << 4) | (z & 0x7) as u8;
}
}
Loading