Skip to content

Commit

Permalink
Refactor m_revTexNameMap m_texNameMap
Browse files Browse the repository at this point in the history
  • Loading branch information
hexagonrecursion committed Aug 21, 2024
1 parent 13ed7ba commit a29dcd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions colobot-base/src/graphics/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1894,8 +1894,8 @@ Texture CEngine::CreateTexture(const std::filesystem::path& texName, const Textu
return tex;
}

m_texNameMap[TempToString(texName)] = tex;
m_revTexNameMap[tex] = TempToString(texName);
m_texNameMap[texName] = tex;
m_revTexNameMap[tex] = texName;

return tex;
}
Expand All @@ -1916,7 +1916,7 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams&
if (m_texBlacklist.find(TempToPath(name)) != m_texBlacklist.end())
return Texture();

std::map<std::string, Texture>::iterator it = m_texNameMap.find(name);
auto it = m_texNameMap.find(TempToPath(name));
if (it != m_texNameMap.end())
return (*it).second;

Expand Down Expand Up @@ -2031,7 +2031,7 @@ bool CEngine::LoadAllTextures()

void CEngine::DeleteTexture(const std::string& texName)
{
auto it = m_texNameMap.find(texName);
auto it = m_texNameMap.find(TempToPath(texName));
if (it == m_texNameMap.end())
return;

Expand Down Expand Up @@ -2062,7 +2062,7 @@ void CEngine::DeleteTexture(const Texture& tex)

void CEngine::CreateOrUpdateTexture(const std::string& texName, CImage* img)
{
auto it = m_texNameMap.find(texName);
auto it = m_texNameMap.find(TempToPath(texName));
if (it == m_texNameMap.end())
{
LoadTexture(texName, img);
Expand Down
4 changes: 2 additions & 2 deletions colobot-base/src/graphics/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,9 @@ class CEngine : public CSingleton<CEngine>
int m_multisample;

//! Map of loaded textures (by name)
std::map<std::string, Texture> m_texNameMap;
std::map<std::filesystem::path, Texture> m_texNameMap;
//! Reverse map of loaded textures (by texture)
std::map<Texture, std::string> m_revTexNameMap;
std::map<Texture, std::filesystem::path> m_revTexNameMap;
//! Blacklist map of textures
/** Textures on this list were not successful in first loading,
* so are disabled for subsequent load calls. */
Expand Down

0 comments on commit a29dcd3

Please sign in to comment.