From d3b4b341a0f0b257ef33184ddc45426752f08d69 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 6 Dec 2008 01:24:55 +0300 Subject: [PATCH 01/17] [6874] * Not remove spell mods for not finished spells * Ignore self miss in drop combopoints (problems vs 5171 and ranks still exist) * Allow cast spell on immune if spell can removeit by dispell --- src/game/Spell.cpp | 13 +++++++------ src/game/Unit.cpp | 3 ++- src/shared/revision_nr.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 900e7ed55..2a0ac63c9 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2483,14 +2483,14 @@ void Spell::finish(bool ok) m_spellState = SPELL_STATE_FINISHED; - //remove spell mods - if (m_caster->GetTypeId() == TYPEID_PLAYER) - ((Player*)m_caster)->RemoveSpellMods(this); - // other code related only to successfully finished spells if(!ok) return; + //remove spell mods + if (m_caster->GetTypeId() == TYPEID_PLAYER) + ((Player*)m_caster)->RemoveSpellMods(this); + //handle SPELL_AURA_ADD_TARGET_TRIGGER auras Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); for(Unit::AuraList::const_iterator i = targetTriggers.begin(); i != targetTriggers.end(); ++i) @@ -2529,10 +2529,11 @@ void Spell::finish(bool ok) // Clear combo at finish state if(m_caster->GetTypeId() == TYPEID_PLAYER && NeedsComboPoints(m_spellInfo)) { - // Not drop combopoints if any miss exist + // Not drop combopoints if negative spell and if any miss on enemy exist bool needDrop = true; + if (!IsPositiveSpell(m_spellInfo->Id)) for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) - if (ihit->missCondition != SPELL_MISS_NONE) + if (ihit->missCondition != SPELL_MISS_NONE && ihit->targetGUID!=m_caster->GetGUID()) { needDrop = false; break; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 82e55049b..671634b9b 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8017,7 +8017,8 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo, bool useCharges) if(itr->type == spellInfo->Dispel) return true; - if( !(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE)) // unaffected by school immunity + if( !(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity + !(spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it) { // not have spells with charges currently SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 169735a48..1b521491b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6873" + #define REVISION_NR "6874" #endif // __REVISION_NR_H__ From 2907868b80a2114ecaaf72352f404d726c2b273d Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 6 Dec 2008 02:44:39 +0300 Subject: [PATCH 02/17] [6875] Skip utf8 header (if exist) for mangosd.conf file --- src/shared/Config/dotconfpp/dotconfpp.cpp | 5 +++++ src/shared/revision_nr.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shared/Config/dotconfpp/dotconfpp.cpp b/src/shared/Config/dotconfpp/dotconfpp.cpp index 60008747a..1c5e667b1 100644 --- a/src/shared/Config/dotconfpp/dotconfpp.cpp +++ b/src/shared/Config/dotconfpp/dotconfpp.cpp @@ -340,6 +340,11 @@ int DOTCONFDocument::setContent(const char * _fileName) error(0, NULL, "failed to open file '%s': %s", fileName, strerror(errno)); return -1; } + // Try read utf8 header and skip it if exist + uint32 utf8header = 0; + fgets((char*)&utf8header, 4, file); // Try read header + if (utf8header!=0x00BFBBEF) // If not exist + fseek(file, 0, SEEK_SET); // Reset read position ret = parseFile(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1b521491b..2c90a0670 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6874" + #define REVISION_NR "6875" #endif // __REVISION_NR_H__ From 223fe7321f8ac21d183adfe5bcf796968157dd53 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Sat, 6 Dec 2008 04:38:31 +0300 Subject: [PATCH 03/17] [6876] * Not drop charge for 1120 and ranks (fix SPELL_AURA_CHANNEL_DEATH_ITEM aura work) --- src/game/Unit.cpp | 11 ++++------- src/shared/revision_nr.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 671634b9b..21d6aa831 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -5974,17 +5974,14 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, Aura* triggeredB { int32 value2 = CalculateSpellDamage((*i)->GetSpellProto(),2,(*i)->GetSpellProto()->EffectBasePoints[2],this); basepoints0 = value2 * GetMaxPower(POWER_MANA) / 100; - // Drain Soul - triggered_spell_id = 18371; - target = this; - found = true; + CastCustomSpell(this, 18371, &basepoints0, NULL, NULL, true, castItem, triggeredByAura); break; } } - if(!found) - return false; - break; // fall through to normal cast + // Not remove charge (aura removed on death in any cases) + // Need for correct work Drain Soul SPELL_AURA_CHANNEL_DEATH_ITEM aura + return false; } break; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2c90a0670..a20708ae8 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6875" + #define REVISION_NR "6876" #endif // __REVISION_NR_H__ From 3c67ea6f67240314e4ea669060bef126b8035ebb Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 6 Dec 2008 04:48:39 +0300 Subject: [PATCH 04/17] [6877] Fix Prayer of Mending. Use original caster's healing bonus. --- src/game/SpellEffects.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 0090fc4b7..bec0756b8 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2195,7 +2195,7 @@ void Spell::EffectApplyAura(uint32 i) // Prayer of Mending (jump animation), we need formal caster instead original for correct animation if( m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && (m_spellInfo->SpellFamilyFlags & 0x00002000000000LL)) - m_caster->CastSpell(unitTarget,41637,true,NULL,Aur); + m_caster->CastSpell(unitTarget, 41637, true, NULL, Aur, m_originalCasterGUID); } void Spell::EffectUnlearnSpecialization( uint32 i ) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a20708ae8..c2c949764 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6876" + #define REVISION_NR "6877" #endif // __REVISION_NR_H__ From 31a052d468fea84c34759def016680dea45e9aef Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Sat, 6 Dec 2008 00:28:09 +0100 Subject: [PATCH 05/17] [6878] Fixed a typo in VC for ACE_Wrappers Signed-off-by: freghar (cherry picked from commit d94f03b0aeec431ec6cee4f469d45d3209434fe7) Signed-off-by: VladimirMangos --- src/shared/revision_nr.h | 2 +- win/mangosdVC71.sln | 2 +- win/mangosdVC80.sln | 2 +- win/mangosdVC90.sln | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c2c949764..53d0f4b8d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6877" + #define REVISION_NR "6878" #endif // __REVISION_NR_H__ diff --git a/win/mangosdVC71.sln b/win/mangosdVC71.sln index 9b71ab7df..3d5ba3ccb 100644 --- a/win/mangosdVC71.sln +++ b/win/mangosdVC71.sln @@ -61,7 +61,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genrevision", "VC71\genrevi ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_Wraper", "VC71\ACE_vc71.vcproj", "{7C74F49E-FECA-1BAD-6757-8A6348EA12C8}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_Wrappers", "VC71\ACE_vc71.vcproj", "{7C74F49E-FECA-1BAD-6757-8A6348EA12C8}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject diff --git a/win/mangosdVC80.sln b/win/mangosdVC80.sln index 664fe3f6b..4440cd0b8 100644 --- a/win/mangosdVC80.sln +++ b/win/mangosdVC80.sln @@ -46,7 +46,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sockets", "VC80\sockets.vcp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genrevision", "VC80\genrevision.vcproj", "{803F488E-4C5A-4866-8D5C-1E6C03C007C2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACEWraper", "VC80\ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6348EA12C8}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_Wrappers", "VC80\ACE_vc8.vcproj", "{AD537C9A-FECA-1BAD-6757-8A6348EA12C8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/win/mangosdVC90.sln b/win/mangosdVC90.sln index 5c3ba4c1d..02a13a939 100644 --- a/win/mangosdVC90.sln +++ b/win/mangosdVC90.sln @@ -46,7 +46,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sockets", "VC90\sockets.vcp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genrevision", "VC90\genrevision.vcproj", "{803F488E-4C5A-4866-8D5C-1E6C03C007C2}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACEWraper", "VC90\ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6348EA12C8}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACE_Wrappers", "VC90\ACE_vc9.vcproj", "{BD537C9A-FECA-1BAD-6757-8A6348EA12C8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From aef154279248c1a560c4b0c209c81ddaaa1eba13 Mon Sep 17 00:00:00 2001 From: thenecromancer Date: Sat, 6 Dec 2008 08:03:42 +0300 Subject: [PATCH 06/17] Set correct base damage for spell 37674 Signed-off-by: VladimirMangos --- src/game/SpellEffects.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index bec0756b8..f9c30d791 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -990,9 +990,14 @@ void Spell::EffectDummy(uint32 i) return; } case 37674: // Chaos Blast - if(unitTarget) - m_caster->CastSpell(unitTarget,37675,true); + { + if(!unitTarget) + return; + + int32 basepoints0 = 100; + m_caster->CastCustomSpell(unitTarget,37675,&basepoints0,NULL,NULL,true); return; + } case 40802: // Mingo's Fortune Generator (Mingo's Fortune Giblets) { // selecting one from Bloodstained Fortune item From 43f713f660107bf9c8c17306f555b416c3b9f6ca Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 6 Dec 2008 08:05:00 +0300 Subject: [PATCH 07/17] [6879] Not apply casting time spell bonuses mods to creature (non-pets) casted spells with 0 cast time. --- src/game/Unit.cpp | 4 ++++ src/shared/revision_nr.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 21d6aa831..f58e54e7d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10552,6 +10552,10 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply ) uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime ) { + // Not apply this to creature casted spells with casttime==0 + if(CastingTime==0 && GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) + return 3500; + if (CastingTime > 7000) CastingTime = 7000; if (CastingTime < 1500) CastingTime = 1500; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 53d0f4b8d..cfb991ff2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6878" + #define REVISION_NR "6879" #endif // __REVISION_NR_H__ From 3f90b661257433913f07a88a02c3cf6d36d2ec5b Mon Sep 17 00:00:00 2001 From: DasBlub Date: Sat, 6 Dec 2008 14:25:00 +0100 Subject: [PATCH 08/17] [6880] fixed spell 26275 for game object 180797 Signed-off-by: arrai --- src/game/SpellEffects.cpp | 32 ++++++++++++++++++++++++++++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index f9c30d791..767cd8ea7 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4587,6 +4587,38 @@ void Spell::EffectScriptEffect(uint32 effIndex) // by spell id switch(m_spellInfo->Id) { + // PX-238 Winter Wondervolt TRAP + case 26275: + { + if( unitTarget->HasAura(26272,0) + || unitTarget->HasAura(26157,0) + || unitTarget->HasAura(26273,0) + || unitTarget->HasAura(26274,0)) + return; + + uint32 iTmpSpellId; + + switch(urand(0,3)) + { + case 0: + iTmpSpellId = 26272; + break; + case 1: + iTmpSpellId = 26157; + break; + case 2: + iTmpSpellId = 26273; + break; + case 3: + iTmpSpellId = 26274; + break; + } + + unitTarget->CastSpell(unitTarget, iTmpSpellId, true); + + return; + } + // Bending Shinbone case 8856: { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index cfb991ff2..c726f0830 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6879" + #define REVISION_NR "6880" #endif // __REVISION_NR_H__ From 4df03b85611afe5a395aed0a33bf6e6903f28887 Mon Sep 17 00:00:00 2001 From: GalaxyMan Date: Sat, 6 Dec 2008 21:40:36 +0300 Subject: [PATCH 09/17] [6881] Fix typo in log string. Signed-off-by: VladimirMangos --- src/game/WorldSocketMgr.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 9bb11f8fe..610d0ac57 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -242,7 +242,7 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address) m_NetThreads = new ReactorRunnable[m_NetThreadsCount]; - sLog.outBasic ("Max alowed socket connections %d",ACE::max_handles ()); + sLog.outBasic ("Max allowed socket connections %d",ACE::max_handles ()); // -1 means use default m_SockOutKBuff = sConfig.GetIntDefault ("Network.OutKBuff", -1); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c726f0830..3cb4a4262 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6880" + #define REVISION_NR "6881" #endif // __REVISION_NR_H__ From e81af0b7393821a6a5472c46d314098d9db79b75 Mon Sep 17 00:00:00 2001 From: hunuza Date: Sun, 7 Dec 2008 13:19:16 +0100 Subject: [PATCH 10/17] [6882] Make corpse erase async. --- src/game/GlobalEvents.cpp | 79 ++++++++++++++++++++------------------- src/shared/revision_nr.h | 2 +- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/game/GlobalEvents.cpp b/src/game/GlobalEvents.cpp index 14ad25607..697c55b1f 100644 --- a/src/game/GlobalEvents.cpp +++ b/src/game/GlobalEvents.cpp @@ -29,49 +29,52 @@ #include "ObjectDefines.h" #include "Corpse.h" +static void CorpsesEraseCallBack(QueryResult *result, bool bones) +{ + if(!result) + return; + + do + { + Field *fields = result->Fetch(); + uint32 guidlow = fields[0].GetUInt32(); + float positionX = fields[1].GetFloat(); + float positionY = fields[2].GetFloat(); + uint32 mapid = fields[3].GetUInt32(); + uint64 player_guid = MAKE_NEW_GUID(fields[4].GetUInt32(), 0, HIGHGUID_PLAYER); + + uint64 guid = MAKE_NEW_GUID(guidlow, 0, HIGHGUID_CORPSE); + + sLog.outDebug("[Global event] Removing %s %u (X:%f Y:%f Map:%u).",(bones?"bones":"corpse"),guidlow,positionX,positionY,mapid); + + /// Resurrectable - convert corpses to bones + if(!bones) + { + if(!ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid)) + { + sLog.outDebug("Corpse %u not found in world. Delete from DB.",guidlow); + CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow); + } + } + else + ///- or delete bones + { + MapManager::Instance().RemoveBonesFromMap(mapid, guid, positionX, positionY); + + ///- remove bones from the database + CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow); + } + } while (result->NextRow()); + + delete result; +} + /// Handle periodic erase of corpses and bones static void CorpsesErase(bool bones,uint32 delay) { ///- Get the list of eligible corpses/bones to be removed //No SQL injection (uint32 and enum) - QueryResult *result = CharacterDatabase.PQuery("SELECT guid,position_x,position_y,map,player FROM corpse WHERE UNIX_TIMESTAMP()-time > '%u' AND corpse_type %s '0'", delay, (bones ? "=" : "<>") ); - - if(result) - { - do - { - Field *fields = result->Fetch(); - uint32 guidlow = fields[0].GetUInt32(); - float positionX = fields[1].GetFloat(); - float positionY = fields[2].GetFloat(); - uint32 mapid = fields[3].GetUInt32(); - uint64 player_guid = MAKE_NEW_GUID(fields[4].GetUInt32(), 0, HIGHGUID_PLAYER); - - uint64 guid = MAKE_NEW_GUID(guidlow, 0, HIGHGUID_CORPSE); - - sLog.outDebug("[Global event] Removing %s %u (X:%f Y:%f Map:%u).",(bones?"bones":"corpse"),guidlow,positionX,positionY,mapid); - - /// Resurrectable - convert corpses to bones - if(!bones) - { - if(!ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid)) - { - sLog.outDebug("Corpse %u not found in world. Delete from DB.",guidlow); - CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow); - } - } - else - ///- or delete bones - { - MapManager::Instance().RemoveBonesFromMap(mapid, guid, positionX, positionY); - - ///- remove bones from the database - CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow); - } - } while (result->NextRow()); - - delete result; - } + CharacterDatabase.AsyncPQuery(&CorpsesEraseCallBack, bones, "SELECT guid,position_x,position_y,map,player FROM corpse WHERE UNIX_TIMESTAMP()-time > '%u' AND corpse_type %s '0'", delay, (bones ? "=" : "<>")); } /// not thread guarded variant for call from other thread diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3cb4a4262..1311b2733 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6881" + #define REVISION_NR "6882" #endif // __REVISION_NR_H__ From 66c98859cf2a6abe5b82e58d55219a19827ae1b1 Mon Sep 17 00:00:00 2001 From: hunuza Date: Sun, 7 Dec 2008 15:41:05 +0100 Subject: [PATCH 11/17] [6883] Avoid DB access on deleting guild member. --- src/game/GlobalEvents.cpp | 1 + src/game/Guild.cpp | 76 +++++++++++++++++++-------------------- src/shared/revision_nr.h | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/game/GlobalEvents.cpp b/src/game/GlobalEvents.cpp index 697c55b1f..219086c61 100644 --- a/src/game/GlobalEvents.cpp +++ b/src/game/GlobalEvents.cpp @@ -22,6 +22,7 @@ #include "Log.h" #include "Database/DatabaseEnv.h" +#include "Database/DatabaseImpl.h" #include "Platform/Define.h" #include "MapManager.h" #include "ObjectAccessor.h" diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index 84b6c6965..19f6214b8 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -417,53 +417,53 @@ void Guild::DelMember(uint64 guid, bool isDisbanding) { if(leaderGuid == guid && !isDisbanding) { - QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid='%u' AND guid != '%u' ORDER BY rank ASC LIMIT 1", Id, GUID_LOPART(leaderGuid)); - if( result ) + MemberSlot* oldLeader = NULL; + MemberSlot* best = NULL; + uint64 newLeaderGUID = 0; + for(Guild::MemberList::iterator i = members.begin(); i != members.end(); ++i) { - uint64 newLeaderGUID; - Player *newLeader; - std::string newLeaderName, oldLeaderName; - - newLeaderGUID = (*result)[0].GetUInt64(); - delete result; - - SetLeader(newLeaderGUID); - - newLeader = objmgr.GetPlayer(newLeaderGUID); - - // If player not online data in data field will be loaded from guild tabs no need to update it !! - if(newLeader) + if(i->first == GUID_LOPART(guid)) { - newLeader->SetRank(GR_GUILDMASTER); - newLeaderName = newLeader->GetName(); - } - else - objmgr.GetPlayerNameByGUID(newLeaderGUID, newLeaderName); - - // when leader non-exist (at guild load with deleted leader only) not send broadcasts - if(objmgr.GetPlayerNameByGUID(guid, oldLeaderName)) - { - WorldPacket data(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1+newLeaderName.size()+1)); - data << (uint8)GE_LEADER_CHANGED; - data << (uint8)2; - data << oldLeaderName; - data << newLeaderName; - BroadcastPacket(&data); - - data.Initialize(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1)); - data << (uint8)GE_LEFT; - data << (uint8)1; - data << oldLeaderName; - BroadcastPacket(&data); + oldLeader = &(i->second); + continue; } - sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" ); + if(!best || best->RankId > i->second.RankId) + { + best = &(i->second); + newLeaderGUID = i->first; + } } - else + if(!best) { Disband(); return; } + + SetLeader(newLeaderGUID); + + // If player not online data in data field will be loaded from guild tabs no need to update it !! + if(Player *newLeader = objmgr.GetPlayer(newLeaderGUID)) + newLeader->SetRank(GR_GUILDMASTER); + + // when leader non-exist (at guild load with deleted leader only) not send broadcasts + if(oldLeader) + { + WorldPacket data(SMSG_GUILD_EVENT, (1+1+(oldLeader->name).size()+1+(best->name).size()+1)); + data << (uint8)GE_LEADER_CHANGED; + data << (uint8)2; + data << oldLeader->name; + data << best->name; + BroadcastPacket(&data); + + data.Initialize(SMSG_GUILD_EVENT, (1+1+(oldLeader->name).size()+1)); + data << (uint8)GE_LEFT; + data << (uint8)1; + data << oldLeader->name; + BroadcastPacket(&data); + } + + sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" ); } members.erase(GUID_LOPART(guid)); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1311b2733..c66531390 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6882" + #define REVISION_NR "6883" #endif // __REVISION_NR_H__ From 2e08a63da71703107ffb99262b84e88f8fe70b1d Mon Sep 17 00:00:00 2001 From: balrok Date: Sun, 7 Dec 2008 00:39:22 +0100 Subject: [PATCH 12/17] [6884] Replaced iterator++ with ++iterator in for-loop-headers i used this script for i in ls *.[ch]*; do cat $i | sed -r 's/(.*for.*iterator.*;\ *)([a-z0-9\_\*]+)\ *\+\+(.*)/\1++\2\3/' > /tmp/mangos/$i; done for i in ls *.[ch]*; do cp /tmp/mangos/$i $i; done and rechecked it with my eyes, if everything is right i took only for-loops cause they can be gathered easier with a script Signed-off-by: hunuza --- src/game/ArenaTeam.cpp | 2 +- src/game/Creature.cpp | 4 ++-- src/game/GossipDef.cpp | 2 +- src/game/Group.cpp | 2 +- src/game/InstanceSaveMgr.cpp | 2 +- src/game/LootMgr.cpp | 8 ++++---- src/game/MapInstanced.cpp | 10 +++++----- src/game/ObjectMgr.cpp | 18 +++++++++--------- src/game/Pet.cpp | 2 +- src/game/Player.cpp | 18 +++++++++--------- src/game/Spell.cpp | 4 ++-- src/game/SpellAuras.cpp | 2 +- src/game/ThreatManager.cpp | 4 ++-- src/shared/revision_nr.h | 2 +- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index b35ce1e36..72ed8d679 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -472,7 +472,7 @@ uint8 ArenaTeam::GetSlot() const void ArenaTeam::BroadcastPacket(WorldPacket *packet) { - for (MemberList::iterator itr = members.begin(); itr != members.end(); itr++) + for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { Player *player = objmgr.GetPlayer(itr->guid); if(player) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index c832804f5..00aed3c0e 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -689,7 +689,7 @@ void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid ) // lazy loading single time at use LoadGossipOptions(); - for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ ) + for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); ++i ) { GossipOption* gso=&*i; if(gso->GossipId == gossipid) @@ -1009,7 +1009,7 @@ uint32 Creature::GetNpcTextId() GossipOption const* Creature::GetGossipOption( uint32 id ) const { - for( GossipOptionList::const_iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ ) + for( GossipOptionList::const_iterator i = m_goptions.begin( ); i != m_goptions.end( ); ++i ) { if(i->Action==id ) return &*i; diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 173e69f66..fc0671b55 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -332,7 +332,7 @@ void QuestMenu::AddMenuItem( uint32 QuestId, uint8 Icon) bool QuestMenu::HasItem( uint32 questid ) { - for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); i++) + for (QuestMenuItemList::iterator i = m_qItems.begin(); i != m_qItems.end(); ++i) { if(i->m_qId==questid) { diff --git a/src/game/Group.cpp b/src/game/Group.cpp index cb03edabd..9cf107f06 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -1109,7 +1109,7 @@ void Group::_setLeader(const uint64 &guid) void Group::_removeRolls(const uint64 &guid) { - for (Rolls::iterator it = RollId.begin(); it < RollId.end(); it++) + for (Rolls::iterator it = RollId.begin(); it < RollId.end(); ++it) { Roll* roll = *it; Roll::PlayerVote::iterator itr2 = roll->playerVote.find(guid); diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index 2f1833480..8fa06c3cb 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -339,7 +339,7 @@ void InstanceSaveManager::PackInstances() uint32 InstanceNumber = 1; // we do assume std::set is sorted properly on integer value - for (std::set< uint32 >::iterator i = InstanceSet.begin(); i != InstanceSet.end(); i++) + for (std::set< uint32 >::iterator i = InstanceSet.begin(); i != InstanceSet.end(); ++i) { if (*i != InstanceNumber) { diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index c61e22b7e..44e9d5982 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -910,7 +910,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, uint8 groupId) co } // Rolling non-grouped items - for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; i++ ) + for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i ) { if ( !i->Roll() ) continue; // Bad luck for the entry @@ -930,7 +930,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, uint8 groupId) co } // Now processing groups - for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; i++ ) + for (LootGroups::const_iterator i = Groups.begin( ) ; i != Groups.end( ) ; ++i ) i->Process(loot); } @@ -959,7 +959,7 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con } // Now processing groups - for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; i++ ) + for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i ) if (i->HasQuestDrop()) return true; @@ -977,7 +977,7 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co } // Checking non-grouped entries - for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; i++ ) + for (LootStoreItemList::const_iterator i = Entries.begin() ; i != Entries.end() ; ++i ) { if (i->mincountOrRef < 0) // References processing { diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index 79a8b88d4..8037e907d 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -57,7 +57,7 @@ void MapInstanced::Update(const uint32& t) void MapInstanced::MoveAllCreaturesInMoveList() { - for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++) + for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) { i->second->MoveAllCreaturesInMoveList(); } @@ -67,7 +67,7 @@ void MapInstanced::MoveAllCreaturesInMoveList() void MapInstanced::RemoveAllObjectsInRemoveList() { - for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++) + for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) { i->second->RemoveAllObjectsInRemoveList(); } @@ -79,7 +79,7 @@ bool MapInstanced::RemoveBones(uint64 guid, float x, float y) { bool remove_result = false; - for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++) + for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) { remove_result = remove_result || i->second->RemoveBones(guid, x, y); } @@ -90,11 +90,11 @@ bool MapInstanced::RemoveBones(uint64 guid, float x, float y) void MapInstanced::UnloadAll(bool pForce) { // Unload instanced maps - for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++) + for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) i->second->UnloadAll(pForce); // Delete the maps only after everything is unloaded to prevent crashes - for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); i++) + for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) delete i->second; m_InstancedMaps.clear(); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index e1ab90d18..a936c0cc2 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -192,7 +192,7 @@ Group * ObjectMgr::GetGroupByLeader(const uint64 &guid) const Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const { - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) if ((*itr)->GetId() == GuildId) return *itr; @@ -201,7 +201,7 @@ Guild * ObjectMgr::GetGuildById(const uint32 GuildId) const Guild * ObjectMgr::GetGuildByName(std::string guildname) const { - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) if ((*itr)->GetName() == guildname) return *itr; @@ -210,7 +210,7 @@ Guild * ObjectMgr::GetGuildByName(std::string guildname) const std::string ObjectMgr::GetGuildNameById(const uint32 GuildId) const { - for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); itr++) + for(GuildSet::const_iterator itr = mGuildSet.begin(); itr != mGuildSet.end(); ++itr) if ((*itr)->GetId() == GuildId) return (*itr)->GetName(); @@ -228,7 +228,7 @@ Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 ArenaTeamId) const { - for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) + for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); ++itr) if ((*itr)->GetId() == ArenaTeamId) return *itr; @@ -237,7 +237,7 @@ ArenaTeam* ObjectMgr::GetArenaTeamById(const uint32 ArenaTeamId) const ArenaTeam* ObjectMgr::GetArenaTeamByName(std::string arenateamname) const { - for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) + for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); ++itr) if ((*itr)->GetName() == arenateamname) return *itr; @@ -246,7 +246,7 @@ ArenaTeam* ObjectMgr::GetArenaTeamByName(std::string arenateamname) const ArenaTeam* ObjectMgr::GetArenaTeamByCapitan(uint64 const& guid) const { - for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); itr++) + for(ArenaTeamSet::const_iterator itr = mArenaTeamSet.begin(); itr != mArenaTeamSet.end(); ++itr) if ((*itr)->GetCaptain() == guid) return *itr; @@ -2862,7 +2862,7 @@ void ObjectMgr::LoadQuests() delete result; // Post processing - for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); iter++) + for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); ++iter) { Quest * qinfo = iter->second; @@ -4081,7 +4081,7 @@ void ObjectMgr::LoadPageTexts() { std::ostringstream ss; ss<< "The text page(s) "; - for (std::set::iterator itr= checkedPages.begin();itr!=checkedPages.end(); itr++) + for (std::set::iterator itr= checkedPages.begin();itr!=checkedPages.end(); ++itr) ss << *itr << " "; ss << "create(s) a circular reference, which can cause the server to freeze. Changing Next_Page of page " << pageItr->Page_ID <<" to 0"; @@ -5065,7 +5065,7 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const { const MapEntry *mapEntry = sMapStore.LookupEntry(Map); if(!mapEntry) return NULL; - for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); itr++) + for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); ++itr) { if(itr->second.target_mapId == mapEntry->entrance_map) { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 40cdd9f75..4bd8a1934 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1493,7 +1493,7 @@ bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 s uint32 chainstart = spellmgr.GetFirstSpellInChain(spell_id); - for (PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); itr++) + for (PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { if(itr->second->state == PETSPELL_REMOVED) continue; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 2c02327c6..a6989dd82 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2390,7 +2390,7 @@ void Player::SendInitialSpells() uint16 spellCooldowns = m_spellCooldowns.size(); data << uint16(spellCooldowns); - for(SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); itr++) + for(SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); ++itr) { SpellEntry const *sEntry = sSpellStore.LookupEntry(itr->first); if(!sEntry) @@ -3212,7 +3212,7 @@ bool Player::_removeSpell(uint16 spell_id) Mail* Player::GetMail(uint32 id) { - for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); itr++) + for(PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) { if ((*itr)->messageID == id) { @@ -5400,7 +5400,7 @@ void Player::SendInitialReputations() RepListID a = 0; - for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); itr++) + for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr) { // fill in absent fields for (; a != itr->first; a++) @@ -6353,7 +6353,7 @@ void Player::DuelComplete(DuelCompleteType type) /* remove auras */ std::vector auras2remove; AuraMap const& vAuras = duel->opponent->GetAuras(); - for (AuraMap::const_iterator i = vAuras.begin(); i != vAuras.end(); i++) + for (AuraMap::const_iterator i = vAuras.begin(); i != vAuras.end(); ++i) { if (!i->second->IsPositive() && i->second->GetCasterGUID() == GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) auras2remove.push_back(i->second->GetId()); @@ -6364,7 +6364,7 @@ void Player::DuelComplete(DuelCompleteType type) auras2remove.clear(); AuraMap const& auras = GetAuras(); - for (AuraMap::const_iterator i = auras.begin(); i != auras.end(); i++) + for (AuraMap::const_iterator i = auras.begin(); i != auras.end(); ++i) { if (!i->second->IsPositive() && i->second->GetCasterGUID() == duel->opponent->GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) auras2remove.push_back(i->second->GetId()); @@ -14662,13 +14662,13 @@ void Player::SendRaidInfo() uint32 counter = 0, i; for(i = 0; i < TOTAL_DIFFICULTIES; i++) - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); itr++) + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) if(itr->second.perm) counter++; data << counter; for(i = 0; i < TOTAL_DIFFICULTIES; i++) { - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); itr++) + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { if(itr->second.perm) { @@ -15165,7 +15165,7 @@ void Player::_SaveMail() if (!m_mailsLoaded) return; - for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); itr++) + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) { Mail *m = (*itr); if (m->state == MAIL_STATE_CHANGED) @@ -15846,7 +15846,7 @@ void Player::PetSpellInitialize() if(pet->isControlled() && (pet->getPetType() == HUNTER_PET || cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)) { - for(PetSpellMap::iterator itr = pet->m_spells.begin();itr != pet->m_spells.end();itr++) + for(PetSpellMap::iterator itr = pet->m_spells.begin();itr != pet->m_spells.end();++itr) { if(itr->second->state == PETSPELL_REMOVED) continue; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 2a0ac63c9..f1fa68b8a 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -637,7 +637,7 @@ void Spell::FillTargetMap() if(m_caster->GetTypeId() == TYPEID_PLAYER) { Player *me = (Player*)m_caster; - for (std::list::const_iterator itr = tmpUnitMap.begin(); itr != tmpUnitMap.end(); itr++) + for (std::list::const_iterator itr = tmpUnitMap.begin(); itr != tmpUnitMap.end(); ++itr) { Unit *owner = (*itr)->GetOwner(); Unit *u = owner ? owner : (*itr); @@ -4150,7 +4150,7 @@ uint8 Spell::CheckCasterAuras() const { //Checking auras is needed now, because you are prevented by some state but the spell grants immunity. Unit::AuraMap const& auras = m_caster->GetAuras(); - for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); itr++) + for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if(itr->second) { diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index b4741b435..8cb0bcb3c 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2141,7 +2141,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) // have a look if there is still some other Lifebloom dummy aura Unit::AuraList auras = m_target->GetAurasByType(SPELL_AURA_DUMMY); - for(Unit::AuraList::iterator itr = auras.begin(); itr!=auras.end(); itr++) + for(Unit::AuraList::iterator itr = auras.begin(); itr!=auras.end(); ++itr) if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && (*itr)->GetSpellProto()->SpellFamilyFlags & 0x1000000000LL) return; diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 537e0e4d9..069115493 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -192,7 +192,7 @@ Unit* HostilReference::getSourceUnit() void ThreatContainer::clearReferences() { - for(std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); i++) + for(std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { (*i)->unlink(); delete (*i); @@ -206,7 +206,7 @@ HostilReference* ThreatContainer::getReferenceByTarget(Unit* pVictim) { HostilReference* result = NULL; uint64 guid = pVictim->GetGUID(); - for(std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); i++) + for(std::list::iterator i = iThreatList.begin(); i != iThreatList.end(); ++i) { if((*i)->getUnitGuid() == guid) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c66531390..430e9c2b3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6883" + #define REVISION_NR "6884" #endif // __REVISION_NR_H__ From a3a57a539004e5bb9b4f5c12e226c8f24f9c1ef5 Mon Sep 17 00:00:00 2001 From: arrai Date: Sun, 7 Dec 2008 21:26:47 +0100 Subject: [PATCH 13/17] [6885] In dungeons even fighting creatures are supposed to put nearby players in combat. 3rd party scripting libraries might have to be updated --- src/game/AggressorAI.cpp | 14 +++++++++++--- src/game/GridNotifiersImpl.h | 6 +++--- src/shared/revision_nr.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index 637410c1f..25244e7a2 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -47,15 +47,23 @@ AggressorAI::MoveInLineOfSight(Unit *u) if( !i_creature.canFly() && i_creature.GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE ) return; - if( !i_creature.getVictim() && !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() && + if( !i_creature.hasUnitState(UNIT_STAT_STUNNED) && u->isTargetableForAttack() && ( i_creature.IsHostileTo( u ) /*|| u->getVictim() && i_creature.IsFriendlyTo( u->getVictim() )*/ ) && u->isInAccessablePlaceFor(&i_creature) ) { float attackRadius = i_creature.GetAttackDistance(u); if(i_creature.IsWithinDistInMap(u, attackRadius) && i_creature.IsWithinLOSInMap(u) ) { - AttackStart(u); - u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + if(!i_creature.getVictim()) + { + AttackStart(u); + u->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); + } + else if(sMapStore.LookupEntry(i_creature.GetMapId())->IsDungeon()) + { + u->SetInCombatWith(&i_creature); + i_creature.AddThreat(u, 0.0f); + } } } } diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index 05eb46197..602d3d247 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -70,7 +70,7 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) pl->UpdateVisibilityOf(c); // Creature AI reaction - if(!c->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) + if(!c->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { if( c->AI() && c->AI()->IsVisible(pl) && !c->IsInEvadeMode() ) c->AI()->MoveInLineOfSight(pl); @@ -79,13 +79,13 @@ inline void PlayerCreatureRelocationWorker(Player* pl, Creature* c) inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) { - if(!c1->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) + if(!c1->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { if( c1->AI() && c1->AI()->IsVisible(c2) && !c1->IsInEvadeMode() ) c1->AI()->MoveInLineOfSight(c2); } - if(!c2->hasUnitState(UNIT_STAT_CHASE | UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) + if(!c2->hasUnitState(UNIT_STAT_SEARCHING | UNIT_STAT_FLEEING)) { if( c2->AI() && c2->AI()->IsVisible(c1) && !c2->IsInEvadeMode() ) c2->AI()->MoveInLineOfSight(c1); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 430e9c2b3..6a19ed4cf 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6884" + #define REVISION_NR "6885" #endif // __REVISION_NR_H__ From 8eccdbc0469c9e6a39743b56fed481f7b6606329 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sun, 7 Dec 2008 23:47:28 +0300 Subject: [PATCH 14/17] [6886] Prevent some memory losses at server shutdown. --- src/game/World.cpp | 3 +++ src/shared/revision_nr.h | 2 +- src/shared/vmap/VMapFactory.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/game/World.cpp b/src/game/World.cpp index 8ee55172b..2c2e87a3d 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -125,6 +125,9 @@ World::~World() m_weathers.clear(); + while (!cliCmdQueue.empty()) + delete cliCmdQueue.next(); + VMAP::VMapFactory::clear(); if(m_resultQueue) delete m_resultQueue; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 6a19ed4cf..936d41044 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6885" + #define REVISION_NR "6886" #endif // __REVISION_NR_H__ diff --git a/src/shared/vmap/VMapFactory.cpp b/src/shared/vmap/VMapFactory.cpp index 172aa9b25..5a5af7b45 100644 --- a/src/shared/vmap/VMapFactory.cpp +++ b/src/shared/vmap/VMapFactory.cpp @@ -97,8 +97,14 @@ namespace VMAP void VMapFactory::clear() { if(iIgnoreSpellIds) + { delete iIgnoreSpellIds; + iIgnoreSpellIds = NULL; + } if(gVMapManager) + { delete gVMapManager; + gVMapManager = NULL; + } } } From 211f987aa9d4a13d80da5994e5d42e0297979111 Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Sun, 7 Dec 2008 00:26:07 +0100 Subject: [PATCH 15/17] Make flying creatures fall on ground when killed. Fix also fly speed computation for creatures. Signed-off-by: Neo2003 --- src/game/Creature.cpp | 30 ++++++++++++++++++++++++++++++ src/game/Creature.h | 1 + src/game/Traveller.h | 7 ++++++- src/game/Unit.h | 3 ++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 00aed3c0e..5a1a80f2e 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -446,6 +446,11 @@ void Creature::Update(uint32 diff) m_regenTimer = 2000; break; } + case DEAD_FALLING: + { + if (!FallGround()) + setDeathState(JUST_DIED); + } default: break; } @@ -1487,6 +1492,9 @@ void Creature::setDeathState(DeathState s) if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) SaveRespawnTime(); + if (canFly() && FallGround()) + return; + if(!IsStopped()) StopMoving(); } @@ -1501,6 +1509,9 @@ void Creature::setDeathState(DeathState s) if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) ) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); + if (canFly() && FallGround()) + return; + Unit::setDeathState(CORPSE); } if(s == JUST_ALIVED) @@ -1520,6 +1531,25 @@ void Creature::setDeathState(DeathState s) } } +bool Creature::FallGround() +{ + // Let's abort after we called this function one time + if (getDeathState() == DEAD_FALLING) + return false; + + // Let's do with no vmap because no way to get far distance with vmap high call + float tz = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), false); + + // Abort too if the ground is very near + if (fabs(GetPositionZ() - tz) < 0.1f) + return false; + + Unit::setDeathState(DEAD_FALLING); + GetMotionMaster()->MovePoint(0, GetPositionX(), GetPositionY(), tz); + Relocate(GetPositionX(), GetPositionY(), tz); + return true; +} + void Creature::Respawn() { RemoveCorpse(); diff --git a/src/game/Creature.h b/src/game/Creature.h index 98f54017e..3c7825706 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -521,6 +521,7 @@ class MANGOS_DLL_SPEC Creature : public Unit const char* GetNameForLocaleIdx(int32 locale_idx) const; void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState + bool FallGround(); bool LoadFromDB(uint32 guid, Map *map); void SaveToDB(); diff --git a/src/game/Traveller.h b/src/game/Traveller.h index 1d50d488a..9256b9162 100644 --- a/src/game/Traveller.h +++ b/src/game/Traveller.h @@ -59,7 +59,12 @@ struct MANGOS_DLL_DECL Traveller template<> inline float Traveller::Speed() { - return i_traveller.GetSpeed( i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE) ? MOVE_WALK : MOVE_RUN); + if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + return i_traveller.GetSpeed(MOVE_WALK); + else if(i_traveller.HasUnitMovementFlag(MOVEMENTFLAG_FLYING2)) + return i_traveller.GetSpeed(MOVE_FLY); + else + return i_traveller.GetSpeed(MOVE_RUN); } template<> diff --git a/src/game/Unit.h b/src/game/Unit.h index 298023665..e4df75950 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -339,7 +339,8 @@ enum DeathState JUST_DIED = 1, CORPSE = 2, DEAD = 3, - JUST_ALIVED = 4 + JUST_ALIVED = 4, + DEAD_FALLING= 5 }; enum UnitState From 09c27ec667e7d9bf3c9e0213abacb98797ebcaf8 Mon Sep 17 00:00:00 2001 From: Neo2003 Date: Sun, 7 Dec 2008 13:03:24 +0100 Subject: [PATCH 16/17] [6887] Position dead flying creatures on ground at creature loading. Signed-off-by: Neo2003 --- src/game/Creature.cpp | 8 ++++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 5a1a80f2e..880427b81 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1345,7 +1345,15 @@ bool Creature::LoadFromDB(uint32 guid, Map *map) m_respawnTime = objmgr.GetCreatureRespawnTime(m_DBTableGuid,GetInstanceId()); if(m_respawnTime > time(NULL)) // not ready to respawn + { m_deathState = DEAD; + if(canFly()) + { + float tz = GetMap()->GetHeight(data->posX,data->posY,data->posZ,false); + if(data->posZ - tz > 0.1) + Relocate(data->posX,data->posY,tz); + } + } else if(m_respawnTime) // respawn time set but expired { m_respawnTime = 0; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 936d41044..e5caac4b2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6886" + #define REVISION_NR "6887" #endif // __REVISION_NR_H__ From 480a935216c0b3d4139b5441f0153756312f5f32 Mon Sep 17 00:00:00 2001 From: KAPATEJIb Date: Mon, 8 Dec 2008 11:34:20 +0300 Subject: [PATCH 17/17] [6888] Add to character.sql not added changes from 2008_11_12_01_character_character_aura.sql Signed-off-by: VladimirMangos --- sql/characters.sql | 2 ++ src/shared/revision_nr.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/characters.sql b/sql/characters.sql index 733f4d3a4..f73ca3c78 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -249,6 +249,7 @@ CREATE TABLE `character_aura` ( `caster_guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Full Global Unique Identifier', `spell` int(11) unsigned NOT NULL default '0', `effect_index` int(11) unsigned NOT NULL default '0', + `stackcount` int(11) NOT NULL default '1', `amount` int(11) NOT NULL default '0', `maxduration` int(11) NOT NULL default '0', `remaintime` int(11) NOT NULL default '0', @@ -1125,6 +1126,7 @@ CREATE TABLE `pet_aura` ( `caster_guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Full Global Unique Identifier', `spell` int(11) unsigned NOT NULL default '0', `effect_index` int(11) unsigned NOT NULL default '0', + `stackcount` int(11) NOT NULL default '1', `amount` int(11) NOT NULL default '0', `maxduration` int(11) NOT NULL default '0', `remaintime` int(11) NOT NULL default '0', diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e5caac4b2..934202b1d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6887" + #define REVISION_NR "6888" #endif // __REVISION_NR_H__