From d83c9b89d845e1b1780765dec2e7e431ef66b305 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 27 Feb 2023 10:36:56 +0100 Subject: [PATCH] Disabled linux-gnu ci for now --- .build.yml | 14 +++++++------- src/screens/build.rs | 4 +--- src/screens/inventory.rs | 26 +++++++++++++++----------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.build.yml b/.build.yml index 5b44430..34a3bf5 100644 --- a/.build.yml +++ b/.build.yml @@ -9,7 +9,7 @@ packages: - protoc artifacts: - ./LittleTown-amd64-musl - - ./LittleTown-amd64-gnu + #- ./LittleTown-amd64-gnu - ./LittleTown.exe tasks: - setup: | @@ -25,12 +25,12 @@ tasks: cd little_town cargo build --release --target x86_64-unknown-linux-musl mv target/x86_64-unknown-linux-musl/release/little_town ../LittleTown-amd64-musl - - build-amd64-gnu: | - source $HOME/.cargo/env - cd little_town - rustup target add x86_64-unknown-linux-gnu - cargo build --release --target x86_64-unknown-linux-gnu - mv target/x86_64-unknown-linux-gnu/release/little_town ../LittleTown-amd64-gnu + #- build-amd64-gnu: | + # source $HOME/.cargo/env + # cd little_town + # rustup target add x86_64-unknown-linux-gnu + # cargo build --release --target x86_64-unknown-linux-gnu + # mv target/x86_64-unknown-linux-gnu/release/little_town ../LittleTown-amd64-gnu - build-amd64-win: | source $HOME/.cargo/env cd little_town diff --git a/src/screens/build.rs b/src/screens/build.rs index 9876312..dcbed25 100644 --- a/src/screens/build.rs +++ b/src/screens/build.rs @@ -113,7 +113,7 @@ impl BuildScreen { grid: HashMap::new(), cam: Camera::new(), show_inv: false, - inv: Inventory::new(), + inv: Inventory::empty(), mouse_position: None, #[cfg(feature="multiplayer")] multiplayer: Some(Peer::client()) @@ -509,11 +509,9 @@ impl GameComponent for BuildScreen { // and perform neccesarry action match task { GameAction::RequestMap => { - println!("Sending map"); mp.perform_action(GameAction::TransmitMap(self.grid.clone())); }, GameAction::RequestInventory => { - println!("Sending inv"); mp.perform_action(GameAction::TransmitInventory(self.inv.contents.clone(), self.inv.has_infinite_items())); }, GameAction::PlaceBlock(pos, block, dir) => { diff --git a/src/screens/inventory.rs b/src/screens/inventory.rs index b49bae7..1ce859e 100644 --- a/src/screens/inventory.rs +++ b/src/screens/inventory.rs @@ -43,23 +43,27 @@ impl Inventory { pub fn toggle_infinite_items(&mut self, toggle: bool) { self.infinite_items = toggle; } + /// creates an empty inventory + pub fn empty() -> Self { + Self { + infinite_items: false, + contents: HashMap::new(), + selected: None, + direction: Direction::North, + page: 0, + } + } pub fn new() -> Self { - let mut cont = HashMap::new(); - let infinite_items = true; + let mut this = Self::empty(); + this.infinite_items = true; - if infinite_items { + if this.infinite_items { for block in Block::all() { - cont.insert(block, 1); + this.contents.insert(block, 1); } } - Self { - infinite_items, - contents: cont, - selected: None, - direction: Direction::North, - page: 0, - } + this } /// adds a block to the players inventory pub fn add(&mut self, block: Block) { -- 2.38.5