Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 36 additions & 25 deletions Server/mods/deathmatch/logic/CResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,44 +1462,55 @@ bool CResource::ReadIncludedHTML(CXMLNode* pRoot)

if (!strFilename.empty())
{
std::string strFullFilename;
ReplaceSlashes(strFilename);

if (IsFilenameUsed(strFilename, false))
if (!IsValidFilePath(strFilename.c_str()))
{
CLogger::LogPrintf("WARNING: Duplicate html file in resource '%s': '%s'\n", m_strResourceName.c_str(), strFilename.c_str());
m_strFailureReason = SString("Couldn't find html %s for resource %s\n", strFilename.c_str(), m_strResourceName.c_str());
CLogger::ErrorPrintf(m_strFailureReason);
return false;
}

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

// If this is supposed to be default, we've now found our default page
if (bIsDefault)
bFoundDefault = true;

// Create a new resource HTML file and add it to the list
auto pResourceFile = new CResourceHTMLItem(this, strFilename.c_str(), strFullFilename.c_str(), &Attributes, bIsDefault, bIsRaw,
bIsRestricted, m_bOOPEnabledInMetaXml);
m_ResourceFiles.push_back(pResourceFile);

// This is the first HTML file? Remember it
if (!pFirstHTML)
pFirstHTML = pResourceFile;
}
else
{
m_strFailureReason = SString("Couldn't find html %s for resource %s\n", strFilename.c_str(), m_strResourceName.c_str());
CLogger::ErrorPrintf(m_strFailureReason);
return false;
}

for (const std::string& strFilePath : vecFiles)
{
std::string strFullFilename;

if (GetFilePath(strFilePath.c_str(), strFullFilename))
{
// This one is supposed to be default, but there's already a default page
if (bFoundDefault && bIsDefault)
{
CLogger::LogPrintf("Only one html item can be default per resource, ignoring %s in %s\n", strFilename.c_str(), m_strResourceName.c_str());
bIsDefault = false;
}

// If this is supposed to be default, we've now found our default page
if (bIsDefault)
bFoundDefault = true;

// Create a new resource HTML file and add it to the list
auto pResourceFile = new CResourceHTMLItem(this, strFilename.c_str(), strFullFilename.c_str(), &Attributes, bIsDefault, bIsRaw, bIsRestricted, m_bOOPEnabledInMetaXml);
m_ResourceFiles.push_back(pResourceFile);

// This is the first HTML file? Remember it
if (!pFirstHTML)
pFirstHTML = pResourceFile;
}
}
}
else
{
Expand Down
Loading