mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-09-18 01:22:08 +00:00
D2S Editor Pretty much finished, seems to be working 100%
This commit is contained in:
@@ -51,133 +51,6 @@ $cmd = $g['cmd'];
|
||||
// Get the file path from the POST data and replace backslashes /
|
||||
$filePath = $g['filePath'];
|
||||
//$filePath = str_replace("\\", "\\\\", $filePath);
|
||||
// Handle the WP check/uncheck
|
||||
if ($cmd == "wp") {
|
||||
$diff = $g['diff'];
|
||||
|
||||
if ($diff == "Norm") {
|
||||
$offset = 643;
|
||||
}
|
||||
|
||||
if ($diff == "NM") {
|
||||
$offset = 667;
|
||||
}
|
||||
|
||||
if ($diff == "Hell") {
|
||||
$offset = 691;
|
||||
}
|
||||
|
||||
/*
|
||||
array (size=5)
|
||||
'cmd' => string 'wp' (length=2)
|
||||
'name' => string '1' (length=1)
|
||||
'value' => string '1' (length=1)
|
||||
'filePath' => string 'D:\\Diablo II\\MODS\\ironman-dev\\save\\Sorc.d2s' (length=48)
|
||||
'diff' => string 'Norm' (length=4)
|
||||
*/
|
||||
|
||||
$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
|
||||
$fileData = $ByteReader->getData(); // Get the data from the ByteReader instance
|
||||
|
||||
$wpBytes = $ByteReader->read($offset, 5, 1);
|
||||
$wpBytesToBits = $ByteReader->toBits($wpBytes);
|
||||
|
||||
$BitReader = new D2BitReader($wpBytesToBits);
|
||||
$BitReader->setBit($g['name'], $g['value']);
|
||||
|
||||
$newBits = $BitReader->getBits();
|
||||
$newBitsToBytes = $ByteReader->bitsToHexString($newBits);
|
||||
|
||||
$ByteReader->writeBytes($offset, $newBitsToBytes);
|
||||
$newFileData = $ByteReader->getData();
|
||||
$fileSaved = file_put_contents($filePath, $newFileData);
|
||||
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
||||
|
||||
if ($fileSaved) {
|
||||
echo "Success";
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
$cmd = $_GET['cmd'];
|
||||
$name = $_GET['name'];
|
||||
@@ -220,18 +93,21 @@ switch ($cmd) {
|
||||
|
||||
// handle difficulty wierdly
|
||||
case "Normal":
|
||||
$char->setChar("Difficulty", $value);
|
||||
$char->setChar("CharacterProgression", $value);
|
||||
echo "Handling Difficulty command - Difficulty: $value, File Path: $filePath";
|
||||
break;
|
||||
case "NM":
|
||||
$char->setChar("Difficulty", $value);
|
||||
case "Finished Normal":
|
||||
$char->setChar("CharacterProgression", $value);
|
||||
echo "Handling Difficulty command - Difficulty: $value, File Path: $filePath";
|
||||
break;
|
||||
case "Hell":
|
||||
$char->setChar("Difficulty", $value);
|
||||
case "Finished Nightmare":
|
||||
$char->setChar("CharacterProgression", $value);
|
||||
echo "Handling Difficulty command - Difficulty: $value, File Path: $filePath";
|
||||
break;
|
||||
case "Finished Hell":
|
||||
$char->setChar("CharacterProgression", $value);
|
||||
echo "Handling Difficulty command - Difficulty: $value, File Path: $filePath";
|
||||
break;
|
||||
|
||||
// skills
|
||||
case "skills":
|
||||
//var_dump($char->cData);
|
||||
@@ -299,6 +175,147 @@ switch ($cmd) {
|
||||
$char->setStat("maxstamina", $value); // Set the "maxstamina" stat to the provided value
|
||||
echo "Handling maxstamina command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the maxstamina command
|
||||
break;
|
||||
case "Died":
|
||||
$char->setChar("CharacterStatus", "Died", $value); // Set the "CharacterStatusDied" value to the provided value
|
||||
echo "Handling Died command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the Died command
|
||||
break;
|
||||
|
||||
case "Expansion":
|
||||
$char->setChar("CharacterStatus", "Expansion", $value); // Set the "CharacterStatusExpansion" value to the provided value
|
||||
echo "Handling Expansion command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the Expansion command
|
||||
break;
|
||||
|
||||
case "Hardcore":
|
||||
$char->setChar("CharacterStatus", "Hardcore", $value); // Set the "CharacterStatusHardcore" value to the provided value
|
||||
echo "Handling Hardcore command - Value: $value, File Path: $filePath"; // Display a message indicating the handling of the Hardcore command
|
||||
break;
|
||||
|
||||
// Handle the WP check/uncheck
|
||||
case "wp":
|
||||
$diff = $g['diff'];
|
||||
|
||||
if ($diff == "Norm") {
|
||||
$offset = 643;
|
||||
}
|
||||
|
||||
if ($diff == "NM") {
|
||||
$offset = 667;
|
||||
}
|
||||
|
||||
if ($diff == "Hell") {
|
||||
$offset = 691;
|
||||
}
|
||||
|
||||
/*
|
||||
array (size=5)
|
||||
'cmd' => string 'wp' (length=2)
|
||||
'name' => string '1' (length=1)
|
||||
'value' => string '1' (length=1)
|
||||
'filePath' => string 'D:\\Diablo II\\MODS\\ironman-dev\\save\\Sorc.d2s' (length=48)
|
||||
'diff' => string 'Norm' (length=4)
|
||||
*/
|
||||
|
||||
$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
|
||||
$fileData = $ByteReader->getData(); // Get the data from the ByteReader instance
|
||||
|
||||
$wpBytes = $ByteReader->read($offset, 5, 1);
|
||||
$wpBytesToBits = $ByteReader->toBits($wpBytes);
|
||||
|
||||
$BitReader = new D2BitReader($wpBytesToBits);
|
||||
$BitReader->setBit($g['name'], $g['value']);
|
||||
|
||||
$newBits = $BitReader->getBits();
|
||||
$newBitsToBytes = $ByteReader->bitsToHexString($newBits);
|
||||
|
||||
$ByteReader->writeBytes($offset, $newBitsToBytes);
|
||||
$newFileData = $ByteReader->getData();
|
||||
$fileSaved = file_put_contents($filePath, $newFileData);
|
||||
$checksum = (shell_exec("bin\d2scs.exe \"$filePath\""));
|
||||
|
||||
if ($fileSaved) {
|
||||
echo "Success";
|
||||
} else {
|
||||
echo "Fail";
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
||||
*/
|
||||
|
||||
case "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);
|
||||
break;
|
||||
|
||||
// default command
|
||||
default:
|
||||
|
Reference in New Issue
Block a user