Skip to content

Commit

Permalink
[419] Changes in Characters::LoadInventory() and Item::LoadFromDB() r…
Browse files Browse the repository at this point in the history
…elated to Trinity`s 10654 commit
  • Loading branch information
Shadez committed Dec 18, 2010
1 parent 5087421 commit a65b527
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
45 changes: 41 additions & 4 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 Candidate 1
* @revision 415
* @revision 419
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -2930,10 +2930,26 @@ public function GetModelData() {
}
}

/**
* Checks for spell ID in character's spellbook
* @category Characters class
* @access public
* @param int $spell_id
* @return bool
**/
public function HasSpell($spell_id) {
return $this->db->selectCell("SELECT 1 FROM `character_spell` WHERE `spell`=%d AND `guid`=%d AND `active`=1 AND `disabled`=0 LIMIT 1", $spell_id, $this->guid);;
return (bool) $this->db->selectCell("SELECT 1 FROM `character_spell` WHERE `spell`=%d AND `guid`=%d AND `active`=1 AND `disabled`=0 LIMIT 1", $spell_id, $this->guid);;
}

/**
* Checks for talent ID in active or all specs
* @category Characters class
* @access public
* @param int $talent_id
* @param bool $active_spec = true
* @param int $rank = -1
* @return bool
**/
public function HasTalent($talent_id, $active_spec = true, $rank = -1) {
if($active_spec) {
if($rank == -1) {
Expand All @@ -2951,9 +2967,17 @@ public function HasTalent($talent_id, $active_spec = true, $rank = -1) {
$has = $this->db->selectCell("SELECT 1 FROM `character_talent` WHERE `talent_id`=%d AND `guid`=%d AND `current_rank`=%d", $talent_id, $this->guid, $rank);
}
}
return $has;
return (bool) $has;
}

/**
* Returns talent rank by talent ID (if player have this talent)
* @category Characters class
* @access public
* @param int $talent_id
* @param bool $active_spec = true
* @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);
Expand All @@ -2967,6 +2991,13 @@ public function GetTalentRankByID($talent_id, $active_spec = true) {
return $rank;
}

/**
* Returns skill value by skill ID (if player have this skill)
* @category Characters class
* @access public
* @param int $skill
* @return int
**/
public function GetSkillValue($skill) {
return $this->db->selectCell("SELECT `value` FROM `character_skills` WHERE `guid`=%d AND `skill`=%d", $this->guid, $skill);
}
Expand Down Expand Up @@ -3006,7 +3037,13 @@ private function LoadInventory() {
$this->armory->Log()->writeError('%s : player guid is not defined.', __METHOD__);
return false;
}
$inv = $this->db->select("SELECT `item`, `slot`, `item_template`, `bag` FROM `character_inventory` WHERE `bag` = 0 AND `slot` < %d AND `guid` = %d", INV_MAX, $this->guid);
switch($this->m_server) {
case SERVER_MANGOS:
$inv = $this->db->select("SELECT `item`, `slot`, `item_template`, `bag` FROM `character_inventory` WHERE `bag` = 0 AND `slot` < %d AND `guid` = %d", INV_MAX, $this->guid);
break;
case SERVER_TRINITY:
$inv = $this->db->select("SELECT `item`, `slot`, `bag`, FROM `character_inventory` WHERE `bag` = 0 AND `slot` < %d AND `guid` = %d", INV_MAX, $this->guid);

This comment has been minimized.

Copy link
@Vasago

Vasago Dec 18, 2010

SELECT item, slot, bag, FROM character_inventory should be
SELECT item, slot, bag FROM character_inventory - without comma but after that you get error:
Notice: Undefined index: item_template in /var/www/armory/includes/classes/class.item.php on line 106

And others:
ArmoryDatabaseHandler::_query : unable to execute SQL query (SELECT name, Quality, ItemLevel, displayid, SellPrice, BuyPrice, Flags2, RequiredDisenchantSkill FROM item_template WHERE entry=47156 LIMIT 1). MySQL error: "Unknown column 'Flags2' in 'field list'" (Error #1054)

ArmoryDatabaseHandler::_query : unable to execute SQL query (SELECT gmlevel FROM account WHERE id=14 LIMIT 1). MySQL error: "Unknown column 'gmlevel' in 'field list'" (Error #1054)

ArmoryDatabaseHandler::__destruct : connection closed.

ArmoryDatabaseHandler::ArmoryDatabaseHandler : connection to MySQL database was successfully established.

ArmoryDatabaseHandler::ArmoryDatabaseHandler : connection to MySQL database was successfully established.

ArmoryDatabaseHandler::ArmoryDatabaseHandler : connection to MySQL database was successfully established.

ArmoryDatabaseHandler::ArmoryDatabaseHandler : connection to MySQL database was successfully established.

ArmoryDatabaseHandler::ArmoryDatabaseHandler : connection to MySQL database was successfully established.

ArmoryDatabaseHandler::ArmoryDatabaseHandler : connection to MySQL database was successfully established.

}
if(!$inv) {
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion includes/classes/class.item.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 400
* @revision 419
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -91,6 +91,7 @@ public function LoadFromDB($data, $owner_guid, $db) {
return false;
}
$this->m_values = explode(' ', $m_values);
$this->entry = $data['item_template'];
}
elseif($this->m_server == SERVER_TRINITY) {
$this->tc_data = $this->db->selectRow("SELECT * FROM `item_instance` WHERE `guid` = %d AND `owner_guid` = %d", $this->m_guid, $this->m_owner);
Expand All @@ -103,6 +104,7 @@ public function LoadFromDB($data, $owner_guid, $db) {
$this->tc_ench = explode(' ', $this->tc_data['enchantments']);
}
$this->tc_data['maxdurability'] = $this->armory->wDB->selectCell("SELECT `MaxDurability` FROM `item_template` WHERE `entry`=%d", $data['item_template']);
$this->entry = $this->tc_data['itemEntry'];
}
else {
$this->armory->Log()->writeError('%s : unknown server type (%d), unable to handle item!', __METHOD__, $this->m_server);
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', 417);
define('ARMORY_REVISION', 419);
define('DB_VERSION', 'armory_r416');
define('CONFIG_VERSION', '0708201001');
?>

6 comments on commit a65b527

@Vasago
Copy link

@Vasago Vasago commented on a65b527 Dec 18, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not working items are not showing with this on newest trinitycore

@Shadez
Copy link
Owner Author

@Shadez Shadez commented on a65b527 Dec 18, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything from debug log?

@calvo
Copy link

@calvo calvo commented on a65b527 Dec 18, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calvo
Copy link

@calvo calvo commented on a65b527 Dec 18, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vasago
Copy link

@Vasago Vasago commented on a65b527 Dec 18, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment to line where is bug

@Shadez
Copy link
Owner Author

@Shadez Shadez commented on a65b527 Dec 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting. This should be fixed after [420] commit (I hope it should).

Please sign in to comment.