summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-31 19:24:39 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-31 19:24:39 +0200
commitb9e06b5da0bdc3644bac37bfcc45e32d0bcc37a5 (patch)
tree1db46b82906163eb09ec7815801f5e3d94b47019
parentff64b6cf1d21e35cbc10ebc6cf3838f5b0244355 (diff)
downloadMultiMC-b9e06b5da0bdc3644bac37bfcc45e32d0bcc37a5.tar
MultiMC-b9e06b5da0bdc3644bac37bfcc45e32d0bcc37a5.tar.gz
MultiMC-b9e06b5da0bdc3644bac37bfcc45e32d0bcc37a5.tar.lz
MultiMC-b9e06b5da0bdc3644bac37bfcc45e32d0bcc37a5.tar.xz
MultiMC-b9e06b5da0bdc3644bac37bfcc45e32d0bcc37a5.zip
GH-1021 make builtin versions not customizable
They use attributes not defined in the OneSix format.
-rw-r--r--logic/minecraft/MinecraftVersion.cpp36
-rw-r--r--logic/minecraft/MinecraftVersion.h5
-rw-r--r--logic/minecraft/RawLibrary.cpp1
3 files changed, 34 insertions, 8 deletions
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp
index 982a5ac3..1451c39d 100644
--- a/logic/minecraft/MinecraftVersion.cpp
+++ b/logic/minecraft/MinecraftVersion.cpp
@@ -53,16 +53,28 @@ bool MinecraftVersion::isMinecraftVersion()
return true;
}
-// 1. assume the local file is good. load, check. If it's good, apply.
-// 2. if discrepancies are found, fall out and fail (impossible to apply incomplete version).
void MinecraftVersion::applyFileTo(MinecraftProfile *version)
{
- getVersionFile()->applyTo(version);
+ if(m_versionSource == Local && getVersionFile())
+ {
+ getVersionFile()->applyTo(version);
+ }
+ else
+ {
+ throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_name));
+ }
}
QJsonDocument MinecraftVersion::toJson(bool saveOrder)
{
- return getVersionFile()->toJson(saveOrder);
+ if(m_versionSource == Local && getVersionFile())
+ {
+ return getVersionFile()->toJson(saveOrder);
+ }
+ else
+ {
+ throw VersionIncomplete(QObject::tr("Can't write incomplete/builtin Minecraft version %1").arg(m_name));
+ }
}
VersionFilePtr MinecraftVersion::getVersionFile()
@@ -76,6 +88,22 @@ VersionFilePtr MinecraftVersion::getVersionFile()
return loadedVersionFile;
}
+bool MinecraftVersion::isCustomizable()
+{
+ switch(m_versionSource)
+ {
+ case Local:
+ case Remote:
+ // locally cached file, or a remote file that we can acquire can be customized
+ return true;
+ case Builtin:
+ // builtins do not follow the normal OneSix format. They are not customizable.
+ default:
+ // Everything else is undefined and therefore not customizable.
+ return false;
+ }
+ return false;
+}
void MinecraftVersion::applyTo(MinecraftProfile *version)
{
diff --git a/logic/minecraft/MinecraftVersion.h b/logic/minecraft/MinecraftVersion.h
index af15c1a4..3795cb41 100644
--- a/logic/minecraft/MinecraftVersion.h
+++ b/logic/minecraft/MinecraftVersion.h
@@ -52,10 +52,7 @@ public: /* methods */
{
return false;
}
- virtual bool isCustomizable() override
- {
- return true;
- }
+ virtual bool isCustomizable() override;
virtual bool isRemovable() override
{
return false;
diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp
index bae6c66a..c4cd97a1 100644
--- a/logic/minecraft/RawLibrary.cpp
+++ b/logic/minecraft/RawLibrary.cpp
@@ -224,6 +224,7 @@ bool RawLibrary::filesExist(const QDir &base) const
}
return true;
}
+
QString RawLibrary::url() const
{
if (!m_absolute_url.isEmpty())