aboutsummaryrefslogtreecommitdiff
path: root/server/protocol
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-10 17:16:03 +0100
committertpart <tpart120@proton.me>2026-02-26 20:48:35 +0100
commitb634bad931f530ee0a207e1461ffc5e52ebb83e3 (patch)
tree90a45e8c67e6a7c66e49c7409f0c37881eade96e /server/protocol
parent0ed9e8387a66b3af78412feea62fdc8b9804f793 (diff)
downloadhurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar
hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar.bz2
hurrycurry-b634bad931f530ee0a207e1461ffc5e52ebb83e3.tar.zst
compiles with tile stacks
Diffstat (limited to 'server/protocol')
-rw-r--r--server/protocol/src/helpers.rs22
-rw-r--r--server/protocol/src/lib.rs8
2 files changed, 19 insertions, 11 deletions
diff --git a/server/protocol/src/helpers.rs b/server/protocol/src/helpers.rs
index 679e6301..1be37a36 100644
--- a/server/protocol/src/helpers.rs
+++ b/server/protocol/src/helpers.rs
@@ -45,6 +45,20 @@ impl Gamedata {
.enumerate()
.map(|(i, e)| (RecipeIndex(i), e))
}
+ pub fn can_place_item(&self, tiles: &[TileIndex], item: ItemIndex) -> bool {
+ for t in tiles.iter().rev() {
+ if let Some(whitelist) = self.tile_placeable_items.get(t) {
+ return whitelist.contains(&item);
+ }
+ if self.tile_placeable_any.contains(t) {
+ return true;
+ }
+ }
+ false
+ }
+ pub fn walkable(&self, tiles: &[TileIndex]) -> bool {
+ tiles.iter().any(|t| self.tile_collide.contains(t))
+ }
}
impl Recipe {
@@ -92,13 +106,9 @@ impl Recipe {
a.iter().chain(b.iter()).copied()
}
- pub fn supports_tile(&self, tile: Option<TileIndex>) -> bool {
+ pub fn supports_tile(&self, tile: TileIndex) -> bool {
if let Some(tile_constraint) = self.tile() {
- if let Some(tile) = tile {
- tile == tile_constraint
- } else {
- false
- }
+ tile == tile_constraint
} else {
true
}
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index d7cd2cd9..8a6e282e 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -87,9 +87,10 @@ pub struct Gamedata {
pub current_map: String,
pub item_names: Vec<String>,
pub tile_names: Vec<String>,
- pub tile_walkable: HashSet<TileIndex>,
+ pub tile_collide: HashSet<TileIndex>,
#[serde(deserialize_with = "deser_tile_index_map")]
pub tile_placeable_items: BTreeMap<TileIndex, HashSet<ItemIndex>>,
+ pub tile_placeable_any: HashSet<TileIndex>,
pub tile_interactable_empty: HashSet<TileIndex>,
pub maps: Vec<(String, MapMetadata)>,
pub bot_algos: Vec<String>,
@@ -257,11 +258,8 @@ pub enum PacketC {
warn: bool,
},
UpdateMap {
- tile: IVec2,
- kind: Option<TileIndex>,
- neighbors: [Option<TileIndex>; 4],
+ changes: Vec<(IVec2, Vec<TileIndex>)>,
},
- FlushMap,
Communicate {
player: PlayerID,
message: Option<Message>,