summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/customer.rs4
-rw-r--r--server/src/game.rs6
-rw-r--r--server/src/protocol.rs1
-rw-r--r--test-client/protocol.ts2
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