From e378598a9c714b9d9fbb7d33947bae464c4f1aaa Mon Sep 17 00:00:00 2001 From: core Date: Fri, 28 Mar 2025 09:14:49 -0400 Subject: [PATCH] asset system cleanup --- crates/api/src/routes/sign_save.rs | 4 ++-- crates/client/src/lib.rs | 6 +++--- crates/client/src/networking/mod.rs | 15 +++++++-------- crates/client/src/rendering/mod.rs | 11 +++++------ crates/client/src/ui/colors.rs | 1 + crates/client/src/wasm/assets.rs | 2 +- crates/common/src/lib.rs | 2 +- 7 files changed, 20 insertions(+), 21 deletions(-) diff --git a/crates/api/src/routes/sign_save.rs b/crates/api/src/routes/sign_save.rs index 16de2cdba8bd225794433525f98e268479874a01..2c75965a6373007860391b887f58cf0026f067e7 100644 --- a/crates/api/src/routes/sign_save.rs +++ b/crates/api/src/routes/sign_save.rs @@ -24,7 +24,7 @@ use actix_web::{ use log::error; use serde::{Deserialize, Serialize}; use starkingdoms_common::{ - __noverify__unpack_savefile, pack_savefile, unpack_savefile, PartType, SaveModule, + __noverify_unpack_savefile, pack_savefile, unpack_savefile, PartType, SaveModule, }; use std::collections::HashMap; use std::hash::Hash; @@ -63,7 +63,7 @@ pub async fn sign_save_req( state: Data, ) -> JsonAPIResponse { let old_save = handle_error!(unpack_savefile(&state.key_raw, req.old_save.clone())); - let new_save = handle_error!(__noverify__unpack_savefile(req.new_partial.clone())); + let new_save = handle_error!(__noverify_unpack_savefile(req.new_partial.clone())); // ensure part counts are the same let mut part_counts_old: HashMap = HashMap::new(); diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index 5226f6d71a894d1d7b9c7feb94e2821496f0f981..bc21badba369120884d7833cf01df18b028f8b86 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -1,13 +1,13 @@ use bevy_ecs::{event::Events, world::World}; -use components::{Camera, Chat, Menu, Part, Player, RecvPacket, SendPacket, Texture, Transform}; -use nalgebra::{Rotation2, Rotation3, Scale2, Scale3, Translation2, Translation3, Vector3}; +use components::{Camera, Chat, Part, Player, RecvPacket, SendPacket, Texture, Transform}; +use nalgebra::{Rotation2, Scale3, Translation3}; use networking::ws::Ws; use rendering::App; use platform::assets::Assets; -use starkingdoms_common::packet::Packet; use tracing::info; use winit::event_loop::{ControlFlow, EventLoop}; use crate::components::PlayerResources; +use rendering::assets::AssetLoader; #[cfg(target_arch = "wasm32")] #[path = "wasm/mod.rs"] diff --git a/crates/client/src/networking/mod.rs b/crates/client/src/networking/mod.rs index c332e6c1028f54baca05a8fce7bbafe066c185e8..bae0e12a5130120b6ccbd0d2191e850470921559 100644 --- a/crates/client/src/networking/mod.rs +++ b/crates/client/src/networking/mod.rs @@ -6,7 +6,7 @@ use bevy_ecs::{ query::{QuerySingleError, With}, world::World, }; -use nalgebra::{Rotation2, Scale2, Scale3, Translation3}; +use nalgebra::{Rotation2, Scale3, Translation3}; use starkingdoms_common::{packet::Packet, PartType, PlanetType}; use crate::components::{Camera, Chat, Menu, Part, Planet, Player, PlayerResources, RecvPacket, SendPacket, ServerId, SpriteBundle, Texture, Transform}; @@ -45,7 +45,7 @@ fn texture_name(part_type: PartType, attached: bool) -> String { pub fn process_packets( world: &mut World, - send_packet_events: &mut Events, + _send_packet_events: &mut Events, recv_packet_events: &mut Events, planet_types: &mut HashMap, ) { @@ -76,7 +76,7 @@ pub fn process_packets( )); } } - SpawnPlayer { id, username } => { + SpawnPlayer { id, .. } => { // username sync, eventually world.spawn(( Transform { @@ -112,10 +112,10 @@ pub fn process_packets( let server_id = match player_query.get_single(world) { Ok(player) => player, Err(e) => match e { - QuerySingleError::NoEntities(s) => { + QuerySingleError::NoEntities(_) => { continue; } - QuerySingleError::MultipleEntities(s) => { + QuerySingleError::MultipleEntities(_) => { panic!("There should never multiple players marked as players"); } }, @@ -130,7 +130,7 @@ pub fn process_packets( world .query::<(Entity, &ServerId, &mut Transform, &mut Texture, &mut Part)>( ); - for (entity, server_id, mut transform, mut texture, mut bevy_part) in + for (_, server_id, mut transform, mut texture, mut bevy_part) in part_query.iter_mut(world) { if server_id.0 == *id { @@ -151,7 +151,6 @@ pub fn process_packets( } PlanetPositions { planets } => { for (server_id, planet) in planets { - let mut planet_query = world.query_filtered::<&mut Transform, With>(); if !planet_types.contains_key(&planet.planet_type) { let entity = world.spawn(SpriteBundle { transform: Transform { @@ -215,7 +214,7 @@ pub fn process_packets( world.entity_mut(id).insert(Menu); } } - Message { message_type, actor, content } => { + Message { actor, content, .. } => { let mut chat = world.get_resource_mut::().unwrap(); chat.messages.push(format!("{}: {}", actor.clone(), content.clone())); } diff --git a/crates/client/src/rendering/mod.rs b/crates/client/src/rendering/mod.rs index 9e360318738714340587501bc11964690393c240..9f08285c3de60fb7ecf57be7db6a1f203e23e911 100644 --- a/crates/client/src/rendering/mod.rs +++ b/crates/client/src/rendering/mod.rs @@ -6,7 +6,6 @@ use bevy_ecs::entity::Entity; use bevy_ecs::event::Events; use bevy_ecs::query::With; use bevy_ecs::world::World; -use egui::{Label, ProgressBar}; use egui_glow::EguiGlow; use glow::{HasContext, PixelUnpackData}; #[cfg(not(target_arch = "wasm32"))] @@ -20,7 +19,7 @@ use glutin::{ }; #[cfg(not(target_arch = "wasm32"))] use glutin_winit::{DisplayBuilder, GlWindow}; -use nalgebra::{Matrix4, Scale3, Translation2, Translation3, Vector3, Vector4}; +use nalgebra::{Scale3, Translation3, Vector3}; use starkingdoms_common::packet::{ButtonType, Packet}; use starkingdoms_common::PlanetType; #[cfg(target_arch = "wasm32")] @@ -39,13 +38,14 @@ use winit::{ event::WindowEvent, event_loop::ActiveEventLoop, raw_window_handle::HasWindowHandle, - window::{Window, WindowAttributes}, + window::{Window}, }; use crate::components::{Camera, Menu, Player, RecvPacket, SendPacket, Texture, Transform}; use crate::networking::process_packets; use crate::networking::ws::Ws; use crate::ui::{draw_ui, init_ui}; +use assets::AssetLoader; pub mod assets; @@ -335,7 +335,7 @@ impl ApplicationHandler for App { fn window_event( &mut self, event_loop: &ActiveEventLoop, - window_id: winit::window::WindowId, + _window_id: winit::window::WindowId, event: winit::event::WindowEvent, ) { let event_response = self @@ -498,11 +498,10 @@ impl ApplicationHandler for App { &mut self.planet_types, ); - let window = self.window.as_ref().unwrap(); let gl = self.gl.as_ref().unwrap(); let mut player = self.world.query_filtered::<&Transform, With>(); - let player = player.single(&self.world); + self.egui_glow .as_mut() .unwrap() diff --git a/crates/client/src/ui/colors.rs b/crates/client/src/ui/colors.rs index 3565e85a86859e4600f52cb006b80e48ac48c6e8..35d9b01ac2fb6eb4daadf80ea76ecf8f36a97664 100644 --- a/crates/client/src/ui/colors.rs +++ b/crates/client/src/ui/colors.rs @@ -1,5 +1,6 @@ macro_rules! color { ($n:ident,rgb($r:expr, $g:expr, $b:expr)) => { + #[allow(dead_code)] pub const $n: ::egui::Color32 = ::egui::Color32::from_rgb($r, $g, $b); }; } diff --git a/crates/client/src/wasm/assets.rs b/crates/client/src/wasm/assets.rs index b2e05ae33a4fdb5715c95a067d098cf7d6ef8621..acee6a6ffe91fd8b20418dfd68966674950802c9 100644 --- a/crates/client/src/wasm/assets.rs +++ b/crates/client/src/wasm/assets.rs @@ -8,7 +8,7 @@ use bevy_ecs::system::Resource; use image::EncodableLayout; use poll_promise::Promise; use resvg::{tiny_skia, usvg}; -use crate::rendering::assets::AssetLoader; +use crate::rendering::assets::{AssetLoader, ImgData}; #[derive(Resource)] pub struct Assets { diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs index 71343ab05ee5d6b46c50a55d6b2439a4cdb37d38..c009206ebaf5224dc32b989b9237e2897874e783 100644 --- a/crates/common/src/lib.rs +++ b/crates/common/src/lib.rs @@ -110,7 +110,7 @@ pub fn unpack_savefile(key: &[u8], file: String) -> Result Result> { +pub fn __noverify_unpack_savefile(file: String) -> Result> { // << reverse! << let savefile_bytes = base64::engine::general_purpose::STANDARD .decode(file)