From f1117fc2d86f9702917c23277763ef53a6c7c419 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Sat, 24 Jun 2017 23:22:43 +0300 Subject: [PATCH] Fix TC build --- ElunaIncludes.h | 5 +++++ ElunaQueryMethods.h | 20 +++++++++++++++++++- ElunaUtility.h | 1 + GlobalMethods.h | 10 +++++++--- PlayerMethods.h | 13 ++++++++----- UnitMethods.h | 4 ++-- WorldObjectMethods.h | 18 +++++++++--------- 7 files changed, 51 insertions(+), 20 deletions(-) diff --git a/ElunaIncludes.h b/ElunaIncludes.h index 26e6114..9b3cb49 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -47,6 +47,11 @@ #include "Battleground.h" #include "GitRevision.h" #include "SpellHistory.h" +#include "MotionMaster.h" +#include "DatabaseEnv.h" +#include "Bag.h" +#include +#include #else #include "Config/Config.h" #ifdef CMANGOS diff --git a/ElunaQueryMethods.h b/ElunaQueryMethods.h index 4634a3d..2f388c6 100644 --- a/ElunaQueryMethods.h +++ b/ElunaQueryMethods.h @@ -303,13 +303,30 @@ namespace LuaQuery const char* str = row[i].GetCString(); if (row[i].IsNull() || !str) Eluna::Push(L); + else + { + // MYSQL_TYPE_LONGLONG Interpreted as string for lua + switch (row[i].GetType()) + { + case DatabaseFieldTypes::Int8: + case DatabaseFieldTypes::Int16: + case DatabaseFieldTypes::Int32: + case DatabaseFieldTypes::Int64: + case DatabaseFieldTypes::Float: + case DatabaseFieldTypes::Double: + Eluna::Push(L, strtod(str, NULL)); + break; + default: + Eluna::Push(L, str); + break; + } + } #else Eluna::Push(L, names[i]); const char* str = row[i].GetString(); if (row[i].IsNULL() || !str) Eluna::Push(L); -#endif else { // MYSQL_TYPE_LONGLONG Interpreted as string for lua @@ -328,6 +345,7 @@ namespace LuaQuery break; } } +#endif lua_rawset(L, tbl); } diff --git a/ElunaUtility.h b/ElunaUtility.h index c651580..1bc277e 100644 --- a/ElunaUtility.h +++ b/ElunaUtility.h @@ -16,6 +16,7 @@ #include "ObjectGuid.h" #ifdef TRINITY #include "QueryResult.h" +#include "Log.h" #ifdef CATA #include "Object.h" #endif diff --git a/GlobalMethods.h b/GlobalMethods.h index d09fd90..a87cda3 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -1709,7 +1709,7 @@ namespace LuaGlobalFunctions GameObject* object = new GameObject; uint32 guidLow = map->GenerateLowGuid(); - G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(o, 0.f, 0.f); + QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); if (!object->Create(guidLow, objectInfo->entry, map, phase, Position(x, y, z, o), rot, 0, GO_STATE_READY)) { delete object; @@ -1842,12 +1842,16 @@ namespace LuaGlobalFunctions if (!items || items->Empty()) return 0; - VendorItemList const itemlist = items->m_items; - for (VendorItemList::const_iterator itr = itemlist.begin(); itr != itemlist.end(); ++itr) + auto const & itemlist = items->m_items; + for (auto itr = itemlist.begin(); itr != itemlist.end(); ++itr) #ifdef CATA eObjectMgr->RemoveVendorItem(entry, (*itr)->item, 1); +#else +#ifdef TRINITY + eObjectMgr->RemoveVendorItem(entry, itr->item); #else eObjectMgr->RemoveVendorItem(entry, (*itr)->item); +#endif #endif return 0; } diff --git a/PlayerMethods.h b/PlayerMethods.h index 5908f73..745564a 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -2882,7 +2882,10 @@ namespace LuaPlayer #ifdef TRINITY // check item starting quest (it can work incorrectly if added without item in inventory) ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore(); - ItemTemplateContainer::const_iterator result = find_if(itc->begin(), itc->end(), Finder(entry, &ItemTemplate::StartQuest)); + ItemTemplateContainer::const_iterator result = std::find_if(itc->begin(), itc->end(), [quest](ItemTemplateContainer::value_type const& value) + { + return value.second.StartQuest == quest->GetQuestId(); + }); if (result != itc->end()) return 0; @@ -3319,9 +3322,7 @@ namespace LuaPlayer uint32 itemId = Eluna::CHECKVAL(L, 2); uint32 itemCount = Eluna::CHECKVAL(L, 3, 1); -#ifndef TRINITY - Eluna::Push(L, player->StoreNewItemInInventorySlot(itemId, itemCount)); -#else +#ifdef TRINITY uint32 noSpaceForCount = 0; ItemPosCountVec dest; InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, itemCount, &noSpaceForCount); @@ -3331,10 +3332,12 @@ namespace LuaPlayer if (itemCount == 0 || dest.empty()) return 1; - Item* item = player->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + Item* item = player->StoreNewItem(dest, itemId, true, GenerateItemRandomPropertyId(itemId)); if (item) player->SendNewItem(item, itemCount, true, false); Eluna::Push(L, item); +#else + Eluna::Push(L, player->StoreNewItemInInventorySlot(itemId, itemCount)); #endif return 1; } diff --git a/UnitMethods.h b/UnitMethods.h index 2150636..6b4905c 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -1200,7 +1200,7 @@ namespace LuaUnit #else Trinity::AnyFriendlyUnitInObjectRangeCheck checker(unit, unit, range); Trinity::UnitListSearcher searcher(unit, list, checker); - unit->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(unit, searcher, range); #endif ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID()); list.remove_if(guidCheck); @@ -1237,7 +1237,7 @@ namespace LuaUnit #else Trinity::AnyUnfriendlyUnitInObjectRangeCheck checker(unit, unit, range); Trinity::UnitListSearcher searcher(unit, list, checker); - unit->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(unit, searcher, range); #endif ElunaUtil::ObjectGUIDCheck guidCheck(unit->GET_GUID()); list.remove_if(guidCheck); diff --git a/WorldObjectMethods.h b/WorldObjectMethods.h index 50c3cfc..aad86f8 100644 --- a/WorldObjectMethods.h +++ b/WorldObjectMethods.h @@ -188,7 +188,7 @@ namespace LuaWorldObject Cell::VisitWorldObjects(obj, searcher, range); #else Trinity::UnitLastSearcher searcher(obj, target, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -217,7 +217,7 @@ namespace LuaWorldObject Cell::VisitGridObjects(obj, searcher, range); #else Trinity::GameObjectLastSearcher searcher(obj, target, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -248,7 +248,7 @@ namespace LuaWorldObject Cell::VisitGridObjects(obj, searcher, range); #else Trinity::CreatureLastSearcher searcher(obj, target, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -277,7 +277,7 @@ namespace LuaWorldObject Cell::VisitWorldObjects(obj, searcher, range); #else Trinity::PlayerListSearcher searcher(obj, list, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -318,7 +318,7 @@ namespace LuaWorldObject Cell::VisitGridObjects(obj, searcher, range); #else Trinity::CreatureListSearcher searcher(obj, list, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -357,7 +357,7 @@ namespace LuaWorldObject Cell::VisitGridObjects(obj, searcher, range); #else Trinity::GameObjectListSearcher searcher(obj, list, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -404,7 +404,7 @@ namespace LuaWorldObject Cell::VisitAllObjects(obj, searcher, range); #else Trinity::WorldObjectLastSearcher searcher(obj, target, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif Eluna::Push(L, target); @@ -441,7 +441,7 @@ namespace LuaWorldObject Cell::VisitAllObjects(obj, searcher, range); #else Trinity::WorldObjectListSearcher searcher(obj, list, checker); - obj->VisitNearbyObject(range, searcher); + Cell::VisitAllObjects(obj, searcher, range); #endif lua_createtable(L, list.size(), 0); @@ -682,7 +682,7 @@ namespace LuaWorldObject #ifndef TRINITY Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, respawnDelay)); #else - G3D::Quat rot = G3D::Matrix3::fromEulerAnglesZYX(o, 0.f, 0.f); + QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, respawnDelay)); #endif return 1;