Skip to content

Commit 9ce52df

Browse files
committed
FIX: Possible save file corruption when reverting to default settings using the settings window
git-svn-id: svn://tron.homeunix.org/simutrans/simutrans/trunk@11722 8aca7d54-2c30-db11-9de9-000461428c89
1 parent 2a48688 commit 9ce52df

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

simutrans/history.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
FIX: Missing collision check for water factories
99
FIX: Crash when screenshotting in-game window with non-0 position
1010
FIX: Graphical glitch when dragging the forest tool across slopes if pakset does not have double grounds
11+
FIX: Possible save file corruption when reverting to default settings using the settings window
1112

1213

1314
Release of 124.3.1 (r11671 on 5-Apr-2025):

src/simutrans/gui/settings_frame.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,17 @@ settings_frame_t::settings_frame_t(settings_t* const s) :
8585
bool settings_frame_t::action_triggered( gui_action_creator_t *comp, value_t )
8686
{
8787
// some things must stay the same when loading defaults
88+
const sint32 old_size_x = sets->size_x;
89+
const sint32 old_size_y = sets->size_y;
90+
const sint32 old_number = sets->map_number;
91+
const uint8 old_rot = sets->rotation;
92+
const uint32 old_city_count = sets->city_count;
93+
8894
std::string old_save = sets->get_filename();
89-
sint32 old_number = sets->get_map_number();
90-
uint8 old_rot = sets->get_rotation();
95+
9196
uint8 old_player_type[MAX_PLAYER_COUNT];
9297
memcpy(old_player_type, sets->player_type, sizeof(old_player_type));
98+
9399
// now we can change values
94100
if( comp==&revert_to_simuconf ) {
95101
// reread from simucon.tab(s) the settings and apply them
@@ -155,10 +161,15 @@ bool settings_frame_t::action_triggered( gui_action_creator_t *comp, value_t )
155161
climates.init(sets);
156162
set_windowsize(get_windowsize());
157163
}
164+
158165
// restore essential values
159-
sets->set_filename(old_save.c_str());
166+
sets->set_size(old_size_x, old_size_y);
160167
sets->map_number = old_number;
161-
sets->rotation = old_rot;
168+
sets->rotation = old_rot;
169+
sets->city_count = old_city_count;
170+
171+
sets->set_filename(old_save.c_str());
172+
162173
memcpy(sets->player_type, old_player_type, sizeof(old_player_type));
163174
return true;
164175
}

0 commit comments

Comments
 (0)