<?php
// Fetch item displayid for use in wows-transmogrify.cmd
// Example: item-displayid.php Civinad Robes

require "_trinity.php";

MySTART( DBnameFromArgv() );

// Classic 1.12: MAX(entry)=24283, MAX(displayid)=36782

$res_item = MyOP("SELECT * FROM item_template WHERE ".EntryConditionFromArgv()." ORDER BY name ASC");
$nitems = 0;

while($item = mysql_fetch_object($res_item)) {

$invslot = "";

if ($item->class == 2) {
    if (in_array($item->subclass, array(2,3,16,18))) // Bow,Gun,Thrown,Crossbow,Wand
        $invslot = "ranged";
    elseif (in_array($item->subclass, array(1,5,8, 6,10,17,20))) // Two-Handed Axe,Mace,Sword,Polearm,Staff,Spear,Fishing Pole
        $invslot = "twohand";
    elseif (in_array($item->subclass, array(0,4,7))) // One-Handed Axe,Mace,Sword
        $invslot = "onehand";
    else  // Main-Hand
        $invslot = "mainhand";
}
else {
    $i = $item->InventoryType;
    if     ($i ==  1)  $invslot = "head";
    elseif ($i ==  3)  $invslot = "shoulders";
    elseif ($i == 16)  $invslot = "back";
    elseif ($i ==  5 or $i == 20)  $invslot = "chest";
    elseif ($i ==  4)  $invslot = "shirt";
    elseif ($i ==  9)  $invslot = "wrist";
    elseif ($i == 10)  $invslot = "hands";
    elseif ($i ==  6)  $invslot = "waist";
    elseif ($i ==  7)  $invslot = "legs";
    elseif ($i ==  8)  $invslot = "feet";
    elseif ($i == 14)  $invslot = "shield";
    elseif (in_array($i, array(15,23,25,26,28)))  $invslot = "ranged";
}

printf("set %s= %s %d\n", $invslot, $item->name, $item->displayid);
++$nitems;

}

printf("  === %d items === \n", $nitems);

?>
