latest, d2s stuff

This commit is contained in:
Hash Borgir
2022-07-03 04:13:50 -06:00
parent e51e40175e
commit f3b24de2a8
11 changed files with 393 additions and 239 deletions

View File

@@ -156,21 +156,40 @@ class D2ByteReader {
}
$file = "D:\Diablo II\MODS\ironman-dev\save\Barb.d2s";
$data = file_get_contents($file);
$filename = "D:\Diablo II\MODS\ironman-dev\save\Barb.d2s";
$fileData = unpack('C*', file_get_contents($filename)); // open file and unpack
var_dump(checksum($fileData));
$c = new D2ByteReader($data);
$bytes = $c->readh(643, 5);
$bits = $c->toBits($bytes);
$bits[4] = 1;
$bits[5] = 1;
$bits[8] = 1;
$newBytes = $c->bitsToHexString($bits);
$c->writeBytes(643, $newBytes);
$c->writeBytes(12, "00000000"); // zero old checksum
$newChecksum = checksum(unpack('C*', $c->getData())); // get new checksum
$c->writeBytes(12, $newChecksum); // write new checksum
file_put_contents($file, $c->getData()); // write bytestream to file
//$file = "D:\Diablo II\MODS\ironman-dev\save\Barb.d2s";
//$data = file_get_contents($file);
//
//$c = new D2ByteReader($data);
//
//$checksum = checksum(unpack('C*', $c->getData()));
//
//ddump($checksum);
//$bytes = $c->readh(643, 5);
//$bits = $c->toBits($bytes);
//
//$bits[4] = 0;
//$bits[5] = 0;
//$bits[8] = 0;
//$newBytes = $c->bitsToHexString($bits);
//$c->writeBytes(643, $newBytes);
//
//$c->writeBytes(12, "00000000"); // zero old checksum
//
//dump($c->readh(12, 4));
//
//$newChecksum = checksum(unpack('C*', $c->getData())); // get new checksum
//$c->writeBytes(12, $newChecksum); // write new checksum
//
//dump($c->readh(12, 4));
//
//file_put_contents($file, $c->getData()); // write bytestream to file