aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/book-export/src/main.rs4
-rw-r--r--server/data/src/book/mod.rs4
-rw-r--r--server/data/src/book/recipe_diagram.rs4
-rw-r--r--server/data/src/lib.rs22
-rw-r--r--server/data/src/registry.rs4
-rw-r--r--server/editor/src/main.rs2
-rw-r--r--server/game-core/src/lib.rs2
-rw-r--r--server/protocol/src/lib.rs16
-rw-r--r--server/registry/src/lobby.rs16
-rw-r--r--server/src/benchmark.rs4
-rw-r--r--server/src/commands.rs14
-rw-r--r--server/src/entity/mod.rs4
-rw-r--r--server/src/main.rs14
-rw-r--r--server/src/server.rs55
-rw-r--r--server/src/state.rs12
-rw-r--r--server/tools/src/graph.rs4
-rw-r--r--server/tools/src/graph_summary.rs4
-rw-r--r--server/tools/src/main.rs10
18 files changed, 119 insertions, 76 deletions
diff --git a/server/book-export/src/main.rs b/server/book-export/src/main.rs
index ff9445c2..4bd8935d 100644
--- a/server/book-export/src/main.rs
+++ b/server/book-export/src/main.rs
@@ -21,7 +21,7 @@ pub mod diagram_svg;
use crate::book_html::render_html_book;
use anyhow::Result;
use clap::{Parser, ValueEnum};
-use hurrycurry_data::{book::book, build_data};
+use hurrycurry_data::{book::book, build_gamedata};
use hurrycurry_locale::Locale;
use std::{fs::File, io::Write, path::PathBuf};
@@ -49,7 +49,7 @@ fn main() -> Result<()> {
env_logger::init_from_env("LOG");
let args = Args::parse();
- let (data, serverdata) = build_data("data".as_ref(), &args.map, true)?;
+ let (data, serverdata) = build_gamedata("data".as_ref(), &args.map, true)?;
let book = book(&data, &serverdata)?;
diff --git a/server/data/src/book/mod.rs b/server/data/src/book/mod.rs
index a0776f41..990d979c 100644
--- a/server/data/src/book/mod.rs
+++ b/server/data/src/book/mod.rs
@@ -20,7 +20,7 @@ pub mod diagram_layout;
pub mod recipe_diagram;
use crate::{
- Serverdata,
+ PrivateGamedata,
book::{diagram_layout::diagram_layout, recipe_diagram::recipe_diagram},
};
use anyhow::{Context, Result};
@@ -30,7 +30,7 @@ use hurrycurry_protocol::{
book::{Book, BookPage},
};
-pub fn book(data: &Gamedata, serverdata: &Serverdata) -> Result<Book> {
+pub fn book(data: &Gamedata, serverdata: &PrivateGamedata) -> Result<Book> {
let mut pages = Vec::new();
pages.push(BookPage::Contents {
diff --git a/server/data/src/book/recipe_diagram.rs b/server/data/src/book/recipe_diagram.rs
index 2c203f95..bef90946 100644
--- a/server/data/src/book/recipe_diagram.rs
+++ b/server/data/src/book/recipe_diagram.rs
@@ -16,7 +16,7 @@
*/
-use crate::Serverdata;
+use crate::PrivateGamedata;
use anyhow::{Result, bail};
use hurrycurry_protocol::{
Gamedata, ItemIndex, Message, Recipe, RecipeIndex,
@@ -30,7 +30,7 @@ use std::{
pub fn recipe_diagram(
data: &Gamedata,
- serverdata: &Serverdata,
+ serverdata: &PrivateGamedata,
target_items: &[ItemIndex],
) -> Result<Diagram> {
let ambient_items = serverdata
diff --git a/server/data/src/lib.rs b/server/data/src/lib.rs
index aff895fa..53b4e802 100644
--- a/server/data/src/lib.rs
+++ b/server/data/src/lib.rs
@@ -87,7 +87,7 @@ struct TileArgs {
#[derive(Debug, Clone, Default)]
#[rustfmt::skip]
-pub struct Serverdata {
+pub struct PrivateGamedata {
pub initial_map: HashMap<IVec2, (Vec<TileIndex>, Option<ItemIndex>)>,
pub chef_spawn: Vec2,
pub customer_spawn: Option<Vec2>,
@@ -98,11 +98,18 @@ pub struct Serverdata {
pub recipe_groups: BTreeMap<String, BTreeSet<ItemIndex>>,
}
-pub fn build_data(
+pub fn map_list(data_path: &Path) -> Result<Vec<(String, MapMetadata)>> {
+ let index =
+ read_to_string(data_path.join("index.yaml")).context("Failed reading data index")?;
+ let index = serde_yaml_ng::from_str::<DataIndex>(&index)?;
+ Ok(map_listing(&index))
+}
+
+pub fn build_gamedata(
data_path: &Path,
map_name: &str,
generate_book: bool,
-) -> Result<(Gamedata, Serverdata)> {
+) -> Result<(Gamedata, PrivateGamedata)> {
debug!("Preparing gamedata for {map_name}");
// Load index
@@ -234,7 +241,6 @@ pub fn build_data(
let mut data = Gamedata {
current_map: map_name.to_string(),
- maps: map_listing(&index),
tile_collide: tiles_flagged(&tile_flags, &tiles, 'c'),
tile_placeable_items: tile_placeable_items(
&initial_map,
@@ -251,15 +257,9 @@ pub fn build_data(
item_names: items,
demands,
tile_names: tiles,
- bot_algos: vec![
- "waiter".to_string(),
- "simple".to_string(),
- "dishwasher".to_string(),
- "frank".to_string(),
- ],
hand_count: map_in.hand_count.unwrap_or(1),
};
- let mut serverdata = Serverdata {
+ let mut serverdata = PrivateGamedata {
initial_map,
chef_spawn,
customer_spawn,
diff --git a/server/data/src/registry.rs b/server/data/src/registry.rs
index bf64795b..3288c037 100644
--- a/server/data/src/registry.rs
+++ b/server/data/src/registry.rs
@@ -23,7 +23,7 @@ use std::{
sync::RwLock,
};
-use crate::{Serverdata, entities::EntityDecl};
+use crate::{PrivateGamedata, entities::EntityDecl};
#[derive(Default)]
pub(crate) struct ItemTileRegistry {
@@ -57,7 +57,7 @@ impl ItemTileRegistry {
}
}
-pub(crate) fn filter_unused_tiles_and_items(data: &mut Gamedata, serverdata: &mut Serverdata) {
+pub(crate) fn filter_unused_tiles_and_items(data: &mut Gamedata, serverdata: &mut PrivateGamedata) {
debug!("running unused item/tile filter");
let mut used_items = BTreeSet::new();
let mut used_tiles = BTreeSet::new();
diff --git a/server/editor/src/main.rs b/server/editor/src/main.rs
index 1751b1f5..0f0dcab3 100644
--- a/server/editor/src/main.rs
+++ b/server/editor/src/main.rs
@@ -141,7 +141,7 @@ async fn handle_conn(
minor: VERSION.1,
supports_bincode: false,
});
- state.out.push(PacketC::Data {
+ state.out.push(PacketC::GameData {
data: Box::new(Gamedata {
tile_collide: (0..TILES.len()).map(TileIndex).collect(),
tile_placeable_items: BTreeMap::new(),
diff --git a/server/game-core/src/lib.rs b/server/game-core/src/lib.rs
index bee97652..ed6faf5b 100644
--- a/server/game-core/src/lib.rs
+++ b/server/game-core/src/lib.rs
@@ -88,7 +88,7 @@ pub struct Game {
impl Game {
pub fn apply_packet(&mut self, packet: PacketC) {
match packet {
- PacketC::Data { data } => {
+ PacketC::GameData { data } => {
self.data = Arc::new(*data);
}
PacketC::AddPlayer {
diff --git a/server/protocol/src/lib.rs b/server/protocol/src/lib.rs
index 8a6e282e..db69f6be 100644
--- a/server/protocol/src/lib.rs
+++ b/server/protocol/src/lib.rs
@@ -81,8 +81,15 @@ pub struct Demand {
pub points: i64,
}
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Serverdata {
+ pub name: String,
+ pub motd: Option<String>,
+ pub maps: Vec<(String, MapMetadata)>,
+ pub bot_algos: Vec<String>,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
-#[rustfmt::skip]
pub struct Gamedata {
pub current_map: String,
pub item_names: Vec<String>,
@@ -92,8 +99,6 @@ pub struct Gamedata {
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>,
pub recipes: Vec<Recipe>,
pub demands: Vec<Demand>,
pub hand_count: usize,
@@ -216,7 +221,10 @@ pub enum PacketC {
Joined {
id: PlayerID,
},
- Data {
+ ServerData {
+ data: Box<Serverdata>,
+ },
+ GameData {
data: Box<Gamedata>,
},
AddPlayer {
diff --git a/server/registry/src/lobby.rs b/server/registry/src/lobby.rs
index acbb69bd..eb6ae1f0 100644
--- a/server/registry/src/lobby.rs
+++ b/server/registry/src/lobby.rs
@@ -1,7 +1,7 @@
use crate::Registry;
use anyhow::Result;
use hurrycurry_protocol::{
- Gamedata, PacketC, PacketS, PlayerClass, PlayerID, TileIndex, VERSION,
+ Gamedata, PacketC, PacketS, PlayerClass, PlayerID, Serverdata, TileIndex, VERSION,
glam::{IVec2, Vec2, ivec2, vec2},
movement::MovementBase,
registry::Entry,
@@ -23,7 +23,9 @@ use tokio::{
use tokio_tungstenite::tungstenite::Message;
pub(crate) async fn lobby_wrapper(registry: Arc<RwLock<Registry>>, saddr: SocketAddr) {
- let Err(e) = lobby(registry, saddr).await else { unreachable!() };
+ let Err(e) = lobby(registry, saddr).await else {
+ unreachable!()
+ };
error!("lobby crashed: {e}");
}
@@ -73,7 +75,15 @@ async fn handle_conn(sock: TcpStream, addr: SocketAddr, entries: &[Entry]) -> Re
minor: VERSION.1,
supports_bincode: false,
});
- out.push(PacketC::Data {
+ out.push(PacketC::ServerData {
+ data: Box::new(Serverdata {
+ bot_algos: vec![],
+ maps: vec![],
+ motd: None,
+ name: "Registry".to_string(),
+ }),
+ });
+ out.push(PacketC::GameData {
data: Box::new(Gamedata {
tile_collide: (0..TILES.len()).map(TileIndex).collect(),
tile_placeable_items: BTreeMap::new(),
diff --git a/server/src/benchmark.rs b/server/src/benchmark.rs
index 6e9e4eb7..216cf0a8 100644
--- a/server/src/benchmark.rs
+++ b/server/src/benchmark.rs
@@ -22,7 +22,7 @@ use crate::{
};
use anyhow::Result;
use hurrycurry_bot::algos::Simple;
-use hurrycurry_data::build_data;
+use hurrycurry_data::build_gamedata;
use hurrycurry_protocol::{Character, PacketC, PlayerClass};
use log::debug;
use std::{path::PathBuf, time::Instant};
@@ -37,7 +37,7 @@ pub fn benchmark(data_path: PathBuf) -> Result<()> {
broadcast::channel(1024).0,
)?;
- server.load(build_data(&server.config.data_path, "junior", true)?, None);
+ server.load(build_gamedata(&server.config.data_path, "junior", true)?, None);
server.entities.push(Box::new(BotDriver::new(
"player".to_string(),
diff --git a/server/src/commands.rs b/server/src/commands.rs
index 0dc8b954..d2a7da2c 100644
--- a/server/src/commands.rs
+++ b/server/src/commands.rs
@@ -22,7 +22,7 @@ use crate::{
use anyhow::Result;
use clap::{Parser, ValueEnum};
use hurrycurry_bot::algos::ALGO_CONSTRUCTORS;
-use hurrycurry_data::build_data;
+use hurrycurry_data::build_gamedata;
use hurrycurry_locale::{TrError, tre, trm};
use hurrycurry_protocol::{
Character, Hand, ItemLocation, Menu, Message, PacketC, PlayerClass, PlayerID,
@@ -175,7 +175,7 @@ impl Server {
})
.ok();
}
- let mut data = build_data(&self.config.data_path, &name, true)
+ let mut data = build_gamedata(&self.config.data_path, &name, true)
.map_err(|e| TrError::Plain(e.to_string()))?;
if let Some(hand_count) = hand_count {
@@ -206,7 +206,7 @@ impl Server {
})
.ok();
self.load(
- build_data(&self.config.data_path, &self.config.lobby, true)
+ build_gamedata(&self.config.data_path, &self.config.lobby, true)
.map_err(|e| TrError::Plain(e.to_string()))?,
None,
);
@@ -216,7 +216,7 @@ impl Server {
return Err(tre!("s.error.must_be_alone"));
}
self.load(
- build_data(&self.config.data_path, &self.game.data.current_map, true)
+ build_gamedata(&self.config.data_path, &self.game.data.current_map, true)
.map_err(|e| TrError::Plain(e.to_string()))?,
None,
);
@@ -233,7 +233,9 @@ impl Server {
}
self.update_paused();
}
- Command::Book => replies.push(PacketC::Menu(Menu::Book(self.data.book.clone()))),
+ Command::Book => {
+ replies.push(PacketC::Menu(Menu::Book(self.priv_gamedata.book.clone())))
+ }
Command::Effect { name } => {
self.broadcast
.send(PacketC::Effect2 {
@@ -289,7 +291,6 @@ impl Server {
Command::Scoreboard { map, text } => {
let mapname = map.as_ref().unwrap_or(&self.game.data.current_map);
let mapname_pretty = &self
- .game
.data
.maps
.iter()
@@ -327,7 +328,6 @@ impl Server {
Command::Info { map } => {
let mapname = map.as_ref().unwrap_or(&self.game.data.current_map);
let info = &self
- .game
.data
.maps
.iter()
diff --git a/server/src/entity/mod.rs b/server/src/entity/mod.rs
index d10bee0c..8a78202b 100644
--- a/server/src/entity/mod.rs
+++ b/server/src/entity/mod.rs
@@ -44,7 +44,7 @@ use campaign::{Gate, Map};
use conveyor::Conveyor;
use customers::Customers;
use environment_effect::{EnvironmentController, EnvironmentEffectController};
-use hurrycurry_data::{Serverdata, entities::EntityDecl};
+use hurrycurry_data::{PrivateGamedata, entities::EntityDecl};
use hurrycurry_game_core::Game;
use hurrycurry_locale::TrError;
use hurrycurry_protocol::{Character, ItemLocation, PacketC, PacketS, PlayerID};
@@ -61,7 +61,7 @@ pub type Entities = Vec<DynEntity>;
pub struct EntityContext<'a> {
pub game: &'a mut Game,
- pub serverdata: &'a Serverdata,
+ pub serverdata: &'a PrivateGamedata,
pub packet_out: &'a mut VecDeque<PacketC>,
pub packet_in: &'a mut VecDeque<PacketS>,
pub score_changed: &'a mut bool,
diff --git a/server/src/main.rs b/server/src/main.rs
index cf133203..f1af7c54 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -68,10 +68,12 @@ pub(crate) struct Args {
#[arg(long)]
upnp: bool,
/// Server name
- #[cfg(any(feature = "register", feature = "mdns"))]
#[arg(long, short = 'N', default_value = "A Hurry Curry! Server")]
server_name: String,
- /// Uri for connecting remotely for registry submission
+ /// Message of the day
+ #[arg(long, short = 'M')]
+ motd: Option<String>,
+ /// URI for connecting remotely for registry submission
#[cfg(feature = "register")]
#[arg(long)]
register_uri: Option<String>,
@@ -140,6 +142,8 @@ async fn run(data_path: PathBuf, args: Args) -> anyhow::Result<()> {
inactivity_timeout: args.inactivity_timeout,
lobby: args.lobby,
data_path,
+ motd: args.motd,
+ name: args.server_name.clone(),
};
let mut state = Server::new(config, tx)?;
@@ -342,7 +346,7 @@ fn find_data_path() -> Result<PathBuf> {
#[cfg(test)]
mod test {
- use hurrycurry_data::build_data;
+ use hurrycurry_data::build_gamedata;
use hurrycurry_protocol::{Character, PacketS, PlayerClass, PlayerID};
use hurrycurry_server::{
ConnectionID,
@@ -376,7 +380,7 @@ mod test {
fn map_load() {
let mut s = server();
s.load(
- build_data(&s.config.data_path, "junior", false).unwrap(),
+ build_gamedata(&s.config.data_path, "junior", false).unwrap(),
None,
);
}
@@ -384,7 +388,7 @@ mod test {
fn map_load_book() {
let mut s = server();
s.load(
- build_data(&s.config.data_path, "junior", true).unwrap(),
+ build_gamedata(&s.config.data_path, "junior", true).unwrap(),
None,
);
}
diff --git a/server/src/server.rs b/server/src/server.rs
index 41156e6b..795192c5 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -21,7 +21,7 @@ use crate::{
scoreboard::ScoreboardStore,
};
use anyhow::{Context, Result, anyhow};
-use hurrycurry_data::{Serverdata, build_data};
+use hurrycurry_data::{PrivateGamedata, build_gamedata, map_list};
use hurrycurry_game_core::{Game, Involvement, Item, Player, Tile};
use hurrycurry_locale::{
GLOBAL_LOCALE, TrError,
@@ -30,7 +30,7 @@ use hurrycurry_locale::{
};
use hurrycurry_protocol::{
Character, Gamedata, Hand, ItemLocation, Menu, MessageTimeout, PacketC, PacketS, PlayerClass,
- PlayerID, Score, glam::Vec2, movement::MovementBase,
+ PlayerID, Score, Serverdata, glam::Vec2, movement::MovementBase,
};
use log::{info, warn};
use std::{
@@ -60,6 +60,8 @@ pub struct ServerConfig {
pub inactivity_timeout: f32,
pub lobby: String,
pub data_path: PathBuf,
+ pub motd: Option<String>,
+ pub name: String,
}
pub struct Server {
@@ -71,8 +73,8 @@ pub struct Server {
pub announce_state: AnnounceState,
pub game: Game,
-
- pub data: Arc<Serverdata>,
+ pub data: Box<Serverdata>,
+ pub priv_gamedata: Arc<PrivateGamedata>,
pub entities: Entities,
pub score_changed: bool,
pub packet_loopback: VecDeque<PacketS>,
@@ -86,6 +88,17 @@ pub struct Server {
impl Server {
pub fn new(config: ServerConfig, tx: broadcast::Sender<PacketC>) -> Result<Self> {
Ok(Self {
+ data: Box::new(Serverdata {
+ bot_algos: vec![
+ "waiter".to_string(),
+ "simple".to_string(),
+ "dishwasher".to_string(),
+ "frank".to_string(),
+ ],
+ maps: map_list(&config.data_path)?,
+ motd: config.motd.clone(),
+ name: config.name.clone(),
+ }),
config,
game: Game::default(),
tick_perf: (Duration::ZERO, 0),
@@ -93,7 +106,7 @@ impl Server {
announce_state: AnnounceState::Done,
packet_out: VecDeque::new(),
connections: HashMap::new(),
- data: Serverdata::default().into(),
+ priv_gamedata: PrivateGamedata::default().into(),
entities: Vec::new(),
score_changed: false,
packet_loopback: VecDeque::new(),
@@ -111,6 +124,8 @@ impl Default for ServerConfig {
data_path: "data".into(),
inactivity_timeout: 60.,
lobby: "lobby".to_string(),
+ name: "A Hurry Curry! Server".to_string(),
+ motd: None,
}
}
}
@@ -120,7 +135,7 @@ pub trait GameServerExt {
fn load(
&mut self,
gamedata: Gamedata,
- serverdata: &Serverdata,
+ serverdata: &PrivateGamedata,
timer: Option<Duration>,
packet_out: &mut VecDeque<PacketC>,
is_lobby: bool,
@@ -132,7 +147,7 @@ pub trait GameServerExt {
name: String,
character: Character,
class: PlayerClass,
- serverdata: &Serverdata,
+ serverdata: &PrivateGamedata,
custom_position: Option<Vec2>,
packet_out: Option<&mut VecDeque<PacketC>>,
);
@@ -161,7 +176,7 @@ impl GameServerExt for Game {
fn load(
&mut self,
gamedata: Gamedata,
- serverdata: &Serverdata,
+ serverdata: &PrivateGamedata,
timer: Option<Duration>,
packet_out: &mut VecDeque<PacketC>,
is_lobby: bool,
@@ -213,7 +228,7 @@ impl GameServerExt for Game {
fn prime_client(&self) -> Vec<PacketC> {
let mut out = Vec::new();
- out.push(PacketC::Data {
+ out.push(PacketC::GameData {
data: {
let mut k = self.data.as_ref().to_owned();
k.recipes.clear();
@@ -309,7 +324,7 @@ impl GameServerExt for Game {
name: String,
character: Character,
class: PlayerClass,
- serverdata: &Serverdata,
+ serverdata: &PrivateGamedata,
custom_position: Option<Vec2>,
packet_out: Option<&mut VecDeque<PacketC>>,
) {
@@ -348,7 +363,7 @@ impl GameServerExt for Game {
impl Server {
pub fn load_map(&mut self, name: &str) -> Result<()> {
self.load(
- build_data(&self.config.data_path, name, true)
+ build_gamedata(&self.config.data_path, name, true)
.context(anyhow!("preparing gamedata for {:?}", name))?,
None,
);
@@ -356,7 +371,7 @@ impl Server {
}
pub fn load(
&mut self,
- (gamedata, serverdata): (Gamedata, Serverdata),
+ (gamedata, serverdata): (Gamedata, PrivateGamedata),
timer: Option<Duration>,
) {
info!("Changing map to {:?}", gamedata.current_map);
@@ -367,7 +382,7 @@ impl Server {
packet_in: &mut self.packet_loopback,
score_changed: &mut self.score_changed,
scoreboard: &self.scoreboard,
- serverdata: self.data.as_ref(),
+ serverdata: self.priv_gamedata.as_ref(),
replies: None,
dt: 0.,
load_map: &mut None,
@@ -391,7 +406,7 @@ impl Server {
for ed in &serverdata.entity_decls {
self.entities.push(construct_entity(ed));
}
- self.data = serverdata.into();
+ self.priv_gamedata = serverdata.into();
for e in &mut self.entities {
e.constructor(EntityContext {
game: &mut self.game,
@@ -399,7 +414,7 @@ impl Server {
packet_in: &mut self.packet_loopback,
score_changed: &mut self.score_changed,
load_map: &mut None,
- serverdata: &self.data,
+ serverdata: &self.priv_gamedata,
scoreboard: &self.scoreboard,
replies: None,
dt: 0.,
@@ -445,7 +460,7 @@ impl Server {
name,
character,
class,
- &self.data,
+ &self.priv_gamedata,
position,
Some(&mut self.packet_out),
);
@@ -541,7 +556,7 @@ impl Server {
packet_in: &mut self.packet_loopback,
score_changed: &mut self.score_changed,
load_map: &mut None,
- serverdata: &self.data,
+ serverdata: &self.priv_gamedata,
scoreboard: &self.scoreboard,
replies: Some(replies),
dt: 0.,
@@ -754,7 +769,7 @@ impl Server {
score_changed: &mut self.score_changed,
packet_in: &mut self.packet_loopback,
scoreboard: &self.scoreboard,
- serverdata: &self.data,
+ serverdata: &self.priv_gamedata,
replies: None,
dt,
}) {
@@ -770,7 +785,7 @@ impl Server {
score_changed: &mut self.score_changed,
packet_in: &mut self.packet_loopback,
scoreboard: &self.scoreboard,
- serverdata: &self.data,
+ serverdata: &self.priv_gamedata,
replies: None,
dt: 0.,
});
@@ -794,7 +809,7 @@ impl Server {
self.game.score.time_remaining -= dt as f64;
if self.game.score.time_remaining < 0. {
let relative_score =
- (self.game.score.points * 100) / self.data.score_baseline.max(1);
+ (self.game.score.points * 100) / self.priv_gamedata.score_baseline.max(1);
self.game.score.stars = match relative_score {
100.. => 3,
70.. => 2,
diff --git a/server/src/state.rs b/server/src/state.rs
index 70c5b7f1..533c5a0c 100644
--- a/server/src/state.rs
+++ b/server/src/state.rs
@@ -20,7 +20,7 @@ use crate::{
server::{AnnounceState, ConnectionData, GameServerExt, Server},
};
use anyhow::Result;
-use hurrycurry_data::build_data;
+use hurrycurry_data::build_gamedata;
use hurrycurry_locale::{TrError, tre, trm};
use hurrycurry_protocol::{KEEPALIVE_INTERVAL, Menu, Message, PacketC, PacketS, PlayerID, VERSION};
use log::{debug, info, trace, warn};
@@ -76,7 +76,7 @@ impl Server {
}
if let Some((name, timer)) = r {
self.scoreboard.save()?;
- self.load(build_data(&self.config.data_path, &name, true)?, timer);
+ self.load(build_gamedata(&self.config.data_path, &name, true)?, timer);
}
}
@@ -128,6 +128,12 @@ impl Server {
supports_bincode: true,
},
);
+ init.insert(
+ 1,
+ PacketC::ServerData {
+ data: self.data.clone(),
+ },
+ );
self.connections.insert(
id,
ConnectionData {
@@ -242,7 +248,7 @@ impl Server {
})
.ok();
self.load(
- build_data(&self.config.data_path, &self.config.lobby, true)
+ build_gamedata(&self.config.data_path, &self.config.lobby, true)
.map_err(|m| tre!("s.error.map_load", s = format!("{m}")))?,
None,
);
diff --git a/server/tools/src/graph.rs b/server/tools/src/graph.rs
index 7e70d1c8..72eab3fe 100644
--- a/server/tools/src/graph.rs
+++ b/server/tools/src/graph.rs
@@ -16,13 +16,13 @@
*/
use anyhow::Result;
-use hurrycurry_data::build_data;
+use hurrycurry_data::build_gamedata;
use hurrycurry_protocol::{Demand, ItemIndex, Recipe, RecipeIndex};
pub(crate) fn graph() -> Result<()> {
println!("digraph {{");
- let (data, _) = build_data("data".as_ref(), "5star", true)?;
+ let (data, _) = build_gamedata("data".as_ref(), "5star", true)?;
for i in 0..data.item_names.len() {
println!("i{i} [label=\"{}\"]", data.item_name(ItemIndex(i)))
}
diff --git a/server/tools/src/graph_summary.rs b/server/tools/src/graph_summary.rs
index 82ecb8c1..2227a1c4 100644
--- a/server/tools/src/graph_summary.rs
+++ b/server/tools/src/graph_summary.rs
@@ -17,14 +17,14 @@
*/
use anyhow::Result;
-use hurrycurry_data::build_data;
+use hurrycurry_data::build_gamedata;
use hurrycurry_protocol::{ItemIndex, Recipe, TileIndex};
use std::collections::HashSet;
pub(crate) fn graph_summary() -> Result<()> {
println!("digraph {{");
- let (data, sdata) = build_data("data".as_ref(), "5star", true)?;
+ let (data, sdata) = build_gamedata("data".as_ref(), "5star", true)?;
struct Node {
inputs: Vec<ItemIndex>,
diff --git a/server/tools/src/main.rs b/server/tools/src/main.rs
index 78d3190c..2c45f57b 100644
--- a/server/tools/src/main.rs
+++ b/server/tools/src/main.rs
@@ -30,7 +30,7 @@ use anyhow::Result;
use clap::Parser;
use hurrycurry_data::{
book::{diagram_layout::diagram_layout, recipe_diagram::recipe_diagram},
- build_data,
+ build_gamedata,
};
#[derive(Parser)]
@@ -64,7 +64,7 @@ fn main() -> Result<()> {
Action::Graph => graph()?,
Action::GraphSummary => graph_summary()?,
Action::GraphSingle { out, dot_out } => {
- let (data, serverdata) = build_data("data".as_ref(), "5star", true)?;
+ let (data, serverdata) = build_gamedata("data".as_ref(), "5star", true)?;
let out = data.get_item_by_name(&out).unwrap();
let mut diagram = recipe_diagram(&data, &serverdata, &[out])?;
let out = if dot_out {
@@ -76,20 +76,20 @@ fn main() -> Result<()> {
println!("{out}");
}
Action::MapDemands { map } => {
- let (data, _) = build_data("data".as_ref(), &map, true)?;
+ let (data, _) = build_gamedata("data".as_ref(), &map, true)?;
for demand in &data.demands {
println!("{}", data.item_name(demand.input))
}
}
Action::MapItems { map } => {
- let (data, _) = build_data("data".as_ref(), &map, true)?;
+ let (data, _) = build_gamedata("data".as_ref(), &map, true)?;
for name in &data.item_names {
println!("{name}")
}
}
Action::MapTiles { map } => {
- let (data, _) = build_data("data".as_ref(), &map, true)?;
+ let (data, _) = build_gamedata("data".as_ref(), &map, true)?;
for name in &data.tile_names {
println!("{name}")
}