mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'songtronix/fixes' into 'master'
Fix: Various fixes Closes #726 See merge request veloren/veloren!1306
This commit is contained in:
commit
a68fc077ce
@ -280,23 +280,14 @@ lazy_static! {
|
|||||||
pub static ref ASSETS_PATH: PathBuf = {
|
pub static ref ASSETS_PATH: PathBuf = {
|
||||||
let mut paths = Vec::new();
|
let mut paths = Vec::new();
|
||||||
|
|
||||||
// VELOREN_ASSETS environment variable
|
// Note: Ordering matters here!
|
||||||
|
|
||||||
|
// 1. VELOREN_ASSETS environment variable
|
||||||
if let Ok(var) = std::env::var("VELOREN_ASSETS") {
|
if let Ok(var) = std::env::var("VELOREN_ASSETS") {
|
||||||
paths.push(var.into());
|
paths.push(var.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Executable path
|
// 2. System paths
|
||||||
if let Ok(mut path) = std::env::current_exe() {
|
|
||||||
path.pop();
|
|
||||||
paths.push(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Working path
|
|
||||||
if let Ok(path) = std::env::current_dir() {
|
|
||||||
paths.push(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// System paths
|
|
||||||
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
|
||||||
{
|
{
|
||||||
if let Ok(result) = std::env::var("XDG_DATA_HOME") {
|
if let Ok(result) = std::env::var("XDG_DATA_HOME") {
|
||||||
@ -316,12 +307,28 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Executable path
|
||||||
|
if let Ok(mut path) = std::env::current_exe() {
|
||||||
|
path.pop();
|
||||||
|
paths.push(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Working path
|
||||||
|
if let Ok(path) = std::env::current_dir() {
|
||||||
|
paths.push(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
tracing::trace!("Possible asset locations paths={:?}", paths);
|
||||||
|
|
||||||
for path in paths.clone() {
|
for path in paths.clone() {
|
||||||
match find_folder::Search::ParentsThenKids(3, 1)
|
match find_folder::Search::ParentsThenKids(3, 1)
|
||||||
.of(path)
|
.of(path)
|
||||||
.for_folder("assets")
|
.for_folder("assets")
|
||||||
{
|
{
|
||||||
Ok(assets_path) => return assets_path,
|
Ok(assets_path) => {
|
||||||
|
tracing::info!("Assets found path={}", assets_path.display());
|
||||||
|
return assets_path;
|
||||||
|
},
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,12 @@ impl Player {
|
|||||||
pub fn is_valid(&self) -> bool { Self::alias_is_valid(&self.alias) }
|
pub fn is_valid(&self) -> bool { Self::alias_is_valid(&self.alias) }
|
||||||
|
|
||||||
pub fn alias_is_valid(alias: &str) -> bool {
|
pub fn alias_is_valid(alias: &str) -> bool {
|
||||||
alias.chars().all(|c| c.is_alphanumeric() || c == '_') && alias.len() <= MAX_ALIAS_LEN
|
// TODO: Expose auth name validation and use it here.
|
||||||
|
// See https://gitlab.com/veloren/auth/-/blob/master/server/src/web.rs#L20
|
||||||
|
alias
|
||||||
|
.chars()
|
||||||
|
.all(|c| c.is_alphanumeric() || c == '_' || c == '-')
|
||||||
|
&& alias.len() <= MAX_ALIAS_LEN
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Not to be confused with uid
|
/// Not to be confused with uid
|
||||||
|
Loading…
Reference in New Issue
Block a user