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

Discussions about Coding and Scripting

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

Postby Dizzy » Sun Jul 22, 2018 4:57 am

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");
Image
Join our UT Discord chat server: https://www.bunnytrack.net/discord
User avatar
Dizzy
Experienced
 
Posts: 99
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf

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

Postby sn260591 » Sun Jul 22, 2018 10:31 am

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();
}
Last edited by sn260591 on Sun Jul 22, 2018 2:05 pm, edited 2 times in total.
Sorry for my bad English
User avatar
sn260591
Average
 
Posts: 52
Joined: Sat Jun 01, 2013 10:38 am
Location: Russia

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

Postby schwap » Sun Jul 22, 2018 1:22 pm

Use 'perObjectConfig' in the class parameters

http://mb.link-m.de/mirror/UndocumentedUC.htm
schwap
Novice
 
Posts: 17
Joined: Thu Aug 25, 2016 1:06 am

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

Postby Dizzy » Mon Jul 23, 2018 1:06 am

Both very interesting and informative replies - thank you!
Image
Join our UT Discord chat server: https://www.bunnytrack.net/discord
User avatar
Dizzy
Experienced
 
Posts: 99
Joined: Tue May 21, 2013 3:57 pm
Personal rank: Oaf


Return to Coding, Scripting

Who is online

Users browsing this forum: No registered users and 3 guests