mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Cleaned up lua glue macro a bit
This commit is contained in:
parent
7b23c8dc75
commit
20fc585b5e
@ -8,14 +8,15 @@ class Client;
|
||||
|
||||
class Lua_Client : public Lua_Mob
|
||||
{
|
||||
typedef Client NativeType;
|
||||
public:
|
||||
Lua_Client() { d_ = nullptr; }
|
||||
Lua_Client(Client *d) { d_ = d; }
|
||||
Lua_Client(NativeType *d) { d_ = d; }
|
||||
virtual ~Lua_Client() { }
|
||||
|
||||
operator Client* () {
|
||||
operator NativeType* () {
|
||||
if(d_) {
|
||||
return reinterpret_cast<Client*>(d_);
|
||||
return reinterpret_cast<NativeType*>(d_);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@ -15,62 +15,62 @@ bool Lua_Entity::Valid() {
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsClient() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsClient();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsNPC() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsNPC();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsMob() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsMob();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsMerc() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsMerc();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsCorpse() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsCorpse();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsPlayerCorpse() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsPlayerCorpse();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsNPCCorpse() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsNPCCorpse();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsObject() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsObject();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsDoor() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsDoor();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsTrap() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsTrap();
|
||||
}
|
||||
|
||||
bool Lua_Entity::IsBeacon() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->IsBeacon();
|
||||
}
|
||||
|
||||
int Lua_Entity::GetID() {
|
||||
Lua_Safe_Call_Bool(Entity);
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->GetID();
|
||||
}
|
||||
|
||||
|
||||
@ -14,26 +14,27 @@ class Lua_Mob;
|
||||
//class Lua_Item;
|
||||
|
||||
//TODO: Remove the error checking by a flag since this adds significant overhead to each c call
|
||||
#define Lua_Safe_Call_Void(Type) if(!d_) { return; } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Bool(Type) if(!d_) { return false; } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Int(Type) if(!d_) { return 0; } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Real(Type) if(!d_) { return 0.0; } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_String(Type) if(!d_) { return ""; } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Entity(Type) if(!d_) { return Lua_Entity(); } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Mob(Type) if(!d_) { return Lua_Mob(); } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_NPC(Type) if(!d_) { return Lua_NPC(); } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Client(Type) if(!d_) { return Lua_Client(); } Type *self = reinterpret_cast<Type*>(d_);
|
||||
#define Lua_Safe_Call_Void() if(!d_) { return; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Bool() if(!d_) { return false; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Int() if(!d_) { return 0; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Real() if(!d_) { return 0.0; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_String() if(!d_) { return ""; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Entity() if(!d_) { return Lua_Entity(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Mob() if(!d_) { return Lua_Mob(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_NPC() if(!d_) { return Lua_NPC(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Client() if(!d_) { return Lua_Client(); } NativeType *self = reinterpret_cast<Type*>(d_)
|
||||
|
||||
class Lua_Entity
|
||||
{
|
||||
typedef Entity NativeType;
|
||||
public:
|
||||
Lua_Entity() { d_ = nullptr; }
|
||||
Lua_Entity(Entity *d) : d_(d) { }
|
||||
Lua_Entity(NativeType *d) : d_(d) { }
|
||||
virtual ~Lua_Entity() { }
|
||||
|
||||
operator Entity* () {
|
||||
operator NativeType* () {
|
||||
if(d_) {
|
||||
return reinterpret_cast<Entity*>(d_);
|
||||
return reinterpret_cast<NativeType*>(d_);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
626
zone/lua_mob.cpp
626
zone/lua_mob.cpp
File diff suppressed because it is too large
Load Diff
@ -8,14 +8,15 @@ class Mob;
|
||||
|
||||
class Lua_Mob : public Lua_Entity
|
||||
{
|
||||
typedef Mob NativeType;
|
||||
public:
|
||||
Lua_Mob() { d_ = nullptr; }
|
||||
Lua_Mob(Mob *d) { d_ = d; }
|
||||
Lua_Mob(NativeType *d) { d_ = d; }
|
||||
virtual ~Lua_Mob() { }
|
||||
|
||||
operator Mob* () {
|
||||
operator NativeType* () {
|
||||
if(d_) {
|
||||
return reinterpret_cast<Mob*>(d_);
|
||||
return reinterpret_cast<NativeType*>(d_);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@ -8,14 +8,15 @@ class NPC;
|
||||
|
||||
class Lua_NPC : public Lua_Mob
|
||||
{
|
||||
typedef NPC NativeType;
|
||||
public:
|
||||
Lua_NPC() { d_ = nullptr; }
|
||||
Lua_NPC(NPC *d) { d_ = d; }
|
||||
Lua_NPC(NativeType *d) { d_ = d; }
|
||||
virtual ~Lua_NPC() { }
|
||||
|
||||
operator NPC* () {
|
||||
operator NativeType* () {
|
||||
if(d_) {
|
||||
return reinterpret_cast<NPC*>(d_);
|
||||
return reinterpret_cast<NativeType*>(d_);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user