Properly detect if the instance is vanilla and don't treat it as custom.

This commit is contained in:
Petr Mrázek 2014-08-11 02:17:48 +02:00
parent fd6706391b
commit 814d5d3315
6 changed files with 23 additions and 2 deletions

View File

@ -157,8 +157,11 @@ bool InstanceVersion::removeFtbPack()
bool InstanceVersion::isVanilla()
{
QDir patches(PathCombine(m_instance->instanceRoot(), "patches/"));
if(VersionPatches.size() >= 1)
for(auto patchptr: VersionPatches)
{
if(patchptr->isCustom())
return false;
}
if(QFile::exists(PathCombine(m_instance->instanceRoot(), "custom.json")))
return false;
if(QFile::exists(PathCombine(m_instance->instanceRoot(), "version.json")))

View File

@ -155,3 +155,9 @@ bool MinecraftVersion::hasUpdate()
{
return m_versionSource == Remote || (m_versionSource == Local && upstreamUpdate);
}
bool MinecraftVersion::isCustom()
{
// if we add any other source types, this will evaluate to false for them.
return m_versionSource != Builtin && m_versionSource != Local && m_versionSource != Remote;
}

View File

@ -47,6 +47,7 @@ public: /* methods */
virtual QString getPatchFilename() override;
bool needsUpdate();
bool hasUpdate();
virtual bool isCustom();
private: /* methods */
void applyFileTo(InstanceVersion *version);

View File

@ -199,6 +199,7 @@ void VersionBuilder::buildFromMultilayer()
throw VersionIncomplete("org.lwjgl");
}
lwjglPatch->setOrder(-1);
lwjgl->setVanilla(true);
m_version->VersionPatches.append(lwjglPatch);
// load all patches, put into map for ordering, apply in the right order

View File

@ -53,9 +53,18 @@ public: /* methods */
{
return filename;
}
virtual bool isCustom()
{
return !isVanilla;
};
void setVanilla (bool state)
{
isVanilla = state;
}
public: /* data */
int order = 0;
bool isVanilla = false;
QString name;
QString fileId;
QString version;

View File

@ -26,6 +26,7 @@ public:
virtual QString getPatchName() = 0;
virtual QString getPatchVersion() = 0;
virtual QString getPatchFilename() = 0;
virtual bool isCustom() = 0;
};
typedef std::shared_ptr<VersionPatch> VersionPatchPtr;