Skip to content

Commit

Permalink
Fix the --diff map feature, broken by 57584a6
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Oct 25, 2021
1 parent 007cf0b commit cf3d00f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use map_model::{Map, MapEdits};
use sim::{Sim, SimFlags};
use widgetry::{EventCtx, Settings, State, Transition};

use crate::app::{App, Flags};
use crate::app::{App, Flags, PerMap};
use crate::common::jump_to_time_upon_startup;
use crate::pregame::TitleScreen;
use crate::sandbox::{GameplayMode, SandboxMode};
Expand Down Expand Up @@ -201,7 +201,7 @@ fn setup_app(ctx: &mut EventCtx, mut setup: Setup) -> (App, Vec<Box<dyn State<Ap
let mut map: Map = abstio::read_binary(path.clone(), &mut timer);
map.map_loaded_directly(&mut timer);
let sim = Sim::new(&map, setup.flags.sim_flags.opts.clone());
let mut per_map = crate::app::PerMap::map_loaded(
let mut per_map = PerMap::map_loaded(
map,
sim,
setup.flags.clone(),
Expand All @@ -224,7 +224,7 @@ fn setup_app(ctx: &mut EventCtx, mut setup: Setup) -> (App, Vec<Box<dyn State<Ap
// Get App created with a dummy blank map
let map = Map::blank();
let sim = Sim::new(&map, setup.flags.sim_flags.opts.clone());
let primary = crate::app::PerMap::map_loaded(
let primary = PerMap::map_loaded(
map,
sim,
setup.flags.clone(),
Expand All @@ -235,7 +235,7 @@ fn setup_app(ctx: &mut EventCtx, mut setup: Setup) -> (App, Vec<Box<dyn State<Ap
);
let app = App {
primary,
secondary,
secondary: None,
store_unedited_map_in_secondary: false,
cs,
opts: setup.opts.clone(),
Expand All @@ -247,7 +247,9 @@ fn setup_app(ctx: &mut EventCtx, mut setup: Setup) -> (App, Vec<Box<dyn State<Ap
ctx,
&app,
map_name,
Box::new(move |ctx, app| Transition::Clear(continue_app_setup(ctx, app, title, setup))),
Box::new(move |ctx, app| {
Transition::Clear(continue_app_setup(ctx, app, title, setup, secondary))
}),
)];
(app, states)
} else {
Expand All @@ -256,7 +258,7 @@ fn setup_app(ctx: &mut EventCtx, mut setup: Setup) -> (App, Vec<Box<dyn State<Ap
let primary = ctx.loading_screen("load map", |ctx, mut timer| {
assert!(setup.flags.sim_flags.modifiers.is_empty());
let (map, sim, _) = setup.flags.sim_flags.load_synchronously(timer);
crate::app::PerMap::map_loaded(
PerMap::map_loaded(
map,
sim,
setup.flags.clone(),
Expand All @@ -269,15 +271,15 @@ fn setup_app(ctx: &mut EventCtx, mut setup: Setup) -> (App, Vec<Box<dyn State<Ap
assert!(secondary.is_none());
let mut app = App {
primary,
secondary,
secondary: None,
store_unedited_map_in_secondary: false,
cs,
opts: setup.opts.clone(),
per_obj: crate::app::PerObjectActions::new(),
session: crate::app::SessionState::empty(),
};

let states = continue_app_setup(ctx, &mut app, title, setup);
let states = continue_app_setup(ctx, &mut app, title, setup, None);
(app, states)
}
}
Expand All @@ -287,7 +289,11 @@ fn continue_app_setup(
app: &mut App,
title: bool,
setup: Setup,
secondary: Option<PerMap>,
) -> Vec<Box<dyn State<App>>> {
// Run this after loading the primary map. That process wipes out app.secondary.
app.secondary = secondary;

if !URLManager::change_camera(
ctx,
setup.center_camera.as_ref(),
Expand Down

0 comments on commit cf3d00f

Please sign in to comment.