Skip to content
Permalink
Browse files

Fixed 'upgrade' command not updating <min_mta_version>

  • Loading branch information...
ccw808 committed Jul 7, 2019
1 parent e77c8cd commit a487b099480925cf19c637f8f09668b87a990cc0
@@ -141,19 +141,21 @@ bool CResource::Load()
m_pNodeSettings = pNodeSettings->CopyNode(nullptr);

// Find the client and server version requirements
m_strMinClientReqFromMetaXml = "";
m_strMinServerReqFromMetaXml = "";
m_strMinClientFromMetaXml = "";
m_strMinServerFromMetaXml = "";
CXMLNode* pNodeMinMtaVersion = pRoot->FindSubNode("min_mta_version", 0);

if (pNodeMinMtaVersion && MTASA_VERSION_TYPE == VERSION_TYPE_RELEASE)
if (pNodeMinMtaVersion)
{
if (CXMLAttribute* pAttr = pNodeMinMtaVersion->GetAttributes().Find("server"))
m_strMinServerReqFromMetaXml = pAttr->GetValue();
m_strMinServerFromMetaXml = pAttr->GetValue();
if (CXMLAttribute* pAttr = pNodeMinMtaVersion->GetAttributes().Find("client"))
m_strMinClientReqFromMetaXml = pAttr->GetValue();
m_strMinClientFromMetaXml = pAttr->GetValue();
if (CXMLAttribute* pAttr = pNodeMinMtaVersion->GetAttributes().Find("both"))
m_strMinServerReqFromMetaXml = m_strMinClientReqFromMetaXml = pAttr->GetValue();
m_strMinServerFromMetaXml = m_strMinClientFromMetaXml = pAttr->GetValue();
}
m_strMinServerRequirement = m_strMinServerFromMetaXml;
m_strMinClientRequirement = m_strMinClientFromMetaXml;

// Find the acl requets
CXMLNode* pNodeAclRequest = pRoot->FindSubNode("aclrequest", 0);
@@ -653,17 +655,18 @@ void CResource::LogUpgradeWarnings()
bool CResource::GetCompatibilityStatus(SString& strOutStatus)
{
// Check declared version strings are valid
if (!IsValidVersionString(m_strMinServerReqFromMetaXml) || !IsValidVersionString(m_strMinClientReqFromMetaXml))
if (!IsValidVersionString(m_strMinServerRequirement) || !IsValidVersionString(m_strMinClientRequirement))
{
strOutStatus = "<min_mta_version> section in the meta.xml contains invalid version strings";
return false;
}

// Check this server can run this resource
#if MTASA_VERSION_BUILD != 0
CMtaVersion strServerVersion = CStaticFunctionDefinitions::GetVersionSortable();
if (m_strMinServerReqFromMetaXml > strServerVersion)
if (m_strMinServerRequirement > strServerVersion)
{
strOutStatus = SString("this server version is too low (%s required)", *m_strMinServerReqFromMetaXml);
strOutStatus = SString("this server version is too low (%s required)", *m_strMinServerRequirement);
return false;
}

@@ -673,15 +676,16 @@ bool CResource::GetCompatibilityStatus(SString& strOutStatus)
strOutStatus = "server has come back from the future";
return false;
}
#endif

// Check if calculated version is higher than declared version
if (m_strMinClientReqFromSource > m_strMinClientReqFromMetaXml)
if (m_strMinClientReqFromSource > m_strMinClientFromMetaXml)
{
strOutStatus = "<min_mta_version> section in the meta.xml is incorrect or missing (expected at least ";
strOutStatus += SString("client %s because of '%s')", *m_strMinClientReqFromSource, *m_strMinClientReason);
m_strMinClientReqFromMetaXml = m_strMinClientReqFromSource; // Apply higher version requirement
m_strMinClientRequirement = m_strMinClientReqFromSource; // Apply higher version requirement
}
else if (m_strMinServerReqFromSource > m_strMinServerReqFromMetaXml)
else if (m_strMinServerReqFromSource > m_strMinServerFromMetaXml)
{
strOutStatus = "<min_mta_version> section in the meta.xml is incorrect or missing (expected at least ";
strOutStatus += SString("server %s because of '%s')", *m_strMinServerReqFromSource, *m_strMinServerReason);
@@ -691,12 +695,12 @@ bool CResource::GetCompatibilityStatus(SString& strOutStatus)
{
uint uiNumIncompatiblePlayers = 0;
for (std::list<CPlayer*>::const_iterator iter = g_pGame->GetPlayerManager()->IterBegin(); iter != g_pGame->GetPlayerManager()->IterEnd(); iter++)
if ((*iter)->IsJoined() && m_strMinClientReqFromMetaXml > (*iter)->GetPlayerVersion() && !(*iter)->ShouldIgnoreMinClientVersionChecks())
if ((*iter)->IsJoined() && m_strMinClientRequirement > (*iter)->GetPlayerVersion() && !(*iter)->ShouldIgnoreMinClientVersionChecks())
uiNumIncompatiblePlayers++;

if (uiNumIncompatiblePlayers > 0)
{
strOutStatus = SString("%d connected player(s) below required client version %s", uiNumIncompatiblePlayers, *m_strMinClientReqFromMetaXml);
strOutStatus = SString("%d connected player(s) below required client version %s", uiNumIncompatiblePlayers, *m_strMinClientRequirement);
return false;
}
}
@@ -940,7 +944,7 @@ bool CResource::Start(std::list<CResource*>* pDependents, bool bManualStart, con
m_bClientScripts = StartOptions.bClientScripts;
m_bClientFiles = StartOptions.bClientFiles;

m_pResourceManager->ApplyMinClientRequirement(this, m_strMinClientReqFromMetaXml);
m_pResourceManager->ApplyMinClientRequirement(this, m_strMinClientRequirement);

// Broadcast new resourceelement that is loaded and tell the players that a new resource was started
g_pGame->GetMapManager()->BroadcastResourceElements(m_pResourceElement, m_pDefaultElementGroup);
@@ -310,8 +310,10 @@ class CResource : public EHS
bool HandleAclRequestChangeCommand(const SString& strRightName, bool bAccess, const SString& strWho);
bool HandleAclRequestChange(const CAclRightName& strRightName, bool bAccess, const SString& strWho);

const CMtaVersion& GetMinServerReqFromMetaXml() const noexcept { return m_strMinServerReqFromMetaXml; }
const CMtaVersion& GetMinClientReqFromMetaXml() const noexcept { return m_strMinClientReqFromMetaXml; }
const CMtaVersion& GetMinServerRequirement() const noexcept { return m_strMinServerRequirement; }
const CMtaVersion& GetMinClientRequirement() const noexcept { return m_strMinClientRequirement; }
const CMtaVersion& GetMinServerFromMetaXml() const noexcept { return m_strMinServerFromMetaXml; }
const CMtaVersion& GetMinClientFromMetaXml() const noexcept { return m_strMinClientFromMetaXml; }

bool IsOOPEnabledInMetaXml() const noexcept { return m_bOOPEnabledInMetaXml; }

@@ -426,10 +428,12 @@ class CResource : public EHS
CXMLNode* m_pNodeSettings = nullptr; // Settings XML node, read from meta.xml and copied into it's own instance
CXMLNode* m_pNodeStorage = nullptr; // Dummy XML node used for temporary storage of stuff returned by CSettings::Get

CMtaVersion m_strMinClientReqFromMetaXml; // Min MTA client version as declared in meta.xml
CMtaVersion m_strMinServerReqFromMetaXml; // Min MTA server version as declared in meta.xml
CMtaVersion m_strMinClientReqFromSource; // Min MTA client version as calculated by scanning the script source
CMtaVersion m_strMinServerReqFromSource; // Min MTA server version as calculated by scanning the script source
CMtaVersion m_strMinClientRequirement; // Min MTA client version
CMtaVersion m_strMinServerRequirement; // Min MTA server version
CMtaVersion m_strMinClientFromMetaXml; // Min MTA client version as declared in meta.xml
CMtaVersion m_strMinServerFromMetaXml; // Min MTA server version as declared in meta.xml
CMtaVersion m_strMinClientReqFromSource; // Min MTA client version as calculated by scanning the script source
CMtaVersion m_strMinServerReqFromSource; // Min MTA server version as calculated by scanning the script source
SString m_strMinClientReason;
SString m_strMinServerReason;

@@ -23,8 +23,8 @@ extern CNetServer* g_pRealNetServer;
///////////////////////////////////////////////////////////////
void CResourceChecker::CheckResourceForIssues(CResource* pResource, const string& strResourceZip)
{
m_strMinClientReqFromMetaXml = pResource->GetMinClientReqFromMetaXml();
m_strMinServerReqFromMetaXml = pResource->GetMinServerReqFromMetaXml();
m_strMinClientFromMetaXml = pResource->GetMinClientFromMetaXml();
m_strMinServerFromMetaXml = pResource->GetMinServerFromMetaXml();
m_strReqClientVersion = "";
m_strReqServerVersion = "";
m_strReqClientReason = "";
@@ -321,15 +321,15 @@ void CResourceChecker::CheckMetaSourceForIssues(CXMLNode* pRootNode, const strin
bool* pbOutHasChanged)
{
// Check min_mta_version is correct
if (m_strReqClientVersion > m_strMinClientReqFromMetaXml || m_strReqServerVersion > m_strMinServerReqFromMetaXml)
if (m_strReqClientVersion > m_strMinClientFromMetaXml || m_strReqServerVersion > m_strMinServerFromMetaXml)
{
// It's not right. What to do?
if (checkerMode == ECheckerMode::WARNINGS)
{
SString strTemp = "<min_mta_version> section in the meta.xml is incorrect or missing (expected at least ";
if (m_strReqClientVersion > m_strMinClientReqFromMetaXml)
if (m_strReqClientVersion > m_strMinClientFromMetaXml)
strTemp += SString("client %s because of '%s')", *m_strReqClientVersion, *m_strReqClientReason);
else if (m_strReqServerVersion > m_strMinServerReqFromMetaXml)
else if (m_strReqServerVersion > m_strMinServerFromMetaXml)
strTemp += SString("server %s because of '%s')", *m_strReqServerVersion, *m_strReqServerReason);

CLogger::LogPrint(SString("WARNING: %s %s\n", strResourceName.c_str(), *strTemp));
@@ -339,7 +339,7 @@ void CResourceChecker::CheckMetaSourceForIssues(CXMLNode* pRootNode, const strin
// Create min_mta_version node if required
CXMLNode* pNodeMinMtaVersion = pRootNode->FindSubNode("min_mta_version", 0);
if (!pNodeMinMtaVersion)
pNodeMinMtaVersion = pRootNode->CreateSubNode("min_mta_version");
pNodeMinMtaVersion = pRootNode->CreateSubNode("min_mta_version", pRootNode->FindSubNode("info"));

CXMLAttributes& attributes = pNodeMinMtaVersion->GetAttributes();
attributes.Delete("server");
@@ -747,8 +747,8 @@ ECheckerWhatType CResourceChecker::GetLuaFunctionNameUpgradeInfo(const string& s
if (!strOutVersion.empty())
{
// Function behaviour depends on min_mta_version setting
const CMtaVersion& strMinReqFromMetaXml = bClientScript ? m_strMinClientReqFromMetaXml : m_strMinServerReqFromMetaXml;
if (strMinReqFromMetaXml < strOutVersion)
const CMtaVersion& strMinFromMetaXml = bClientScript ? m_strMinClientFromMetaXml : m_strMinServerFromMetaXml;
if (strMinFromMetaXml < strOutVersion)
return ECheckerWhat::MODIFIED;
return ECheckerWhat::NONE;
}
@@ -765,9 +765,6 @@ ECheckerWhatType CResourceChecker::GetLuaFunctionNameUpgradeInfo(const string& s
///////////////////////////////////////////////////////////////
void CResourceChecker::CheckVersionRequirements(const string& strIdentifierName, bool bClientScript)
{
// if ( MTASA_VERSION_TYPE < VERSION_TYPE_RELEASE )
// return;

static CHashMap<SString, CMtaVersion> clientFunctionMap;
static CHashMap<SString, CMtaVersion> serverFunctionMap;

@@ -74,8 +74,8 @@ class CResourceChecker
bool m_bUpgradeScripts;
unsigned long m_ulDeprecatedWarningCount;
vector<string> m_upgradedFullPathList;
CMtaVersion m_strMinClientReqFromMetaXml;
CMtaVersion m_strMinServerReqFromMetaXml;
CMtaVersion m_strMinClientFromMetaXml;
CMtaVersion m_strMinServerFromMetaXml;
CMtaVersion m_strReqClientVersion;
CMtaVersion m_strReqServerVersion;
SString m_strReqClientReason;
@@ -371,7 +371,7 @@ void MinServerReqCheck(CScriptArgReader& argStream, const char* szVersionReq, co
CResource* pResource = pLuaMain->GetResource();
if (pResource)
{
if (pResource->GetMinServerReqFromMetaXml() < szVersionReq)
if (pResource->GetMinServerRequirement() < szVersionReq)
{
#if MTASA_VERSION_TYPE == VERSION_TYPE_RELEASE
argStream.SetVersionWarning(szVersionReq, "server", szReason);
@@ -57,8 +57,8 @@ bool CResourceStartPacket::Write(NetBitStreamInterface& BitStream) const
// Write the declared min client version for this resource
if (BitStream.Version() >= 0x32)
{
BitStream.WriteString(m_pResource->GetMinServerReqFromMetaXml());
BitStream.WriteString(m_pResource->GetMinClientReqFromMetaXml());
BitStream.WriteString(m_pResource->GetMinServerRequirement());
BitStream.WriteString(m_pResource->GetMinClientRequirement());
}
if (BitStream.Version() >= 0x45)
{

0 comments on commit a487b09

Please sign in to comment.
You can’t perform that action at this time.