Skip to content

Commit

Permalink
fix incorrect variable migration (#77992)
Browse files Browse the repository at this point in the history
* fix incorrect variable migration

* bump version again
  • Loading branch information
GuardianDll authored Nov 19, 2024
1 parent 82a4ba9 commit c4a030c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,12 +871,12 @@ void game::load_map( const tripoint_abs_sm &pos_sm,
}

void game::legacy_migrate_npctalk_var_prefix( std::unordered_map<std::string, std::string>
map_of_vars )
&map_of_vars )
{
// migrate existing variables with npctalk_var prefix to no prefix (npctalk_var_foo to just foo)
// remove after 0.J

if( savegame_loading_version >= 35 ) {
if( savegame_loading_version >= 36 ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ class game
void load_map( const tripoint_abs_sm &pos_sm, bool pump_events = false );
// Removes legacy npctalk_var_ prefix from older versions of the game. Should be removed after 0.J
static void legacy_migrate_npctalk_var_prefix( std::unordered_map<std::string, std::string>
map_of_vars );
&map_of_vars );
/**
* The overmap which contains the center submap of the reality bubble.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/savegame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern std::map<std::string, std::list<input_event>> quick_shortcuts_map;
* Changes that break backwards compatibility should bump this number, so the game can
* load a legacy format loader.
*/
const int savegame_version = 35;
const int savegame_version = 36;

/*
* This is a global set by detected version header in .sav, maps.txt, or overmap.
Expand Down
2 changes: 1 addition & 1 deletion src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2817,7 +2817,7 @@ void item::io( Archive &archive )
// game::legacy_migrate_npctalk_var_prefix( item_vars );
// doesn't work here, because item_vars is cata::heap<std::map<>>, not std::unordered_map<>
// remove after 0.J
if( savegame_loading_version < 35 ) {
if( savegame_loading_version < 36 ) {
const std::string prefix = "npctalk_var_";
for( auto i = item_vars.begin(); i != item_vars.end(); ) {
if( i->first.rfind( prefix, 0 ) == 0 ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/submap_load_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ static JsonValue submap_fd_pre_migration = json_loader::from_string( submap_fd_p
static void load_from_jsin( submap &sm, const JsonValue &jsin )
{
// Ensure that the JSON is up to date for our savegame version
REQUIRE( savegame_version == 35 );
REQUIRE( savegame_version == 36 );
int version = 0;
JsonObject sm_json = jsin.get_object();
if( sm_json.has_member( "version" ) ) {
Expand Down

0 comments on commit c4a030c

Please sign in to comment.