diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-19 13:01:18 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-23 19:21:22 +0200 | 
| commit | c55d90768a9336436238dd93ae1706e23e281e84 (patch) | |
| tree | a8d70b76100ae539d0659caa1c62dd0594a05817 | |
| parent | bcbc56d161ac78a48dcca88e5671d333614d7425 (diff) | |
| download | hurrycurry-c55d90768a9336436238dd93ae1706e23e281e84.tar hurrycurry-c55d90768a9336436238dd93ae1706e23e281e84.tar.bz2 hurrycurry-c55d90768a9336436238dd93ae1706e23e281e84.tar.zst | |
send neighbours on map updatre
| -rw-r--r-- | server/src/customer.rs | 4 | ||||
| -rw-r--r-- | server/src/game.rs | 6 | ||||
| -rw-r--r-- | server/src/protocol.rs | 1 | ||||
| -rw-r--r-- | test-client/protocol.ts | 2 | 
4 files changed, 10 insertions, 3 deletions
| diff --git a/server/src/customer.rs b/server/src/customer.rs index ea63f93a..8d843fda 100644 --- a/server/src/customer.rs +++ b/server/src/customer.rs @@ -4,7 +4,7 @@ use crate::{      protocol::{PacketC, PacketS, PlayerID},  };  use glam::{IVec2, Vec2}; -use log::{error, info}; +use log::error;  use std::{      cmp::Ordering,      collections::{BinaryHeap, HashMap, HashSet, VecDeque}, @@ -49,7 +49,7 @@ pub async fn customer(game: Arc<RwLock<Game>>, mut grx: broadcast::Receiver<Pack              PacketC::Init { data, .. } => {                  state.data = data;              } -            PacketC::UpdateMap { pos, tile } => { +            PacketC::UpdateMap { pos, tile, .. } => {                  let tilename = &state.data.tile_names[tile];                  if tilename == "floor" || tilename == "door" {                      state.walkable.insert(pos); diff --git a/server/src/game.rs b/server/src/game.rs index 9c1bdd29..228d7048 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -85,6 +85,12 @@ impl Game {          for (&tile, tdata) in &self.tiles {              out.push(PacketC::UpdateMap {                  pos: tile, +                neighbours: [ +                    self.tiles.get(&(tile + IVec2::NEG_Y)).map(|e| e.kind), +                    self.tiles.get(&(tile + IVec2::NEG_X)).map(|e| e.kind), +                    self.tiles.get(&(tile + IVec2::Y)).map(|e| e.kind), +                    self.tiles.get(&(tile + IVec2::X)).map(|e| e.kind), +                ],                  tile: tdata.kind.clone(),              });              if let Some(item) = &tdata.item { diff --git a/server/src/protocol.rs b/server/src/protocol.rs index 34442263..18b5f6fa 100644 --- a/server/src/protocol.rs +++ b/server/src/protocol.rs @@ -61,6 +61,7 @@ pub enum PacketC {      UpdateMap {          pos: IVec2,          tile: TileIndex, +        neighbours: [Option<TileIndex>; 4],      },      Collide {          player: PlayerID, diff --git a/test-client/protocol.ts b/test-client/protocol.ts index 31f61d19..aa3aa063 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -25,4 +25,4 @@ export type PacketC =      | { type: "produce_item", tile: Vec2, item: ItemIndex } // A tile generated a new item      | { type: "consume_item", tile: Vec2 } // A tile removed an item      | { type: "set_active", tile: Vec2, progress?: number } // A tile is doing something. progress goes from 0 to 1, then null when finished -    | { type: "update_map", pos: Vec2, tile: TileIndex } // A map tile was changed +    | { type: "update_map", pos: Vec2, tile: TileIndex, neighbours: [TileIndex | null] } // A map tile was changed | 
