Skip to content

Commit

Permalink
Merge branch 'main' into roomxy_u8_range
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden committed Aug 18, 2024
2 parents b042307 + 9e63c8d commit ebc80f4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ Unreleased

- Change return type of `RoomXY::get_range_to` and input type of `RoomXY::in_range_to` to u8

### Additions:

- Make `RoomName::from_packed` and `RoomName::packed_repr` public

0.21.3 (2024-08-14)
===================

### Bugfixes:

- Temporarily pin to wasm-bindgen 0.2.92 due to incompatible generated javascript

0.21.2 (2024-08-14)
===================

### Bugfixes:

- Update for new string enum implementation in wasm-bindgen 0.2.93

### Misc:

- Move crate constant `ROOM_AREA` to extra constants module and make public
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "screeps-game-api"
version = "0.21.1"
version = "0.21.3"
authors = ["David Ross <[email protected]>"]
documentation = "https://docs.rs/screeps-game-api/"
edition = "2021"
Expand Down Expand Up @@ -39,7 +39,7 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_repr = "0.1"
serde-wasm-bindgen = "0.6"
wasm-bindgen = "0.2"
wasm-bindgen = "=0.2.92"

[dev-dependencies]
bincode = "1.3"
Expand Down
2 changes: 1 addition & 1 deletion src/constants/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ impl wasm_bindgen::convert::FromWasmAbi for MarketResourceType {
// try with IntershardResourceType
match IntershardResourceType::from_js_value(&s) {
Some(r) => Self::IntershardResource(r),
None => Self::Resource(ResourceType::__Nonexhaustive),
None => unreachable!("should have come from IntoWasmAbi"),
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/local/room_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ impl RoomName {
x.as_ref().parse()
}

/// Get the [`RoomName`] represented by a packed integer
#[inline]
pub(crate) const fn from_packed(packed: u16) -> Self {
pub const fn from_packed(packed: u16) -> Self {
RoomName { packed }
}

Expand Down Expand Up @@ -156,8 +157,12 @@ impl RoomName {
(self.packed & 0xFF) as i32 - HALF_WORLD_SIZE
}

/// Get the inner packed representation of the room name.
///
/// This data structure matches the implementation of the upper 16 bits of
/// the js Position type.
#[inline]
pub(super) const fn packed_repr(&self) -> u16 {
pub const fn packed_repr(&self) -> u16 {
self.packed
}

Expand Down

0 comments on commit ebc80f4

Please sign in to comment.