From 60b8f30898875a1e25e4617df80c6da9f184f58e Mon Sep 17 00:00:00 2001 From: tomrus88 Date: Mon, 1 Dec 2008 08:19:26 +0300 Subject: [PATCH] Rune system fix, dk crash fix --- src/game/AchievementMgr.cpp | 1 - src/game/Player.cpp | 7 +++---- src/game/Player.h | 19 ++++++------------ src/game/Spell.cpp | 39 +++++++++++++++++++++++-------------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index e7dc6f3a1..c255bfb93 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -839,4 +839,3 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket *data) *data << int32(-1); } - diff --git a/src/game/Player.cpp b/src/game/Player.cpp index d2783886e..cddb31692 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1890,9 +1890,9 @@ void Player::Regenerate(Powers power) } break; case POWER_RUNE: { - for(uint32 i = 0; i < 6; ++i) + for(uint32 i = 0; i < MAX_RUNES; ++i) if(uint8 cd = GetRuneCooldown(i)) // if we have cooldown, reduce it... - SetRuneCooldown(i, cd - 1); // by 2 sec (because update is every 2 sec) + SetRuneCooldown(i, cd - 1); // ... by 2 sec (because update is every 2 sec) } break; case POWER_FOCUS: case POWER_HAPPINESS: @@ -14083,6 +14083,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) InitStatsForLevel(); InitTaxiNodesForLevel(); InitGlyphsForLevel(); + InitRunes(); // apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods() @@ -14239,8 +14240,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadDeclinedNames(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDECLINEDNAMES)); - InitRunes(); - m_achievementMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS), holder->GetResult(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS)); m_achievementMgr.CheckAllAchievementCriteria(); return true; diff --git a/src/game/Player.h b/src/game/Player.h index 4166238fc..6e1537579 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -238,9 +238,9 @@ enum RuneType struct RuneInfo { - uint8 BaseRune:1; - uint8 CurrentRune:1; - uint8 Cooldown:1; + uint8 BaseRune; + uint8 CurrentRune; + uint8 Cooldown; }; struct Runes @@ -2092,16 +2092,9 @@ class MANGOS_DLL_SPEC Player : public Unit WorldLocation& GetTeleportDest() { return m_teleport_dest; } DeclinedName const* GetDeclinedNames() const { return m_declinedname; } - RuneInfo const* GetRuneInfo(uint8 index) { return &m_runes->runes[index]; } - uint8 GetBaseRune(uint8 index) { return m_runes->runes[index].BaseRune; } - uint8 GetCurrentRune(uint8 index) { return m_runes->runes[index].CurrentRune; } - uint8 GetRuneCooldown(uint8 index) { return m_runes->runes[index].Cooldown; } - void SetRuneInfo(uint8 index, uint8 baseRune, uint8 currentRune, uint8 cooldown) - { - m_runes->runes[index].BaseRune = baseRune; - m_runes->runes[index].CurrentRune = currentRune; - m_runes->runes[index].Cooldown = cooldown; - } + uint8 GetBaseRune(uint8 index) const { return m_runes->runes[index].BaseRune; } + uint8 GetCurrentRune(uint8 index) const { return m_runes->runes[index].CurrentRune; } + uint8 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; } void SetBaseRune(uint8 index, uint8 baseRune) { m_runes->runes[index].BaseRune = baseRune; } void SetCurrentRune(uint8 index, uint8 currentRune) { m_runes->runes[index].CurrentRune = currentRune; } void SetRuneCooldown(uint8 index, uint8 cooldown) { m_runes->runes[index].Cooldown = cooldown; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 846a51cb4..337273e21 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3160,20 +3160,31 @@ uint8 Spell::CheckRuneCost(uint32 runeCostID) int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death for(uint32 i = 0; i < RUNE_DEATH; ++i) + { runeCost[i] = src->RuneCost[i]; + } runeCost[RUNE_DEATH] = 0; // calculated later for(uint32 i = 0; i < MAX_RUNES; ++i) - if(!plr->GetRuneCooldown(i)) - runeCost[plr->GetCurrentRune(i)]--; + { + uint8 rune = plr->GetCurrentRune(i); + if((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0)) + { + runeCost[rune]--; + } + } for(uint32 i = 0; i < RUNE_DEATH; ++i) + { if(runeCost[i] > 0) + { runeCost[RUNE_DEATH] += runeCost[i]; + } + } if(runeCost[RUNE_DEATH] > 0) - return SPELL_FAILED_REAGENTS; // not sure if result code is correct + return SPELL_FAILED_NO_POWER; // not sure if result code is correct return 0; } @@ -3196,20 +3207,19 @@ void Spell::TakeRunePower() int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death for(uint32 i = 0; i < RUNE_DEATH; ++i) + { runeCost[i] = src->RuneCost[i]; + } runeCost[RUNE_DEATH] = 0; // calculated later for(uint32 i = 0; i < MAX_RUNES; ++i) { - if(!plr->GetRuneCooldown(i)) + uint8 rune = plr->GetCurrentRune(i); + if((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0)) { - uint8 rune = plr->GetCurrentRune(i); - if(runeCost[rune] > 0) - { - plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec - runeCost[rune]--; - } + plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec + runeCost[rune]--; } } @@ -3219,13 +3229,12 @@ void Spell::TakeRunePower() { for(uint32 i = 0; i < MAX_RUNES; ++i) { - if(!plr->GetRuneCooldown(i) && plr->GetCurrentRune(i) == RUNE_DEATH) + uint8 rune = plr->GetCurrentRune(i); + if((plr->GetRuneCooldown(i) == 0) && (rune == RUNE_DEATH)) { plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec - runeCost[plr->GetCurrentRune(i)]--; - uint8 base = plr->GetBaseRune(i); - plr->SetCurrentRune(i, base); - plr->ConvertRune(i, base); + runeCost[rune]--; + plr->ConvertRune(i, plr->GetBaseRune(i)); if(runeCost[RUNE_DEATH] == 0) break; }