getting same results for every char, something is fucked

This commit is contained in:
Hash Borgir
2022-05-09 02:08:51 -06:00
parent bd7a2efed7
commit c4c1622902
34 changed files with 10884 additions and 128 deletions

View File

@@ -52,7 +52,7 @@ function ddump($var) {
function dump($var) {
echo "<pre>";
echo "$var";
var_dump($var);
echo "</pre>";
//header('Content-Type: application/json');

View File

@@ -1,50 +1,33 @@
<?php
require_once 'D2SaveFileStructureData.php';
require_once 'D2Files.php';
class D2SaveFile {
public $charData;
public $sdata;
public $files;
public function __construct() {
$sdata = new D2SaveFileStructureData();
$this->sdata = new D2SaveFileStructureData();
$D2Files = new D2Files();
$files = $D2Files->getSaveFiles();
foreach ($files as $f) {
$this->files = $D2Files->getSaveFiles();
foreach ($this->files as $f) {
$filePath = $_SESSION['savePath'] . $f;
$fp = fopen($filePath, "rb+");
foreach ($sdata->qNorm as $k => $v) {
fseek($fp, $k);
$questsNorm[$k] = fread($fp, 2);
}
foreach ($sdata->qNM as $k => $v) {
fseek($fp, $k);
$questsNM[$k] = fread($fp, 2);
}
foreach ($sdata->qHell as $k => $v) {
fseek($fp, $k);
$questsHell[$k] = fread($fp, 2);
}
// read offsets here from sdata and put into $data which will be used for charData
foreach ($sdata->offsets as $k => $v) {
foreach ($this->sdata->offsets as $k => $v) {
fseek($fp, $k);
$data[$k] = fread($fp, $v);
}
}
$charData['Identifier'] = bin2hex($data[0]);
$charData['VersionID'] = $sdata->version[unpack('l', $data[4])[1]]; // 96 is v1.10+ - check out
@@ -53,7 +36,11 @@ class D2SaveFile {
// $charData['Checksum'] = bin2hex($data['12']);
// $charData['Activeweapon'] = unpack('l', $data['16']);
$charData['CharacterName'] = ($data[20]);
$charData['CharacterName'] = str_replace("\0", "", $data[20]);
// ddump(str_replace("\0x00", '', $charData['CharacterName']));
$charData['CharacterStatus'] = array_filter(str_split(strtobits($data[36])));
@@ -65,7 +52,7 @@ class D2SaveFile {
// $charData['Characterprogression'] = bindec($data['37']);
$charData['CharacterClass'] = $sdata->class[unpack('C', $data[40])[1]];
$charData['CharacterClass'] = $this->sdata->class[unpack('C', $data[40])[1]];
$charData['CharacterLevel'] = unpack('C', $data[43])[1];
@@ -73,10 +60,10 @@ class D2SaveFile {
// $charData['Assignedskills'] = (unpack('i16', $data['56']));
$charData['LeftmousebuttonskillID'] = $sdata->skills[unpack('i', $data[120])[1]];
$charData['RightmousebuttonskillID'] = $sdata->skills[unpack('i', $data[124])[1]];
$charData['LeftswapmousebuttonskillID'] = $sdata->skills[unpack('i', $data[128])[1]];
$charData['RightswapmousebuttonskillID'] = $sdata->skills[unpack('i', $data[132])[1]];
$charData['LeftmousebuttonskillID'] = $this->sdata->skills[unpack('i', $data[120])[1]];
$charData['RightmousebuttonskillID'] = $this->sdata->skills[unpack('i', $data[124])[1]];
$charData['LeftswapmousebuttonskillID'] = $this->sdata->skills[unpack('i', $data[128])[1]];
$charData['RightswapmousebuttonskillID'] = $this->sdata->skills[unpack('i', $data[132])[1]];
// $charData['Charactermenuappearance'] = unpack('i', $data[136]);
@@ -96,40 +83,108 @@ class D2SaveFile {
//$charData['Mercenaryexperience'] = $data['187'];
$charData['Quests'][] = $this->getQuestData();
$charData['Waypoints'] = $this->getWaypointsData();
$charData['NPCIntroductions'] = $data[714];
$this->charData[] = $charData;
// ddump($charData);
}
// ddump($this->charData);
return $this->charData;
}
public function getQuestData() {
foreach ($this->files as $f) {
$questsNorm = null;
$questsNM = null;
$questsHell = null;
$quests = null;
$filePath = $_SESSION['savePath'] . $f;
$fp = fopen($filePath, "rb+");
foreach ($this->sdata->qNorm as $k => $v) {
fseek($fp, $k);
$questsNorm[$k] = fread($fp, 2);
}
foreach ($this->sdata->qNM as $k => $v) {
fseek($fp, $k);
$questsNM[$k] = fread($fp, 2);
}
foreach ($this->sdata->qHell as $k => $v) {
fseek($fp, $k);
$questsHell[$k] = fread($fp, 2);
}
foreach ($questsNorm as $k => $v) {
$x = array_filter(str_split(strtobits($v), 8));
if ($x[0][0]) {
$quests[] = ($sdata->qNorm[$k] . " => " . $x[0][0]);
}
$x = (str_split(strtobits($v), 8));
//if ($x[0][0]) {
$quests['Norm'][$this->sdata->qNorm[$k]] = $x[0][0];
//}
}
foreach ($questsNM as $k => $v) {
$x = array_filter(str_split(strtobits($v), 8));
if ($x[0][0]) {
$quests[] = ($sdata->qNM[$k] . " => " . $x[0][0]);
}
//if ($x[0][0]) {
$quests['NM'][$this->sdata->qNM[$k]] = $x[0][0];
//}
}
foreach ($questsHell as $k => $v) {
$x = array_filter(str_split(strtobits($v), 8));
if ($x[0][0]) {
$quests[] = ($sdata->qHell[$k] . " => " . $x[0][0]);
}
//if ($x[0][0]) {
$quests['Hell'][$this->sdata->qHell[$k]] = $x[0][0];
//}
}
$charData['Quests'] = $quests;
$charData['Waypoints'] = $data[633];
$charData['NPCIntroductions'] = $data[714];
$this->charData[] = $charData;
// ddump($charData);
return $quests;
}
}
return $this->charData;
public function getWaypointsData() {
foreach ($this->files as $f) {
$filePath = $_SESSION['savePath'] . $f;
$fp = fopen($filePath, "rb+");
$wp = null;
fseek($fp, $this->sdata->wpOffsetsNorm);
$wp['Norm'] = (strtobits(fread($fp, 5)));
fseek($fp, $this->sdata->wpOffsetsNM);
$wp['NM'] = (strtobits(fread($fp, 5)));
fseek($fp, $this->sdata->wpOffsetsHell);
$wp['Hell'] = (strtobits(fread($fp, 5)));
// ddump($wp);
foreach ($wp['Norm'] as $k => $v) {
$waypoints['Norm'][$this->sdata->wpNames[$k]] = $v;
}
foreach ($wp['NM'] as $k => $v) {
$waypoints['NM'][$this->sdata->wpNames[$k]] = $v;
}
foreach ($wp['Hell'] as $k => $v) {
$waypoints['Hell'][$this->sdata->wpNames[$k]] = $v;
}
//ddump($waypoints);
return $wp;
}
}
}

View File

@@ -99,9 +99,9 @@ class D2SaveFileStructureData {
395 => 'TheFallenAngel',
397 => 'TerrorsEnd',
399 => 'HellForge',
401 => 'empty',
403 => 'empty',
405 => 'empty',
401 => 'empty1',
403 => 'empty2',
405 => 'empty3',
407 => 'traveledToAct5',
409 => 'completedTerrorsEnd',
414 => 'SiegeOnHarrogath',
@@ -140,9 +140,9 @@ class D2SaveFileStructureData {
488 => 'TheFallenAngelNM',
490 => 'TerrorsEndNM',
492 => 'HellForgeNM',
494 => 'emptyNM',
496 => 'emptyNM',
498 => 'emptyNM',
494 => 'emptyNM1',
496 => 'emptyNM2',
498 => 'emptyNM3',
500 => 'traveledToAct5NM',
502 => 'completedTerrorsEndNM',
504 => 'SiegeOnHarrogathNM',
@@ -181,9 +181,9 @@ class D2SaveFileStructureData {
578 => 'TheFallenAngelHell',
580 => 'TerrorsEndHell',
582 => 'HellForgeHell',
584 => 'emptyHell',
586 => 'emptyHell',
588 => 'emptyHell',
584 => 'emptyHell1',
586 => 'emptyHell2',
588 => 'emptyHell3',
590 => 'traveledToAct5Hell',
592 => 'completedTerrorsEndHell',
594 => 'SiegeOnHarrogathHell',
@@ -202,6 +202,98 @@ class D2SaveFileStructureData {
96 => "v1.10+"
];
public $wpOffsetsNorm = 643;
public $wpOffsetsNM = 667;
public $wpOffsetsHell = 691;
public $wpRawNames = [
0 => 'Act 1 - Town',
1 => 'Act 1 - Wilderness 2',
2 => 'Act 1 - Wilderness 3',
3 => 'Act 1 - Wilderness 4',
4 => 'Act 1 - Wilderness 5',
5 => 'Act 1 - Courtyard 1',
6 => 'Act 1 - Jail 1',
7 => 'Act 1 - Courtyard 2',
8 => 'Act 1 - Catacombs 2',
9 => 'Act 2 - Town',
10 => 'Act 2 - Desert 2',
11 => 'Act 2 - Desert 3',
12 => 'Act 2 - Desert 4',
13 => 'Act 2 - Valley of the Kings',
14 => 'Act 2 - Sewer 1 B',
15 => 'Act 2 - Basement 1',
16 => 'Act 2 - Tomb 2 B',
17 => 'Act 2 - Arcane',
18 => 'Act 3 - Town',
19 => 'Act 3 - Jungle 1',
20 => 'Act 3 - Jungle 2',
21 => 'Act 3 - Jungle 3',
22 => 'Act 3 - Kurast 1',
23 => 'Act 3 - Kurast 2',
24 => 'Act 3 - Kurast 3',
25 => 'Act 3 - Travincal',
26 => 'Act 3 - Mephisto 2',
27 => 'Act 4 - Town',
28 => 'Act 4 - Mesa 3',
29 => 'Act 4 - Lava 1',
30 => 'Act 5 - Town',
31 => 'Act 5 - Barricade 1',
32 => 'Act 5 - Barricade 2',
33 => 'Act 5 - Ice Cave 1',
34 => 'Act 5 - Ice Cave 2',
35 => 'Act 5 - Barricade Snow',
36 => 'Act 5 - Ice Cave 3',
37 => 'Act 5 - Temple 2',
38 => 'Act 5 - Baal Temple 2'
];
public $wpNames = [
0 => 'Rogue Encampment',
1 => 'Cold Plains',
2 => 'Stony Field',
3 => 'Dark Wood',
4 => 'Black Marsh',
5 => 'Outer Cloister',
6 => 'Jail, level 1',
7 => 'Inner Cloister',
8 => 'Catacombs, level 2',
9 => 'Lut Gholein',
10 => 'Sewers, level 2',
11 => 'Dry Hills',
12 => 'Halls of the Dead, level 2',
13 => 'Far Oasis',
14 => 'Lost City',
15 => 'Palace Cellar, level 1',
16 => 'Arcane Sanctuary',
17 => 'Canyon of the Magi',
18 => 'Kurast Docks',
19 => 'Spider Forest',
20 => 'Great Marsh',
21 => 'Flayer Jungle',
22 => 'Lower Kurast',
23 => 'Kurast Bazaar',
24 => 'Upper Kurast',
25 => 'Travincal',
26 => 'Durance of Hate, level 2',
27 => 'Pandemonium Fortress',
28 => 'City of the Damned',
29 => 'River of Flames',
30 => 'Harrogath',
31 => 'Frigid Highlands',
32 => 'Arreat Plateau',
33 => 'Crystalline Passage',
34 => 'Halls of Pain',
35 => 'Glacial Trail',
36 => 'Frozen Tundra',
37 => "The Ancients' Way",
38 => 'Worldstone Keep, level 2'
];
/*
Initialize Skills From Skills.txt
*/

View File

@@ -61,7 +61,7 @@
</div>
<ul class="nav nav-tabs" id="Tabs" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">Unique Items</a>
<a class="nav-link" id="Unique-tab" data-toggle="tab" href="#Unique" role="tab" aria-controls="Unique" aria-selected="true">Unique Items</a>
</li>
<!-- <li class="nav-item" role="presentation">
<a class="nav-link" id="Set-tab" data-toggle="tab" href="#Set" role="tab" aria-controls="Set" aria-selected="false">Set Items</a>
@@ -77,7 +77,7 @@
</li>
-->
<li class="nav-item" role="presentation">
<a class="nav-link" id="Chars-tab" data-toggle="tab" href="#Chars" role="tab" aria-controls="Chars" aria-selected="false">Character Editor</a>
<a class="nav-link active" id="Chars-tab" data-toggle="tab" href="#Chars" role="tab" aria-controls="Chars" aria-selected="false">Character Editor</a>
</li>
<li class="nav-item" role="presentation">
@@ -94,7 +94,7 @@
</div>
</div>
<div class="tab-content" id="TabContent">
<div class="tab-pane fade show active" id="Unique" role="tabpanel" aria-labelledby="Unique-tab">
<div class="tab-pane fade" id="Unique" role="tabpanel" aria-labelledby="Unique-tab">
<?php require_once 'tabs/UniqueItems.php'; ?>
</div>
<div class="tab-pane fade" id="Set" role="tabpanel" aria-labelledby="Set-tab">
@@ -113,7 +113,7 @@
<div class="tab-pane fade" id="Doc" role="tabpanel" aria-labelledby="Doc-tab">
<?php require_once 'tabs/Doc.php'; ?>
</div>
<div class="tab-pane fade" id="Chars" role="tabpanel" aria-labelledby="Chars-tab">
<div class="tab-pane fade show active" id="Chars" role="tabpanel" aria-labelledby="Chars-tab">
<?php require_once 'tabs/Chars.php'; ?>
</div>
<div class="tab-pane fade" id="Debug" role="tabpanel" aria-labelledby="Debug-tab">

View File

@@ -1,4 +1,6 @@
<?php
$form = new Formr\Formr();
/*
Copyright (C) 2021 Hash Borgir
@@ -40,7 +42,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// var_dump($chars->charData);
// dump($chars->charData);
?>
@@ -49,23 +51,28 @@
<div style="text-align: center; margin-top: 20px;">
<div class="container">
<ul class="nav nav-tabs" id="CTabs" role="tablist">
<?php
$tabs = '';
foreach ($chars->charData as $c) {
$tabs .= <<<EOT
<?php
$tabs = '';
$counter = 1;
foreach ($chars->charData as $k => $c) {
if ($k == 0) {
$active = "active";
} else {
$active = "";
}
$tabs .= <<<EOT
<li class="nav-item" role="presentation">
<a class="nav-link btn btn-outline-danger" style="background: #ddd; border: 1px solid #888;" id="{$c['CharacterName']}-tab" data-toggle="tab" href="#{$c['CharacterName']}" role="tab" aria-controls="{$c['CharacterName']}" aria-selected="true"><img height="64" width="" src="img/chars/{$c['CharacterClass']}.gif">{$c['CharacterName']}</a>
<a class="nav-link btn btn-outline-danger $active" style="background: #ddd; border: 1px solid #888;" id="{$c['CharacterName']}-tab" data-toggle="tab" href="#{$c['CharacterName']}" role="tab" aria-controls="{$c['CharacterName']}" aria-selected="true"><img height="64" width="" src="img/chars/{$c['CharacterClass']}.gif">{$c['CharacterName']}</a>
</li>
EOT;
}
echo $tabs;
?>
EOT;
}
echo $tabs;
?>
</ul>
</div>
</div>
@@ -73,52 +80,69 @@ EOT;
<div class="tab-content" id="CTabContent">
<?php
foreach ($c['Quests'] as $q) {
$quest .= "<>";
<?php
foreach ($c['Quests'] as $quest) {
foreach ($quest as $q) {
foreach ($q as $k => $v) {
$quest .= "$k = $v<br>";
}
}
}
foreach ($chars->charData as $c) {
$tabContent .= <<<EOT
<div style="background: white;" class="tab-pane fade" id="{$c['CharacterName']}" role="tabpanel" aria-labelledby="{$c['CharacterName']}-tab">
foreach ($chars->charData as $k => $c) {
if ($k == 0) {
$active = "active show";
} else {
$active = "";
}
// dump($c['Waypoints']);
$tabContent .= <<<EOT
<div style="background: white;" class="tab-pane fade $active" id="{$c['CharacterName']}" role="tabpanel" aria-labelledby="{$c['CharacterName']}-tab">
<h1 style="margin: 15px;">{$c['CharacterName']}</h1>
<table>
<tr>
<td>
<img style="height: 240px;" src="img/chars/{$c['CharacterClass']}.gif">
</td>
<td>
<ul>
<li>Version: {$c['VersionID']}</li>
<li>Filesize: {$c['Filesize']}</li>
<li>CharacterStatus: {$c['CharacterStatus']}</li>
<li>CharacterClass: {$c['CharacterClass']}</li>
<li>CharacterLevel: {$c['CharacterLevel']}</li>
<li>Lastplayed: {$c['Lastplayed']}</li>
<li>LeftmousebuttonskillID: {$c['LeftmousebuttonskillID']}</li>
<li>LeftmousebuttonskillID: {$c['LeftmousebuttonskillID']}</li>
<li>LeftswapmousebuttonskillID: {$c['LeftswapmousebuttonskillID']}</li>
<li>RightswapmousebuttonskillID: {$c['RightswapmousebuttonskillID']}</li>
<li>Difficulty: {$c['Difficulty']}</li>
</ul>
</td>
<td>
<ul>
<li>{$c['Quests']}</li>
</ul>
</td>
</tr>
</table>
<div class="container" style="font-size: 14px;">
<div class="row">
<div class="col">
<img src="/img/chars/{$c['CharacterClass']}.gif">
</div>
<div class="col">
<input type="text" id="ChracterName" name="ChracterName" maxlength="16" value="{$c['CharacterName']}">
<select id='CharacterClass'>
<option value="Amazon">Amazon</option>
<option value="Assassin">Assassin</option>
<option value="Barbarian">Barbarian</option>
<option value="Druid">Druid</option>
<option value="Paladin">Paladin</option>
<option value="Necromancer">Necromancer</option>
<option value="Sorceress">Sorceress</option>
</select>
<input type="number" id="CharacterLevel">
<input type="radio" id="DifficultyNormal" name="Difficulty" value="Normal">Normal<br>
<input type="radio" id="DifficultyNM" name="Difficulty" value="Normal">NM<br>
<input type="radio" id="DifficultyHell" name="Difficulty" value="Normal">Hell<br>
{$c['Waypoints']['Norm']}<br>
{$c['Waypoints']['NM']}<br>
{$c['Waypoints']['Hell']}<br>
</div>
<div class="col">$quest</div>
<div class="col">Col 3</div>
</div>
</div>
</div>
EOT;
}
echo $tabContent;
EOT;
}
echo $tabContent;
?>
</div>