D2S Editor Pretty much finished, seems to be working 100%

This commit is contained in:
Hash Borgir
2023-06-03 23:38:00 -06:00
parent dc7e046077
commit ad2e7c2c0b
6 changed files with 397 additions and 268 deletions

View File

@@ -177,13 +177,19 @@ WHERE sk.charclass = '$class'";
if ($cData['CharacterStatus'] == 'Hardcore Expansion') {
$cData['CharacterProgression'] = $this->sData->characterProgressionExpHC[$progression];
}
if ($cData['CharacterStatus'] == "Expansion") {
if (str_contains($cData['CharacterStatus'], "Expansion")) {
$cData['CharacterProgression'] = $this->sData->characterProgressionExp[$progression];
$cData['CharacterStatusExpansion'] = 1;
}
if ($cData['CharacterStatus'] == "Hardcore") {
if (str_contains($cData['CharacterStatus'], "Hardcore")) {
$cData['CharacterProgression'] = $this->sData->characterProgressionClassicHC[$progression];
$cData['CharacterStatusHardcore'] = 1;
}
if (str_contains($cData['CharacterStatus'], "Died")) {
$cData['CharacterProgression'] = $this->sData->characterProgressionClassicHC[$progression];
$cData['CharacterStatusDied'] = 1;
}
$cData['CharacterClass'] = $this->sData->class[unpack('C', $this->bData[40])[1]];
$cData['CharacterLevel'] = unpack('C', $this->bData[43])[1];
$cData['Lastplayed'] = gmdate("Y-m-d\TH:i:s\Z", unpack('L', $this->bData[48])[0]);
@@ -319,24 +325,53 @@ WHERE sk.charclass = '$class'";
$len = $if - $gf;
$stats = new D2BitReader($this->ByteReader->toBits($this->ByteReader->readh($gf, $len)));
$bits = $stats->getBits();
$bits = $stats->getBits();
$bytes = $this->ByteReader->toBytes($bits);
// var_dump($bits);
// // Split the bits into 8-bit pieces
// var_dump(str_split($bits, 8));
/*
* CSvBits for Example, how many bits they store
Stat ID CSvBits
strength 0 10
energy 1 10
dexterity 2 10
vitality 3 10
statpts 4 10
newskills 5 8
hitpoints 6 21
maxhp 7 21
mana 8 21
maxmana 9 21
stamina 10 21
maxstamina 11 21
level 12 7
experience 13 32
gold 14 25
goldbank 15 25
*/
$stats->rewind();
$ids = []; // Array to store the encountered stat IDs
// Iterate over the stats and collect their IDs
for ($i = 0; $i <= count($this->ISC); $i++) {
$id = hexdec($this->ByteReader->toBytesR($stats->readb(9)));
// Skip the bits corresponding to the stat if needed
//var_dump("Offset Before Starting: " . $stats->getOffset());
$id = hexdec($this->ByteReader->toBytesR($stats->readb(9))); // read 9 bits for stat id
//var_dump("$id Stat Done: ". $stats->getOffset());
// if ISC saves the stat, meaning CSVBits is set, it means it saves that my bits for this stat
// then we can skip that many number of bits, so we can get the next stat id
if ($this->ISC[$id]['CSvBits'] !== NULL && $this->ISC[$id]['CSvBits'] !== '') {
$stats->skip($this->ISC[$id]['CSvBits']);
$stats->skip($this->ISC[$id]['CSvBits']);
//var_dump("Offset After Skipping Bits for $id: ". $stats->getOffset());
}
$ids[$id] = $id; // Store the ID in the array
}
//ddump($ids);
$stats->rewind();
$values = []; // Array to store the parsed stat values
@@ -351,6 +386,9 @@ WHERE sk.charclass = '$class'";
$values[$stat] = hexdec($this->ByteReader->toBytesR($val));
}
}
//ddump($values);
// Perform additional calculations or conversions on specific stats
$values['hitpoints'] = (int) round($values['hitpoints'] >> 11);

View File

@@ -182,33 +182,33 @@ class D2CharStructureData {
*/
public $qNorm = [
//345 => 'introWarriv',
347 => 'Den_Of_Evil',
349 => 'Sisters_Burial_Grounds',
351 => 'Tools_Of_The_Trade',
353 => 'The_Search_For_Cain',
355 => 'The_Forgotten_Tower',
357 => 'Sisters_To_The_Slaughter',
347 => 'Act 1 - Den_Of_Evil',
349 => 'Act 1 - Sisters_Burial_Grounds',
351 => 'Act 1 - Tools_Of_The_Trade',
353 => 'Act 1 - The_Search_For_Cain',
355 => 'Act 1 - The_Forgotten_Tower',
357 => 'Act 1 - Sisters_To_The_Slaughter',
//359 => 'traveledToAct2',
//361 => 'introJerhyn',
363 => 'Radaments_Lair',
365 => 'TheHoradric_Staff',
367 => 'Tainted_Sun',
369 => 'Arcane_Sanctuary',
371 => 'The_Summoner',
373 => 'The_Seven_Tombs',
363 => 'Act 2 - Radaments_Lair',
365 => 'Act 2 - TheHoradric_Staff',
367 => 'Act 2 - Tainted_Sun',
369 => 'Act 2 - Arcane_Sanctuary',
371 => 'Act 2 - The_Summoner',
373 => 'Act 2 - The_Seven_Tombs',
//375 => 'traveledToAct3',
//377 => 'introHratli',
379 => 'LamEsens_Tome',
381 => 'Khalims_Will',
383 => 'Blade_Of_The_Old_Religion',
385 => 'The_Golden_Bird',
387 => 'The_Blackened_Temple',
389 => 'The_Guardian',
379 => 'Act 3 - LamEsens_Tome',
381 => 'Act 3 - Khalims_Will',
383 => 'Act 3 - Blade_Of_The_Old_Religion',
385 => 'Act 3 - The_Golden_Bird',
387 => 'Act 3 - The_Blackened_Temple',
389 => 'Act 3 - The_Guardian',
//391 => 'traveledtoAct4',
//393 => 'introToAct4',
395 => 'The_Fallen_Angel',
397 => 'Terrors_End',
399 => 'Hell_Forge',
395 => 'Act 4 - The_Fallen_Angel',
397 => 'Act 4 - Terrors_End',
399 => 'Act 4 - Hell_Forge',
//401 => 'traveledToAct5',
//403 => 'empty31',
//405 => 'empty32',
@@ -216,12 +216,12 @@ class D2CharStructureData {
//409 => 'completedTerrorsEnd',
//411 => 'empty21',
//413 => 'empty22',
415 => 'Siege_On_Harrogath',
417 => 'Rescue_On_MountArreat',
419 => 'Prison_Of_Ice',
421 => 'Betrayal_Of_Harrogath',
423 => 'Rite_Of_Passage',
425 => 'Eve_Of_Destruction',
415 => 'Act 5 - Siege_On_Harrogath',
417 => 'Act 5 - Rescue_On_MountArreat',
419 => 'Act 5 - Prison_Of_Ice',
421 => 'Act 5 - Betrayal_Of_Harrogath',
423 => 'Act 5 - Rite_Of_Passage',
425 => 'Act 5 - Eve_Of_Destruction',
// read 425, pointer at 427, + 14 = 441 qNM offset
];
@@ -230,33 +230,33 @@ class D2CharStructureData {
*/
public $qNM = [
//441 => 'introWarrivNM',
443 => 'Den_Of_Evil_NM',
445 => 'Sisters_Burial_Grounds_NM',
447 => 'Tools_Of_The_Trade_NM',
449 => 'The_Search_For_Cain_NM',
451 => 'The_Forgotten_Tower_NM',
453 => 'Sisters_To_The_Slaughter_NM',
443 => 'Act 1 - Den_Of_Evil_NM',
445 => 'Act 1 - Sisters_Burial_Grounds_NM',
447 => 'Act 1 - Tools_Of_The_Trade_NM',
449 => 'Act 1 - The_Search_For_Cain_NM',
451 => 'Act 1 - The_Forgotten_Tower_NM',
453 => 'Act 1 - Sisters_To_The_Slaughter_NM',
//455 => 'traveledToAct2',
//457 => 'introJerhyn',
459 => 'Radaments_Lair_NM',
461 => 'The_Horadric_Staff_NM',
463 => 'Tainted_Sun_NM',
465 => 'Arcane_Sanctuary_NM',
467 => 'The_Summoner_NM',
469 => 'The_SevenTombs_NM',
459 => 'Act 2 - Radaments_Lair_NM',
461 => 'Act 2 - The_Horadric_Staff_NM',
463 => 'Act 2 - Tainted_Sun_NM',
465 => 'Act 2 - Arcane_Sanctuary_NM',
467 => 'Act 2 - The_Summoner_NM',
469 => 'Act 2 - The_SevenTombs_NM',
//471 => 'traveledToAct3',
//473 => 'introHratli',
475 => 'Lam_Esens_Tome_NM',
477 => 'Khalims_Will_NM',
479 => 'Blade_Of_The_OldReligion_NM',
481 => 'The_Golden_Bird_NM',
483 => 'The_Blackened_Temple_NM',
485 => 'The_Guardian_NM',
475 => 'Act 3 - Lam_Esens_Tome_NM',
477 => 'Act 3 - Khalims_Will_NM',
479 => 'Act 3 - Blade_Of_The_OldReligion_NM',
481 => 'Act 3 - The_Golden_Bird_NM',
483 => 'Act 3 - The_Blackened_Temple_NM',
485 => 'Act 3 - The_Guardian_NM',
//487 => 'traveledtoAct4',
//489 => 'introToAct4',
491 => 'The_Fallen_Angel_NM',
493 => 'Terrors_End_NM',
495 => 'Hell_Forge_NM',
491 => 'Act 4 - The_Fallen_Angel_NM',
493 => 'Act 4 - Terrors_End_NM',
495 => 'Act 4 - Hell_Forge_NM',
//497 => 'traveledToAct5',
//499 => 'empty31',
//501 => 'empty32',
@@ -264,12 +264,12 @@ class D2CharStructureData {
//505 => 'completedTerrorsEnd',
//507 => 'empty21',
//509 => 'empty22',
511 => 'Siege_On_Harrogath',
513 => 'Rescue_On_MountArreat',
515 => 'Prison_Of_Ice',
517 => 'Betrayal_Of_Harrogath',
519 => 'Rite_Of_Passage',
521 => 'Eve_Of_Destruction',
511 => 'Act 5 - Siege_On_Harrogath',
513 => 'Act 5 - Rescue_On_MountArreat',
515 => 'Act 5 - Prison_Of_Ice',
517 => 'Act 5 - Betrayal_Of_Harrogath',
519 => 'Act 5 - Rite_Of_Passage',
521 => 'Act 5 - Eve_Of_Destruction',
// read 521, pointer at 523, + 14 = 537 qHell offset
];
@@ -278,46 +278,46 @@ class D2CharStructureData {
*/
public $qHell = [
//537 => 'introWarriv',
539 => 'Den_Of_Evil_Hell',
541 => 'Sisters_Burial_Grounds_Hell',
543 => 'Tools_Of_The_Trade_Hell',
545 => 'The_Search_For_Cain_Hell',
547 => 'The_Forgotten_Tower_Hell',
549 => 'Sisters_To_The_Slaughter_Hell',
539 => 'Act 1 - Den_Of_Evil_Hell',
541 => 'Act 1 - Sisters_Burial_Grounds_Hell',
543 => 'Act 1 - Act 5 - Tools_Of_The_Trade_Hell',
545 => 'Act 1 - The_Search_For_Cain_Hell',
547 => 'Act 1 - The_Forgotten_Tower_Hell',
549 => 'Act 1 - Sisters_To_The_Slaughter_Hell',
//551 => 'traveledToAct2',
//553 => 'introJerhyn',
555 => 'Radaments_Lair_Hell',
557 => 'The_Horadric_Staff_Hell',
559 => 'Tainted_Sun_Hell',
561 => 'Arcane_Sanctuary_Hell',
563 => 'The_Summoner_Hell',
565 => 'The_SevenTombs_Hell',
555 => 'Act 2 - Radaments_Lair_Hell',
557 => 'Act 2 - The_Horadric_Staff_Hell',
559 => 'Act 2 - Tainted_Sun_Hell',
561 => 'Act 2 - Arcane_Sanctuary_Hell',
563 => 'Act 2 - The_Summoner_Hell',
565 => 'Act 2 - The_SevenTombs_Hell',
//567 => 'traveledToAct3',
//569 => 'introHratli',
571 => 'Lam_Esens_Tome_Hell',
573 => 'KhalimsWill_Hell',
575 => 'Blade_Of_The_Old_Religion_Hell',
577 => 'The_Golden_Bird_Hell',
579 => 'The_Blackened_Temple_Hell',
581 => 'The_Guardian_Hell',
571 => 'Act 3 - Lam_Esens_Tome_Hell',
573 => 'Act 3 - KhalimsWill_Hell',
575 => 'Act 3 - Blade_Of_The_Old_Religion_Hell',
577 => 'Act 3 - The_Golden_Bird_Hell',
579 => 'Act 3 - The_Blackened_Temple_Hell',
581 => 'Act 3 - The_Guardian_Hell',
//583 => 'traveledtoAct4',
//585 => 'introToAct4',
587 => 'The_Fallen_Angel_Hell',
589 => 'Terrors_End_Hell',
591 => 'Hell_Forge_Hell',
587 => 'Act 4 - The_Fallen_Angel_Hell',
589 => 'Act 4 - Terrors_End_Hell',
591 => 'Act 4 - Hell_Forge_Hell',
//593 => 'traveledToAct5',
//595 => 'empty31',
//597 => 'empty32',
//599 => 'empty33',
601 => 'completedTerrorsEnd',
//601 => 'completedTerrorsEnd',
//603 => 'empty21',
//605 => 'empty22',
607 => 'Siege_On_Harrogath',
609 => 'Rescue_On_MountArreat',
611 => 'Prison_Of_Ice',
613 => 'Betrayal_Of_Harrogath',
615 => 'Rite_Of_Passage',
617 => 'Eve_Of_Destruction',
607 => 'Act 5 - Siege_On_Harrogath',
609 => 'Act 5 - Rescue_On_MountArreat',
611 => 'Act 5 - Prison_Of_Ice',
613 => 'Act 5 - Betrayal_Of_Harrogath',
615 => 'Act 5 - Rite_Of_Passage',
617 => 'Act 5 - Eve_Of_Destruction',
];
/**

View File

@@ -25,15 +25,15 @@ EOT;
$quests = '';
foreach ($c->cData['Quests'] as $quest) {
foreach ($quest as $difficulty => $q) {
$quests .= "<h2>$difficulty</h2>";
$quests .= "<h2 style='text-align: center'>$difficulty</h2>";
foreach ($q as $k => $v) {
$kD = str_replace("_", " ", $k);
$kD = str_replace([" NM", " Hell"], "", $kD);
$checked = ($v == 1) ? 'checked' : '';
$quests .= "<input class='qcheck' diff='$difficulty' type='checkbox' value='1' name='$k' id='$k' $checked>";
$quests .= "<label for='$k'>$kD</label><br>";
$quests .= "<div class='qcheckgroup' ><input class='qcheck' diff='$difficulty' type='checkbox' value='1' name='$k' id='$k' $checked>";
$quests .= "<label for='$k'>$kD</label><br></div>";
}
}
}
@@ -45,7 +45,7 @@ EOT;
//$wps .= "<label style='font-size: 1.3em; color: red;' for='wp_all_off'>Disable All Waypoints</label><hr>";
foreach ($c->cData['Waypoints'] as $diff => $waypoints) { // diff is difficulty
$wps .= "<h2>$diff</h2>";
$wps .= "<h2 style='text-align: center'>$diff</h2>";
array_pop($waypoints);
$wp_count = 0;
foreach ($waypoints as $k => $v) {
@@ -54,8 +54,8 @@ EOT;
$kD = str_replace([" NM", " Hell"], "", $kD);
$checked = ($v == 1 && $k != '') ? 'checked ' : '';
$wps .= "<input diff='$diff' class='wpcheck' type='checkbox' value='1' name='$wp_count' id='$k' $checked>";
$wps .= "<label for='$k'>$kD</label><br>";
$wps .= "<div class='wcheckgroup' ><input diff='$diff' class='wpcheck' type='checkbox' value='1' name='$wp_count' id='$k' $checked>";
$wps .= "<label for='$k'>$kD</label><br></div>";
$wp_count++;
}
}
@@ -71,34 +71,35 @@ EOT;
}
$difficulties = [
'Normal' => '1',
'NM' => '2',
'Hell' => '3'
'Normal' => '0',
'Finished Normal' => '1',
'Finished Nightmare' => '2',
'Finished Hell' => '3'
];
$radio = '';
foreach ($difficulties as $difficulty => $id) {
$checked = ($c->cData['Difficulty'][$difficulty] == 1) ? 'checked' : '';
$radio .= "<input $checked type='radio' id='$difficulty' name='Difficulty' value='$difficulty'>";
$radio .= "<input $checked type='radio' id='$difficulty' name='Difficulty' value='$id'>";
$radio .= "<label for='$difficulty'>$difficulty</label><br>";
}
$skills = '';
/*
'skills' =>
array (size=1)
'skills' =>
array (size=52)
0 =>
array (size=7)
'id' => int 36
'skill' => string 'Fire Bolt' (length=9)
'points' => int 0
'page' => int 3
'row' => int 1
'col' => int 2
'icon' => int 0
/*
'skills' =>
array (size=1)
'skills' =>
array (size=52)
0 =>
array (size=7)
'id' => int 36
'skill' => string 'Fire Bolt' (length=9)
'points' => int 0
'page' => int 3
'row' => int 1
'col' => int 2
'icon' => int 0
*/
$skillcounter = 1;
foreach ($c->cData['skills']['skills'] as $k => $skill) {
@@ -106,6 +107,29 @@ EOT;
$skillcounter++;
}
// ddump($c->cData['CharacterStatusDied']);
$statuses = [
'Died' => 'CharacterStatusDied',
'Expansion' => 'CharacterStatusExpansion',
'Hardcore' => 'CharacterStatusHardcore',
];
$checkboxes = '';
foreach ($statuses as $status => $dataKey) {
$checked = $c->cData[$dataKey] ? 'checked' : '';
$checkboxes .= <<<HTML
<div class="col">
<div class="form-check">
<label class="form-check-label" for="{$status}">{$status}: </label><br>
<input class="form-check-input" {$checked} type="checkbox" id="{$status}" name="CharacterStatus[{$status}]" value="{$c->cData[$dataKey]}">
</div>
</div>
HTML;
}
$tabContent .= <<<EOT
<div style="background: white; margin-top: 10px;" class="tab-pane fade" id="{$c->cData['CharacterName']}" role="tabpanel" aria-labelledby="{$c->cData['CharacterName']}-tab">
<form id='{$c->cData['CharacterName']}' class="charform {$c->cData['CharacterName']}" method="POST" action="/saveCharacter.php">
@@ -122,10 +146,23 @@ EOT;
</select><br>
Character Level: <input style="border: 1px solid black;width: 54px;" type="number" name="CharacterLevel" id="CharacterLevel" value="{$c->cData['CharacterLevel']}">
<hr>
<div style="background: #efe;">
Difficulty:<br>
$radio
</div>
<hr>
<!--Character Status -->
<div class="form-row">
$checkboxes
<br><br>
</div>
<hr>
<!-- STATS -->
<div class="stats">
<div class="form-row">
<div class="form-row" style="background: #eed;">
<div class="form-group col-md-3">
<label for="strength">Strength:</label>
<input type="number" class="form-control" id="strength" name="strength" min="1" max="255" value="{$c->cData['stats']['strength']}" required>
@@ -144,7 +181,7 @@ EOT;
</div>
</div>
<div class="form-row">
<div class="form-row" style="background: #eee;">
<div class="form-group col-md-3">
<label for="hitpoints">Hitpoints:</label>
<input type="number" class="form-control" id="hitpoints" name="hitpoints" min="1" max="255" value="{$c->cData['stats']['hitpoints']}" required>
@@ -163,7 +200,7 @@ EOT;
</div>
</div>
<div class="form-row">
<div class="form-row" style="background: #eed;">
<div class="form-group col-md-6">
<label for="stamina">Stamina:</label>
<input type="number" class="form-control" id="stamina" name="stamina" min="1" max="255" value="{$c->cData['stats']['stamina']}" required>
@@ -172,22 +209,20 @@ EOT;
<label for="maxstamina">Max Stamina:</label>
<input type="number" class="form-control" id="maxstamina" name="maxstamina" min="1" max="255" value="{$c->cData['stats']['maxstamina']}" required>
</div>
</div>
</div>
</div>
<hr>
<!--Difficulty:<br>
$radio-->
<div>
<h3>Skills</h3>
<div style="background:;">
<h3 style="text-align: center">Skills</h3>
$skills
</div>
</div>
<div class="col">
<h3>Quests</h3>
<h3 style="text-align: center">Quests</h3>
$quests
</div>
<div class="col">
<h3>Waypoints</h3>
<h3 style="text-align: center">Waypoints</h3>
$wps
</div>
</div>