Skip to content

Commit

Permalink
add GEODE_HIDDEN to _spr
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Sep 12, 2023
1 parent f64c74a commit 71a79ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion loader/include/Geode/loader/Mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,6 @@ namespace geode {
};
}

inline char const* operator"" _spr(char const* str, size_t) {
GEODE_HIDDEN inline char const* operator"" _spr(char const* str, size_t) {
return geode::Mod::get()->expandSpriteName(str);
}
6 changes: 3 additions & 3 deletions loader/src/loader/ModImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,14 @@ ghc::filesystem::path Mod::Impl::getConfigDir(bool create) const {
}

char const* Mod::Impl::expandSpriteName(char const* name) {
static std::unordered_map<std::string, char const*> expanded = {};
if (expanded.count(name)) return expanded[name];
log::debug("Expanding sprite name {} for {}", name, m_metadata.getID());
if (m_expandedSprites.count(name)) return m_expandedSprites[name];

auto exp = new char[strlen(name) + 2 + m_metadata.getID().size()];
auto exps = m_metadata.getID() + "/" + name;
memcpy(exp, exps.c_str(), exps.size() + 1);

expanded[name] = exp;
m_expandedSprites[name] = exp;

return exp;
}
Expand Down
2 changes: 2 additions & 0 deletions loader/src/loader/ModImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ namespace geode {
*/
bool m_loggingEnabled = true;

std::unordered_map<std::string, char const*> m_expandedSprites;


ModRequestedAction m_requestedAction = ModRequestedAction::None;

Expand Down

0 comments on commit 71a79ab

Please sign in to comment.