diff --git a/Server/mods/deathmatch/logic/CResource.cpp b/Server/mods/deathmatch/logic/CResource.cpp index 3dcf147c39..1c2ebe3ea8 100644 --- a/Server/mods/deathmatch/logic/CResource.cpp +++ b/Server/mods/deathmatch/logic/CResource.cpp @@ -1465,44 +1465,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 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 {