aboutsummaryrefslogtreecommitdiff
path: root/server/data
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-24 18:43:49 +0100
committertpart <tpart120@proton.me>2026-02-26 20:49:13 +0100
commit28e1cfa50847de1a7347531054bd62c88f304678 (patch)
tree25626a8df6b01a2a8f3174d75de42008b9126d8c /server/data
parentb9af9a5d862836051d07fad9803cb3d308968668 (diff)
downloadhurrycurry-28e1cfa50847de1a7347531054bd62c88f304678.tar
hurrycurry-28e1cfa50847de1a7347531054bd62c88f304678.tar.bz2
hurrycurry-28e1cfa50847de1a7347531054bd62c88f304678.tar.zst
update server to new tile stacks
Diffstat (limited to 'server/data')
-rw-r--r--server/data/src/filter_demands.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/server/data/src/filter_demands.rs b/server/data/src/filter_demands.rs
index cb29a678..4eb2d597 100644
--- a/server/data/src/filter_demands.rs
+++ b/server/data/src/filter_demands.rs
@@ -15,13 +15,12 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-use hurrycurry_protocol::{Demand, ItemIndex, Recipe, TileIndex};
+use hurrycurry_protocol::{Demand, ItemIndex, Recipe, TileIndex, glam::IVec2};
use log::debug;
use std::collections::{HashMap, HashSet};
pub fn filter_demands_and_recipes(
- map_tiles: &HashSet<TileIndex>,
- map_items: &HashSet<ItemIndex>,
+ initial_map: &HashMap<IVec2, (Vec<TileIndex>, Option<ItemIndex>)>,
demands: &mut Vec<Demand>,
recipes: &mut Vec<Recipe>,
) {
@@ -31,6 +30,17 @@ pub fn filter_demands_and_recipes(
demands.len()
);
+ let map_tiles = initial_map
+ .values()
+ .flat_map(|(t, _)| t)
+ .copied()
+ .collect::<HashSet<_>>();
+ let map_items = initial_map
+ .values()
+ .flat_map(|(_, i)| i)
+ .copied()
+ .collect::<HashSet<_>>();
+
// Remove tile-bound recipes that cant be performed
recipes.retain(|r| r.tile().is_none_or(|t| map_tiles.contains(&t)));