mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 12:36:03 +00:00
AJAX waypoint/quest enable/disable working
This commit is contained in:
parent
b9f4054028
commit
ce83c42701
22
res/app.js
22
res/app.js
@ -352,7 +352,29 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".qcheck").change(function () {
|
||||||
|
// Toggle the value between 0 and 1
|
||||||
|
var value = $(this).is(":checked") ? 1 : 0;
|
||||||
|
|
||||||
|
// Get the name of the checkbox
|
||||||
|
var name = $(this).attr("name");
|
||||||
|
|
||||||
|
// Get the name of the difficulty
|
||||||
|
var diff = $(this).attr("diff");
|
||||||
|
|
||||||
|
// Get the value of the input named "filePath"
|
||||||
|
var filePath = $("input[name='filePath']").val();
|
||||||
|
|
||||||
|
// Construct the URL for the GET request
|
||||||
|
var url = "/saveCharacter.php?cmd=q&name=" + name + "&value=" + value + "&filePath=" + filePath + "&diff=" + diff;
|
||||||
|
|
||||||
|
|
||||||
|
// Send the GET request
|
||||||
|
$.get(url, function (response) {
|
||||||
|
// Handle the response if needed
|
||||||
|
console.log(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});// end document.ready
|
});// end document.ready
|
@ -72,8 +72,6 @@ if ($cmd == "wp") {
|
|||||||
'diff' => string 'Norm' (length=4)
|
'diff' => string 'Norm' (length=4)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$fileContents = file_get_contents($filePath); // Read the contents of the file
|
$fileContents = file_get_contents($filePath); // Read the contents of the file
|
||||||
$ByteReader = new D2ByteReader($fileContents); // Create a new instance of D2ByteReader with the file data
|
$ByteReader = new D2ByteReader($fileContents); // Create a new instance of D2ByteReader with the file data
|
||||||
$fileData = $ByteReader->getData(); // Get the data from the ByteReader instance
|
$fileData = $ByteReader->getData(); // Get the data from the ByteReader instance
|
||||||
@ -82,15 +80,12 @@ if ($cmd == "wp") {
|
|||||||
$wpBytesToBits = $ByteReader->toBits($wpBytes);
|
$wpBytesToBits = $ByteReader->toBits($wpBytes);
|
||||||
|
|
||||||
$BitReader = new D2BitReader($wpBytesToBits);
|
$BitReader = new D2BitReader($wpBytesToBits);
|
||||||
|
|
||||||
$BitReader->setBit($g['name'], $g['value']);
|
$BitReader->setBit($g['name'], $g['value']);
|
||||||
|
|
||||||
$newBits = $BitReader->getBits();
|
$newBits = $BitReader->getBits();
|
||||||
|
|
||||||
$newBitsToBytes = $ByteReader->bitsToHexString($newBits);
|
$newBitsToBytes = $ByteReader->bitsToHexString($newBits);
|
||||||
|
|
||||||
$ByteReader->writeBytes($offset, $newBitsToBytes);
|
$ByteReader->writeBytes($offset, $newBitsToBytes);
|
||||||
|
|
||||||
$newFileData = $ByteReader->getData();
|
$newFileData = $ByteReader->getData();
|
||||||
$fileSaved = file_put_contents($filePath, $newFileData);
|
$fileSaved = file_put_contents($filePath, $newFileData);
|
||||||
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
||||||
@ -100,101 +95,82 @@ if ($cmd == "wp") {
|
|||||||
} else {
|
} else {
|
||||||
echo "Fail";
|
echo "Fail";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* array (size=5)
|
||||||
|
'cmd' => string 'q' (length=1)
|
||||||
|
'name' => string 'Sisters_Burial_Grounds' (length=29)
|
||||||
|
'value' => string '1' (length=1)
|
||||||
|
'filePath' => string 'D:\\Diablo II\\MODS\\ironman-dev\\save\\Sorc.d2s' (length=48)
|
||||||
|
'diff' => string 'Norm' (length=4)
|
||||||
|
|
||||||
|
At each quest offset, read a short, 2 bytes.
|
||||||
|
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',
|
||||||
|
|
||||||
|
Each short is 16 bytes.
|
||||||
|
*
|
||||||
|
* 0xFEFF = 11111110 11111111
|
||||||
|
* Short #0 Den of Evil Bit 4 is set when you enter the Den.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($cmd == "q") {
|
||||||
|
$diff = $g['diff'];
|
||||||
|
if ($diff == "Norm") {
|
||||||
|
$qArray = array_flip($csData->qNorm);
|
||||||
|
$questOffset = $qArray[$g['name']];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($diff == "NM") {
|
||||||
|
$qArray = array_flip($csData->qNM);
|
||||||
|
$questOffset = $qArray[$g['name']];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($diff == "Hell") {
|
||||||
|
$qArray = array_flip($csData->qHell);
|
||||||
|
$questOffset = $qArray[$g['name']];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the file in binary mode for both reading and writing
|
||||||
|
$fp = fopen($filePath, "rb+");
|
||||||
|
|
||||||
|
if ($g['value']) {
|
||||||
|
// Set the file pointer position to the quest offset
|
||||||
|
fseek($fp, $questOffset);
|
||||||
|
|
||||||
|
// Write the byte value 0xFE at the current position
|
||||||
|
fwrite($fp, pack('C', 0xFE));
|
||||||
|
|
||||||
|
// Move the file pointer to the next position
|
||||||
|
fseek($fp, $questOffset + 1);
|
||||||
|
|
||||||
|
// Write the byte value 0xFF at the current position
|
||||||
|
fwrite($fp, pack('C', 0xFF));
|
||||||
|
|
||||||
|
echo "Quest Just Finished, Collect Reward!";
|
||||||
|
} else {
|
||||||
|
// Set the file pointer position to the quest offset
|
||||||
|
fseek($fp, $questOffset);
|
||||||
|
|
||||||
|
// Write the byte value 0xFE at the current position
|
||||||
|
fwrite($fp, pack('C', 0x00));
|
||||||
|
|
||||||
|
// Move the file pointer to the next position
|
||||||
|
fseek($fp, $questOffset + 1);
|
||||||
|
|
||||||
|
// Write the byte value 0xFF at the current position
|
||||||
|
fwrite($fp, pack('C', 0x00));
|
||||||
|
|
||||||
|
echo "Quest Not Started Yet!";
|
||||||
|
}
|
||||||
|
|
||||||
|
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
die();
|
|
||||||
|
|
||||||
// Get the POST data
|
|
||||||
$p = $_GET;
|
|
||||||
|
|
||||||
// Loop through each 'quest' element in the POST data and assign the corresponding value from 'dStruct->_qNorm' to 'q'
|
|
||||||
foreach ($p['quest'] as $k => $v) {
|
|
||||||
$q[$k] = $dStruct->_qNorm[$k];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$wpNames_flipped = array_values($dStruct->wpNames_flipped);
|
|
||||||
|
|
||||||
// Loop through each 'wp' element in the POST data and assign the corresponding value from 'dStruct->_qNorm' to 'w'
|
|
||||||
foreach ($p['wp'] as $k => $v) {
|
|
||||||
$w[$k] = $dStruct->_qNorm[$k];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the file path from the POST data and replace backslashes /
|
|
||||||
$filePath = $p['filePath'];
|
|
||||||
$filePath = str_replace("\\", "\\\\", $filePath);
|
|
||||||
|
|
||||||
// Open the file in binary mode for both reading and writing
|
|
||||||
$fp = fopen($filePath, "rb+");
|
|
||||||
|
|
||||||
// Edit quests which are checked to set them as 'Just finished' (FE FF)
|
|
||||||
foreach ($q as $k => $v) {
|
|
||||||
// Set the file pointer position to the quest offset
|
|
||||||
fseek($fp, $v);
|
|
||||||
|
|
||||||
// Write the byte value 0xFE at the current position
|
|
||||||
fwrite($fp, pack('C', 0xFE));
|
|
||||||
|
|
||||||
// Move the file pointer to the next position
|
|
||||||
fseek($fp, $v + 1);
|
|
||||||
|
|
||||||
// Write the byte value 0xFF at the current position
|
|
||||||
fwrite($fp, pack('C', 0xFF));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Array containing the fseek wp offsets
|
|
||||||
// 5 acts per difficulty
|
|
||||||
// starts at 641, but we skip two bytes, go to 643, then read next 5 bytes, each byte is a bitfield per act.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$offsets = [
|
|
||||||
643, 644, 645, 646, 647, // First set of offsets Norm
|
|
||||||
667, 668, 669, 670, 671, // Second set of offsets NM
|
|
||||||
691, 692, 693, 694, 695 // Third set of offsets Hell
|
|
||||||
];
|
|
||||||
|
|
||||||
// Determine the value to write based on the condition $p['wp_all'] == "1"
|
|
||||||
$valueToWrite = ($p['wp_all'] == "1") ? 0xFF : 0x00;
|
|
||||||
|
|
||||||
// Loop over each offset in the $offsets array
|
|
||||||
foreach ($offsets as $offset) {
|
|
||||||
// Set the file pointer position to the current offset
|
|
||||||
fseek($fp, $offset);
|
|
||||||
|
|
||||||
// Write the value specified by pack('C', $valueToWrite)
|
|
||||||
fwrite($fp, pack('C', $valueToWrite));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
header('Location: /');
|
|
||||||
|
@ -181,39 +181,39 @@ class D2CharStructureData {
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $qNorm = [
|
public $qNorm = [
|
||||||
345 => 'introWarriv',
|
//345 => 'introWarriv',
|
||||||
347 => 'Den_Of_Evil',
|
347 => 'Den_Of_Evil',
|
||||||
349 => 'Sisters_Burial_Grounds',
|
349 => 'Sisters_Burial_Grounds',
|
||||||
351 => 'Tools_Of_The_Trade',
|
351 => 'Tools_Of_The_Trade',
|
||||||
353 => 'The_Search_For_Cain',
|
353 => 'The_Search_For_Cain',
|
||||||
355 => 'The_Forgotten_Tower',
|
355 => 'The_Forgotten_Tower',
|
||||||
357 => 'Sisters_To_The_Slaughter',
|
357 => 'Sisters_To_The_Slaughter',
|
||||||
359 => 'traveledToAct2',
|
//359 => 'traveledToAct2',
|
||||||
361 => 'introJerhyn',
|
//361 => 'introJerhyn',
|
||||||
363 => 'Radaments_Lair',
|
363 => 'Radaments_Lair',
|
||||||
365 => 'TheHoradric_Staff',
|
365 => 'TheHoradric_Staff',
|
||||||
367 => 'Tainted_Sun',
|
367 => 'Tainted_Sun',
|
||||||
369 => 'Arcane_Sanctuary',
|
369 => 'Arcane_Sanctuary',
|
||||||
371 => 'The_Summoner',
|
371 => 'The_Summoner',
|
||||||
373 => 'The_Seven_Tombs',
|
373 => 'The_Seven_Tombs',
|
||||||
375 => 'traveledToAct3',
|
//375 => 'traveledToAct3',
|
||||||
377 => 'introHratli',
|
//377 => 'introHratli',
|
||||||
379 => 'LamEsens_Tome',
|
379 => 'LamEsens_Tome',
|
||||||
381 => 'Khalims_Will',
|
381 => 'Khalims_Will',
|
||||||
383 => 'Blade_Of_The_Old_Religion',
|
383 => 'Blade_Of_The_Old_Religion',
|
||||||
385 => 'The_Golden_Bird',
|
385 => 'The_Golden_Bird',
|
||||||
387 => 'The_Blackened_Temple',
|
387 => 'The_Blackened_Temple',
|
||||||
389 => 'The_Guardian',
|
389 => 'The_Guardian',
|
||||||
391 => 'traveledtoAct4',
|
//391 => 'traveledtoAct4',
|
||||||
393 => 'introToAct4',
|
//393 => 'introToAct4',
|
||||||
395 => 'The_Fallen_Angel',
|
395 => 'The_Fallen_Angel',
|
||||||
397 => 'Terrors_End',
|
397 => 'Terrors_End',
|
||||||
399 => 'Hell_Forge',
|
399 => 'Hell_Forge',
|
||||||
401 => 'traveledToAct5',
|
//401 => 'traveledToAct5',
|
||||||
//403 => 'empty31',
|
//403 => 'empty31',
|
||||||
//405 => 'empty32',
|
//405 => 'empty32',
|
||||||
//407 => 'empty33',
|
//407 => 'empty33',
|
||||||
409 => 'completedTerrorsEnd',
|
//409 => 'completedTerrorsEnd',
|
||||||
//411 => 'empty21',
|
//411 => 'empty21',
|
||||||
//413 => 'empty22',
|
//413 => 'empty22',
|
||||||
415 => 'Siege_On_Harrogath',
|
415 => 'Siege_On_Harrogath',
|
||||||
@ -229,39 +229,39 @@ class D2CharStructureData {
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $qNM = [
|
public $qNM = [
|
||||||
441 => 'introWarrivNM',
|
//441 => 'introWarrivNM',
|
||||||
443 => 'Den_Of_Evil_NM',
|
443 => 'Den_Of_Evil_NM',
|
||||||
445 => 'Sisters_Burial_Grounds_NM',
|
445 => 'Sisters_Burial_Grounds_NM',
|
||||||
447 => 'Tools_Of_The_Trade_NM',
|
447 => 'Tools_Of_The_Trade_NM',
|
||||||
449 => 'The_Search_For_Cain_NM',
|
449 => 'The_Search_For_Cain_NM',
|
||||||
451 => 'The_Forgotten_Tower_NM',
|
451 => 'The_Forgotten_Tower_NM',
|
||||||
453 => 'Sisters_To_The_Slaughter_NM',
|
453 => 'Sisters_To_The_Slaughter_NM',
|
||||||
455 => 'traveledToAct2',
|
//455 => 'traveledToAct2',
|
||||||
457 => 'introJerhyn',
|
//457 => 'introJerhyn',
|
||||||
459 => 'Radaments_Lair_NM',
|
459 => 'Radaments_Lair_NM',
|
||||||
461 => 'The_Horadric_Staff_NM',
|
461 => 'The_Horadric_Staff_NM',
|
||||||
463 => 'Tainted_Sun_NM',
|
463 => 'Tainted_Sun_NM',
|
||||||
465 => 'Arcane_Sanctuary_NM',
|
465 => 'Arcane_Sanctuary_NM',
|
||||||
467 => 'The_Summoner_NM',
|
467 => 'The_Summoner_NM',
|
||||||
469 => 'The_SevenTombs_NM',
|
469 => 'The_SevenTombs_NM',
|
||||||
471 => 'traveledToAct3',
|
//471 => 'traveledToAct3',
|
||||||
473 => 'introHratli',
|
//473 => 'introHratli',
|
||||||
475 => 'Lam_Esens_Tome_NM',
|
475 => 'Lam_Esens_Tome_NM',
|
||||||
477 => 'Khalims_Will_NM',
|
477 => 'Khalims_Will_NM',
|
||||||
479 => 'Blade_Of_The_OldReligion_NM',
|
479 => 'Blade_Of_The_OldReligion_NM',
|
||||||
481 => 'The_Golden_Bird_NM',
|
481 => 'The_Golden_Bird_NM',
|
||||||
483 => 'The_Blackened_Temple_NM',
|
483 => 'The_Blackened_Temple_NM',
|
||||||
485 => 'The_Guardian_NM',
|
485 => 'The_Guardian_NM',
|
||||||
487 => 'traveledtoAct4',
|
//487 => 'traveledtoAct4',
|
||||||
489 => 'introToAct4',
|
//489 => 'introToAct4',
|
||||||
491 => 'The_Fallen_Angel_NM',
|
491 => 'The_Fallen_Angel_NM',
|
||||||
493 => 'Terrors_End_NM',
|
493 => 'Terrors_End_NM',
|
||||||
495 => 'Hell_Forge_NM',
|
495 => 'Hell_Forge_NM',
|
||||||
497 => 'traveledToAct5',
|
//497 => 'traveledToAct5',
|
||||||
//499 => 'empty31',
|
//499 => 'empty31',
|
||||||
//501 => 'empty32',
|
//501 => 'empty32',
|
||||||
//503 => 'empty33',
|
//503 => 'empty33',
|
||||||
505 => 'completedTerrorsEnd',
|
//505 => 'completedTerrorsEnd',
|
||||||
//507 => 'empty21',
|
//507 => 'empty21',
|
||||||
//509 => 'empty22',
|
//509 => 'empty22',
|
||||||
511 => 'Siege_On_Harrogath',
|
511 => 'Siege_On_Harrogath',
|
||||||
@ -277,35 +277,35 @@ class D2CharStructureData {
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $qHell = [
|
public $qHell = [
|
||||||
537 => 'introWarriv',
|
//537 => 'introWarriv',
|
||||||
539 => 'Den_Of_Evil_Hell',
|
539 => 'Den_Of_Evil_Hell',
|
||||||
541 => 'Sisters_Burial_Grounds_Hell',
|
541 => 'Sisters_Burial_Grounds_Hell',
|
||||||
543 => 'Tools_Of_The_Trade_Hell',
|
543 => 'Tools_Of_The_Trade_Hell',
|
||||||
545 => 'The_Search_For_Cain_Hell',
|
545 => 'The_Search_For_Cain_Hell',
|
||||||
547 => 'The_Forgotten_Tower_Hell',
|
547 => 'The_Forgotten_Tower_Hell',
|
||||||
549 => 'Sisters_To_The_Slaughter_Hell',
|
549 => 'Sisters_To_The_Slaughter_Hell',
|
||||||
551 => 'traveledToAct2',
|
//551 => 'traveledToAct2',
|
||||||
553 => 'introJerhyn',
|
//553 => 'introJerhyn',
|
||||||
555 => 'Radaments_Lair_Hell',
|
555 => 'Radaments_Lair_Hell',
|
||||||
557 => 'The_Horadric_Staff_Hell',
|
557 => 'The_Horadric_Staff_Hell',
|
||||||
559 => 'Tainted_Sun_Hell',
|
559 => 'Tainted_Sun_Hell',
|
||||||
561 => 'Arcane_Sanctuary_Hell',
|
561 => 'Arcane_Sanctuary_Hell',
|
||||||
563 => 'The_Summoner_Hell',
|
563 => 'The_Summoner_Hell',
|
||||||
565 => 'The_SevenTombs_Hell',
|
565 => 'The_SevenTombs_Hell',
|
||||||
567 => 'traveledToAct3',
|
//567 => 'traveledToAct3',
|
||||||
569 => 'introHratli',
|
//569 => 'introHratli',
|
||||||
571 => 'Lam_Esens_Tome_Hell',
|
571 => 'Lam_Esens_Tome_Hell',
|
||||||
573 => 'KhalimsWill_Hell',
|
573 => 'KhalimsWill_Hell',
|
||||||
575 => 'Blade_Of_The_Old_Religion_Hell',
|
575 => 'Blade_Of_The_Old_Religion_Hell',
|
||||||
577 => 'The_Golden_Bird_Hell',
|
577 => 'The_Golden_Bird_Hell',
|
||||||
579 => 'The_Blackened_Temple_Hell',
|
579 => 'The_Blackened_Temple_Hell',
|
||||||
581 => 'The_Guardian_Hell',
|
581 => 'The_Guardian_Hell',
|
||||||
583 => 'traveledtoAct4',
|
//583 => 'traveledtoAct4',
|
||||||
585 => 'introToAct4',
|
//585 => 'introToAct4',
|
||||||
587 => 'The_Fallen_Angel_Hell',
|
587 => 'The_Fallen_Angel_Hell',
|
||||||
589 => 'Terrors_End_Hell',
|
589 => 'Terrors_End_Hell',
|
||||||
591 => 'Hell_Forge_Hell',
|
591 => 'Hell_Forge_Hell',
|
||||||
593 => 'traveledToAct5',
|
//593 => 'traveledToAct5',
|
||||||
//595 => 'empty31',
|
//595 => 'empty31',
|
||||||
//597 => 'empty32',
|
//597 => 'empty32',
|
||||||
//599 => 'empty33',
|
//599 => 'empty33',
|
||||||
|
@ -32,7 +32,7 @@ EOT;
|
|||||||
$kD = str_replace([" NM", " Hell"], "", $kD);
|
$kD = str_replace([" NM", " Hell"], "", $kD);
|
||||||
$checked = ($v == 1) ? 'checked' : '';
|
$checked = ($v == 1) ? 'checked' : '';
|
||||||
|
|
||||||
$quests .= "<input type='checkbox' value='1' name='quest[$k]' id='$k' $checked>";
|
$quests .= "<input class='qcheck' diff='$difficulty' type='checkbox' value='1' name='$k' id='$k' $checked>";
|
||||||
$quests .= "<label for='$k'>$kD</label><br>";
|
$quests .= "<label for='$k'>$kD</label><br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user