|
@@ -20,9 +20,9 @@ CModVersion CModVersion::GameVersion()
|
|
|
|
|
|
CModVersion CModVersion::fromString(std::string from)
|
|
|
{
|
|
|
- int major = 0;
|
|
|
- int minor = 0;
|
|
|
- int patch = 0;
|
|
|
+ int major = Any;
|
|
|
+ int minor = Any;
|
|
|
+ int patch = Any;
|
|
|
try
|
|
|
{
|
|
|
auto pointPos = from.find('.');
|
|
@@ -45,11 +45,29 @@ CModVersion CModVersion::fromString(std::string from)
|
|
|
|
|
|
std::string CModVersion::toString() const
|
|
|
{
|
|
|
- return std::to_string(major) + '.' + std::to_string(minor) + '.' + std::to_string(patch);
|
|
|
+ std::string res;
|
|
|
+ if(major != Any)
|
|
|
+ {
|
|
|
+ res += std::to_string(major);
|
|
|
+ if(minor != Any)
|
|
|
+ {
|
|
|
+ res += '.' + std::to_string(minor);
|
|
|
+ if(patch != Any)
|
|
|
+ res += '.' + std::to_string(patch);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
bool CModVersion::compatible(const CModVersion & other, bool checkMinor, bool checkPatch) const
|
|
|
{
|
|
|
+ if(minor == Any || other.minor == Any)
|
|
|
+ checkMinor = false;
|
|
|
+ if(patch == Any || other.patch == Any)
|
|
|
+ checkPatch = false;
|
|
|
+
|
|
|
+ assert(checkMinor || !checkPatch);
|
|
|
+
|
|
|
return (major == other.major &&
|
|
|
(!checkMinor || minor >= other.minor) &&
|
|
|
(!checkPatch || minor > other.minor || (minor == other.minor && patch >= other.patch)));
|
|
@@ -57,11 +75,12 @@ bool CModVersion::compatible(const CModVersion & other, bool checkMinor, bool ch
|
|
|
|
|
|
bool CModVersion::isNull() const
|
|
|
{
|
|
|
- return major == 0 && minor == 0 && patch == 0;
|
|
|
+ return major == Any;
|
|
|
}
|
|
|
|
|
|
bool operator < (const CModVersion & lesser, const CModVersion & greater)
|
|
|
{
|
|
|
+ //specific is "greater" than non-specific, that's why do not check for Any value
|
|
|
if(lesser.major == greater.major)
|
|
|
{
|
|
|
if(lesser.minor == greater.minor)
|