mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Merge branch 'indexthemoon' into 'master'
Move Lua index helpers to components and make owner.factionRank match other ranks See merge request OpenMW/openmw!4186
This commit is contained in:
commit
d3c3d0cf44
16 changed files with 73 additions and 52 deletions
20
components/lua/util.hpp
Normal file
20
components/lua/util.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef COMPONENTS_LUA_UTIL_H
|
||||
#define COMPONENTS_LUA_UTIL_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace LuaUtil
|
||||
{
|
||||
// Lua arrays index from 1
|
||||
constexpr inline std::int64_t fromLuaIndex(std::int64_t i)
|
||||
{
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
constexpr inline std::int64_t toLuaIndex(std::int64_t i)
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -10,6 +10,7 @@
|
|||
#include <components/misc/mathutil.hpp>
|
||||
|
||||
#include "luastate.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
#include "shapes/box.hpp"
|
||||
|
||||
|
@ -143,7 +144,7 @@ namespace LuaUtil
|
|||
sol::table table(lua, sol::create);
|
||||
const auto vertices = b.vertices();
|
||||
for (size_t i = 0; i < vertices.size(); ++i)
|
||||
table[i + 1] = vertices[i];
|
||||
table[toLuaIndex(i)] = vertices[i];
|
||||
return table;
|
||||
});
|
||||
boxType[sol::meta_function::equal_to] = [](const Box& a, const Box& b) { return a == b; };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue