aboutsummaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-10-24 20:53:08 +0200
committermetamuffin <metamuffin@disroot.org>2025-10-24 20:53:08 +0200
commite67d2d03f9e2d66a24a6b7561146af589e019891 (patch)
treed776ae10122b569f6d8faf36cd01088ce1231afc /server/src
parent1e5dc0dee2fed17d6cc5c0e98edbb9b72daa6345 (diff)
downloadhurrycurry-e67d2d03f9e2d66a24a6b7561146af589e019891.tar
hurrycurry-e67d2d03f9e2d66a24a6b7561146af589e019891.tar.bz2
hurrycurry-e67d2d03f9e2d66a24a6b7561146af589e019891.tar.zst
Localize book html export
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main.rs78
-rw-r--r--server/src/server.rs4
2 files changed, 42 insertions, 40 deletions
diff --git a/server/src/main.rs b/server/src/main.rs
index 0236ebe4..727ad4b1 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -99,44 +99,7 @@ fn main() -> Result<()> {
let data_path = if let Some(d) = args.data_dir.clone() {
d
} else {
- let mut test_order = Vec::new();
-
- if let Ok(path) = var("HURRYCURRY_DATA_PATH") {
- test_order.push(path);
- }
-
- if let Some(path) = option_env!("HURRYCURRY_DATA_PATH") {
- test_order.push(path.to_owned());
- }
-
- #[cfg(debug_assertions)]
- test_order.push("data".to_string());
-
- #[cfg(windows)]
- match read_windows_reg_datadir() {
- Ok(path) => test_order.push(path),
- Err(e) => warn!("Cannot find read datadir from windows registry: {e}"),
- };
-
- #[cfg(not(windows))]
- test_order.extend([
- "/usr/local/share/hurrycurry/data".to_string(),
- "/usr/share/hurrycurry/data".to_string(),
- "/opt/hurrycurry/data".to_string(),
- ]);
-
- let Some(d) = test_order
- .iter()
- .find(|p| PathBuf::from_str(p).unwrap().join("index.yaml").exists())
- else {
- warn!("The following paths were tested without success: {test_order:#?}",);
- bail!(
- "Could not find the data directory. Use the --data-dir option to specify a path."
- );
- };
-
- info!("Selected data dir {d:?}");
- PathBuf::from_str(d)?
+ find_data_path()?
};
tokio::runtime::Builder::new_multi_thread()
@@ -308,6 +271,45 @@ async fn send_packet(
}
}
+fn find_data_path() -> Result<PathBuf> {
+ let mut test_order = Vec::new();
+
+ if let Ok(path) = var("HURRYCURRY_DATA_PATH") {
+ test_order.push(path);
+ }
+
+ if let Some(path) = option_env!("HURRYCURRY_DATA_PATH") {
+ test_order.push(path.to_owned());
+ }
+
+ #[cfg(debug_assertions)]
+ test_order.push("data".to_string());
+
+ #[cfg(windows)]
+ match read_windows_reg_datadir() {
+ Ok(path) => test_order.push(path),
+ Err(e) => warn!("Cannot find read datadir from windows registry: {e}"),
+ };
+
+ #[cfg(not(windows))]
+ test_order.extend([
+ "/usr/local/share/hurrycurry/data".to_string(),
+ "/usr/share/hurrycurry/data".to_string(),
+ "/opt/hurrycurry/data".to_string(),
+ ]);
+
+ let Some(d) = test_order
+ .iter()
+ .find(|p| PathBuf::from_str(p).unwrap().join("index.yaml").exists())
+ else {
+ warn!("The following paths were tested without success: {test_order:#?}",);
+ bail!("Could not find the data directory. Use the --data-dir option to specify a path.");
+ };
+
+ info!("Selected data dir {d:?}");
+ Ok(PathBuf::from_str(d)?)
+}
+
#[cfg(test)]
mod test {
use hurrycurry_protocol::{Character, PacketS, PlayerClass, PlayerID};
diff --git a/server/src/server.rs b/server/src/server.rs
index 267b3062..e3bcd63d 100644
--- a/server/src/server.rs
+++ b/server/src/server.rs
@@ -25,7 +25,7 @@ use anyhow::{Context, Result};
use hurrycurry_data::{Serverdata, index::DataIndex};
use hurrycurry_game_core::{Game, Involvement, Item, Player, Tile};
use hurrycurry_locale::{
- FALLBACK_LOCALE, TrError,
+ GLOBAL_LOCALE, TrError,
message::{COLORED, MessageDisplayExt},
tre,
};
@@ -573,7 +573,7 @@ impl Server {
return Ok(());
};
if let Some(message) = &message {
- let body = message.display_message(&FALLBACK_LOCALE, &self.game.data, &COLORED);
+ let body = message.display_message(&GLOBAL_LOCALE, &self.game.data, &COLORED);
if !player_data.name.is_empty() {
info!("[{player} {:?}] {body}", player_data.name);
} else {