Namespace data/player/{edits,camera_state,saves} by city name. #326

This commit is contained in:
Dustin Carlino 2020-11-14 14:28:41 -08:00
parent 8101c2a820
commit 5107b0f6c2
2 changed files with 15 additions and 9 deletions

View File

@ -165,26 +165,32 @@ pub fn parse_scenario_path(path: &str) -> (MapName, String) {
// Player data (Players edit this)
pub fn path_camera_state(name: &MapName) -> String {
path(format!("player/camera_state/{}.json", name.map))
path(format!(
"player/camera_state/{}/{}.json",
name.city, name.map
))
}
pub fn path_edits(name: &MapName, edits_name: &str) -> String {
path(format!("player/edits/{}/{}.json", name.map, edits_name))
path(format!(
"player/edits/{}/{}/{}.json",
name.city, name.map, edits_name
))
}
pub fn path_all_edits(name: &MapName) -> String {
path(format!("player/edits/{}", name.map))
path(format!("player/edits/{}/{}", name.city, name.map))
}
pub fn path_save(name: &MapName, edits_name: &str, run_name: &str, time: String) -> String {
path(format!(
"player/saves/{}/{}_{}/{}.bin",
name.map, edits_name, run_name, time
"player/saves/{}/{}/{}_{}/{}.bin",
name.city, name.map, edits_name, run_name, time
))
}
pub fn path_all_saves(name: &MapName, edits_name: &str, run_name: &str) -> String {
path(format!(
"player/saves/{}/{}_{}",
name.map, edits_name, run_name
"player/saves/{}/{}/{}_{}",
name.city, name.map, edits_name, run_name
))
}

View File

@ -85,8 +85,8 @@ are missing, etc. A summary of the commands available so far:
hour since midnight, throughput for that one hour period).
- **/map**
- **GET /map/get-edits**: Returns the current map edits in JSON. You can save
this to a file in `data/player/edits/map_name/` and later use it in-game
normally. You can also later run the `headless` server with
this to a file in `data/player/edits/city_name/map_name/` and later use it
in-game normally. You can also later run the `headless` server with
`--edits=name_of_edits`.
- **GET /map/get-edit-road-command?id=123**: Returns an object that can be
modified and then added to map edits.