item parsing error + fix

Requests, feedback, and general discussion about WoWRoster
DO NOT post topics about WoWRoster AddOns here!

item parsing error + fix

Postby Diska » Fri Jun 27, 2008 7:37 pm

Heya,

I had an item which was getting parsed very weird (Handwraps of the Aggressor with a +10 stamina enchant). It was failing to detect the enchant and ended up marking the Durability line as the enchant.
This in turn caused the +10 stamina line not to be removed from the stack, which ended up overwriting the basestat of +36 stamina.

I've been debugging and found the error, it's in lib/item.php, lines 961 through 966.

Original code:
Code: Select all
                if( preg_match($roster->locale->wordings[$locale]['tooltip_preg_socketbonus'], $tooltip, $matches) )
                {
                        $tooltip = str_replace( $matches[0], '', $tooltip );
                        $tooltipWithoutColoredLines = str_replace( $matches[0], '', $tooltipWithoutColoredLines );
                        $tt['Attributes']['SocketBonus'] = $matches[0];
                }


Now the preg_match here is matching just fine, but the 2 lines which are supposed to remove the matched line from the stack forget to remove a newline character, which causes an empty line to end up in the stack.
Later on this will make the check for an enchant fail (@line 1016)

The fixed code:
Code: Select all
                if( preg_match($roster->locale->wordings[$locale]['tooltip_preg_socketbonus'], $tooltip, $matches) )
                {
                        $tooltip = str_replace( $matches[0] . "\n", '', $tooltip );
                        $tooltipWithoutColoredLines = str_replace( $matches[0] . "\n", '', $tooltipWithoutColoredLines );
                        $tt['Attributes']['SocketBonus'] = $matches[0];
                }


All I did was add . "\n" to the 2 lines that remove the matched line.
If you check the rest of the code, you'll see that at other places the \n was already in place, it appears to have been forgotten at this place.

Afaik this caused no regressions but it did fix several badly parsed items.
Last edited by Diska on Fri Jun 27, 2008 7:38 pm, edited 1 time in total.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

item parsing error + fix

Postby Diska » Fri Jun 27, 2008 9:10 pm

I also have more information on why the parsing of headpieces with a meta gem goes wrong. (which I described in the beta forum: http://www.wowroster.net/Forums/viewtopic/t=5416.html )

The problem is that the line of the tooltip that has the requirement of the metagem is prefixed with 2 spaces, is then followed by a color code and the text.

Line 949 of lib/item.php removes all lines with color codes from the $tooltipWithoutColoredLines stack, but fails to remove the 2 leading spaces of the line with the meta gem requirement.
This causes the next line to have 2 leading spaces (usually the Classes line), which causes problems later on.

I fixed this by adding 1 line before 949:

Original code:
Code: Select all
$tooltipWithoutColoredLines = preg_replace( '/\|c[a-f0-9]{6,8}.+?\|r\n/', '', $tooltipWithoutColoredLines );


New code:
Code: Select all
$tooltipWithoutColoredLines = preg_replace( '/\s\s\|c[a-f0-9]{6,8}.+?\|r\n/', '',$tooltipWithoutColoredLines );
$tooltipWithoutColoredLines = preg_replace( '/\|c[a-f0-9]{6,8}.+?\|r\n/', '', $tooltipWithoutColoredLines );


I'll admit it right away, ugly fix, the regular expression could probably be adapted to account for possible leading spaces, but hey, it works. I'm sure Pleegwat or Poetter can improve the regular expression :-)
Last edited by Diska on Fri Jun 27, 2008 9:11 pm, edited 1 time in total.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

item parsing error + fix

Postby Diska » Fri Jun 27, 2008 10:04 pm

Whoop, fix nr. 3 to the item parsing :)

The regular expressions for the metagem requirements don't take into account that the word "gems" also occurs as singular instead of plural.

localization/enUS.php:

Original code:
Code: Select all
$lang['tooltip_preg_meta_requires']='/Requires.*?gems/';
$lang['tooltip_preg_meta_requires_min']='/Requires at least (\d) (\S+) gems/';


New code:
Code: Select all
$lang['tooltip_preg_meta_requires']='/Requires.*?gem?/';
$lang['tooltip_preg_meta_requires_min']='/Requires at least (\d) (\S+) gem?/';


I haven't checked the other languages
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

item parsing error + fix

Postby zanix » Sat Jun 28, 2008 5:27 am

Thanks Diska

After I branch the roster svn, I will add these in and test
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US

item parsing error + fix

Postby Diska » Fri Jan 23, 2009 4:49 pm

Fix nr.3, the 2 changes in the enUS.php localization file have not yet been included in the latest release yet, any chance they could be added in?
Currently some meta gems are not recognized because of it.

What is kinda weird though, if I look at 1 of the troubled meta-gems on wowhead: http://www.wowhead.com/?item=41380 it actually says "Requires at least 1 Red gems", note the "gems" in plural. The in-game data gathered by CP really says "Requires at least 1 Red gem" though.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

Re: item parsing error + fix

Postby Diska » Fri Jan 23, 2009 5:31 pm

And I've fixed a parse error for druids weapons, the tooltip on those has changed it's format with patch 3.08:

Add to enUS.php:
Code: Select all
$lang['tooltip_feral_ap']='Increases attack power by';


patch for lib/item.php:
Code: Select all
@@ -1093,6 +1096,10 @@
          {
             $tt['Effects']['ChanceToProc'][] = $line;
          }
+         elseif( ereg('^' . $roster->locale->wordings[$locale]['tooltip_feral_ap'], $line) )
+         {
+            $tt['Effects']['Equip'][] = $line;
+         }
          elseif( ereg('^' . $roster->locale->wordings[$locale]['tooltip_bind_types'], $line) )
          {
             //soulbound, bop, quest item etc


Extra info: You actually need CP data from a druid to see the feral attackpower on weapons because it will not show for other classes.
Last edited by Diska on Fri Jan 23, 2009 5:33 pm, edited 2 times in total.
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

Re: item parsing error + fix

Postby Diska » Fri Jan 23, 2009 6:51 pm

And here's the fix for item parsing of heirloom (bind on account) items:

lib/item.php:
Code: Select all
--- item.php.old        2008-06-27 14:23:45.000000000 +0200
+++ item.php    2009-01-23 12:46:14.000000000 +0100
@@ -34,7 +34,7 @@
        var $member_id, $item_id, $name, $level, $icon, $color;
        var $slot, $parent, $tooltip, $quantity, $locale;

-       // 1=poor, 2=common, 3=uncommon, 4=rare, 5=epic, 6=legendary
+       // 1=poor, 2=common, 3=uncommon, 4=rare, 5=epic, 6=legendary, 7=heirloom
        var $quality_id; //holds numerical value of item quality
        var $quality; // holds string value of item quality

@@ -173,6 +173,10 @@
                {
                        $color = '00bbff';
                }
+               elseif( ereg('^' . $roster->locale->wordings[$this->locale]['tooltip_boa'], $bindtype) )
+               {
+                       $color = 'e6cc80';
+               }
                else
                {
                        $color = 'ffffff';
@@ -735,6 +739,10 @@
        {
                switch( strtolower( $color ) )
                {
+                       case 'e6cc80':
+                               $this->quality_id = '7';
+                               $this->quality = 'heirloom';
+                               break;
                        case 'ff8800':
                                $this->quality_id = '6';
                                $this->quality = 'legendary';


locale/enUS.php:
Code: Select all
--- enUS.php.old   2009-01-23 12:51:38.000000000 +0100
+++ enUS.php   2009-01-23 12:44:13.000000000 +0100
@@ -686,6 +686,7 @@
 $lang['tooltip_reinforced']='Reinforced';
 $lang['tooltip_soulbound']='Soulbound';
 $lang['tooltip_boe']='Binds when equipped';
+$lang['tooltip_boa']='Account Bound';
 $lang['tooltip_equip']='Equip:';
 $lang['tooltip_equip_restores']='Equip: Restores';
 $lang['tooltip_equip_when']='Equip: When';
@@ -734,7 +735,7 @@
 
 $lang['tooltip_armor_types']='Cloth|Leather|Mail|Plate';
 $lang['tooltip_weapon_types']='Arrow|Axe|Bow|Bullet|Crossbow|Dagger|Fishing Pole|Fist Weapon|Gun|Idol|Mace|Main Hand|Off-hand|Polearm|Staff|Sword|Thrown|Wand|Ranged|One-Hand|Two-Hand|Relic';
-$lang['tooltip_bind_types']='Soulbound|Binds when equipped|Quest Item|Binds when used|Binds when picked up|This Item Begins a Quest';
+$lang['tooltip_bind_types']='Soulbound|Binds when equipped|Quest Item|Binds when used|Binds when picked up|This Item Begins a Quest|Account Bound';
 $lang['tooltip_misc_types']='Finger|Neck|Back|Shirt|Trinket|Tabard|Head|Chest|Legs|Feet';
 $lang['tooltip_garbage']='<Shift Right Click to Socket>|<Right Click to Read>|Duration|Cooldown remaining|<Right Click to Open>';
User avatar
Diska
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 179
Joined: Tue Jul 04, 2006 2:05 pm

Re: item parsing error + fix

Postby zanix » Thu May 14, 2009 3:16 am

Ok, the missing fixes will be in the svn on my next commit
Sorry this took so long
Read the Forum Rules, the WiKi, and Search before posting!
WoWRoster v2.1 - SigGen v0.3.3.523 - WoWRosterDF
User avatar
zanix
Admin
Admin
WoWRoster.net Dev Team
WoWRoster.net Dev Team
UA/UU Developer
UA/UU Developer
 
Posts: 5546
Joined: Mon Jul 03, 2006 8:29 am
Location: Idaho Falls, Idaho
Realm: Doomhammer (PvE) - US


Return to General Support & Feedback

Who is online

Users browsing this forum: No registered users and 1 guest

cron