diff --git a/CHANGELOG.md b/CHANGELOG.md index aecad2c1..855a2ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Unreleased - Implement `JsCollectionIntoValue` for `Direction`, making the `JsHashMap` returned by `game::map::describe_exits` able to be used +- Handle object return properly from `RoomTerrain::get_raw_buffer_to_array` when built in dev mode 0.16.1 (2023-10-11) =================== diff --git a/src/objects/impls/room_terrain.rs b/src/objects/impls/room_terrain.rs index 4dfe77e6..6b61cccc 100644 --- a/src/objects/impls/room_terrain.rs +++ b/src/objects/impls/room_terrain.rs @@ -30,7 +30,7 @@ extern "C" { // and when called with a destination, it can only ever return a return code int #[wasm_bindgen(method, js_name = getRawBuffer)] - fn get_raw_buffer_to_array_internal(this: &RoomTerrain, destination: &Uint8Array) -> i8; + fn get_raw_buffer_to_array_internal(this: &RoomTerrain, destination: &Uint8Array) -> JsValue; } impl RoomTerrain { @@ -58,6 +58,13 @@ impl RoomTerrain { /// [Screeps documentation](https://docs.screeps.com/api/#Room.Terrain.getRawBuffer) #[inline] pub fn get_raw_buffer_to_array(&self, destination: &Uint8Array) -> Result<(), ErrorCode> { - ErrorCode::result_from_i8(self.get_raw_buffer_to_array_internal(destination)) + let val = self.get_raw_buffer_to_array_internal(destination); + + // val is integer if error; if object it's another reference to the Uint8Array; + // function was successful in that case + match val.as_f64() { + Some(n) => ErrorCode::result_from_i8(n as i8), + None => Ok(()), + } } }