Skip to content

Fix FRED resetting the grid position after saving a mission#7552

Open
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/7548
Open

Fix FRED resetting the grid position after saving a mission#7552
Goober5000 wants to merge 1 commit into
scp-fs2open:masterfrom
Goober5000:fix/7548

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

When FRED2 saves a mission, OnSaveDocument() reloads it via load_mission(MPF_FAST_RELOAD). That reload calls clear_mission() -> fred_render_init() -> create_default_grid(), which rebuilds The_grid as the default origin-centered XZ plane, discarding any adjustments made in the Adjust Grid dialog (e.g. the X-Z Plane Y Level). The grid is editor display state and is not stored in the mission file, so the reload had nothing to restore it from.

The camera (view_pos/view_orient) is already preserved across this reload; apply the same preserve-and-restore pattern to the grid by capturing its orientation, center, dimensions, and square size before clear_mission() and rebuilding it with create_grid() afterward.

qtfred is unaffected because its save path does not reload the mission.

Fixes #7548

When FRED2 saves a mission, OnSaveDocument() reloads it via
load_mission(MPF_FAST_RELOAD).  That reload calls clear_mission() ->
fred_render_init() -> create_default_grid(), which rebuilds The_grid as
the default origin-centered XZ plane, discarding any adjustments made in
the Adjust Grid dialog (e.g. the X-Z Plane Y Level).  The grid is editor
display state and is not stored in the mission file, so the reload had
nothing to restore it from.

The camera (view_pos/view_orient) is already preserved across this reload;
apply the same preserve-and-restore pattern to the grid by capturing its
orientation, center, dimensions, and square size before clear_mission()
and rebuilding it with create_grid() afterward.

qtfred is unaffected because its save path does not reload the mission.

Fixes scp-fs2open#7548

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. fred A feature or issue related to the FReespace EDitor (FRED) labels Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. fred A feature or issue related to the FReespace EDitor (FRED)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FRED resets grid position after saving a mission

2 participants