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 'D2Functions.php';
require_once 'D2ItemData.php'; require_once 'D2ItemData.php';
class D2Item_OLD { class D2Item_OLD {
/** /**
@ -134,10 +133,9 @@ class D2Item_OLD {
$class_specific = bindec($b->readr(11)); $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 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) { if ($ring && !$_class_specific) {
@ -169,7 +167,7 @@ class D2Item_OLD {
default: default:
$this->iData['low_quality_item_data'] = "Unknown quality"; $this->iData['low_quality_item_data'] = "Unknown quality";
break; break;
} }
break; break;
// Normal items have no extra quality data. // Normal items have no extra quality data.
case D2ItemQuality::NORMAL: case D2ItemQuality::NORMAL:
@ -191,11 +189,11 @@ class D2Item_OLD {
//var_dump($setid); //var_dump($setid);
$sql = "SELECT ROWID,* from sets WHERE ROWID=$setid"; $sql = "SELECT ROWID,* from sets WHERE ROWID=$setid";
$res = PDO_FetchRow($sql); $res = PDO_FetchRow($sql);
//ddump($res); //ddump($res);
$this->iData["setname"] = $res; $this->iData["setname"] = $res;
break; break;
case D2ItemQuality::RARE: case D2ItemQuality::RARE:
$this->iData['iquality'] = "Rare"; $this->iData['iquality'] = "Rare";
@ -316,7 +314,7 @@ class D2Item_OLD {
$sql = "SELECT * from weapons WHERE code = '{$this->iData['code']}'"; $sql = "SELECT * from weapons WHERE code = '{$this->iData['code']}'";
$res = PDO_FetchRow($sql); $res = PDO_FetchRow($sql);
} }
// set txt data array // set txt data array
$this->iData['txt'] = ($res); $this->iData['txt'] = ($res);
@ -345,10 +343,6 @@ class D2Item_OLD {
} }
/** /**
* *
*/ */
@ -406,6 +400,9 @@ class D2Item {
} }
public function parseItem() { public function parseItem() {
$sql = "SELECT * FROM itemstatcost";
$isc = PDO_FetchAll($sql);
// Read and store the actual bits for each class member // Read and store the actual bits for each class member
$this->JM = $this->b->read(16); $this->JM = $this->b->read(16);
$this->UN1 = $this->b->read(4); $this->UN1 = $this->b->read(4);
@ -680,8 +677,8 @@ class D2Item {
// if it is an Armor, then get defense // if it is an Armor, then get defense
if (!empty($res)) { if (!empty($res)) {
$this->defense = $this->b->read(11); $this->defense = $this->b->read($isc[31]['Save Bits']);
$this->_defense = bindec(strrev($this->defense)) - 10; $this->_defense = bindec(strrev($this->defense)) - $isc[31]['Save Add'];
var_dump("Def:" . $this->defense); var_dump("Def:" . $this->defense);
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. // 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 = "" . $this->b->read($isc[73]['Save Bits']);
$this->_maxdurability = bindec(strrev($this->maxdurability)); $this->_maxdurability = bindec(strrev($this->maxdurability)) - $isc[73]['Save Add'];
var_dump("MaxDur:" . $this->maxdurability); var_dump("MaxDur:" . $this->maxdurability);
var_dump("MaxDur:" . $this->_maxdurability); var_dump("MaxDur:" . $this->_maxdurability);
//Only exists if the item's max durability is greater than zero //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) { if ($this->maxdurability !== 0) {
$this->currentdurability = $this->b->read(9); $this->currentdurability = $this->b->read($isc[72]['Save Bits']);
$this->_currentdurability = bindec(strrev($this->currentdurability)); $this->_currentdurability = bindec(strrev($this->currentdurability)) - $isc[72]['Save Add'];
var_dump("CurDur:" . $this->currentdurability); var_dump("CurDur:" . $this->currentdurability);
var_dump("CurDur:" . $this->_currentdurability); var_dump("CurDur:" . $this->_currentdurability);
//$this->currentdurability_unknown_bit = $this->b->read(1); //$this->currentdurability_unknown_bit = $this->b->read(1);
@ -715,17 +712,17 @@ class D2Item {
$sql = "SELECT code FROM weapons WHERE code = ?"; $sql = "SELECT code FROM weapons WHERE code = ?";
$weap = PDO_FetchOne($sql, [$this->itemcode]); $weap = PDO_FetchOne($sql, [$this->itemcode]);
if (!empty($weap)) { if (!empty($weap)) {
$this->maxdurability = $this->b->read(8); $this->maxdurability = $this->b->read($isc[73]['Save Bits']);
$this->_maxdurability = bindec(strrev($this->maxdurability)); $this->_maxdurability = bindec(strrev($this->maxdurability)) - $isc[73]['Save Add'];
var_dump("MaxDur:" . $this->maxdurability); var_dump("MaxDur:" . $this->maxdurability);
var_dump("MaxDur:" . $this->_maxdurability); var_dump("MaxDur:" . $this->_maxdurability);
//Only exists if the item's max durability is greater than zero //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) { if ($this->maxdurability !== 0) {
$this->currentdurability = $this->b->read(9); $this->currentdurability = $this->b->read($isc[72]['Save Bits']);
$this->_currentdurability = bindec(strrev($this->currentdurability)); $this->_currentdurability = bindec(strrev($this->currentdurability)) - $isc[72]['Save Add'];
var_dump("CurDur:" . $this->currentdurability); var_dump("CurDur:" . $this->currentdurability);
var_dump("CurDur:" . $this->_currentdurability); var_dump("CurDur:" . $this->_currentdurability);
//$this->currentdurability_unknown_bit = $this->b->read(1); //$this->currentdurability_unknown_bit = $this->b->read(1);
@ -740,7 +737,7 @@ class D2Item {
} }
// //
if ($this->socketed == "1") { if ($this->socketed == "1") {
$this->numsockets = $this->b->read(4); $this->numsockets = $this->b->read(4);
$this->_numsockets = bindec(strrev($this->numsockets)); $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 // Set properties bit field, used later for reading the set property lists of the item
// if item is set // if item is set
//somewhere here in the set thing, we're missing 9 bits. //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)) { 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)) { if (($quality == D2ItemQuality::MAGIC)) {
@ -774,46 +771,69 @@ class D2Item {
} }
$sql = "SELECT * FROM itemstatcost";
$isc = PDO_FetchAll($sql);
// read properties here // read properties here
$property = $this->b->read(9); // while (true) {
$_property = bindec(strrev($property)); // $property = $this->b->read(9);
// $_property = bindec(strrev($property));
$val1; // if ($_property == 511) {
$_val1; // echo 511;
$val2; // break;
$_val2; // }
// if (!empty($isc[$_property]['Save Bits'])) {
for ($i = 0; $i < 10; $i++) { // switch ($_property) {
if ($isc[$_property]['Save Bits']) { // case 17:
switch ($_property) { // $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
case 17: // $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']); // break;
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']); // case 48:
break; // $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
case 48: // $props[$property][] = $this->b->read($isc[49]['Save Bits']);
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']); // break;
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']); // case 50:
break; // $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
default: // $props[$property][] = $this->b->read($isc[51]['Save Bits']);
$props[$property][] = $this->b->read($isc[$_property]['Save Bits']); // break;
break; // case 52:
} // $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
$property = $this->b->read(9); // $props[$property][] = $this->b->read($isc[53]['Save Bits']);
$_property = bindec(strrev($property)); // break;
if ($_property == 511) { // case 54:
echo 511; // $props[$property][] = $this->b->read($isc[$_property]['Save Bits']);
break; // $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; $this->props = $props;
var_dump($this->props); //var_dump($this->props);
if ($this->simple) { if ($this->simple) {
echo "Simple"; echo "Simple";
@ -903,16 +923,14 @@ class D2Item {
$values[] = $this->setfield; $values[] = $this->setfield;
$values[] = $this->magicammo; $values[] = $this->magicammo;
$values[] = $this->tpot; $values[] = $this->tpot;
// foreach($this->props as $k => $v){ // foreach($this->props as $k => $v){
// $values[] = $k; // $values[] = $k;
// $values[] = $v[0]; // $values[] = $v[0];
// $values[] = $v[1] ?? ''; // $values[] = $v[1] ?? '';
// //
// } // }
$values[] = ""; $values[] = "";
$values[] = ""; $values[] = "";
$values[] = ""; $values[] = "";