Page 1 of 1

Retaining config values (.ini settings) when upgrading mods?

Posted: Sun Jul 22, 2018 4:57 am
by Dizzy
Is there an established method for retaining a mod's settings inside .ini files (both client- and server-side) when you are upgrading or renaming your mods?

For example, let's say you are running a mod called MyCoolModv1, and you want to upgrade to MyCoolModv2.

Before the upgrade, your .ini files might look like this:
• Server-side settings: stored on servers as MyCoolMod_ServerSide.ini under a section called [MyCoolModv1.CoolStuff].
• Client-side settings: stored on clients as MyCoolMod_ClientSide.ini under a section called [MyCoolModv1.CoolStuff].

After you upgrade, however, the mod now looks for settings in the .inis, but under [MyCoolModv2.CoolStuff]. Since those settings don't exist, it uses the default values. Server-side, this isn't a problem because the admin can just copy/paste the settings under the new heading. But clients don't have the knowledge to do this.

I'm aware of one potential solution where you can use a second separate mod just for storing settings, whose name should not change when you update the main mod. For example, the mod "BTPlusPlusv009" uses a separate package called "BTPPUser" to store settings under "[BTPPUser.ClientData]" -- and this works, up until you want to extend the number of settings available in the mod, or change the names of some of those settings, in which case you find yourself needing to update (and therefore rename) BTPPUser to BTPPUser_v2 and face the same problem all over again.

So how have others solved this problem?

Is there a design pattern or a method where you can actually specify arbitrary .ini, package and class names to store and retrieve settings data?

I'm imagining some code like

Code: Select all

MaxPlayers = SettingsManager.GetSetting("MyCoolMod.ini", "MyCoolMod.CoolStuff", "MaxPlayers");

Re: Retaining config values (.ini settings) when upgrading m

Posted: Sun Jul 22, 2018 10:31 am
by sn260591

Code: Select all

class CoolStuffv2 expands Mutator config(MyCoolModv2);

var config bool bNoFirstRun;
var config int SomeSetting;

function PreBeginPlay()
{
	Super.PreBeginPlay();

	if (!bNoFirstRun && (DynamicLoadObject("MyCoolModv1.CoolStuffv1", Class'Class', true) != None))
	{
		SomeSetting = int(ConsoleCommand("get MyCoolModv1.CoolStuffv1 SomeSetting"));
		bNoFirstRun = true;
	}

	// Some code

	SaveConfig();
}

Re: Retaining config values (.ini settings) when upgrading m

Posted: Sun Jul 22, 2018 1:22 pm
by schwap
Use 'perObjectConfig' in the class parameters

http://mb.link-m.de/mirror/UndocumentedUC.htm

Re: Retaining config values (.ini settings) when upgrading m

Posted: Mon Jul 23, 2018 1:06 am
by Dizzy
Both very interesting and informative replies - thank you!