Update eluna

This commit is contained in:
Rochet2
2014-04-07 01:48:45 +03:00
committed by Foereaper
parent 46a5f4d033
commit 7ed94d3e7a
6 changed files with 49 additions and 58 deletions

View File

@@ -222,6 +222,19 @@ namespace LuaGroup
return 0;
}
int SetTargetIcon(lua_State* L, Group* group)
{
uint8 icon = sEluna->CHECKVAL<uint8>(L, 2);
uint64 target = sEluna->CHECKVAL<uint64>(L, 3);
uint64 setter = sEluna->CHECKVAL<uint64>(L, 4, 0);
if (icon >= TARGETICONCOUNT)
return luaL_argerror(L, 2, "valid target icon expected");
group->SetTargetIcon(icon, setter, target);
return 0;
}
/*int ConvertToLFG(lua_State* L, Group* group) // TODO: Implementation
{
group->ConvertToLFG();

View File

@@ -423,7 +423,7 @@ template<> float Eluna::CHECKVAL<float>(lua_State* L, int narg)
}
template<> float Eluna::CHECKVAL<float>(lua_State* L, int narg, float def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optnumber(L, narg, def);
}
@@ -433,7 +433,7 @@ template<> double Eluna::CHECKVAL<double>(lua_State* L, int narg)
}
template<> double Eluna::CHECKVAL<double>(lua_State* L, int narg, double def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optnumber(L, narg, def);
}
@@ -443,7 +443,7 @@ template<> int8 Eluna::CHECKVAL<int8>(lua_State* L, int narg)
}
template<> int8 Eluna::CHECKVAL<int8>(lua_State* L, int narg, int8 def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optint(L, narg, def);
}
@@ -453,7 +453,7 @@ template<> uint8 Eluna::CHECKVAL<uint8>(lua_State* L, int narg)
}
template<> uint8 Eluna::CHECKVAL<uint8>(lua_State* L, int narg, uint8 def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optunsigned(L, narg, def);
}
@@ -463,7 +463,7 @@ template<> int16 Eluna::CHECKVAL<int16>(lua_State* L, int narg)
}
template<> int16 Eluna::CHECKVAL<int16>(lua_State* L, int narg, int16 def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optint(L, narg, def);
}
@@ -473,7 +473,7 @@ template<> uint16 Eluna::CHECKVAL<uint16>(lua_State* L, int narg)
}
template<> uint16 Eluna::CHECKVAL<uint16>(lua_State* L, int narg, uint16 def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optunsigned(L, narg, def);
}
@@ -483,7 +483,7 @@ template<> uint32 Eluna::CHECKVAL<uint32>(lua_State* L, int narg)
}
template<> uint32 Eluna::CHECKVAL<uint32>(lua_State* L, int narg, uint32 def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optunsigned(L, narg, def);
}
@@ -493,7 +493,7 @@ template<> int32 Eluna::CHECKVAL<int32>(lua_State* L, int narg)
}
template<> int32 Eluna::CHECKVAL<int32>(lua_State* L, int narg, int32 def)
{
if (lua_isnoneornil(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isnumber(L, narg))
return def;
return luaL_optlong(L, narg, def);
}
@@ -503,7 +503,7 @@ template<> const char* Eluna::CHECKVAL<const char*>(lua_State* L, int narg)
}
template<> const char* Eluna::CHECKVAL<const char*>(lua_State* L, int narg, const char* def)
{
if (lua_isnoneornil(L, narg) || !lua_isstring(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isstring(L, narg))
return def;
return luaL_optstring(L, narg, def);
}
@@ -513,7 +513,7 @@ template<> std::string Eluna::CHECKVAL<std::string>(lua_State* L, int narg)
}
template<> std::string Eluna::CHECKVAL<std::string>(lua_State* L, int narg, std::string def)
{
if (lua_isnoneornil(L, narg) || !lua_isstring(L, narg) || lua_isnumber(L, narg))
if (lua_isnoneornil(L, narg) || !lua_isstring(L, narg))
return def;
return luaL_optstring(L, narg, def.c_str());
}

View File

@@ -144,7 +144,6 @@ ElunaRegister<Object> ObjectMethods[] =
{ "RemoveFlag", &LuaObject::RemoveFlag }, // :RemoveFlag(index, flag)
{ "RemoveUInt64Value", &LuaObject::RemoveUInt64Value }, // :RemoveUInt64Value(index, value)
{ "AddUInt64Value", &LuaObject::AddUInt64Value }, // :AddUInt64Value(index, value)
{ "ApplyModUInt64Value", &LuaObject::ApplyModUInt64Value }, // :ApplyModUInt64Value(index, value, apply)
{ NULL, NULL },
};
@@ -980,6 +979,7 @@ ElunaRegister<Group> GroupMethods[] =
// Setters
{ "SetLeader", &LuaGroup::ChangeLeader }, // :SetLeader(Player) - Sets the player as the new leader
{ "SetMembersGroup", &LuaGroup::ChangeMembersGroup }, // :ChangeMembersGroup(player, subGroup) - Changes the member's subgroup
{ "SetTargetIcon", &LuaGroup::SetTargetIcon }, // :SetTargetIcon(icon, targetguid[, setterguid]) - Sets target's icon for group. target 0 to clear.
// Boolean
{ "IsLeader", &LuaGroup::IsLeader }, // :IsLeader(GUID)

View File

@@ -241,14 +241,5 @@ namespace LuaObject
obj->AddUInt64Value(index, value);
return 0;
}
int ApplyModUInt64Value(lua_State* L, Object* obj)
{
uint16 index = sEluna->CHECKVAL<uint16>(L, 2);
int32 value = sEluna->CHECKVAL<int32>(L, 3);
bool apply = sEluna->CHECKVAL<bool>(L, 4);
obj->ApplyModUInt64Value(index, value, apply);
return 0;
}
};
#endif

View File

@@ -2028,17 +2028,17 @@ namespace LuaPlayer
int SendAreaTriggerMessage(lua_State* L, Player* player)
{
const char* msg = sEluna->CHECKVAL<const char*>(L, 2);
if (std::string(msg).length() > 0)
player->GetSession()->SendAreaTriggerMessage(msg);
std::string msg = sEluna->CHECKVAL<std::string>(L, 2);
if (msg.length() > 0)
player->GetSession()->SendAreaTriggerMessage(msg.c_str());
return 0;
}
int SendNotification(lua_State* L, Player* player)
{
const char* msg = sEluna->CHECKVAL<const char*>(L, 2);
if (std::string(msg).length() > 0)
player->GetSession()->SendNotification(msg);
std::string msg = sEluna->CHECKVAL<std::string>(L, 2);
if (msg.length() > 0)
player->GetSession()->SendNotification(msg.c_str());
return 0;
}
@@ -2069,20 +2069,16 @@ namespace LuaPlayer
std::string fullmsg = prefix + "\t" + message;
// Needs a custom built packet since TC doesnt send guid
WorldPacket* data = new WorldPacket();
uint32 messageLength = (uint32)strlen(fullmsg.c_str()) + 1;
data->Initialize(SMSG_MESSAGECHAT, 100);
*data << (uint8)channel;
*data << LANG_ADDON;
*data << player->GetGUID();
*data << uint32(0);
*data << player->GetGUID();
*data << messageLength;
*data << fullmsg;
*data << uint8(0);
player->GetSession()->SendPacket(data);
WorldPacket data(SMSG_MESSAGECHAT, 100);
data << uint8(channel);
data << int32(LANG_ADDON);
data << uint64(player->GetGUID());
data << uint32(0);
data << uint64(receiver->GetGUID());
data << uint32(fullmsg.length() + 1);
data << fullmsg;
data << uint8(0);
receiver->GetSession()->SendPacket(&data);
return 0;
}

View File

@@ -1242,26 +1242,17 @@ namespace LuaUnit
{
uint8 type = sEluna->CHECKVAL<uint8>(L, 2);
uint32 lang = sEluna->CHECKVAL<uint32>(L, 3);
const char* msg = sEluna->CHECKVAL<const char*>(L, 4);
std::string msg = sEluna->CHECKVAL<std::string>(L, 4);
Player* target = sEluna->CHECKOBJ<Player>(L, 5);
if (type == CHAT_MSG_CHANNEL)
return 0;
WorldPacket* data = new WorldPacket();
uint32 messageLength = (uint32)strlen(msg) + 1;
data->Initialize(SMSG_MESSAGECHAT, 100);
*data << (uint8)type;
*data << lang;
*data << unit->GetGUIDLow();
*data << uint32(0);
*data << unit->GetGUIDLow();
*data << messageLength;
*data << msg;
if (unit->ToPlayer() && type != CHAT_MSG_WHISPER_INFORM && type != CHAT_MSG_DND && type != CHAT_MSG_AFK)
*data << uint8(unit->ToPlayer()->GetChatTag());
else
*data << uint8(0);
target->GetSession()->SendPacket(data);
if (type >= MAX_CHAT_MSG_TYPE)
return luaL_argerror(L, 2, "valid ChatMsg expected");
if (lang >= LANGUAGES_COUNT)
return luaL_argerror(L, 3, "valid Language expected");
WorldPacket data;
ChatHandler::BuildChatPacket(data, ChatMsg(type), Language(lang), unit, target, msg);
target->GetSession()->SendPacket(&data);
return 0;
}