Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/contrib/extractor/libmpq/common.cpp b/contrib/extractor/libmpq/common.cpp
- index 711dfb0..42d8c65 100644
- --- a/contrib/extractor/libmpq/common.cpp
- +++ b/contrib/extractor/libmpq/common.cpp
- @@ -38,7 +38,7 @@ unsigned int libmpq_lseek(mpq_archive* mpq_a, unsigned int pos)
- {
- #ifdef WIN32
- return (unsigned int)_lseeki64(mpq_a->fd, pos, SEEK_SET);
- -#elif defined(__APPLE__)
- +#elif defined(__APPLE__) | defined(__FreeBSD__)
- return (unsigned int)lseek(mpq_a->fd, pos, SEEK_SET);
- #else
- return (unsigned int)lseek64(mpq_a->fd, pos, SEEK_SET);
- diff --git a/contrib/vmap_extractor/vmapextract/vmapexport.cpp b/contrib/vmap_extractor/vmapextract/vmapexport.cpp
- index 905daf7..2da289b 100644
- --- a/contrib/vmap_extractor/vmapextract/vmapexport.cpp
- +++ b/contrib/vmap_extractor/vmapextract/vmapexport.cpp
- @@ -476,7 +476,7 @@ int main(int argc, char** argv)
- //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- // Create the working directory
- if (mkdir(szWorkDirWmo
- -#ifdef __linux__
- +#if defined(__linux__) || defined(__FreeBSD__)
- , 0711
- #endif
- ))
- diff --git a/dep/ACE_wrappers/configure b/dep/ACE_wrappers/configure
- index f122865..16f09b4 100755
- --- a/dep/ACE_wrappers/configure
- +++ b/dep/ACE_wrappers/configure
- @@ -6331,7 +6331,6 @@ if test "${enable_lib_streams+set}" = set; then :
- fi
- -
- # Check whether --enable-lib-svcconf was given.
- if test "${enable_lib_svcconf+set}" = set; then :
- enableval=$enable_lib_svcconf;
- @@ -10446,7 +10445,7 @@ else
- PRELINK=""
- fi
- -
- +ace_cv_new_throws_bad_alloc_exception=no
- # Check whether --enable-repo was given.
- if test "${enable_repo+set}" = set; then :
- enableval=$enable_repo;
- diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt
- index 15c5a81..396103f 100644
- --- a/dep/CMakeLists.txt
- +++ b/dep/CMakeLists.txt
- @@ -20,3 +20,4 @@ endif()
- add_subdirectory(recastnavigation)
- add_subdirectory(src)
- +add_subdirectory(lualib)
- \ No newline at end of file
- diff --git a/dep/include/g3dlite/G3D/System.h b/dep/include/g3dlite/G3D/System.h
- index 3183064..0fb8704 100755
- --- a/dep/include/g3dlite/G3D/System.h
- +++ b/dep/include/g3dlite/G3D/System.h
- @@ -20,6 +20,10 @@
- #include "G3D/BinaryFormat.h"
- #include <string>
- +#if defined(__FreeBSD__)
- +# include <sys/_timeval.h>
- +#endif
- +
- #ifdef G3D_OSX
- # include <CoreServices/CoreServices.h>
- #endif
- diff --git a/dep/src/g3dlite/uint128.cpp b/dep/src/g3dlite/uint128.cpp
- index 1f596fc..2fd58a3 100644
- --- a/dep/src/g3dlite/uint128.cpp
- +++ b/dep/src/g3dlite/uint128.cpp
- @@ -17,8 +17,8 @@ static void addAndCarry(const uint64& _a, const uint64& _b, uint64& carry, uint6
- // Break each number into 4 32-bit chunks. Since we are using uints, right-shifting will fill with zeros.
- // This eliminates the need to and with 0xFFFFFFFF.
- - uint32 a [2] = {_a & 0xFFFFFFFF, _a >> 32};
- - uint32 b [2] = {_b & 0xFFFFFFFF, _b >> 32};
- + uint32 a [2] = {static_cast<uint32>(_a & 0xFFFFFFFF), static_cast<uint32>(_a >> 32)};
- + uint32 b [2] = {static_cast<uint32>(_b & 0xFFFFFFFF), static_cast<uint32>(_b >> 32)};
- uint64 tmp = uint64(a[0]) + b[0];
- @@ -35,8 +35,8 @@ void multiplyAndCarry(const uint64& _a, const uint64& _b, uint64& carry, uint64&
- // Break each number into 4 32-bit chunks. Since we are using uints, right-shifting will fill with zeros.
- // This eliminates the need to and with 0xFFFFFFFF.
- - uint32 a [2] = {_a & 0xFFFFFFFF, _a >> 32};
- - uint32 b [2] = {_b & 0xFFFFFFFF, _b >> 32};
- + uint32 a [2] = {static_cast<uint32>(_a & 0xFFFFFFFF), static_cast<uint32>(_a >> 32)};
- + uint32 b [2] = {static_cast<uint32>(_b & 0xFFFFFFFF), static_cast<uint32>(_b >> 32)};
- uint64 prod [2][2];
- for(int i = 0; i < 2; ++i) {
- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
- index 3a4300c..9ddb25f 100644
- --- a/src/CMakeLists.txt
- +++ b/src/CMakeLists.txt
- @@ -24,10 +24,7 @@ if(WIN32)
- )
- endif()
- -if (BUILD_SCRIPTS)
- - add_subdirectory(scripts)
- -endif()
- -
- +add_subdirectory(bindings)
- add_subdirectory(framework)
- add_subdirectory(shared)
- add_subdirectory(realmd)
- diff --git a/src/framework/Utilities/UnorderedMapSet.h b/src/framework/Utilities/UnorderedMapSet.h
- index 92bb6f9..52f9607 100644
- --- a/src/framework/Utilities/UnorderedMapSet.h
- +++ b/src/framework/Utilities/UnorderedMapSet.h
- @@ -94,9 +94,9 @@ HASH_NAMESPACE_END
- using std::hash_map;
- using std::hash_set;
- #elif COMPILER == COMPILER_CLANG
- -# define UNORDERED_MAP std::tr1::unordered_map
- -# define UNORDERED_SET std::tr1::unordered_set
- -# define HASH_NAMESPACE_START namespace std { namespace tr1 {
- +# define UNORDERED_MAP std::unordered_map
- +# define UNORDERED_SET std::unordered_set
- +# define HASH_NAMESPACE_START namespace std { namespace __1 {
- # define HASH_NAMESPACE_END } }
- #elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- # define UNORDERED_MAP std::tr1::unordered_map
- diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp
- index 77943f0..d5b93bd 100644
- --- a/src/game/AuctionHouseHandler.cpp
- +++ b/src/game/AuctionHouseHandler.cpp
- @@ -29,6 +29,7 @@
- #include "Mail.h"
- #include "Util.h"
- #include "Chat.h"
- +#include "LuaEngine.h"
- // please DO NOT use iterator++, because it is slower than ++iterator!!!
- // post-incrementation is always slower than pre-incrementation !
- @@ -367,6 +368,9 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data)
- SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK);
- GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
- +
- + // Used by Eluna
- + sEluna->OnAdd(auctionHouse);
- }
- }
- @@ -521,6 +525,10 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recv_data)
- CharacterDatabase.CommitTransaction();
- sAuctionMgr.RemoveAItem(auction->itemGuidLow);
- auctionHouse->RemoveAuction(auction->Id);
- +
- + // Used by Eluna
- + sEluna->OnRemove(auctionHouse);
- +
- delete auction;
- }
- diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp
- index 692367a..5adb46c 100644
- --- a/src/game/AuctionHouseMgr.cpp
- +++ b/src/game/AuctionHouseMgr.cpp
- @@ -33,6 +33,7 @@
- #include "WorldPacket.h"
- #include "WorldSession.h"
- #include "Mail.h"
- +#include "LuaEngine.h"
- #include "Policies/Singleton.h"
- @@ -48,6 +49,14 @@ AuctionHouseMgr::~AuctionHouseMgr()
- delete itr->second;
- }
- +AuctionHouseObject::~AuctionHouseObject()
- +{
- + Eluna::RemoveRef(this);
- +
- + for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
- + delete itr->second;
- +}
- +
- AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house)
- {
- if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
- diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h
- index 703e25d..6852e08 100644
- --- a/src/game/AuctionHouseMgr.h
- +++ b/src/game/AuctionHouseMgr.h
- @@ -92,11 +92,7 @@ class AuctionHouseObject
- {
- public:
- AuctionHouseObject() {}
- - ~AuctionHouseObject()
- - {
- - for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
- - delete itr->second;
- - }
- + ~AuctionHouseObject();
- typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
- typedef std::pair<AuctionEntryMap::const_iterator, AuctionEntryMap::const_iterator> AuctionEntryMapBounds;
- diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt
- index bdeb230..ce2b85e 100644
- --- a/src/game/CMakeLists.txt
- +++ b/src/game/CMakeLists.txt
- @@ -16,7 +16,13 @@
- set(LIBRARY_NAME game)
- +file(GLOB SRC_FILES_LUAENGINE LuaEngine/*.cpp LuaEngine/*.h)
- +set(SRC_GRP_LUAENGINE
- + ${SRC_FILES_LUAENGINE}
- +)
- +
- set(LIBRARY_SRCS
- + ${SRC_GRP_LUAENGINE}
- AccountMgr.cpp
- AccountMgr.h
- AchievementMgr.cpp
- @@ -366,10 +372,12 @@ include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}/AuctionHouseBot
- ${CMAKE_CURRENT_SOURCE_DIR}/BattleGround
- ${CMAKE_CURRENT_SOURCE_DIR}/OutdoorPvP
- + ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine
- ${CMAKE_SOURCE_DIR}/dep/include/g3dlite
- ${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour
- ${CMAKE_SOURCE_DIR}/dep/recastnavigation/
- ${CMAKE_SOURCE_DIR}/dep/include
- + ${CMAKE_SOURCE_DIR}/dep/lualib
- ${CMAKE_SOURCE_DIR}/src/shared
- ${CMAKE_SOURCE_DIR}/src/framework
- ${CMAKE_BINARY_DIR}
- @@ -378,6 +386,11 @@ include_directories(
- ${ACE_INCLUDE_DIR}
- )
- +source_group("LuaEngine"
- + FILES
- + ${SRC_GRP_LUAENGINE}
- +)
- +
- source_group("Object"
- REGULAR_EXPRESSION .*
- )
- @@ -429,6 +442,7 @@ add_library(${LIBRARY_NAME} STATIC
- target_link_libraries(${LIBRARY_NAME}
- shared
- detour
- + lualib
- )
- if(UNIX)
- @@ -441,6 +455,7 @@ if(UNIX)
- endif()
- add_dependencies(${LIBRARY_NAME} revision.h)
- +add_dependencies(${LIBRARY_NAME} lualib)
- if(NOT ACE_USE_EXTERNAL)
- add_dependencies(${LIBRARY_NAME} ACE_Project)
- endif()
- @@ -459,3 +474,5 @@ if(PCH)
- endif()
- endif()
- endif()
- +
- +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/extensions DESTINATION ${BIN_DIR}/lua_scripts/)
- \ No newline at end of file
- diff --git a/src/game/Calendar.cpp b/src/game/Calendar.cpp
- index 979ede4..9a4ce28 100644
- --- a/src/game/Calendar.cpp
- +++ b/src/game/Calendar.cpp
- @@ -286,7 +286,7 @@ CalendarEvent* CalendarMgr::AddEvent(ObjectGuid const& guid, std::string title,
- uint64 nId = GetNewEventId();
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "CalendarMgr::AddEvent> ID("UI64FMTD"), '%s', Desc > '%s', type=%u, repeat=%u, maxInvites=%u, dungeonId=%d, flags=%u",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "CalendarMgr::AddEvent> ID(" UI64FMTD "), '%s', Desc > '%s', type=%u, repeat=%u, maxInvites=%u, dungeonId=%d, flags=%u",
- nId, title.c_str(), description.c_str(), type, repeatable, maxInvites, dungeonId, flags);
- CalendarEvent& newEvent = m_EventStore[nId];
- @@ -304,7 +304,7 @@ CalendarEvent* CalendarMgr::AddEvent(ObjectGuid const& guid, std::string title,
- CharacterDatabase.escape_string(title);
- CharacterDatabase.escape_string(description);
- - CharacterDatabase.PExecute("INSERT INTO calendar_events VALUES ("UI64FMTD", %u, %u, %u, %u, %d, %u, '%s', '%s')",
- + CharacterDatabase.PExecute("INSERT INTO calendar_events VALUES (" UI64FMTD ", %u, %u, %u, %u, %d, %u, '%s', '%s')",
- nId,
- guid.GetCounter(),
- guildId,
- @@ -388,7 +388,7 @@ CalendarInvite* CalendarMgr::AddInvite(CalendarEvent* event, ObjectGuid const& s
- return NULL;
- }
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Add Invite> eventId["UI64FMTD"], senderGuid[%s], inviteGuid[%s], Status[%u], rank[%u], text[%s], time[%u]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Add Invite> eventId[" UI64FMTD "], senderGuid[%s], inviteGuid[%s], Status[%u], rank[%u], text[%s], time[%u]",
- event->EventId, senderGuid.GetString().c_str(), inviteeGuid.GetString().c_str(), uint32(status), uint32(rank), text.c_str(), uint32(statusTime));
- if (!event->AddInvite(invite))
- @@ -398,7 +398,7 @@ CalendarInvite* CalendarMgr::AddInvite(CalendarEvent* event, ObjectGuid const& s
- return NULL;
- }
- - CharacterDatabase.PExecute("INSERT INTO calendar_invites VALUES ("UI64FMTD", "UI64FMTD", %u, %u, %u, %u, %u)",
- + CharacterDatabase.PExecute("INSERT INTO calendar_invites VALUES (" UI64FMTD ", " UI64FMTD ", %u, %u, %u, %u, %u)",
- invite->InviteId,
- event->EventId,
- inviteeGuid.GetCounter(),
- @@ -661,7 +661,7 @@ void CalendarMgr::LoadCalendarsFromDB()
- }
- while (invitesQuery->NextRow());
- sLog.outString();
- - sLog.outString(">> Loaded "UI64FMTD" invites! %s", totalInvites, (deletedInvites != 0) ? "(deleted some invites without corresponding event!)" : "");
- + sLog.outString(">> Loaded " UI64FMTD " invites! %s", totalInvites, (deletedInvites != 0) ? "(deleted some invites without corresponding event!)" : "");
- }
- else
- {
- diff --git a/src/game/CalendarHandler.cpp b/src/game/CalendarHandler.cpp
- index 7239ee2..58ae0f7 100644
- --- a/src/game/CalendarHandler.cpp
- +++ b/src/game/CalendarHandler.cpp
- @@ -58,7 +58,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
- data << uint8(event->IsGuildEvent());
- data << event->CreatorGuid.WriteAsPacked();
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "invite> EventId["UI64FMTD"], InviteId["UI64FMTD"], status[%u], rank[%u]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "invite> EventId[" UI64FMTD "], InviteId[" UI64FMTD "], status[%u], rank[%u]",
- event->EventId, (*itr)->InviteId, uint32((*itr)->Status), uint32((*itr)->Rank));
- }
- @@ -81,7 +81,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/)
- data << event->CreatorGuid.WriteAsPacked();
- std::string timeStr = TimeToTimestampStr(event->EventTime);
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Events> EventId["UI64FMTD"], Title[%s], Time[%s], Type[%u], Flag[%u], DungeonId[%d], CreatorGuid[%s]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Events> EventId[" UI64FMTD "], Title[%s], Time[%s], Type[%u], Flag[%u], DungeonId[%d], CreatorGuid[%s]",
- event->EventId, event->Title.c_str(), timeStr.c_str(), uint32(event->Type),
- uint32(event->Flags), event->DungeonId, event->CreatorGuid.GetString().c_str());
- }
- @@ -221,7 +221,7 @@ void WorldSession::HandleCalendarEventSignup(WorldPacket& recv_data)
- recv_data >> eventId;
- recv_data >> tentative; // uint8 == bool size in all compilator???
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"] Tentative %u", eventId, uint32(tentative));
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "] Tentative %u", eventId, uint32(tentative));
- if (CalendarEvent* event = sCalendarMgr.GetEventById(eventId))
- {
- @@ -327,7 +327,7 @@ void WorldSession::HandleCalendarUpdateEvent(WorldPacket& recv_data)
- recv_data >> UnknownPackedTime;
- recv_data >> flags;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"], InviteId ["UI64FMTD"] Title %s, Description %s, type %u "
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "], InviteId [" UI64FMTD "] Title %s, Description %s, type %u "
- "Repeatable %u, MaxInvites %u, Dungeon ID %d, Flags %u", eventId, inviteId, title.c_str(),
- description.c_str(), uint32(type), uint32(repetitionType), maxInvites, dungeonId, flags);
- @@ -400,7 +400,7 @@ void WorldSession::HandleCalendarCopyEvent(WorldPacket& recv_data)
- recv_data >> eventId >> inviteId;
- recv_data >> packedTime;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"] inviteId ["UI64FMTD"]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "] inviteId [" UI64FMTD "]",
- eventId, inviteId);
- sCalendarMgr.CopyEvent(eventId, timeBitFieldsToSecs(packedTime), guid);
- @@ -524,7 +524,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data)
- uint32 status;
- recv_data >> eventId >> inviteId >> status;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD "], InviteId [" UI64FMTD "], status %u",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "], InviteId [" UI64FMTD "], status %u",
- eventId, inviteId, status);
- if (CalendarEvent* event = sCalendarMgr.GetEventById(eventId))
- @@ -557,7 +557,7 @@ void WorldSession::HandleCalendarEventRsvp(WorldPacket& recv_data)
- invite->Status = CalendarInviteStatus(status);
- invite->LastUpdateTime = time(NULL);
- - CharacterDatabase.PExecute("UPDATE calendar_invites SET status=%u, lastUpdateTime=%u WHERE inviteId = "UI64FMTD, status, uint32(invite->LastUpdateTime), invite->InviteId);
- + CharacterDatabase.PExecute("UPDATE calendar_invites SET status=%u, lastUpdateTime=%u WHERE inviteId = " UI64FMTD , status, uint32(invite->LastUpdateTime), invite->InviteId);
- sCalendarMgr.SendCalendarEventStatus(invite);
- sCalendarMgr.SendCalendarClearPendingAction(_player);
- }
- @@ -581,7 +581,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recv_data)
- recv_data >> invitee.ReadAsPacked();
- recv_data >> inviteId >> ownerInviteId >> eventId;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"], ownerInviteId ["UI64FMTD"], Invitee ([%s] id: ["UI64FMTD"])",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "], ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" UI64FMTD "])",
- eventId, ownerInviteId, invitee.GetString().c_str(), inviteId);
- if (CalendarEvent* event = sCalendarMgr.GetEventById(eventId))
- @@ -604,7 +604,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recv_data)
- recv_data >> invitee.ReadAsPacked();
- recv_data >> eventId >> inviteId >> ownerInviteId >> status;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"] ownerInviteId ["UI64FMTD"], Invitee ([%s] id: ["UI64FMTD"], status %u",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" UI64FMTD "], status %u",
- eventId, ownerInviteId, invitee.GetString().c_str(), inviteId, status);
- if (CalendarEvent* event = sCalendarMgr.GetEventById(eventId))
- @@ -654,7 +654,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recv_data)
- recv_data >> invitee.ReadAsPacked();
- recv_data >> eventId >> inviteId >> ownerInviteId >> rank;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"] ownerInviteId ["UI64FMTD"], Invitee ([%s] id: ["UI64FMTD"], rank %u",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" UI64FMTD "], rank %u",
- eventId, ownerInviteId, invitee.GetString().c_str(), inviteId, rank);
- if (CalendarEvent* event = sCalendarMgr.GetEventById(eventId))
- @@ -706,7 +706,7 @@ void WorldSession::HandleCalendarComplain(WorldPacket& recv_data)
- recv_data >> badGuyGuid;
- recv_data >> eventId >> inviteId;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId ["UI64FMTD"], BadGuyGuid ([%s] inviteId: ["UI64FMTD"])",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "EventId [" UI64FMTD "], BadGuyGuid ([%s] inviteId: [" UI64FMTD "])",
- eventId, badGuyGuid.GetString().c_str(), inviteId);
- // Remove the invite
- @@ -759,7 +759,7 @@ void CalendarMgr::SendCalendarEventInviteAlert(CalendarInvite const* invite)
- data << invite->SenderGuid.WriteAsPacked();
- //data.hexlike();
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarInviteAlert> senderGuid[%s], inviteeGuid[%s], EventId["UI64FMTD"], Status[%u], InviteId["UI64FMTD"]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarInviteAlert> senderGuid[%s], inviteeGuid[%s], EventId[" UI64FMTD "], Status[%u], InviteId[" UI64FMTD "]",
- invite->SenderGuid.GetString().c_str(), invite->InviteeGuid.GetString().c_str(), event->EventId, uint32(invite->Status), invite->InviteId);
- if (event->IsGuildEvent() || event->IsGuildAnnouncement())
- @@ -799,7 +799,7 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const* invite)
- data << secsToTimeBitFields(statusTime);
- data << uint8(invite->SenderGuid != invite->InviteeGuid); // false only if the invite is sign-up (invitee create himself his invite)
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarInvit> %s senderGuid[%s], inviteeGuid[%s], EventId["UI64FMTD"], Status[%u], InviteId["UI64FMTD"]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarInvit> %s senderGuid[%s], inviteeGuid[%s], EventId[" UI64FMTD "], Status[%u], InviteId[" UI64FMTD "]",
- preInvite ? "is PreInvite," : "", invite->SenderGuid.GetString().c_str(), invite->InviteeGuid.GetString().c_str(), eventId, uint32(invite->Status), invite->InviteId);
- //data.hexlike();
- @@ -855,7 +855,7 @@ void CalendarMgr::SendCalendarEvent(Player* player, CalendarEvent const* event,
- return;
- std::string timeStr = TimeToTimestampStr(event->EventTime);
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarEvent> sendType[%u], CreatorGuid[%s], EventId["UI64FMTD"], Type[%u], Flags[%u], Title[%s]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarEvent> sendType[%u], CreatorGuid[%s], EventId[" UI64FMTD "], Type[%u], Flags[%u], Title[%s]",
- sendType, event->CreatorGuid.GetString().c_str(), event->EventId, uint32(event->Type), event->Flags, event->Title.c_str());
- WorldPacket data(SMSG_CALENDAR_SEND_EVENT);
- @@ -893,7 +893,7 @@ void CalendarMgr::SendCalendarEvent(Player* player, CalendarEvent const* event,
- data << secsToTimeBitFields(invite->LastUpdateTime);
- data << invite->Text;
- - DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Invite> InviteId["UI64FMTD"], InviteLvl[%u], Status[%u], Rank[%u], GuildEvent[%s], Text[%s]",
- + DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "Invite> InviteId[" UI64FMTD "], InviteLvl[%u], Status[%u], Rank[%u], GuildEvent[%s], Text[%s]",
- invite->InviteId, uint32(inviteeLevel), uint32(invite->Status), uint32(invite->Rank),
- (event->IsGuildEvent() && event->GuildId == inviteeGuildId) ? "true" : "false", invite->Text.c_str());
- }
- diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp
- index 6d6a63e..003161f 100644
- --- a/src/game/CharacterHandler.cpp
- +++ b/src/game/CharacterHandler.cpp
- @@ -40,6 +40,7 @@
- #include "Language.h"
- #include "SpellMgr.h"
- #include "Calendar.h"
- +#include "LuaEngine.h"
- // config option SkipCinematics supported values
- enum CinematicsSkipMode
- @@ -488,6 +489,9 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data)
- BASIC_LOG("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow());
- sLog.outChar("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow());
- + // Used by Eluna
- + sEluna->OnCreate(pNewChar);
- +
- delete pNewChar; // created only to call SaveToDB()
- }
- @@ -540,6 +544,9 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data)
- BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);
- sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);
- + // Used by Eluna
- + sEluna->OnDelete(lowguid);
- +
- if (sLog.IsOutCharDump()) // optimize GetPlayerDump call
- {
- std::string dump = PlayerDumpWriter().GetDump(lowguid);
- @@ -803,7 +810,12 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
- }
- if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST))
- + {
- + // Eluna
- + sEluna->OnFirstLogin(pCurrChar);
- +
- pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST);
- + }
- // show time before shutdown if shutdown planned.
- if (sWorld.IsShutdowning())
- @@ -831,6 +843,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
- pCurrChar->SetStandState(UNIT_STAND_STATE_STAND);
- m_playerLoading = false;
- +
- + // Eluna
- + sEluna->OnLogin(pCurrChar);
- // Handle Login-Achievements (should be handled after loading)
- pCurrChar->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, 1);
- diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp
- index fce786c..2fd32a7 100644
- --- a/src/game/Chat.cpp
- +++ b/src/game/Chat.cpp
- @@ -35,6 +35,7 @@
- #include "PoolManager.h"
- #include "GameEventMgr.h"
- #include "AuctionHouseBot/AuctionHouseBot.h"
- +#include "LuaEngine.h"
- // Supported shift-links (client generated and server side)
- // |color|Hachievement:achievement_id:player_guid_hex:completed_0_1:mm:dd:yy_from_2000:criteriaMask1:criteriaMask2:criteriaMask3:criteriaMask4|h[name]|h|r
- @@ -1259,6 +1260,9 @@ void ChatHandler::ExecuteCommand(const char* text)
- }
- case CHAT_COMMAND_UNKNOWN_SUBCOMMAND:
- {
- + if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str()))
- + return;
- +
- SendSysMessage(LANG_NO_SUBCMD);
- ShowHelpForCommand(command->ChildCommands, text);
- SetSentErrorMessage(true);
- @@ -1266,6 +1270,9 @@ void ChatHandler::ExecuteCommand(const char* text)
- }
- case CHAT_COMMAND_UNKNOWN:
- {
- + if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str()))
- + return;
- +
- SendSysMessage(LANG_NO_CMD);
- SetSentErrorMessage(true);
- break;
- diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp
- index a6839df..1ed6fc8 100644
- --- a/src/game/ChatHandler.cpp
- +++ b/src/game/ChatHandler.cpp
- @@ -35,6 +35,7 @@
- #include "Util.h"
- #include "GridNotifiersImpl.h"
- #include "CellImpl.h"
- +#include "LuaEngine.h"
- bool WorldSession::processChatmessageFurtherAfterSecurityChecks(std::string& msg, uint32 lang)
- {
- @@ -180,11 +181,26 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- break;
- if (type == CHAT_MSG_SAY)
- + {
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
- + return;
- +
- GetPlayer()->Say(msg, lang);
- + }
- else if (type == CHAT_MSG_EMOTE)
- + {
- + if (!sEluna->OnChat(GetPlayer(), type, LANG_UNIVERSAL, msg))
- + return;
- +
- GetPlayer()->TextEmote(msg);
- + }
- else if (type == CHAT_MSG_YELL)
- + {
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
- + return;
- +
- GetPlayer()->Yell(msg, lang);
- + }
- } break;
- case CHAT_MSG_WHISPER:
- @@ -223,6 +239,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- }
- }
- + // Used by Eluna
- + sEluna->OnChat(GetPlayer(), type, lang, msg, player);
- GetPlayer()->Whisper(msg, lang, player->GetObjectGuid());
- } break;
- @@ -255,6 +273,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- if ((type == CHAT_MSG_PARTY_LEADER) && !group->IsLeader(_player->GetObjectGuid()))
- return;
- +
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
- + return;
- WorldPacket data;
- ChatHandler::BuildChatPacket(data, ChatMsg(type), msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName());
- @@ -281,8 +303,14 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- if (GetPlayer()->GetGuildId())
- if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()))
- + {
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild))
- + return;
- +
- guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
- -
- + }
- +
- break;
- }
- case CHAT_MSG_OFFICER:
- @@ -304,8 +332,14 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- if (GetPlayer()->GetGuildId())
- if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId()))
- + {
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild))
- + return;
- +
- guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
- -
- + }
- +
- break;
- }
- case CHAT_MSG_RAID:
- @@ -334,6 +368,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- return;
- }
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
- + return;
- +
- WorldPacket data;
- ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName());
- group->BroadcastPacket(&data, false);
- @@ -364,6 +402,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- return;
- }
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
- + return;
- +
- WorldPacket data;
- ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_LEADER, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName());
- group->BroadcastPacket(&data, false);
- @@ -385,6 +427,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- !(group->IsLeader(GetPlayer()->GetObjectGuid()) || group->IsAssistant(GetPlayer()->GetObjectGuid())))
- return;
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
- + return;
- +
- WorldPacket data;
- // in battleground, raid warning is sent only to players in battleground - code is ok
- ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_WARNING, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName());
- @@ -406,6 +452,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- Group* group = GetPlayer()->GetGroup();
- if (!group || !group->isBGGroup())
- return;
- +
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
- + return;
- WorldPacket data;
- ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName());
- @@ -427,6 +477,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- Group* group = GetPlayer()->GetGroup();
- if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetObjectGuid()))
- return;
- +
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group))
- + return;
- WorldPacket data;
- ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND_LEADER, msg.c_str(), Language(lang), _player->GetChatTag(), _player->GetObjectGuid(), _player->GetName());
- @@ -447,7 +501,13 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
- if (Channel* chn = cMgr->GetChannel(channel, _player))
- + {
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg, chn))
- + return;
- +
- chn->Say(_player, msg.c_str(), lang);
- + }
- } break;
- case CHAT_MSG_AFK:
- @@ -473,6 +533,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- _player->ToggleAFK();
- }
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
- + return;
- }
- break;
- }
- @@ -497,6 +560,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data)
- _player->ToggleDND();
- }
- + // Used by Eluna
- + if (!sEluna->OnChat(GetPlayer(), type, lang, msg))
- + return;
- +
- break;
- }
- @@ -513,6 +580,9 @@ void WorldSession::HandleEmoteOpcode(WorldPacket& recv_data)
- uint32 emote;
- recv_data >> emote;
- +
- + // Used by Eluna
- + sEluna->OnEmote(GetPlayer(), emote);
- GetPlayer()->HandleEmoteCommand(emote);
- }
- @@ -566,6 +636,9 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data)
- recv_data >> text_emote;
- recv_data >> emoteNum;
- recv_data >> guid;
- +
- + // Used by Eluna
- + sEluna->OnTextEmote(GetPlayer(), text_emote, emoteNum, guid);
- EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(text_emote);
- if (!em)
- diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp
- index 4708392..53c33f6 100644
- --- a/src/game/Corpse.cpp
- +++ b/src/game/Corpse.cpp
- @@ -26,6 +26,7 @@
- #include "GossipDef.h"
- #include "World.h"
- #include "ObjectMgr.h"
- +#include "LuaEngine.h"
- Corpse::Corpse(CorpseType type) : WorldObject(),
- loot(this),
- @@ -46,6 +47,7 @@ Corpse::Corpse(CorpseType type) : WorldObject(),
- Corpse::~Corpse()
- {
- + Eluna::RemoveRef(this);
- }
- void Corpse::AddToWorld()
- diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
- index 142d904..a0e571d 100644
- --- a/src/game/Creature.cpp
- +++ b/src/game/Creature.cpp
- @@ -49,6 +49,7 @@
- #include "CellImpl.h"
- #include "movement/MoveSplineInit.h"
- #include "CreatureLinkingMgr.h"
- +#include "LuaEngine.h"
- // apply implementation of the singletons
- #include "Policies/Singleton.h"
- @@ -155,11 +156,15 @@ Creature::Creature(CreatureSubtype subtype) : Unit(),
- m_CreatureSpellCooldowns.clear();
- m_CreatureCategoryCooldowns.clear();
- + DisableReputationGain = false;
- +
- SetWalk(true, true);
- }
- Creature::~Creature()
- {
- + Eluna::RemoveRef(this);
- +
- CleanupsBeforeDelete();
- m_vendorItemCounts.clear();
- @@ -170,6 +175,9 @@ Creature::~Creature()
- void Creature::AddToWorld()
- {
- + if (!IsInWorld())
- + sEluna->OnAddToWorld(this);
- +
- ///- Register the creature for guid lookup
- if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
- GetMap()->GetObjectsStore().insert<Creature>(GetObjectGuid(), (Creature*)this);
- @@ -179,6 +187,9 @@ void Creature::AddToWorld()
- void Creature::RemoveFromWorld()
- {
- + if (IsInWorld())
- + sEluna->OnRemoveFromWorld(this);
- +
- ///- Remove the creature from the accessor
- if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle())
- GetMap()->GetObjectsStore().erase<Creature>(GetObjectGuid(), (Creature*)NULL);
- @@ -1056,6 +1067,18 @@ void Creature::SaveToDB()
- SaveToDB(GetMapId(), data->spawnMask, GetPhaseMask());
- }
- +bool Creature::isTappedBy(Player const* player) const
- +{
- + if (player == GetOriginalLootRecipient())
- + return true;
- +
- + Group const* playerGroup = player->GetGroup();
- + if (!playerGroup || playerGroup != GetGroupLootRecipient()) // if we dont have a group we arent the recipient
- + return false;
- +
- + return true;
- +}
- +
- void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
- {
- // update in loaded data
- @@ -2177,6 +2200,13 @@ bool Creature::HasCategoryCooldown(uint32 spell_id) const
- return (itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
- }
- +uint32 Creature::GetCreatureSpellCooldownDelay(uint32 spellId) const
- +{
- + CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spellId);
- + time_t t = time(NULL);
- + return uint32(itr != m_CreatureSpellCooldowns.end() && itr->second > t ? itr->second - t : 0);
- +}
- +
- bool Creature::HasSpellCooldown(uint32 spell_id) const
- {
- CreatureSpellCooldowns::const_iterator itr = m_CreatureSpellCooldowns.find(spell_id);
- diff --git a/src/game/Creature.h b/src/game/Creature.h
- index 4134e68..59708e1 100644
- --- a/src/game/Creature.h
- +++ b/src/game/Creature.h
- @@ -510,6 +510,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
- bool IsCorpse() const { return getDeathState() == CORPSE; }
- bool IsDespawned() const { return getDeathState() == DEAD; }
- void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; }
- + uint32 GetCorpseDelay() const { return m_corpseDelay; }
- bool IsRacialLeader() const { return GetCreatureInfo()->RacialLeader; }
- bool IsCivilian() const { return GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_CIVILIAN; }
- bool IsGuard() const { return GetCreatureInfo()->ExtraFlags & CREATURE_FLAG_EXTRA_GUARD; }
- @@ -573,6 +574,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
- void AddCreatureSpellCooldown(uint32 spellid);
- bool HasSpellCooldown(uint32 spell_id) const;
- bool HasCategoryCooldown(uint32 spell_id) const;
- + uint32 GetCreatureSpellCooldownDelay(uint32 spellId) const;
- bool HasSpell(uint32 spellID) const override;
- @@ -634,6 +636,7 @@ class MANGOS_DLL_SPEC Creature : public Unit
- uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; }
- Player* GetLootRecipient() const; // use group cases as prefered
- Group* GetGroupLootRecipient() const;
- + bool isTappedBy(Player const* player) const;
- bool HasLootRecipient() const { return m_lootGroupRecipientId || m_lootRecipientGuid; }
- bool IsGroupLootRecipient() const { return m_lootGroupRecipientId; }
- void SetLootRecipient(Unit* unit);
- @@ -731,6 +734,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
- void SetVirtualItem(VirtualItemSlot slot, uint32 item_id) { SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, item_id); }
- + void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; }
- + bool IsReputationGainDisabled() { return DisableReputationGain; }
- +
- protected:
- bool MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* pSpellInfo, uint32 selectFlags) const;
- @@ -781,6 +787,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
- float m_combatStartZ;
- Position m_respawnPos;
- +
- + bool DisableReputationGain;
- private:
- GridReference<Creature> m_gridRef;
- diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
- index 0377274..064d47a 100644
- --- a/src/game/GameObject.cpp
- +++ b/src/game/GameObject.cpp
- @@ -40,7 +40,9 @@
- #include "Util.h"
- #include "ScriptMgr.h"
- #include "vmap/GameObjectModel.h"
- +#include "CreatureAISelector.h"
- #include "SQLStorages.h"
- +#include "LuaEngine.h"
- #include <G3D/Quat.h>
- GameObject::GameObject() : WorldObject(),
- @@ -73,11 +75,16 @@ GameObject::GameObject() : WorldObject(),
- GameObject::~GameObject()
- {
- + Eluna::RemoveRef(this);
- +
- delete m_model;
- }
- void GameObject::AddToWorld()
- {
- + if (!IsInWorld())
- + sEluna->OnAddToWorld(this);
- +
- ///- Register the gameobject for guid lookup
- if (!IsInWorld())
- GetMap()->GetObjectsStore().insert<GameObject>(GetObjectGuid(), (GameObject*)this);
- @@ -96,6 +103,8 @@ void GameObject::RemoveFromWorld()
- ///- Remove the gameobject from the accessor
- if (IsInWorld())
- {
- + sEluna->OnRemoveFromWorld(this);
- +
- // Notify the outdoor pvp script
- if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId()))
- outdoorPvP->HandleGameObjectRemove(this);
- @@ -121,6 +130,15 @@ void GameObject::RemoveFromWorld()
- Object::RemoveFromWorld();
- }
- +void GameObject::CleanupsBeforeDelete()
- +{
- + if (m_uint32Values)
- + {
- + m_Events.KillAllEvents(false);
- + }
- + WorldObject::CleanupsBeforeDelete();
- +}
- +
- bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, QuaternionData rotation, uint8 animprogress, GOState go_state)
- {
- MANGOS_ASSERT(map);
- @@ -187,6 +205,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
- default:
- break;
- }
- +
- + // Used by Eluna
- + sEluna->OnSpawn(this);
- // Notify the battleground or outdoor pvp script
- if (map->IsBattleGroundOrArena())
- @@ -210,6 +231,10 @@ void GameObject::Update(uint32 update_diff, uint32 p_time)
- //((Transport*)this)->Update(p_time);
- return;
- }
- +
- + m_Events.Update(p_time);
- + // Used by Eluna
- + sEluna->UpdateAI(this, p_time);
- switch (m_lootState)
- {
- @@ -976,6 +1001,12 @@ void GameObject::Use(Unit* user)
- Unit* spellCaster = user;
- uint32 spellId = 0;
- bool triggered = false;
- +
- + if (Player* playerUser = user->ToPlayer())
- + {
- + if (sScriptMgr.OnGossipHello(playerUser, this))
- + return;
- + }
- // test only for exist cooldown data (cooldown timer used for door/buttons reset that not have use cooldown)
- if (uint32 cooldown = GetGOInfo()->GetCooldown())
- @@ -1790,12 +1821,14 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
- void GameObject::SetLootState(LootState state)
- {
- m_lootState = state;
- + sEluna->OnLootStateChanged(this, state);
- UpdateCollisionState();
- }
- void GameObject::SetGoState(GOState state)
- {
- SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
- + sEluna->OnGameObjectStateChanged(this, state);
- UpdateCollisionState();
- }
- @@ -2236,6 +2269,8 @@ void GameObject::ForceGameObjectHealth(int32 diff, Unit* caster)
- {
- DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DestructibleGO: %s taken damage %u dealt by %s", GetGuidStr().c_str(), uint32(-diff), caster->GetGuidStr().c_str());
- + if (caster && caster->ToPlayer())
- + sEluna->OnDamaged(this, caster->ToPlayer());
- if (m_useTimes > uint32(-diff))
- m_useTimes += diff;
- else
- @@ -2274,6 +2309,8 @@ void GameObject::ForceGameObjectHealth(int32 diff, Unit* caster)
- {
- DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DestructibleGO: %s got destroyed", GetGuidStr().c_str());
- + if(caster && caster->ToPlayer())
- + sEluna->OnDestroyed(this, caster->ToPlayer());
- RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK_9 | GO_FLAG_UNK_10);
- SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK_11);
- diff --git a/src/game/GameObject.h b/src/game/GameObject.h
- index fb7547d..d440668 100644
- --- a/src/game/GameObject.h
- +++ b/src/game/GameObject.h
- @@ -24,6 +24,7 @@
- #include "Object.h"
- #include "LootMgr.h"
- #include "Database/DatabaseEnv.h"
- +#include "Utilities/EventProcessor.h"
- // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
- #if defined( __GNUC__ )
- @@ -619,6 +620,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
- void AddToWorld() override;
- void RemoveFromWorld() override;
- +
- + void CleanupsBeforeDelete() override;
- bool Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang,
- QuaternionData rotation = QuaternionData(), uint8 animprogress = GO_ANIMPROGRESS_DEFAULT, GOState go_state = GO_STATE_READY);
- @@ -681,6 +684,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
- (m_respawnTime == 0 && m_spawnedByDefault);
- }
- bool isSpawnedByDefault() const { return m_spawnedByDefault; }
- + void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
- uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
- void Refresh();
- void Delete();
- @@ -772,6 +776,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
- GridReference<GameObject>& GetGridRef() { return m_gridRef; }
- GameObjectModel* m_model;
- +
- + // Event Handler
- + EventProcessor m_Events;
- protected:
- uint32 m_spellId;
- diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
- index 3f47240..41d7661 100644
- --- a/src/game/GridNotifiers.h
- +++ b/src/game/GridNotifiers.h
- @@ -216,6 +216,25 @@ namespace MaNGOS
- };
- template<class Check>
- + struct MANGOS_DLL_DECL WorldObjectLastSearcher
- + {
- + uint32 i_phaseMask;
- + WorldObject* &i_object;
- + Check& i_check;
- +
- + WorldObjectLastSearcher(WorldObject* & result, Check& check)
- + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {}
- +
- + void Visit(PlayerMapType& m);
- + void Visit(CreatureMapType& m);
- + void Visit(CorpseMapType& m);
- + void Visit(GameObjectMapType& m);
- + void Visit(DynamicObjectMapType& m);
- +
- + template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED>&) {}
- + };
- +
- + template<class Check>
- struct MANGOS_DLL_DECL WorldObjectListSearcher
- {
- uint32 i_phaseMask;
- diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
- index 7b714e5..eafe9dd 100644
- --- a/src/game/GridNotifiersImpl.h
- +++ b/src/game/GridNotifiersImpl.h
- @@ -310,6 +310,86 @@ void MaNGOS::WorldObjectSearcher<Check>::Visit(DynamicObjectMapType& m)
- }
- template<class Check>
- +void MaNGOS::WorldObjectLastSearcher<Check>::Visit(GameObjectMapType& m)
- +{
- + for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- + {
- + if (!itr->getSource()->InSamePhase(i_phaseMask))
- + continue;
- +
- + if (i_check(itr->getSource()))
- + {
- + i_object = itr->getSource();
- + return;
- + }
- + }
- +}
- +
- +template<class Check>
- +void MaNGOS::WorldObjectLastSearcher<Check>::Visit(PlayerMapType& m)
- +{
- + for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- + {
- + if (!itr->getSource()->InSamePhase(i_phaseMask))
- + continue;
- +
- + if (i_check(itr->getSource()))
- + {
- + i_object = itr->getSource();
- + return;
- + }
- + }
- +}
- +
- +template<class Check>
- +void MaNGOS::WorldObjectLastSearcher<Check>::Visit(CreatureMapType& m)
- +{
- + for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- + {
- + if (!itr->getSource()->InSamePhase(i_phaseMask))
- + continue;
- +
- + if (i_check(itr->getSource()))
- + {
- + i_object = itr->getSource();
- + return;
- + }
- + }
- +}
- +
- +template<class Check>
- +void MaNGOS::WorldObjectLastSearcher<Check>::Visit(CorpseMapType& m)
- +{
- + for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- + {
- + if (!itr->getSource()->InSamePhase(i_phaseMask))
- + continue;
- +
- + if (i_check(itr->getSource()))
- + {
- + i_object = itr->getSource();
- + return;
- + }
- + }
- +}
- +
- +template<class Check>
- +void MaNGOS::WorldObjectLastSearcher<Check>::Visit(DynamicObjectMapType& m)
- +{
- + for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr)
- + {
- + if (!itr->getSource()->InSamePhase(i_phaseMask))
- + continue;
- +
- + if (i_check(itr->getSource()))
- + {
- + i_object = itr->getSource();
- + return;
- + }
- + }
- +}
- +
- +template<class Check>
- void MaNGOS::WorldObjectListSearcher<Check>::Visit(PlayerMapType& m)
- {
- for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
- diff --git a/src/game/Group.cpp b/src/game/Group.cpp
- index 7b93500..bc6f5f1 100644
- --- a/src/game/Group.cpp
- +++ b/src/game/Group.cpp
- @@ -33,6 +33,7 @@
- #include "MapPersistentStateMgr.h"
- #include "Util.h"
- #include "LootMgr.h"
- +#include "LuaEngine.h"
- #define LOOT_ROLL_TIMEOUT (1*MINUTE*IN_MILLISECONDS)
- @@ -83,6 +84,8 @@ Group::Group() : m_Id(0), m_groupType(GROUPTYPE_NORMAL),
- Group::~Group()
- {
- + Eluna::RemoveRef(this);
- +
- if (m_bgGroup)
- {
- DEBUG_LOG("Group::~Group: battleground group being deleted.");
- @@ -163,6 +166,9 @@ bool Group::Create(ObjectGuid guid, const char* name)
- if (!isBGGroup())
- CharacterDatabase.CommitTransaction();
- +
- + // Used by Eluna
- + sEluna->OnCreate(this, m_leaderGuid, m_groupType);
- return true;
- }
- @@ -255,6 +261,9 @@ bool Group::AddInvite(Player* player)
- m_invitees.insert(player);
- player->SetGroupInvite(this);
- +
- + // Used by Eluna
- + sEluna->OnInviteMember(this, player->GetObjectGuid());
- return true;
- }
- @@ -336,6 +345,9 @@ bool Group::AddMember(ObjectGuid guid, const char* name)
- }
- player->SetGroupUpdateFlag(GROUP_UPDATE_FULL);
- UpdatePlayerOutOfRange(player);
- +
- + // Used by Eluna
- + sEluna->OnAddMember(this, player->GetObjectGuid());
- // quest related GO state dependent from raid membership
- if (isRaidGroup())
- @@ -394,6 +406,9 @@ uint32 Group::RemoveMember(ObjectGuid guid, uint8 method)
- // if group before remove <= 2 disband it
- else
- Disband(true);
- +
- + // Used by Eluna
- + sEluna->OnRemoveMember(this, guid, method); // Kicker and Reason not a part of Mangos, implement?
- return m_memberSlots.size();
- }
- @@ -403,6 +418,9 @@ void Group::ChangeLeader(ObjectGuid guid)
- member_citerator slot = _getMemberCSlot(guid);
- if (slot == m_memberSlots.end())
- return;
- +
- + // Used by Eluna
- + sEluna->OnChangeLeader(this, guid, GetLeaderGuid());
- _setLeader(guid);
- @@ -478,6 +496,9 @@ void Group::Disband(bool hideDestroy)
- ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
- ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
- }
- +
- + // Used by Eluna
- + sEluna->OnDisband(this);
- m_leaderGuid.Clear();
- m_leaderName = "";
- diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp
- index a6ab775..7fa1ba7 100644
- --- a/src/game/Guild.cpp
- +++ b/src/game/Guild.cpp
- @@ -30,6 +30,7 @@
- #include "Language.h"
- #include "World.h"
- #include "Calendar.h"
- +#include "LuaEngine.h"
- //// MemberSlot ////////////////////////////////////////////
- void MemberSlot::SetMemberStats(Player* player)
- @@ -101,6 +102,8 @@ Guild::Guild()
- Guild::~Guild()
- {
- + Eluna::RemoveRef(this);
- +
- DeleteGuildBankItems();
- }
- @@ -140,6 +143,9 @@ bool Guild::Create(Player* leader, std::string gname)
- CharacterDatabase.CommitTransaction();
- CreateDefaultGuildRanks(lSession->GetSessionDbLocaleIndex());
- +
- + // Used by Eluna
- + sEluna->OnCreate(this, leader, gname.c_str());
- return AddMember(m_LeaderGuid, (uint32)GR_GUILDMASTER);
- }
- @@ -240,6 +246,9 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)
- }
- UpdateAccountsNumber();
- +
- + // Used by Eluna
- + sEluna->OnAddMember(this, pl, newmember.RankId);
- return true;
- }
- @@ -251,6 +260,9 @@ void Guild::SetMOTD(std::string motd)
- // motd now can be used for encoding to DB
- CharacterDatabase.escape_string(motd);
- CharacterDatabase.PExecute("UPDATE guild SET motd='%s' WHERE guildid='%u'", motd.c_str(), m_Id);
- +
- + // Used by Eluna
- + sEluna->OnMOTDChanged(this, motd);
- }
- void Guild::SetGINFO(std::string ginfo)
- @@ -260,6 +272,9 @@ void Guild::SetGINFO(std::string ginfo)
- // ginfo now can be used for encoding to DB
- CharacterDatabase.escape_string(ginfo);
- CharacterDatabase.PExecute("UPDATE guild SET info='%s' WHERE guildid='%u'", ginfo.c_str(), m_Id);
- +
- + // Used by Eluna
- + sEluna->OnInfoChanged(this, ginfo);
- }
- bool Guild::LoadGuildFromDB(QueryResult* guildDataResult)
- @@ -554,10 +569,25 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)
- if (!isDisbanding)
- UpdateAccountsNumber();
- +
- + // Used by Eluna
- + sEluna->OnRemoveMember(this, player, isDisbanding); // IsKicked not a part of Mangos, implement?
- return members.empty();
- }
- +bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank)
- +{
- + if (newRank <= GetLowestRank()) // Validate rank (allow only existing ranks)
- + if (MemberSlot* member = GetMemberSlot(guid))
- + {
- + member->ChangeRank(newRank);
- + return true;
- + }
- +
- + return false;
- +}
- +
- void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language)
- {
- if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_GCHATSPEAK))
- @@ -755,6 +785,10 @@ void Guild::Disband()
- CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid = '%u'", m_Id);
- CharacterDatabase.PExecute("DELETE FROM guild_eventlog WHERE guildid = '%u'", m_Id);
- CharacterDatabase.CommitTransaction();
- +
- + // Used by Eluna
- + sEluna->OnDisband(this);
- +
- sGuildMgr.RemoveGuild(m_Id);
- }
- @@ -1268,6 +1302,11 @@ bool Guild::MemberMoneyWithdraw(uint32 amount, uint32 LowGuid)
- CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'",
- itr->second.BankRemMoney, m_Id, LowGuid);
- }
- +
- + // Used by Eluna
- + Player* player = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, LowGuid));
- + sEluna->OnMemberWitdrawMoney(this, player, amount, false); // IsRepair not a part of Mangos, implement?
- +
- return true;
- }
- @@ -1656,6 +1695,9 @@ void Guild::LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uin
- m_GuildBankEventLog_Item[TabId].push_back(NewEvent);
- }
- +
- + // Used by Eluna
- + sEluna->OnBankEvent(this, EventType, TabId, PlayerGuidLow, ItemOrMoney, ItemStackCount, DestTabId);
- // save event to database
- CharacterDatabase.PExecute("DELETE FROM guild_bank_eventlog WHERE guildid='%u' AND LogGuid='%u' AND TabId='%u'", m_Id, currentLogGuid, currentTabId);
- diff --git a/src/game/Guild.h b/src/game/Guild.h
- index 02792a7..7d5cbbf 100644
- --- a/src/game/Guild.h
- +++ b/src/game/Guild.h
- @@ -29,6 +29,7 @@
- class Item;
- +#define GUILD_RANK_NONE 0xFF
- #define GUILD_RANKS_MIN_COUNT 5
- #define GUILD_RANKS_MAX_COUNT 10
- @@ -324,6 +325,7 @@ class Guild
- void SetLeader(ObjectGuid guid);
- bool AddMember(ObjectGuid plGuid, uint32 plRank);
- bool DelMember(ObjectGuid guid, bool isDisbanding = false);
- + bool ChangeMemberRank(ObjectGuid guid, uint8 newRank);
- // lowest rank is the count of ranks - 1 (the highest rank_id in table)
- uint32 GetLowestRank() const { return m_Ranks.size() - 1; }
- diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp
- index fbe814e..7e28881 100644
- --- a/src/game/GuildHandler.cpp
- +++ b/src/game/GuildHandler.cpp
- @@ -28,6 +28,7 @@
- #include "GossipDef.h"
- #include "SocialMgr.h"
- #include "Calendar.h"
- +#include "LuaEngine.h"
- void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket)
- {
- @@ -65,6 +66,17 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket)
- sGuildMgr.AddGuild(guild);
- }
- +void WorldSession::SendGuildInvite(Player* player, bool alreadyInGuild /*= false*/)
- +{
- + Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId());
- + player->SetGuildIdInvited(GetPlayer()->GetGuildId());
- +
- + WorldPacket data(SMSG_GUILD_INVITE, (8 + 10)); // guess size
- + data << GetPlayer()->GetName();
- + data << guild->GetName();
- + player->GetSession()->SendPacket(&data); // unk
- +}
- +
- void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket)
- {
- DEBUG_LOG("WORLD: Received opcode CMSG_GUILD_INVITE");
- @@ -917,6 +929,9 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recv_data)
- // log
- pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), GetPlayer()->GetGUIDLow(), money);
- + // Used by Eluna
- + sEluna->OnMemberDepositMoney(pGuild, GetPlayer(), money);
- +
- pGuild->DisplayGuildBankTabsInfo(this);
- pGuild->DisplayGuildBankContent(this, 0);
- pGuild->DisplayGuildBankMoneyUpdate(this);
- diff --git a/src/game/Item.cpp b/src/game/Item.cpp
- index 4de0aac..a73a737 100644
- --- a/src/game/Item.cpp
- +++ b/src/game/Item.cpp
- @@ -23,6 +23,7 @@
- #include "Database/DatabaseEnv.h"
- #include "ItemEnchantmentMgr.h"
- #include "SQLStorages.h"
- +#include "LuaEngine.h"
- void AddItemsSetItem(Player* player, Item* item)
- {
- @@ -247,6 +248,11 @@ Item::Item() :
- m_lootState = ITEM_LOOT_NONE;
- }
- +Item::~Item()
- +{
- + Eluna::RemoveRef(this);
- +}
- +
- bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
- {
- Object::_Create(guidlow, 0, HIGHGUID_ITEM);
- @@ -273,6 +279,13 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
- return true;
- }
- +bool Item::IsNotEmptyBag() const
- +{
- + if (Bag const* bag = ToBag())
- + return !bag->IsEmpty();
- + return false;
- +}
- +
- void Item::UpdateDuration(Player* owner, uint32 diff)
- {
- if (!GetUInt32Value(ITEM_FIELD_DURATION))
- @@ -282,6 +295,9 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
- if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
- {
- + // Used by Eluna
- + sEluna->OnExpire(owner, GetProto());
- +
- if (uint32 newItemId = sObjectMgr.GetItemExpireConvert(GetEntry()))
- owner->ConvertItem(this, newItemId);
- else
- diff --git a/src/game/Item.h b/src/game/Item.h
- index c86afa1..194ea68 100644
- --- a/src/game/Item.h
- +++ b/src/game/Item.h
- @@ -277,6 +277,7 @@ class MANGOS_DLL_SPEC Item : public Object
- Item* CloneItem(uint32 count, Player const* player = NULL) const;
- Item();
- + ~Item();
- virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
- @@ -297,7 +298,13 @@ class MANGOS_DLL_SPEC Item : public Object
- void DeleteFromInventoryDB();
- void LoadLootFromDB(Field* fields);
- + Bag* ToBag() { if (IsBag()) return reinterpret_cast<Bag*>(this); else return NULL; }
- + const Bag* ToBag() const { if (IsBag()) return reinterpret_cast<const Bag*>(this); else return NULL; }
- +
- + bool IsLocked() const { return !HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_UNLOCKED); }
- bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; }
- + bool IsCurrencyToken() const { return GetProto()->IsCurrencyToken(); }
- + bool IsNotEmptyBag() const;
- bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
- bool CanBeTraded(bool mail = false) const;
- void SetInTrade(bool b = true) { mb_in_trade = b; }
- @@ -378,7 +385,9 @@ class MANGOS_DLL_SPEC Item : public Object
- bool HasInvolvedQuest(uint32 /*quest_id*/) const override { return false; }
- bool IsPotion() const { return GetProto()->IsPotion(); }
- bool IsConjuredConsumable() const { return GetProto()->IsConjuredConsumable(); }
- -
- + bool IsWeaponVellum() const { return GetProto()->IsWeaponVellum(); }
- + bool IsArmorVellum() const { return GetProto()->IsArmorVellum(); }
- +
- void AddToClientUpdateList() override;
- void RemoveFromClientUpdateList() override;
- void BuildUpdateData(UpdateDataMapType& update_players) override;
- diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h
- index 1a60d8c..54f4ce0 100644
- --- a/src/game/ItemPrototype.h
- +++ b/src/game/ItemPrototype.h
- @@ -638,6 +638,8 @@ struct ItemPrototype
- return false;
- }
- +
- + bool IsCurrencyToken() const { return BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS; }
- uint32 GetMaxStackSize() const { return Stackable > 0 ? uint32(Stackable) : uint32(0x7FFFFFFF - 1); }
- @@ -670,6 +672,9 @@ struct ItemPrototype
- {
- return (Class == ITEM_CLASS_TRADE_GOODS && (1 << SubClass) & (1 << ITEM_SUBCLASS_ARMOR_ENCHANTMENT | 1 << ITEM_SUBCLASS_WEAPON_ENCHANTMENT));
- }
- +
- + bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; }
- + bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; }
- };
- // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
- diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp
- index 3756e9a..4dc97b2 100644
- --- a/src/game/LootHandler.cpp
- +++ b/src/game/LootHandler.cpp
- @@ -31,6 +31,7 @@
- #include "World.h"
- #include "Util.h"
- #include "DBCStores.h"
- +#include "LuaEngine.h"
- void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data)
- {
- @@ -275,6 +276,9 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/)
- data << uint8(1); // 1 is "you loot..."
- player->GetSession()->SendPacket(&data);
- }
- +
- + // Used by Eluna
- + sEluna->OnLootMoney(player, pLoot->gold);
- pLoot->gold = 0;
- @@ -575,6 +579,9 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data)
- target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, pLoot->loot_type, item.count);
- target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count);
- + // Used by Eluna
- + sEluna->OnLootItem(target, newitem, item.count, lootguid);
- +
- // mark as looted
- item.count = 0;
- item.is_looted = true;
- diff --git a/src/game/Map.cpp b/src/game/Map.cpp
- index 82d7352..3aec8f7 100644
- --- a/src/game/Map.cpp
- +++ b/src/game/Map.cpp
- @@ -39,9 +39,13 @@
- #include "BattleGround/BattleGroundMgr.h"
- #include "Calendar.h"
- #include "Chat.h"
- +#include "LuaEngine.h"
- Map::~Map()
- {
- + sEluna->OnDestroy(this);
- + Eluna::RemoveRef(this);
- +
- UnloadAll(true);
- if (!m_scriptSchedule.empty())
- @@ -99,6 +103,8 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode)
- m_persistentState = sMapPersistentStateMgr.AddPersistentState(i_mapEntry, GetInstanceId(), GetDifficulty(), 0, IsDungeon());
- m_persistentState->SetUsedByMapState(this);
- +
- + sEluna->OnCreate(this);
- }
- void Map::InitVisibilityDistance()
- @@ -300,6 +306,9 @@ bool Map::Add(Player* player)
- NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
- player->GetViewPoint().Event_AddedToWorld(&(*grid)(cell.CellX(), cell.CellY()));
- UpdateObjectVisibility(player, cell, p);
- +
- + sEluna->OnMapChanged(player);
- + sEluna->OnPlayerEnter(this, player);
- if (i_data)
- i_data->OnPlayerEnter(player);
- @@ -563,12 +572,16 @@ void Map::Update(const uint32& t_diff)
- if (!m_scriptSchedule.empty())
- ScriptsProcess();
- + sEluna->OnUpdate(this, t_diff);
- +
- if (i_data)
- i_data->Update(t_diff);
- }
- void Map::Remove(Player* player, bool remove)
- {
- + sEluna->OnPlayerLeave(this, player);
- +
- if (i_data)
- i_data->OnPlayerLeave(player);
- @@ -982,6 +995,11 @@ void Map::AddObjectToRemoveList(WorldObject* obj)
- {
- MANGOS_ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
- + if (Creature* creature = obj->ToCreature())
- + sEluna->OnRemove(creature);
- + else if (GameObject* gameobject = obj->ToGameObject())
- + sEluna->OnRemove(gameobject);
- +
- obj->CleanupsBeforeDelete(); // remove or simplify at least cross referenced links
- i_objectsToRemove.insert(obj);
- diff --git a/src/game/Map.h b/src/game/Map.h
- index 0c2e77e..b2aea60 100644
- --- a/src/game/Map.h
- +++ b/src/game/Map.h
- @@ -191,6 +191,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
- // NOTE: this duplicate of Instanceable(), but Instanceable() can be changed when BG also will be instanceable
- bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); }
- bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); }
- + bool IsHeroic() const { return IsRaid() ? i_spawnMode >= RAID_DIFFICULTY_10MAN_HEROIC : i_spawnMode >= DUNGEON_DIFFICULTY_HEROIC; }
- bool IsNonRaidDungeon() const { return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); }
- bool IsRaidOrHeroicDungeon() const { return IsRaid() || GetDifficulty() > DUNGEON_DIFFICULTY_NORMAL; }
- bool IsBattleGround() const { return i_mapEntry && i_mapEntry->IsBattleGround(); }
- diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp
- index 2bdb6a7..46fc2a1 100644
- --- a/src/game/MiscHandler.cpp
- +++ b/src/game/MiscHandler.cpp
- @@ -42,6 +42,7 @@
- #include "Pet.h"
- #include "SocialMgr.h"
- #include "DBCEnums.h"
- +#include "LuaEngine.h"
- void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data)
- {
- @@ -62,6 +63,9 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data)
- DEBUG_LOG("HandleRepopRequestOpcode: got request after player %s(%d) was killed and before he was updated", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
- GetPlayer()->KillPlayer();
- }
- +
- + // Used by Eluna
- + sEluna->OnRepop(GetPlayer());
- // this is spirit release confirm?
- GetPlayer()->RemovePet(PET_SAVE_REAGENTS);
- diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp
- index 2f3717f..24af752 100644
- --- a/src/game/NPCHandler.cpp
- +++ b/src/game/NPCHandler.cpp
- @@ -34,6 +34,8 @@
- #include "Guild.h"
- #include "GuildMgr.h"
- #include "Chat.h"
- +#include "Item.h"
- +#include "LuaEngine.h"
- enum StableResultCode
- {
- @@ -392,6 +394,29 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data)
- if (!sScriptMgr.OnGossipSelect(_player, pGo, sender, action, code.empty() ? NULL : code.c_str()))
- _player->OnGossipSelect(pGo, gossipListId, menuId);
- }
- + else if (guid.IsItem())
- + {
- + Item* item = GetPlayer()->GetItemByGuid(guid);
- + if (!item)
- + {
- + DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", guid.GetString().c_str());
- + return;
- + }
- +
- + // Used by Eluna
- + sEluna->HandleGossipSelectOption(GetPlayer(), item, GetPlayer()->PlayerTalkClass->GossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GossipOptionAction(gossipListId), code);
- + }
- + else if (guid.IsPlayer())
- + {
- + if (GetPlayer()->GetGUIDLow() != guid || GetPlayer()->PlayerTalkClass->GetGossipMenu().GetMenuId() != menuId)
- + {
- + DEBUG_LOG("WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", guid.GetString().c_str());
- + return;
- + }
- +
- + // Used by Eluna
- + sEluna->HandleGossipSelectOption(GetPlayer(), menuId, GetPlayer()->PlayerTalkClass->GossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GossipOptionAction(gossipListId), code);
- + }
- }
- void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recv_data)
- diff --git a/src/game/Object.cpp b/src/game/Object.cpp
- index a39b808..576bd9a 100644
- --- a/src/game/Object.cpp
- +++ b/src/game/Object.cpp
- @@ -44,6 +44,7 @@
- #include "movement/packet_builder.h"
- #include "CreatureLinkingMgr.h"
- #include "Chat.h"
- +#include "LuaEngine.h"
- Object::Object()
- {
- @@ -59,6 +60,8 @@ Object::Object()
- Object::~Object()
- {
- + Eluna::RemoveRef(this);
- +
- if (IsInWorld())
- {
- ///- Do NOT call RemoveFromWorld here, if the object is a player it will crash
- @@ -677,6 +680,14 @@ void Object::SetUInt32Value(uint16 index, uint32 value)
- }
- }
- +void Object::UpdateUInt32Value(uint16 index, uint32 value)
- +{
- + MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
- +
- + m_uint32Values[index] = value;
- + m_changedValues[index] = true;
- +}
- +
- void Object::SetUInt64Value(uint16 index, const uint64& value)
- {
- MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
- @@ -944,6 +955,11 @@ WorldObject::WorldObject() :
- {
- }
- +WorldObject::~WorldObject()
- +{
- + Eluna::RemoveRef(this);
- +}
- +
- void WorldObject::CleanupsBeforeDelete()
- {
- RemoveFromWorld();
- @@ -1582,6 +1598,9 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
- if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
- ((Creature*)this)->AI()->JustSummoned(pCreature);
- +
- + if (Unit* summoner = ToUnit())
- + sEluna->OnSummoned(pCreature, summoner);
- // Creature Linking, Initial load is handled like respawn
- if (pCreature->IsLinkingEventTrigger())
- @@ -1591,6 +1610,28 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
- return pCreature;
- }
- +GameObject* WorldObject::SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime)
- +{
- + GameObject* pGameObj = new GameObject;
- +
- + Map *map = GetMap();
- +
- + if(!map)
- + return NULL;
- +
- + if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), id, map, GetPhaseMask(), x, y, z, angle))
- + {
- + delete pGameObj;
- + return NULL;
- + }
- +
- + pGameObj->SetRespawnTime(despwtime/IN_MILLISECONDS);
- +
- + map->Add(pGameObj);
- +
- + return pGameObj;
- +}
- +
- // how much space should be left in front of/ behind a mob that already uses a space
- #define OCCUPY_POS_DEPTH_FACTOR 1.8f
- diff --git a/src/game/Object.h b/src/game/Object.h
- index d1def09..fa89d70 100644
- --- a/src/game/Object.h
- +++ b/src/game/Object.h
- @@ -66,6 +66,7 @@ class WorldPacket;
- class UpdateData;
- class WorldSession;
- class Creature;
- +class GameObject;
- class Player;
- class Unit;
- class Group;
- @@ -216,8 +217,28 @@ class MANGOS_DLL_SPEC Object
- ObjectGuid const& GetGuidValue(uint16 index) const { return *reinterpret_cast<ObjectGuid const*>(&GetUInt64Value(index)); }
- + Player* ToPlayer() { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return NULL; }
- + Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player const*>(this); else return NULL; }
- +
- + Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; }
- + Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature const*>(this); else return NULL; }
- +
- + Unit* ToUnit() { if (isType(TYPEMASK_UNIT)) return reinterpret_cast<Unit*>(this); else return NULL; }
- + Unit const* ToUnit() const { if (isType(TYPEMASK_UNIT)) return reinterpret_cast<Unit const*>(this); else return NULL; }
- +
- + GameObject* ToGameObject() { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(this); else return NULL; }
- + GameObject const* ToGameObject() const { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject const*>(this); else return NULL; }
- +
- + Corpse* ToCorpse() { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse*>(this); else return NULL; }
- + Corpse const* ToCorpse() const { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse const*>(this); else return NULL; }
- +
- + DynamicObject* ToDynObject() { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject*>(this); else return NULL; }
- + DynamicObject const* ToDynObject() const { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject const*>(this); else return NULL; }
- +
- +
- void SetInt32Value(uint16 index, int32 value);
- void SetUInt32Value(uint16 index, uint32 value);
- + void UpdateUInt32Value(uint16 index, uint32 value);
- void SetUInt64Value(uint16 index, const uint64& value);
- void SetFloatValue(uint16 index, float value);
- void SetByteValue(uint16 index, uint8 offset, uint8 value);
- @@ -435,7 +456,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
- WorldObject* const m_obj;
- };
- - virtual ~WorldObject() {}
- + virtual ~WorldObject();
- virtual void Update(uint32 /*update_diff*/, uint32 /*time_diff*/) {}
- @@ -604,7 +625,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
- void BuildUpdateData(UpdateDataMapType&) override;
- Creature* SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject = false);
- -
- + GameObject* SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime);
- +
- bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); }
- void SetActiveObjectState(bool active);
- diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
- index 17b7310..18d9d64 100755
- --- a/src/game/ObjectMgr.cpp
- +++ b/src/game/ObjectMgr.cpp
- @@ -223,6 +223,17 @@ ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(ObjectGuid guid) const
- return NULL;
- }
- +void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)
- +{
- + if (!s.empty())
- + {
- + if (data.size() <= size_t(locale))
- + data.resize(locale + 1);
- +
- + data[locale] = s;
- + }
- +}
- +
- void ObjectMgr::LoadCreatureLocales()
- {
- mCreatureLocaleMap.clear(); // need for reload case
- @@ -6933,11 +6944,15 @@ void ObjectMgr::LoadNPCSpellClickSpells()
- continue;
- }
- - SpellEntry const* spellinfo = sSpellStore.LookupEntry(info.spellId);
- - if (!spellinfo)
- + // spell can be 0 for special or custom cases
- + if(info.spellId)
- {
- - sLog.outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", info.spellId);
- - continue;
- + SpellEntry const* spellinfo = sSpellStore.LookupEntry(info.spellId);
- + if (!spellinfo)
- + {
- + sLog.outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", info.spellId);
- + continue;
- + }
- }
- if (info.conditionId && !sConditionStorage.LookupEntry<PlayerCondition const*>(info.conditionId))
- diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h
- index 31077b1..910e7fc 100755
- --- a/src/game/ObjectMgr.h
- +++ b/src/game/ObjectMgr.h
- @@ -117,7 +117,7 @@ typedef UNORDERED_MAP < uint32/*(mapid,spawnMode) pair*/, CellObjectGuidsMap > M
- // mangos string ranges
- #define MIN_MANGOS_STRING_ID 1 // 'mangos_string'
- -#define MAX_MANGOS_STRING_ID 2001000000
- +#define MAX_MANGOS_STRING_ID 2000000000
- #define MIN_DB_SCRIPT_STRING_ID MAX_MANGOS_STRING_ID // 'db_script_string'
- #define MAX_DB_SCRIPT_STRING_ID 2000010000
- #define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts'
- @@ -1043,6 +1043,13 @@ class ObjectMgr
- bool RemoveVendorItem(uint32 entry, uint32 item);
- bool IsVendorItemValid(bool isTemplate, char const* tableName, uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, uint16 conditionId, Player* pl = NULL, std::set<uint32>* skip_vendors = NULL) const;
- + static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
- + static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
- + {
- + if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
- + value = data[loc_idx];
- + }
- +
- int GetOrNewIndexForLocale(LocaleConstant loc);
- SpellClickInfoMapBounds GetSpellClickInfoMapBounds(uint32 creature_id) const
- diff --git a/src/game/Player.cpp b/src/game/Player.cpp
- index 88f4770..1806730 100644
- --- a/src/game/Player.cpp
- +++ b/src/game/Player.cpp
- @@ -66,6 +66,7 @@
- #include "SQLStorages.h"
- #include "Vehicle.h"
- #include "Calendar.h"
- +#include "LuaEngine.h"
- #include <cmath>
- @@ -569,6 +570,8 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
- Player::~Player()
- {
- + Eluna::RemoveRef(this);
- +
- CleanupsBeforeDelete();
- // it must be unloaded already in PlayerLogout and accessed only for loggined player
- @@ -1339,6 +1342,9 @@ void Player::Update(uint32 update_diff, uint32 p_time)
- if (!m_regenTimer)
- RegenerateAll();
- }
- +
- + if(!isAlive() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) && getDeathState() != GHOULED)
- + SetHealth(0);
- if (m_deathState == JUST_DIED)
- KillPlayer();
- @@ -1348,6 +1354,9 @@ void Player::Update(uint32 update_diff, uint32 p_time)
- if (update_diff >= m_nextSave)
- {
- // m_nextSave reseted in SaveToDB call
- + // Used by Eluna
- + sEluna->OnSave(this);
- +
- SaveToDB();
- DETAIL_LOG("Player '%s' (GUID: %u) saved", GetName(), GetGUIDLow());
- }
- @@ -1388,7 +1397,7 @@ void Player::Update(uint32 update_diff, uint32 p_time)
- }
- // Not auto-free ghost from body in instances
- - if (m_deathTimer > 0 && !GetMap()->Instanceable())
- + if (m_deathTimer > 0 && !GetMap()->Instanceable() && getDeathState() != GHOULED)
- {
- if (p_time >= m_deathTimer)
- {
- @@ -2455,6 +2464,9 @@ void Player::GiveXP(uint32 xp, Unit* victim)
- return;
- uint32 level = getLevel();
- +
- + // Used by Eluna
- + sEluna->OnGiveXP(this, xp, victim);
- // XP to money conversion processed in Player::RewardQuest
- if (level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL))
- @@ -2502,6 +2514,8 @@ void Player::GiveXP(uint32 xp, Unit* victim)
- // Current player experience not update (must be update by caller)
- void Player::GiveLevel(uint32 level)
- {
- + uint8 oldLevel = getLevel();
- +
- if (level == getLevel())
- return;
- @@ -2573,6 +2587,16 @@ void Player::GiveLevel(uint32 level)
- MailDraft(mailReward->mailTemplateId).SendMailTo(this, MailSender(MAIL_CREATURE, mailReward->senderEntry));
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
- +
- + // Used by Eluna
- + sEluna->OnLevelChanged(this, oldLevel);
- +}
- +
- +void Player::SetFreeTalentPoints(uint32 points)
- +{
- + // Used by Eluna
- + sEluna->OnFreeTalentPointsChanged(this, points);
- + SetUInt32Value(PLAYER_CHARACTER_POINTS1, points);
- }
- void Player::UpdateFreeTalentPoints(bool resetIfNeed)
- @@ -3712,6 +3736,9 @@ uint32 Player::resetTalentsCost() const
- bool Player::resetTalents(bool no_cost, bool all_specs)
- {
- + // Used by Eluna
- + sEluna->OnTalentsReset(this, no_cost);
- +
- // not need after this call
- if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs)
- RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS, true);
- @@ -4024,6 +4051,12 @@ bool Player::HasSpell(uint32 spell) const
- !itr->second.disabled);
- }
- +bool Player::HasTalent(uint32 spell, uint8 spec) const
- +{
- + PlayerTalentMap::const_iterator itr = m_talents[spec].find(spell);
- + return (itr != m_talents[spec].end() && itr->second.state != PLAYERSPELL_REMOVED);
- +}
- +
- bool Player::HasActiveSpell(uint32 spell) const
- {
- PlayerSpellMap::const_iterator itr = m_spells.find(spell);
- @@ -4413,7 +4446,8 @@ void Player::BuildPlayerRepop()
- GetMap()->Add(corpse);
- // convert player body to ghost
- - SetHealth(1);
- + if(getDeathState() != GHOULED)
- + SetHealth(1);
- SetWaterWalk(true);
- if (!GetSession()->isLogingOut())
- @@ -4422,7 +4456,8 @@ void Player::BuildPlayerRepop()
- // BG - remove insignia related
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
- - SendCorpseReclaimDelay();
- + if(getDeathState() != GHOULED)
- + SendCorpseReclaimDelay();
- // to prevent cheating
- corpse->ResetGhostTime();
- @@ -4476,6 +4511,8 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
- m_camera.UpdateVisibilityForOwner();
- // update visibility of player for nearby cameras
- UpdateObjectVisibility();
- +
- + sEluna->OnResurrect(this);
- if (!applySickness)
- return;
- @@ -6344,6 +6381,9 @@ void Player::RewardReputation(Unit* pVictim, float rate)
- {
- if (!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER)
- return;
- +
- + if (((Creature*)pVictim)->IsReputationGainDisabled())
- + return;
- // used current difficulty creature entry instead normal version (GetEntry())
- ReputationOnKillEntry const* Rep = sObjectMgr.GetReputationOnKillEntry(((Creature*)pVictim)->GetCreatureInfo()->Entry);
- @@ -6814,6 +6854,9 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
- }
- }
- + // Used by Eluna
- + sEluna->OnUpdateZone(this, newZone, newArea);
- +
- m_zoneUpdateId = newZone;
- m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;
- @@ -6945,6 +6988,9 @@ void Player::DuelComplete(DuelCompleteType type)
- data << GetName();
- SendMessageToSet(&data, true);
- }
- +
- + // Used by Eluna
- + sEluna->OnDuelEnd(duel->opponent, this, type);
- if (type == DUEL_WON)
- {
- @@ -11131,6 +11177,9 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
- pItem2->SetState(ITEM_CHANGED, this);
- ApplyEquipCooldown(pItem2);
- +
- + // Used by Eluna
- + sEluna->OnEquip(this, pItem2, bag, slot);
- return pItem2;
- }
- @@ -11142,6 +11191,9 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update)
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
- GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, slot + 1);
- + // Used by Eluna
- + sEluna->OnEquip(this, pItem, bag, slot);
- +
- return pItem;
- }
- @@ -11369,6 +11421,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
- ApplyItemOnStoreSpell(pItem, false);
- ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
- + sEluna->OnRemove(this, pItem);
- if (bag == INVENTORY_SLOT_BAG_0)
- {
- @@ -14982,8 +15035,10 @@ void Player::SendQuestCompleteEvent(uint32 quest_id)
- }
- }
- -void Player::SendQuestReward(Quest const* pQuest, uint32 XP, Object* /*questGiver*/)
- +void Player::SendQuestReward(Quest const* pQuest, uint32 XP, Object* questGiver)
- {
- + Player* pPlayer = m_session->GetPlayer();
- +
- uint32 questid = pQuest->GetQuestId();
- DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid);
- WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4 + 4 + 4 + 4 + 4));
- @@ -15004,6 +15059,13 @@ void Player::SendQuestReward(Quest const* pQuest, uint32 XP, Object* /*questGive
- data << uint32(pQuest->GetBonusTalents()); // bonus talents
- data << uint32(0); // arena points
- GetSession()->SendPacket(&data);
- +
- + // Used by Eluna
- + if (Creature* pCreature = questGiver->ToCreature())
- + sEluna->OnQuestComplete(pPlayer, pCreature, pQuest);
- +
- + if (GameObject* pGameObject = questGiver->ToGameObject())
- + sEluna->OnQuestComplete(pPlayer, pGameObject, pQuest);
- }
- void Player::SendQuestFailed(uint32 quest_id, InventoryResult reason)
- @@ -16849,6 +16911,9 @@ InstancePlayerBind* Player::BindToInstance(DungeonPersistentState* state, bool p
- if (!load)
- DEBUG_LOG("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d",
- GetName(), GetGUIDLow(), state->GetMapId(), state->GetInstanceId(), state->GetDifficulty());
- +
- + // Used by Eluna
- + sEluna->OnBindToInstance(this, state->GetDifficulty(), state->GetMapId(), permanent);
- return &bind;
- }
- else
- @@ -18174,6 +18239,9 @@ void Player::UpdateDuelFlag(time_t currTime)
- {
- if (!duel || duel->startTimer == 0 || currTime < duel->startTimer + 3)
- return;
- +
- + // Used by Eluna
- + sEluna->OnDuelStart(this, duel->opponent);
- SetUInt32Value(PLAYER_DUEL_TEAM, 1);
- duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 2);
- @@ -22747,6 +22815,21 @@ void Player::UpdateSpecCount(uint8 count)
- SendTalentsInfoData(false);
- }
- +void Player::ModifyMoney(int32 d)
- +{
- + // Used by Eluna
- + sEluna->OnMoneyChanged(this, d);
- +
- + if (d < 0)
- + SetMoney(GetMoney() > uint32(-d) ? GetMoney() + d : 0);
- + else
- + SetMoney(GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
- +
- + // "At Gold Limit"
- + if (GetMoney() >= MAX_MONEY_AMOUNT)
- + SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL);
- +}
- +
- void Player::RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also /*= false*/)
- {
- m_atLoginFlags &= ~f;
- diff --git a/src/game/Player.h b/src/game/Player.h
- index 44b127b..200b40f 100644
- --- a/src/game/Player.h
- +++ b/src/game/Player.h
- @@ -1035,6 +1035,7 @@ class MANGOS_DLL_SPEC Player : public Unit
- bool IsInWater() const override { return m_isInWater; }
- bool IsUnderWater() const override;
- + bool IsFalling() { return GetPositionZ() < m_lastFallZ; }
- void SendInitialPacketsBeforeAddToMap();
- void SendInitialPacketsAfterAddToMap();
- @@ -1463,17 +1464,8 @@ class MANGOS_DLL_SPEC Player : public Unit
- void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;}
- uint32 GetMoney() const { return GetUInt32Value(PLAYER_FIELD_COINAGE); }
- - void ModifyMoney(int32 d)
- - {
- - if (d < 0)
- - SetMoney(GetMoney() > uint32(-d) ? GetMoney() + d : 0);
- - else
- - SetMoney(GetMoney() < uint32(MAX_MONEY_AMOUNT - d) ? GetMoney() + d : MAX_MONEY_AMOUNT);
- -
- - // "At Gold Limit"
- - if (GetMoney() >= MAX_MONEY_AMOUNT)
- - SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL);
- - }
- + void ModifyMoney(int32 d);
- +
- void SetMoney(uint32 value)
- {
- SetUInt32Value(PLAYER_FIELD_COINAGE, value);
- @@ -1561,7 +1553,7 @@ class MANGOS_DLL_SPEC Player : public Unit
- void learnSpellHighRank(uint32 spellid);
- uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
- - void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1, points); }
- + void SetFreeTalentPoints(uint32 points);
- void UpdateFreeTalentPoints(bool resetIfNeed = true);
- bool resetTalents(bool no_cost = false, bool all_specs = false);
- uint32 resetTalentsCost() const;
- @@ -1571,7 +1563,8 @@ class MANGOS_DLL_SPEC Player : public Unit
- void SendTalentsInfoData(bool pet);
- void LearnTalent(uint32 talentId, uint32 talentRank);
- void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank);
- -
- + bool HasTalent(uint32 spell_id, uint8 spec) const;
- +
- uint32 CalculateTalentsPoints() const;
- // Dual Spec
- @@ -1893,6 +1886,7 @@ class MANGOS_DLL_SPEC Player : public Unit
- static Team TeamForRace(uint8 race);
- Team GetTeam() const { return m_team; }
- + TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
- static uint32 getFactionForRace(uint8 race);
- void setFactionForRace(uint8 race);
- diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp
- index fcbc93d..19dba86 100644
- --- a/src/game/QuestHandler.cpp
- +++ b/src/game/QuestHandler.cpp
- @@ -29,6 +29,7 @@
- #include "ObjectAccessor.h"
- #include "ScriptMgr.h"
- #include "Group.h"
- +#include "LuaEngine.h"
- void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPacket& recv_data)
- {
- @@ -344,6 +345,9 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
- }
- _player->SetQuestStatus(quest, QUEST_STATUS_NONE);
- +
- + // Used by Eluna
- + sEluna->OnQuestAbandon(_player, quest);
- }
- _player->SetQuestSlot(slot, 0);
- diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp
- index db07c2f..c194834 100644
- --- a/src/game/ReputationMgr.cpp
- +++ b/src/game/ReputationMgr.cpp
- @@ -21,6 +21,7 @@
- #include "Player.h"
- #include "WorldPacket.h"
- #include "ObjectMgr.h"
- +#include "LuaEngine.h"
- const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000};
- @@ -233,6 +234,9 @@ void ReputationMgr::Initialize()
- void ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
- {
- + // Used by Eluna
- + sEluna->OnReputationChange(m_player, factionEntry->ID, standing, incremental);
- +
- bool anyRankIncreased = false;
- // if spillover definition exists in DB, override DBC
- diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp
- index 6bb2706..fb210d4 100644
- --- a/src/game/ScriptMgr.cpp
- +++ b/src/game/ScriptMgr.cpp
- @@ -31,6 +31,7 @@
- #include "BattleGround/BattleGround.h"
- #include "OutdoorPvP/OutdoorPvP.h"
- #include "WaypointMovementGenerator.h"
- +#include "LuaEngine.h"
- #include "revision_nr.h"
- @@ -73,6 +74,7 @@ ScriptMgr::ScriptMgr() :
- m_pOnGOUse(NULL),
- m_pOnItemUse(NULL),
- m_pOnAreaTrigger(NULL),
- + m_pOnNpcSpellClick(NULL),
- m_pOnProcessEvent(NULL),
- m_pOnEffectDummyCreature(NULL),
- m_pOnEffectDummyGO(NULL),
- @@ -1988,6 +1990,10 @@ char const* ScriptMgr::GetScriptLibraryVersion() const
- CreatureAI* ScriptMgr::GetCreatureAI(Creature* pCreature)
- {
- + // Used by Eluna
- + if (CreatureAI* luaAI = sEluna->GetAI(pCreature))
- + return luaAI;
- +
- if (!m_pGetCreatureAI)
- return NULL;
- @@ -2004,17 +2010,38 @@ InstanceData* ScriptMgr::CreateInstanceData(Map* pMap)
- bool ScriptMgr::OnGossipHello(Player* pPlayer, Creature* pCreature)
- {
- + // Used by Eluna
- + if (sEluna->OnGossipHello(pPlayer, pCreature))
- + return true;
- +
- return m_pOnGossipHello != NULL && m_pOnGossipHello(pPlayer, pCreature);
- }
- bool ScriptMgr::OnGossipHello(Player* pPlayer, GameObject* pGameObject)
- {
- + // Used by Eluna
- + if (sEluna->OnGossipHello(pPlayer, pGameObject))
- + return true;
- +
- return m_pOnGOGossipHello != NULL && m_pOnGOGossipHello(pPlayer, pGameObject);
- }
- bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action, const char* code)
- {
- if (code)
- + {
- + // Used by Eluna
- + if (sEluna->OnGossipSelectCode(pPlayer, pCreature, sender, action, code))
- + return true;
- + }
- + else
- + {
- + // Used by Eluna
- + if (sEluna->OnGossipSelect(pPlayer, pCreature, sender, action))
- + return true;
- + }
- +
- + if (code)
- return m_pOnGossipSelectWithCode != NULL && m_pOnGossipSelectWithCode(pPlayer, pCreature, sender, action, code);
- else
- return m_pOnGossipSelect != NULL && m_pOnGossipSelect(pPlayer, pCreature, sender, action);
- @@ -2023,6 +2050,15 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 send
- bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 sender, uint32 action, const char* code)
- {
- if (code)
- + {
- + if (sEluna->OnGossipSelectCode(pPlayer, pGameObject, sender, action, code))
- + return true;
- + }
- + else
- + if (sEluna->OnGossipSelect(pPlayer, pGameObject, sender, action))
- + return true;
- +
- + if (code)
- return m_pOnGOGossipSelectWithCode != NULL && m_pOnGOGossipSelectWithCode(pPlayer, pGameObject, sender, action, code);
- else
- return m_pOnGOGossipSelect != NULL && m_pOnGOGossipSelect(pPlayer, pGameObject, sender, action);
- @@ -2030,31 +2066,55 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32
- bool ScriptMgr::OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
- {
- + // used by eluna
- + if (sEluna->OnQuestAccept(pPlayer, pCreature, pQuest))
- + return true;
- +
- return m_pOnQuestAccept != NULL && m_pOnQuestAccept(pPlayer, pCreature, pQuest);
- }
- bool ScriptMgr::OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest)
- {
- + // used by eluna
- + if (sEluna->OnQuestAccept(pPlayer, pGameObject, pQuest))
- + return true;
- +
- return m_pOnGOQuestAccept != NULL && m_pOnGOQuestAccept(pPlayer, pGameObject, pQuest);
- }
- bool ScriptMgr::OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest)
- {
- + // used by eluna
- + if (sEluna->OnQuestAccept(pPlayer, pItem, pQuest))
- + return true;
- +
- return m_pOnItemQuestAccept != NULL && m_pOnItemQuestAccept(pPlayer, pItem, pQuest);
- }
- bool ScriptMgr::OnQuestRewarded(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
- {
- + // used by eluna
- + if (sEluna->OnQuestReward(pPlayer, pCreature, pQuest))
- + return true;
- +
- return m_pOnQuestRewarded != NULL && m_pOnQuestRewarded(pPlayer, pCreature, pQuest);
- }
- bool ScriptMgr::OnQuestRewarded(Player* pPlayer, GameObject* pGameObject, Quest const* pQuest)
- {
- + // used by eluna
- + if (sEluna->OnQuestReward(pPlayer, pGameObject, pQuest))
- + return true;
- +
- return m_pOnGOQuestRewarded != NULL && m_pOnGOQuestRewarded(pPlayer, pGameObject, pQuest);
- }
- uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, Creature* pCreature)
- {
- + // used by eluna
- + if (uint32 dialogId = sEluna->GetDialogStatus(pPlayer, pCreature))
- + return dialogId;
- +
- if (!m_pGetNPCDialogStatus)
- return DIALOG_STATUS_UNDEFINED;
- @@ -2063,6 +2123,10 @@ uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, Creature* pCreature)
- uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, GameObject* pGameObject)
- {
- + // used by eluna
- + if (uint32 dialogId = sEluna->GetDialogStatus(pPlayer, pGameObject))
- + return dialogId;
- +
- if (!m_pGetGODialogStatus)
- return DIALOG_STATUS_UNDEFINED;
- @@ -2076,14 +2140,27 @@ bool ScriptMgr::OnGameObjectUse(Player* pPlayer, GameObject* pGameObject)
- bool ScriptMgr::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
- {
- + // used by eluna
- + if(sEluna->OnUse(pPlayer, pItem, targets)) // says if (!sEluna... on cmangos repo..)
- + return true;
- +
- return m_pOnItemUse != NULL && m_pOnItemUse(pPlayer, pItem, targets);
- }
- bool ScriptMgr::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry)
- {
- + // used by eluna
- + if(sEluna->OnAreaTrigger(pPlayer, atEntry))
- + return true;
- +
- return m_pOnAreaTrigger != NULL && m_pOnAreaTrigger(pPlayer, atEntry);
- }
- +bool ScriptMgr::OnNpcSpellClick(Player* pPlayer, Creature* pClickedCreature, uint32 spellId)
- +{
- + return m_pOnNpcSpellClick != NULL && m_pOnNpcSpellClick(pPlayer, pClickedCreature, spellId);
- +}
- +
- bool ScriptMgr::OnProcessEvent(uint32 eventId, Object* pSource, Object* pTarget, bool isStart)
- {
- return m_pOnProcessEvent != NULL && m_pOnProcessEvent(eventId, pSource, pTarget, isStart);
- @@ -2091,16 +2168,28 @@ bool ScriptMgr::OnProcessEvent(uint32 eventId, Object* pSource, Object* pTarget,
- bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid)
- {
- + // used by eluna
- + if(sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget))
- + return true;
- +
- return m_pOnEffectDummyCreature != NULL && m_pOnEffectDummyCreature(pCaster, spellId, effIndex, pTarget, originalCasterGuid);
- }
- bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget, ObjectGuid originalCasterGuid)
- {
- + // used by eluna
- + if (sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget))
- + return true;
- +
- return m_pOnEffectDummyGO != NULL && m_pOnEffectDummyGO(pCaster, spellId, effIndex, pTarget, originalCasterGuid);
- }
- bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Item* pTarget, ObjectGuid originalCasterGuid)
- {
- + // used by eluna
- + if(sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget))
- + return true;
- +
- return m_pOnEffectDummyItem != NULL && m_pOnEffectDummyItem(pCaster, spellId, effIndex, pTarget, originalCasterGuid);
- }
- @@ -2164,6 +2253,7 @@ ScriptLoadResult ScriptMgr::LoadScriptLibrary(const char* libName)
- GET_SCRIPT_HOOK_PTR(m_pOnGOUse, "GOUse");
- GET_SCRIPT_HOOK_PTR(m_pOnItemUse, "ItemUse");
- GET_SCRIPT_HOOK_PTR(m_pOnAreaTrigger, "AreaTrigger");
- + GET_SCRIPT_HOOK_PTR(m_pOnNpcSpellClick, "NpcSpellClick");
- GET_SCRIPT_HOOK_PTR(m_pOnProcessEvent, "ProcessEvent");
- GET_SCRIPT_HOOK_PTR(m_pOnEffectDummyCreature, "EffectDummyCreature");
- GET_SCRIPT_HOOK_PTR(m_pOnEffectDummyGO, "EffectDummyGameObject");
- @@ -2218,6 +2308,7 @@ void ScriptMgr::UnloadScriptLibrary()
- m_pOnGOUse = NULL;
- m_pOnItemUse = NULL;
- m_pOnAreaTrigger = NULL;
- + m_pOnNpcSpellClick = NULL;
- m_pOnProcessEvent = NULL;
- m_pOnEffectDummyCreature = NULL;
- m_pOnEffectDummyGO = NULL;
- diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h
- index d3abdaf..715e29c 100644
- --- a/src/game/ScriptMgr.h
- +++ b/src/game/ScriptMgr.h
- @@ -509,6 +509,7 @@ class ScriptMgr
- bool OnGameObjectUse(Player* pPlayer, GameObject* pGameObject);
- bool OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets);
- bool OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry);
- + bool OnNpcSpellClick(Player* pPlayer, Creature* pClickedCreature, uint32 spellId);
- bool OnProcessEvent(uint32 eventId, Object* pSource, Object* pTarget, bool isStart);
- bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget, ObjectGuid originalCasterGuid);
- bool OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget, ObjectGuid originalCasterGuid);
- @@ -563,6 +564,7 @@ class ScriptMgr
- bool (MANGOS_IMPORT* m_pOnGOUse)(Player*, GameObject*);
- bool (MANGOS_IMPORT* m_pOnItemUse)(Player*, Item*, SpellCastTargets const&);
- bool (MANGOS_IMPORT* m_pOnAreaTrigger)(Player*, AreaTriggerEntry const*);
- + bool (MANGOS_IMPORT* m_pOnNpcSpellClick)(Player*, Creature*, uint32);
- bool (MANGOS_IMPORT* m_pOnProcessEvent)(uint32, Object*, Object*, bool);
- bool (MANGOS_IMPORT* m_pOnEffectDummyCreature)(Unit*, uint32, SpellEffectIndex, Creature*, ObjectGuid);
- bool (MANGOS_IMPORT* m_pOnEffectDummyGO)(Unit*, uint32, SpellEffectIndex, GameObject*, ObjectGuid);
- diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
- index 74652e7..50d902a 100644
- --- a/src/game/SharedDefines.h
- +++ b/src/game/SharedDefines.h
- @@ -22,6 +22,9 @@
- #include "Platform/Define.h"
- #include <cassert>
- +#define MANGOS
- +#define WOTLK
- +
- enum Gender
- {
- GENDER_MALE = 0,
- @@ -155,6 +158,7 @@ enum Powers
- POWER_HAPPINESS = 4,
- POWER_RUNE = 5,
- POWER_RUNIC_POWER = 6,
- + POWER_ALL = 127,
- POWER_HEALTH = 0xFFFFFFFE // (-2 as signed value)
- };
- @@ -604,6 +608,13 @@ enum Language
- #define LANGUAGES_COUNT 19
- +enum TeamId
- +{
- + TEAM_ALLIANCE = 0,
- + TEAM_HORDE,
- + TEAM_NEUTRAL
- +};
- +
- // In fact !=0 values is alliance/horde root faction ids
- enum Team
- {
- @@ -757,7 +768,7 @@ enum SpellEffects
- SPELL_EFFECT_LEAP_BACK = 138,
- SPELL_EFFECT_CLEAR_QUEST = 139,
- SPELL_EFFECT_FORCE_CAST = 140,
- - SPELL_EFFECT_141 = 141,
- + SPELL_EFFECT_FORCE_CAST_WITH_VALUE = 141,
- SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE = 142,
- SPELL_EFFECT_APPLY_AREA_AURA_OWNER = 143,
- SPELL_EFFECT_KNOCKBACK_FROM_POSITION = 144,
- diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
- index a1603f6..1f5a756 100644
- --- a/src/game/Spell.cpp
- +++ b/src/game/Spell.cpp
- @@ -47,6 +47,7 @@
- #include "Vehicle.h"
- #include "TemporarySummon.h"
- #include "SQLStorages.h"
- +#include "LuaEngine.h"
- extern pEffect SpellEffects[TOTAL_SPELL_EFFECTS];
- @@ -419,6 +420,7 @@ Spell::Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid or
- Spell::~Spell()
- {
- + Eluna::RemoveRef(this);
- }
- template<typename T>
- @@ -3326,6 +3328,9 @@ void Spell::cast(bool skipCheck)
- ((Player*)m_caster)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM, m_CastItem->GetEntry());
- ((Player*)m_caster)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, m_spellInfo->Id);
- +
- + // used by eluna
- + sEluna->OnSpellCast(m_caster->ToPlayer(), this, skipCheck);
- }
- FillTargetMap();
- @@ -7677,6 +7682,7 @@ void Spell::GetSpellRangeAndRadius(SpellEffectIndex effIndex, float& radius, uin
- case 44869: // Spectral Blast (SWP, Kalecgos)
- case 45391: // Summon Demonic Vapor (SWP, Felmyst)
- case 45785: // Sinister Reflection Clone (SWP, Kil'jaeden)
- + case 45863: // Cosmetic - Incinerate to Random Target (Borean Tundra)
- case 45892: // Sinister Reflection (SWP, Kil'jaeden)
- case 45976: // Open Portal (SWP, M'uru)
- case 46372: // Ice Spear Target Picker (Slave Pens, Ahune)
- diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h
- index e24cb1b..ffa57e3 100644
- --- a/src/game/SpellAuraDefines.h
- +++ b/src/game/SpellAuraDefines.h
- @@ -385,7 +385,7 @@ enum AuraType
- SPELL_AURA_MOD_EXPERTISE = 240,
- SPELL_AURA_FORCE_MOVE_FORWARD = 241,
- SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING = 242,
- - SPELL_AURA_243 = 243,
- + SPELL_AURA_FACTION_OVERRIDE = 243,
- SPELL_AURA_COMPREHEND_LANGUAGE = 244,
- SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS = 245,
- SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL = 246,
- @@ -421,7 +421,7 @@ enum AuraType
- SPELL_AURA_276 = 276, // Only "Test Mod Damage % Mechanic" spell, possible mod damage done
- SPELL_AURA_MOD_MAX_AFFECTED_TARGETS = 277,
- SPELL_AURA_MOD_DISARM_RANGED = 278,
- - SPELL_AURA_279 = 279,
- + SPELL_AURA_MIRROR_NAME = 279,
- SPELL_AURA_MOD_TARGET_ARMOR_PCT = 280,
- SPELL_AURA_MOD_HONOR_GAIN = 281,
- SPELL_AURA_MOD_BASE_HEALTH_PCT = 282,
- diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
- index 98d99c7..a0d43c5 100644
- --- a/src/game/SpellAuras.cpp
- +++ b/src/game/SpellAuras.cpp
- @@ -48,6 +48,7 @@
- #include "CellImpl.h"
- #include "Language.h"
- #include "MapManager.h"
- +#include "LuaEngine.h"
- #define NULL_AURA_SLOT 0xFF
- @@ -300,7 +301,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS] =
- &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE
- &Aura::HandleForceMoveForward, //241 Forces the caster to move forward
- &Aura::HandleUnused, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING (only 2 test spels in 3.2.2a)
- - &Aura::HandleNULL, //243 faction reaction override spells
- + &Aura::HandleFactionOverride, //243 SPELL_AURA_FACTION_OVERRIDE
- &Aura::HandleComprehendLanguage, //244 SPELL_AURA_COMPREHEND_LANGUAGE
- &Aura::HandleNoImmediateEffect, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS implemented in Unit::CalculateAuraDuration
- &Aura::HandleNoImmediateEffect, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL implemented in Unit::CalculateAuraDuration
- @@ -336,7 +337,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS] =
- &Aura::HandleNULL, //276 mod damage % mechanic?
- &Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
- &Aura::HandleAuraModDisarm, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
- - &Aura::HandleNULL, //279 visual effects? 58836 and 57507
- + &Aura::HandleMirrorName, //279 SPELL_AURA_MIRROR_NAME target receives the casters name
- &Aura::HandleModTargetArmorPct, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
- &Aura::HandleNoImmediateEffect, //281 SPELL_AURA_MOD_HONOR_GAIN implemented in Player::RewardHonor
- &Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
- @@ -444,6 +445,7 @@ Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBas
- Aura::~Aura()
- {
- + Eluna::RemoveRef(this);
- }
- AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target,
- @@ -1106,8 +1108,9 @@ void Aura::TriggerSpell()
- // // Polymorphic Ray
- // case 6965: break;
- case 9712: // Thaumaturgy Channel
- - trigger_spell_id = 21029;
- - break;
- + if (Unit* caster = GetCaster())
- + caster->CastSpell(caster, 21029, true);
- + return;
- // // Egan's Blaster
- // case 17368: break;
- // // Haunted
- @@ -8373,9 +8376,19 @@ void Aura::PeriodicDummyTick()
- }
- case SPELLFAMILY_MAGE:
- {
- - // Mirror Image
- -// if (spell->Id == 55342)
- -// return;
- + switch (spell->Id)
- + {
- + case 55342: // Mirror Image
- + {
- + if (GetAuraTicks() != 1)
- + return;
- + if (Unit* pCaster = GetCaster())
- + pCaster->CastSpell(pCaster, spell->EffectTriggerSpell[GetEffIndex()], true, NULL, this);
- + return;
- + }
- + default:
- + break;
- + }
- break;
- }
- case SPELLFAMILY_DRUID:
- @@ -8737,6 +8750,29 @@ void Aura::HandleAuraMirrorImage(bool apply, bool Real)
- }
- }
- +void Aura::HandleMirrorName(bool apply, bool Real)
- +{
- + if (!Real)
- + return;
- +
- + Unit* caster = GetCaster();
- + Unit* target = GetTarget();
- +
- + if (!target || !caster || target->GetTypeId() != TYPEID_UNIT)
- + return;
- +
- + if (apply)
- + target->SetName(caster->GetName());
- + else
- + {
- + CreatureInfo const* cinfo = ((Creature*)target)->GetCreatureInfo();
- + if (!cinfo)
- + return;
- +
- + target->SetName(cinfo->Name);
- + }
- +}
- +
- void Aura::HandleAuraConvertRune(bool apply, bool Real)
- {
- if (!Real)
- @@ -8875,6 +8911,21 @@ void Aura::HandleAuraSetVehicleId(bool apply, bool Real)
- GetTarget()->SetVehicleId(apply ? GetMiscValue() : 0, 0);
- }
- +void Aura::HandleFactionOverride(bool apply, bool Real)
- +{
- + if (!Real)
- + return;
- +
- + Unit* target = GetTarget();
- + if (!target || !sFactionTemplateStore.LookupEntry(GetMiscValue()))
- + return;
- +
- + if (apply)
- + target->setFaction(GetMiscValue());
- + else
- + target->RestoreOriginalFaction();
- +}
- +
- bool Aura::IsLastAuraOnHolder()
- {
- for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
- @@ -9891,7 +9942,48 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply)
- switch (GetId())
- {
- case 49039: spellId1 = 50397; break; // Lichborne
- -
- + case 46619: // Raise ally
- + {
- + if (!m_target || m_target->GetTypeId() != TYPEID_PLAYER)
- + return;
- + Player* m_player = (Player*)m_target;
- + if (apply)
- + {
- + // turn player into ghoul
- + m_player->SetDeathState(GHOULED);
- + m_player->SetHealth(1);
- + m_player->SetRoot(true);
- + }
- + else
- + {
- + m_player->SetRoot(false);
- + m_player->SetHealth(0);
- + m_player->SetDeathState(JUST_DIED);
- + }
- + break;
- + }
- + case 48979: // Butchery, rank 1
- + case 49483: // Butchery, rank 2
- + {
- + if(GetId() == 48979) // rank 1
- + {
- + if (!m_target || m_target->getDeathState() != JUST_DIED)
- + return;
- + // give 10 runic power and
- + // cast spell for 2 runic power per 5 sec in combat
- +
- + m_target->ModifyPower(POWER_RUNIC_POWER, (int32)10);
- + }
- + else if(GetId() == 49483) // rank 2
- + {
- + if (!m_target || m_target->getDeathState() != JUST_DIED)
- + return;
- + // give 20 runic power and extra 2 runic power per 5 sec in combat
- +
- + m_target->ModifyPower(POWER_RUNIC_POWER, (int32)20);
- + }
- + break;
- + }
- case 48263: // Frost Presence
- case 48265: // Unholy Presence
- case 48266: // Blood Presence
- diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h
- index 653c05b..fd2f115 100644
- --- a/src/game/SpellAuras.h
- +++ b/src/game/SpellAuras.h
- @@ -409,6 +409,8 @@ class MANGOS_DLL_SPEC Aura
- void HandleAuraAddMechanicAbilities(bool apply, bool Real);
- void HandleAuraStopNaturalManaRegen(bool apply, bool Real);
- void HandleAuraSetVehicleId(bool apply, bool Real);
- + void HandleMirrorName(bool apply, bool Real);
- + void HandleFactionOverride(bool apply, bool Real);
- virtual ~Aura();
- diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
- index d55e749..50edb4e 100644
- --- a/src/game/SpellEffects.cpp
- +++ b/src/game/SpellEffects.cpp
- @@ -57,6 +57,7 @@
- #include "GridNotifiers.h"
- #include "GridNotifiersImpl.h"
- #include "CellImpl.h"
- +#include "LuaEngine.h"
- pEffect SpellEffects[TOTAL_SPELL_EFFECTS] =
- {
- @@ -201,7 +202,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS] =
- &Spell::EffectLeapBack, //138 SPELL_EFFECT_LEAP_BACK Leap back
- &Spell::EffectClearQuest, //139 SPELL_EFFECT_CLEAR_QUEST (misc - is quest ID)
- &Spell::EffectForceCast, //140 SPELL_EFFECT_FORCE_CAST
- - &Spell::EffectNULL, //141 SPELL_EFFECT_141 damage and reduce speed?
- + &Spell::EffectForceCast, //141 SPELL_EFFECT_FORCE_CAST_WITH_VALUE damage and reduce speed?
- &Spell::EffectTriggerSpellWithValue, //142 SPELL_EFFECT_TRIGGER_SPELL_WITH_VALUE
- &Spell::EffectApplyAreaAura, //143 SPELL_EFFECT_APPLY_AREA_AURA_OWNER
- &Spell::EffectKnockBackFromPosition, //144 SPELL_EFFECT_KNOCKBACK_FROM_POSITION
- @@ -1930,6 +1931,28 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
- return;
- }
- + case 46292: // Cataclysm Breath
- + {
- + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
- + return;
- +
- + uint32 spellId = 0;
- +
- + switch (urand(0,7))
- + {
- + case 0: spellId = 46293; break; // Corrosive Poison
- + case 1: spellId = 46294; break; // Fevered Fatigue
- + case 2: spellId = 46295; break; // Hex
- + case 3: spellId = 46296; break; // Necrotic Poison
- + case 4: spellId = 46297; break; // Piercing Shadow
- + case 5: spellId = 46298; break; // Shrink
- + case 6: spellId = 46299; break; // Wavering Will
- + case 7: spellId = 46300; break; // Withered Touch
- + }
- +
- + m_caster->CastSpell(unitTarget, spellId, true);
- + return;
- + }
- case 46372: // Ice Spear Target Picker
- {
- if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
- @@ -3685,6 +3708,34 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
- // Death Strike
- else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000010))
- {
- +
- + // Death Rune Mastery talents
- + if ((Player*)m_caster->HasSpell(49467))
- + {
- + // 33% chance
- + if (roll_chance_i(33))
- + {
- + for(uint8 i = 2; i <= 5; i++)
- + ((Player*)m_caster)->ConvertRune(i, RUNE_DEATH);
- + //((Player*)m_caster)->ConvertRune(2, RUNE_DEATH);
- + //((Player*)m_caster)->ConvertRune(4, RUNE_DEATH);
- + }
- + }
- + else if ((Player*)m_caster->HasSpell(50033))
- + {
- + // 66% chance
- + if (roll_chance_i(66))
- + {
- + for(uint8 i = 2; i <= 5; i++)
- + ((Player*)m_caster)->ConvertRune(i, RUNE_DEATH);
- + }
- + }
- + else if ((Player*)m_caster->HasSpell(50034))
- + {
- + for(uint8 i = 2; i <= 5; i++)
- + ((Player*)m_caster)->ConvertRune(i, RUNE_DEATH);
- + }
- +
- uint32 count = 0;
- Unit::SpellAuraHolderMap const& auras = unitTarget->GetSpellAuraHolderMap();
- for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
- @@ -3739,6 +3790,32 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
- // Obliterate
- else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0002000000000000))
- {
- +
- + // Death Rune Mastery talents
- + if ((Player*)m_caster->HasSpell(49467))
- + {
- + // 33% chance
- + if (roll_chance_i(33))
- + {
- + for(uint8 i = 2; i <= 5; i++)
- + ((Player*)m_caster)->ConvertRune(i, RUNE_DEATH);
- + }
- + }
- + else if ((Player*)m_caster->HasSpell(50033))
- + {
- + // 66% chance
- + if (roll_chance_i(66))
- + {
- + for(uint8 i = 2; i <= 5; i++)
- + ((Player*)m_caster)->ConvertRune(i, RUNE_DEATH);
- + }
- + }
- + else if ((Player*)m_caster->HasSpell(50034))
- + {
- + for(uint8 i = 2; i <= 5; i++)
- + ((Player*)m_caster)->ConvertRune(i, RUNE_DEATH);
- + }
- +
- // search for Annihilation
- Unit::AuraList const& dummyList = m_caster->GetAurasByType(SPELL_AURA_DUMMY);
- for (Unit::AuraList::const_iterator itr = dummyList.begin(); itr != dummyList.end(); ++itr)
- @@ -3868,7 +3945,13 @@ void Spell::EffectForceCast(SpellEffectIndex eff_idx)
- return;
- }
- - unitTarget->CastSpell(unitTarget, spellInfo, true, NULL, NULL, m_originalCasterGUID, m_spellInfo);
- + int32 basePoints = damage;
- +
- + // spell effect 141 has BasePoints greater than 1
- + if (basePoints > 1)
- + unitTarget->CastCustomSpell(unitTarget, spellInfo, &basePoints, &basePoints, &basePoints, true, NULL , NULL, m_originalCasterGUID, m_spellInfo);
- + else
- + unitTarget->CastSpell(unitTarget, spellInfo, true, NULL, NULL, m_originalCasterGUID, m_spellInfo);
- }
- void Spell::EffectTriggerSpell(SpellEffectIndex effIndex)
- @@ -3950,6 +4033,13 @@ void Spell::EffectTriggerSpell(SpellEffectIndex effIndex)
- }
- return;
- }
- + case 58832: // Mirror Image
- + {
- + // Glyph of Mirror Image
- + if (m_caster->HasAura(63093))
- + m_caster->CastSpell(m_caster, 65047, true, m_CastItem, NULL, m_originalCasterGUID);
- + break;
- + }
- }
- // normal case
- @@ -5322,6 +5412,13 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)
- ((Creature*)m_caster)->AI()->JustSummoned(itr->creature);
- if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI())
- ((Creature*)m_originalCaster)->AI()->JustSummoned(itr->creature);
- +
- + // used by eluna
- + if (Unit* summoner = m_caster->ToUnit())
- + sEluna->OnSummoned(itr->creature, summoner);
- + else if (m_originalCaster)
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(itr->creature, summoner);
- }
- }
- }
- @@ -5354,6 +5451,9 @@ bool Spell::DoSummonWild(CreatureSummonPositions& list, SummonPropertiesEntry co
- // Notify original caster if not done already
- if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI())
- ((Creature*)m_originalCaster)->AI()->JustSummoned(summon);
- +
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(summon, summoner);
- }
- else
- return false;
- @@ -5422,6 +5522,12 @@ bool Spell::DoSummonCritter(CreatureSummonPositions& list, SummonPropertiesEntry
- critter->SetDuration(m_duration);
- m_caster->SetMiniPet(critter);
- +
- + if (Unit* summoner = m_caster->ToUnit())
- + sEluna->OnSummoned(critter, summoner);
- + if (m_originalCaster)
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(critter, summoner);
- return true;
- }
- @@ -5495,6 +5601,12 @@ bool Spell::DoSummonGuardian(CreatureSummonPositions& list, SummonPropertiesEntr
- spawnCreature->GetCharmInfo()->SetPetNumber(pet_number, false);
- m_caster->AddGuardian(spawnCreature);
- +
- + if (Unit* summoner = m_caster->ToUnit())
- + sEluna->OnSummoned(spawnCreature, summoner);
- + if (m_originalCaster)
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(spawnCreature, summoner);
- }
- return true;
- @@ -5630,6 +5742,9 @@ bool Spell::DoSummonPossessed(CreatureSummonPositions& list, SummonPropertiesEnt
- if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI())
- ((Creature*)m_originalCaster)->AI()->JustSummoned(spawnCreature);
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(spawnCreature, summoner);
- +
- return true;
- }
- @@ -5724,6 +5839,12 @@ bool Spell::DoSummonPet(SpellEffectIndex eff_idx)
- if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI())
- ((Creature*)m_originalCaster)->AI()->JustSummoned((Creature*)spawnCreature);
- + if (Unit* summoner = m_caster->ToUnit())
- + sEluna->OnSummoned(spawnCreature, summoner);
- + if (m_originalCaster)
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(spawnCreature, summoner);
- +
- return false;
- }
- @@ -5773,6 +5894,10 @@ bool Spell::DoSummonVehicle(CreatureSummonPositions& list, SummonPropertiesEntry
- if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI())
- ((Creature*)m_originalCaster)->AI()->JustSummoned(spawnCreature);
- + if (m_originalCaster)
- + if (Unit* summoner = m_originalCaster->ToUnit())
- + sEluna->OnSummoned(spawnCreature, summoner);
- +
- return true;
- }
- @@ -7527,6 +7652,8 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
- return;
- }
- case 41055: // Copy Weapon
- + case 63416: // Copy Weapon
- + case 69891: // Copy Weapon (No Threat)
- {
- if (m_caster->GetTypeId() != TYPEID_UNIT || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
- return;
- @@ -7541,6 +7668,14 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
- return;
- }
- + case 41072: // Bloodbolt
- + {
- + if (!unitTarget)
- + return;
- +
- + m_caster->CastSpell(unitTarget, m_spellInfo->CalculateSimpleValue(eff_idx), true);
- + return;
- + }
- case 41126: // Flame Crash
- {
- if (!unitTarget)
- @@ -7549,6 +7684,17 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
- unitTarget->CastSpell(unitTarget, 41131, true);
- break;
- }
- + case 42281: // Sprouting
- + {
- + if (!unitTarget)
- + return;
- +
- + unitTarget->RemoveAurasDueToSpell(42280);
- + unitTarget->RemoveAurasDueToSpell(42294);
- + unitTarget->CastSpell(unitTarget, 42285, true);
- + unitTarget->CastSpell(unitTarget, 42291, true);
- + return;
- + }
- case 43365: // The Cleansing: Shrine Cast
- {
- if (m_caster->GetTypeId() != TYPEID_PLAYER)
- @@ -7730,6 +7876,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
- return;
- }
- case 45206: // Copy Off-hand Weapon
- + case 69892: // Copy Off-hand Weapon (No Threat)
- {
- if (m_caster->GetTypeId() != TYPEID_UNIT || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
- return;
- @@ -9404,6 +9551,59 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
- break;
- }
- + case 46584: // Raise dead
- + {
- + if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER)
- + return;
- +
- + // If DK has spell 52143, summon pet from dummy effect
- + // otherwise summon guardian
- + uint32 triggered_spell_id = m_spellInfo->CalculateSimpleValue(SpellEffectIndex(m_caster->HasSpell(52143) ? EFFECT_INDEX_2 : EFFECT_INDEX_1));
- +
- + float x,y,z;
- + m_caster->GetClosePoint(x, y, z, m_caster->GetObjectBoundingRadius(), PET_FOLLOW_DIST);
- +
- + if (unitTarget != (Unit*)m_caster)
- + m_caster->CastSpell(unitTarget->GetPositionX(),unitTarget->GetPositionY(),unitTarget->GetPositionZ(),triggered_spell_id, true, NULL, NULL, m_caster->GetObjectGuid(), m_spellInfo);
- + else if (m_caster->HasAura(60200))
- + m_caster->CastSpell(x,y,z,triggered_spell_id, true, NULL, NULL, m_caster->GetObjectGuid(), m_spellInfo);
- + else if (((Player*)m_caster)->HasItemCount(37201,1))
- + {
- + ((Player*)m_caster)->DestroyItemCount(37201, 1, true);
- + m_caster->CastSpell(m_caster,48289,true);
- + m_caster->CastSpell(x,y,z,triggered_spell_id, true, NULL, NULL, m_caster->GetObjectGuid(), m_spellInfo);
- + }
- + else
- + {
- + SendCastResult(SPELL_FAILED_REAGENTS);
- + finish(true);
- + CancelGlobalCooldown();
- + return;
- + }
- + finish(true);
- + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_2),true);
- + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_1),true);
- + //CancelGlobalCooldown();
- + return;
- + }
- + case 61999: // Raise ally
- + {
- + if (m_caster->GetTypeId() != TYPEID_PLAYER)
- + return;
- +
- + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->isAlive())
- + {
- + SendCastResult(SPELL_FAILED_TARGET_NOT_DEAD);
- + finish(true);
- + CancelGlobalCooldown();
- + return;
- + }
- +
- + // hacky remove death
- + unitTarget->CastSpell(unitTarget, m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_0), true);
- + CancelGlobalCooldown();
- + return;
- + }
- }
- break;
- }
- @@ -9534,6 +9734,9 @@ void Spell::EffectDuel(SpellEffectIndex eff_idx)
- caster->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetObjectGuid());
- target->SetGuidValue(PLAYER_DUEL_ARBITER, pGameObj->GetObjectGuid());
- +
- + // used by eluna
- + sEluna->OnDuelRequest(target, caster);
- }
- void Spell::EffectStuck(SpellEffectIndex /*eff_idx*/)
- @@ -10658,7 +10861,10 @@ void Spell::EffectWMODamage(SpellEffectIndex effIdx)
- {
- DEBUG_LOG("Effect: WMODamage");
- - if (!gameObjTarget || gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- + if (!gameObjTarget)
- + return;
- +
- + if (gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- {
- sLog.outError("Spell::EffectWMODamage called without valid targets. Spell Id %u", m_spellInfo->Id);
- return;
- @@ -10678,8 +10884,11 @@ void Spell::EffectWMODamage(SpellEffectIndex effIdx)
- void Spell::EffectWMORepair(SpellEffectIndex effIdx)
- {
- DEBUG_LOG("Effect: WMORepair");
- +
- + if (!gameObjTarget)
- + return;
- - if (!gameObjTarget || gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- + if (gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- {
- sLog.outError("Spell::EffectWMORepair called without valid targets. Spell Id %u", m_spellInfo->Id);
- return;
- @@ -10696,8 +10905,11 @@ void Spell::EffectWMORepair(SpellEffectIndex effIdx)
- void Spell::EffectWMOChange(SpellEffectIndex effIdx)
- {
- DEBUG_LOG("Effect: WMOChange");
- +
- + if (!gameObjTarget)
- + return;
- - if (!gameObjTarget || gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- + if (gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- {
- sLog.outError("Spell::EffectWMOChange called without valid targets. Spell Id %u", m_spellInfo->Id);
- return;
- diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp
- index 4e2afdd..8760a6f 100644
- --- a/src/game/SpellHandler.cpp
- +++ b/src/game/SpellHandler.cpp
- @@ -617,10 +617,16 @@ void WorldSession::HandleSpellClick(WorldPacket& recv_data)
- {
- if (itr->second.IsFitToRequirements(_player, unit))
- {
- + if (sScriptMgr.OnNpcSpellClick(_player, unit, itr->second.spellId))
- + return;
- +
- Unit* caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit;
- Unit* target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit;
- - caster->CastSpell(target, itr->second.spellId, true);
- + if (itr->second.spellId)
- + caster->CastSpell(target, itr->second.spellId, true);
- + else
- + sLog.outError("WorldSession::HandleSpellClick: npc_spell_click with entry %u has 0 in spell_id. Not handled custom case?", unit->GetEntry());
- }
- }
- }
- diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
- index b09b328..aea4bd7 100644
- --- a/src/game/Totem.cpp
- +++ b/src/game/Totem.cpp
- @@ -25,6 +25,7 @@
- #include "SpellMgr.h"
- #include "CreatureAI.h"
- #include "InstanceData.h"
- +#include "LuaEngine.h"
- Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
- {
- @@ -96,6 +97,7 @@ void Totem::Summon(Unit* owner)
- if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI())
- ((Creature*)owner)->AI()->JustSummoned((Creature*)this);
- + sEluna->OnSummoned(this, owner);
- // there are some totems, which exist just for their visual appeareance
- if (!GetSpell())
- diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
- index 24743d8..84148e5 100644
- --- a/src/game/Unit.cpp
- +++ b/src/game/Unit.cpp
- @@ -51,6 +51,7 @@
- #include "movement/MoveSplineInit.h"
- #include "movement/MoveSpline.h"
- #include "CreatureLinkingMgr.h"
- +#include "LuaEngine.h"
- #include <math.h>
- #include <stdarg.h>
- @@ -274,6 +275,8 @@ Unit::Unit() :
- Unit::~Unit()
- {
- + Eluna::RemoveRef(this);
- +
- // set current spells as deletable
- for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
- {
- @@ -802,6 +805,13 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
- // Call KilledUnit for creatures
- if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
- ((Creature*)this)->AI()->KilledUnit(pVictim);
- +
- + if (Creature* killer = ToCreature())
- + {
- + // used by eluna
- + if (Player* killed = pVictim->ToPlayer())
- + sEluna->OnPlayerKilledByCreature(killer, killed);
- + }
- // Call AI OwnerKilledUnit (for any current summoned minipet/guardian/protector)
- PetOwnerKilledUnit(pVictim);
- @@ -866,6 +876,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
- if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(playerVictim->GetCachedZoneId()))
- outdoorPvP->HandlePlayerKill(player_tap, playerVictim);
- }
- +
- + // used by eluna
- + sEluna->OnPVPKill(player_tap, playerVictim);
- }
- }
- else // Killed creature
- @@ -1062,8 +1075,14 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
- mapInstance->OnCreatureDeath(victim);
- if (responsiblePlayer) // killedby Player, inform BG
- + {
- if (BattleGround* bg = responsiblePlayer->GetBattleGround())
- bg->HandleKillUnit(victim, responsiblePlayer);
- +
- + // used by eluna
- + sEluna->OnCreatureKill(responsiblePlayer, victim);
- + }
- +
- // Notify the outdoor pvp script
- if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(responsiblePlayer ? responsiblePlayer->GetCachedZoneId() : GetZoneId()))
- outdoorPvP->HandleCreatureDeath(victim);
- @@ -7979,6 +7998,9 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
- if (PvP)
- m_CombatTimer = 5000;
- +
- + if (isInCombat())
- + return;
- bool creatureNotInCombat = GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
- @@ -8017,6 +8039,10 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
- if (m_isCreatureLinkingTrigger)
- GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_AGGRO, pCreature, enemy);
- }
- +
- + // used by eluna
- + if (GetTypeId() == TYPEID_PLAYER)
- + sEluna->OnPlayerEnterCombat(ToPlayer(), enemy);
- }
- void Unit::ClearInCombat()
- @@ -8026,6 +8052,9 @@ void Unit::ClearInCombat()
- if (isCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet()))
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
- +
- + if (GetTypeId() == TYPEID_PLAYER)
- + sEluna->OnPlayerLeaveCombat(ToPlayer());
- // Player's state will be cleared in Player::UpdateContestedPvP
- if (GetTypeId() == TYPEID_UNIT)
- @@ -10842,6 +10871,24 @@ void Unit::SetFFAPvP(bool state)
- CallForAllControlledUnits(SetFFAPvPHelper(state), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
- }
- +void Unit::RestoreOriginalFaction()
- +{
- + if (GetTypeId() == TYPEID_PLAYER)
- + ((Player*)this)->setFactionForRace(getRace());
- + else
- + {
- + Creature* creature = (Creature*)this;
- +
- + if (creature->IsPet() || creature->IsTotem())
- + {
- + if (Unit* owner = GetOwner())
- + setFaction(owner->getFaction());
- + }
- + else
- + setFaction(creature->GetCreatureInfo()->FactionAlliance);
- + }
- +}
- +
- void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpeed)
- {
- float angle = this == target ? GetOrientation() + M_PI_F : target->GetAngle(this);
- diff --git a/src/game/Unit.h b/src/game/Unit.h
- index 5ddddef..5b31bd2 100644
- --- a/src/game/Unit.h
- +++ b/src/game/Unit.h
- @@ -412,6 +412,7 @@ enum DeathState
- CORPSE = 2, // corpse state, for player this also meaning that player not leave corpse
- DEAD = 3, // for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state
- JUST_ALIVED = 4, // temporary state at resurrection, for creature auto converted to ALIVE, for player at next update call
- + GHOULED = 5, // death knight related
- };
- // internal state flags for some auras and movement generators, other.
- @@ -1627,6 +1628,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
- * \see GetMaxHealth
- */
- float GetHealthPercent() const { return (GetHealth() * 100.0f) / GetMaxHealth(); }
- +
- + uint32 CountPctFromMaxHealth(int32 pct) const { return (GetMaxHealth() * static_cast<float>(pct) / 100.0f); }
- + uint32 CountPctFromCurHealth(int32 pct) const { return (GetHealth() * static_cast<float>(pct) / 100.0f); }
- +
- /**
- * Sets the health to the given value, it cant be higher than Unit::GetMaxHealth though
- * @param val the value to set the health to
- @@ -1654,6 +1659,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
- */
- int32 ModifyHealth(int32 val);
- + // Eluna-related health functions
- + bool HealthAbovePctHealed(int32 pct, uint32 heal) const { return uint64(GetHealth()) + uint64(heal) > CountPctFromMaxHealth(pct); }
- + bool IsFullHealth() const { return GetHealth() == GetMaxHealth(); }
- + bool HealthBelowPct(int32 pct) const { return GetHealth() < CountPctFromMaxHealth(pct); }
- + bool HealthBelowPctDamaged(int32 pct, uint32 damage) const { return int64(GetHealth()) - int64(damage) < int64(CountPctFromMaxHealth(pct)); }
- + bool HealthAbovePct(int32 pct) const { return GetHealth() > CountPctFromMaxHealth(pct); }
- +
- /**
- * Gets the power type for this Unit
- * @return The type of power this Unit uses
- @@ -1752,6 +1764,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
- */
- void setFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); }
- FactionTemplateEntry const* getFactionTemplateEntry() const;
- + void RestoreOriginalFaction();
- /**
- * Are we hostile towards the given Unit?
- * @param unit the unit we want to check against
- @@ -2202,6 +2215,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
- bool isAlive() const { return (m_deathState == ALIVE); };
- bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); };
- + bool isDying() const { return (m_deathState == JUST_DIED); }
- DeathState getDeathState() const { return m_deathState; };
- virtual void SetDeathState(DeathState s); // overwritten in Creature/Player/Pet
- @@ -2360,6 +2374,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
- void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0);
- Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; }
- + Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; }
- Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
- bool CheckAndIncreaseCastCounter();
- diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
- index f275015..d1502bd 100644
- --- a/src/game/Vehicle.cpp
- +++ b/src/game/Vehicle.cpp
- @@ -46,6 +46,7 @@
- #include "movement/MoveSpline.h"
- #include "MapManager.h"
- #include "TemporarySummon.h"
- +#include "LuaEngine.h"
- void ObjectMgr::LoadVehicleAccessory()
- {
- @@ -118,6 +119,8 @@ VehicleInfo::VehicleInfo(Unit* owner, VehicleEntry const* vehicleEntry, uint32 o
- VehicleInfo::~VehicleInfo()
- {
- + Eluna::RemoveRef(this);
- +
- ((Unit*)m_owner)->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
- RemoveAccessoriesFromMap(); // Remove accessories (for example required with player vehicles)
- @@ -138,9 +141,36 @@ void VehicleInfo::Initialize()
- m_accessoryGuids.insert(summoned->GetObjectGuid());
- int32 basepoint0 = itr->seatId + 1;
- summoned->CastCustomSpell((Unit*)m_owner, SPELL_RIDE_VEHICLE_HARDCODED, &basepoint0, NULL, NULL, true);
- +
- + sEluna->OnInstallAccessory(this, summoned);
- }
- }
- +
- + // Initialize movement limitations
- + /* uint32 vehicleFlags = GetVehicleEntry()->m_flags;
- + Unit* pVehicle = (Unit*)m_owner;
- +
- + if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE)
- + pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_STRAFE);
- + if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING)
- + pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_JUMPING);
- + if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING)
- + pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDTURNING);
- + if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING)
- + pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_ALLOW_PITCHING);
- + if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING)
- + pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDPITCHING);
- +
- + // Initialize power type based on DBC values (creatures only)
- + if (pVehicle->GetTypeId() == TYPEID_UNIT)
- + {
- + if (PowerDisplayEntry const* powerEntry = sPowerDisplayStore.LookupEntry(GetVehicleEntry()->m_powerDisplayID))
- + pVehicle->SetPowerType(Powers(powerEntry->power));
- + }*/
- +
- m_isInitialized = true;
- +
- + sEluna->OnInstall(this);
- }
- /*
- @@ -212,6 +242,8 @@ void VehicleInfo::Board(Unit* passenger, uint8 seat)
- // Apply passenger modifications
- ApplySeatMods(passenger, seatEntry->m_flags);
- +
- + sEluna->OnAddPassenger(this, passenger, seat);
- }
- /*
- @@ -325,6 +357,8 @@ void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle)
- // Remove passenger modifications
- RemoveSeatMods(passenger, seatEntry->m_flags);
- +
- + sEluna->OnRemovePassenger(this, passenger);
- // Some creature vehicles get despawned after passenger unboarding
- if (m_owner->GetTypeId() == TYPEID_UNIT)
- diff --git a/src/game/Vehicle.h b/src/game/Vehicle.h
- index c1dd877..93c8362 100644
- --- a/src/game/Vehicle.h
- +++ b/src/game/Vehicle.h
- @@ -68,7 +68,8 @@ class VehicleInfo : public TransportBase
- ~VehicleInfo();
- VehicleEntry const* GetVehicleEntry() const { return m_vehicleEntry; }
- -
- + VehicleSeatEntry const* GetSeatEntry(uint8 seat) const;
- +
- void Board(Unit* passenger, uint8 seat); // Board a passenger to a vehicle
- void SwitchSeat(Unit* passenger, uint8 seat); // Used to switch seats of a passenger
- void UnBoard(Unit* passenger, bool changeVehicle); // Used to Unboard a passenger from a vehicle
- @@ -83,7 +84,6 @@ class VehicleInfo : public TransportBase
- void CalculateBoardingPositionOf(float gx, float gy, float gz, float go, float& lx, float& ly, float& lz, float& lo) const;
- // Seat information
- - VehicleSeatEntry const* GetSeatEntry(uint8 seat) const;
- bool GetUsableSeatFor(Unit* passenger, uint8& seat) const;
- bool IsSeatAvailableFor(Unit* passenger, uint8 seat) const;
- diff --git a/src/game/Weather.cpp b/src/game/Weather.cpp
- index 7002212..1597f59 100644
- --- a/src/game/Weather.cpp
- +++ b/src/game/Weather.cpp
- @@ -27,6 +27,7 @@
- #include "Log.h"
- #include "ObjectMgr.h"
- #include "Util.h"
- +#include "LuaEngine.h"
- /// Create the Weather object
- Weather::Weather(uint32 zone, WeatherZoneChances const* weatherChances) : m_zone(zone), m_weatherChances(weatherChances)
- @@ -38,6 +39,11 @@ Weather::Weather(uint32 zone, WeatherZoneChances const* weatherChances) : m_zone
- DETAIL_FILTER_LOG(LOG_FILTER_WEATHER, "WORLD: Starting weather system for zone %u (change every %u minutes).", m_zone, (m_timer.GetInterval() / (MINUTE * IN_MILLISECONDS)));
- }
- +Weather::~Weather()
- +{
- + Eluna::RemoveRef(this);
- +}
- +
- /// Launch a weather update
- bool Weather::Update(time_t diff)
- {
- @@ -261,6 +267,7 @@ bool Weather::UpdateWeather()
- }
- DETAIL_FILTER_LOG(LOG_FILTER_WEATHER, "Change the weather of zone %u to %s.", m_zone, wthstr);
- + sEluna->OnChange(this, (WeatherState)m_type, m_grade);
- return true;
- }
- diff --git a/src/game/Weather.h b/src/game/Weather.h
- index 1680e30..53c1c47 100644
- --- a/src/game/Weather.h
- +++ b/src/game/Weather.h
- @@ -52,7 +52,7 @@ class Weather
- {
- public:
- Weather(uint32 zone, WeatherZoneChances const* weatherChances);
- - ~Weather() { };
- + ~Weather();
- bool ReGenerate();
- bool UpdateWeather();
- void SendWeatherUpdateToPlayer(Player* player);
- diff --git a/src/game/World.cpp b/src/game/World.cpp
- index b67e09e..cd7dc50 100644
- --- a/src/game/World.cpp
- +++ b/src/game/World.cpp
- @@ -67,6 +67,7 @@
- #include "CharacterDatabaseCleaner.h"
- #include "CreatureLinkingMgr.h"
- #include "Calendar.h"
- +#include "LuaEngine.h"
- INSTANTIATE_SINGLETON_1(World);
- @@ -150,6 +151,8 @@ void World::CleanupsBeforeStop()
- KickAll(); // save and kick all players
- UpdateSessions(1); // real players unload required UpdateSessions call
- sBattleGroundMgr.DeleteAllBattleGrounds(); // unload battleground templates before different singletons destroyed
- +
- + Eluna::Uninitialize();
- }
- /// Find a player in a specified zone
- @@ -919,6 +922,8 @@ void World::LoadConfigSettings(bool reload)
- std::string ignoreMapIds = sConfig.GetStringDefault("mmap.ignoreMapIds", "");
- MMAP::MMapFactory::preventPathfindingOnMaps(ignoreMapIds.c_str());
- sLog.outString("WORLD: mmap pathfinding %sabled", getConfig(CONFIG_BOOL_MMAP_ENABLED) ? "en" : "dis");
- +
- + setConfig(CONFIG_BOOL_ELUNA_ENABLED, "Eluna.Enabled", true);
- }
- /// Initialize the World
- @@ -1363,6 +1368,10 @@ void World::SetInitialWorldSettings()
- sLog.outError("Scripting library build for old mangosd revision. You need rebuild it.");
- break;
- }
- +
- + ///- Initialize Lua Engine
- + sLog.outString("Initialize Eluna Lua Engine...");
- + Eluna::Initialize();
- ///- Initialize game time and timers
- sLog.outString("DEBUG:: Initialize game time and timers");
- @@ -1591,6 +1600,9 @@ void World::Update(uint32 diff)
- sMapMgr.Update(diff);
- sBattleGroundMgr.Update(diff);
- sOutdoorPvPMgr.Update(diff);
- +
- + ///- Used by Eluna
- + sEluna->OnWorldUpdate(diff);
- ///- Delete all characters which have been deleted X days before
- if (m_timers[WUPDATE_DELETECHARS].Passed())
- @@ -2181,7 +2193,7 @@ void World::InitRandomBGResetTime()
- // normalize reset time
- m_NextRandomBGReset = m_NextRandomBGReset < curTime ? nextDayResetTime - DAY : nextDayResetTime;
- if (!result)
- - CharacterDatabase.PExecute("INSERT INTO saved_variables (NextRandomBGResetTime) VALUES ('"UI64FMTD"')", uint64(m_NextRandomBGReset));
- + CharacterDatabase.PExecute("INSERT INTO saved_variables (NextRandomBGResetTime) VALUES ('" UI64FMTD "')", uint64(m_NextRandomBGReset));
- else
- delete result;
- }
- @@ -2207,7 +2219,7 @@ void World::ResetRandomBG()
- itr->second->GetPlayer()->SetRandomWinner(false);
- m_NextRandomBGReset = time_t(m_NextRandomBGReset + DAY);
- - CharacterDatabase.PExecute("UPDATE saved_variables SET NextRandomBGResetTime = '"UI64FMTD"'", uint64(m_NextRandomBGReset));
- + CharacterDatabase.PExecute("UPDATE saved_variables SET NextRandomBGResetTime = '" UI64FMTD "'", uint64(m_NextRandomBGReset));
- }
- void World::ResetWeeklyQuests()
- diff --git a/src/game/World.h b/src/game/World.h
- index e67c504..51834ce 100644
- --- a/src/game/World.h
- +++ b/src/game/World.h
- @@ -345,6 +345,7 @@ enum eConfigBoolValues
- CONFIG_BOOL_VMAP_INDOOR_CHECK,
- CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT,
- CONFIG_BOOL_MMAP_ENABLED,
- + CONFIG_BOOL_ELUNA_ENABLED,
- CONFIG_BOOL_PLAYER_COMMANDS,
- CONFIG_BOOL_VALUE_COUNT
- };
- @@ -444,6 +445,9 @@ struct CliCommandHolder
- };
- /// The World
- +
- +typedef UNORDERED_MAP<uint32, WorldSession*> SessionMap;
- +
- class World
- {
- public:
- @@ -459,6 +463,7 @@ class World
- bool RemoveSession(uint32 id);
- /// Get the number of current active sessions
- void UpdateMaxSessionCounters();
- + const SessionMap& GetAllSessions() const { return m_sessions; }
- uint32 GetActiveAndQueuedSessionCount() const { return m_sessions.size(); }
- uint32 GetActiveSessionCount() const { return m_sessions.size() - m_QueuedSessions.size(); }
- uint32 GetQueuedSessionCount() const { return m_QueuedSessions.size(); }
- diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp
- index 8966566..a36237f 100644
- --- a/src/game/WorldSession.cpp
- +++ b/src/game/WorldSession.cpp
- @@ -39,6 +39,7 @@
- #include "Auth/AuthCrypt.h"
- #include "Auth/HMACSHA1.h"
- #include "zlib/zlib.h"
- +#include "LuaEngine.h"
- // select opcodes appropriate for processing in Map::Update context for current session state
- static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& opHandle)
- @@ -463,6 +464,9 @@ void WorldSession::LogoutPlayer(bool Save)
- ///- Broadcast a logout message to the player's friends
- sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetObjectGuid(), true);
- sSocialMgr.RemovePlayerSocial(_player->GetGUIDLow());
- +
- + ///- Used by Eluna
- + sEluna->OnLogout(_player);
- ///- Remove the player from the world
- // the player may not be in the world when logging out
- @@ -962,6 +966,9 @@ void WorldSession::SendRedirectClient(std::string& ip, uint16 port)
- void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* packet)
- {
- + if (!sEluna->OnPacketReceive(this, *packet))
- + return;
- +
- // need prevent do internal far teleports in handlers because some handlers do lot steps
- // or call code that can do far teleports in some conditions unexpectedly for generic way work code
- if (_player)
- diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h
- index be2fb4f..f8ef946 100644
- --- a/src/game/WorldSession.h
- +++ b/src/game/WorldSession.h
- @@ -250,6 +250,7 @@ class MANGOS_DLL_SPEC WorldSession
- void SendLfgUpdate(bool isGroup, LfgUpdateType updateType, uint32 id);
- void SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res);
- void SendGroupInvite(Player* player, bool alreadyInGroup = false);
- + void SendGuildInvite(Player* player, bool alreadyInGuild = false);
- void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3);
- void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0);
- void SendSetPhaseShift(uint32 phaseShift);
- diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp
- index 74d1acc..728a685 100644
- --- a/src/game/WorldSocket.cpp
- +++ b/src/game/WorldSocket.cpp
- @@ -42,6 +42,7 @@
- #include "WorldSocketMgr.h"
- #include "Log.h"
- #include "DBCStores.h"
- +#include "LuaEngine.h"
- #if defined( __GNUC__ )
- #pragma pack(1)
- @@ -156,16 +157,21 @@ const std::string& WorldSocket::GetRemoteAddress(void) const
- return m_Address;
- }
- -int WorldSocket::SendPacket(const WorldPacket& pct)
- +int WorldSocket::SendPacket(const WorldPacket& pkt)
- {
- ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1);
- if (closing_)
- return -1;
- +
- + WorldPacket pct = pkt;
- // Dump outgoing packet.
- sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false);
- + if (!sEluna->OnPacketSend(m_Session, pct))
- + return 0;
- +
- ServerPktHeader header(pct.size() + 2, pct.GetOpcode());
- m_Crypt.EncryptSend((uint8*)header.header, header.getHeaderLength());
- @@ -687,11 +693,14 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
- sLog.outError("WorldSocket::ProcessIncoming: Player send CMSG_AUTH_SESSION again");
- return -1;
- }
- -
- +
- + if (!sEluna->OnPacketReceive(m_Session, *new_pct))
- + return 0;
- return HandleAuthSession(*new_pct);
- case CMSG_KEEP_ALIVE:
- DEBUG_LOG("CMSG_KEEP_ALIVE ,size: " SIZEFMTD " ", new_pct->size());
- + sEluna->OnPacketReceive(m_Session, *new_pct);
- return 0;
- default:
- {
- diff --git a/src/game/vmap/RegularGrid.h b/src/game/vmap/RegularGrid.h
- index d15e79f..dbaa501 100644
- --- a/src/game/vmap/RegularGrid.h
- +++ b/src/game/vmap/RegularGrid.h
- @@ -107,7 +107,7 @@ class RegularGrid2D
- static Cell ComputeCell(float fx, float fy)
- {
- - Cell c = {fx* (1.f / CELL_SIZE) + (CELL_NUMBER / 2), fy* (1.f / CELL_SIZE) + (CELL_NUMBER / 2)};
- + Cell c = {static_cast<int>(fx* (1.f / CELL_SIZE) + (CELL_NUMBER / 2)), static_cast<int>(fy* (1.f / CELL_SIZE) + (CELL_NUMBER / 2))};
- return c;
- }
- diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in
- index ee6066f..8c50348 100644
- --- a/src/mangosd/mangosd.conf.dist.in
- +++ b/src/mangosd/mangosd.conf.dist.in
- @@ -305,6 +305,10 @@ CleanCharacterDB = 1
- # Log file of DB errors detected at server run
- # Default: "DBErrors.log"
- #
- +# ElunaErrorLogFile
- +# Log file of Eluna errors detected at server run
- +# Default: "ElunaErrors.log"
- +#
- # EventAIErrorLogFile
- # Log file of EventAI errors detected at server run
- # Default: "EventAIErrors.log"
- @@ -384,6 +388,7 @@ LogFilter_Calendar = 1
- WorldLogFile = ""
- WorldLogTimestamp = 0
- DBErrorLogFile = "DBErrors.log"
- +ElunaErrorLogFile = "ElunaErrors.log"
- EventAIErrorLogFile = "EventAIErrors.log"
- CharLogFile = "Char.log"
- CharLogTimestamp = 0
- @@ -1717,3 +1722,19 @@ SOAP.Port = 7878
- CharDelete.Method = 0
- CharDelete.MinLevel = 0
- CharDelete.KeepDays = 30
- +
- +###################################################################################################################
- +# ELUNA SETTINGS
- +#
- +# Eluna.Enabled
- +# Enable Enabled Eluna LuaEngine
- +# Default: 1 (Enabled)
- +# 0 (Disabled)
- +#
- +# Eluna.ScriptPath
- +# Default: "lua_scripts"
- +#
- +###################################################################################################################
- +
- +Eluna.Enabled = 1
- +Eluna.ScriptPath = "lua_scripts"
- diff --git a/src/shared/Common.h b/src/shared/Common.h
- index 0885b1d..0c29af8 100644
- --- a/src/shared/Common.h
- +++ b/src/shared/Common.h
- @@ -242,6 +242,7 @@ enum LocaleConstant
- };
- #define MAX_LOCALE 9
- +#define DEFAULT_LOCALE LOCALE_enUS
- /**
- * @brief
- @@ -251,6 +252,8 @@ enum LocaleConstant
- */
- LocaleConstant GetLocaleByName(const std::string& name);
- +typedef std::vector<std::string> StringVector;
- +
- extern char const* localeNames[MAX_LOCALE]; /**< TODO */
- /**
- diff --git a/src/shared/Database/DBCStore.h b/src/shared/Database/DBCStore.h
- index 1aae802..b111f17 100644
- --- a/src/shared/Database/DBCStore.h
- +++ b/src/shared/Database/DBCStore.h
- @@ -55,13 +55,24 @@ class DBCStorage
- * @param id
- * @return const T
- */
- - T const* LookupEntry(uint32 id) const { return (id >= nCount) ? NULL : indexTable[id]; }
- + //T const* LookupEntry(uint32 id) const { return (id >= nCount) ? NULL : indexTable[id]; }
- + T const* LookupEntry(uint32 id) const
- + {
- + if (loaded)
- + {
- + typename std::map<uint32, T const*>::const_iterator it = data.find(id);
- + if (it != data.end())
- + return it->second;
- + }
- + return (id >= nCount) ? NULL : indexTable[id];
- + }
- /**
- * @brief
- *
- * @return uint32
- */
- - uint32 GetNumRows() const { return nCount; }
- + //uint32 GetNumRows() const { return nCount; }
- + uint32 GetNumRows() const { return loaded ? data.size() : nCount; }
- /**
- * @brief
- *
- @@ -99,6 +110,22 @@ class DBCStorage
- // error in dbc file at loading if NULL
- return indexTable != NULL;
- }
- +
- + void SetEntry(uint32 id, T* t) // Cryptic they say..
- + {
- + if (!loaded)
- + {
- + for (uint32 i = 0; i < nCount; ++i)
- + {
- + T const* node = LookupEntry(i);
- + if (!node)
- + continue;
- + data[i] = node;
- + }
- + loaded = true;
- + }
- + data[id] = t;
- + }
- /**
- * @brief
- @@ -129,6 +156,12 @@ class DBCStorage
- */
- void Clear()
- {
- + if (loaded)
- + {
- + data.clear();
- + loaded = false;
- + }
- +
- if (!indexTable)
- { return; }
- @@ -165,6 +198,8 @@ class DBCStorage
- char const* fmt; /**< TODO */
- T** indexTable; /**< TODO */
- T* m_dataTable; /**< TODO */
- + std::map<uint32, T const*> data;
- + bool loaded;
- StringPoolList m_stringPoolList; /**< TODO */
- };
- diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h
- index 6c841eb..2714b76 100644
- --- a/src/shared/Database/Field.h
- +++ b/src/shared/Database/Field.h
- @@ -104,6 +104,8 @@ class Field
- * @return bool
- */
- bool GetBool() const { return mValue ? atoi(mValue) > 0 : false; }
- + double GetDouble() const { return mValue ? static_cast<double>(atof(mValue)) : 0.0f; }
- + int8 GetInt8() const { return mValue ? static_cast<int8>(atol(mValue)) : int8(0); }
- /**
- * @brief
- *
- @@ -147,6 +149,15 @@ class Field
- return value;
- }
- +
- + int64 GetInt64() const
- + {
- + int64 value = 0;
- + if (!mValue || sscanf(mValue, SI64FMTD, &value) == -1)
- + return 0;
- +
- + return value;
- + }
- /**
- * @brief
- diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp
- index 1eb04b7..e547471 100644
- --- a/src/shared/Log.cpp
- +++ b/src/shared/Log.cpp
- @@ -71,7 +71,7 @@ const int LogType_count = int(LogError) + 1;
- Log::Log() :
- raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
- - dberLogfile(NULL), eventAiErLogfile(NULL), scriptErrLogFile(NULL), worldLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false), m_scriptLibName(NULL)
- + dberLogfile(NULL), elunaErrLogfile(NULL), eventAiErLogfile(NULL), scriptErrLogFile(NULL), worldLogfile(NULL), m_colored(false), m_includeTime(false), m_gmlog_per_account(false), m_scriptLibName(NULL)
- {
- Initialize();
- }
- @@ -267,6 +267,7 @@ void Log::Initialize()
- charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
- dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
- + elunaErrLogfile = openLogFile("ElunaErrorLogFile", NULL, "a");
- eventAiErLogfile = openLogFile("EventAIErrorLogFile", NULL, "a");
- raLogfile = openLogFile("RaLogFile", NULL, "a");
- worldLogfile = openLogFile("WorldLogFile", "WorldLogTimestamp", "a");
- @@ -520,6 +521,81 @@ void Log::outErrorDb(const char* err, ...)
- fflush(stderr);
- }
- +void Log::outErrorEluna()
- +{
- + if (m_includeTime)
- + outTime();
- +
- + fprintf(stderr, "\n");
- +
- + if (logfile)
- + {
- + outTimestamp(logfile);
- + fprintf(logfile, "ERROR Eluna\n");
- + fflush(logfile);
- + }
- +
- + if (elunaErrLogfile)
- + {
- + outTimestamp(elunaErrLogfile);
- + fprintf(elunaErrLogfile, "\n");
- + fflush(elunaErrLogfile);
- + }
- +
- + fflush(stderr);
- +}
- +
- +void Log::outErrorEluna(const char* err, ...)
- +{
- + if (!err)
- + return;
- +
- + if (m_colored)
- + SetColor(false, m_colors[LogError]);
- +
- + if (m_includeTime)
- + outTime();
- +
- + va_list ap;
- +
- + va_start(ap, err);
- + vutf8printf(stderr, err, &ap);
- + va_end(ap);
- +
- + if (m_colored)
- + ResetColor(false);
- +
- + fprintf(stderr, "\n");
- +
- + if (logfile)
- + {
- + outTimestamp(logfile);
- + fprintf(logfile, "ERROR Eluna: ");
- +
- + va_start(ap, err);
- + vfprintf(logfile, err, ap);
- + va_end(ap);
- +
- + fprintf(logfile, "\n");
- + fflush(logfile);
- + }
- +
- + if (elunaErrLogfile)
- + {
- + outTimestamp(elunaErrLogfile);
- +
- + va_list ap;
- + va_start(ap, err);
- + vfprintf(elunaErrLogfile, err, ap);
- + va_end(ap);
- +
- + fprintf(elunaErrLogfile, "\n");
- + fflush(elunaErrLogfile);
- + }
- +
- + fflush(stderr);
- +}
- +
- void Log::outErrorEventAI()
- {
- if (m_includeTime)
- diff --git a/src/shared/Log.h b/src/shared/Log.h
- index 0c809de..04717bc 100644
- --- a/src/shared/Log.h
- +++ b/src/shared/Log.h
- @@ -142,6 +142,10 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
- if (dberLogfile != NULL)
- { fclose(dberLogfile); }
- dberLogfile = NULL;
- +
- + if (elunaErrLogfile != NULL)
- + fclose(elunaErrLogfile);
- + elunaErrLogfile = NULL;
- if (eventAiErLogfile != NULL)
- { fclose(eventAiErLogfile); }
- @@ -233,6 +237,17 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
- void outChar(const char* str, ...) ATTR_PRINTF(2, 3);
- /**
- * @brief any log level
- + *
- + */
- + void outErrorEluna();
- + /**
- + * @brief any log level
- + *
- + * @param str...
- + */
- + void outErrorEluna(const char* str, ...) ATTR_PRINTF(2, 3);
- + /**
- + * @brief any log level
- *
- */
- void outErrorEventAI();
- @@ -399,6 +414,7 @@ class Log : public MaNGOS::Singleton<Log, MaNGOS::ClassLevelLockable<Log, ACE_Th
- FILE* gmLogfile; /**< TODO */
- FILE* charLogfile; /**< TODO */
- FILE* dberLogfile; /**< TODO */
- + FILE* elunaErrLogfile; /**< TODO */
- FILE* eventAiErLogfile; /**< TODO */
- FILE* scriptErrLogFile; /**< TODO */
- FILE* worldLogfile; /**< TODO */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement