From 55fc0c58af02f1ae4fa69976a9d351824ffde56e Mon Sep 17 00:00:00 2001 From: Nay Date: Sun, 3 Feb 2013 01:37:23 +0000 Subject: [PATCH 01/15] DB/Schema: Change engine and collation of `world`.`lfg_entrances` latin1 -> utf8_general_ci InnoDB -> MyISAM (defaults for all `world` DB tables) --- sql/updates/world/2013_02_03_world_lfg_entrances.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 sql/updates/world/2013_02_03_world_lfg_entrances.sql diff --git a/sql/updates/world/2013_02_03_world_lfg_entrances.sql b/sql/updates/world/2013_02_03_world_lfg_entrances.sql new file mode 100644 index 0000000000..e308c001d2 --- /dev/null +++ b/sql/updates/world/2013_02_03_world_lfg_entrances.sql @@ -0,0 +1 @@ +ALTER TABLE `lfg_entrances` CHARACTER SET utf8 COLLATE utf8_general_ci, ENGINE MyISAM; From 68610a60ea268b2ee7b3f5c949ff513ec30ab4d3 Mon Sep 17 00:00:00 2001 From: Manuel Carrasco Date: Sun, 3 Feb 2013 03:01:47 -0200 Subject: [PATCH 02/15] Core/AI: Removed needless code --- src/server/game/AI/CoreAI/UnitAI.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 09ba2cc19b..0d2f623fd9 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -103,8 +103,7 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) if (unit->GetTypeId() == TYPEID_PLAYER) me->AddAura(spellid, unit); } - }else - return; + } } void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) @@ -118,8 +117,7 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) if (unit->GetTypeId() == TYPEID_PLAYER) me->CastSpell(unit, spellid, triggered); } - }else - return; + } } void UnitAI::DoCast(uint32 spellId) From 2df1908c2933c88f1442dbde52658b3c5499a849 Mon Sep 17 00:00:00 2001 From: m7nu3l Date: Sun, 3 Feb 2013 02:25:58 -0300 Subject: [PATCH 03/15] Core/AI: Inherited AggressorAI, so the wheel is not reinvented. --- src/server/game/AI/CoreAI/ReactorAI.cpp | 29 +++---------------------- src/server/game/AI/CoreAI/ReactorAI.h | 9 ++++---- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/server/game/AI/CoreAI/ReactorAI.cpp b/src/server/game/AI/CoreAI/ReactorAI.cpp index 31b9a82c53..fef465d592 100644 --- a/src/server/game/AI/CoreAI/ReactorAI.cpp +++ b/src/server/game/AI/CoreAI/ReactorAI.cpp @@ -23,35 +23,12 @@ #include "ObjectAccessor.h" #include "CreatureAIImpl.h" -#define REACTOR_VISIBLE_RANGE (26.46f) +// #define REACTOR_VISIBLE_RANGE (26.46f) - It has not any use at all -int -ReactorAI::Permissible(const Creature* creature) +int ReactorAI::Permissible(const Creature* creature) { if (creature->isCivilian() || creature->IsNeutralToAll()) return PERMIT_BASE_REACTIVE; return PERMIT_BASE_NO; -} - -void -ReactorAI::MoveInLineOfSight(Unit*) -{ -} - -void -ReactorAI::UpdateAI(const uint32 /*time_diff*/) -{ - // update i_victimGuid if me->getVictim() !=0 and changed - if (!UpdateVictim()) - return; - - if (me->isAttackReady()) - { - if (me->IsWithinMeleeRange(me->getVictim())) - { - me->AttackerStateUpdate(me->getVictim()); - me->resetAttackTimer(); - } - } -} +} \ No newline at end of file diff --git a/src/server/game/AI/CoreAI/ReactorAI.h b/src/server/game/AI/CoreAI/ReactorAI.h index 39af09c4a9..6f4d704f75 100644 --- a/src/server/game/AI/CoreAI/ReactorAI.h +++ b/src/server/game/AI/CoreAI/ReactorAI.h @@ -19,19 +19,18 @@ #ifndef TRINITY_REACTORAI_H #define TRINITY_REACTORAI_H -#include "CreatureAI.h" +#include "CombatAI.h" class Unit; -class ReactorAI : public CreatureAI +class ReactorAI : public AggressorAI { public: - explicit ReactorAI(Creature* c) : CreatureAI(c) {} + explicit ReactorAI(Creature* c) : AggressorAI(c) {} - void MoveInLineOfSight(Unit*); + void MoveInLineOfSight(Unit*) {}; - void UpdateAI(const uint32); static int Permissible(const Creature*); }; #endif From a8054311ca4419354b4a55ad2d9626e4f202d697 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 10:49:31 +0100 Subject: [PATCH 04/15] Core/AI: Reverted 2df1908c2933c88f1442dbde52658b3c5499a849 - sometimes it is better to copy some code to make its purpose clearer (ReactorAI is an AI class used for neutral creatures, it makes no sense to inherit AggresorAI, which is used for aggressive creatures) --- src/server/game/AI/CoreAI/ReactorAI.cpp | 12 +++++++++--- src/server/game/AI/CoreAI/ReactorAI.h | 7 ++++--- src/server/game/AI/CoreAI/UnitAI.cpp | 5 ++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/server/game/AI/CoreAI/ReactorAI.cpp b/src/server/game/AI/CoreAI/ReactorAI.cpp index fef465d592..b9c235176b 100644 --- a/src/server/game/AI/CoreAI/ReactorAI.cpp +++ b/src/server/game/AI/CoreAI/ReactorAI.cpp @@ -23,12 +23,18 @@ #include "ObjectAccessor.h" #include "CreatureAIImpl.h" -// #define REACTOR_VISIBLE_RANGE (26.46f) - It has not any use at all - int ReactorAI::Permissible(const Creature* creature) { if (creature->isCivilian() || creature->IsNeutralToAll()) return PERMIT_BASE_REACTIVE; return PERMIT_BASE_NO; -} \ No newline at end of file +} + +void ReactorAI::UpdateAI(uint32 const /*diff*/) +{ + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); +} diff --git a/src/server/game/AI/CoreAI/ReactorAI.h b/src/server/game/AI/CoreAI/ReactorAI.h index 6f4d704f75..e6db46bf38 100644 --- a/src/server/game/AI/CoreAI/ReactorAI.h +++ b/src/server/game/AI/CoreAI/ReactorAI.h @@ -19,17 +19,18 @@ #ifndef TRINITY_REACTORAI_H #define TRINITY_REACTORAI_H -#include "CombatAI.h" +#include "CreatureAI.h" class Unit; -class ReactorAI : public AggressorAI +class ReactorAI : public CreatureAI { public: explicit ReactorAI(Creature* c) : AggressorAI(c) {} - void MoveInLineOfSight(Unit*) {}; + void MoveInLineOfSight(Unit*) {} + void UpdateAI(uint32 const diff); static int Permissible(const Creature*); }; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 0d2f623fd9..7f0d387c2f 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -238,7 +238,10 @@ void UnitAI::FillAISpellInfo() } //Enable PlayerAI when charmed -void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; } +void PlayerAI::OnCharmed(bool apply) +{ + me->IsAIEnabled = apply; +} void SimpleCharmedAI::UpdateAI(const uint32 /*diff*/) { From a216ef2ca00b2aa4049114f68f1d9cefb547a059 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 11:05:42 +0100 Subject: [PATCH 05/15] And a build fix. Nothing new... move along --- src/server/game/AI/CoreAI/ReactorAI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/game/AI/CoreAI/ReactorAI.h b/src/server/game/AI/CoreAI/ReactorAI.h index e6db46bf38..f7de3b9956 100644 --- a/src/server/game/AI/CoreAI/ReactorAI.h +++ b/src/server/game/AI/CoreAI/ReactorAI.h @@ -27,7 +27,7 @@ class ReactorAI : public CreatureAI { public: - explicit ReactorAI(Creature* c) : AggressorAI(c) {} + explicit ReactorAI(Creature* c) : CreatureAI(c) {} void MoveInLineOfSight(Unit*) {} void UpdateAI(uint32 const diff); From 653557d335abf1a703ac518ee5df41f104adff63 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 12:16:10 +0100 Subject: [PATCH 06/15] Core/Objects: Some optimizations to object updatemask building --- src/server/game/Entities/Object/Object.cpp | 74 +++++++------------ src/server/game/Entities/Object/Object.h | 4 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 7 +- 3 files changed, 29 insertions(+), 56 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index f20d452dc9..70b2618ef6 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -777,64 +777,56 @@ void Object::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) cons BuildValuesUpdateBlockForPlayer(&iter->second, iter->first); } -void Object::GetUpdateFieldData(Player const* target, uint32*& flags, bool& isOwner, bool& isItemOwner, bool& hasSpecialInfo, bool& isPartyMember) const +uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const { - // This function assumes updatefield index is always valid + uint32 visibleFlag = UF_FLAG_PUBLIC; + + if (target == this) + visibleFlag |= UF_FLAG_PRIVATE; + switch (GetTypeId()) { case TYPEID_ITEM: case TYPEID_CONTAINER: flags = ItemUpdateFieldFlags; - isOwner = isItemOwner = ((Item*)this)->GetOwnerGUID() == target->GetGUID(); + if (((Item*)this)->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER | UF_FLAG_ITEM_OWNER; break; case TYPEID_UNIT: case TYPEID_PLAYER: { Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself(); flags = UnitUpdateFieldFlags; - isOwner = ToUnit()->GetOwnerGUID() == target->GetGUID(); - hasSpecialInfo = ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()); - isPartyMember = plr && plr->IsInSameGroupWith(target); + if (ToUnit()->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; + + if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID())) + visibleFlag |= UF_FLAG_SPECIAL_INFO; + + if (plr && plr->IsInSameGroupWith(target)) + visibleFlag |= UF_FLAG_PARTY_MEMBER; break; } case TYPEID_GAMEOBJECT: flags = GameObjectUpdateFieldFlags; - isOwner = ToGameObject()->GetOwnerGUID() == target->GetGUID(); + if (ToGameObject()->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; break; case TYPEID_DYNAMICOBJECT: flags = DynamicObjectUpdateFieldFlags; - isOwner = ((DynamicObject*)this)->GetCasterGUID() == target->GetGUID(); + if (((DynamicObject*)this)->GetCasterGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; break; case TYPEID_CORPSE: flags = CorpseUpdateFieldFlags; - isOwner = ToCorpse()->GetOwnerGUID() == target->GetGUID(); + if (ToCorpse()->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; break; case TYPEID_OBJECT: break; } -} -bool Object::IsUpdateFieldVisible(uint32 flags, bool isSelf, bool isOwner, bool isItemOwner, bool isPartyMember) const -{ - if (flags == UF_FLAG_NONE) - return false; - - if (flags & UF_FLAG_PUBLIC) - return true; - - if (flags & UF_FLAG_PRIVATE && isSelf) - return true; - - if (flags & UF_FLAG_OWNER && isOwner) - return true; - - if (flags & UF_FLAG_ITEM_OWNER && isItemOwner) - return true; - - if (flags & UF_FLAG_PARTY_MEMBER && isPartyMember) - return true; - - return false; + return visibleFlag; } void Object::_LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count) @@ -857,16 +849,10 @@ void Object::_LoadIntoDataField(std::string const& data, uint32 startOffset, uin void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const { uint32* flags = NULL; - bool isSelf = target == this; - bool isOwner = false; - bool isItemOwner = false; - bool hasSpecialInfo = false; - bool isPartyMember = false; - - GetUpdateFieldData(target, flags, isOwner, isItemOwner, hasSpecialInfo, isPartyMember); + uint32 visibleFlag = GetUpdateFieldData(target, flags); for (uint16 index = 0; index < m_valuesCount; ++index) - if (_fieldNotifyFlags & flags[index] || (flags[index] & UF_FLAG_SPECIAL_INFO && hasSpecialInfo) || (_changesMask.GetBit(index) && IsUpdateFieldVisible(flags[index], isSelf, isOwner, isItemOwner, isPartyMember))) + if (_fieldNotifyFlags & flags[index] || ((flags[index] & visibleFlag) & UF_FLAG_SPECIAL_INFO) || (_changesMask.GetBit(index) && (flags[index] & visibleFlag))) updateMask->SetBit(index); } @@ -874,16 +860,10 @@ void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const { uint32* value = m_uint32Values; uint32* flags = NULL; - bool isSelf = target == this; - bool isOwner = false; - bool isItemOwner = false; - bool hasSpecialInfo = false; - bool isPartyMember = false; - - GetUpdateFieldData(target, flags, isOwner, isItemOwner, hasSpecialInfo, isPartyMember); + uint32 visibleFlag = GetUpdateFieldData(target, flags); for (uint16 index = 0; index < m_valuesCount; ++index, ++value) - if (_fieldNotifyFlags & flags[index] || (flags[index] & UF_FLAG_SPECIAL_INFO && hasSpecialInfo) || (*value && IsUpdateFieldVisible(flags[index], isSelf, isOwner, isItemOwner, isPartyMember))) + if (_fieldNotifyFlags & flags[index] || ((flags[index] & visibleFlag) & UF_FLAG_SPECIAL_INFO) || (*value && (flags[index] & visibleFlag))) updateMask->SetBit(index); } diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 641f9afb15..ae3d545b7d 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -326,9 +326,7 @@ class Object std::string _ConcatFields(uint16 startIndex, uint16 size) const; void _LoadIntoDataField(std::string const& data, uint32 startOffset, uint32 count); - void GetUpdateFieldData(Player const* target, uint32*& flags, bool& isOwner, bool& isItemOwner, bool& hasSpecialInfo, bool& isPartyMember) const; - - bool IsUpdateFieldVisible(uint32 flags, bool isSelf, bool isOwner, bool isItemOwner, bool isPartyMember) const; + uint32 GetUpdateFieldData(Player const* target, uint32*& flags) const; void _SetUpdateBits(UpdateMask* updateMask, Player* target) const; void _SetCreateBits(UpdateMask* updateMask, Player* target) const; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 52e8523a72..d6b19e6010 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -5061,10 +5061,6 @@ void AuraEffect::HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bo return; Unit* target = aurApp->GetTarget(); - - if (target->GetTypeId() != TYPEID_UNIT) - return; - if (!apply) { // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit @@ -5072,8 +5068,7 @@ void AuraEffect::HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bo return; } - CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(target->GetEntry()); - if (ci && ci->type == CREATURE_TYPE_BEAST) + if (target->GetCreatureType() == CREATURE_TYPE_BEAST) target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply); } From 07442f932ce956d0ef90e543a91b1127532d2cdc Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 12:23:28 +0100 Subject: [PATCH 07/15] Core/Object: Fixed a mistake in update mask building - fields marked with UF_FLAG_PARTY_MEMBER should be sent to the entire raid, not only one subgroup --- src/server/game/Entities/Object/Object.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 70b2618ef6..8f89e58ad5 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -800,10 +800,11 @@ uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const if (ToUnit()->GetOwnerGUID() == target->GetGUID()) visibleFlag |= UF_FLAG_OWNER; - if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID())) - visibleFlag |= UF_FLAG_SPECIAL_INFO; + if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO)) + if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID())) + visibleFlag |= UF_FLAG_SPECIAL_INFO; - if (plr && plr->IsInSameGroupWith(target)) + if (plr && plr->IsInSameRaidWith(target)) visibleFlag |= UF_FLAG_PARTY_MEMBER; break; } From 54924f18af20434174a2610a19f0b1946a5b0ac1 Mon Sep 17 00:00:00 2001 From: Gacko Date: Sat, 2 Feb 2013 15:58:37 +0100 Subject: [PATCH 08/15] Core/EventMap: Internal changes and doxygen doc See http://www.trinitycore.org/f/topic/7003-doxygen-documentation-and-hacks for details and examples. Thanks to @Shauren for several hints. --- src/server/game/AI/CreatureAIImpl.h | 357 +++++++++++++++++++--------- 1 file changed, 243 insertions(+), 114 deletions(-) diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index bf5ab9703e..03402ce415 100644 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -313,110 +313,177 @@ const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, c class EventMap { - typedef std::map StorageType; + /** + * Internal storage type. + * Key: Time as uint32 when the event should occur. + * Value: The event data as uint32. + * + * Structure of event data: + * - Bit 0 - 15: Event Id. + * - Bit 16 - 23: Group + * - Bit 24 - 31: Phase + * - Pattern: 0xPPGGEEEE + */ + typedef std::multimap EventStore; public: EventMap() : _time(0), _phase(0) {} - // Returns current timer value, does not represent real dates/times - uint32 GetTimer() const { return _time; } - - // Removes all events and clears phase + /** + * @name Reset + * @brief Removes all scheduled events and resets time and phase. + */ void Reset() { - _eventMap.clear(); _time = 0; _phase = 0; + _eventMap.clear(); + _time = 0; + _phase = 0; } - void Update(uint32 time) { _time += time; } - - uint32 GetPhaseMask() const { return (_phase >> 24) & 0xFF; } - - bool Empty() const { return _eventMap.empty(); } - - // Sets event phase, must be in range 1 - 8 - void SetPhase(uint32 phase) + /** + * @name Update + * @brief Updates the timer of the event map. + * @param time Value to be added to time. + */ + void Update(uint32 time) { - if (phase && phase <= 8) - _phase = (1 << (phase + 23)); - else if (!phase) + _time += time; + } + + /** + * @name GetTimer + * @return Current timer value. + */ + uint32 GetTimer() const + { + return _time; + } + + /** + * @name GetPhaseMask + * @return Active phases as mask. + */ + uint8 GetPhaseMask() const + { + return _phase; + } + + /** + * @name Empty + * @return True, if there are no events scheduled. + */ + bool Empty() const + { + return _eventMap.empty(); + } + + /** + * @name SetPhase + * @brief Sets the phase of the map (absolute). + * @param phase Phase which should be set. Values: 1 - 8. 0 resets phase. + */ + void SetPhase(uint8 phase) + { + if (!phase) _phase = 0; + else if (phase <= 8) + _phase = (1 << (phase - 1)); } - // Activates event phase, must be in range 1 - 8 - void AddPhase(uint32 phase) + /** + * @name AddPhase + * @brief Activates the given phase (bitwise). + * @param phase Phase which should be activated. Values: 1 - 8 + */ + void AddPhase(uint8 phase) { if (phase && phase <= 8) - _phase |= (1 << (phase + 23)); + _phase |= (1 << (phase - 1)); } - // Deactivates event phase, must be in range 1 - 8 - void RemovePhase(uint32 phase) + /** + * @name RemovePhase + * @brief Deactivates the given phase (bitwise). + * @param phase Phase which should be deactivated. Values: 1 - 8. + */ + void RemovePhase(uint8 phase) { if (phase && phase <= 8) - _phase &= ~(1 << (phase + 23)); + _phase &= ~(1 << (phase - 1)); } - // Creates new event entry in map with given id, time, group if given (1 - 8) and phase if given (1 - 8) - // 0 for group/phase means it belongs to no group or runs in all phases - void ScheduleEvent(uint32 eventId, uint32 time, uint32 groupId = 0, uint32 phase = 0) + /** + * @name ScheduleEvent + * @brief Creates new event entry in map. + * @param eventId The id of the new event. + * @param time The time in milliseconds until the event occurs. + * @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group. + * @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases. + */ + void ScheduleEvent(uint32 eventId, uint32 time, uint32 group = 0, uint8 phase = 0) { - time += _time; - if (groupId && groupId < 9) - eventId |= (1 << (groupId + 15)); - if (phase && phase < 8) + if (group && group <= 8) + eventId |= (1 << (group + 15)); + + if (phase && phase <= 8) eventId |= (1 << (phase + 23)); - StorageType::const_iterator itr = _eventMap.find(time); - while (itr != _eventMap.end()) - { - ++time; - itr = _eventMap.find(time); - } - _eventMap.insert(StorageType::value_type(time, eventId)); + _eventMap.insert(EventStore::value_type(_time + time, eventId)); } - // Removes event with specified id and creates new entry for it - void RescheduleEvent(uint32 eventId, uint32 time, uint32 groupId = 0, uint32 phase = 0) + /** + * @name RescheduleEvent + * @brief Cancels the given event and reschedules it. + * @param eventId The id of the event. + * @param time The time in milliseconds until the event occurs. + * @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group. + * @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases. + */ + void RescheduleEvent(uint32 eventId, uint32 time, uint32 group = 0, uint8 phase = 0) { CancelEvent(eventId); - ScheduleEvent(eventId, time, groupId, phase); + ScheduleEvent(eventId, time, group, phase); } - // Reschedules closest event + /** + * @name RepeatEvent + * @brief Cancels the closest event and reschedules it. + * @param time Time until the event occurs. + */ void RepeatEvent(uint32 time) { - if (_eventMap.empty()) + if (Empty()) return; - + uint32 eventId = _eventMap.begin()->second; _eventMap.erase(_eventMap.begin()); - time += _time; - StorageType::const_iterator itr = _eventMap.find(time); - while (itr != _eventMap.end()) - { - ++time; - itr = _eventMap.find(time); - } - - _eventMap.insert(StorageType::value_type(time, eventId)); + ScheduleEvent(eventId, time); } - // Removes first event + /** + * @name PopEvent + * @brief Remove the first event in the map. + */ void PopEvent() { - if (!_eventMap.empty()) + if (!Empty()) _eventMap.erase(_eventMap.begin()); } - // Gets next event id to execute and removes it from map + /** + * @name ExecuteEvent + * @brief Returns the next event to execute and removes it from map. + * @return Id of the event to execute. + */ uint32 ExecuteEvent() { - while (!_eventMap.empty()) + while (!Empty()) { - StorageType::iterator itr = _eventMap.begin(); + EventStore::iterator itr = _eventMap.begin(); + if (itr->first > _time) return 0; - else if (_phase && (itr->second & 0xFF000000) && !(itr->second & _phase)) + else if (_phase && (itr->second & 0xFF000000) && !((itr->second >> 24) & _phase)) _eventMap.erase(itr); else { @@ -425,114 +492,176 @@ class EventMap return eventId; } } + return 0; } - // Gets next event id to execute + /** + * @name GetEvent + * @brief Returns the next event to execute. + * @return Id of the event to execute. + */ uint32 GetEvent() { - while (!_eventMap.empty()) + while (!Empty()) { - StorageType::iterator itr = _eventMap.begin(); + EventStore::iterator itr = _eventMap.begin(); + if (itr->first > _time) return 0; - else if (_phase && (itr->second & 0xFF000000) && !(itr->second & _phase)) + else if (_phase && (itr->second & 0xFF000000) && !(itr->second & (_phase << 24))) _eventMap.erase(itr); else return (itr->second & 0x0000FFFF); } - + return 0; } - // Delay all events + /** + * @name DelayEvents + * @brief Delays all events in the map. If delay is greater than or equal internal timer, delay will be 0. + * @param delay Amount of delay. + */ void DelayEvents(uint32 delay) { - if (delay < _time) - _time -= delay; - else - _time = 0; + _time = delay < _time ? _time - delay : 0; } - // Delay all events having the specified Group - void DelayEvents(uint32 delay, uint32 groupId) + /** + * @name DelayEvents + * @brief Delay all events of the same group. + * @param delay Amount of delay. + * @param group Group of the events. + */ + void DelayEvents(uint32 delay, uint32 group) { - if (!groupId || groupId > 8) + if (!group || group > 8 || Empty()) return; + + EventStore delayed; - uint32 nextTime = _time + delay; - uint32 groupMask = (1 << (groupId + 15)); - - for (StorageType::iterator itr = _eventMap.begin(); itr != _eventMap.end() && itr->first < nextTime;) + for (EventStore::iterator itr = _eventMap.begin(); itr != _eventMap.end();) { - if (itr->second & groupMask) + if (itr->second & (1 << (group + 15))) { - ScheduleEvent(itr->second, itr->first - _time + delay); - _eventMap.erase(itr); - itr = _eventMap.begin(); + delayed.insert(EventStore::value_type(itr->first + delay, itr->second)); + _eventMap.erase(itr++); } else ++itr; } + + _eventMap.insert(delayed.begin(), delayed.end()); } - // Cancel events with specified id + /** + * @name CancelEvent + * @brief Cancels all events of the specified id. + * @param eventId Event id to cancel. + */ void CancelEvent(uint32 eventId) { - for (StorageType::iterator itr = _eventMap.begin(); itr != _eventMap.end();) - { - if (eventId == (itr->second & 0x0000FFFF)) - { - _eventMap.erase(itr); - itr = _eventMap.begin(); - } - else - ++itr; - } - } - - // Cancel events belonging to specified group - void CancelEventGroup(uint32 groupId) - { - if (!groupId || groupId > 8) + if (Empty()) return; - uint32 groupMask = (1 << (groupId + 15)); - - for (StorageType::iterator itr = _eventMap.begin(); itr != _eventMap.end();) + for (EventStore::iterator itr = _eventMap.begin(); itr != _eventMap.end();) { - if (itr->second & groupMask) - { - _eventMap.erase(itr); - itr = _eventMap.begin(); - } + if (eventId == (itr->second & 0x0000FFFF)) + _eventMap.erase(itr++); else ++itr; } } - // Returns time of next event to execute - // To get how much time remains substract _time + /** + * @name CancelEventGroup + * @brief Cancel events belonging to specified group. + * @param group Group to cancel. + */ + void CancelEventGroup(uint32 group) + { + if (!group || group > 8 || Empty()) + return; + + for (EventStore::iterator itr = _eventMap.begin(); itr != _eventMap.end();) + { + if (itr->second & (1 << (group + 15))) + _eventMap.erase(itr++); + else + ++itr; + } + } + + /** + * @name GetNextEventTime + * @brief Returns closest occurence of specified event. + * @param eventId Wanted event id. + * @return Time of found event. + */ uint32 GetNextEventTime(uint32 eventId) const { - for (StorageType::const_iterator itr = _eventMap.begin(); itr != _eventMap.end(); ++itr) + if (Empty()) + return 0; + + for (EventStore::const_iterator itr = _eventMap.begin(); itr != _eventMap.end(); ++itr) if (eventId == (itr->second & 0x0000FFFF)) return itr->first; return 0; } - - // Returns wether the eventmap is in the given phase or not. - bool IsInPhase(uint32 phase) + + /** + * @name GetNextEventTime + * @return Time of next event. + */ + uint32 GetNextEventTime() const { - return phase <= 8 && (!phase || _phase & (1 << (phase + 23))); + return Empty() ? 0 : _eventMap.begin()->first; + } + + /** + * @name IsInPhase + * @brief Returns wether event map is in specified phase or not. + * @param phase Wanted phase. + * @return True, if phase of event map contains specified phase. + */ + bool IsInPhase(uint8 phase) + { + return phase <= 8 && (!phase || _phase & (1 << (phase - 1))); } private: + /** + * @name _time + * @brief Internal timer. + * + * This does not represent the real date/time value. + * It's more like a stop watch: It can run, it can be stopped, + * it can be resetted and so on. Events occur when this timer + * has reached their time value. It's value is changed in the + * Update method. + */ uint32 _time; - uint32 _phase; - - StorageType _eventMap; + + /** + * @name _phase + * @brief Phase mask of the event map. + * + * Contains the phases the event map is in. Multiple + * phases from 1 to 8 can be set with SetPhase or + * AddPhase. RemovePhase deactives a phase. + */ + uint8 _phase; + + /** + * @name _eventMap + * @brief Internal event storage map. Contains the scheduled events. + * + * See typedef at the beginning of the class for more + * details. + */ + EventStore _eventMap; }; enum AITarget From 6d29a62b78d347a9ccaaa39fa61d3ed9af54d2ca Mon Sep 17 00:00:00 2001 From: Regigicas Date: Sun, 3 Feb 2013 14:08:29 +0100 Subject: [PATCH 09/15] Update WheatyExceptionReport to print Windows 8 --- src/server/shared/Debugging/WheatyExceptionReport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp index 96a115f805..2f30ddfcd7 100644 --- a/src/server/shared/Debugging/WheatyExceptionReport.cpp +++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp @@ -202,7 +202,9 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) if (osvi.wProductType == VER_NT_WORKSTATION) #endif // WINVER < 0x0500 { - if (osvi.dwMinorVersion == 1) + if (osvi.dwMinorVersion == 2) + _tcsncat(szVersion, _T("Windows 8 "), cntMax); + else if (osvi.dwMinorVersion == 1) _tcsncat(szVersion, _T("Windows 7 "), cntMax); else _tcsncat(szVersion, _T("Windows Vista "), cntMax); From b346459ca88a4959c579e51607ef0b5eb8d75b98 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 14:11:59 +0100 Subject: [PATCH 10/15] Core: Warning fixes --- src/server/collision/Models/GameObjectModel.cpp | 3 +++ src/server/game/Movement/Spline/MovementPacketBuilder.cpp | 2 +- .../scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp | 2 +- src/tools/mmaps_generator/MapBuilder.cpp | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server/collision/Models/GameObjectModel.cpp b/src/server/collision/Models/GameObjectModel.cpp index 5428338938..e166a860cd 100644 --- a/src/server/collision/Models/GameObjectModel.cpp +++ b/src/server/collision/Models/GameObjectModel.cpp @@ -48,7 +48,10 @@ ModelList model_list; void LoadGameObjectModelList() { +#ifndef NO_CORE_FUNCS uint32 oldMSTime = getMSTime(); +#endif + FILE* model_list_file = fopen((sWorld->GetDataPath() + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb"); if (!model_list_file) { diff --git a/src/server/game/Movement/Spline/MovementPacketBuilder.cpp b/src/server/game/Movement/Spline/MovementPacketBuilder.cpp index 801219b2a5..29d1bb50a8 100644 --- a/src/server/game/Movement/Spline/MovementPacketBuilder.cpp +++ b/src/server/game/Movement/Spline/MovementPacketBuilder.cpp @@ -146,7 +146,7 @@ namespace Movement //data.append(&mov.m_float_values[SpeedWalk], SpeedMaxCount); //if (mov.SplineEnabled()) { - MoveSplineFlag splineFlags = move_spline.splineflags; + MoveSplineFlag const& splineFlags = move_spline.splineflags; data << splineFlags.raw(); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index aa65cfda97..1d340e61b6 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -298,7 +298,7 @@ class boss_lord_marrowgar : public CreatureScript case DATA_SPIKE_IMMUNE + 1: case DATA_SPIKE_IMMUNE + 2: { - int32 index = type - DATA_SPIKE_IMMUNE; + uint32 index = uint32(type - DATA_SPIKE_IMMUNE); if (index < _boneSpikeImmune.size()) return _boneSpikeImmune[index]; diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index 4a016f267b..cd85d92612 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -957,7 +957,7 @@ namespace MMAP if (count != 1) return false; - if (header.mmapMagic != MMAP_MAGIC || header.dtVersion != DT_NAVMESH_VERSION) + if (header.mmapMagic != MMAP_MAGIC || header.dtVersion != uint32(DT_NAVMESH_VERSION)) return false; if (header.mmapVersion != MMAP_VERSION) From fe1aa11e08c2f395a0f3b42763165439e11f5c76 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 15:04:12 +0100 Subject: [PATCH 11/15] Core/Debugging: Made WheatyExceptionReport::_GetWindowsVersion code more readable and added check for Windows Server 2012 --- .../Debugging/WheatyExceptionReport.cpp | 187 ++++++++---------- 1 file changed, 78 insertions(+), 109 deletions(-) diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp index 2f30ddfcd7..ea9ab096dc 100644 --- a/src/server/shared/Debugging/WheatyExceptionReport.cpp +++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp @@ -193,14 +193,19 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) { // Windows NT product family. case VER_PLATFORM_WIN32_NT: + { + #if WINVER < 0x0500 + BYTE suiteMask = osvi.wReserved[0]; + BYTE productType = osvi.wReserved[1]; + #else + WORD suiteMask = osvi.wSuiteMask; + BYTE productType = osvi.wProductType; + #endif // WINVER < 0x0500 + // Test for the specific product family. if (osvi.dwMajorVersion == 6) { - #if WINVER < 0x0500 - if (osvi.wReserved[1] == VER_NT_WORKSTATION) - #else - if (osvi.wProductType == VER_NT_WORKSTATION) - #endif // WINVER < 0x0500 + if (productType == VER_NT_WORKSTATION) { if (osvi.dwMinorVersion == 2) _tcsncat(szVersion, _T("Windows 8 "), cntMax); @@ -209,140 +214,104 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) else _tcsncat(szVersion, _T("Windows Vista "), cntMax); } + else if (osvi.dwMinorVersion == 2) + _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); else if (osvi.dwMinorVersion == 1) _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); else _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); } - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) _tcsncat(szVersion, _T("Microsoft Windows Server 2003 "), cntMax); - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) _tcsncat(szVersion, _T("Microsoft Windows XP "), cntMax); - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) _tcsncat(szVersion, _T("Microsoft Windows 2000 "), cntMax); - if (osvi.dwMajorVersion <= 4) + else if (osvi.dwMajorVersion <= 4) _tcsncat(szVersion, _T("Microsoft Windows NT "), cntMax); // Test for specific product on Windows NT 4.0 SP6 and later. if (bOsVersionInfoEx) { // Test for the workstation type. - #if WINVER < 0x0500 - if (osvi.wReserved[1] == VER_NT_WORKSTATION) - #else - if (osvi.wProductType == VER_NT_WORKSTATION) - #endif // WINVER < 0x0500 - { - if (osvi.dwMajorVersion == 4) - _tcsncat(szVersion, _T("Workstation 4.0 "), cntMax); - #if WINVER < 0x0500 - else if (osvi.wReserved[0] & VER_SUITE_PERSONAL) - #else - else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) - #endif // WINVER < 0x0500 + if (productType == VER_NT_WORKSTATION) + { + if (osvi.dwMajorVersion == 4) + _tcsncat(szVersion, _T("Workstation 4.0 "), cntMax); + else if (suiteMask & VER_SUITE_PERSONAL) _tcsncat(szVersion, _T("Home Edition "), cntMax); - #if WINVER < 0x0500 - else if (osvi.wReserved[0] & VER_SUITE_EMBEDDEDNT) - #else - else if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT) - #endif // WINVER < 0x0500 + else if (suiteMask & VER_SUITE_EMBEDDEDNT) _tcsncat(szVersion, _T("Embedded "), cntMax); - else - _tcsncat(szVersion, _T("Professional "), cntMax); - } - // Test for the server type. - #if WINVER < 0x0500 - else if (osvi.wReserved[1] == VER_NT_SERVER) - #else - else if (osvi.wProductType == VER_NT_SERVER) - #endif // WINVER < 0x0500 - { - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + else + _tcsncat(szVersion, _T("Professional "), cntMax); + } + // Test for the server type. + else if (productType == VER_NT_SERVER) { - #if WINVER < 0x0500 - if (osvi.wReserved[0] & VER_SUITE_DATACENTER) - #else - if (osvi.wSuiteMask & VER_SUITE_DATACENTER) - #endif // WINVER < 0x0500 + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + { + if (suiteMask & VER_SUITE_DATACENTER) _tcsncat(szVersion, _T("Datacenter Edition "), cntMax); - #if WINVER < 0x0500 - else if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE) - #else - else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - #endif // WINVER < 0x0500 + else if (suiteMask & VER_SUITE_ENTERPRISE) _tcsncat(szVersion, _T("Enterprise Edition "), cntMax); - #if WINVER < 0x0500 - else if (osvi.wReserved[0] == VER_SUITE_BLADE) - #else - else if (osvi.wSuiteMask == VER_SUITE_BLADE) - #endif // WINVER < 0x0500 + else if (suiteMask == VER_SUITE_BLADE) _tcsncat(szVersion, _T("Web Edition "), cntMax); - else - _tcsncat(szVersion, _T("Standard Edition "), cntMax); - } - else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) - { - #if WINVER < 0x0500 - if (osvi.wReserved[0] & VER_SUITE_DATACENTER) - #else - if (osvi.wSuiteMask & VER_SUITE_DATACENTER) - #endif // WINVER < 0x0500 + else + _tcsncat(szVersion, _T("Standard Edition "), cntMax); + } + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) + { + if (suiteMask & VER_SUITE_DATACENTER) _tcsncat(szVersion, _T("Datacenter Server "), cntMax); - #if WINVER < 0x0500 - else if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE) - #else - else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - #endif // WINVER < 0x0500 + else if (suiteMask & VER_SUITE_ENTERPRISE) _tcsncat(szVersion, _T("Advanced Server "), cntMax); - else - _tcsncat(szVersion, _T("Server "), cntMax); - } - else // Windows NT 4.0 - { - #if WINVER < 0x0500 - if (osvi.wReserved[0] & VER_SUITE_ENTERPRISE) - #else - if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - #endif // WINVER < 0x0500 + else + _tcsncat(szVersion, _T("Server "), cntMax); + } + else // Windows NT 4.0 + { + if (suiteMask & VER_SUITE_ENTERPRISE) _tcsncat(szVersion, _T("Server 4.0, Enterprise Edition "), cntMax); - else - _tcsncat(szVersion, _T("Server 4.0 "), cntMax); + else + _tcsncat(szVersion, _T("Server 4.0 "), cntMax); + } } } - } - // Display service pack (if any) and build number. - if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0) - { - HKEY hKey; - LONG lRet; - // Test for SP6 versus SP6a. - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey); - if (lRet == ERROR_SUCCESS) + // Display service pack (if any) and build number. + if (osvi.dwMajorVersion == 4 && _tcsicmp(osvi.szCSDVersion, _T("Service Pack 6")) == 0) { - _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"), - osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + HKEY hKey; + LONG lRet; + + // Test for SP6 versus SP6a. + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009"), 0, KEY_QUERY_VALUE, &hKey); + if (lRet == ERROR_SUCCESS) + { + _stprintf(wszTmp, _T("Service Pack 6a (Version %d.%d, Build %d)"), + osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + _tcsncat(szVersion, wszTmp, cntMax); + } + else // Windows NT 4.0 prior to SP6a + { + _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + _tcsncat(szVersion, wszTmp, cntMax); + } + ::RegCloseKey(hKey); + } + else // Windows NT 3.51 and earlier or Windows 2000 and later + { + if (!_tcslen(osvi.szCSDVersion)) + _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), + osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); + else + _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), + osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); _tcsncat(szVersion, wszTmp, cntMax); } - else // Windows NT 4.0 prior to SP6a - { - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); - _tcsncat(szVersion, wszTmp, cntMax); - } - ::RegCloseKey(hKey); + break; } - else // Windows NT 3.51 and earlier or Windows 2000 and later - { - if (!_tcslen(osvi.szCSDVersion)) - _stprintf(wszTmp, _T("(Version %d.%d, Build %d)"), - osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); - else - _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), - osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); - _tcsncat(szVersion, wszTmp, cntMax); - } - break; default: _stprintf(wszTmp, _T("%s (Version %d.%d, Build %d)"), osvi.szCSDVersion, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber & 0xFFFF); From 193a0d5f153c593e421bf2f7e36a536acceaf36b Mon Sep 17 00:00:00 2001 From: Gacko Date: Sun, 3 Feb 2013 15:21:36 +0100 Subject: [PATCH 12/15] Fix engrish in doc --- src/server/game/AI/CreatureAIImpl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index 03402ce415..7121a031ec 100644 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -637,9 +637,9 @@ class EventMap * @brief Internal timer. * * This does not represent the real date/time value. - * It's more like a stop watch: It can run, it can be stopped, + * It's more like a stopwatch: It can run, it can be stopped, * it can be resetted and so on. Events occur when this timer - * has reached their time value. It's value is changed in the + * has reached their time value. Its value is changed in the * Update method. */ uint32 _time; From ccc19366601afe6afad528308530e0811e7aa80d Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 3 Feb 2013 15:36:29 +0100 Subject: [PATCH 13/15] Core/Loot: Items in generated loot will now be split in multiple stacks if their count exceeds max stack size defined in item_template --- src/server/game/Loot/LootMgr.cpp | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 59696a47fe..128cf35855 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -351,7 +351,6 @@ LootItem::LootItem(LootStoreItem const& li) needs_quest = li.needs_quest; - count = urand(li.mincountOrRef, li.maxcount); // constructor called for mincountOrRef > 0 only randomSuffix = GenerateEnchSuffixFactor(itemid); randomPropertyId = Item::GenerateItemRandomPropertyId(itemid); is_looted = 0; @@ -400,26 +399,30 @@ void LootItem::AddAllowedLooter(const Player* player) // // Inserts the item into the loot (called by LootTemplate processors) -void Loot::AddItem(LootStoreItem const & item) +void Loot::AddItem(LootStoreItem const& item) { - if (item.needs_quest) // Quest drop + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item.itemid); + if (!proto) + return; + + uint32 count = urand(item.mincountOrRef, item.maxcount); + uint32 stacks = count / proto->GetMaxStackSize() + (count % proto->GetMaxStackSize() ? 1 : 0); + + std::vector& lootItems = item.needs_quest ? quest_items : items; + uint32 limit = item.needs_quest ? MAX_NR_QUEST_ITEMS : MAX_NR_LOOT_ITEMS; + + for (uint32 i = 0; i < stacks && lootItems.size() < limit; ++i) { - if (quest_items.size() < MAX_NR_QUEST_ITEMS) - quest_items.push_back(LootItem(item)); - } - else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop - { - items.push_back(LootItem(item)); + LootItem generatedLoot(item); + generatedLoot.count = std::min(count, proto->GetMaxStackSize()); + lootItems.push_back(generatedLoot); + count -= proto->GetMaxStackSize(); // non-conditional one-player only items are counted here, // free for all items are counted in FillFFALoot(), // non-ffa conditionals are counted in FillNonQuestNonFFAConditionalLoot() - if (item.conditions.empty()) - { - ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item.itemid); - if (!proto || (proto->Flags & ITEM_PROTO_FLAG_PARTY_LOOT) == 0) - ++unlootedCount; - } + if (!item.needs_quest && item.conditions.empty() && !(proto->Flags & ITEM_PROTO_FLAG_PARTY_LOOT)) + ++unlootedCount; } } From cfaabe50cf229040b9f6c7d379a1879579c18bb9 Mon Sep 17 00:00:00 2001 From: Krogonos Date: Sun, 3 Feb 2013 09:12:03 -0600 Subject: [PATCH 14/15] Fixed a few file names to improve searching. Signed-off-by: Krogonos --- src/server/scripts/Kalimdor/CMakeLists.txt | 6 +++--- .../{boss_epoch.cpp => boss_chrono_lord_epoch.cpp} | 0 .../{boss_infinite.cpp => boss_infinite_corruptor.cpp} | 0 .../{boss_salramm.cpp => boss_salramm_the_fleshcrafter.cpp} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/{boss_epoch.cpp => boss_chrono_lord_epoch.cpp} (100%) rename src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/{boss_infinite.cpp => boss_infinite_corruptor.cpp} (100%) rename src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/{boss_salramm.cpp => boss_salramm_the_fleshcrafter.cpp} (100%) diff --git a/src/server/scripts/Kalimdor/CMakeLists.txt b/src/server/scripts/Kalimdor/CMakeLists.txt index 5c44cd7ef2..536824e7a6 100644 --- a/src/server/scripts/Kalimdor/CMakeLists.txt +++ b/src/server/scripts/Kalimdor/CMakeLists.txt @@ -38,11 +38,11 @@ set(scripts_STAT_SRCS Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjal.h Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_azgalor.cpp Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp - Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite.cpp - Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm.cpp + Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp + Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp Kalimdor/CavernsOfTime/CullingOfStratholme/boss_meathook.cpp Kalimdor/CavernsOfTime/CullingOfStratholme/boss_mal_ganis.cpp - Kalimdor/CavernsOfTime/CullingOfStratholme/boss_epoch.cpp + Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.cpp Kalimdor/CavernsOfTime/CullingOfStratholme/instance_culling_of_stratholme.cpp Kalimdor/CavernsOfTime/CullingOfStratholme/culling_of_stratholme.h diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_epoch.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp similarity index 100% rename from src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_epoch.cpp rename to src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_chrono_lord_epoch.cpp diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp similarity index 100% rename from src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite.cpp rename to src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_infinite_corruptor.cpp diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp similarity index 100% rename from src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm.cpp rename to src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/boss_salramm_the_fleshcrafter.cpp From 124b5ed6e7f9be9ffe6453e1defef3df5d409d8c Mon Sep 17 00:00:00 2001 From: m7nu3l Date: Sun, 3 Feb 2013 14:46:17 -0300 Subject: [PATCH 15/15] Core/AI: Implemented functionality for _isCombatMovementAllowed in ScriptedAI, only when AttackStart is called. --- src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 8 ++++++++ src/server/game/AI/ScriptedAI/ScriptedCreature.h | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 9709cb0ecc..090c73f456 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -108,6 +108,14 @@ void ScriptedAI::AttackStartNoMove(Unit* who) DoStartNoMovement(who); } +void ScriptedAI::AttackStart(Unit* who) +{ + if (IsCombatMovementAllowed()) + CreatureAI::AttackStart(who); + else + AttackStartNoMove(who); +} + void ScriptedAI::UpdateAI(uint32 const /*diff*/) { //Check if we have a current target diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 50363f20ed..15068557ac 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -136,6 +136,9 @@ struct ScriptedAI : public CreatureAI //Called at creature aggro either by MoveInLOS or Attack Start void EnterCombat(Unit* /*victim*/) {} + // Called before EnterCombat even before the creature is in combat. + void AttackStart(Unit* /*target*/); + // ************* //AI Helper Functions // ************* @@ -191,7 +194,11 @@ struct ScriptedAI : public CreatureAI void SetEquipmentSlots(bool loadDefault, int32 mainHand = EQUIP_NO_CHANGE, int32 offHand = EQUIP_NO_CHANGE, int32 ranged = EQUIP_NO_CHANGE); - //Generally used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims + // Used to control if MoveChase() is to be used or not in AttackStart(). Some creatures does not chase victims + // NOTE: If you use SetCombatMovement while the creature is in combat, it will do NOTHING - This only affects AttackStart + // You should make the necessary to make it happen so. + // Remember that if you modified _isCombatMovementAllowed (e.g: using SetCombatMovement) it will not be reset at Reset(). + // It will keep the last value you set. void SetCombatMovement(bool allowMovement); bool IsCombatMovementAllowed() const { return _isCombatMovementAllowed; }