Hall of fame : Merge two files into one

JackInTheBox

Chieftain
Joined
Sep 30, 2019
Messages
1
Some of you may play civ on multiple devices and find yourselves with different hall of fames that you would like to regroup.

I just did that succesfully and I'm sharing the process.

First you need both Hall of fame data files. You can find them in "Documents\my games\Sid Meier's Civilization VI\HallofFame.sqlite" on each device. I advise copying them as a safety measure. Rename one fo the files "Source.sqlite" and the other 'Destination.sqlite".

Then you need a software to handle the files. I used DB Browser, but feel free to use any other freeware/software that you feel comfortable with.

After launching DB Browser open "Destination.sqlite" and then click "attach database" (in the toolbar) and select "Source.sqlite" and when prompted for a database name call it "source".

Then go into the Execute SQL tab and copy this script :

Code:
/* first we need to update Ids to avoid collisions */
/* it needs to be done in two steps each time to avoid self-collision */
UPDATE source.DataSets SET DataSetId = DataSetId + (select max(DataSetId) from DataSets) + (select max(DataSetId) from source.DataSets) + 1;
UPDATE source.DataSets SET DataSetId = DataSetId + (select max(DataSetId) from DataSets) - (select min(DataSetId) from source.DataSets) + 1;

UPDATE source.GameObjects SET ObjectId = ObjectId + (select max(ObjectId) from GameObjects) + (select max(ObjectId) from source.GameObjects) + 1;
UPDATE source.GameObjects SET ObjectId = ObjectId + (select max(ObjectId) from GameObjects) - (select min(ObjectId) from source.GameObjects) + 1;

UPDATE source.Games SET GameId = GameId + (select max(GameId) from Games) + (select max(GameId) from source.Games) + 1;
UPDATE source.Games SET GameId = GameId + (select max(GameId) from Games) - (select min(GameId) from source.Games) + 1;

/* Now it's only a matter of copying the data in the right order regarding forreign keys */
INSERT INTO Rulesets SELECT s.* FROM source.Rulesets s LEFT JOIN Rulesets d ON d.Ruleset = s.Ruleset WHERE d.Ruleset IS NULL;
INSERT INTO RulesetTypes SELECT s.* FROM source.RulesetTypes s LEFT JOIN RulesetTypes d ON d.Ruleset = s.Ruleset AND d.Type = s.Type WHERE d.Ruleset IS NULL;
INSERT INTO Games SELECT * FROM source.Games;
INSERT INTO GameObjects SELECT * FROM source.GameObjects WHERE Type = 'Player';
INSERT INTO GamePlayers SELECT * FROM source.GamePlayers;
INSERT INTO GameObjects SELECT * FROM source.GameObjects WHERE Type != 'Player';
INSERT INTO RulesetDataPointValues SELECT * FROM source.RulesetDataPointValues;
INSERT INTO GameDataPointValues SELECT * FROM source.GameDataPointValues;
INSERT INTO ObjectDataPointValues SELECT * FROM source.ObjectDataPointValues;
INSERT INTO DataSets SELECT * FROM source.DataSets;
INSERT INTO DataSetValues SELECT * FROM source.DataSetValues;

Now you have to execute the whole script (either clicking the button with a "play" triangle icon, or Ctrl-Return, or Ctrl-R, or F5).

And finally you have Write the changes back into the file with the toolbar button ""Write changes". If you have an issue at any step you can close the program, discard everything and restart.

Once the changes written, move the "Destination.sqlite" file back into the device you want to use (or both devices) and rename it to it's original name "HallofFame.sqlite" (I advise renaming the old one HallofFameBackup.sqlite).

Then Just start Civ6. Warning : The game may crash the first time it launches after the operation (as it did for me) because of some data issues but just start it again and it should be fine as the game knows how to fix the data by itself.

Enjoy!

If you have issues, feel free to contact me.
 
Top Bottom