mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 12:36:03 +00:00
working
This commit is contained in:
parent
c4c1622902
commit
5e75c70664
@ -9,7 +9,7 @@ ob_start();
|
||||
|
||||
echo "<pre>";
|
||||
|
||||
$filePath = "D:\Diablo II\MODS\ironman-dev\save\Barb.d2s";
|
||||
$filePath = "D:\Diablo II\MODS\ironman-dev\save\Sorc.d2s";
|
||||
$fp = fopen($filePath, "rb");
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ $charData['Filesize'] = round(unpack('l', $data[8])[1] / 1024, 2) . " KB"; //
|
||||
|
||||
$charData['CharacterName'] = ($data[20]);
|
||||
|
||||
$charData['CharacterStatus'] = array_filter(str_split(strtobits($data[36])));
|
||||
// $charData['CharacterStatus'] = array_filter(str_split(strtobits($data[36])));
|
||||
|
||||
foreach ($charData['CharacterStatus'] as $k => $v) {
|
||||
$str .= ($characterStatus[$k]) . " ";
|
||||
|
15
index.php
15
index.php
@ -89,10 +89,21 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
||||
require_once './src/D2TxtParser.php';
|
||||
require_once './src/D2ItemDesc.php';
|
||||
require_once './src/D2SaveFile.php';
|
||||
|
||||
$chars = new D2SaveFile();
|
||||
require_once './src/D2SaveFileStructureData.php';
|
||||
|
||||
|
||||
$D2Files = new D2Files();
|
||||
$charFiles = $D2Files->getSaveFiles();
|
||||
|
||||
|
||||
foreach($charFiles as $charFile){
|
||||
$charData[] = new D2SaveFile($charFile);
|
||||
}
|
||||
|
||||
|
||||
// dump($charData[0]->charData);
|
||||
// dump($charData[1]->charData);
|
||||
// die();
|
||||
|
||||
$idesc = new D2ItemDesc();
|
||||
$db = new D2Database();
|
||||
|
@ -6,31 +6,25 @@ require_once 'D2Files.php';
|
||||
class D2SaveFile {
|
||||
|
||||
public $charData;
|
||||
public $sdata;
|
||||
public $files;
|
||||
public $sData;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct($file) {
|
||||
|
||||
$this->sdata = new D2SaveFileStructureData();
|
||||
$this->sData = new D2SaveFileStructureData();
|
||||
|
||||
$D2Files = new D2Files();
|
||||
$this->files = $D2Files->getSaveFiles();
|
||||
|
||||
foreach ($this->files as $f) {
|
||||
$filePath = $_SESSION['savePath'] . $f;
|
||||
$filePath = $_SESSION['savePath'] . $file;
|
||||
|
||||
$fp = fopen($filePath, "rb+");
|
||||
|
||||
// read offsets here from sdata and put into $data which will be used for charData
|
||||
// read offsets here from sData and put into $data which will be used for charData
|
||||
|
||||
foreach ($this->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
|
||||
$charData['VersionID'] = $sData->version[unpack('l', $data[4])[1]]; // 96 is v1.10+ - checks out
|
||||
|
||||
$charData['Filesize'] = round(unpack('l', $data[8])[1] / 1024, 2) . " KB"; // 1.41 KB (1,447 bytes) - checks out
|
||||
// $charData['Checksum'] = bin2hex($data['12']);
|
||||
@ -52,7 +46,7 @@ class D2SaveFile {
|
||||
|
||||
// $charData['Characterprogression'] = bindec($data['37']);
|
||||
|
||||
$charData['CharacterClass'] = $this->sdata->class[unpack('C', $data[40])[1]];
|
||||
$charData['CharacterClass'] = $this->sData->class[unpack('C', $data[40])[1]];
|
||||
|
||||
$charData['CharacterLevel'] = unpack('C', $data[43])[1];
|
||||
|
||||
@ -60,10 +54,10 @@ class D2SaveFile {
|
||||
|
||||
// $charData['Assignedskills'] = (unpack('i16', $data['56']));
|
||||
|
||||
$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['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]);
|
||||
|
||||
@ -83,24 +77,20 @@ class D2SaveFile {
|
||||
//$charData['Mercenaryexperience'] = $data['187'];
|
||||
|
||||
|
||||
$charData['Quests'][] = $this->getQuestData();
|
||||
$charData['Quests'][] = $this->getQuestData($file);
|
||||
|
||||
$charData['Waypoints'] = $this->getWaypointsData();
|
||||
$charData['Waypoints'] = $this->getWaypointsData($file);
|
||||
$charData['NPCIntroductions'] = $data[714];
|
||||
|
||||
$this->charData[] = $charData;
|
||||
$this->charData = $charData;
|
||||
|
||||
// ddump($charData);
|
||||
}
|
||||
|
||||
// ddump($this->charData);
|
||||
unset($this->sData);
|
||||
return $this->charData;
|
||||
}
|
||||
|
||||
public function getQuestData() {
|
||||
public function getQuestData($file) {
|
||||
|
||||
|
||||
foreach ($this->files as $f) {
|
||||
|
||||
$questsNorm = null;
|
||||
$questsNM = null;
|
||||
@ -108,19 +98,19 @@ class D2SaveFile {
|
||||
|
||||
$quests = null;
|
||||
|
||||
$filePath = $_SESSION['savePath'] . $f;
|
||||
$filePath = $_SESSION['savePath'] . $file;
|
||||
$fp = fopen($filePath, "rb+");
|
||||
|
||||
foreach ($this->sdata->qNorm as $k => $v) {
|
||||
foreach ($this->sData->qNorm as $k => $v) {
|
||||
fseek($fp, $k);
|
||||
$questsNorm[$k] = fread($fp, 2);
|
||||
}
|
||||
foreach ($this->sdata->qNM as $k => $v) {
|
||||
foreach ($this->sData->qNM as $k => $v) {
|
||||
fseek($fp, $k);
|
||||
$questsNM[$k] = fread($fp, 2);
|
||||
}
|
||||
|
||||
foreach ($this->sdata->qHell as $k => $v) {
|
||||
foreach ($this->sData->qHell as $k => $v) {
|
||||
fseek($fp, $k);
|
||||
$questsHell[$k] = fread($fp, 2);
|
||||
}
|
||||
@ -129,62 +119,90 @@ class D2SaveFile {
|
||||
foreach ($questsNorm as $k => $v) {
|
||||
$x = (str_split(strtobits($v), 8));
|
||||
//if ($x[0][0]) {
|
||||
$quests['Norm'][$this->sdata->qNorm[$k]] = $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['NM'][$this->sdata->qNM[$k]] = $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['Hell'][$this->sdata->qHell[$k]] = $x[0][0];
|
||||
$quests['Hell'][$this->sData->qHell[$k]] = $x[0][0];
|
||||
//}
|
||||
}
|
||||
|
||||
return $quests;
|
||||
}
|
||||
}
|
||||
|
||||
public function getWaypointsData() {
|
||||
public function getWaypointsData($file) {
|
||||
|
||||
foreach ($this->files as $f) {
|
||||
$filePath = $_SESSION['savePath'] . $f;
|
||||
$filePath = $_SESSION['savePath'] . $file;
|
||||
$fp = fopen($filePath, "rb+");
|
||||
|
||||
$wp = null;
|
||||
|
||||
fseek($fp, $this->sdata->wpOffsetsNorm);
|
||||
$wp['Norm'] = (strtobits(fread($fp, 5)));
|
||||
fseek($fp, $this->sData->wpOffsetsNorm);
|
||||
$a1 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNorm + 1);
|
||||
$a2 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNorm + 2);
|
||||
$a3 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNorm + 3);
|
||||
$a4 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNorm + 4);
|
||||
$a5 = strrev(strtobits(fread($fp, 1)));
|
||||
|
||||
fseek($fp, $this->sdata->wpOffsetsNM);
|
||||
$wp['NM'] = (strtobits(fread($fp, 5)));
|
||||
$wp['Norm'] = str_split($a1.$a2.$a3.$a4.$a5);
|
||||
|
||||
fseek($fp, $this->sdata->wpOffsetsHell);
|
||||
$wp['Hell'] = (strtobits(fread($fp, 5)));
|
||||
fseek($fp, $this->sData->wpOffsetsNM);
|
||||
$a1 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNM + 1);
|
||||
$a2 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNM + 2);
|
||||
$a3 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNM + 3);
|
||||
$a4 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsNM + 4);
|
||||
$a5 = strrev(strtobits(fread($fp, 1)));
|
||||
|
||||
// ddump($wp);
|
||||
$wp['NM'] = str_split($a1.$a2.$a3.$a4.$a5);
|
||||
|
||||
|
||||
fseek($fp, $this->sData->wpOffsetsHell);
|
||||
$a1 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsHell + 1);
|
||||
$a2 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsHell + 2);
|
||||
$a3 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsHell + 3);
|
||||
$a4 = strrev(strtobits(fread($fp, 1)));
|
||||
fseek($fp, $this->sData->wpOffsetsHell + 4);
|
||||
$a5 = strrev(strtobits(fread($fp, 1)));
|
||||
|
||||
$wp['Hell'] = str_split($a1.$a2.$a3.$a4.$a5);
|
||||
|
||||
// ddump(str_split($wp['Norm']));
|
||||
|
||||
foreach ($wp['Norm'] as $k => $v) {
|
||||
$waypoints['Norm'][$this->sdata->wpNames[$k]] = $v;
|
||||
$waypoints['Norm'][$this->sData->wpNames[$k]] = $v;
|
||||
}
|
||||
|
||||
foreach ($wp['NM'] as $k => $v) {
|
||||
$waypoints['NM'][$this->sdata->wpNames[$k]] = $v;
|
||||
$waypoints['NM'][$this->sData->wpNames[$k]] = $v;
|
||||
}
|
||||
|
||||
foreach ($wp['Hell'] as $k => $v) {
|
||||
$waypoints['Hell'][$this->sdata->wpNames[$k]] = $v;
|
||||
$waypoints['Hell'][$this->sData->wpNames[$k]] = $v;
|
||||
}
|
||||
|
||||
|
||||
//ddump($waypoints);
|
||||
// ddump($waypoints);
|
||||
|
||||
return $wp;
|
||||
}
|
||||
return $waypoints;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
$form = new Formr\Formr();
|
||||
$form = new Formr\Formr('bootstrap4');
|
||||
|
||||
/*
|
||||
|
||||
@ -42,7 +42,7 @@ $form = new Formr\Formr();
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
// dump($chars->charData);
|
||||
// ddump($charData);
|
||||
?>
|
||||
|
||||
|
||||
@ -53,24 +53,21 @@ $form = new Formr\Formr();
|
||||
<ul class="nav nav-tabs" id="CTabs" role="tablist">
|
||||
|
||||
|
||||
<?php
|
||||
$tabs = '';
|
||||
$counter = 1;
|
||||
foreach ($chars->charData as $k => $c) {
|
||||
if ($k == 0) {
|
||||
$active = "active";
|
||||
} else {
|
||||
$active = "";
|
||||
}
|
||||
<?php
|
||||
foreach ($charData as $c) {
|
||||
|
||||
$tabs = '';
|
||||
// ddump($c);
|
||||
|
||||
$tabs .= <<<EOT
|
||||
|
||||
<li class="nav-item" role="presentation">
|
||||
<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>
|
||||
<a class="nav-link btn btn-outline-danger" style="background: #ddd; border: 1px solid #888;" id="{$c->charData['CharacterName']}-tab" data-toggle="tab" href="#{$c->charData['CharacterName']}" role="tab" aria-controls="{$c->charData['CharacterName']}" aria-selected="true"><img height="64" width="" src="img/chars/{$c->charData['CharacterClass']}.gif">{$c->charData['CharacterName']}</a>
|
||||
</li>
|
||||
EOT;
|
||||
}
|
||||
echo $tabs;
|
||||
?>
|
||||
echo $tabs;
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
</ul>
|
||||
@ -80,59 +77,116 @@ echo $tabs;
|
||||
|
||||
|
||||
<div class="tab-content" id="CTabContent">
|
||||
<?php
|
||||
foreach ($c['Quests'] as $quest) {
|
||||
<?php
|
||||
foreach ($charData as $c) {
|
||||
|
||||
foreach ($c->charData['Quests'] as $quest) {
|
||||
foreach ($quest as $q) {
|
||||
foreach ($q as $k => $v) {
|
||||
$quest .= "$k = $v<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($chars->charData as $k => $c) {
|
||||
if ($k == 0) {
|
||||
$active = "active show";
|
||||
} else {
|
||||
$active = "";
|
||||
}
|
||||
|
||||
$wps = null;
|
||||
foreach ($c->charData['Waypoints'] as $waypoints) {
|
||||
foreach ($waypoints as $k => $v) {
|
||||
$wps .= "$k = $v<br>";
|
||||
}
|
||||
}
|
||||
|
||||
$option = '';
|
||||
if ($c->charData['CharacterClass'] == 'Amazon'){
|
||||
$option .= "<option value='Amazon' selected>Amazon</option>";
|
||||
} else {
|
||||
$option .= "<option value='Amazon'>Amazon</option>";
|
||||
}
|
||||
|
||||
if ($c->charData['CharacterClass'] == 'Assassin'){
|
||||
$option .= "<option value='Assassin' selected>Assassin</option>";
|
||||
} else {
|
||||
$option .= "<option value='Assassin'>Assassin</option>";
|
||||
}
|
||||
|
||||
if ($c->charData['CharacterClass'] == 'Barbarian'){
|
||||
$option .= "<option value='Barbarian' selected>Barbarian</option>";
|
||||
} else {
|
||||
$option .= "<option value='Barbarian'>Barbarian</option>";
|
||||
}
|
||||
|
||||
if ($c->charData['CharacterClass'] == 'Druid'){
|
||||
$option .= "<option value='Druid' selected>Druid</option>";
|
||||
} else {
|
||||
$option .= "<option value='Druid'>Druid</option>";
|
||||
}
|
||||
|
||||
if ($c->charData['CharacterClass'] == 'Paladin'){
|
||||
$option .= "<option value='Paladin' selected>Paladin</option>";
|
||||
} else {
|
||||
$option .= "<option value='Paladin'>Paladin</option>";
|
||||
}
|
||||
|
||||
if ($c->charData['CharacterClass'] == 'Necromancer'){
|
||||
$option .= "<option value='Necromancer' selected>Necromancer</option>";
|
||||
} else {
|
||||
$option .= "<option value='Necromancer'>Necromancer</option>";
|
||||
}
|
||||
|
||||
if ($c->charData['CharacterClass'] == 'Sorceress'){
|
||||
$option .= "<option value='Sorceress' selected>Sorceress</option>";
|
||||
} else {
|
||||
$option .= "<option value='Sorceress'>Sorceress</option>";
|
||||
}
|
||||
|
||||
$radio = '';
|
||||
if ($c->charData['Difficulty']['Norm'] == 1){
|
||||
$radio .= '<input checked type="radio" id="DifficultyNormal" name="Difficulty" value="Normal">Normal<br>';
|
||||
} else {
|
||||
$radio .= '<input type="radio" id="DifficultyNormal" name="Difficulty" value="Normal">Normal<br>';
|
||||
}
|
||||
|
||||
|
||||
if ($c->charData['Difficulty']['NM'] == 1){
|
||||
$radio .= '<input checked type="radio" id="DifficultyNM" name="Difficulty" value="NM">NM<br>';
|
||||
} else {
|
||||
$radio .= '<input type="radio" id="DifficultyNM" name="Difficulty" value="NM">NM<br>';
|
||||
}
|
||||
|
||||
|
||||
if ($c->charData['Difficulty']['Hell'] == 1){
|
||||
$radio .= '<input checked type="radio" id="DifficultyHell" name="Difficulty" value="Hell">Hell<br>';
|
||||
} else {
|
||||
$radio .= '<input type="radio" id="DifficultyHell" name="Difficulty" value="Hell">Hell<br>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// dump($c['Waypoints']);
|
||||
$tabContent .= <<<EOT
|
||||
<div style="background: white;" class="tab-pane fade $active" id="{$c['CharacterName']}" role="tabpanel" aria-labelledby="{$c['CharacterName']}-tab">
|
||||
<div style="background: white;" class="tab-pane fade" id="{$c->charData['CharacterName']}" role="tabpanel" aria-labelledby="{$c->charData['CharacterName']}-tab">
|
||||
|
||||
<h1 style="margin: 15px;">{$c['CharacterName']}</h1>
|
||||
<h1 style="margin: 15px;">{$c->charData['CharacterName']}</h1>
|
||||
|
||||
|
||||
<div class="container" style="font-size: 14px;">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<img src="/img/chars/{$c['CharacterClass']}.gif">
|
||||
<img src="/img/chars/{$c->charData['CharacterClass']}.gif">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input type="text" id="ChracterName" name="ChracterName" maxlength="16" value="{$c['CharacterName']}">
|
||||
<input type="text" id="ChracterName" name="ChracterName" maxlength="16" value="{$c->charData['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>
|
||||
$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>
|
||||
<input style="border: 1px solid black;width: 34px;" type="number" id="CharacterLevel" value="{$c->charData['CharacterLevel']}">: Char Lvl<br>
|
||||
$radio
|
||||
</div>
|
||||
<div class="col">$quest</div>
|
||||
<div class="col">Col 3</div>
|
||||
</div>
|
||||
<div class="col"><h2>Quests</h2>$quest</div>
|
||||
<div class="col"><h2>Waypoints</h2>$wps</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -141,8 +195,9 @@ foreach ($chars->charData as $k => $c) {
|
||||
|
||||
</div>
|
||||
EOT;
|
||||
}
|
||||
echo $tabContent;
|
||||
?>
|
||||
|
||||
echo $tabContent;
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user