Skip to content

Commit 7e6b4d0

Browse files
authored
Fix #3635 meta.xml file path patterns don't work on html files (#3780)
Add patterns for html
1 parent 1fcd732 commit 7e6b4d0

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

Server/mods/deathmatch/logic/CResource.cpp

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,44 +1465,55 @@ bool CResource::ReadIncludedHTML(CXMLNode* pRoot)
14651465

14661466
if (!strFilename.empty())
14671467
{
1468-
std::string strFullFilename;
14691468
ReplaceSlashes(strFilename);
14701469

1471-
if (IsFilenameUsed(strFilename, false))
1470+
if (!IsValidFilePath(strFilename.c_str()))
14721471
{
1473-
CLogger::LogPrintf("WARNING: Duplicate html file in resource '%s': '%s'\n", m_strResourceName.c_str(), strFilename.c_str());
1472+
m_strFailureReason = SString("Couldn't find html %s for resource %s\n", strFilename.c_str(), m_strResourceName.c_str());
1473+
CLogger::ErrorPrintf(m_strFailureReason);
1474+
return false;
14741475
}
14751476

1476-
// Try to find the file
1477-
if (IsValidFilePath(strFilename.c_str()) && GetFilePath(strFilename.c_str(), strFullFilename))
1477+
std::vector<std::string> vecFiles = GetFilePaths(strFilename.c_str());
1478+
if (vecFiles.empty())
14781479
{
1479-
// This one is supposed to be default, but there's already a default page
1480-
if (bFoundDefault && bIsDefault)
1480+
if (glob::has_magic(strFilename))
14811481
{
1482-
CLogger::LogPrintf("Only one html item can be default per resource, ignoring %s in %s\n", strFilename.c_str(),
1483-
m_strResourceName.c_str());
1484-
bIsDefault = false;
1482+
m_ResourceFilesCountPerDir[strFilename] = vecFiles.size();
1483+
continue;
14851484
}
14861485

1487-
// If this is supposed to be default, we've now found our default page
1488-
if (bIsDefault)
1489-
bFoundDefault = true;
1490-
1491-
// Create a new resource HTML file and add it to the list
1492-
auto pResourceFile = new CResourceHTMLItem(this, strFilename.c_str(), strFullFilename.c_str(), &Attributes, bIsDefault, bIsRaw,
1493-
bIsRestricted, m_bOOPEnabledInMetaXml);
1494-
m_ResourceFiles.push_back(pResourceFile);
1495-
1496-
// This is the first HTML file? Remember it
1497-
if (!pFirstHTML)
1498-
pFirstHTML = pResourceFile;
1499-
}
1500-
else
1501-
{
15021486
m_strFailureReason = SString("Couldn't find html %s for resource %s\n", strFilename.c_str(), m_strResourceName.c_str());
15031487
CLogger::ErrorPrintf(m_strFailureReason);
15041488
return false;
15051489
}
1490+
1491+
for (const std::string& strFilePath : vecFiles)
1492+
{
1493+
std::string strFullFilename;
1494+
1495+
if (GetFilePath(strFilePath.c_str(), strFullFilename))
1496+
{
1497+
// This one is supposed to be default, but there's already a default page
1498+
if (bFoundDefault && bIsDefault)
1499+
{
1500+
CLogger::LogPrintf("Only one html item can be default per resource, ignoring %s in %s\n", strFilename.c_str(), m_strResourceName.c_str());
1501+
bIsDefault = false;
1502+
}
1503+
1504+
// If this is supposed to be default, we've now found our default page
1505+
if (bIsDefault)
1506+
bFoundDefault = true;
1507+
1508+
// Create a new resource HTML file and add it to the list
1509+
auto pResourceFile = new CResourceHTMLItem(this, strFilename.c_str(), strFullFilename.c_str(), &Attributes, bIsDefault, bIsRaw, bIsRestricted, m_bOOPEnabledInMetaXml);
1510+
m_ResourceFiles.push_back(pResourceFile);
1511+
1512+
// This is the first HTML file? Remember it
1513+
if (!pFirstHTML)
1514+
pFirstHTML = pResourceFile;
1515+
}
1516+
}
15061517
}
15071518
else
15081519
{

0 commit comments

Comments
 (0)