mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 12:36:03 +00:00
testing new d2item class, working copy, produces identical bits on old item bits and parsed newbits
This commit is contained in:
parent
e560650b4c
commit
143cf8d1ae
197
src/D2Item.php
197
src/D2Item.php
@ -445,8 +445,7 @@ class D2Item {
|
||||
private $bits = null; // Item bitstring
|
||||
private $oldbits = null; // Old Item bits for comparison
|
||||
private $charName; // Character Name
|
||||
private $quality;
|
||||
// Item Structure
|
||||
// Item Structure
|
||||
public $JM;
|
||||
public $UN1;
|
||||
public $identified;
|
||||
@ -480,11 +479,6 @@ class D2Item {
|
||||
public $ilvl;
|
||||
public $rarity;
|
||||
|
||||
// now begins variable item data
|
||||
// so they will not be made into properties here
|
||||
// they will be added from the parseItem() function
|
||||
|
||||
|
||||
public function __construct($bits, $charName = null) {
|
||||
if ($bits == '')
|
||||
return false;
|
||||
@ -507,7 +501,7 @@ class D2Item {
|
||||
$this->ear = $this->b->read(1);
|
||||
$this->starting_item = $this->b->read(1);
|
||||
$this->UN5 = $this->b->read(3);
|
||||
$this->compact = $this->b->read(1); //compact/simple item, only 112 bits
|
||||
$this->simple = $this->b->read(1);
|
||||
$this->eth = $this->b->read(1);
|
||||
$this->UN6 = $this->b->read(1);
|
||||
$this->personalized = $this->b->read(1);
|
||||
@ -524,137 +518,19 @@ class D2Item {
|
||||
|
||||
// for non-ear items
|
||||
$this->code = $this->b->read(32);
|
||||
$code = '';
|
||||
foreach (str_split($this->code, 8) as $byte) {
|
||||
$code .= chr(bindec(strrev($byte)));
|
||||
}
|
||||
$this->itemcode = $code;
|
||||
$this->number_of_items_socketed_within_this_item = $this->b->read(3);
|
||||
//
|
||||
// // if item is not compact, then read advanced data
|
||||
// if ($this->compact == "0") {
|
||||
// // advanced item info
|
||||
// $this->identifier = $this->b->read(32);
|
||||
// $this->ilvl = $this->b->read(7);
|
||||
// $this->rarity = $this->b->read(4);
|
||||
//
|
||||
// // we just read quality, from 150, 151, 152, 153. We are now at 154.
|
||||
// $this->gfx = $this->b->read(1);
|
||||
// if ($this->gfx == "1") {
|
||||
// $this->gfxid = $this->b->read(3);
|
||||
// }
|
||||
//
|
||||
// $this->class_specific = $this->b->read(1);
|
||||
// if ($this->class_specific == "1") {
|
||||
// $this->class_specific_affix_id = $this->b->read(11);
|
||||
// }
|
||||
//
|
||||
// // now we read the rarities
|
||||
// $quality = bindec(strrev($this->rarity));
|
||||
//
|
||||
// switch ($quality) {
|
||||
// case D2ItemQuality::LOW_QUALITY:
|
||||
// $this->quality = "Low Quality";
|
||||
// $this->low_quality_item_data = $this->b->read(3);
|
||||
// $low_quality_item_data = bindec(strrev($this->low_quality_item_data));
|
||||
// switch ($low_quality_item_data) {
|
||||
// case 0:
|
||||
// $this->iData['low_quality_item_data'] = "Crude";
|
||||
// break;
|
||||
// case 1:
|
||||
// $this->iData['low_quality_item_data'] = "Cracked";
|
||||
// break;
|
||||
// case 2:
|
||||
// $this->iData['low_quality_item_data'] = "Damaged";
|
||||
// break;
|
||||
// case 3:
|
||||
// $this->iData['low_quality_item_data'] = "Low Quality";
|
||||
// break;
|
||||
// default:
|
||||
// $this->iData['low_quality_item_data'] = "Unknown quality";
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case D2ItemQuality::NORMAL:
|
||||
// $this->quality = "Normal";
|
||||
// break;
|
||||
// case D2ItemQuality::HIGH_QUALITY:
|
||||
// $this->quality = "High Quality";
|
||||
// $this->high_quality_item_data = $this->b->read(3);
|
||||
// break;
|
||||
// case D2ItemQuality::MAGIC:
|
||||
// $this->quality = "Magic";
|
||||
// // read 11 bits, prefix.
|
||||
// // if no prefix, then next 11 bits will be suffix
|
||||
// $this->magic_prefix = $this->b->read(11);
|
||||
// if (!bindec($this->magic_prefix)) {
|
||||
// $this->magic_suffix = $this->b->read(11);
|
||||
// }
|
||||
//
|
||||
// $prefix = bindec(strrev($this->magic_prefix));
|
||||
// $suffix = bindec(strrev($this->magic_suffix));
|
||||
//
|
||||
// if (!empty(bindec($this->magic_prefix))) {
|
||||
// $sql = "SELECT * FROM magicprefix WHERE ROWID='$prefix'";
|
||||
// $res = PDO_FetchRow($sql);
|
||||
// $this->iData['magic_prefix'] = $res;
|
||||
// }
|
||||
// if (!empty(bindec($this->magic_suffix))) {
|
||||
// $sql = "SELECT * FROM magicsuffix WHERE ROWID='$suffix'";
|
||||
// $res = PDO_FetchRow($sql);
|
||||
// $this->iData['magic_suffix'] = $res;
|
||||
// }
|
||||
// break;
|
||||
// case D2ItemQuality::SET:
|
||||
// $this->quality = "Set";
|
||||
// // Set items have a 12-bit field containing the ID of the set. (Not the set member, but the whole set.) The set member is identified by cross-referencing the item type with the set ID. Also note that set items have an extra field following the item-specific data.
|
||||
// // Set identifier; i.e., all items which are part of the set will have the same value in this field.
|
||||
// $this->setid = $this->b->read(12);
|
||||
// $setid = bindec(strrev($this->setid));
|
||||
//
|
||||
// // first get set name
|
||||
// $sql = "SELECT `set` from setitems WHERE ROWID=$setid";
|
||||
// $set = PDO_FetchOne($sql);
|
||||
// $this->iData["setname"] = $set;
|
||||
//
|
||||
// $sql = "SELECT * from setitems WHERE `set`=? AND item=?";
|
||||
// $res = PDO_FetchRow($sql, [$set, $this->itemcode]);
|
||||
//
|
||||
// $this->iData["data"] = $res;
|
||||
//
|
||||
// break;
|
||||
// case D2ItemQuality::RARE:
|
||||
// $this->quality = "Rare";
|
||||
// break;
|
||||
// case D2ItemQuality::UNIQUE:
|
||||
// $this->quality = "Unique";
|
||||
// break;
|
||||
// case D2ItemQuality::CRAFTED:
|
||||
// $this->quality = "Crafted";
|
||||
// break;
|
||||
// default:
|
||||
// $this->quality = "Unknown";
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// //
|
||||
// }
|
||||
var_dump("old: " . $this->oldbits);
|
||||
var_dump("new: " . ($this->dumpValues()));
|
||||
echo "<hr>";
|
||||
}
|
||||
|
||||
// advanced item info
|
||||
$this->identifier = $this->b->read(32);
|
||||
$this->ilvl = $this->b->read(7);
|
||||
$this->rarity = $this->b->read(4);
|
||||
|
||||
var_dump($this->oldbits);
|
||||
var_dump($this->dumpValues());
|
||||
echo "<hr>";
|
||||
|
||||
}
|
||||
|
||||
public function dumpValues() {
|
||||
$values = [];
|
||||
|
||||
@ -686,37 +562,32 @@ class D2Item {
|
||||
$values[] = $this->panel;
|
||||
$values[] = $this->code;
|
||||
$values[] = $this->number_of_items_socketed_within_this_item;
|
||||
// $values[] = $this->identifier;
|
||||
// $values[] = $this->ilvl;
|
||||
// $values[] = $this->rarity;
|
||||
// $values[] = $this->gfx;
|
||||
// $values[] = $this->gfxid;
|
||||
// $values[] = $this->class_specific;
|
||||
// $values[] = $this->class_specific_affix_id;
|
||||
// $values[] = $this->low_quality_item_data;
|
||||
// $values[] = $this->magic_prefix;
|
||||
// $values[] = $this->magic_suffix;
|
||||
// $values[] = $this->setid;
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
// $values[] = "";
|
||||
$values[] = $this->identifier;
|
||||
$values[] = $this->ilvl;
|
||||
$values[] = $this->rarity;
|
||||
|
||||
// Concatenate the values into a long string
|
||||
$concatenatedValues = implode("", $values);
|
||||
|
||||
return $concatenatedValues;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user