mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 07:25:47 +03:00
centralize a little more path building in abstutil
This commit is contained in:
parent
720f9b8b30
commit
6170792328
@ -47,7 +47,6 @@ pub const AB_TESTS: &str = "ab_tests";
|
|||||||
pub const AB_TEST_SAVES: &str = "ab_test_saves";
|
pub const AB_TEST_SAVES: &str = "ab_test_saves";
|
||||||
pub const EDITS: &str = "edits";
|
pub const EDITS: &str = "edits";
|
||||||
pub const NEIGHBORHOODS: &str = "neighborhoods";
|
pub const NEIGHBORHOODS: &str = "neighborhoods";
|
||||||
pub const POLYGONS: &str = "polygons";
|
|
||||||
pub const SAVE: &str = "save";
|
pub const SAVE: &str = "save";
|
||||||
pub const SCENARIOS: &str = "scenarios";
|
pub const SCENARIOS: &str = "scenarios";
|
||||||
pub const SHORTCUTS: &str = "shortcuts";
|
pub const SHORTCUTS: &str = "shortcuts";
|
||||||
@ -56,14 +55,6 @@ pub fn path1(map_name: &str, category: &str, dir: &str) -> String {
|
|||||||
format!("../data/{}/{}/{}", category, map_name, dir)
|
format!("../data/{}/{}/{}", category, map_name, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path1_json(map_name: &str, category: &str, instance: &str) -> String {
|
|
||||||
format!("../data/{}/{}/{}.json", category, map_name, instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path1_bin(map_name: &str, category: &str, instance: &str) -> String {
|
|
||||||
format!("../data/{}/{}/{}.bin", category, map_name, instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn path2_dir(map_name: &str, category: &str, dir: &str) -> String {
|
pub fn path2_dir(map_name: &str, category: &str, dir: &str) -> String {
|
||||||
format!("../data/{}/{}/{}/", category, map_name, dir)
|
format!("../data/{}/{}/{}/", category, map_name, dir)
|
||||||
}
|
}
|
||||||
@ -103,3 +94,11 @@ pub fn path_prebaked_results(map_name: &str) -> String {
|
|||||||
pub fn path_shortcut(name: &str) -> String {
|
pub fn path_shortcut(name: &str) -> String {
|
||||||
format!("../data/shortcuts/{}.json", name)
|
format!("../data/shortcuts/{}.json", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn path_scenario(map_name: &str, scenario_name: &str) -> String {
|
||||||
|
format!("../data/scenarios/{}/{}.bin", map_name, scenario_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn path_edits(map_name: &str, edits_name: &str) -> String {
|
||||||
|
format!("../data/edits/{}/{}.json", map_name, edits_name)
|
||||||
|
}
|
||||||
|
@ -123,7 +123,7 @@ fn launch_test(test: &ABTest, ui: &mut UI, ctx: &mut EventCtx) -> ABTestMode {
|
|||||||
&format!("Launching A/B test {}", test.test_name),
|
&format!("Launching A/B test {}", test.test_name),
|
||||||
|ctx, mut timer| {
|
|ctx, mut timer| {
|
||||||
let scenario: Scenario = abstutil::read_binary(
|
let scenario: Scenario = abstutil::read_binary(
|
||||||
&abstutil::path1_bin(&test.map_name, abstutil::SCENARIOS, &test.scenario_name),
|
&abstutil::path_scenario(&test.map_name, &test.scenario_name),
|
||||||
&mut timer,
|
&mut timer,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -213,11 +213,7 @@ pub fn prebake() {
|
|||||||
for map_name in vec!["montlake", "23rd"] {
|
for map_name in vec!["montlake", "23rd"] {
|
||||||
timer.start(&format!("run normal sim for {}", map_name));
|
timer.start(&format!("run normal sim for {}", map_name));
|
||||||
let (map, mut sim, _) = SimFlags {
|
let (map, mut sim, _) = SimFlags {
|
||||||
load: abstutil::path1_bin(
|
load: abstutil::path_scenario(map_name, "weekday_typical_traffic_from_psrc"),
|
||||||
map_name,
|
|
||||||
abstutil::SCENARIOS,
|
|
||||||
"weekday_typical_traffic_from_psrc",
|
|
||||||
),
|
|
||||||
use_map_fixes: true,
|
use_map_fixes: true,
|
||||||
rng_seed: Some(42),
|
rng_seed: Some(42),
|
||||||
opts: SimOptions::new("prebaked"),
|
opts: SimOptions::new("prebaked"),
|
||||||
|
@ -69,7 +69,7 @@ fn load_scenario(wiz: &mut Wizard, ctx: &mut EventCtx, ui: &mut UI) -> Option<Tr
|
|||||||
abstutil::list_all_objects(abstutil::SCENARIOS, &map_name)
|
abstutil::list_all_objects(abstutil::SCENARIOS, &map_name)
|
||||||
})?;
|
})?;
|
||||||
let scenario = abstutil::read_binary(
|
let scenario = abstutil::read_binary(
|
||||||
&abstutil::path1_bin(&map_name, abstutil::SCENARIOS, &s),
|
&abstutil::path_scenario(&map_name, &s),
|
||||||
&mut Timer::throwaway(),
|
&mut Timer::throwaway(),
|
||||||
);
|
);
|
||||||
Some(Transition::Replace(Box::new(
|
Some(Transition::Replace(Box::new(
|
||||||
|
@ -75,7 +75,7 @@ impl GameplayMode {
|
|||||||
s
|
s
|
||||||
} else {
|
} else {
|
||||||
abstutil::read_binary(
|
abstutil::read_binary(
|
||||||
&abstutil::path1_bin(&ui.primary.map.get_name(), abstutil::SCENARIOS, &name),
|
&abstutil::path_scenario(&ui.primary.map.get_name(), &name),
|
||||||
timer,
|
timer,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -73,10 +73,7 @@ impl MapEdits {
|
|||||||
if edits_name == "no_edits" {
|
if edits_name == "no_edits" {
|
||||||
return MapEdits::new(map_name.to_string());
|
return MapEdits::new(map_name.to_string());
|
||||||
}
|
}
|
||||||
abstutil::read_json(
|
abstutil::read_json(&abstutil::path_edits(map_name, edits_name), timer)
|
||||||
&abstutil::path1_json(map_name, abstutil::EDITS, edits_name),
|
|
||||||
timer,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Version these
|
// TODO Version these
|
||||||
|
Loading…
Reference in New Issue
Block a user