This commit is contained in:
Hash Borgir 2023-09-16 00:53:42 -06:00
parent d794031fd8
commit 5ae4788ed1

View File

@ -6,7 +6,6 @@ require_once 'D2Strings.php';
require_once 'D2Functions.php';
require_once 'D2ItemData.php';
class D2Item_OLD {
/**
@ -134,10 +133,9 @@ class D2Item_OLD {
$class_specific = bindec($b->readr(11));
}
//var_dump($b->getOffset());
//
//var_dump($b->getOffset());
//
{
// if 151 is 1, but 152 is 0, then we have read 152/153/154 already, so we should be at 155
if ($ring && !$_class_specific) {
@ -169,7 +167,7 @@ class D2Item_OLD {
default:
$this->iData['low_quality_item_data'] = "Unknown quality";
break;
}
}
break;
// Normal items have no extra quality data.
case D2ItemQuality::NORMAL:
@ -191,11 +189,11 @@ class D2Item_OLD {
//var_dump($setid);
$sql = "SELECT ROWID,* from sets WHERE ROWID=$setid";
$res = PDO_FetchRow($sql);
//ddump($res);
$this->iData["setname"] = $res;
break;
case D2ItemQuality::RARE:
$this->iData['iquality'] = "Rare";
@ -316,7 +314,7 @@ class D2Item_OLD {
$sql = "SELECT * from weapons WHERE code = '{$this->iData['code']}'";
$res = PDO_FetchRow($sql);
}
// set txt data array
$this->iData['txt'] = ($res);
@ -345,10 +343,6 @@ class D2Item_OLD {
}
/**
*
*/
@ -406,6 +400,9 @@ class D2Item {
}
public function parseItem() {
$sql = "SELECT * FROM itemstatcost";
$isc = PDO_FetchAll($sql);
// Read and store the actual bits for each class member
$this->JM = $this->b->read(16);
$this->UN1 = $this->b->read(4);
@ -680,8 +677,8 @@ class D2Item {
// if it is an Armor, then get defense
if (!empty($res)) {
$this->defense = $this->b->read(11);
$this->_defense = bindec(strrev($this->defense)) - 10;
$this->defense = $this->b->read($isc[31]['Save Bits']);
$this->_defense = bindec(strrev($this->defense)) - $isc[31]['Save Add'];
var_dump("Def:" . $this->defense);
var_dump("Def:" . $this->_defense);
@ -694,17 +691,17 @@ class D2Item {
// I found it. It's current durability. If we read it, we end up missing the 8 bits.
$this->maxdurability = "" . $this->b->read(8);
$this->_maxdurability = bindec(strrev($this->maxdurability));
$this->maxdurability = "" . $this->b->read($isc[73]['Save Bits']);
$this->_maxdurability = bindec(strrev($this->maxdurability)) - $isc[73]['Save Add'];
var_dump("MaxDur:" . $this->maxdurability);
var_dump("MaxDur:" . $this->_maxdurability);
//Only exists if the item's max durability is greater than zero
//The first 8 bits are the item's current durability. The last bit is unknown.
//The first 8 bits are the item's current durability. The last bit is unknown.
if ($this->maxdurability !== 0) {
$this->currentdurability = $this->b->read(9);
$this->_currentdurability = bindec(strrev($this->currentdurability));
$this->currentdurability = $this->b->read($isc[72]['Save Bits']);
$this->_currentdurability = bindec(strrev($this->currentdurability)) - $isc[72]['Save Add'];
var_dump("CurDur:" . $this->currentdurability);
var_dump("CurDur:" . $this->_currentdurability);
//$this->currentdurability_unknown_bit = $this->b->read(1);
@ -715,17 +712,17 @@ class D2Item {
$sql = "SELECT code FROM weapons WHERE code = ?";
$weap = PDO_FetchOne($sql, [$this->itemcode]);
if (!empty($weap)) {
$this->maxdurability = $this->b->read(8);
$this->_maxdurability = bindec(strrev($this->maxdurability));
$this->maxdurability = $this->b->read($isc[73]['Save Bits']);
$this->_maxdurability = bindec(strrev($this->maxdurability)) - $isc[73]['Save Add'];
var_dump("MaxDur:" . $this->maxdurability);
var_dump("MaxDur:" . $this->_maxdurability);
//Only exists if the item's max durability is greater than zero
//The first 8 bits are the item's current durability. The last bit is unknown.
//The first 8 bits are the item's current durability. The last bit is unknown.
if ($this->maxdurability !== 0) {
$this->currentdurability = $this->b->read(9);
$this->_currentdurability = bindec(strrev($this->currentdurability));
$this->currentdurability = $this->b->read($isc[72]['Save Bits']);
$this->_currentdurability = bindec(strrev($this->currentdurability)) - $isc[72]['Save Add'];
var_dump("CurDur:" . $this->currentdurability);
var_dump("CurDur:" . $this->_currentdurability);
//$this->currentdurability_unknown_bit = $this->b->read(1);
@ -740,7 +737,7 @@ class D2Item {
}
//
//
if ($this->socketed == "1") {
$this->numsockets = $this->b->read(4);
$this->_numsockets = bindec(strrev($this->numsockets));
@ -752,10 +749,10 @@ class D2Item {
// Set properties bit field, used later for reading the set property lists of the item
// if item is set
//somewhere here in the set thing, we're missing 9 bits.
// if we skip those 9 bits for testing, we should get corect setprops?
// if we skip those 9 bits for testing, we should get corect setprops?
if (($quality == D2ItemQuality::SET)) {
$this->setfield = $this->b->read(5); // mismatch, need to debug
$this->setfield = $this->b->read(5); // mismatch, need to debug
}
if (($quality == D2ItemQuality::MAGIC)) {
@ -774,46 +771,69 @@ class D2Item {
}
$sql = "SELECT * FROM itemstatcost";
$isc = PDO_FetchAll($sql);
// read properties here
$property = $this->b->read(9);
$_property = bindec(strrev($property));
$val1;
$_val1;
$val2;
$_val2;
for ($i = 0; $i < 10; $i++) {
if ($isc[$_property]['Save Bits']) {
switch ($_property) {
case 17:
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
break;
case 48:
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
break;
default:
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
break;
}
$property = $this->b->read(9);
$_property = bindec(strrev($property));
if ($_property == 511) {
echo 511;
break;
}
}
}
// while (true) {
// $property = $this->b->read(9);
// $_property = bindec(strrev($property));
// if ($_property == 511) {
// echo 511;
// break;
// }
// if (!empty($isc[$_property]['Save Bits'])) {
// switch ($_property) {
// case 17:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// break;
// case 48:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[49]['Save Bits']);
// break;
// case 50:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[51]['Save Bits']);
// break;
// case 52:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[53]['Save Bits']);
// break;
// case 54:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[55]['Save Bits']);
// $props[$property][] = $this->b->read($isc[56]['Save Bits']);
// break;
// case 57:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[58]['Save Bits']);
// $props[$property][] = $this->b->read($isc[59]['Save Bits']);
// break;
// case 83:
// case 107:
// case 108:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read($isc[$_property]['Save Param Bits']);
// case 188:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read(13);
// $props[$property][] = $this->b->read(3);
// case 204:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// $props[$property][] = $this->b->read(5);
// $props[$property][] = $this->b->read(8);
// $props[$property][] = $this->b->read(8);
// default:
// $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
// break;
// }
// }
// }
$this->props = $props;
var_dump($this->props);
//var_dump($this->props);
if ($this->simple) {
echo "Simple";
@ -903,16 +923,14 @@ class D2Item {
$values[] = $this->setfield;
$values[] = $this->magicammo;
$values[] = $this->tpot;
// foreach($this->props as $k => $v){
// $values[] = $k;
// $values[] = $v[0];
// $values[] = $v[1] ?? '';
//
//
// }
$values[] = "";
$values[] = "";
$values[] = "";