# HG changeset patch # User unC0Rr # Date 1738597925 -3600 # Node ID 36862a9ec59b35db49f98eb71985bf37f5b48d3f # Parent 004258297037212873d21f7b09e0aef5931a057b Update lib-hedgewars-engine to use newer versions of dependencies diff -r 004258297037 -r 36862a9ec59b rust/hwphysics/src/grid.rs --- a/rust/hwphysics/src/grid.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/hwphysics/src/grid.rs Mon Feb 03 16:52:05 2025 +0100 @@ -35,7 +35,7 @@ } } -const GRID_BIN_SIZE: usize = 128; +const GRID_BIN_SIZE: u32 = 128; pub struct Grid { bins: Vec, @@ -57,9 +57,9 @@ } } - fn linear_bin_index(&self, index: Point) -> usize { + fn linear_bin_index(&self, index: Point) -> u32 { self.bins_count - .linear_index(index.x as usize, index.y as usize) + .linear_index(index.x as u32, index.y as u32) } fn bin_index(&self, position: &FPPoint) -> Point { @@ -68,12 +68,12 @@ fn get_bin(&mut self, index: Point) -> &mut GridBin { let index = self.linear_bin_index(index); - &mut self.bins[index] + &mut self.bins[index as usize] } fn try_get_bin(&mut self, index: Point) -> Option<&mut GridBin> { let index = self.linear_bin_index(index); - self.bins.get_mut(index) + self.bins.get_mut(index as usize) } fn lookup_bin(&mut self, position: &FPPoint) -> &mut GridBin { diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/Cargo.toml --- a/rust/lib-hedgewars-engine/Cargo.toml Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/Cargo.toml Mon Feb 03 16:52:05 2025 +0100 @@ -6,10 +6,10 @@ build = "build.rs" [dependencies] -gl = "0.11" +gl = "0.14" netbuf = "0.4" -itertools = "0.10" -png = "0.13" +itertools = "0.14" +png = "0.17" fpnum = { path = "../fpnum" } land2d = { path = "../land2d" } @@ -20,13 +20,13 @@ hwphysics = { path = "../hwphysics" } mapgen = { path = "../mapgen" } vec2d = { path = "../vec2d" } -log = "0.4.21" +log = "0.4.25" [dev-dependencies] proptest = "0.9.2" [build-dependencies] -cbindgen = "0.24" +cbindgen = "0.28" [lib] name = "hedgewars_engine" diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/src/render/atlas.rs --- a/rust/lib-hedgewars-engine/src/render/atlas.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/src/render/atlas.rs Mon Feb 03 16:52:05 2025 +0100 @@ -35,27 +35,27 @@ #[derive(PartialEq, Eq)] pub struct UsedSpace { - used_area: usize, - total_area: usize, + used_area: u32, + total_area: u32, } impl UsedSpace { - const fn new(used_area: usize, total_area: usize) -> Self { + const fn new(used_area: u32, total_area: u32) -> Self { Self { used_area, total_area, } } - const fn used(&self) -> usize { + const fn used(&self) -> u32 { self.used_area } - const fn total(&self) -> usize { + const fn total(&self) -> u32 { self.total_area } - const fn free(&self) -> usize { + const fn free(&self) -> u32 { self.total_area - self.used_area } } @@ -93,7 +93,7 @@ } pub fn used_space(&self) -> UsedSpace { - let used = self.used_rects.iter().map(|(r, _)| r.size().area()).sum(); + let used = self.used_rects.iter().map(|(r, _)| r.size().area()).sum::(); UsedSpace::new(used, self.size.area()) } @@ -419,7 +419,7 @@ } } - fn sum_area(items: &[S]) -> usize { + fn sum_area(items: &[S]) -> u32 { items.iter().map(|s| s.size().area()).sum() } diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/src/render/camera.rs --- a/rust/lib-hedgewars-engine/src/render/camera.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/src/render/camera.rs Mon Feb 03 16:52:05 2025 +0100 @@ -22,7 +22,7 @@ pub fn viewport(&self) -> Rect { #[inline] - fn scale(value: usize, zoom: f32) -> i32 { + fn scale(value: u32, zoom: f32) -> i32 { (value as f32 / zoom / 2.0) as i32 } let half_width = scale(self.size.width, self.zoom); diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/src/render/gear.rs --- a/rust/lib-hedgewars-engine/src/render/gear.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/src/render/gear.rs Mon Feb 03 16:52:05 2025 +0100 @@ -131,7 +131,7 @@ .expect(&format!("Could not store sprite {:?}", sprite)); let (texture_index, rect) = atlas.get_rect(index).unwrap(); - let mut pixels = vec![255u8; size.area() * 4].into_boxed_slice(); + let mut pixels = vec![255u8; size.area() as usize * 4].into_boxed_slice(); load_sprite_pixels(path.as_path(), &mut pixels).expect("Unable to load Graphics"); texture.update( @@ -258,18 +258,20 @@ fn load_sprite_pixels(path: &Path, buffer: &mut [u8]) -> io::Result { let decoder = Decoder::new(BufReader::new(File::open(path)?)); - let (info, mut reader) = decoder.read_info()?; + let mut reader = decoder.read_info()?; + let info = reader.info(); - let size = Size::new(info.width as usize, info.height as usize); + let size = Size::new(info.width, info.height); reader.next_frame(buffer)?; Ok(size) } fn load_sprite_size(path: &Path) -> io::Result { let decoder = Decoder::new(BufReader::new(File::open(path)?)); - let (info, mut reader) = decoder.read_info()?; + let mut reader = decoder.read_info()?; + let info = reader.info(); - let size = Size::new(info.width as usize, info.height as usize); + let size = Size::new(info.width, info.height); Ok(size) } diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/src/render/gl.rs --- a/rust/lib-hedgewars-engine/src/render/gl.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/src/render/gl.rs Mon Feb 03 16:52:05 2025 +0100 @@ -91,10 +91,10 @@ fn is_out_of_bounds(data: &[u8], data_stride: Option, texture_size: Size) -> bool { let data_stride = get_u32(data_stride); - data_stride == 0 && texture_size.area() * 4 > data.len() + data_stride == 0 && texture_size.area() * 4 > data.len() as u32 || data_stride != 0 - && texture_size.width > data_stride as usize - && (texture_size.height * data_stride as usize) * 4 > data.len() + && texture_size.width > data_stride + && (texture_size.height * data_stride) * 4 > data.len() as u32 } impl Texture2D { @@ -193,7 +193,7 @@ } pub fn retrieve(&self, data: &mut [u8]) { - if self.size.area() * 4 > data.len() { + if self.size.area() * 4 > data.len() as u32 { return; } diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/src/render/map.rs --- a/rust/lib-hedgewars-engine/src/render/map.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/src/render/map.rs Mon Feb 03 16:52:05 2025 +0100 @@ -82,7 +82,7 @@ tile_layout: InputLayout, tile_size: Size, - num_tile_x: usize, + num_tile_x: u32, } impl MapRenderer { @@ -147,8 +147,8 @@ let tw = self.tile_size.width; let th = self.tile_size.height; - let lw = land.width(); - let lh = land.height(); + let lw = land.width() as u32; + let lh = land.height() as u32; let num_tile_x = lw / tw; let num_tile_y = lh / th; @@ -156,14 +156,14 @@ for y in 0..num_tile_y { for x in 0..num_tile_x { - let idx = x + y * num_tile_x; + let idx = (x + y * num_tile_x) as usize; let (data, stride) = { let bpp = 4; let offset = x * tw * bpp + y * th * lw * bpp; - let data = unsafe { &land.as_bytes()[offset..] }; + let data = unsafe { &land.as_bytes()[offset as usize..] }; let stride = land.width(); (data, NonZeroU32::new(stride as u32)) @@ -187,7 +187,7 @@ } else { let texture_region = Rect::at_origin(self.tile_size); - self.textures[idx].update( + self.textures[idx as usize].update( texture_region, data, stride, @@ -219,8 +219,8 @@ self.index_offset = 0; for (idx, tile) in self.tiles.iter().enumerate() { - let tile_x = idx % self.num_tile_x; - let tile_y = idx / self.num_tile_x; + let tile_x = idx as u32 % self.num_tile_x; + let tile_y = idx as u32 / self.num_tile_x; let tile_w = self.tile_size.width; let tile_h = self.tile_size.width; diff -r 004258297037 -r 36862a9ec59b rust/lib-hedgewars-engine/src/world.rs --- a/rust/lib-hedgewars-engine/src/world.rs Mon Feb 03 16:32:44 2025 +0100 +++ b/rust/lib-hedgewars-engine/src/world.rs Mon Feb 03 16:52:05 2025 +0100 @@ -59,7 +59,7 @@ let land_tile_size = Size::square(512); self.map_renderer = Some(MapRenderer::new(land_tile_size)); self.gear_renderer = Some(GearRenderer::new(&self.data_path.as_path())); - self.camera = Camera::with_size(Size::new(width as usize, height as usize)); + self.camera = Camera::with_size(Size::new(width as u32, height as u32)); if let Some(ref state) = self.game_state { self.camera.position = state.land.play_box().center(); @@ -75,7 +75,7 @@ let parameters = LandGenerationParameters::new(0u32, 0x8000u32, 0, false, false); let theme = Theme::load(self.data_path.join(Path::new("Themes/Cheese/")).as_path()).unwrap(); - let texture = MapGenerator::::new().make_texture( + let texture = MapGenerator::::new(&self.data_path).make_texture( &state.land, ¶meters, &theme,