diff --git a/src/D2Item.php b/src/D2Item.php index 0da2283..db1a0ed 100644 --- a/src/D2Item.php +++ b/src/D2Item.php @@ -39,9 +39,6 @@ class D2Item { */ private function parseItem() { $b = new D2BitReader($this->bits); - // if the item is extended or not, based on length of bits - $this->iData['extended'] = (strlen($this->bits) > 112) ? 1 : 0; - $b->skip(16); // Skip JM $b->skip(4); // skip unknown 4 bytes $this->iData['identified'] = $b->read(1); // bit 20, identified @@ -110,9 +107,9 @@ class D2Item { // ring/amu/jew/char or not. 1 or 0. if 1, next 3 are set // If this bit is set, the item has one of multiple pictures associated with it; the next field determines which picture a particular item uses. If this bit is 0, the next field is absent. The picture field is used for rings, amulets, jewels, and charms. - + $b->seek(151); - if(bindec($b->read(1))) { + if (bindec($b->read(1))) { $b->seek(152); $jarc_picture = bindec($b->readr(3)); } @@ -120,29 +117,37 @@ class D2Item { // This bit apparently is set for certain class-specific Expansion Set items. It indicates the presence of the next 11-bit field. If this bit is 0, the next field is absent. $b->seek(152); -/*Credit for the discovery of this field's meaning goes entirely to Guillaume Courtin of France. Thanks! :-> -This field indicates magic properties which are inherent in certain class-specific items. A given class-specific item will (almost) always start with the same set of properties, even if its quality is "normal". Other quality ratings may add more properties to the standard set. It appears that items which will have this field are: -Amazon-only bows, spears, and javelins -Voodoo heads (Necromancer-only shields) -Paladin-only shields -Orbs (Sorceress-Only wands) - */ - if(bindec($b->read(1))) { + /* Credit for the discovery of this field's meaning goes entirely to Guillaume Courtin of France. Thanks! :-> + This field indicates magic properties which are inherent in certain class-specific items. A given class-specific item will (almost) always start with the same set of properties, even if its quality is "normal". Other quality ratings may add more properties to the standard set. It appears that items which will have this field are: + Amazon-only bows, spears, and javelins + Voodoo heads (Necromancer-only shields) + Paladin-only shields + Orbs (Sorceress-Only wands) + */ + if (bindec($b->read(1))) { $b->seek(153); $class_specific = bindec($b->readr(11)); } - - + + // weird behavior/bug // if item is in a container, bodypart will be NULL // if item is on bodypart, container will be NULL switch ($location) { + case D2ItemLocation::BELT: + $this->iData['container'] = 'Belt'; + break; + case D2ItemLocation::CURSOR: + break; + case D2ItemLocation::SOCKET: + break; case D2ItemLocation::STORED: switch ($_stored) { case D2ItemLocationStored::NONE: - $this->iData['container'] = ''; // item is not stored, check bit 58 + + $this->iData['container'] = 'None'; // item is not stored, check bit 58 break; case D2ItemLocationStored::INVENTORY: $this->iData['container'] = 'Inventory'; @@ -159,31 +164,43 @@ Orbs (Sorceress-Only wands) break; case D2ItemLocation::EQUIPPED: switch ($body) { - case D2ItemLocationBody::HELMET: $this->iData['bodypart'] = 'Helmet'; + case D2ItemLocationBody::HELMET: $this->iData['location'] = 'Helmet'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::AMULET: $this->iData['bodypart'] = 'Amulet'; + case D2ItemLocationBody::AMULET: $this->iData['location'] = 'Amulet'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::ARMOR: $this->iData['bodypart'] = 'Armor'; + case D2ItemLocationBody::ARMOR: $this->iData['location'] = 'Armor'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::WEAPONR: $this->iData['bodypart'] = 'Weapon R'; + case D2ItemLocationBody::WEAPONR: $this->iData['location'] = 'Weapon R'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::WEAPONL: $this->iData['bodypart'] = 'Weapon L'; + case D2ItemLocationBody::WEAPONL: $this->iData['location'] = 'Weapon L'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::RINGR: $this->iData['bodypart'] = 'Ring R'; + case D2ItemLocationBody::RINGR: $this->iData['location'] = 'Ring R'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::RINGL: $this->iData['bodypart'] = 'Ring L'; + case D2ItemLocationBody::RINGL: $this->iData['location'] = 'Ring L'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::BELT: $this->iData['bodypart'] = 'Belt'; + case D2ItemLocationBody::BELT: $this->iData['location'] = 'Belt'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::BOOTS: $this->iData['bodypart'] = 'Boots'; + case D2ItemLocationBody::BOOTS: $this->iData['location'] = 'Boots'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::GLOVES: $this->iData['bodypart'] = 'Gloves'; + case D2ItemLocationBody::GLOVES: $this->iData['location'] = 'Gloves'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::WEAPONR2: $this->iData['bodypart'] = 'Weapon Alt R'; + case D2ItemLocationBody::WEAPONR2: $this->iData['location'] = 'Weapon Alt R'; + $this->iData['container'] = 'Body'; break; - case D2ItemLocationBody::WEAPONL2: $this->iData['bodypart'] = 'Weapon Alt L'; + case D2ItemLocationBody::WEAPONL2: $this->iData['location'] = 'Weapon Alt L'; + $this->iData['container'] = 'Body'; break; - default: $this->iData['bodypart'] = 'Unknown'; + default: $this->iData['location'] = 'Unknown'; break; } break; @@ -208,6 +225,18 @@ Orbs (Sorceress-Only wands) } $this->iData['code'] = trim($itemCode); + $sql = "SELECT * from armor WHERE code = '{$this->iData['code']}'"; + $res = PDO_FetchRow($sql); + if (empty($res)) { + $sql = "SELECT * from misc WHERE code = '{$this->iData['code']}'"; + $res = PDO_FetchRow($sql); + } + if (empty($res)) { + $sql = "SELECT * from weapons WHERE code = '{$this->iData['code']}'"; + $res = PDO_FetchRow($sql); + } + $this->iData['txt']=($res); + $sql = " SELECT code, namestr FROM armor diff --git a/src/D2ItemStructureData.php b/src/D2ItemStructureData.php index 8041fee..bc4845b 100644 --- a/src/D2ItemStructureData.php +++ b/src/D2ItemStructureData.php @@ -17,7 +17,7 @@ class D2ItemLocation { /** * */ - const BELTI = 2; + const BELT = 2; /** * */ @@ -25,7 +25,7 @@ class D2ItemLocation { /** * */ - const ITEM = 6; + const SOCKET = 6; }