summaryrefslogtreecommitdiffstats
path: root/src/IniFile.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2015-02-06 21:52:14 +0100
committerHowaner <franzi.moos@googlemail.com>2015-02-06 21:52:14 +0100
commit2c7925f0adc17d7680ff9791832ab2c349c2301f (patch)
treeef6233b0d9dece6f7520996f2a4d850470e2c2d3 /src/IniFile.cpp
parentReadded old DistributeStackToAreas() comment. (diff)
parentSwitched LuaState to use sizeof... (diff)
downloadcuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.gz
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.bz2
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.lz
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.xz
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.zst
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.zip
Diffstat (limited to 'src/IniFile.cpp')
-rw-r--r--src/IniFile.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/IniFile.cpp b/src/IniFile.cpp
index ded7e4199..3a213a90e 100644
--- a/src/IniFile.cpp
+++ b/src/IniFile.cpp
@@ -888,3 +888,39 @@ void cIniFile::RemoveBom(AString & a_line) const
+
+AStringVector ReadUpgradeIniPorts(
+ cIniFile & a_IniFile,
+ const AString & a_KeyName,
+ const AString & a_PortsValueName,
+ const AString & a_OldIPv4ValueName,
+ const AString & a_OldIPv6ValueName,
+ const AString & a_DefaultValue
+)
+{
+ // Read the regular value, but don't use the default (in order to detect missing value for upgrade):
+ AStringVector Ports = StringSplitAndTrim(a_IniFile.GetValue(a_KeyName, a_PortsValueName), ";,");
+
+ if (Ports.empty())
+ {
+ // Historically there were two separate entries for IPv4 and IPv6, merge them and migrate:
+ AString Ports4 = a_IniFile.GetValue(a_KeyName, a_OldIPv4ValueName, a_DefaultValue);
+ AString Ports6 = a_IniFile.GetValue(a_KeyName, a_OldIPv6ValueName);
+ Ports = MergeStringVectors(StringSplitAndTrim(Ports4, ";,"), StringSplitAndTrim(Ports6, ";,"));
+ a_IniFile.DeleteValue(a_KeyName, a_OldIPv4ValueName);
+ a_IniFile.DeleteValue(a_KeyName, a_OldIPv6ValueName);
+
+ // If those weren't present or were empty, use the default:"
+ if (Ports.empty())
+ {
+ Ports = StringSplitAndTrim(a_DefaultValue, ";,");
+ }
+ a_IniFile.SetValue(a_KeyName, a_PortsValueName, StringsConcat(Ports, ','));
+ }
+
+ return Ports;
+}
+
+
+
+