Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KeyValues.Merge #2184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add KeyValues.Merge #2184

wants to merge 1 commit into from

Conversation

Fyren
Copy link
Contributor

@Fyren Fyren commented Jun 18, 2024

AI in Discord brought up that Import/CopySubkeys doesn't do what you want if you want to merge together KVs. Although it does copy the foreign data in, it also replaces the existing data when it does so. To get around this, his workaround was to manually iterate, create, and import:

if (!hKVSource.GotoFirstSubKey(false)) {
    return;
}

char sSectionName[256];
do {
    hKVSource.GetSectionName(sSectionName, sizeof(sSectionName));
    hKVDestination.JumpToKey(sSectionName, true);
    hKVDestination.Import(hKVSource);
    hKVDestination.GoBack();
} while (hKVSource.GotoNextKey(false));

With this PR, you should be able to just do hKVDestination.Merge(hKVSource).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant