Skip to content

Commit

Permalink
[462] Another SQL query fix for Trintiy Core DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadez committed Jan 20, 2011
1 parent b0ba223 commit ecf577f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions includes/classes/class.characters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release 4.50
* @revision 461
* @revision 462
* @copyright (c) 2009-2011 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -1549,7 +1549,7 @@ public function GetMaxEnergy() {
$maxPower = 100;
if($this->class == CLASS_DK) {
// Check for 50147, 49455 spells (Runic power mastery) in current talent spec
$tRank = $this->db->selectCell("SELECT `current_rank` FROM `character_talent` WHERE `guid`=%d AND `talent_id`=2020 AND `spec`=%d", $this->guid, $this->activeSpec);
$tRank = $this->HasTalent(2020);
if($tRank == 0) {
// Runic power mastery (Rank 1)
$maxPower = 115;
Expand All @@ -1561,7 +1561,7 @@ public function GetMaxEnergy() {
}
elseif($this->class == CLASS_ROGUE) {
// Check for 14983 spell (Vigor) in current talent spec
$tRank = $this->db->selectCell("SELECT 1 FROM `character_talent` WHERE `guid`=%d AND `talent_id`=382 AND `spec`=%d", $this->guid, $this->activeSpec);
$tRank = $this->HasTalent(382);
if($tRank) {
$maxPower = 110;
}
Expand Down Expand Up @@ -3020,11 +3020,11 @@ public function HasTalent($talent_id, $active_spec = true, $rank = -1) {
case SERVER_MANGOS:
$sql_data = array(
'activeSpec' => array(
sprintf('SELECT 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%%d AND `spec`=%%d', $talent_id),
sprintf('SELECT `current_rank` + 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%%d AND `spec`=%%d', $talent_id),
sprintf('SELECT 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%%d AND `spec`=%%d AND `current_rank`=%d', $talent_id, $rank)
),
'spec' => array(
sprintf('SELECT 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%%d', $talent_id),
sprintf('SELECT `current_rank` + 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%%d', $talent_id),
sprintf('SELECT 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%%d AND `current_rank`=%d', $talent_id, $rank)
)
);
Expand All @@ -3037,11 +3037,11 @@ public function HasTalent($talent_id, $active_spec = true, $rank = -1) {
}
$sql_data = array(
'activeSpec' => array(
sprintf('SELECT 1 FROM `character_talent` WHERE `spell` IN (%s) AND `guid`=%%d AND `spec`=%%d', array($talent_spells['Rank_1'], $talent_spells['Rank_2'], $talent_spells['Rank_3'], $talent_spells['Rank_4'], $talent_spells['Rank_5'])),
sprintf('SELECT `spell` FROM `character_talent` WHERE `spell` IN (%s) AND `guid`=%%d AND `spec`=%%d', array($talent_spells['Rank_1'], $talent_spells['Rank_2'], $talent_spells['Rank_3'], $talent_spells['Rank_4'], $talent_spells['Rank_5'])),
sprintf('SELECT 1 FROM `character_talent` WHERE `spell`=%d AND `guid`=%%d AND `spec`=%%d'. $talent_spells['Rank_' . $rank + 1])
),
'spec' => array(
sprintf('SELECT 1 FROM `character_talent` WHERE `spell` IN (%s) AND `guid`=%%d', array($talent_spells['Rank_1'], $talent_spells['Rank_2'], $talent_spells['Rank_3'], $talent_spells['Rank_4'], $talent_spells['Rank_5'])),
sprintf('SELECT `spell` FROM `character_talent` WHERE `spell` IN (%s) AND `guid`=%%d', array($talent_spells['Rank_1'], $talent_spells['Rank_2'], $talent_spells['Rank_3'], $talent_spells['Rank_4'], $talent_spells['Rank_5'])),
sprintf('SELECT 1 FROM `character_talent` WHERE `spell`=%d AND `guid`=%%d', $talent_spells['Rank_' . $rank + 1])
)
);
Expand All @@ -3068,7 +3068,17 @@ public function HasTalent($talent_id, $active_spec = true, $rank = -1) {
$has = $this->db->selectCell($sql_data['spec'][1], $this->guid);
}
}
return (bool) $has;
if($this->GetServerType() == SERVER_TRINITY && $rank == -1 && $has) {
for($i = 0; $i < 5; $i++) {
if($talent_spells['Rank_' . $i + 1] == $has) {
return $i;
}
}
}
if($this->GetServerType() == SERVER_MANGOS && $has) {
return $has - 1;
}
return $has;
}

/**
Expand All @@ -3080,13 +3090,7 @@ public function HasTalent($talent_id, $active_spec = true, $rank = -1) {
* @return int
**/
public function GetTalentRankByID($talent_id, $active_spec = true) {
if($active_spec) {
$rank = $this->db->selectCell("SELECT `current_rank` FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%d AND `spec`=%d LIMIT 1", $talent_id, $this->guid, $this->activeSpec);
}
else {
$rank = $this->db->selectCell("SELECT `current_rank` FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%d LIMIT 1", $talent_id, $this->guid);
}
return $rank;
return $this->HasTalent($talent_id, $active_spec);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/revision_nr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
define('ARMORY_REVISION', 461);
define('ARMORY_REVISION', 462);
define('DB_VERSION', 'armory_r456');
define('CONFIG_VERSION', '1801201101');
?>

0 comments on commit ecf577f

Please sign in to comment.