aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-09 15:31:13 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-09 15:31:13 +0200
commit545f79b03ca1fa778cfffb77ee0fbd0f5e66de44 (patch)
treea0324b8731f0042e89a6b0417837d8aa933e5aaf
parent1da3465d7a4402760aed03ce2f450cd1b412417f (diff)
downloadhurrycurry-545f79b03ca1fa778cfffb77ee0fbd0f5e66de44.tar
hurrycurry-545f79b03ca1fa778cfffb77ee0fbd0f5e66de44.tar.bz2
hurrycurry-545f79b03ca1fa778cfffb77ee0fbd0f5e66de44.tar.zst
adjust logging and better duplex
-rw-r--r--data/maps/duplex.yaml36
-rw-r--r--server/protocol/src/lib.rs11
-rw-r--r--server/src/customer/mod.rs12
-rw-r--r--server/src/customer/pathfinding.rs4
-rw-r--r--server/src/game.rs25
5 files changed, 53 insertions, 35 deletions
diff --git a/data/maps/duplex.yaml b/data/maps/duplex.yaml
index 8c068683..1253e7ed 100644
--- a/data/maps/duplex.yaml
+++ b/data/maps/duplex.yaml
@@ -14,23 +14,25 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
map:
- - "''''''''''''''''''''''''''''"
- - "'c'c''''''''''''''''''''c'c'"
- - "'t_t'███████c__c███████'t_t'"
- - "''_''█SSSS#█t__t█RTFL#█''_''"
- - "'c_c'█....#█c__c█....#█'c_c'"
- - "'t_t'█....#█'__'█....#█'t_t'"
- - "'c_c'█....>›>»»>›v...#█'c_c'"
- - "''___d....^‹<««<‹<....d___''"
- - "''___d....>›>»»>›v....d___''"
- - "'c_c'█....^‹<««<‹<...p█'c_c'"
- - "'t_t'█#....█'__'█....p█'t_t'"
- - "'c_c'█#....█'__'█....p█'c_c'"
- - "''_''█#ffCC█'__'█Xsspp█''_''"
- - "'t_t'███████'__'███████'t_t'"
- - "'c_c''''=''''__''''=''''c_c'"
- - "''_'''''=''''__''''='''''_''"
- - "''''''''=''''!~''''=''''''''"
+ - "''''*''''''''*''''''''''*'"
+ - "*'''''''''*''''*''''*''''*"
+ - "''*'''*''''''*''''''''*'''"
+ - "'t_t'██████''''██████'t_t'"
+ - "'c_c'█#FCC█''''█Xss#█'c_c'"
+ - "'c_c'█p...█====█...p█'c_c'"
+ - "'t_t'█p...█''''█...p█'t_t'"
+ - "'c_c'█p..v‹<<<<‹<..p█'c_c'"
+ - "''___d...>›>>>>›^...d___''"
+ - "''___d...v‹<<<<‹<...d___''"
+ - "'c_c'█S..>›>>>>›^..#█'c_c'"
+ - "'t_t'█S...█''''█...o█'t_t'"
+ - "'c_c'█S...█====█...o█'c_c'"
+ - "''_''█#ff#█''''█RTL#█''_''"
+ - "''_''██████''''██████''_''"
+ - "''_''''''''''''''''''''_''"
+ - "''______________________''"
+ - "''''''''''''__''''''''''''"
+ - "*''*''''''''!~'''''*''''*'"
tiles:
"#": counter
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index 9c8d6bee..147a4fc3 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -17,7 +17,7 @@
*/
use glam::{IVec2, Vec2};
use serde::{Deserialize, Serialize};
-use std::collections::HashSet;
+use std::{collections::HashSet, fmt::Display};
pub use glam;
@@ -170,3 +170,12 @@ pub enum ItemLocation {
Tile(IVec2),
Player(PlayerID),
}
+
+impl Display for ItemLocation {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ ItemLocation::Tile(pos) => write!(f, "tile({pos})"),
+ ItemLocation::Player(PlayerID(id)) => write!(f, "player({id})"),
+ }
+ }
+}
diff --git a/server/src/customer/mod.rs b/server/src/customer/mod.rs
index ba57542c..e60c50c7 100644
--- a/server/src/customer/mod.rs
+++ b/server/src/customer/mod.rs
@@ -22,7 +22,7 @@ use crate::{data::Gamedata, game::Tile};
use anyhow::{anyhow, Result};
use fake::{faker, Fake};
use hurrycurry_protocol::{glam::IVec2, DemandIndex, Message, PacketS, PlayerID};
-use log::debug;
+use log::info;
use movement::MovementBase;
use pathfinding::{find_path, Path};
use rand::{random, thread_rng};
@@ -121,6 +121,7 @@ impl DemandState {
let from = data.customer_spawn.as_ivec2();
let path = find_path(&self.walkable, from, chair)
.ok_or(anyhow!("no path from {from} to {chair}"))?;
+ info!("{id:?} -> entering");
self.customers.insert(
id,
Customer {
@@ -133,7 +134,6 @@ impl DemandState {
for (&id, p) in &mut self.customers {
match &mut p.state {
CustomerState::Entering { path, chair } => {
- debug!("{id:?} entering");
packets_out.push((id, path.execute_tick(&mut p.movement, &self.walkable, dt)));
if path.is_done() {
let demand = DemandIndex(random::<usize>() % self.data.demands.len());
@@ -144,6 +144,7 @@ impl DemandState {
persist: true,
},
));
+ info!("{id:?} -> waiting");
p.state = CustomerState::Waiting {
chair: *chair,
timeout: 60. + random::<f32>() * 30.,
@@ -156,7 +157,6 @@ impl DemandState {
demand,
timeout,
} => {
- debug!("{id:?} waiting");
*timeout -= dt;
if *timeout <= 0. {
packets_out.push((
@@ -183,6 +183,7 @@ impl DemandState {
self.failed += 1;
*points -= 1;
self.score_changed = true;
+ info!("{id:?} -> exiting");
p.state = CustomerState::Exiting { path }
} else {
let demand_data = &data.demand(*demand);
@@ -222,6 +223,7 @@ impl DemandState {
));
packets_out.push((id, PacketS::Interact { pos: Some(pos) }));
packets_out.push((id, PacketS::Interact { pos: None }));
+ info!("{id:?} -> eating");
p.state = CustomerState::Eating {
demand: *demand,
target: pos,
@@ -237,7 +239,6 @@ impl DemandState {
progress,
chair,
} => {
- debug!("{id:?} eating");
let demand = data.demand(*demand);
*progress += dt / demand.duration;
if *progress >= 1. {
@@ -256,13 +257,14 @@ impl DemandState {
self.completed += 1;
*points += demand.points;
self.score_changed = true;
+ info!("{id:?} -> exiting");
p.state = CustomerState::Exiting { path }
}
}
CustomerState::Exiting { path } => {
- debug!("{id:?} exiting");
packets_out.push((id, path.execute_tick(&mut p.movement, &self.walkable, dt)));
if path.is_done() {
+ info!("{id:?} -> leave");
packets_out.push((id, PacketS::Leave));
customers_to_remove.push(id);
}
diff --git a/server/src/customer/pathfinding.rs b/server/src/customer/pathfinding.rs
index 29ee4e00..2fe938a9 100644
--- a/server/src/customer/pathfinding.rs
+++ b/server/src/customer/pathfinding.rs
@@ -20,7 +20,7 @@ use hurrycurry_protocol::{
glam::{IVec2, Vec2},
PacketS,
};
-use log::debug;
+use log::trace;
use std::{
cmp::Ordering,
collections::{BinaryHeap, HashMap, HashSet},
@@ -36,7 +36,7 @@ impl Path {
dt: f32,
) -> PacketS {
if let Some(next) = self.0.last().copied() {
- debug!("next {next}");
+ trace!("next {next}");
if next.distance(player.position) < if self.0.len() == 1 { 0.1 } else { 0.6 } {
self.0.pop();
}
diff --git a/server/src/game.rs b/server/src/game.rs
index 908c0b4e..5cdf8cd4 100644
--- a/server/src/game.rs
+++ b/server/src/game.rs
@@ -326,8 +326,6 @@ impl Game {
.push_back(PacketC::Collide { player, force });
}
PacketS::Interact { pos } => {
- info!("interact {pos:?}");
-
let pid = player;
let player = self
.players
@@ -571,15 +569,22 @@ pub fn interact_effect(
if let Some(effect) = interact(&data, edge, this_tile_kind, this, other, points, automated) {
match effect {
- InteractEffect::Put => packet_out.push_back(PacketC::MoveItem {
- from: other_loc,
- to: this_loc,
- }),
- InteractEffect::Take => packet_out.push_back(PacketC::MoveItem {
- from: this_loc,
- to: other_loc,
- }),
+ InteractEffect::Put => {
+ info!("put {this_loc} <- {other_loc}");
+ packet_out.push_back(PacketC::MoveItem {
+ from: other_loc,
+ to: this_loc,
+ })
+ }
+ InteractEffect::Take => {
+ info!("take {this_loc} -> {other_loc}");
+ packet_out.push_back(PacketC::MoveItem {
+ from: this_loc,
+ to: other_loc,
+ })
+ }
InteractEffect::Produce => {
+ info!("produce {this_loc} <~ {other_loc}");
if this_had_item {
packet_out.push_back(PacketC::SetProgress {
item: this_loc,