mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
Less ugly API declarations
This commit is contained in:
parent
ec6f7b88fe
commit
6d245a7821
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "api/Registry.h"
|
#include "api/Registry.h"
|
||||||
#include "LuaStack.h"
|
#include "LuaStack.h"
|
||||||
#include "LuaFunctor.h"
|
|
||||||
|
|
||||||
namespace scripting
|
namespace scripting
|
||||||
{
|
{
|
||||||
@ -20,8 +19,83 @@ namespace scripting
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
template<int ...>
|
||||||
|
struct Seq {};
|
||||||
|
|
||||||
|
template<int N, int ...S>
|
||||||
|
struct Gens : Gens<N-1, N-1, S...> {};
|
||||||
|
|
||||||
|
template<int ...S>
|
||||||
|
struct Gens<0, S...>
|
||||||
|
{
|
||||||
|
typedef Seq<S...> type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R, typename ... Args>
|
||||||
|
class LuaArgumentsTuple
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using TupleData = std::tuple<Args ...>;
|
||||||
|
using Functor = R(*)(Args ...);
|
||||||
|
|
||||||
|
TupleData args;
|
||||||
|
Functor f;
|
||||||
|
|
||||||
|
LuaArgumentsTuple(Functor _f)
|
||||||
|
:f(_f),
|
||||||
|
args()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
STRONG_INLINE int invoke(lua_State * L)
|
||||||
|
{
|
||||||
|
return callFunc(L, typename Gens<sizeof...(Args)>::type());
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
template<int ...N>
|
||||||
|
int callFunc(lua_State * L, Seq<N...>)
|
||||||
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
|
||||||
|
bool ok[sizeof...(Args)] = {(S.tryGet(N+1, std::get<N>(args)))...};
|
||||||
|
|
||||||
|
if(std::count(std::begin(ok), std::end(ok), false) > 0)
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
|
||||||
|
R ret = f(std::get<N>(args) ...);
|
||||||
|
S.clear();
|
||||||
|
S.push(ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class LuaFunctionInvoker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename R, typename ... Args>
|
||||||
|
static STRONG_INLINE int invoke(lua_State * L, R(*f)(Args ...))
|
||||||
|
{
|
||||||
|
LuaArgumentsTuple<R, Args ...> args(f);
|
||||||
|
return args.invoke(L);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename F, F f>
|
||||||
|
class LuaFunctionWrapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int invoke(lua_State * L)
|
||||||
|
{
|
||||||
|
return detail::LuaFunctionInvoker::invoke(L, f);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//TODO: this should be the only one wrapper type
|
//TODO: this should be the only one wrapper type
|
||||||
//
|
//
|
||||||
template <typename U, typename M, M m>
|
template <typename U, typename M, M m>
|
||||||
@ -50,6 +124,26 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename U, typename T, typename R, R(T:: * method)()>
|
||||||
|
class LuaMethodWrapper <U, R(T:: *)(), method>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int invoke(lua_State * L)
|
||||||
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
U * obj = nullptr;
|
||||||
|
|
||||||
|
if(!S.tryGet(1,obj))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
static auto functor = std::mem_fn(method);
|
||||||
|
|
||||||
|
S.clear();
|
||||||
|
S.push(functor(obj));
|
||||||
|
return S.retPushed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename U, typename T, void(T:: * method)()const>
|
template <typename U, typename T, void(T:: * method)()const>
|
||||||
class LuaMethodWrapper <U, void(T:: *)()const, method>
|
class LuaMethodWrapper <U, void(T:: *)()const, method>
|
||||||
{
|
{
|
||||||
@ -69,6 +163,25 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename U, typename T, void(T:: * method)()>
|
||||||
|
class LuaMethodWrapper <U, void(T:: *)(), method>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int invoke(lua_State * L)
|
||||||
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
U * obj = nullptr;
|
||||||
|
|
||||||
|
if(!S.tryGet(1,obj))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
static auto functor = std::mem_fn(method);
|
||||||
|
S.clear();
|
||||||
|
functor(obj);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename U, typename T, typename R, typename P1, R(T:: * method)(P1)const>
|
template <typename U, typename T, typename R, typename P1, R(T:: * method)(P1)const>
|
||||||
class LuaMethodWrapper <U, R(T:: *)(P1)const, method>
|
class LuaMethodWrapper <U, R(T:: *)(P1)const, method>
|
||||||
{
|
{
|
||||||
@ -92,6 +205,29 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename U, typename T, typename R, typename P1, R(T:: * method)(P1)>
|
||||||
|
class LuaMethodWrapper <U, R(T:: *)(P1), method>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int invoke(lua_State * L)
|
||||||
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
U * obj = nullptr;
|
||||||
|
|
||||||
|
if(!S.tryGet(1,obj))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
P1 p1;
|
||||||
|
if(!S.tryGet(2, p1))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
static auto functor = std::mem_fn(method);
|
||||||
|
S.clear();
|
||||||
|
S.push(functor(obj, p1));
|
||||||
|
return S.retPushed();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename U, typename T, typename P1, void(T:: * method)(P1)const>
|
template <typename U, typename T, typename P1, void(T:: * method)(P1)const>
|
||||||
class LuaMethodWrapper <U, void(T:: *)(P1)const, method>
|
class LuaMethodWrapper <U, void(T:: *)(P1)const, method>
|
||||||
{
|
{
|
||||||
@ -115,6 +251,28 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename U, typename T, typename P1, void(T:: * method)(P1)>
|
||||||
|
class LuaMethodWrapper <U, void(T:: *)(P1), method>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static int invoke(lua_State * L)
|
||||||
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
U * obj = nullptr;
|
||||||
|
|
||||||
|
if(!S.tryGet(1,obj))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
P1 p1;
|
||||||
|
if(!S.tryGet(2, p1))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
static auto functor = std::mem_fn(method);
|
||||||
|
S.clear();
|
||||||
|
functor(obj, p1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename U, typename T, typename R, typename P1, typename P2, R(T:: * method)(P1, P2)const>
|
template <typename U, typename T, typename R, typename P1, typename P2, R(T:: * method)(P1, P2)const>
|
||||||
class LuaMethodWrapper <U, R(T:: *)(P1, P2)const, method>
|
class LuaMethodWrapper <U, R(T:: *)(P1, P2)const, method>
|
||||||
@ -170,150 +328,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//deprecated, should use LuaMethodWrapper instead, once implemented
|
|
||||||
template <typename T>
|
|
||||||
class LuaCallWrapper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using Wrapped = typename std::remove_const<T>::type;
|
|
||||||
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(void (Wrapped::* method)())
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
functor(object);
|
|
||||||
return S.retVoid();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(void (Wrapped::* method)() const)
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
functor(object);
|
|
||||||
return S.retVoid();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename R>
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(R (Wrapped::* method)())
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
S.clear();
|
|
||||||
S.push(functor(object));
|
|
||||||
return S.retPushed();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename R>
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(R (Wrapped::* method)() const)
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
S.clear();
|
|
||||||
S.push(functor(object));
|
|
||||||
return S.retPushed();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename P1>
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(void (Wrapped::* method)(P1))
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
P1 p1;
|
|
||||||
if(S.tryGet(1, p1))
|
|
||||||
{
|
|
||||||
functor(object, p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return S.retVoid();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename P1>
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(void (Wrapped::* method)(P1) const)
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
P1 p1;
|
|
||||||
if(S.tryGet(1, p1))
|
|
||||||
{
|
|
||||||
functor(object, p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return S.retVoid();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename R, typename P1>
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(R (Wrapped::* method)(P1))
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
P1 p1;
|
|
||||||
if(S.tryGet(1, p1))
|
|
||||||
{
|
|
||||||
S.push(functor(object, p1));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return S.retVoid();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename R, typename P1>
|
|
||||||
static std::function<int(lua_State *, T *)> createFunctor(R (Wrapped::* method)(P1) const)
|
|
||||||
{
|
|
||||||
auto functor = std::mem_fn(method);
|
|
||||||
auto ret = [=](lua_State * L, T * object)->int
|
|
||||||
{
|
|
||||||
LuaStack S(L);
|
|
||||||
P1 p1;
|
|
||||||
if(S.tryGet(1, p1))
|
|
||||||
{
|
|
||||||
S.push(functor(object, p1));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return S.retVoid();
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "api/Registry.h"
|
#include "LuaCallWrapper.h"
|
||||||
#include "LuaFunctor.h"
|
|
||||||
#include "LuaStack.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Original code is LunaWrapper by nornagon.
|
* Original code is LunaWrapper by nornagon.
|
||||||
@ -27,13 +25,6 @@ namespace scripting
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<typename T>
|
|
||||||
struct RegType
|
|
||||||
{
|
|
||||||
const char * name;
|
|
||||||
std::function<int(lua_State *, T)> functor;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CustomRegType
|
struct CustomRegType
|
||||||
{
|
{
|
||||||
const char * name;
|
const char * name;
|
||||||
@ -47,40 +38,11 @@ namespace detail
|
|||||||
using ProxyType = P;
|
using ProxyType = P;
|
||||||
using UDataType = U;
|
using UDataType = U;
|
||||||
|
|
||||||
static int invoke(lua_State * L)
|
|
||||||
{
|
|
||||||
static auto KEY = api::TypeRegistry::get()->getKey<UDataType>();
|
|
||||||
|
|
||||||
int i = (int)lua_tonumber(L, lua_upvalueindex(1));
|
|
||||||
|
|
||||||
void * raw = luaL_checkudata(L, 1, KEY);
|
|
||||||
|
|
||||||
if(!raw)
|
|
||||||
{
|
|
||||||
lua_settop(L, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_remove(L, 1);
|
|
||||||
|
|
||||||
auto obj = *(static_cast<UDataType *>(raw));
|
|
||||||
return (ProxyType::REGISTER[i].functor)(L, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setIndexTable(lua_State * L)
|
static void setIndexTable(lua_State * L)
|
||||||
{
|
{
|
||||||
lua_pushstring(L, "__index");
|
lua_pushstring(L, "__index");
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_Integer index = 0;
|
|
||||||
for(auto & reg : ProxyType::REGISTER)
|
|
||||||
{
|
|
||||||
lua_pushstring(L, reg.name);
|
|
||||||
lua_pushnumber(L, index);
|
|
||||||
lua_pushcclosure(L, &invoke, 1);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto & reg : ProxyType::REGISTER_CUSTOM)
|
for(auto & reg : ProxyType::REGISTER_CUSTOM)
|
||||||
{
|
{
|
||||||
@ -164,7 +126,6 @@ public:
|
|||||||
using UDataType = ObjectType *;
|
using UDataType = ObjectType *;
|
||||||
using CUDataType = const ObjectType *;
|
using CUDataType = const ObjectType *;
|
||||||
|
|
||||||
using RegType = detail::RegType<UDataType>;
|
|
||||||
using CustomRegType = detail::CustomRegType;
|
using CustomRegType = detail::CustomRegType;
|
||||||
|
|
||||||
void pushMetatable(lua_State * L) const override final
|
void pushMetatable(lua_State * L) const override final
|
||||||
@ -202,7 +163,6 @@ class SharedWrapper : public RegistarBase
|
|||||||
public:
|
public:
|
||||||
using ObjectType = typename std::remove_cv<T>::type;
|
using ObjectType = typename std::remove_cv<T>::type;
|
||||||
using UDataType = std::shared_ptr<T>;
|
using UDataType = std::shared_ptr<T>;
|
||||||
using RegType = detail::RegType<UDataType>;
|
|
||||||
using CustomRegType = detail::CustomRegType;
|
using CustomRegType = detail::CustomRegType;
|
||||||
|
|
||||||
static int constructor(lua_State * L)
|
static int constructor(lua_State * L)
|
||||||
@ -248,7 +208,6 @@ class UniqueOpaqueWrapper : public api::Registar
|
|||||||
public:
|
public:
|
||||||
using ObjectType = typename std::remove_cv<T>::type;
|
using ObjectType = typename std::remove_cv<T>::type;
|
||||||
using UDataType = std::unique_ptr<T>;
|
using UDataType = std::unique_ptr<T>;
|
||||||
using RegType = detail::RegType<UDataType>;
|
|
||||||
using CustomRegType = detail::CustomRegType;
|
using CustomRegType = detail::CustomRegType;
|
||||||
|
|
||||||
void pushMetatable(lua_State * L) const override final
|
void pushMetatable(lua_State * L) const override final
|
||||||
|
@ -24,23 +24,21 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(ArtifactProxy, "Artifact");
|
VCMI_REGISTER_CORE_SCRIPT_API(ArtifactProxy, "Artifact");
|
||||||
|
|
||||||
const std::vector<ArtifactProxy::RegType> ArtifactProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<ArtifactProxy::CustomRegType> ArtifactProxy::REGISTER_CUSTOM =
|
const std::vector<ArtifactProxy::CustomRegType> ArtifactProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<Artifact, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<Artifact, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<Artifact, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<Artifact, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<Artifact, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<Artifact, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<Artifact, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<Artifact, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
|
|
||||||
{"getId", LuaMethodWrapper<Artifact, ArtifactID(EntityT<ArtifactID>::*)()const, &EntityT<ArtifactID>::getId>::invoke, false},
|
{"getId", LuaMethodWrapper<Artifact, decltype(&EntityT<ArtifactID>::getId), &EntityT<ArtifactID>::getId>::invoke, false},
|
||||||
{"accessBonuses", LuaMethodWrapper<Artifact, const IBonusBearer *(EntityWithBonuses<ArtifactID>:: *)()const, &EntityWithBonuses<ArtifactID>::accessBonuses>::invoke, false},
|
{"accessBonuses", LuaMethodWrapper<Artifact, decltype(&EntityWithBonuses<ArtifactID>::accessBonuses), &EntityWithBonuses<ArtifactID>::accessBonuses>::invoke, false},
|
||||||
|
|
||||||
{"getDescription", LuaMethodWrapper<Artifact, const std::string &(Artifact:: *)()const, &Artifact::getDescription>::invoke, false},
|
{"getDescription", LuaMethodWrapper<Artifact, decltype(&Artifact::getDescription), &Artifact::getDescription>::invoke, false},
|
||||||
{"getEventText", LuaMethodWrapper<Artifact, const std::string &(Artifact:: *)()const, &Artifact::getEventText>::invoke, false},
|
{"getEventText", LuaMethodWrapper<Artifact, decltype(&Artifact::getEventText), &Artifact::getEventText>::invoke, false},
|
||||||
{"isBig", LuaMethodWrapper<Artifact, bool(Artifact:: *)()const, &Artifact::isBig>::invoke, false},
|
{"isBig", LuaMethodWrapper<Artifact, decltype(&Artifact::isBig), &Artifact::isBig>::invoke, false},
|
||||||
{"isTradable", LuaMethodWrapper<Artifact, bool(Artifact:: *)()const, &Artifact::isTradable>::invoke, false},
|
{"isTradable", LuaMethodWrapper<Artifact, decltype(&Artifact::isTradable), &Artifact::isTradable>::invoke, false},
|
||||||
{"getPrice", LuaMethodWrapper<Artifact, uint32_t(Artifact:: *)()const, &Artifact::getPrice>::invoke, false},
|
{"getPrice", LuaMethodWrapper<Artifact, decltype(&Artifact::getPrice), &Artifact::getPrice>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ class ArtifactProxy : public OpaqueWrapper<const Artifact, ArtifactProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Artifact, ArtifactProxy>;
|
using Wrapper = OpaqueWrapper<const Artifact, ArtifactProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,75 +24,90 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(BattleCbProxy, "Battle");
|
VCMI_REGISTER_CORE_SCRIPT_API(BattleCbProxy, "Battle");
|
||||||
|
|
||||||
const std::vector<BattleCbProxy::RegType> BattleCbProxy::REGISTER =
|
const std::vector<BattleCbProxy::CustomRegType> BattleCbProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"getBattlefieldType",
|
"getBattlefieldType",
|
||||||
&BattleCbProxy::getBattlefieldType
|
&BattleCbProxy::getBattlefieldType,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"getNextUnitId",
|
"getNextUnitId",
|
||||||
LuaCallWrapper<const BattleCb>::createFunctor(&BattleCb::battleNextUnitId)
|
LuaMethodWrapper<BattleCb, decltype(&BattleCb::battleNextUnitId), &BattleCb::battleNextUnitId>::invoke,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"getTacticDistance",
|
"getTacticDistance",
|
||||||
LuaCallWrapper<const BattleCb>::createFunctor(&BattleCb::battleTacticDist)
|
LuaMethodWrapper<BattleCb, decltype(&BattleCb::battleTacticDist), &BattleCb::battleTacticDist>::invoke,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"getTerrainType",
|
"getTerrainType",
|
||||||
&BattleCbProxy::getTerrainType
|
&BattleCbProxy::getTerrainType,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"getUnitById",
|
"getUnitById",
|
||||||
LuaCallWrapper<const BattleCb>::createFunctor(&BattleCb::battleGetUnitByID)
|
LuaMethodWrapper<BattleCb, decltype(&BattleCb::battleGetUnitByID), &BattleCb::battleGetUnitByID>::invoke,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"getUnitByPos",
|
"getUnitByPos",
|
||||||
&BattleCbProxy::getUnitByPos
|
&BattleCbProxy::getUnitByPos,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"isFinished",
|
"isFinished",
|
||||||
LuaCallWrapper<const BattleCb>::createFunctor(&BattleCb::battleIsFinished)
|
LuaMethodWrapper<BattleCb, decltype(&BattleCb::battleIsFinished), &BattleCb::battleIsFinished>::invoke,
|
||||||
|
false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int BattleCbProxy::getBattlefieldType(lua_State * L)
|
||||||
const std::vector<BattleCbProxy::CustomRegType> BattleCbProxy::REGISTER_CUSTOM =
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int BattleCbProxy::getBattlefieldType(lua_State * L, const BattleCb * object)
|
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
const BattleCb * object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
auto ret = object->battleGetBattlefieldType();
|
auto ret = object->battleGetBattlefieldType();
|
||||||
S.push(static_cast<si32>(ret.num));
|
|
||||||
return 1;
|
return LuaStack::quickRetInt(L, static_cast<si32>(ret.num));
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleCbProxy::getTerrainType(lua_State * L, const BattleCb * object)
|
int BattleCbProxy::getTerrainType(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
const BattleCb * object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
auto ret = object->battleTerrainType();
|
auto ret = object->battleTerrainType();
|
||||||
S.push(static_cast<si32>(ret.num));
|
|
||||||
return 1;
|
return LuaStack::quickRetInt(L, static_cast<si32>(ret.num));
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleCbProxy::getUnitByPos(lua_State * L, const BattleCb * object)
|
int BattleCbProxy::getUnitByPos(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
const BattleCb * object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
BattleHex hex;
|
BattleHex hex;
|
||||||
|
|
||||||
if(!S.tryGet(1, hex.hex))
|
if(!S.tryGet(2, hex.hex))
|
||||||
return S.retNil();
|
return S.retNil();
|
||||||
|
|
||||||
bool onlyAlive;
|
bool onlyAlive;
|
||||||
|
|
||||||
if(!S.tryGet(2, onlyAlive))
|
if(!S.tryGet(3, onlyAlive))
|
||||||
onlyAlive = true;//same as default value in battleGetUnitByPos
|
onlyAlive = true;//same as default value in battleGetUnitByPos
|
||||||
|
|
||||||
|
S.clear();
|
||||||
S.push(object->battleGetUnitByPos(hex, onlyAlive));
|
S.push(object->battleGetUnitByPos(hex, onlyAlive));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,11 @@ class BattleCbProxy : public OpaqueWrapper<const BattleCb, BattleCbProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const BattleCb, BattleCbProxy>;
|
using Wrapper = OpaqueWrapper<const BattleCb, BattleCbProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int getBattlefieldType(lua_State * L, const BattleCb * object);
|
static int getBattlefieldType(lua_State * L);
|
||||||
static int getTerrainType(lua_State * L, const BattleCb * object);
|
static int getTerrainType(lua_State * L);
|
||||||
static int getUnitByPos(lua_State * L, const BattleCb * object);
|
static int getUnitByPos(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,85 +25,127 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(BonusProxy, "Bonus");
|
VCMI_REGISTER_SCRIPT_API(BonusProxy, "Bonus");
|
||||||
|
|
||||||
const std::vector<BonusProxy::RegType> BonusProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getType", &BonusProxy::getType},
|
|
||||||
{"getSubtype", &BonusProxy::getSubtype},
|
|
||||||
{"getDuration", &BonusProxy::getDuration},
|
|
||||||
{"getTurns", &BonusProxy::getTurns},
|
|
||||||
{"getValueType", &BonusProxy::getValueType},
|
|
||||||
{"getVal", &BonusProxy::getVal},
|
|
||||||
{"getSource", &BonusProxy::getSource},
|
|
||||||
{"getSourceID", &BonusProxy::getSourceID},
|
|
||||||
{"getEffectRange", &BonusProxy::getEffectRange},
|
|
||||||
{"getStacking", &BonusProxy::getStacking},
|
|
||||||
{"getDescription", &BonusProxy::getDescription},
|
|
||||||
{"toJsonNode", &BonusProxy::toJsonNode}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<BonusProxy::CustomRegType> BonusProxy::REGISTER_CUSTOM =
|
const std::vector<BonusProxy::CustomRegType> BonusProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getType", &BonusProxy::getType, false},
|
||||||
|
{"getSubtype", &BonusProxy::getSubtype, false},
|
||||||
|
{"getDuration", &BonusProxy::getDuration, false},
|
||||||
|
{"getTurns", &BonusProxy::getTurns, false},
|
||||||
|
{"getValueType", &BonusProxy::getValueType, false},
|
||||||
|
{"getVal", &BonusProxy::getVal, false},
|
||||||
|
{"getSource", &BonusProxy::getSource, false},
|
||||||
|
{"getSourceID", &BonusProxy::getSourceID, false},
|
||||||
|
{"getEffectRange", &BonusProxy::getEffectRange, false},
|
||||||
|
{"getStacking", &BonusProxy::getStacking, false},
|
||||||
|
{"getDescription", &BonusProxy::getDescription, false},
|
||||||
|
{"toJsonNode", &BonusProxy::toJsonNode, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int BonusProxy::getType(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getType(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->type);
|
return LuaStack::quickRetInt(L, object->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getSubtype(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getSubtype(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->subtype);
|
return LuaStack::quickRetInt(L, object->subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getDuration(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getDuration(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->duration);
|
return LuaStack::quickRetInt(L, object->duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getTurns(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getTurns(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->turnsRemain);
|
return LuaStack::quickRetInt(L, object->turnsRemain);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getValueType(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getValueType(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->valType);
|
return LuaStack::quickRetInt(L, object->valType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getVal(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getVal(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->val);
|
return LuaStack::quickRetInt(L, object->val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getSource(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getSource(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->source);
|
return LuaStack::quickRetInt(L, object->source);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getSourceID(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getSourceID(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->sid);
|
return LuaStack::quickRetInt(L, object->sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getEffectRange(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getEffectRange(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetInt(L, object->effectRange);
|
return LuaStack::quickRetInt(L, object->effectRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getStacking(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getStacking(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetStr(L, object->stacking);
|
return LuaStack::quickRetStr(L, object->stacking);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::getDescription(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::getDescription(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
return LuaStack::quickRetStr(L, object->description);
|
return LuaStack::quickRetStr(L, object->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BonusProxy::toJsonNode(lua_State * L, std::shared_ptr<const Bonus> object)
|
int BonusProxy::toJsonNode(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<const Bonus> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
S.clear();
|
S.clear();
|
||||||
S.push(object->toJsonNode());
|
S.push(object->toJsonNode());
|
||||||
return 1;
|
return 1;
|
||||||
@ -133,67 +175,48 @@ void BonusProxy::adjustStaticTable(lua_State * L) const
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(BonusListProxy, "BonusList");
|
VCMI_REGISTER_SCRIPT_API(BonusListProxy, "BonusList");
|
||||||
|
|
||||||
const std::vector<BonusListProxy::RegType> BonusListProxy::REGISTER =
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<BonusListProxy::CustomRegType> BonusListProxy::REGISTER_CUSTOM =
|
const std::vector<BonusListProxy::CustomRegType> BonusListProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int BonusListProxy::index(lua_State * L)
|
std::shared_ptr<const Bonus> BonusListProxy::index(std::shared_ptr<const BonusList> self, int key)
|
||||||
{
|
{
|
||||||
//field = __index(self, key)
|
//field = __index(self, key)
|
||||||
LuaStack S(L);
|
|
||||||
|
|
||||||
std::shared_ptr<const BonusList> self;
|
std::shared_ptr<const Bonus> ret;
|
||||||
lua_Integer key = -1;
|
|
||||||
|
|
||||||
if(S.tryGet(1, self) && S.tryGetInteger(2, key))
|
|
||||||
{
|
|
||||||
if((key >= 1) && (key <= self->size()))
|
if((key >= 1) && (key <= self->size()))
|
||||||
{
|
ret = (*self)[key-1];
|
||||||
std::shared_ptr<const Bonus> ret = (*self)[key-1];
|
return ret;
|
||||||
|
|
||||||
S.clear();
|
|
||||||
S.push(ret);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return S.retNil();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BonusListProxy::adjustMetatable(lua_State * L) const
|
void BonusListProxy::adjustMetatable(lua_State * L) const
|
||||||
{
|
{
|
||||||
lua_pushstring(L, "__index");
|
lua_pushstring(L, "__index");
|
||||||
lua_pushcfunction(L, &BonusListProxy::index);
|
lua_pushcclosure(L, LuaFunctionWrapper<decltype(&BonusListProxy::index), &BonusListProxy::index>::invoke, 0);
|
||||||
lua_rawset(L, -3);
|
lua_rawset(L, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(BonusBearerProxy, "BonusBearer");
|
VCMI_REGISTER_SCRIPT_API(BonusBearerProxy, "BonusBearer");
|
||||||
|
|
||||||
const std::vector<BonusBearerProxy::RegType> BonusBearerProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getBonuses", &BonusBearerProxy::getBonuses},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<BonusBearerProxy::CustomRegType> BonusBearerProxy::REGISTER_CUSTOM =
|
const std::vector<BonusBearerProxy::CustomRegType> BonusBearerProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getBonuses", &BonusBearerProxy::getBonuses, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
int BonusBearerProxy::getBonuses(lua_State * L, const IBonusBearer * object)
|
int BonusBearerProxy::getBonuses(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
const IBonusBearer * object = nullptr;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
|
|
||||||
TConstBonusListPtr ret;
|
TConstBonusListPtr ret;
|
||||||
|
|
||||||
const bool hasSelector = S.isFunction(1);
|
const bool hasSelector = S.isFunction(2);
|
||||||
const bool hasRangeSelector = S.isFunction(2);
|
const bool hasRangeSelector = S.isFunction(3);
|
||||||
|
|
||||||
if(hasSelector)
|
if(hasSelector)
|
||||||
{
|
{
|
||||||
|
@ -26,21 +26,20 @@ class BonusProxy : public SharedWrapper<const Bonus, BonusProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<const Bonus, BonusProxy>;
|
using Wrapper = SharedWrapper<const Bonus, BonusProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int getType(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getType(lua_State * L);
|
||||||
static int getSubtype(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getSubtype(lua_State * L);
|
||||||
static int getDuration(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getDuration(lua_State * L);
|
||||||
static int getTurns(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getTurns(lua_State * L);
|
||||||
static int getValueType(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getValueType(lua_State * L);
|
||||||
static int getVal(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getVal(lua_State * L);
|
||||||
static int getSource(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getSource(lua_State * L);
|
||||||
static int getSourceID(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getSourceID(lua_State * L);
|
||||||
static int getDescription(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getDescription(lua_State * L);
|
||||||
static int getEffectRange(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getEffectRange(lua_State * L);
|
||||||
static int getStacking(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int getStacking(lua_State * L);
|
||||||
static int toJsonNode(lua_State * L, std::shared_ptr<const Bonus> object);
|
static int toJsonNode(lua_State * L);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void adjustStaticTable(lua_State * L) const override;
|
virtual void adjustStaticTable(lua_State * L) const override;
|
||||||
@ -51,10 +50,9 @@ class BonusListProxy : public SharedWrapper<const BonusList, BonusListProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<const BonusList, BonusListProxy>;
|
using Wrapper = SharedWrapper<const BonusList, BonusListProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int index(lua_State * L);
|
static std::shared_ptr<const Bonus> index(std::shared_ptr<const BonusList> self, int key);
|
||||||
protected:
|
protected:
|
||||||
virtual void adjustMetatable(lua_State * L) const override;
|
virtual void adjustMetatable(lua_State * L) const override;
|
||||||
};
|
};
|
||||||
@ -64,10 +62,9 @@ class BonusBearerProxy : public OpaqueWrapper<const IBonusBearer, BonusBearerPro
|
|||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const IBonusBearer, BonusBearerProxy>;
|
using Wrapper = OpaqueWrapper<const IBonusBearer, BonusBearerProxy>;
|
||||||
|
|
||||||
static int getBonuses(lua_State * L, const IBonusBearer * object);
|
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
|
static int getBonuses(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,42 +24,38 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(CreatureProxy, "Creature");
|
VCMI_REGISTER_CORE_SCRIPT_API(CreatureProxy, "Creature");
|
||||||
|
|
||||||
const std::vector<CreatureProxy::RegType> CreatureProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getCost", LuaCallWrapper<const Creature>::createFunctor(&Creature::getCost)},
|
|
||||||
{"isDoubleWide", LuaCallWrapper<const Creature>::createFunctor(&Creature::isDoubleWide)},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<CreatureProxy::CustomRegType> CreatureProxy::REGISTER_CUSTOM =
|
const std::vector<CreatureProxy::CustomRegType> CreatureProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<Creature, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<Creature, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<Creature, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<Creature, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<Creature, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<Creature, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<Creature, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<Creature, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
{"accessBonuses", LuaMethodWrapper<Creature, const IBonusBearer *(EntityWithBonuses<CreatureID>:: *)()const, &EntityWithBonuses<CreatureID>::accessBonuses>::invoke, false},
|
{"accessBonuses", LuaMethodWrapper<Creature, decltype(&EntityWithBonuses<CreatureID>::accessBonuses), &EntityWithBonuses<CreatureID>::accessBonuses>::invoke, false},
|
||||||
|
|
||||||
{"getMaxHealth", LuaMethodWrapper<Creature, uint32_t(Creature:: *)()const, &Creature::getMaxHealth>::invoke, false},
|
{"getMaxHealth", LuaMethodWrapper<Creature,decltype(&Creature::getMaxHealth), &Creature::getMaxHealth>::invoke, false},
|
||||||
{"getPluralName", LuaMethodWrapper<Creature, const std::string &(Creature:: *)()const, &Creature::getPluralName>::invoke, false},
|
{"getPluralName", LuaMethodWrapper<Creature, decltype(&Creature::getPluralName), &Creature::getPluralName>::invoke, false},
|
||||||
{"getSingularName", LuaMethodWrapper<Creature, const std::string &(Creature:: *)()const, &Creature::getSingularName>::invoke, false},
|
{"getSingularName", LuaMethodWrapper<Creature, decltype(&Creature::getSingularName), &Creature::getSingularName>::invoke, false},
|
||||||
|
|
||||||
{"getAdvMapAmountMin", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getAdvMapAmountMin>::invoke, false},
|
{"getAdvMapAmountMin", LuaMethodWrapper<Creature, decltype(&Creature::getAdvMapAmountMin), &Creature::getAdvMapAmountMin>::invoke, false},
|
||||||
{"getAdvMapAmountMax", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getAdvMapAmountMax>::invoke, false},
|
{"getAdvMapAmountMax", LuaMethodWrapper<Creature, decltype(&Creature::getAdvMapAmountMax), &Creature::getAdvMapAmountMax>::invoke, false},
|
||||||
{"getAIValue", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getAIValue>::invoke, false},
|
{"getAIValue", LuaMethodWrapper<Creature, decltype(&Creature::getAIValue), &Creature::getAIValue>::invoke, false},
|
||||||
{"getFightValue", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getFightValue>::invoke, false},
|
{"getFightValue", LuaMethodWrapper<Creature, decltype(&Creature::getFightValue), &Creature::getFightValue>::invoke, false},
|
||||||
{"getLevel", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getLevel>::invoke, false},
|
{"getLevel", LuaMethodWrapper<Creature, decltype(&Creature::getLevel), &Creature::getLevel>::invoke, false},
|
||||||
{"getGrowth", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getGrowth>::invoke, false},
|
{"getGrowth", LuaMethodWrapper<Creature, decltype(&Creature::getGrowth), &Creature::getGrowth>::invoke, false},
|
||||||
{"getHorde", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getHorde>::invoke, false},
|
{"getHorde", LuaMethodWrapper<Creature, decltype(&Creature::getHorde), &Creature::getHorde>::invoke, false},
|
||||||
{"getFactionIndex", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getFactionIndex>::invoke, false},
|
{"getFactionIndex", LuaMethodWrapper<Creature, decltype(&Creature::getFactionIndex), &Creature::getFactionIndex>::invoke, false},
|
||||||
|
|
||||||
{"getBaseAttack", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseAttack>::invoke, false},
|
{"getBaseAttack", LuaMethodWrapper<Creature, decltype(&Creature::getBaseAttack), &Creature::getBaseAttack>::invoke, false},
|
||||||
{"getBaseDefense", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseDefense>::invoke, false},
|
{"getBaseDefense", LuaMethodWrapper<Creature, decltype(&Creature::getBaseDefense), &Creature::getBaseDefense>::invoke, false},
|
||||||
{"getBaseDamageMin", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseDamageMin>::invoke, false},
|
{"getBaseDamageMin", LuaMethodWrapper<Creature, decltype(&Creature::getBaseDamageMin), &Creature::getBaseDamageMin>::invoke, false},
|
||||||
{"getBaseDamageMax", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseDamageMax>::invoke, false},
|
{"getBaseDamageMax", LuaMethodWrapper<Creature, decltype(&Creature::getBaseDamageMax), &Creature::getBaseDamageMax>::invoke, false},
|
||||||
{"getBaseHitPoints", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseHitPoints>::invoke, false},
|
{"getBaseHitPoints", LuaMethodWrapper<Creature, decltype(&Creature::getBaseHitPoints), &Creature::getBaseHitPoints>::invoke, false},
|
||||||
{"getBaseSpellPoints", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseSpellPoints>::invoke, false},
|
{"getBaseSpellPoints", LuaMethodWrapper<Creature, decltype(&Creature::getBaseSpellPoints), &Creature::getBaseSpellPoints>::invoke, false},
|
||||||
{"getBaseSpeed", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseSpeed>::invoke, false},
|
{"getBaseSpeed", LuaMethodWrapper<Creature, decltype(&Creature::getBaseSpeed), &Creature::getBaseSpeed>::invoke, false},
|
||||||
{"getBaseShots", LuaMethodWrapper<Creature, int32_t(Creature:: *)()const, &Creature::getBaseShots>::invoke, false},
|
{"getBaseShots", LuaMethodWrapper<Creature, decltype(&Creature::getBaseShots), &Creature::getBaseShots>::invoke, false},
|
||||||
|
|
||||||
|
{"getCost", LuaMethodWrapper<Creature, decltype(&Creature::getCost), &Creature::getCost>::invoke, false},
|
||||||
|
{"isDoubleWide", LuaMethodWrapper<Creature, decltype(&Creature::isDoubleWide), &Creature::isDoubleWide>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ class CreatureProxy : public OpaqueWrapper<const Creature, CreatureProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Creature, CreatureProxy>;
|
using Wrapper = OpaqueWrapper<const Creature, CreatureProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,15 +23,13 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(FactionProxy, "Faction");
|
VCMI_REGISTER_CORE_SCRIPT_API(FactionProxy, "Faction");
|
||||||
|
|
||||||
const std::vector<FactionProxy::RegType> FactionProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<FactionProxy::CustomRegType> FactionProxy::REGISTER_CUSTOM =
|
const std::vector<FactionProxy::CustomRegType> FactionProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<Faction, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<Faction, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<Faction, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<Faction, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<Faction, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<Faction, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<Faction, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<Faction, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
{"hasTown", LuaMethodWrapper<Faction, bool(Faction:: *)()const, &Faction::hasTown>::invoke, false},
|
{"hasTown", LuaMethodWrapper<Faction, decltype(&Faction::hasTown), &Faction::hasTown>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ class FactionProxy : public OpaqueWrapper<const Faction, FactionProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Faction, FactionProxy>;
|
using Wrapper = OpaqueWrapper<const Faction, FactionProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,19 +24,17 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(GameCbProxy, "Game");
|
VCMI_REGISTER_CORE_SCRIPT_API(GameCbProxy, "Game");
|
||||||
|
|
||||||
const std::vector<GameCbProxy::RegType> GameCbProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<GameCbProxy::CustomRegType> GameCbProxy::REGISTER_CUSTOM =
|
const std::vector<GameCbProxy::CustomRegType> GameCbProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getDate", LuaMethodWrapper<GameCb, int32_t(GameCb:: *)(Date::EDateType)const, &GameCb::getDate>::invoke, false},
|
{"getDate", LuaMethodWrapper<GameCb, decltype(&GameCb::getDate), &GameCb::getDate>::invoke, false},
|
||||||
{"isAllowed", LuaMethodWrapper<GameCb, bool(GameCb:: *)(int32_t, int32_t)const, &GameCb::isAllowed>::invoke, false},
|
{"isAllowed", LuaMethodWrapper<GameCb, decltype(&GameCb::isAllowed), &GameCb::isAllowed>::invoke, false},
|
||||||
{"getCurrentPlayer", LuaMethodWrapper<GameCb, PlayerColor(GameCb:: *)()const, &GameCb::getLocalPlayer>::invoke, false},
|
{"getCurrentPlayer", LuaMethodWrapper<GameCb, decltype(&GameCb::getLocalPlayer), &GameCb::getLocalPlayer>::invoke, false},
|
||||||
{"getPlayer", LuaMethodWrapper<GameCb, const Player * (GameCb:: *)(PlayerColor)const, &GameCb::getPlayer>::invoke, false},
|
{"getPlayer", LuaMethodWrapper<GameCb, decltype(&GameCb::getPlayer), &GameCb::getPlayer>::invoke, false},
|
||||||
|
|
||||||
{"getHero", LuaMethodWrapper<GameCb, const CGHeroInstance *(GameCb:: *)(ObjectInstanceID)const, &GameCb::getHero>::invoke, false},
|
{"getHero", LuaMethodWrapper<GameCb, decltype(&GameCb::getHero), &GameCb::getHero>::invoke, false},
|
||||||
{"getHeroWithSubid", LuaMethodWrapper<GameCb, const CGHeroInstance *(GameCb:: *)(int)const, &GameCb::getHeroWithSubid>::invoke, false},
|
{"getHeroWithSubid", LuaMethodWrapper<GameCb, decltype(&GameCb::getHeroWithSubid), &GameCb::getHeroWithSubid>::invoke, false},
|
||||||
|
|
||||||
{"getObj", LuaMethodWrapper<GameCb, const CGObjectInstance *(GameCb:: *)(ObjectInstanceID, bool)const, &GameCb::getObj>::invoke, false},
|
{"getObj", LuaMethodWrapper<GameCb, decltype(&GameCb::getObj), &GameCb::getObj>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class GameCbProxy : public OpaqueWrapper<const GameCb, GameCbProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const GameCb, GameCbProxy>;
|
using Wrapper = OpaqueWrapper<const GameCb, GameCbProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -22,14 +22,12 @@ namespace api
|
|||||||
{
|
{
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(HeroClassProxy, "HeroClass");
|
VCMI_REGISTER_CORE_SCRIPT_API(HeroClassProxy, "HeroClass");
|
||||||
|
|
||||||
const std::vector<HeroClassProxy::RegType> HeroClassProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<HeroClassProxy::CustomRegType> HeroClassProxy::REGISTER_CUSTOM =
|
const std::vector<HeroClassProxy::CustomRegType> HeroClassProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<HeroClass, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<HeroClass, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<HeroClass, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<HeroClass, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<HeroClass, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<HeroClass, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<HeroClass, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<HeroClass, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ class HeroClassProxy : public OpaqueWrapper<const HeroClass, HeroClassProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const HeroClass, HeroClassProxy>;
|
using Wrapper = OpaqueWrapper<const HeroClass, HeroClassProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,12 +22,10 @@ namespace api
|
|||||||
{
|
{
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(HeroInstanceProxy, "HeroInstance");
|
VCMI_REGISTER_CORE_SCRIPT_API(HeroInstanceProxy, "HeroInstance");
|
||||||
|
|
||||||
const std::vector<HeroInstanceProxy::RegType> HeroInstanceProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<HeroInstanceProxy::CustomRegType> HeroInstanceProxy::REGISTER_CUSTOM =
|
const std::vector<HeroInstanceProxy::CustomRegType> HeroInstanceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getStack", LuaMethodWrapper<CGHeroInstance, const CStackInstance *(CCreatureSet:: *)(SlotID)const, &CCreatureSet::getStackPtr>::invoke, false},
|
{"getStack", LuaMethodWrapper<CGHeroInstance, decltype(&CCreatureSet::getStackPtr), &CCreatureSet::getStackPtr>::invoke, false},
|
||||||
{"getOwner", LuaMethodWrapper<CGHeroInstance, PlayerColor(CGObjectInstance:: *)()const, &CGObjectInstance::getOwner>::invoke, false},
|
{"getOwner", LuaMethodWrapper<CGHeroInstance, decltype(&CGObjectInstance::getOwner), &CGObjectInstance::getOwner>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class HeroInstanceProxy : public OpaqueWrapper<const CGHeroInstance, HeroInstanc
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const CGHeroInstance, HeroInstanceProxy>;
|
using Wrapper = OpaqueWrapper<const CGHeroInstance, HeroInstanceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,14 +23,12 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(HeroTypeProxy, "HeroType");
|
VCMI_REGISTER_CORE_SCRIPT_API(HeroTypeProxy, "HeroType");
|
||||||
|
|
||||||
const std::vector<HeroTypeProxy::RegType> HeroTypeProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<HeroTypeProxy::CustomRegType> HeroTypeProxy::REGISTER_CUSTOM =
|
const std::vector<HeroTypeProxy::CustomRegType> HeroTypeProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<HeroType, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<HeroType, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<HeroType, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<HeroType, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<HeroType, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<HeroType, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<HeroType, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<HeroType, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ class HeroTypeProxy : public OpaqueWrapper<const HeroType, HeroTypeProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const HeroType, HeroTypeProxy>;
|
using Wrapper = OpaqueWrapper<const HeroType, HeroTypeProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,15 +22,13 @@ namespace api
|
|||||||
{
|
{
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(ObjectInstanceProxy, "ObjectInstance");
|
VCMI_REGISTER_CORE_SCRIPT_API(ObjectInstanceProxy, "ObjectInstance");
|
||||||
|
|
||||||
const std::vector<ObjectInstanceProxy::RegType> ObjectInstanceProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<ObjectInstanceProxy::CustomRegType> ObjectInstanceProxy::REGISTER_CUSTOM =
|
const std::vector<ObjectInstanceProxy::CustomRegType> ObjectInstanceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getOwner", LuaMethodWrapper<CGObjectInstance, PlayerColor(IObjectInterface:: *)()const, &IObjectInterface::getOwner>::invoke, false},
|
{"getOwner", LuaMethodWrapper<CGObjectInstance, decltype(&IObjectInterface::getOwner), &IObjectInterface::getOwner>::invoke, false},
|
||||||
{"getObjGroupIndex", LuaMethodWrapper<CGObjectInstance, int32_t(IObjectInterface:: *)()const, &IObjectInterface::getObjGroupIndex>::invoke, false},
|
{"getObjGroupIndex", LuaMethodWrapper<CGObjectInstance, decltype(&IObjectInterface::getObjGroupIndex), &IObjectInterface::getObjGroupIndex>::invoke, false},
|
||||||
{"getObjTypeIndex", LuaMethodWrapper<CGObjectInstance, int32_t(IObjectInterface:: *)()const, &IObjectInterface::getObjTypeIndex>::invoke, false},
|
{"getObjTypeIndex", LuaMethodWrapper<CGObjectInstance, decltype(&IObjectInterface::getObjTypeIndex), &IObjectInterface::getObjTypeIndex>::invoke, false},
|
||||||
{"getVisitablePosition", LuaMethodWrapper<CGObjectInstance, int3(IObjectInterface:: *)()const, &IObjectInterface::visitablePos>::invoke, false},
|
{"getVisitablePosition", LuaMethodWrapper<CGObjectInstance, decltype(&IObjectInterface::visitablePos), &IObjectInterface::visitablePos>::invoke, false},
|
||||||
{"getPosition", LuaMethodWrapper<CGObjectInstance, int3(IObjectInterface:: *)()const, &IObjectInterface::getPosition>::invoke, false},
|
{"getPosition", LuaMethodWrapper<CGObjectInstance, decltype(IObjectInterface::getPosition), &IObjectInterface::getPosition>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class ObjectInstanceProxy : public OpaqueWrapper<const CGObjectInstance, ObjectI
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const CGObjectInstance, ObjectInstanceProxy>;
|
using Wrapper = OpaqueWrapper<const CGObjectInstance, ObjectInstanceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,10 +24,6 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(PlayerProxy, "Player");
|
VCMI_REGISTER_CORE_SCRIPT_API(PlayerProxy, "Player");
|
||||||
|
|
||||||
const std::vector<PlayerProxy::RegType> PlayerProxy::REGISTER =
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<PlayerProxy::CustomRegType> PlayerProxy::REGISTER_CUSTOM =
|
const std::vector<PlayerProxy::CustomRegType> PlayerProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
// virtual PlayerColor getColor() const = 0;
|
// virtual PlayerColor getColor() const = 0;
|
||||||
|
@ -23,8 +23,6 @@ class PlayerProxy : public OpaqueWrapper<const Player, PlayerProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Player, PlayerProxy>;
|
using Wrapper = OpaqueWrapper<const Player, PlayerProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -22,38 +22,43 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(ServerCbProxy, "Server");
|
VCMI_REGISTER_CORE_SCRIPT_API(ServerCbProxy, "Server");
|
||||||
|
|
||||||
const std::vector<ServerCbProxy::RegType> ServerCbProxy::REGISTER =
|
const std::vector<ServerCbProxy::CustomRegType> ServerCbProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"addToBattleLog",
|
"addToBattleLog",
|
||||||
&ServerCbProxy::apply<BattleLogMessage>
|
&ServerCbProxy::apply<BattleLogMessage>,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"moveUnit",
|
"moveUnit",
|
||||||
&ServerCbProxy::apply<BattleStackMoved>
|
&ServerCbProxy::apply<BattleStackMoved>,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"changeUnits",
|
"changeUnits",
|
||||||
&ServerCbProxy::apply<BattleUnitsChanged>
|
&ServerCbProxy::apply<BattleUnitsChanged>,
|
||||||
|
false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"commitPackage",
|
"commitPackage",
|
||||||
&ServerCbProxy::commitPackage
|
&ServerCbProxy::commitPackage,
|
||||||
|
false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<ServerCbProxy::CustomRegType> ServerCbProxy::REGISTER_CUSTOM =
|
int ServerCbProxy::commitPackage(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
|
||||||
};
|
ServerCallback * object = nullptr;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
|
|
||||||
|
lua_remove(L, 1);
|
||||||
|
|
||||||
int ServerCbProxy::commitPackage(lua_State * L, ServerCallback * object)
|
|
||||||
{
|
|
||||||
if(lua_isuserdata(L, 1) != 1)
|
if(lua_isuserdata(L, 1) != 1)
|
||||||
{
|
return S.retVoid();
|
||||||
lua_settop(L, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_getfield(L, 1, "toNetpackLight");
|
lua_getfield(L, 1, "toNetpackLight");
|
||||||
lua_insert(L, 1);
|
lua_insert(L, 1);
|
||||||
@ -61,24 +66,28 @@ int ServerCbProxy::commitPackage(lua_State * L, ServerCallback * object)
|
|||||||
int ret = lua_pcall(L, 1, 1, 0);
|
int ret = lua_pcall(L, 1, 1, 0);
|
||||||
|
|
||||||
if(ret != 0 || !lua_islightuserdata(L, 1))
|
if(ret != 0 || !lua_islightuserdata(L, 1))
|
||||||
{
|
return S.retVoid();
|
||||||
lua_settop(L, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CPackForClient * pack = static_cast<CPackForClient *>(lua_touserdata(L, 1));
|
CPackForClient * pack = static_cast<CPackForClient *>(lua_touserdata(L, 1));
|
||||||
|
|
||||||
object->apply(pack);
|
object->apply(pack);
|
||||||
|
|
||||||
lua_settop(L, 0);
|
return S.retVoid();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NetPack>
|
template<typename NetPack>
|
||||||
int ServerCbProxy::apply(lua_State * L, ServerCallback * object)
|
int ServerCbProxy::apply(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
ServerCallback * object = nullptr;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retNil();
|
||||||
|
|
||||||
|
lua_remove(L, 1);
|
||||||
|
|
||||||
std::shared_ptr<NetPack> pack;
|
std::shared_ptr<NetPack> pack;
|
||||||
|
|
||||||
if(!S.tryGet(1, pack))
|
if(!S.tryGet(1, pack))
|
||||||
|
@ -24,13 +24,11 @@ class ServerCbProxy : public OpaqueWrapper<ServerCallback, ServerCbProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<ServerCallback, ServerCbProxy>;
|
using Wrapper = OpaqueWrapper<ServerCallback, ServerCbProxy>;
|
||||||
|
|
||||||
static int commitPackage(lua_State * L, ServerCallback * object);
|
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
template<typename NetPack>
|
template<typename NetPack>
|
||||||
static int apply(lua_State * L, ServerCallback * object);
|
static int apply(lua_State * L);
|
||||||
|
static int commitPackage(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,104 +33,64 @@ namespace api
|
|||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(ServicesProxy, "Services");
|
VCMI_REGISTER_CORE_SCRIPT_API(ServicesProxy, "Services");
|
||||||
|
|
||||||
const std::vector<ServicesProxy::RegType> ServicesProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"artifacts", LuaCallWrapper<const Services>::createFunctor(&Services::artifacts)},
|
|
||||||
{"creatures", LuaCallWrapper<const Services>::createFunctor(&Services::creatures)},
|
|
||||||
{"factions", LuaCallWrapper<const Services>::createFunctor(&Services::factions)},
|
|
||||||
{"heroClasses", LuaCallWrapper<const Services>::createFunctor(&Services::heroClasses)},
|
|
||||||
{"heroTypes", LuaCallWrapper<const Services>::createFunctor(&Services::heroTypes)},
|
|
||||||
{"spells", LuaCallWrapper<const Services>::createFunctor(&Services::spells)},
|
|
||||||
{"skills", LuaCallWrapper<const Services>::createFunctor(&Services::skills)},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<ServicesProxy::CustomRegType> ServicesProxy::REGISTER_CUSTOM =
|
const std::vector<ServicesProxy::CustomRegType> ServicesProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"artifacts", LuaMethodWrapper<Services, decltype(&Services::artifacts), &Services::artifacts>::invoke, false},
|
||||||
|
{"creatures", LuaMethodWrapper<Services, decltype(&Services::creatures), &Services::creatures>::invoke, false},
|
||||||
|
{"factions", LuaMethodWrapper<Services, decltype(&Services::factions), &Services::factions>::invoke, false},
|
||||||
|
{"heroClasses", LuaMethodWrapper<Services, decltype(&Services::heroClasses), &Services::heroClasses>::invoke, false},
|
||||||
|
{"heroTypes", LuaMethodWrapper<Services,decltype(&Services::heroTypes), &Services::heroTypes>::invoke, false},
|
||||||
|
{"spells", LuaMethodWrapper<Services, decltype(&Services::spells), &Services::spells>::invoke, false},
|
||||||
|
{"skills", LuaMethodWrapper<Services,decltype(&Services::skills), &Services::skills>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(ArtifactServiceProxy, "Artifacts");
|
VCMI_REGISTER_CORE_SCRIPT_API(ArtifactServiceProxy, "Artifacts");
|
||||||
|
|
||||||
const std::vector<ArtifactServiceProxy::RegType> ArtifactServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<ArtifactID, Artifact>>::createFunctor(&ArtifactService::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<ArtifactServiceProxy::CustomRegType> ArtifactServiceProxy::REGISTER_CUSTOM =
|
const std::vector<ArtifactServiceProxy::CustomRegType> ArtifactServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<ArtifactService, decltype(&ArtifactService::getByIndex), &ArtifactService::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(CreatureServiceProxy, "Creatures");
|
VCMI_REGISTER_CORE_SCRIPT_API(CreatureServiceProxy, "Creatures");
|
||||||
|
|
||||||
const std::vector<CreatureServiceProxy::RegType> CreatureServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<CreatureID, Creature>>::createFunctor(&CreatureService::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<CreatureServiceProxy::CustomRegType> CreatureServiceProxy::REGISTER_CUSTOM =
|
const std::vector<CreatureServiceProxy::CustomRegType> CreatureServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<CreatureService, decltype(&CreatureService::getByIndex), &CreatureService::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(FactionServiceProxy, "Factions");
|
VCMI_REGISTER_CORE_SCRIPT_API(FactionServiceProxy, "Factions");
|
||||||
|
|
||||||
const std::vector<FactionServiceProxy::RegType> FactionServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<FactionID, Faction>>::createFunctor(&FactionService::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<FactionServiceProxy::CustomRegType> FactionServiceProxy::REGISTER_CUSTOM =
|
const std::vector<FactionServiceProxy::CustomRegType> FactionServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<FactionService, decltype(&FactionService::getByIndex), &FactionService::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(HeroClassServiceProxy, "HeroClasses");
|
VCMI_REGISTER_CORE_SCRIPT_API(HeroClassServiceProxy, "HeroClasses");
|
||||||
|
|
||||||
const std::vector<HeroClassServiceProxy::RegType> HeroClassServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<HeroClassID, HeroClass>>::createFunctor(&HeroClassService::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<HeroClassServiceProxy::CustomRegType> HeroClassServiceProxy::REGISTER_CUSTOM =
|
const std::vector<HeroClassServiceProxy::CustomRegType> HeroClassServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<HeroClassService, decltype(&HeroClassService::getByIndex), &HeroClassService::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(HeroTypeServiceProxy, "HeroTypes");
|
VCMI_REGISTER_CORE_SCRIPT_API(HeroTypeServiceProxy, "HeroTypes");
|
||||||
|
|
||||||
const std::vector<HeroTypeServiceProxy::RegType> HeroTypeServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<HeroTypeID, HeroType>>::createFunctor(&HeroTypeService::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<HeroTypeServiceProxy::CustomRegType> HeroTypeServiceProxy::REGISTER_CUSTOM =
|
const std::vector<HeroTypeServiceProxy::CustomRegType> HeroTypeServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<HeroTypeService, decltype(&HeroTypeService::getByIndex), &HeroTypeService::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(SkillServiceProxy, "Skills");
|
VCMI_REGISTER_CORE_SCRIPT_API(SkillServiceProxy, "Skills");
|
||||||
|
|
||||||
const std::vector<SkillServiceProxy::RegType> SkillServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<SecondarySkill, Skill>>::createFunctor(&SkillService::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<SkillServiceProxy::CustomRegType> SkillServiceProxy::REGISTER_CUSTOM =
|
const std::vector<SkillServiceProxy::CustomRegType> SkillServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<SkillService, decltype(&SkillService::getByIndex), &SkillService::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(SpellServiceProxy, "Spells");
|
VCMI_REGISTER_CORE_SCRIPT_API(SpellServiceProxy, "Spells");
|
||||||
|
|
||||||
const std::vector<SpellServiceProxy::RegType> SpellServiceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getByIndex", LuaCallWrapper<const EntityServiceT<SpellID, spells::Spell>>::createFunctor(&spells::Service::getByIndex)}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<SpellServiceProxy::CustomRegType> SpellServiceProxy::REGISTER_CUSTOM =
|
const std::vector<SpellServiceProxy::CustomRegType> SpellServiceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getByIndex", LuaMethodWrapper<spells::Service, decltype(&spells::Service::getByIndex), &spells::Service::getByIndex>::invoke, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ class ServicesProxy : public OpaqueWrapper<const Services, ServicesProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Services, ServicesProxy>;
|
using Wrapper = OpaqueWrapper<const Services, ServicesProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,7 +38,6 @@ class ArtifactServiceProxy : public OpaqueWrapper<const ArtifactService, Artifac
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const ArtifactService, ArtifactServiceProxy>;
|
using Wrapper = OpaqueWrapper<const ArtifactService, ArtifactServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,7 +45,6 @@ class CreatureServiceProxy : public OpaqueWrapper<const CreatureService, Creatur
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const CreatureService, CreatureServiceProxy>;
|
using Wrapper = OpaqueWrapper<const CreatureService, CreatureServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,7 +52,6 @@ class FactionServiceProxy : public OpaqueWrapper<const FactionService, FactionSe
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const FactionService, FactionServiceProxy>;
|
using Wrapper = OpaqueWrapper<const FactionService, FactionServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +59,6 @@ class HeroClassServiceProxy : public OpaqueWrapper<const HeroClassService, HeroC
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const HeroClassService, HeroClassServiceProxy>;
|
using Wrapper = OpaqueWrapper<const HeroClassService, HeroClassServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,7 +66,6 @@ class HeroTypeServiceProxy : public OpaqueWrapper<const HeroTypeService, HeroTyp
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const HeroTypeService, HeroTypeServiceProxy>;
|
using Wrapper = OpaqueWrapper<const HeroTypeService, HeroTypeServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,7 +73,6 @@ class SkillServiceProxy : public OpaqueWrapper<const SkillService, SkillServiceP
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const SkillService, SkillServiceProxy>;
|
using Wrapper = OpaqueWrapper<const SkillService, SkillServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,7 +80,6 @@ class SpellServiceProxy : public OpaqueWrapper<const spells::Service, SpellServi
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const spells::Service, SpellServiceProxy>;
|
using Wrapper = OpaqueWrapper<const spells::Service, SpellServiceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,14 +22,12 @@ namespace api
|
|||||||
{
|
{
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(SkillProxy, "Skill");
|
VCMI_REGISTER_CORE_SCRIPT_API(SkillProxy, "Skill");
|
||||||
|
|
||||||
const std::vector<SkillProxy::RegType> SkillProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<SkillProxy::CustomRegType> SkillProxy::REGISTER_CUSTOM =
|
const std::vector<SkillProxy::CustomRegType> SkillProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<Skill, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<Skill, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<Skill, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<Skill, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<Skill, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<Skill, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<Skill, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<Skill, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ class SkillProxy : public OpaqueWrapper<const Skill, SkillProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Skill, SkillProxy>;
|
using Wrapper = OpaqueWrapper<const Skill, SkillProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,31 +26,27 @@ VCMI_REGISTER_CORE_SCRIPT_API(SpellProxy, "Spell");
|
|||||||
|
|
||||||
//TODO:calculateDamage,forEachSchool
|
//TODO:calculateDamage,forEachSchool
|
||||||
|
|
||||||
const std::vector<SpellProxy::RegType> SpellProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getCost", LuaCallWrapper<const Spell>::createFunctor(&Spell::getCost)},
|
|
||||||
{"getBasePower", LuaCallWrapper<const Spell>::createFunctor(&Spell::getBasePower)},
|
|
||||||
{"getLevelPower", LuaCallWrapper<const Spell>::createFunctor(&Spell::getLevelPower)},
|
|
||||||
{"getLevelDescription", LuaCallWrapper<const Spell>::createFunctor(&Spell::getLevelDescription)},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<SpellProxy::CustomRegType> SpellProxy::REGISTER_CUSTOM =
|
const std::vector<SpellProxy::CustomRegType> SpellProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getIconIndex", LuaMethodWrapper<Spell, int32_t(Entity:: *)()const, &Entity::getIconIndex>::invoke, false},
|
{"getIconIndex", LuaMethodWrapper<Spell, decltype(&Entity::getIconIndex), &Entity::getIconIndex>::invoke, false},
|
||||||
{"getIndex", LuaMethodWrapper<Spell, int32_t(Entity:: *)()const, &Entity::getIndex>::invoke, false},
|
{"getIndex", LuaMethodWrapper<Spell, decltype(&Entity::getIndex), &Entity::getIndex>::invoke, false},
|
||||||
{"getJsonKey", LuaMethodWrapper<Spell, const std::string &(Entity:: *)()const, &Entity::getJsonKey>::invoke, false},
|
{"getJsonKey", LuaMethodWrapper<Spell, decltype(&Entity::getJsonKey), &Entity::getJsonKey>::invoke, false},
|
||||||
{"getName", LuaMethodWrapper<Spell, const std::string &(Entity:: *)()const, &Entity::getName>::invoke, false},
|
{"getName", LuaMethodWrapper<Spell, decltype(&Entity::getName), &Entity::getName>::invoke, false},
|
||||||
|
|
||||||
{"isAdventure", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isAdventure>::invoke, false},
|
{"isAdventure", LuaMethodWrapper<Spell, decltype(&Spell::isAdventure), &Spell::isAdventure>::invoke, false},
|
||||||
{"isCombat", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isCombat>::invoke, false},
|
{"isCombat", LuaMethodWrapper<Spell, decltype(&Spell::isCombat), &Spell::isCombat>::invoke, false},
|
||||||
{"isCreatureAbility", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isCreatureAbility>::invoke, false},
|
{"isCreatureAbility", LuaMethodWrapper<Spell, decltype(&Spell::isCreatureAbility), &Spell::isCreatureAbility>::invoke, false},
|
||||||
{"isPositive", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isPositive>::invoke, false},
|
{"isPositive", LuaMethodWrapper<Spell, decltype(&Spell::isPositive), &Spell::isPositive>::invoke, false},
|
||||||
{"isNegative", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isNegative>::invoke, false},
|
{"isNegative", LuaMethodWrapper<Spell, decltype(&Spell::isNegative), &Spell::isNegative>::invoke, false},
|
||||||
{"isNeutral", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isNeutral>::invoke, false},
|
{"isNeutral", LuaMethodWrapper<Spell, decltype(&Spell::isNeutral), &Spell::isNeutral>::invoke, false},
|
||||||
{"isDamage", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isDamage>::invoke, false},
|
{"isDamage", LuaMethodWrapper<Spell, decltype(&Spell::isDamage), &Spell::isDamage>::invoke, false},
|
||||||
{"isOffensive", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isOffensive>::invoke, false},
|
{"isOffensive", LuaMethodWrapper<Spell, decltype(&Spell::isOffensive), &Spell::isOffensive>::invoke, false},
|
||||||
{"isSpecial", LuaMethodWrapper<Spell, bool(Spell:: *)()const, &Spell::isSpecial>::invoke, false},
|
{"isSpecial", LuaMethodWrapper<Spell, decltype(&Spell::isSpecial), &Spell::isSpecial>::invoke, false},
|
||||||
|
|
||||||
|
{"getCost", LuaMethodWrapper<Spell, decltype(&Spell::getCost), &Spell::getCost>::invoke, false},
|
||||||
|
{"getBasePower", LuaMethodWrapper<Spell, decltype(&Spell::getBasePower), &Spell::getBasePower>::invoke, false},
|
||||||
|
{"getLevelPower", LuaMethodWrapper<Spell, decltype(&Spell::getLevelPower), &Spell::getLevelPower>::invoke, false},
|
||||||
|
{"getLevelDescription", LuaMethodWrapper<Spell, decltype(&Spell::getLevelDescription), &Spell::getLevelDescription>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ class SpellProxy : public OpaqueWrapper<const ::spells::Spell, SpellProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const ::spells::Spell, SpellProxy>;
|
using Wrapper = OpaqueWrapper<const ::spells::Spell, SpellProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,15 +23,10 @@ namespace api
|
|||||||
{
|
{
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(StackInstanceProxy, "StackInstance");
|
VCMI_REGISTER_CORE_SCRIPT_API(StackInstanceProxy, "StackInstance");
|
||||||
|
|
||||||
const std::vector<StackInstanceProxy::RegType> StackInstanceProxy::REGISTER =
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<StackInstanceProxy::CustomRegType> StackInstanceProxy::REGISTER_CUSTOM =
|
const std::vector<StackInstanceProxy::CustomRegType> StackInstanceProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"getType", LuaMethodWrapper<CStackInstance, const Creature *(CStackBasicDescriptor:: *)()const, &CStackBasicDescriptor::getType>::invoke, false},
|
{"getType", LuaMethodWrapper<CStackInstance, decltype(&CStackBasicDescriptor::getType), &CStackBasicDescriptor::getType>::invoke, false},
|
||||||
{"getCount", LuaMethodWrapper<CStackInstance, TQuantity(CStackBasicDescriptor:: *)()const, &CStackBasicDescriptor::getCount>::invoke, false},
|
{"getCount", LuaMethodWrapper<CStackInstance, decltype(&CStackBasicDescriptor::getCount), &CStackBasicDescriptor::getCount>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ class StackInstanceProxy : public OpaqueWrapper<const CStackInstance, StackInsta
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const CStackInstance, StackInstanceProxy>;
|
using Wrapper = OpaqueWrapper<const CStackInstance, StackInstanceProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,37 +25,14 @@ namespace battle
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(UnitProxy, "battle.Unit")
|
VCMI_REGISTER_SCRIPT_API(UnitProxy, "battle.Unit")
|
||||||
|
|
||||||
const std::vector<UnitProxy::RegType> UnitProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"getMinDamage",
|
|
||||||
LuaCallWrapper<const IBonusBearer>::createFunctor(&IBonusBearer::getMinDamage)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getMaxDamage",
|
|
||||||
LuaCallWrapper<const IBonusBearer>::createFunctor(&IBonusBearer::getMaxDamage)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getAttack",
|
|
||||||
LuaCallWrapper<const IBonusBearer>::createFunctor(&IBonusBearer::getAttack)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getDefense",
|
|
||||||
LuaCallWrapper<const IBonusBearer>::createFunctor(&IBonusBearer::getDefense)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"isAlive",
|
|
||||||
LuaCallWrapper<const Unit>::createFunctor(&Unit::alive)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"unitId",
|
|
||||||
LuaCallWrapper<const IUnitInfo>::createFunctor(&IUnitInfo::unitId)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<UnitProxy::CustomRegType> UnitProxy::REGISTER_CUSTOM =
|
const std::vector<UnitProxy::CustomRegType> UnitProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
|
{"getMinDamage", LuaMethodWrapper<Unit, decltype(&IBonusBearer::getMinDamage), &IBonusBearer::getMinDamage>::invoke, false},
|
||||||
|
{"getMaxDamage", LuaMethodWrapper<Unit, decltype(&IBonusBearer::getMaxDamage), &IBonusBearer::getMaxDamage>::invoke, false},
|
||||||
|
{"getAttack", LuaMethodWrapper<Unit, decltype(&IBonusBearer::getAttack), &IBonusBearer::getAttack>::invoke, false},
|
||||||
|
{"getDefense", LuaMethodWrapper<Unit, decltype(&IBonusBearer::getDefense), &IBonusBearer::getDefense>::invoke, false},
|
||||||
|
{"isAlive", LuaMethodWrapper<Unit, decltype(&Unit::alive), &Unit::alive>::invoke, false},
|
||||||
|
{"unitId", LuaMethodWrapper<Unit, decltype(&IUnitInfo::unitId), &IUnitInfo::unitId>::invoke, false},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,6 @@ class UnitProxy : public OpaqueWrapper<const Unit, UnitProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<const Unit, UnitProxy>;
|
using Wrapper = OpaqueWrapper<const Unit, UnitProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,35 +25,13 @@ namespace events
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(ObjectVisitStartedProxy, "events.ObjectVisitStarted");
|
VCMI_REGISTER_SCRIPT_API(ObjectVisitStartedProxy, "events.ObjectVisitStarted");
|
||||||
|
|
||||||
const std::vector<ObjectVisitStartedProxy::RegType> ObjectVisitStartedProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<ObjectVisitStartedProxy::CustomRegType> ObjectVisitStartedProxy::REGISTER_CUSTOM =
|
const std::vector<ObjectVisitStartedProxy::CustomRegType> ObjectVisitStartedProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{"subscribeBefore", &SubscriptionRegistryProxy<ObjectVisitStartedProxy>::subscribeBefore, true},
|
||||||
"subscribeBefore",
|
{"subscribeAfter", &SubscriptionRegistryProxy<ObjectVisitStartedProxy>::subscribeAfter,true},
|
||||||
&SubscriptionRegistryProxy<ObjectVisitStartedProxy>::subscribeBefore,
|
{"getPlayer", LuaMethodWrapper<ObjectVisitStarted, decltype(&ObjectVisitStarted::getPlayer), &ObjectVisitStarted::getPlayer>::invoke, false},
|
||||||
true
|
{"getHero", LuaMethodWrapper<ObjectVisitStarted, decltype(&ObjectVisitStarted::getHero), &ObjectVisitStarted::getHero>::invoke, false},
|
||||||
},
|
{"getObject", LuaMethodWrapper<ObjectVisitStarted, decltype(&ObjectVisitStarted::getObject), &ObjectVisitStarted::getObject>::invoke, false},
|
||||||
{
|
|
||||||
"subscribeAfter",
|
|
||||||
&SubscriptionRegistryProxy<ObjectVisitStartedProxy>::subscribeAfter,
|
|
||||||
true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getPlayer",
|
|
||||||
LuaMethodWrapper<ObjectVisitStarted, PlayerColor(ObjectVisitStarted:: *)()const, &ObjectVisitStarted::getPlayer>::invoke,
|
|
||||||
false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getHero",
|
|
||||||
LuaMethodWrapper<ObjectVisitStarted, ObjectInstanceID(ObjectVisitStarted:: *)()const, &ObjectVisitStarted::getHero>::invoke,
|
|
||||||
false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getObject",
|
|
||||||
LuaMethodWrapper<ObjectVisitStarted, ObjectInstanceID(ObjectVisitStarted:: *)()const, &ObjectVisitStarted::getObject>::invoke,
|
|
||||||
false
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ class ObjectVisitStartedProxy : public OpaqueWrapper<ObjectVisitStarted, ObjectV
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<ObjectVisitStarted, ObjectVisitStartedProxy>;
|
using Wrapper = OpaqueWrapper<ObjectVisitStarted, ObjectVisitStartedProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,26 +27,6 @@ using ::events::ApplyDamage;
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(ApplyDamageProxy, "events.ApplyDamage");
|
VCMI_REGISTER_SCRIPT_API(ApplyDamageProxy, "events.ApplyDamage");
|
||||||
|
|
||||||
const std::vector<ApplyDamageProxy::RegType> ApplyDamageProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"getInitalDamage",
|
|
||||||
LuaCallWrapper<ApplyDamage>::createFunctor(&ApplyDamage::getInitalDamage)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getDamage",
|
|
||||||
LuaCallWrapper<ApplyDamage>::createFunctor(&ApplyDamage::getDamage)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"setDamage",
|
|
||||||
LuaCallWrapper<ApplyDamage>::createFunctor(&ApplyDamage::setDamage)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"getTarget",
|
|
||||||
LuaCallWrapper<ApplyDamage>::createFunctor(&ApplyDamage::getTarget)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<ApplyDamageProxy::CustomRegType> ApplyDamageProxy::REGISTER_CUSTOM =
|
const std::vector<ApplyDamageProxy::CustomRegType> ApplyDamageProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -58,7 +38,28 @@ const std::vector<ApplyDamageProxy::CustomRegType> ApplyDamageProxy::REGISTER_CU
|
|||||||
"subscribeAfter",
|
"subscribeAfter",
|
||||||
&SubscriptionRegistryProxy<ApplyDamageProxy>::subscribeAfter,
|
&SubscriptionRegistryProxy<ApplyDamageProxy>::subscribeAfter,
|
||||||
true
|
true
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"getInitalDamage",
|
||||||
|
LuaMethodWrapper<ApplyDamage, decltype(&ApplyDamage::getInitalDamage), &ApplyDamage::getInitalDamage>::invoke,
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"getDamage",
|
||||||
|
LuaMethodWrapper<ApplyDamage, decltype(&ApplyDamage::getDamage), &ApplyDamage::getDamage>::invoke,
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setDamage",
|
||||||
|
LuaMethodWrapper<ApplyDamage, decltype(&ApplyDamage::setDamage), &ApplyDamage::setDamage>::invoke,
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"getTarget",
|
||||||
|
LuaMethodWrapper<ApplyDamage, decltype(&ApplyDamage::getTarget), &ApplyDamage::getTarget>::invoke,
|
||||||
|
false
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ class ApplyDamageProxy : public OpaqueWrapper<::events::ApplyDamage, ApplyDamage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<::events::ApplyDamage, ApplyDamageProxy>;
|
using Wrapper = OpaqueWrapper<::events::ApplyDamage, ApplyDamageProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ namespace events
|
|||||||
{
|
{
|
||||||
//No methods here, just an empty metatable for type safety.
|
//No methods here, just an empty metatable for type safety.
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(EventBusProxy, "EventBus");
|
VCMI_REGISTER_CORE_SCRIPT_API(EventBusProxy, "EventBus");
|
||||||
const std::vector<EventBusProxy::RegType> EventBusProxy::REGISTER = {};
|
|
||||||
const std::vector<EventBusProxy::CustomRegType> EventBusProxy::REGISTER_CUSTOM = {};
|
const std::vector<EventBusProxy::CustomRegType> EventBusProxy::REGISTER_CUSTOM = {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ class EventBusProxy : public OpaqueWrapper<::events::EventBus, EventBusProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<::events::EventBus, EventBusProxy>;
|
using Wrapper = OpaqueWrapper<::events::EventBus, EventBusProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,8 +30,6 @@ VCMI_REGISTER_SCRIPT_API(GameResumedProxy, "events.GameResumed");
|
|||||||
VCMI_REGISTER_SCRIPT_API(PlayerGotTurnProxy, "events.PlayerGotTurn");
|
VCMI_REGISTER_SCRIPT_API(PlayerGotTurnProxy, "events.PlayerGotTurn");
|
||||||
VCMI_REGISTER_SCRIPT_API(TurnStartedProxy, "events.TurnStarted");
|
VCMI_REGISTER_SCRIPT_API(TurnStartedProxy, "events.TurnStarted");
|
||||||
|
|
||||||
const std::vector<GameResumedProxy::RegType> GameResumedProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<GameResumedProxy::CustomRegType> GameResumedProxy::REGISTER_CUSTOM =
|
const std::vector<GameResumedProxy::CustomRegType> GameResumedProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -46,18 +44,6 @@ const std::vector<GameResumedProxy::CustomRegType> GameResumedProxy::REGISTER_CU
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<PlayerGotTurnProxy::RegType> PlayerGotTurnProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"getPlayer",
|
|
||||||
LuaCallWrapper<PlayerGotTurn>::createFunctor(&PlayerGotTurn::getPlayerIndex)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"setPlayer",
|
|
||||||
LuaCallWrapper<PlayerGotTurn>::createFunctor(&PlayerGotTurn::setPlayerIndex)
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<PlayerGotTurnProxy::CustomRegType> PlayerGotTurnProxy::REGISTER_CUSTOM =
|
const std::vector<PlayerGotTurnProxy::CustomRegType> PlayerGotTurnProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -69,11 +55,19 @@ const std::vector<PlayerGotTurnProxy::CustomRegType> PlayerGotTurnProxy::REGISTE
|
|||||||
"subscribeAfter",
|
"subscribeAfter",
|
||||||
&SubscriptionRegistryProxy<PlayerGotTurnProxy>::subscribeAfter,
|
&SubscriptionRegistryProxy<PlayerGotTurnProxy>::subscribeAfter,
|
||||||
true
|
true
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"getPlayer",
|
||||||
|
LuaMethodWrapper<PlayerGotTurn, decltype(&PlayerGotTurn::getPlayerIndex), &PlayerGotTurn::getPlayerIndex>::invoke,
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"setPlayer",
|
||||||
|
LuaMethodWrapper<PlayerGotTurn, decltype(&PlayerGotTurn::setPlayerIndex), &PlayerGotTurn::setPlayerIndex>::invoke,
|
||||||
|
false
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<TurnStartedProxy::RegType> TurnStartedProxy::REGISTER = {};
|
|
||||||
|
|
||||||
const std::vector<TurnStartedProxy::CustomRegType> TurnStartedProxy::REGISTER_CUSTOM =
|
const std::vector<TurnStartedProxy::CustomRegType> TurnStartedProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,6 @@ class GameResumedProxy : public OpaqueWrapper<::events::GameResumed, GameResumed
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<::events::GameResumed, GameResumedProxy>;
|
using Wrapper = OpaqueWrapper<::events::GameResumed, GameResumedProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,7 +34,6 @@ class PlayerGotTurnProxy : public OpaqueWrapper<::events::PlayerGotTurn, PlayerG
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<::events::PlayerGotTurn, PlayerGotTurnProxy>;
|
using Wrapper = OpaqueWrapper<::events::PlayerGotTurn, PlayerGotTurnProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,7 +41,6 @@ class TurnStartedProxy : public OpaqueWrapper<::events::TurnStarted, TurnStarted
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = OpaqueWrapper<::events::TurnStarted, TurnStartedProxy>;
|
using Wrapper = OpaqueWrapper<::events::TurnStarted, TurnStartedProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ namespace events
|
|||||||
{
|
{
|
||||||
//No methods here, just an empty metatable for type safety.
|
//No methods here, just an empty metatable for type safety.
|
||||||
VCMI_REGISTER_CORE_SCRIPT_API(EventSubscriptionProxy, "EventSubscription");
|
VCMI_REGISTER_CORE_SCRIPT_API(EventSubscriptionProxy, "EventSubscription");
|
||||||
const std::vector<EventSubscriptionProxy::RegType> EventSubscriptionProxy::REGISTER = {};
|
|
||||||
const std::vector<EventSubscriptionProxy::CustomRegType> EventSubscriptionProxy::REGISTER_CUSTOM = {};
|
const std::vector<EventSubscriptionProxy::CustomRegType> EventSubscriptionProxy::REGISTER_CUSTOM = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ class EventSubscriptionProxy : public UniqueOpaqueWrapper<::events::EventSubscri
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = UniqueOpaqueWrapper<::events::EventSubscription, EventSubscriptionProxy>;
|
using Wrapper = UniqueOpaqueWrapper<::events::EventSubscription, EventSubscriptionProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,35 +24,30 @@ namespace netpacks
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(BattleLogMessageProxy, "netpacks.BattleLogMessage");
|
VCMI_REGISTER_SCRIPT_API(BattleLogMessageProxy, "netpacks.BattleLogMessage");
|
||||||
|
|
||||||
const std::vector<BattleLogMessageProxy::RegType> BattleLogMessageProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"addText",
|
|
||||||
&BattleLogMessageProxy::addText
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"toNetpackLight",
|
|
||||||
&PackForClientProxy<BattleLogMessageProxy>::toNetpackLight
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<BattleLogMessageProxy::CustomRegType> BattleLogMessageProxy::REGISTER_CUSTOM =
|
const std::vector<BattleLogMessageProxy::CustomRegType> BattleLogMessageProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"new", &Wrapper::constructor, true}
|
{"new", &Wrapper::constructor, true},
|
||||||
|
{"addText", &BattleLogMessageProxy::addText, false},
|
||||||
|
{"toNetpackLight",&PackForClientProxy<BattleLogMessageProxy>::toNetpackLight, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int BattleLogMessageProxy::addText(lua_State * L, std::shared_ptr<BattleLogMessage> object)
|
int BattleLogMessageProxy::addText(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<BattleLogMessage> object;
|
||||||
|
|
||||||
|
if(S.tryGet(1, object))
|
||||||
|
{
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
if(S.tryGet(1, text))
|
if(S.tryGet(2, text))
|
||||||
{
|
{
|
||||||
if(object->lines.empty())
|
if(object->lines.empty())
|
||||||
object->lines.emplace_back();
|
object->lines.emplace_back();
|
||||||
object->lines.back() << text;
|
object->lines.back() << text;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ class BattleLogMessageProxy : public SharedWrapper<BattleLogMessage, BattleLogMe
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<BattleLogMessage, BattleLogMessageProxy>;
|
using Wrapper = SharedWrapper<BattleLogMessage, BattleLogMessageProxy>;
|
||||||
|
|
||||||
static const std::vector<Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int addText(lua_State * L, std::shared_ptr<BattleLogMessage> object);
|
static int addText(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,63 +24,58 @@ namespace netpacks
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(BattleStackMovedProxy, "netpacks.BattleStackMoved");
|
VCMI_REGISTER_SCRIPT_API(BattleStackMovedProxy, "netpacks.BattleStackMoved");
|
||||||
|
|
||||||
const std::vector<BattleStackMovedProxy::RegType> BattleStackMovedProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"addTileToMove",
|
|
||||||
&BattleStackMovedProxy::addTileToMove
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"setUnitId",
|
|
||||||
&BattleStackMovedProxy::setUnitId
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"setDistance",
|
|
||||||
&BattleStackMovedProxy::setDistance
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"setTeleporting",
|
|
||||||
&BattleStackMovedProxy::setTeleporting
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"toNetpackLight",
|
|
||||||
&PackForClientProxy<BattleStackMovedProxy>::toNetpackLight
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<BattleStackMovedProxy::CustomRegType> BattleStackMovedProxy::REGISTER_CUSTOM =
|
const std::vector<BattleStackMovedProxy::CustomRegType> BattleStackMovedProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"new", &Wrapper::constructor, true}
|
{"new", &Wrapper::constructor, true},
|
||||||
|
{"addTileToMove", &BattleStackMovedProxy::addTileToMove, false},
|
||||||
|
{"setUnitId", &BattleStackMovedProxy::setUnitId, false},
|
||||||
|
{"setDistance", &BattleStackMovedProxy::setDistance, false},
|
||||||
|
{"setTeleporting", &BattleStackMovedProxy::setTeleporting, false},
|
||||||
|
{"toNetpackLight", &PackForClientProxy<BattleStackMovedProxy>::toNetpackLight, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int BattleStackMovedProxy::addTileToMove(lua_State * L, std::shared_ptr<BattleStackMoved> object)
|
int BattleStackMovedProxy::addTileToMove(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<BattleStackMoved> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
lua_Integer hex = 0;
|
lua_Integer hex = 0;
|
||||||
if(!S.tryGetInteger(1, hex))
|
if(!S.tryGetInteger(2, hex))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
object->tilesToMove.emplace_back(hex);
|
object->tilesToMove.emplace_back(hex);
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleStackMovedProxy::setUnitId(lua_State * L, std::shared_ptr<BattleStackMoved> object)
|
int BattleStackMovedProxy::setUnitId(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
S.tryGet(1, object->stack);
|
std::shared_ptr<BattleStackMoved> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
S.tryGet(2, object->stack);
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleStackMovedProxy::setDistance(lua_State * L, std::shared_ptr<BattleStackMoved> object)
|
int BattleStackMovedProxy::setDistance(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
S.tryGet(1, object->distance);
|
std::shared_ptr<BattleStackMoved> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
S.tryGet(2, object->distance);
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleStackMovedProxy::setTeleporting(lua_State * L, std::shared_ptr<BattleStackMoved> object)
|
int BattleStackMovedProxy::setTeleporting(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
S.tryGet(1, object->teleporting);
|
std::shared_ptr<BattleStackMoved> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
S.tryGet(2, object->teleporting);
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,14 +24,12 @@ class BattleStackMovedProxy : public SharedWrapper<BattleStackMoved, BattleStack
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<BattleStackMoved, BattleStackMovedProxy>;
|
using Wrapper = SharedWrapper<BattleStackMoved, BattleStackMovedProxy>;
|
||||||
|
|
||||||
static const std::vector<Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int addTileToMove(lua_State * L, std::shared_ptr<BattleStackMoved> object);
|
static int addTileToMove(lua_State * L);
|
||||||
|
static int setUnitId(lua_State * L);
|
||||||
static int setUnitId(lua_State * L, std::shared_ptr<BattleStackMoved> object);
|
static int setDistance(lua_State * L);
|
||||||
static int setDistance(lua_State * L, std::shared_ptr<BattleStackMoved> object);
|
static int setTeleporting(lua_State * L);
|
||||||
static int setTeleporting(lua_State * L, std::shared_ptr<BattleStackMoved> object);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,49 +24,35 @@ namespace netpacks
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(BattleUnitsChangedProxy, "netpacks.BattleUnitsChanged");
|
VCMI_REGISTER_SCRIPT_API(BattleUnitsChangedProxy, "netpacks.BattleUnitsChanged");
|
||||||
|
|
||||||
const std::vector<BattleUnitsChangedProxy::RegType> BattleUnitsChangedProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"toNetpackLight",
|
|
||||||
&PackForClientProxy<BattleUnitsChangedProxy>::toNetpackLight
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"add",
|
|
||||||
&BattleUnitsChangedProxy::add
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"update",
|
|
||||||
&BattleUnitsChangedProxy::update
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"resetState",
|
|
||||||
&BattleUnitsChangedProxy::resetState
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"remove",
|
|
||||||
&BattleUnitsChangedProxy::remove
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<BattleUnitsChangedProxy::CustomRegType> BattleUnitsChangedProxy::REGISTER_CUSTOM =
|
const std::vector<BattleUnitsChangedProxy::CustomRegType> BattleUnitsChangedProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"new", &Wrapper::constructor, true}
|
{"new", &Wrapper::constructor, true},
|
||||||
|
{"add", &BattleUnitsChangedProxy::add, false},
|
||||||
|
{"update", &BattleUnitsChangedProxy::update, false},
|
||||||
|
{"resetState", &BattleUnitsChangedProxy::resetState, false},
|
||||||
|
{"remove", &BattleUnitsChangedProxy::remove, false},
|
||||||
|
{"toNetpackLight", &PackForClientProxy<BattleUnitsChangedProxy>::toNetpackLight, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int BattleUnitsChangedProxy::add(lua_State * L, std::shared_ptr<BattleUnitsChanged> object)
|
int BattleUnitsChangedProxy::add(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<BattleUnitsChanged> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
if(!S.tryGet(1, id))
|
if(!S.tryGet(2, id))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
UnitChanges changes(id, BattleChanges::EOperation::ADD);
|
UnitChanges changes(id, BattleChanges::EOperation::ADD);
|
||||||
|
|
||||||
if(!S.tryGet(2, changes.data))
|
if(!S.tryGet(3, changes.data))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
if(!S.tryGet(3, changes.healthDelta))
|
if(!S.tryGet(4, changes.healthDelta))
|
||||||
changes.healthDelta = 0;
|
changes.healthDelta = 0;
|
||||||
|
|
||||||
object->changedStacks.push_back(changes);
|
object->changedStacks.push_back(changes);
|
||||||
@ -74,21 +60,25 @@ int BattleUnitsChangedProxy::add(lua_State * L, std::shared_ptr<BattleUnitsChang
|
|||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleUnitsChangedProxy::update(lua_State * L, std::shared_ptr<BattleUnitsChanged> object)
|
int BattleUnitsChangedProxy::update(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<BattleUnitsChanged> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
if(!S.tryGet(1, id))
|
if(!S.tryGet(2, id))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
UnitChanges changes(id, BattleChanges::EOperation::UPDATE);
|
UnitChanges changes(id, BattleChanges::EOperation::UPDATE);
|
||||||
|
|
||||||
if(!S.tryGet(2, changes.data))
|
if(!S.tryGet(3, changes.data))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
if(!S.tryGet(3, changes.healthDelta))
|
if(!S.tryGet(4, changes.healthDelta))
|
||||||
changes.healthDelta = 0;
|
changes.healthDelta = 0;
|
||||||
|
|
||||||
object->changedStacks.push_back(changes);
|
object->changedStacks.push_back(changes);
|
||||||
@ -96,15 +86,25 @@ int BattleUnitsChangedProxy::update(lua_State * L, std::shared_ptr<BattleUnitsCh
|
|||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleUnitsChangedProxy::resetState(lua_State * L, std::shared_ptr<BattleUnitsChanged> object)
|
int BattleUnitsChangedProxy::resetState(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<BattleUnitsChanged> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
//todo
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int BattleUnitsChangedProxy::remove(lua_State * L, std::shared_ptr<BattleUnitsChanged> object)
|
int BattleUnitsChangedProxy::remove(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<BattleUnitsChanged> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
//todo
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,13 +24,12 @@ class BattleUnitsChangedProxy : public SharedWrapper<BattleUnitsChanged, BattleU
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<BattleUnitsChanged, BattleUnitsChangedProxy>;
|
using Wrapper = SharedWrapper<BattleUnitsChanged, BattleUnitsChangedProxy>;
|
||||||
|
|
||||||
static const std::vector<Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int add(lua_State * L, std::shared_ptr<BattleUnitsChanged> object);
|
static int add(lua_State * L);
|
||||||
static int update(lua_State * L, std::shared_ptr<BattleUnitsChanged> object);
|
static int update(lua_State * L);
|
||||||
static int resetState(lua_State * L, std::shared_ptr<BattleUnitsChanged> object);
|
static int resetState(lua_State * L);
|
||||||
static int remove(lua_State * L, std::shared_ptr<BattleUnitsChanged> object);
|
static int remove(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,39 +24,33 @@ namespace netpacks
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(EntitiesChangedProxy, "netpacks.EntitiesChanged");
|
VCMI_REGISTER_SCRIPT_API(EntitiesChangedProxy, "netpacks.EntitiesChanged");
|
||||||
|
|
||||||
const std::vector<EntitiesChangedProxy::RegType> EntitiesChangedProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"update",
|
|
||||||
&EntitiesChangedProxy::update
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"toNetpackLight",
|
|
||||||
&PackForClientProxy<EntitiesChangedProxy>::toNetpackLight
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<EntitiesChangedProxy::CustomRegType> EntitiesChangedProxy::REGISTER_CUSTOM =
|
const std::vector<EntitiesChangedProxy::CustomRegType> EntitiesChangedProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"new", &Wrapper::constructor, true}
|
{"new", &Wrapper::constructor, true},
|
||||||
|
{"update", &EntitiesChangedProxy::update, false},
|
||||||
|
{"toNetpackLight", &PackForClientProxy<EntitiesChangedProxy>::toNetpackLight, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int EntitiesChangedProxy::update(lua_State * L, std::shared_ptr<EntitiesChanged> object)
|
int EntitiesChangedProxy::update(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<EntitiesChanged> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
EntityChanges changes;
|
EntityChanges changes;
|
||||||
|
|
||||||
int32_t metaIndex = 0;
|
int32_t metaIndex = 0;
|
||||||
|
|
||||||
if(!S.tryGet(1, metaIndex))
|
if(!S.tryGet(2, metaIndex))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
changes.metatype = static_cast<Metatype>(metaIndex);
|
changes.metatype = static_cast<Metatype>(metaIndex);
|
||||||
|
|
||||||
if(!S.tryGet(2, changes.entityIndex))
|
if(!S.tryGet(3, changes.entityIndex))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
if(!S.tryGet(3, changes.data))
|
if(!S.tryGet(4, changes.data))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
object->changes.push_back(changes);
|
object->changes.push_back(changes);
|
||||||
|
@ -25,10 +25,9 @@ class EntitiesChangedProxy : public SharedWrapper<EntitiesChanged, EntitiesChang
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<EntitiesChanged, EntitiesChangedProxy>;
|
using Wrapper = SharedWrapper<EntitiesChanged, EntitiesChangedProxy>;
|
||||||
|
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int update(lua_State * L, std::shared_ptr<EntitiesChanged> object);
|
static int update(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,96 +27,96 @@ namespace api
|
|||||||
namespace netpacks
|
namespace netpacks
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::vector<InfoWindowProxy::RegType> InfoWindowProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"addReplacement",
|
|
||||||
&InfoWindowProxy::addReplacement
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"addText",
|
|
||||||
&InfoWindowProxy::addText
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"setPlayer",
|
|
||||||
&InfoWindowProxy::setPlayer
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"toNetpackLight",
|
|
||||||
&PackForClientProxy<InfoWindowProxy>::toNetpackLight
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<InfoWindowProxy::CustomRegType> InfoWindowProxy::REGISTER_CUSTOM =
|
const std::vector<InfoWindowProxy::CustomRegType> InfoWindowProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"new", &Wrapper::constructor, true}
|
{"new", &Wrapper::constructor, true},
|
||||||
|
{"addReplacement", &InfoWindowProxy::addReplacement, false},
|
||||||
|
{"addText", &InfoWindowProxy::addText, false},
|
||||||
|
{"setPlayer", &InfoWindowProxy::setPlayer, false},
|
||||||
|
{"toNetpackLight", &PackForClientProxy<InfoWindowProxy>::toNetpackLight, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int InfoWindowProxy::addReplacement(lua_State * L, std::shared_ptr<InfoWindow> object)
|
int InfoWindowProxy::addReplacement(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<InfoWindow> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
if(top == 1)
|
if(top == 2)
|
||||||
{
|
{
|
||||||
if(lua_isstring(L, 1))
|
if(lua_isstring(L, 2))
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
auto raw = lua_tolstring(L, 1, &len);
|
auto raw = lua_tolstring(L, 2, &len);
|
||||||
std::string text(raw, len);
|
std::string text(raw, len);
|
||||||
|
|
||||||
object->text.addReplacement(text);
|
object->text.addReplacement(text);
|
||||||
}
|
}
|
||||||
else if(lua_isnumber(L, 1))
|
else if(lua_isnumber(L, 2))
|
||||||
{
|
{
|
||||||
object->text.addReplacement(lua_tointeger(L, 1));
|
object->text.addReplacement(lua_tointeger(L, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(top >= 2)
|
else if(top >= 3)
|
||||||
{
|
{
|
||||||
if(lua_isnumber(L, 1) && lua_isnumber(L, 2))
|
if(lua_isnumber(L, 2) && lua_isnumber(L, 3))
|
||||||
object->text.addReplacement(lua_tointeger(L, 1), lua_tointeger(L, 2));
|
object->text.addReplacement(lua_tointeger(L, 2), lua_tointeger(L, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_settop(L, 0);
|
return S.retVoid();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int InfoWindowProxy::addText(lua_State * L, std::shared_ptr<InfoWindow> object)
|
int InfoWindowProxy::addText(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<InfoWindow> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
int top = lua_gettop(L);
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
if(top == 1)
|
if(top == 2)
|
||||||
{
|
{
|
||||||
if(lua_isstring(L, 1))
|
if(lua_isstring(L, 2))
|
||||||
{
|
{
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
auto raw = lua_tolstring(L, 1, &len);
|
auto raw = lua_tolstring(L, 2, &len);
|
||||||
std::string text(raw, len);
|
std::string text(raw, len);
|
||||||
|
|
||||||
object->text << text;
|
object->text << text;
|
||||||
}
|
}
|
||||||
else if(lua_isnumber(L, 1))
|
else if(lua_isnumber(L, 2))
|
||||||
{
|
{
|
||||||
object->text << (lua_tointeger(L, 1));
|
object->text << (lua_tointeger(L, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(top >= 2)
|
if(top >= 3)
|
||||||
{
|
{
|
||||||
if(lua_isnumber(L, 1) && lua_isnumber(L, 2))
|
if(lua_isnumber(L, 2) && lua_isnumber(L, 3))
|
||||||
object->text.addTxt(lua_tointeger(L, 1), lua_tointeger(L, 2));
|
object->text.addTxt(lua_tointeger(L, 2), lua_tointeger(L, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_settop(L, 0);
|
return S.retVoid();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int InfoWindowProxy::setPlayer(lua_State * L, std::shared_ptr<InfoWindow> object)
|
int InfoWindowProxy::setPlayer(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<InfoWindow> object;
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
PlayerColor value;
|
PlayerColor value;
|
||||||
|
|
||||||
if(S.tryGet(1, value))
|
if(S.tryGet(2, value))
|
||||||
object->player = value;
|
object->player = value;
|
||||||
|
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
@ -23,12 +23,11 @@ class InfoWindowProxy : public SharedWrapper<InfoWindow, InfoWindowProxy>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<InfoWindow, InfoWindowProxy>;
|
using Wrapper = SharedWrapper<InfoWindow, InfoWindowProxy>;
|
||||||
static const std::vector<typename Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int addReplacement(lua_State * L, std::shared_ptr<InfoWindow> object);
|
static int addReplacement(lua_State * L);
|
||||||
static int addText(lua_State * L, std::shared_ptr<InfoWindow> object);
|
static int addText(lua_State * L);
|
||||||
static int setPlayer(lua_State * L, std::shared_ptr<InfoWindow> object);
|
static int setPlayer(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,14 @@ template <typename Derived>
|
|||||||
class PackForClientProxy
|
class PackForClientProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static int toNetpackLight(lua_State * L, typename Derived::UDataType object)
|
static int toNetpackLight(lua_State * L)
|
||||||
{
|
{
|
||||||
|
typename Derived::UDataType object;
|
||||||
|
LuaStack S(L);
|
||||||
|
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
lua_settop(L, 0);
|
lua_settop(L, 0);
|
||||||
lua_pushlightuserdata(L, static_cast<CPackForClient *>(object.get()));
|
lua_pushlightuserdata(L, static_cast<CPackForClient *>(object.get()));
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -24,68 +24,85 @@ namespace netpacks
|
|||||||
|
|
||||||
VCMI_REGISTER_SCRIPT_API(SetResourcesProxy, "netpacks.SetResources");
|
VCMI_REGISTER_SCRIPT_API(SetResourcesProxy, "netpacks.SetResources");
|
||||||
|
|
||||||
const std::vector<SetResourcesProxy::RegType> SetResourcesProxy::REGISTER =
|
|
||||||
{
|
|
||||||
{"getAbs",&SetResourcesProxy::getAbs},
|
|
||||||
{"setAbs",&SetResourcesProxy::setAbs},
|
|
||||||
{"getPlayer",&SetResourcesProxy::getPlayer},
|
|
||||||
{"setPlayer",&SetResourcesProxy::setPlayer},
|
|
||||||
{"setAmount",&SetResourcesProxy::setAmount},
|
|
||||||
{"getAmount",&SetResourcesProxy::getAmount},
|
|
||||||
{"clear",&SetResourcesProxy::clear},
|
|
||||||
|
|
||||||
{
|
|
||||||
"toNetpackLight",
|
|
||||||
&PackForClientProxy<SetResourcesProxy>::toNetpackLight
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<SetResourcesProxy::CustomRegType> SetResourcesProxy::REGISTER_CUSTOM =
|
const std::vector<SetResourcesProxy::CustomRegType> SetResourcesProxy::REGISTER_CUSTOM =
|
||||||
{
|
{
|
||||||
{"new", &Wrapper::constructor, true}
|
{"new", &Wrapper::constructor, true},
|
||||||
|
{"getAbs", &SetResourcesProxy::getAbs, false},
|
||||||
|
{"setAbs", &SetResourcesProxy::setAbs, false},
|
||||||
|
{"getPlayer", &SetResourcesProxy::getPlayer, false},
|
||||||
|
{"setPlayer", &SetResourcesProxy::setPlayer, false},
|
||||||
|
{"setAmount", &SetResourcesProxy::setAmount, false},
|
||||||
|
{"getAmount", &SetResourcesProxy::getAmount, false},
|
||||||
|
{"clear", &SetResourcesProxy::clear, false},
|
||||||
|
{"toNetpackLight", &PackForClientProxy<SetResourcesProxy>::toNetpackLight, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int SetResourcesProxy::getAbs(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::getAbs(lua_State * L)
|
||||||
{
|
{
|
||||||
|
LuaStack S(L);
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
return LuaStack::quickRetBool(L, object->abs);
|
return LuaStack::quickRetBool(L, object->abs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetResourcesProxy::setAbs(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::setAbs(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
|
|
||||||
bool value = false;
|
bool value = false;
|
||||||
if(S.tryGet(1, value))
|
if(S.tryGet(2, value))
|
||||||
object->abs = value;
|
object->abs = value;
|
||||||
|
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetResourcesProxy::getPlayer(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::getPlayer(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
S.clear();
|
S.clear();
|
||||||
S.push(object->player);
|
S.push(object->player);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetResourcesProxy::setPlayer(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::setPlayer(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
PlayerColor value;
|
PlayerColor value;
|
||||||
|
|
||||||
if(S.tryGet(1, value))
|
if(S.tryGet(2, value))
|
||||||
object->player = value;
|
object->player = value;
|
||||||
|
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetResourcesProxy::getAmount(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::getAmount(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
Res::ERes type = Res::ERes::INVALID;
|
Res::ERes type = Res::ERes::INVALID;
|
||||||
|
|
||||||
if(!S.tryGet(1, type))
|
if(!S.tryGet(2, type))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
S.clear();
|
S.clear();
|
||||||
@ -95,13 +112,17 @@ int SetResourcesProxy::getAmount(lua_State * L, std::shared_ptr<SetResources> ob
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetResourcesProxy::setAmount(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::setAmount(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
Res::ERes type = Res::ERes::INVALID;
|
Res::ERes type = Res::ERes::INVALID;
|
||||||
|
|
||||||
if(!S.tryGet(1, type))
|
if(!S.tryGet(2, type))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
int typeIdx = static_cast<int>(type);
|
int typeIdx = static_cast<int>(type);
|
||||||
@ -111,7 +132,7 @@ int SetResourcesProxy::setAmount(lua_State * L, std::shared_ptr<SetResources> ob
|
|||||||
|
|
||||||
TQuantity amount = 0;
|
TQuantity amount = 0;
|
||||||
|
|
||||||
if(!S.tryGet(2, amount))
|
if(!S.tryGet(3, amount))
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
|
||||||
object->res.at(typeIdx) = amount;
|
object->res.at(typeIdx) = amount;
|
||||||
@ -119,9 +140,14 @@ int SetResourcesProxy::setAmount(lua_State * L, std::shared_ptr<SetResources> ob
|
|||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetResourcesProxy::clear(lua_State * L, std::shared_ptr<SetResources> object)
|
int SetResourcesProxy::clear(lua_State * L)
|
||||||
{
|
{
|
||||||
LuaStack S(L);
|
LuaStack S(L);
|
||||||
|
|
||||||
|
std::shared_ptr<SetResources> object;
|
||||||
|
if(!S.tryGet(1, object))
|
||||||
|
return S.retVoid();
|
||||||
|
|
||||||
object->res.amin(0);
|
object->res.amin(0);
|
||||||
object->res.positive();
|
object->res.positive();
|
||||||
return S.retVoid();
|
return S.retVoid();
|
||||||
|
@ -24,16 +24,15 @@ class SetResourcesProxy : public SharedWrapper<SetResources, SetResourcesProxy>
|
|||||||
public:
|
public:
|
||||||
using Wrapper = SharedWrapper<SetResources, SetResourcesProxy>;
|
using Wrapper = SharedWrapper<SetResources, SetResourcesProxy>;
|
||||||
|
|
||||||
static const std::vector<Wrapper::RegType> REGISTER;
|
|
||||||
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
static const std::vector<typename Wrapper::CustomRegType> REGISTER_CUSTOM;
|
||||||
|
|
||||||
static int getAbs(lua_State * L, std::shared_ptr<SetResources> object);
|
static int getAbs(lua_State * L);
|
||||||
static int setAbs(lua_State * L, std::shared_ptr<SetResources> object);
|
static int setAbs(lua_State * L);
|
||||||
static int getPlayer(lua_State * L, std::shared_ptr<SetResources> object);
|
static int getPlayer(lua_State * L);
|
||||||
static int setPlayer(lua_State * L, std::shared_ptr<SetResources> object);
|
static int setPlayer(lua_State * L);
|
||||||
static int getAmount(lua_State * L, std::shared_ptr<SetResources> object);
|
static int getAmount(lua_State * L);
|
||||||
static int setAmount(lua_State * L, std::shared_ptr<SetResources> object);
|
static int setAmount(lua_State * L);
|
||||||
static int clear(lua_State * L, std::shared_ptr<SetResources> object);
|
static int clear(lua_State * L);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user