aboutsummaryrefslogtreecommitdiff
path: root/server/src/server.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-24 18:43:49 +0100
committertpart <tpart120@proton.me>2026-02-26 20:49:13 +0100
commit28e1cfa50847de1a7347531054bd62c88f304678 (patch)
tree25626a8df6b01a2a8f3174d75de42008b9126d8c /server/src/server.rs
parentb9af9a5d862836051d07fad9803cb3d308968668 (diff)
downloadhurrycurry-28e1cfa50847de1a7347531054bd62c88f304678.tar
hurrycurry-28e1cfa50847de1a7347531054bd62c88f304678.tar.bz2
hurrycurry-28e1cfa50847de1a7347531054bd62c88f304678.tar.zst
update server to new tile stacks
Diffstat (limited to 'server/src/server.rs')
-rw-r--r--server/src/server.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/server/src/server.rs b/server/src/server.rs
index bd1d0f86..7d267cad 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -21,8 +21,8 @@ use crate::{
random_float,
scoreboard::ScoreboardStore,
};
-use anyhow::{Context, Result};
-use hurrycurry_data::{Serverdata, index::DataIndex};
+use anyhow::{Context, Result, anyhow};
+use hurrycurry_data::{Serverdata, build_data};
use hurrycurry_game_core::{Game, Involvement, Item, Player, Tile};
use hurrycurry_locale::{
GLOBAL_LOCALE, TrError,
@@ -31,9 +31,7 @@ use hurrycurry_locale::{
};
use hurrycurry_protocol::{
Character, Gamedata, Hand, ItemLocation, Menu, MessageTimeout, PacketC, PacketS, PlayerClass,
- PlayerID, Score,
- glam::Vec2,
- movement::MovementBase,
+ PlayerID, Score, glam::Vec2, movement::MovementBase,
};
use log::{info, warn};
use std::{
@@ -62,6 +60,7 @@ pub enum AnnounceState {
pub struct ServerConfig {
pub inactivity_timeout: f32,
pub lobby: String,
+ pub data_path: PathBuf,
}
pub struct Server {
@@ -80,23 +79,17 @@ pub struct Server {
pub packet_loopback: VecDeque<PacketS>,
pub last_movement_update: HashMap<PlayerID, Instant>,
pub player_inactivity_timers: HashMap<PlayerID, f32>,
- pub index: DataIndex,
pub packet_out: VecDeque<PacketC>,
pub scoreboard: ScoreboardStore,
pub editor_address: Option<String>,
}
impl Server {
- pub fn new(
- data_path: PathBuf,
- config: ServerConfig,
- tx: broadcast::Sender<PacketC>,
- ) -> Result<Self> {
+ pub fn new(config: ServerConfig, tx: broadcast::Sender<PacketC>) -> Result<Self> {
Ok(Self {
config,
game: Game::default(),
tick_perf: (Duration::ZERO, 0),
- index: DataIndex::new(data_path).context("Failed to load data index")?,
broadcast: tx,
announce_state: AnnounceState::Done,
packet_out: VecDeque::new(),
@@ -116,6 +109,7 @@ impl Server {
impl Default for ServerConfig {
fn default() -> Self {
Self {
+ data_path: "data".into(),
inactivity_timeout: 60.,
lobby: "lobby".to_string(),
}
@@ -352,6 +346,14 @@ 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)
+ .context(anyhow!("preparing gamedata for {:?}", name))?,
+ None,
+ );
+ Ok(())
+ }
pub fn load(
&mut self,
(gamedata, serverdata): (Gamedata, Serverdata),