}\r
\r
const VALHEIM_PROCESS_NAME: &str = "valheim_server";\r
+const STRING_BEFORE_CHARACTER_NAME: &str = "Got character ZDOID from";\r
+const STRING_BEFORE_NB_OF_CONNECTIONS: &str = "Connections";\r
\r
#[cfg(target_os = "linux")]\r
fn get_active_players() -> Vec<String> {\r
Ok(Some(entry)) => {\r
if let (Some(unit), Some(mess)) = (entry.get("_SYSTEMD_UNIT"), entry.get("MESSAGE")) {\r
if unit == "valheim.service" {\r
- //"Got character ZDOID from {}"\r
- if let Some(pos) = mess.find("Got character ZDOID from") {\r
- let character_str = mess.get(pos+25..).unwrap();\r
+ if let Some(pos) = mess.find(STRING_BEFORE_CHARACTER_NAME) {\r
+ let character_str = mess.get(pos+STRING_BEFORE_CHARACTER_NAME.len()+1..).unwrap();\r
if let Some(pos_end) = character_str.find(" : ") {\r
let player_name = String::from(character_str.get(0..pos_end).unwrap());\r
if !players.contains(&player_name) {\r
}\r
}\r
}\r
- else if let Some(pos) = mess.find("Connections") {\r
- let nb_of_connections_str = mess.get(pos+12..).unwrap();\r
+ else if let Some(pos) = mess.find(STRING_BEFORE_NB_OF_CONNECTIONS) {\r
+ let nb_of_connections_str = mess.get(pos+STRING_BEFORE_NB_OF_CONNECTIONS.len()+1..).unwrap();\r
if let Some(pos_end) = nb_of_connections_str.find(' ') {\r
if let Ok(n) = nb_of_connections_str.get(0..pos_end).unwrap().parse() {\r
number_of_connections = n;\r