Skip to content

Commit

Permalink
[400] Item random suffixes/properties should work fine now. Need test…
Browse files Browse the repository at this point in the history
…s for Trinity Core realms.
  • Loading branch information
Shadez committed Oct 8, 2010
1 parent cb01aef commit 413a807
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 52 deletions.
3 changes: 2 additions & 1 deletion guild-bank-contents.php
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 365
* @revision 400
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand All @@ -26,6 +26,7 @@
define('load_characters_class', true);
define('load_guilds_class', true);
define('load_items_class', true);
define('load_item_class', true);
if(!@include('includes/armory_loader.php')) {
die('<b>Fatal error:</b> unable to load system files.');
}
Expand Down
9 changes: 6 additions & 3 deletions includes/classes/class.guilds.php
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 396
* @revision 400
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -286,7 +286,9 @@ public function BuildGuildBankItemList() {
}
$items_list = $this->armory->cDB->select("SELECT `item_entry` AS `id`, `item_guid` AS `seed`, `SlotId` AS `slot`, `TabId` AS `bag` FROM `guild_bank_item` WHERE `guildid`=%d", $this->guildId);
$count_items = count($items_list);
for($i=0;$i<$count_items;$i++) {
for($i = 0; $i < $count_items; $i++) {
$m_server = Utils::GetServerTypeByString($this->armory->currentRealmInfo['type']);
$item_data = $this->armory->wDB->selectRow("SELECT `RandomProperty`, `RandomSuffix` FROM `item_template` WHERE `entry` = %d LIMIT 1", $items_list[$i]['id']);
$tmp_durability = Items::GetItemDurabilityByItemGuid($items_list[$i]['seed']);
$items_list[$i]['durability'] = (int) $tmp_durability['current'];
$items_list[$i]['maxDurability'] = (int) $tmp_durability['max'];
Expand All @@ -300,7 +302,8 @@ public function BuildGuildBankItemList() {
elseif($this->armory->currentRealmInfo['type'] == 'trinity') {
$items_list[$i]['quantity'] = $this->armory->cDB->selectCell("SELECT `count` FROM `item_instance` WHERE `guid`=%d", $items_list[$i]['seed']);
}
$items_list[$i]['randomPropertiesId'] = Items::GetRandomPropertiesData($items_list[$i]['id'], 0, $items_list[$i]['seed'], true);
//TODO: Find correct random property/suffix for items in guild vault.
$items_list[$i]['randomPropertiesId'] = Items::GetRandomPropertiesData($items_list[$i]['id'], 0, $items_list[$i]['seed'], true, $m_server, null, $item_data);
$tmp_classinfo = Items::GetItemSubTypeInfo($items_list[$i]['id']);
$items_list[$i]['subtype'] = '';
$items_list[$i]['subtypeLoc'] = $tmp_classinfo['subclass_name'];
Expand Down
24 changes: 23 additions & 1 deletion includes/classes/class.item.php
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 398
* @revision 400
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -331,6 +331,9 @@ public function GetSkill() {
}
}

/**
* @return int
**/
public function GetCurrentDurability() {
if($this->m_server == SERVER_MANGOS) {
return $this->GetUInt32Value(ITEM_FIELD_DURABILITY);
Expand All @@ -342,13 +345,17 @@ public function GetCurrentDurability() {
return 0;
}

/**
* @return int
**/
public function GetMaxDurability() {
if($this->m_server == SERVER_MANGOS) {
return $this->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
}
elseif($this->m_server == SERVER_TRINITY) {
return $this->tc_data['maxdurability']; // assigned in Item::LoadFromDB()
}
$this->armory->Log()->writeLog('%s : wrong server type', __METHOD__);
return 0;
}

Expand All @@ -358,6 +365,21 @@ public function GetMaxDurability() {
public function GetItemDurability() {
return array('current' => $this->GetCurrentDurability(), 'max' => $this->GetMaxDurability());
}

/**
* @return array
**/
public function GetRandomSuffixData() {
if($this->m_server != SERVER_MANGOS) {
$this->armory->Log()->writeError('%s : this method is usable with MaNGOS servers only.', __METHOD__);
return false;
}
return array(
$this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_8_1),
$this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_9_1),
$this->GetUInt32Value(ITEM_FIELD_ENCHANTMENT_10_1)
);
}
}

?>
17 changes: 16 additions & 1 deletion includes/classes/class.itemprototype.php
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 398
* @revision 400
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -287,6 +287,21 @@ public function getDPS() {
}
return $temp * 500 / $this->delay;
}

// Not used now.
public function GetItemQualityColor() {
$colors_array = array(
'#c9c9c9', //GREY
'#ffffff', //WHITE
'#00FF00', //GREEN
'#0070DD', //BLUE
'#A335EE', //PURPLE
'#ff8000', //ORANGE
'#7e7046', //LIGHT YELLOW
'#7e7046' //LIGHT YELLOW
);
return (isset($colors_array[$this->Quality])) ? $colors_array[$this->Quality] : $colors_array[1];
}
}

?>
101 changes: 82 additions & 19 deletions includes/classes/class.items.php
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 398
* @revision 400
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -1299,20 +1299,48 @@ public function GetModelSuffix($name) {
* @param int $item_guid
* @return array
**/
public function GetRandomPropertiesData($item_entry, $owner_guid, $item_guid = 0, $rIdOnly = false) {
public function GetRandomPropertiesData($item_entry, $owner_guid, $item_guid = 0, $rIdOnly = false, $serverType = 1, $item = null, $item_data = null) {
// I have no idea how it works but it works :D
// Do not touch anything in this method (at least until somebody will explain me what the fuck am I did here).
$enchId = 0;
switch($this->armory->currentRealmInfo['type']) {
case 'mangos':
$use = 'property';
switch($serverType) {
case SERVER_MANGOS:
if($item_guid > 0) {
$enchId = self::GetItemDataField(ITEM_FIELD_RANDOM_PROPERTIES_ID, 0, $owner_guid, $item_guid);
if(is_object($item) && $item->IsCorrect()) {
if(is_array($item_data) && $item_data['RandomProperty'] > 0) {
$enchId = $item->GetItemRandomPropertyId();
}
elseif(is_array($item_data) && $item_data['RandomSuffix'] > 0) {
$suffix_enchants = $item->GetRandomSuffixData();
if(!is_array($suffix_enchants) || !isset($suffix_enchants[0]) || $suffix_enchants[0] == 0) {
$this->armory->Log()->writeError('%s : suffix_enchants not found', __METHOD__);
return false;
}
$enchId = $this->armory->aDB->selectCell("SELECT `id` FROM `ARMORYDBPREFIX_randomsuffix` WHERE `ench_1` = %d AND `ench_2` = %d AND `ench_3` = %d LIMIT 1", $suffix_enchants[0], $suffix_enchants[1], $suffix_enchants[2]);
$use = 'suffix';
}
}
else {
$enchId = self::GetItemDataField(ITEM_FIELD_RANDOM_PROPERTIES_ID, 0, $owner_guid, $item_guid);
}
}
else {
$enchId = self::GetItemDataField(ITEM_FIELD_RANDOM_PROPERTIES_ID, $item_entry, $owner_guid);
}
break;
case 'trinity':
case SERVER_TRINITY:
if($item_guid > 0) {
$enchId = $this->armory->cDB->selectCell("SELECT `randomPropertyId` FROM `item_instance` WHERE `guid`=%d", $item_guid);
if(is_object($item) && $item->IsCorrect()) {
$enchId = $item->GetItemRandomPropertyId();
if($enchId < 0) {
$use = 'suffix';
$enchId = abs($enchId);
}
}
else {
$enchId = $this->armory->cDB->selectCell("SELECT `randomPropertyId` FROM `item_instance` WHERE `guid`=%d", $item_guid);
}
}
else {
$item_guid = self::GetItemGUIDByEntry($item_entry, $owner_guid);
Expand All @@ -1323,17 +1351,47 @@ public function GetRandomPropertiesData($item_entry, $owner_guid, $item_guid = 0
if($rIdOnly == true) {
return $enchId;
}
$rand_data = $this->armory->aDB->selectRow("SELECT `name_%s` AS `name`, `ench_1`, `ench_2`, `ench_3` FROM `ARMORYDBPREFIX_randomproperties` WHERE `id`=%d", $this->armory->GetLocale(), $enchId);
if(!$rand_data) {
$this->armory->Log()->writeLog('%s : unable to get rand_data FROM `ARMORYDBPREFIX_randomproperties` for id %d', __METHOD__, $enchId);
return false;
}
$return_data = array();
$return_data['suffix'] = $rand_data['name'];
$return_data['data'] = array();
for($i = 1; $i < 4; $i++) {
if($rand_data['ench_' . $i] > 0) {
$return_data['data'][$i] = $this->armory->aDB->selectCell("SELECT `text_%s` FROM `ARMORYDBPREFIX_enchantment` WHERE `id`=%d", $this->armory->GetLocale(), $rand_data['ench_' . $i]);
$table = 'randomproperties';
if($use == 'property') {
$rand_data = $this->armory->aDB->selectRow("SELECT `name_%s` AS `name`, `ench_1`, `ench_2`, `ench_3` FROM `ARMORYDBPREFIX_randomproperties` WHERE `id`=%d", $this->armory->GetLocale(), $enchId);
}
elseif($use == 'suffix') {
$table = 'randomsuffix';
}
if($table == 'randomproperties') {
if(!$rand_data) {
$this->armory->Log()->writeLog('%s : unable to get rand_data FROM `%s_%s` for id %d (itemGuid: %d, ownerGuid: %d)', __METHOD__, $this->armory->armoryconfig['db_prefix'], $table, $enchId, $item_guid, $owner_guid);
return false;
}
$return_data['suffix'] = $rand_data['name'];
$return_data['data'] = array();
for($i = 1; $i < 4; $i++) {
if($rand_data['ench_' . $i] > 0) {
$return_data['data'][$i] = $this->armory->aDB->selectCell("SELECT `text_%s` FROM `ARMORYDBPREFIX_enchantment` WHERE `id`=%d", $this->armory->GetLocale(), $rand_data['ench_' . $i]);
}
}
}
elseif($table == 'randomsuffix') {
$enchant = $this->armory->aDB->selectRow("SELECT `id`, `name_%s` AS `name`, `ench_1`, `ench_2`, `ench_3`, `pref_1`, `pref_2`, `pref_3` FROM `ARMORYDBPREFIX_randomsuffix` WHERE `id`=%d", $this->armory->GetLocale(), $enchId);
if(!$enchant) {
return false;
}
$return_data['suffix'] = $enchant['name'];
$return_data['data'] = array();
$item_data = $this->armory->wDB->selectRow("SELECT `InventoryType`, `ItemLevel`, `Quality` FROM `item_template` WHERE `entry`=%d", $item_entry);
$points = self::GetRandomPropertiesPoints($item_data['ItemLevel'], $item_data['InventoryType'], $item_data['Quality']);
$return_data = array(
'suffix' => $enchant['name'],
'data' => array()
);
$k = 1;
for($i = 1; $i < 4; $i++) {
if(isset($enchant['ench_' . $i]) && $enchant['ench_' . $i] > 0) {
$cur = $this->armory->aDB->selectCell("SELECT `text_%s` FROM `ARMORYDBPREFIX_enchantment` WHERE `id` = %d", $this->armory->GetLocale(), $enchant['ench_' . $i]);
$return_data['data'][$k] = str_replace('$i', round(floor($points * $enchant['pref_' . $i] / 10000), 0), $cur);
}
$k++;
}
}
return $return_data;
Expand Down Expand Up @@ -1872,10 +1930,10 @@ private function CreateAdditionalItemTooltip($itemID, XMLHandler $xml, Character
}
else {
if($itemSlotName) {
$rPropInfo = self::GetRandomPropertiesData($itemID, $characters->GetGUID(), $characters->GetEquippedItemGuidBySlot($itemSlotName));
$rPropInfo = self::GetRandomPropertiesData($itemID, $characters->GetGUID(), $characters->GetEquippedItemGuidBySlot($itemSlotName), false, $characters->GetServerType(), $item, array('RandomProperty' => $proto->RandomProperty, 'RandomSuffix' => $proto->RandomSuffix));
}
else {
$rPropInfo = self::GetRandomPropertiesData($itemID, $characters->GetGUID());
$rPropInfo = self::GetRandomPropertiesData($itemID, $characters->GetGUID(), 0, false, $characters->GetServerType(), $item);
}
if($isCharacter && !$parent && is_array($rPropInfo)) {
$xml->XMLWriter()->startElement('randomEnchantData');
Expand Down Expand Up @@ -2994,5 +3052,10 @@ private function IsMultiplyItemSet($itemSetID) {
}
return false;
}

public function GetItemIdByName($name) {
$name = Utils::escape(urldecode($name));
return $this->armory->wDB->selectCell("SELECT `entry` FROM `item_template` WHERE `name` = '%s' LIMIT 1", $name);
}
}
?>
3 changes: 2 additions & 1 deletion includes/classes/class.utils.php
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 398
* @revision 400
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -114,6 +114,7 @@ public function CloseSession() {
* @param int $guildId
* @param int $realmId
* @return bool
* @todo Add guild bank tab access handling
**/
public function IsAllowedToGuildBank($guildId, $realmId) {
if(!isset($_SESSION['accountId'])) {
Expand Down
2 changes: 1 addition & 1 deletion includes/revision_nr.php
@@ -1,5 +1,5 @@
<?php
define('ARMORY_REVISION', 399);
define('ARMORY_REVISION', 400);
define('DB_VERSION', 'armory_r398');
define('CONFIG_VERSION', '0708201001');
?>
2 changes: 2 additions & 0 deletions sql/updates/characters_r399_character_feed_log.sql
@@ -0,0 +1,2 @@
-- This update is for `characters` database, not `armory`!
ALTER TABLE `character_feed_log` CHANGE `difficulty` `difficulty` SMALLINT( 6 ) DEFAULT '-1';
Binary file added sql/wowarmory_rc1_r398.7z
Binary file not shown.
2 changes: 1 addition & 1 deletion tools/mangos/sql/characters.sql
Expand Up @@ -12,6 +12,6 @@ CREATE TABLE `character_feed_log` (
`data` int(11) NOT NULL,
`date` int(11) default NULL,
`counter` int(11) NOT NULL,
`difficulty` smallint(6) NOT NULL,
`difficulty` smallint(6) default '-1',
PRIMARY KEY (`guid`,`type`,`data`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
10 changes: 5 additions & 5 deletions tools/mangos/wowarmory_arena_chart.patch
@@ -1,9 +1,9 @@
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 8343ab5..08debcc 100644
index a786ffa..b6db14f 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -723,6 +723,47 @@ void BattleGround::EndBattleGround(uint32 winner)
DEBUG_LOG("--- Winner rating: %u, Loser rating: %u, Winner change: %u, Losser change: %u ---", winner_rating, loser_rating, winner_change, loser_change);
DEBUG_LOG("--- Winner rating: %u, Loser rating: %u, Winner change: %i, Loser change: %i ---", winner_rating, loser_rating, winner_change, loser_change);
SetArenaTeamRatingChangeForTeam(winner, winner_change);
SetArenaTeamRatingChangeForTeam(GetOtherTeam(winner), loser_change);
+ /** World of Warcraft Armory **/
Expand Down Expand Up @@ -94,10 +94,10 @@ index 0a70990..55ea549 100644

/*
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 4bf7533..b9bf8b0 100644
index e5f9745..6aac984 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -633,6 +633,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
@@ -658,6 +658,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
{
// FIXME: kept by compatibility. don't know in BG if the restriction apply.
bg->UpdatePlayerScore(killer, SCORE_DAMAGE_DONE, damage);
Expand All @@ -108,7 +108,7 @@ index 4bf7533..b9bf8b0 100644
}
}

@@ -5872,6 +5876,10 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro
@@ -6000,6 +6004,10 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro
{
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_HEALING_RECEIVED, gain);
((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HEALING_RECEIVED, addhealth);
Expand Down

0 comments on commit 413a807

Please sign in to comment.