mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
@ -155,8 +155,8 @@ int BonusProxy::toJsonNode(lua_State * L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void publishMap(lua_State * L, const T & map)
|
||||
template <typename T, typename N>
|
||||
static void publishMap(lua_State * L, const std::map<T , N> & map)
|
||||
{
|
||||
for(auto & p : map)
|
||||
{
|
||||
@ -169,6 +169,20 @@ static void publishMap(lua_State * L, const T & map)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
static void publishMap(lua_State * L, const std::map<T , std::bitset<N>> & map)
|
||||
{
|
||||
for(auto & p : map)
|
||||
{
|
||||
const std::string & name = p.first;
|
||||
auto id = static_cast<int32_t>(p.second.to_ulong());
|
||||
|
||||
lua_pushstring(L, name.c_str());
|
||||
lua_pushinteger(L, id);
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
}
|
||||
|
||||
void BonusProxy::adjustStaticTable(lua_State * L) const
|
||||
{
|
||||
publishMap(L, bonusNameMap);
|
||||
|
Reference in New Issue
Block a user