d2tools/test.php

46 lines
1.2 KiB
PHP
Raw Normal View History

<?php
error_reporting(E_ERROR | E_PARSE);
set_time_limit(-1);
ini_set('max_input_time', '-1');
ini_set('max_execution_time', '0');
session_start();
ob_start();
require_once './testData.php';
require_once './config.php';
require_once './_pdo.php';
require_once "./src/D2Functions.php";
require_once './src/D2ItemData.php';
require_once './src/D2ItemDesc.php';
require_once './src/D2DocGenerator.php';
define('DB_FILE', "ironman-dev.db");
PDO_Connect("sqlite:" . DB_FILE);
2022-05-15 02:14:49 +00:00
$filename = "D:\Diablo II\MODS\ironman-dev\save\Test.d2s";
$filename = str_replace("\\", "\\\\", $filename);
2022-05-15 02:14:49 +00:00
$fp = fopen($filename, "rb+");
// delete old checksum at offset 0x0C - byte 12
fseek($fp, 12);
// (I) unsigned integer (machine dependent size and byte order)
fwrite($fp, pack('I', 0)); // produces 4 bytes
// edit quest test, den of evil
2022-05-15 02:14:49 +00:00
fseek($fp, 347);
fwrite($fp, pack('C', 0xFD));
fseek($fp, 348);
fwrite($fp, pack('C', 0x9F));
$checksum = swapEndianness(shell_exec("bin\d2scs.exe \"$filename\""));
// write NEW checksum at offset 0x0C - byte 12
fseek($fp, 12);
// (I) unsigned integer (machine dependent size and byte order)
fwrite($fp, pack('H*', $checksum)); // produces 4 bytes
2022-05-15 02:14:49 +00:00
fclose($fp);