mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +03:00
Fix web build and directory listing, and make sure huge_seattle is
treated separately in the updater. #326 [rebuild] [release]
This commit is contained in:
parent
054561412d
commit
3d3cf9f3ea
@ -2,8 +2,6 @@ use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::Timer;
|
||||
|
||||
/// A list of all canonical data files for A/B Street that're uploaded somewhere. The file formats
|
||||
/// are tied to the latest version of the git repo. Players use the updater crate to sync these
|
||||
/// files with local copies.
|
||||
@ -25,7 +23,8 @@ pub struct Entry {
|
||||
impl Manifest {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn load() -> Manifest {
|
||||
crate::maybe_read_json(crate::path("MANIFEST.json"), &mut Timer::throwaway()).unwrap()
|
||||
crate::maybe_read_json(crate::path("MANIFEST.json"), &mut crate::Timer::throwaway())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@ -39,7 +38,8 @@ impl Manifest {
|
||||
for path in self.entries.keys() {
|
||||
// TODO Some hardcoded weird exceptions
|
||||
if !data_packs.runtime.contains("huge_seattle")
|
||||
&& path == "data/system/seattle/scenarios/montlake/everyone_weekday.bin"
|
||||
&& (path == "data/system/seattle/maps/huge_seattle.bin"
|
||||
|| path == "data/system/seattle/scenarios/huge_seattle/weekday.bin")
|
||||
{
|
||||
remove.push(path.clone());
|
||||
continue;
|
||||
@ -80,7 +80,7 @@ impl DataPacks {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn load_or_create() -> DataPacks {
|
||||
let path = crate::path("player/data.json");
|
||||
match crate::maybe_read_json::<DataPacks>(path.clone(), &mut Timer::throwaway()) {
|
||||
match crate::maybe_read_json::<DataPacks>(path.clone(), &mut crate::Timer::throwaway()) {
|
||||
Ok(mut cfg) => {
|
||||
// The game breaks without this required data pack.
|
||||
cfg.runtime.insert("seattle".to_string());
|
||||
|
@ -16,7 +16,7 @@ static SYSTEM_DATA: include_dir::Dir = include_dir::include_dir!(
|
||||
"../data/system",
|
||||
"assets/",
|
||||
"fonts/",
|
||||
"proposals/"
|
||||
"proposals/",
|
||||
"seattle/city.bin",
|
||||
"seattle/maps/montlake.bin",
|
||||
// used by tutorial
|
||||
@ -38,19 +38,27 @@ pub fn file_exists<I: Into<String>>(path: I) -> bool {
|
||||
|
||||
pub fn list_dir(dir: String) -> Vec<String> {
|
||||
let mut results = BTreeSet::new();
|
||||
if let Some(dir) = SYSTEM_DATA.get_dir(dir.trim_start_matches("../data/system/")) {
|
||||
if dir == "../data/system" {
|
||||
for f in SYSTEM_DATA.files() {
|
||||
results.insert(format!("../data/system/{}", f.path().display()));
|
||||
}
|
||||
} else if let Some(dir) = SYSTEM_DATA.get_dir(dir.trim_start_matches("../data/system/")) {
|
||||
for f in dir.files() {
|
||||
results.insert(format!("../data/system/{}", f.path().display()));
|
||||
}
|
||||
} else {
|
||||
error!("Can't list_dir({})", dir);
|
||||
warn!("list_dir({}): not in SYSTEM_DATA, maybe it's remote", dir);
|
||||
}
|
||||
|
||||
// Merge with remote files. Duplicates handled by BTreeSet.
|
||||
let dir = dir.trim_start_matches("../");
|
||||
let mut dir = dir.trim_start_matches("../").to_string();
|
||||
if !dir.ends_with("/") {
|
||||
dir = format!("{}/", dir);
|
||||
}
|
||||
for f in Manifest::load().entries.keys() {
|
||||
if f.starts_with(dir) {
|
||||
results.insert(format!("../{}", f));
|
||||
if let Some(path) = f.strip_prefix(&dir) {
|
||||
// Just list the things immediately in this directory; don't recurse arbitrarily
|
||||
results.insert(format!("../{}/{}", dir, path.split("/").next().unwrap()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user