1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Bonus: complex duration as bitset

Fixes #2125
This commit is contained in:
Konstantin P
2023-05-05 12:56:53 +03:00
parent e9a90a8cbf
commit 8764765dcf
9 changed files with 105 additions and 38 deletions

View File

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