From 3aa6d0544b49c20ab32dc9ed21323023dc149269 Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Thu, 4 Jun 2015 12:30:43 +0300 Subject: [PATCH] Fix TC compile --- CreatureMethods.h | 15 +++++++++++++++ ElunaIncludes.h | 1 + GlobalMethods.h | 28 +++++++++++++++++++++++---- LuaFunctions.cpp | 1 - PlayerMethods.h | 49 +++++++++++++++++++++++++++++------------------ 5 files changed, 70 insertions(+), 24 deletions(-) diff --git a/CreatureMethods.h b/CreatureMethods.h index 1c33266..e94d074 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -279,7 +279,14 @@ namespace LuaCreature { uint32 spell = Eluna::CHECKVAL(L, 2); +#ifdef TRINITY + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) + Eluna::Push(L, info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); + else + Eluna::Push(L, false); +#else Eluna::Push(L, creature->HasCategoryCooldown(spell)); +#endif return 1; } @@ -328,7 +335,11 @@ namespace LuaCreature { uint32 spellId = Eluna::CHECKVAL(L, 2); +#ifdef TRINITY + Eluna::Push(L, creature->GetSpellHistory()->HasCooldown(spellId)); +#else Eluna::Push(L, creature->HasSpellCooldown(spellId)); +#endif return 1; } @@ -565,7 +576,11 @@ namespace LuaCreature { uint32 spell = Eluna::CHECKVAL(L, 2); +#ifdef TRINITY + Eluna::Push(L, creature->GetSpellHistory()->GetRemainingCooldown(spell)); +#else Eluna::Push(L, creature->GetCreatureSpellCooldownDelay(spell)); +#endif return 1; } diff --git a/ElunaIncludes.h b/ElunaIncludes.h index 3beab98..09f8da1 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -45,6 +45,7 @@ #include "WeatherMgr.h" #include "Battleground.h" #include "revision.h" +#include "SpellHistory.h" #else #include "Config/Config.h" #include "AggressorAI.h" diff --git a/GlobalMethods.h b/GlobalMethods.h index ef9d9e7..4fa2944 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -2093,6 +2093,16 @@ namespace LuaGlobalFunctions // Stack: {nodes}, mountA, mountH, price, pathid, {nodes}, node, key, value } TaxiPathNodeEntry entry; +#ifdef TRINITY + // mandatory + entry.MapID = Eluna::CHECKVAL(L, start); + entry.LocX = Eluna::CHECKVAL(L, start + 1); + entry.LocY = Eluna::CHECKVAL(L, start + 2); + entry.LocZ = Eluna::CHECKVAL(L, start + 3); + // optional + entry.Flags = Eluna::CHECKVAL(L, start + 4, 0); + entry.Delay = Eluna::CHECKVAL(L, start + 5, 0); +#else // mandatory entry.mapid = Eluna::CHECKVAL(L, start); entry.x = Eluna::CHECKVAL(L, start + 1); @@ -2101,6 +2111,7 @@ namespace LuaGlobalFunctions // optional entry.actionFlag = Eluna::CHECKVAL(L, start + 4, 0); entry.delay = Eluna::CHECKVAL(L, start + 5, 0); +#endif nodes.push_back(entry); @@ -2130,17 +2141,26 @@ namespace LuaGlobalFunctions for (std::list::iterator it = nodes.begin(); it != nodes.end(); ++it) { TaxiPathNodeEntry& entry = *it; - entry.path = pathId; TaxiNodesEntry* nodeEntry = new TaxiNodesEntry(); +#ifdef TRINITY + entry.PathID = pathId; + nodeEntry->ID = index; + nodeEntry->map_id = entry.MapID; + nodeEntry->x = entry.LocX; + nodeEntry->y = entry.LocY; + nodeEntry->z = entry.LocZ; +#else + entry.path = pathId; nodeEntry->ID = index; nodeEntry->map_id = entry.mapid; - nodeEntry->MountCreatureID[0] = mountH; - nodeEntry->MountCreatureID[1] = mountA; nodeEntry->x = entry.x; nodeEntry->y = entry.y; nodeEntry->z = entry.z; +#endif + nodeEntry->MountCreatureID[0] = mountH; + nodeEntry->MountCreatureID[1] = mountA; sTaxiNodesStore.SetEntry(nodeId, nodeEntry); - entry.index = nodeId++; + entry.NodeIndex = nodeId++; sTaxiPathNodesByPath[pathId].set(index++, new TaxiPathNodeEntry(entry)); } if (startNode >= nodeId) diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index 7cce15d..303bba4 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -483,7 +483,6 @@ ElunaRegister PlayerMethods[] = { "GetSkillPermBonusValue", &LuaPlayer::GetSkillPermBonusValue }, // :GetSkillPermBonusValue(skill) - Returns current permanent bonus { "GetSkillTempBonusValue", &LuaPlayer::GetSkillTempBonusValue }, // :GetSkillTempBonusValue(skill) - Returns current temp bonus { "GetReputationRank", &LuaPlayer::GetReputationRank }, // :GetReputationRank(faction) - Returns the reputation rank with given faction - { "GetSpellCooldowns", &LuaPlayer::GetSpellCooldowns }, // :GetSpellCooldowns() - Gets a table where spellIDs are the keys and values are cooldowns { "GetDrunkValue", &LuaPlayer::GetDrunkValue }, // :GetDrunkValue() - Returns the current drunkness value { "GetBattlegroundId", &LuaPlayer::GetBattlegroundId }, // :GetBattlegroundId() - Returns the player's current battleground ID { "GetBattlegroundTypeId", &LuaPlayer::GetBattlegroundTypeId }, // :GetBattlegroundTypeId() - Returns the player's current battleground type ID diff --git a/PlayerMethods.h b/PlayerMethods.h index fcb8745..9344c5d 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -199,7 +199,11 @@ namespace LuaPlayer { uint32 spellId = Eluna::CHECKVAL(L, 2); +#ifdef TRINITY + Eluna::Push(L, player->GetSpellHistory()->HasCooldown(spellId)); +#else Eluna::Push(L, player->HasSpellCooldown(spellId)); +#endif return 1; } @@ -783,7 +787,11 @@ namespace LuaPlayer { uint32 spellId = Eluna::CHECKVAL(L, 2); +#ifdef TRINITY + Eluna::Push(L, player->GetSpellHistory()->GetRemainingCooldown(spellId)); +#else Eluna::Push(L, uint32(player->GetSpellCooldownDelay(spellId))); +#endif return 1; } @@ -938,24 +946,6 @@ namespace LuaPlayer return 1; } - int GetSpellCooldowns(Eluna* /*E*/, lua_State* L, Player* player) - { - lua_newtable(L); - int tbl = lua_gettop(L); - uint32 i = 0; - - for (SpellCooldowns::const_iterator it = player->GetSpellCooldownMap().begin(); it != player->GetSpellCooldownMap().end(); ++it) - { - ++i; - Eluna::Push(L, it->first); - Eluna::Push(L, uint32(it->second.end)); - lua_settable(L, tbl); - } - - lua_settop(L, tbl); - return 1; - } - int GetSkillTempBonusValue(Eluna* /*E*/, lua_State* L, Player* player) { uint32 skill = Eluna::CHECKVAL(L, 2); @@ -3133,7 +3123,11 @@ namespace LuaPlayer { uint32 spellId = Eluna::CHECKVAL(L, 2); bool update = Eluna::CHECKVAL(L, 3, true); +#ifdef TRINITY + player->GetSpellHistory()->ResetCooldown(spellId, update); +#else player->RemoveSpellCooldown(spellId, update); +#endif return 0; } @@ -3141,7 +3135,16 @@ namespace LuaPlayer { uint32 category = Eluna::CHECKVAL(L, 2); bool update = Eluna::CHECKVAL(L, 3, true); + +#ifdef TRINITY + player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); + return spellInfo && spellInfo->GetCategory() == 1248; + }, true); +#else player->RemoveSpellCategoryCooldown(category, update); +#endif return 0; } @@ -3150,7 +3153,11 @@ namespace LuaPlayer */ int ResetAllCooldowns(Eluna* /*E*/, lua_State* /*L*/, Player* player) { +#ifdef TRINITY + player->GetSpellHistory()->ResetAllCooldowns(); +#else player->RemoveAllSpellCooldown(); +#endif return 0; } @@ -3158,8 +3165,12 @@ namespace LuaPlayer { uint32 spellId = Eluna::CHECKVAL(L, 2); Unit* target = Eluna::CHECKOBJ(L, 3); - + +#ifdef TRINITY + target->GetSpellHistory()->ResetCooldown(spellId, true); +#else player->SendClearCooldown(spellId, target); +#endif return 0; } /**