aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximius <none@none>2009-09-11 16:25:11 -0700
committermaximius <none@none>2009-09-11 16:25:11 -0700
commit2bb0c319789c893255d94556bd8a819f96be0c0d (patch)
tree8ac2b7dded072fce9ff871b4ffc7990b018143cb
parent996fcc967f05e304cc0e51bb4e0dd2d5a0de17c9 (diff)
*[8474] Allow to delete BattleGround objects when any of invited players didn't click to enter battle. Rename m_TeamScores500disadvantage to m_TeamScores500Disadvantage, and optimize its update. Patch is tested. Author: Triply
*Added some missed changes that might of broken compile in the last 2~ commits. *Some fixes to Warlock's Death Coil by Gyullo. *Last MaNGOS merge until KingPin says otherwise.. --HG-- branch : trunk
-rw-r--r--sql/updates/5628_character_8433_01_characters_character_account_data.sql1
-rw-r--r--src/game/AchievementMgr.cpp2
-rw-r--r--src/game/BattleGround.cpp39
-rw-r--r--src/game/BattleGroundAB.cpp21
-rw-r--r--src/game/BattleGroundAB.h4
-rw-r--r--src/game/BattleGroundMgr.cpp19
-rw-r--r--src/game/PoolHandler.h2
-rw-r--r--src/game/Spell.h1
-rw-r--r--src/game/SpellEffects.cpp2
9 files changed, 48 insertions, 43 deletions
diff --git a/sql/updates/5628_character_8433_01_characters_character_account_data.sql b/sql/updates/5628_character_8433_01_characters_character_account_data.sql
index f1979ad3cda..50449a30fee 100644
--- a/sql/updates/5628_character_8433_01_characters_character_account_data.sql
+++ b/sql/updates/5628_character_8433_01_characters_character_account_data.sql
@@ -1,3 +1,4 @@
+
-- ALTER TABLE character_db_version CHANGE COLUMN required_8433_01_characters_character_account_data required_8469_01_characters_character_spell bit;
DELETE FROM character_spell WHERE spell in (
diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp
index 67fea7e36d5..f4512db3793 100644
--- a/src/game/AchievementMgr.cpp
+++ b/src/game/AchievementMgr.cpp
@@ -760,7 +760,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
{
if (bg->GetTypeID() != BATTLEGROUND_AB)
continue;
- if(!((BattleGroundAB*)bg)->IsTeamScores500disadvantage(GetPlayer()->GetTeam()))
+ if(!((BattleGroundAB*)bg)->IsTeamScores500Disadvantage(GetPlayer()->GetTeam()))
continue;
break;
}
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 91e52858a65..8ac19588b7c 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -237,9 +237,22 @@ BattleGround::~BattleGround()
void BattleGround::Update(uint32 diff)
{
- if (!GetPlayersSize() && !GetReviveQueueSize())
+ if (!GetPlayersSize())
+ {
//BG is empty
+ // if there are no players invited, delete BG
+ // this will delete arena or bg object, where any player entered
+ // [[ but if you use battleground object again (more battles possible to be played on 1 instance)
+ // then this condition should be removed and code:
+ // if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
+ // this->AddToFreeBGObjectsQueue(); // not yet implemented
+ // should be used instead of current
+ // ]]
+ // BattleGround Template instance cannot be updated, because it would be deleted
+ if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
+ m_SetDeleteThis = true;
return;
+ }
// remove offline players from bg after 5 minutes
if (!m_OfflineQueue.empty())
@@ -1061,7 +1074,11 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
DecreaseInvitedCount(team);
//we should update battleground queue, but only if bg isn't ending
if (isBattleGround() && GetStatus() < STATUS_WAIT_LEAVE)
+ {
+ // a player has left the battleground, so there are free slots -> add to queue
+ AddToBGFreeSlotQueue();
sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, GetQueueId());
+ }
// Let others know
WorldPacket data;
sBattleGroundMgr.BuildPlayerLeftBattleGroundPacket(&data, guid);
@@ -1081,17 +1098,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
sLog.outDetail("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName());
}
- if (!GetPlayersSize() && !GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
- {
- // if no players left AND no invitees left, set this bg to delete in next update
- // direct deletion could cause crashes
- m_SetDeleteThis = true;
- // return to prevent addition to freeslotqueue
- return;
- }
-
- // a player exited the battleground, so there are free slots. add to queue
- this->AddToBGFreeSlotQueue();
+ //battleground object will be deleted next BattleGround::Update() call
}
// this method is called when no players remains in battleground
@@ -1126,9 +1133,15 @@ void BattleGround::Reset()
void BattleGround::StartBattleGround()
{
- ///this method should spawn spirit guides and so on
SetStartTime(0);
SetLastResurrectTime(0);
+ // add BG to free slot queue
+ AddToBGFreeSlotQueue();
+
+ // add bg to update list
+ // This must be done here, because we need to have already invited some players when first BG::Update() method is executed
+ // and it doesn't matter if we call StartBattleGround() more times, because m_BattleGrounds is a map and instance id never changes
+ sBattleGroundMgr.AddBattleGround(GetInstanceID(), GetTypeID(), this);
if(m_IsRated)
sLog.outArena("Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]);
}
diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp
index 70709af42ad..a6e9e9b97d7 100644
--- a/src/game/BattleGroundAB.cpp
+++ b/src/game/BattleGroundAB.cpp
@@ -158,21 +158,14 @@ void BattleGroundAB::Update(uint32 diff)
UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]);
if (team == BG_TEAM_HORDE)
UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]);
+ // update achievement flags
+ // we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources
+ uint8 otherTeam = (team + 1) % BG_TEAMS_COUNT;
+ if (m_TeamScores[team] > m_TeamScores[otherTeam] + 500)
+ m_TeamScores500Disadvantage[otherTeam] = true;
}
}
- // achievements flags
- if (m_TeamScores[BG_TEAM_ALLIANCE] > m_TeamScores[BG_TEAM_HORDE])
- {
- if (m_TeamScores[BG_TEAM_ALLIANCE] - m_TeamScores[BG_TEAM_HORDE] >= 500)
- m_TeamScores500disadvantage[BG_TEAM_HORDE] = true;
- }
- else
- {
- if (m_TeamScores[BG_TEAM_HORDE] - m_TeamScores[BG_TEAM_ALLIANCE] >= 500)
- m_TeamScores500disadvantage[BG_TEAM_ALLIANCE] = true;
- }
-
// Test win condition
if (m_TeamScores[BG_TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE)
EndBattleGround(ALLIANCE);
@@ -603,8 +596,8 @@ void BattleGroundAB::Reset()
bool isBGWeekend = false; //TODO FIXME - call sBattleGroundMgr.IsBGWeekend(m_TypeID); - you must also implement that call!
m_HonorTics = (isBGWeekend) ? BG_AB_ABBGWeekendHonorTicks : BG_AB_NotABBGWeekendHonorTicks;
m_ReputationTics = (isBGWeekend) ? BG_AB_ABBGWeekendReputationTicks : BG_AB_NotABBGWeekendReputationTicks;
- m_TeamScores500disadvantage[BG_TEAM_ALLIANCE] = false;
- m_TeamScores500disadvantage[BG_TEAM_HORDE] = false;
+ m_TeamScores500Disadvantage[BG_TEAM_ALLIANCE] = false;
+ m_TeamScores500Disadvantage[BG_TEAM_HORDE] = false;
for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
{
diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h
index 1a940a041d4..ef151ad187b 100644
--- a/src/game/BattleGroundAB.h
+++ b/src/game/BattleGroundAB.h
@@ -264,7 +264,7 @@ class BattleGroundAB : public BattleGround
/* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited
- bool IsTeamScores500disadvantage(uint32 team) const { return m_TeamScores500disadvantage[GetTeamIndexByTeamId(team)]; }
+ bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
private:
/* Gameobject spawning/despawning */
void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);
@@ -295,7 +295,7 @@ class BattleGroundAB : public BattleGround
uint32 m_HonorTics;
uint32 m_ReputationTics;
// need for achievements
- bool m_TeamScores500disadvantage[BG_TEAMS_COUNT];
+ bool m_TeamScores500Disadvantage[BG_TEAMS_COUNT];
};
#endif
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index 49424249eb3..a06b7f45f7b 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -1184,13 +1184,16 @@ void BattleGroundMgr::Update(uint32 diff)
if (!m_QueueUpdateScheduler.empty())
{
//copy vector and clear the other
+ // TODO add lock
+ // TODO maybe std::list would be better and then unlock after end of cycle
std::vector<uint32> scheduled(m_QueueUpdateScheduler);
m_QueueUpdateScheduler.clear();
+ // TODO drop lock
for (uint8 i = 0; i < scheduled.size(); i++)
{
- BattleGroundQueueTypeId bgQueueTypeId = BattleGroundQueueTypeId(scheduled[i] / 65536);
- BattleGroundTypeId bgTypeId = BattleGroundTypeId((scheduled[i] % 65536) / 256);
- BGQueueIdBasedOnLevel queue_id = BGQueueIdBasedOnLevel(scheduled[i] % 256);
+ BattleGroundQueueTypeId bgQueueTypeId = BattleGroundQueueTypeId(scheduled[i] >> 16);
+ BattleGroundTypeId bgTypeId = BattleGroundTypeId((scheduled[i] >> 8) & 255);
+ BGQueueIdBasedOnLevel queue_id = BGQueueIdBasedOnLevel(scheduled[i] & 255);
m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, queue_id);
}
}
@@ -1616,12 +1619,6 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
bg->SetArenaType(arenaType);
bg->SetRated(isRated);
- // add BG to free slot queue
- bg->AddToBGFreeSlotQueue();
-
- // add bg to update list
- AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg);
-
return bg;
}
@@ -2036,9 +2033,9 @@ void BattleGroundMgr::SetHolidayWeekends(uint32 mask)
void BattleGroundMgr::ScheduleQueueUpdate(BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
{
- //This method must be atomic!
+ //This method must be atomic, TODO add mutex
//we will use only 1 number created of bgTypeId and queue_id
- uint32 schedule_id = (bgQueueTypeId * 65536) + (bgTypeId * 256) + queue_id;
+ uint32 schedule_id = (bgQueueTypeId << 16) | (bgTypeId << 8) | queue_id;
bool found = false;
for (uint8 i = 0; i < m_QueueUpdateScheduler.size(); i++)
{
diff --git a/src/game/PoolHandler.h b/src/game/PoolHandler.h
index 35e18c2d58c..8b6c82d1197 100644
--- a/src/game/PoolHandler.h
+++ b/src/game/PoolHandler.h
@@ -43,7 +43,7 @@ class PoolGroup
public:
PoolGroup();
~PoolGroup() {};
- bool isEmpty() { return ExplicitlyChanced.size()==0 && EqualChanced.size()==0; }
+ bool isEmpty() { return ExplicitlyChanced.empty() && EqualChanced.empty(); }
void AddEntry(PoolObject& poolitem, uint32 maxentries);
bool CheckPool(void);
uint32 RollOne(void);
diff --git a/src/game/Spell.h b/src/game/Spell.h
index 997800d9989..f045a1415e0 100644
--- a/src/game/Spell.h
+++ b/src/game/Spell.h
@@ -350,6 +350,7 @@ class Spell
void EffectEnergizePct(uint32 i);
void EffectTriggerSpellWithValue(uint32 i);
void EffectTriggerRitualOfSummoning(uint32 i);
+ void EffectKillCreditPersonal(uint32 i);
void EffectKillCredit(uint32 i);
void EffectQuestFail(uint32 i);
void EffectRedirectThreat(uint32 i);
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index f8f7fd8a6e6..35db1b0cc04 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -2749,7 +2749,7 @@ void Spell::EffectHealthLeech(uint32 i)
if (m_spellInfo->SpellFamilyFlags[0] & 0x80000)
new_damage = damage;
else
- int32 new_damage = int32(damage*multiplier);
+ new_damage = int32(damage*multiplier);
uint32 curHealth = unitTarget->GetHealth();
new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage );
if(curHealth < new_damage)