diff --git a/BindingMap.h b/BindingMap.h index 793ea5e9bb..6a786c2417 100644 --- a/BindingMap.h +++ b/BindingMap.h @@ -355,7 +355,7 @@ namespace std hash_helper::result_type operator()(argument_type const& k) const { - return hash_helper::hash(k.event_id, k.instance_id, k.guid.GetRawValue()); + return hash_helper::hash(k.event_id, k.instance_id, k.guid); } }; } diff --git a/LuaEngine.cpp b/LuaEngine.cpp index b35df214dd..733a3400c5 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -958,7 +958,13 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc } luaL_unref(L, LUA_REGISTRYINDEX, functionRef); std::ostringstream oss; - oss << "regtype " << static_cast(regtype) << ", event " << event_id << ", entry " << entry << ", guid " << guid.GetRawValue() << ", instance " << instanceId; + oss << "regtype " << static_cast(regtype) << ", event " << event_id << ", entry " << entry << ", guid " << +#ifdef TRINITY + guid.ToHexString() +#else + guid.GetRawValue() +#endif + << ", instance " << instanceId; luaL_error(L, "Unknown event type (%s)", oss.str().c_str()); return 0; } diff --git a/methods/TrinityCore/ElunaQueryMethods.h b/methods/TrinityCore/ElunaQueryMethods.h index c38ee60f46..1e95c0fad6 100644 --- a/methods/TrinityCore/ElunaQueryMethods.h +++ b/methods/TrinityCore/ElunaQueryMethods.h @@ -281,26 +281,44 @@ namespace LuaQuery for (uint32 i = 0; i < col; ++i) { - E->Push(RESULT->GetFieldName(i)); + QueryResultFieldMetadata const& fieldMetadata = RESULT->GetFieldMetadata(i); - const char* str = row[i].GetCString(); - if (row[i].IsNull() || !str) + E->Push(fieldMetadata.Alias); + + if (row[i].IsNull()) E->Push(); else { - // MYSQL_TYPE_LONGLONG Interpreted as string for lua - switch (row[i].GetType()) + switch (fieldMetadata.Type) { + case DatabaseFieldTypes::UInt8: + case DatabaseFieldTypes::UInt16: + case DatabaseFieldTypes::UInt32: + E->Push(row[i].GetUInt32()); + break; case DatabaseFieldTypes::Int8: case DatabaseFieldTypes::Int16: case DatabaseFieldTypes::Int32: + E->Push(row[i].GetInt32()); + break; + case DatabaseFieldTypes::UInt64: + E->Push(row[i].GetUInt64()); + break; case DatabaseFieldTypes::Int64: + E->Push(row[i].GetInt64()); + break; case DatabaseFieldTypes::Float: case DatabaseFieldTypes::Double: - E->Push(strtod(str, NULL)); + case DatabaseFieldTypes::Decimal: + E->Push(row[i].GetDouble()); + break; + case DatabaseFieldTypes::Date: + case DatabaseFieldTypes::Time: + case DatabaseFieldTypes::Binary: + E->Push(row[i].GetCString()); break; default: - E->Push(str); + E->Push(); break; } } @@ -310,7 +328,7 @@ namespace LuaQuery lua_settop(E->L, tbl); return 1; } - + ElunaRegister QueryMethods[] = { // Getters diff --git a/methods/TrinityCore/PlayerMethods.h b/methods/TrinityCore/PlayerMethods.h index 9309579f47..7efd583bc2 100644 --- a/methods/TrinityCore/PlayerMethods.h +++ b/methods/TrinityCore/PlayerMethods.h @@ -8,6 +8,9 @@ #define PLAYERMETHODS_H #include "LuaValue.h" +#include "NPCPackets.h" +#include "PartyPackets.h" +#include /*** * Inherits all methods from: [Object], [WorldObject], [Unit] @@ -1914,7 +1917,9 @@ namespace LuaPlayer */ int SetCoinage(Eluna* E, Player* player) { - uint32 amt = E->CHECKVAL(2); + using MoneyType = std::tuple_element_t<1, boost::callable_traits::args_t>; + + MoneyType amt = E->CHECKVAL(2); player->SetMoney(amt); return 0; } @@ -2136,16 +2141,7 @@ namespace LuaPlayer { Unit* unit = E->CHECKOBJ(2); - AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->GetFaction()); - if (!ahEntry) - return 0; - - WorldPacket data(MSG_AUCTION_HELLO, 12); - data << unit->GET_GUID(); - data << uint32(ahEntry->ID); - data << uint8(1); - - player->GetSession()->SendPacket(&data); + player->GetSession()->SendAuctionHello(unit->GET_GUID(), unit); return 0; } @@ -3328,7 +3324,9 @@ namespace LuaPlayer */ int ModifyMoney(Eluna* E, Player* player) { - int32 amt = E->CHECKVAL(2); + using MoneyType = std::tuple_element_t<1, boost::callable_traits::args_t>; + + MoneyType amt = E->CHECKVAL(2); player->ModifyMoney(amt); return 1; @@ -3504,15 +3502,14 @@ namespace LuaPlayer uint32 data = E->CHECKVAL(6); std::string iconText = E->CHECKVAL(7); - WorldPacket packet(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 10); - packet << flags; - packet << x; - packet << y; - packet << icon; - packet << data; - packet << iconText; + WorldPackets::NPC::GossipPOI packet; + packet.Name = iconText; + packet.Flags = flags; + packet.Pos.Pos.Relocate(x, y); + packet.Icon = icon; + packet.Importance = data; - player->GetSession()->SendPacket(&packet); + player->SendDirectMessage(packet.Write()); return 0; } @@ -3623,18 +3620,9 @@ namespace LuaPlayer if (success) { -#ifdef CATA - WorldPacket data(SMSG_PARTY_INVITE, 10); // guess size -#else - WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size -#endif - data << uint8(1); // invited/already in group flag - data << player->GetName(); // max len 48 - data << uint32(0); // unk - data << uint8(0); // count - data << uint32(0); // unk - - invited->GetSession()->SendPacket(&data); + WorldPackets::Party::PartyInvite partyInvite; + partyInvite.Initialize(player, 0, true); + invited->SendDirectMessage(partyInvite.Write()); } E->Push(success);