From 991cbf635070381e9f18b79ec3e6befee78926a8 Mon Sep 17 00:00:00 2001 From: H0zen Date: Thu, 24 Mar 2016 18:20:55 +0200 Subject: [PATCH] Various external fixes - part 7 Ported commits from cmangos repositories - https://github.com/cmangos/mangos-classic/commit/10a1710 - https://github.com/cmangos/mangos-classic/commit/4aacdaf - https://github.com/cmangos/mangos-classic/commit/c05d0ed - https://github.com/cmangos/mangos-classic/commit/e8aa9cb --- src/framework/Platform/Define.h | 6 ++++- .../TargetedMovementGenerator.cpp | 22 ++++++++++++++++--- .../TargetedMovementGenerator.h | 3 ++- src/game/Object/CreatureEventAI.cpp | 6 +++-- src/game/Object/Formulas.h | 2 +- src/game/Object/PlayerLogger.cpp | 2 +- src/game/Object/SpellMgr.cpp | 2 +- src/game/Object/Unit.cpp | 8 +++---- src/game/Object/Unit.h | 5 ++--- src/game/Server/WorldSocket.cpp | 6 +++-- .../WorldHandlers/MapPersistentStateMgr.cpp | 9 ++++++-- src/game/WorldHandlers/MassMailMgr.cpp | 2 +- src/game/WorldHandlers/SpellAuras.cpp | 2 ++ src/modules/Eluna | 2 +- 14 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/framework/Platform/Define.h b/src/framework/Platform/Define.h index 54e8a899..141b62e3 100644 --- a/src/framework/Platform/Define.h +++ b/src/framework/Platform/Define.h @@ -66,7 +66,11 @@ typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE; #else // PLATFORM != PLATFORM_WINDOWS # define MANGOS_EXPORT export # if defined(__APPLE_CC__) && defined(BIG_ENDIAN) -# define MANGOS_IMPORT __attribute__ ((longcall)) +# if (defined(__ppc__) || defined(__powerpc__)) +# define MANGOS_IMPORT __attribute__ ((longcall)) +# else +# define MANGOS_IMPORT +# endif # elif defined(__x86_64__) # define MANGOS_IMPORT # else diff --git a/src/game/MotionGenerators/TargetedMovementGenerator.cpp b/src/game/MotionGenerators/TargetedMovementGenerator.cpp index 66c021ea..1cea3311 100644 --- a/src/game/MotionGenerators/TargetedMovementGenerator.cpp +++ b/src/game/MotionGenerators/TargetedMovementGenerator.cpp @@ -140,6 +140,23 @@ bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_ i_recheckDistance.Reset(this->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE ? 50 : 100); G3D::Vector3 dest = owner.movespline->FinalDestination(); targetMoved = RequiresNewPosition(owner, dest.x, dest.y, dest.z); + if (!targetMoved) + { + // This unit is in hitbox of target + // howewer we have to check if the target not moved a bit to update the orientation + // client do it automatically 'visually' but it need this new orientation send or it will retrieve old orientation in some case (like stun) + G3D::Vector3 currTargetPos; + i_target->GetPosition(currTargetPos.x, currTargetPos.y, currTargetPos.z); + if (owner.movespline->Finalized() && currTargetPos != m_prevTargetPos) + { + // position changed we need to adjust owner orientation to continue facing it + m_prevTargetPos = currTargetPos; + owner.SetInFront(i_target.getTarget()); // set movementinfo orientation, needed for next movement if any + + float angle = owner.GetAngle(i_target.getTarget()); + owner.SetFacingTo(angle); // inform client that orientation changed + } + } } if (m_speedChanged || targetMoved) @@ -147,9 +164,6 @@ bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_ if (owner.movespline->Finalized()) { - if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget())) - { owner.SetInFront(i_target.getTarget()); } - if (!i_targetReached) { i_targetReached = true; @@ -199,6 +213,7 @@ void ChaseMovementGenerator::Initialize(Player& owner) { owner.addUnitState(UNIT_STAT_CHASE); // _MOVE set in _SetTargetLocation after required checks _setTargetLocation(owner, true); + i_target->GetPosition(m_prevTargetPos.x, m_prevTargetPos.y, m_prevTargetPos.z); } template<> @@ -207,6 +222,7 @@ void ChaseMovementGenerator::Initialize(Creature& owner) owner.SetWalk(false, false); // Chase movement is running owner.addUnitState(UNIT_STAT_CHASE); // _MOVE set in _SetTargetLocation after required checks _setTargetLocation(owner, true); + i_target->GetPosition(m_prevTargetPos.x, m_prevTargetPos.y, m_prevTargetPos.z); } template diff --git a/src/game/MotionGenerators/TargetedMovementGenerator.h b/src/game/MotionGenerators/TargetedMovementGenerator.h index ac5c6162..a8379429 100644 --- a/src/game/MotionGenerators/TargetedMovementGenerator.h +++ b/src/game/MotionGenerators/TargetedMovementGenerator.h @@ -27,6 +27,7 @@ #include "MovementGenerator.h" #include "FollowerReference.h" +#include "G3D/Vector3.h" class PathFinder; @@ -71,9 +72,9 @@ class TargetedMovementGeneratorMedium ShortTimeTracker i_recheckDistance; float i_offset; float i_angle; + G3D::Vector3 m_prevTargetPos; bool m_speedChanged : 1; bool i_targetReached : 1; - PathFinder* i_path; }; diff --git a/src/game/Object/CreatureEventAI.cpp b/src/game/Object/CreatureEventAI.cpp index 5d4e19e5..8a3ed0ae 100644 --- a/src/game/Object/CreatureEventAI.cpp +++ b/src/game/Object/CreatureEventAI.cpp @@ -1086,6 +1086,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->HandleEmote(action.emoteTarget.emoteId); break; } + default: + break; } } @@ -1126,11 +1128,11 @@ void CreatureEventAI::Reset() i->Enabled = true; break; } - // default: + default: // TODO: enable below code line / verify this is correct to enable events previously disabled (ex. aggro yell), instead of enable this in void Aggro() //i->Enabled = true; //i->Time = 0; - // break; + break; } } } diff --git a/src/game/Object/Formulas.h b/src/game/Object/Formulas.h index df0392a1..830b9576 100644 --- a/src/game/Object/Formulas.h +++ b/src/game/Object/Formulas.h @@ -241,7 +241,7 @@ namespace MaNGOS namespace XP { - typedef enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY } XPColorChar; + enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY }; inline uint32 GetGrayLevel(uint32 pl_level) { diff --git a/src/game/Object/PlayerLogger.cpp b/src/game/Object/PlayerLogger.cpp index dd41c86c..d910c756 100644 --- a/src/game/Object/PlayerLogger.cpp +++ b/src/game/Object/PlayerLogger.cpp @@ -252,7 +252,7 @@ void PlayerLogger::StartLogging(PlayerLogEntity entity) uint32 PlayerLogger::Stop(PlayerLogEntity entity) { SetLogActiveMask(entity, false); - sLog.outDebug("PlayerLogger: logging type %u stopped for player %u at %u records.", entity, playerGuid, data[entity]->size()); + sLog.outDebug("PlayerLogger: logging type %u stopped for player %u at %lu records.", entity, playerGuid, data[entity]->size()); return data[entity]->size(); } diff --git a/src/game/Object/SpellMgr.cpp b/src/game/Object/SpellMgr.cpp index 5458eb5a..8544cb49 100644 --- a/src/game/Object/SpellMgr.cpp +++ b/src/game/Object/SpellMgr.cpp @@ -4447,7 +4447,7 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 if (questStart) { // not in expected required quest state - if ((!questStartCanActive || !player->IsActiveQuest(questStart)) || player->GetQuestRewardStatus(questStart)) + if ((!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart)) { return false; } } diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 82ece126..f72e5370 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -3139,8 +3139,6 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed) { - MANGOS_ASSERT(spellType < CURRENT_MAX_SPELL); - if (m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED)) { // send autorepeat cancel message for autorepeat spells @@ -5307,7 +5305,7 @@ Unit* Unit::_GetTotem(TotemSlot slot) const Totem* Unit::GetTotem(TotemSlot slot) const { - if (slot >= MAX_TOTEM_SLOT || !IsInWorld() || !m_TotemSlot[slot]) + if (!IsInWorld() || !m_TotemSlot[slot]) { return NULL; } Creature* totem = GetMap()->GetCreature(m_TotemSlot[slot]); @@ -8812,8 +8810,8 @@ float Unit::GetObjectScaleMod() const // TODO:: not sure we have to do this sanity check, less than /100 or more than *100 seem not reasonable if (result < 0.01f) { result = 0.01f; } - else if (result > 100) - { result = 100; } + else if (result > 100.0f) + { result = 100.0f; } return result; } diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index bf508ef7..f701c5ed 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -379,11 +379,10 @@ enum BaseModGroup enum BaseModType { FLAT_MOD, - PCT_MOD + PCT_MOD, + MOD_END, }; -#define MOD_END (PCT_MOD+1) - enum DeathState { ALIVE = 0, ///< show as alive diff --git a/src/game/Server/WorldSocket.cpp b/src/game/Server/WorldSocket.cpp index df3beac3..63d931ad 100644 --- a/src/game/Server/WorldSocket.cpp +++ b/src/game/Server/WorldSocket.cpp @@ -822,9 +822,11 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) time_t mutetime = time_t (fields[7].GetUInt64()); - locale = LocaleConstant(fields[8].GetUInt8()); - if (locale >= MAX_LOCALE) + uint8 tmpLoc = fields[8].GetUInt8(); + if (tmpLoc >= MAX_LOCALE) { locale = LOCALE_enUS; } + else + { locale = LocaleConstant(tmpLoc); } os = fields[9].GetString(); diff --git a/src/game/WorldHandlers/MapPersistentStateMgr.cpp b/src/game/WorldHandlers/MapPersistentStateMgr.cpp index dbd06b8c..6cb22148 100644 --- a/src/game/WorldHandlers/MapPersistentStateMgr.cpp +++ b/src/game/WorldHandlers/MapPersistentStateMgr.cpp @@ -23,7 +23,6 @@ */ #include "MapPersistentStateMgr.h" - #include "SQLStorages.h" #include "Player.h" #include "GridNotifiers.h" @@ -41,6 +40,7 @@ #include "Group.h" #include "InstanceData.h" #include "ProgressBar.h" +#include INSTANTIATE_SINGLETON_1(MapPersistentStateManager); @@ -896,9 +896,14 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 } // remove all binds for online player + std::vector unbindList; + for (PersistentStateMap::iterator itr = m_instanceSaveByInstanceId.begin(); itr != m_instanceSaveByInstanceId.end(); ++itr) if (itr->second->GetMapId() == mapid) - ((DungeonPersistentState*)(itr->second))->UnbindThisState(); + unbindList.push_back((DungeonPersistentState*)itr->second); + + for (std::vector::const_iterator it = unbindList.begin(); it != unbindList.end(); ++it) + (*it)->UnbindThisState(); // reset maps, teleport player automaticaly to their homebinds and unload maps MapPersistantStateResetWorker worker; diff --git a/src/game/WorldHandlers/MassMailMgr.cpp b/src/game/WorldHandlers/MassMailMgr.cpp index 0c98b81e..83643fa9 100644 --- a/src/game/WorldHandlers/MassMailMgr.cpp +++ b/src/game/WorldHandlers/MassMailMgr.cpp @@ -74,7 +74,7 @@ struct MassMailerQueryHandler void MassMailMgr::AddMassMailTask(MailDraft* mailProto, const MailSender &sender, char const* query) { - CharacterDatabase.AsyncPQuery(&massMailerQueryHandler, &MassMailerQueryHandler::HandleQueryCallback, mailProto, sender, query); + CharacterDatabase.AsyncPQuery(&massMailerQueryHandler, &MassMailerQueryHandler::HandleQueryCallback, mailProto, sender, "%s", query); } void MassMailMgr::Update(bool sendall /*= false*/) diff --git a/src/game/WorldHandlers/SpellAuras.cpp b/src/game/WorldHandlers/SpellAuras.cpp index b3e888f2..1ec8971a 100644 --- a/src/game/WorldHandlers/SpellAuras.cpp +++ b/src/game/WorldHandlers/SpellAuras.cpp @@ -4074,6 +4074,8 @@ void Aura::HandleShapeshiftBoosts(bool apply) case FORM_CREATURECAT: case FORM_CREATUREBEAR: break; + default: + break; } if (apply) diff --git a/src/modules/Eluna b/src/modules/Eluna index d6cbadfe..e3dd72d2 160000 --- a/src/modules/Eluna +++ b/src/modules/Eluna @@ -1 +1 @@ -Subproject commit d6cbadfec9037c160a28ec72fac9e2ebe276195a +Subproject commit e3dd72d27b24168db3057a609af9884de5f10da4