mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna Fix checking of objects with varying types
This commit is contained in:
@@ -676,47 +676,35 @@ template<> uint64 Eluna::CHECKVAL<uint64>(lua_State* L, int narg)
|
|||||||
// return static_cast<size_t>(*(Eluna::CHECKOBJ<uint64>(L, narg, true)));
|
// return static_cast<size_t>(*(Eluna::CHECKOBJ<uint64>(L, narg, true)));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#define TEST_OBJ(T, O, R, F)\
|
template<> Object* Eluna::CHECKOBJ<Object>(lua_State* L, int narg, bool error)
|
||||||
{\
|
{
|
||||||
if (!O || !O->F())\
|
Object* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
||||||
{\
|
if (!obj)
|
||||||
if (R)\
|
obj = CHECKOBJ<Item>(L, narg, false);
|
||||||
{\
|
if (!obj)
|
||||||
std::string errmsg(ElunaTemplate<T>::tname);\
|
obj = ElunaTemplate<Object>::Check(L, narg, false);
|
||||||
errmsg += " expected";\
|
return obj;
|
||||||
luaL_argerror(L, narg, errmsg.c_str());\
|
}
|
||||||
}\
|
template<> WorldObject* Eluna::CHECKOBJ<WorldObject>(lua_State* L, int narg, bool error)
|
||||||
return NULL;\
|
{
|
||||||
}\
|
WorldObject* obj = CHECKOBJ<Unit>(L, narg, false);
|
||||||
return O->F();\
|
if (!obj)
|
||||||
|
obj = CHECKOBJ<GameObject>(L, narg, false);
|
||||||
|
if (!obj)
|
||||||
|
obj = CHECKOBJ<Corpse>(L, narg, false);
|
||||||
|
if (!obj)
|
||||||
|
obj = ElunaTemplate<WorldObject>::Check(L, narg, false);
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error)
|
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error)
|
||||||
{
|
{
|
||||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
Unit* obj = CHECKOBJ<Player>(L, narg, false);
|
||||||
TEST_OBJ(Unit, obj, error, ToUnit);
|
if (!obj)
|
||||||
|
obj = CHECKOBJ<Creature>(L, narg, false);
|
||||||
|
if (!obj)
|
||||||
|
obj = ElunaTemplate<Unit>::Check(L, narg, false);
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
template<> Player* Eluna::CHECKOBJ<Player>(lua_State* L, int narg, bool error)
|
|
||||||
{
|
|
||||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
|
||||||
TEST_OBJ(Player, obj, error, ToPlayer);
|
|
||||||
}
|
|
||||||
template<> Creature* Eluna::CHECKOBJ<Creature>(lua_State* L, int narg, bool error)
|
|
||||||
{
|
|
||||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
|
||||||
TEST_OBJ(Creature, obj, error, ToCreature);
|
|
||||||
}
|
|
||||||
template<> GameObject* Eluna::CHECKOBJ<GameObject>(lua_State* L, int narg, bool error)
|
|
||||||
{
|
|
||||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
|
||||||
TEST_OBJ(GameObject, obj, error, ToGameObject);
|
|
||||||
}
|
|
||||||
template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error)
|
|
||||||
{
|
|
||||||
WorldObject* obj = CHECKOBJ<WorldObject>(L, narg, false);
|
|
||||||
TEST_OBJ(Corpse, obj, error, ToCorpse);
|
|
||||||
}
|
|
||||||
#undef TEST_OBJ
|
|
||||||
|
|
||||||
template<> ElunaObject* Eluna::CHECKOBJ<ElunaObject>(lua_State* L, int narg, bool error)
|
template<> ElunaObject* Eluna::CHECKOBJ<ElunaObject>(lua_State* L, int narg, bool error)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -384,10 +384,8 @@ public:
|
|||||||
void OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
|
void OnBGDestroy(BattleGround* bg, BattleGroundTypeId bgId, uint32 instanceId);
|
||||||
};
|
};
|
||||||
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error);
|
template<> Unit* Eluna::CHECKOBJ<Unit>(lua_State* L, int narg, bool error);
|
||||||
template<> Player* Eluna::CHECKOBJ<Player>(lua_State* L, int narg, bool error);
|
template<> Object* Eluna::CHECKOBJ<Object>(lua_State* L, int narg, bool error);
|
||||||
template<> Creature* Eluna::CHECKOBJ<Creature>(lua_State* L, int narg, bool error);
|
template<> WorldObject* Eluna::CHECKOBJ<WorldObject>(lua_State* L, int narg, bool error);
|
||||||
template<> GameObject* Eluna::CHECKOBJ<GameObject>(lua_State* L, int narg, bool error);
|
|
||||||
template<> Corpse* Eluna::CHECKOBJ<Corpse>(lua_State* L, int narg, bool error);
|
|
||||||
template<> ElunaObject* Eluna::CHECKOBJ<ElunaObject>(lua_State* L, int narg, bool error);
|
template<> ElunaObject* Eluna::CHECKOBJ<ElunaObject>(lua_State* L, int narg, bool error);
|
||||||
|
|
||||||
#define sEluna Eluna::GEluna
|
#define sEluna Eluna::GEluna
|
||||||
|
|||||||
Reference in New Issue
Block a user