add GEODE_HIDDEN to _spr

This commit is contained in:
altalk23 2023-09-12 21:07:53 +03:00
parent f64c74a128
commit 71a79ab4dd
3 changed files with 6 additions and 4 deletions

View file

@ -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);
}

View file

@ -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;
}

View file

@ -61,6 +61,8 @@ namespace geode {
*/
bool m_loggingEnabled = true;
std::unordered_map<std::string, char const*> m_expandedSprites;
ModRequestedAction m_requestedAction = ModRequestedAction::None;