mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2024-11-30 04:26:03 +00:00
Added D2Strings class to get strings where needed from strings table
This commit is contained in:
parent
ade44ff427
commit
5907c8c8d3
267
index.php
267
index.php
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
session_start();
|
||||
/*
|
||||
|
||||
@ -21,7 +20,7 @@ session_start();
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* This software must not be used for commercial purposes
|
||||
* This software must not be used for commercial purposes
|
||||
* without my consent. Any sales or commercial use are prohibited
|
||||
* without my express knowledge and consent.
|
||||
|
||||
@ -49,65 +48,56 @@ error_reporting(E_ALL ^ E_WARNING);
|
||||
ini_set('log_errors', 1);
|
||||
|
||||
include "./_pdo.php";
|
||||
|
||||
include "./config.php";
|
||||
|
||||
require_once "./vendor/autoload.php";
|
||||
|
||||
|
||||
if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SESSION['modname'] . ".db"))) {
|
||||
// first load, no active mod, go to switchmods to select mod
|
||||
header("Location: /switchMods.php");
|
||||
// first load, no active mod, go to switchmods to select mod
|
||||
header("Location: /switchMods.php");
|
||||
} else {
|
||||
PDO_Connect("sqlite:" . APP_DB);
|
||||
$sql = "SELECT * FROM D2Modder ORDER BY lastused DESC LIMIT 1";
|
||||
$lastUsedMod = PDO_FetchRow($sql);
|
||||
|
||||
PDO_Connect("sqlite:" . APP_DB);
|
||||
$sql = "SELECT * FROM D2Modder ORDER BY lastused DESC LIMIT 1";
|
||||
$_SESSION['modname'] = $lastUsedMod['modname'];
|
||||
$_SESSION['path'] = $lastUsedMod['path'];
|
||||
|
||||
$lastUsedMod = PDO_FetchRow($sql);
|
||||
$sql = "SELECT theme FROM `D2Modder` WHERE `modname`='{$_SESSION['modname']}'";
|
||||
$res = PDO_FetchAll($sql);
|
||||
|
||||
if ($res[0]['theme'] == 1) {
|
||||
$css = 'dark.css';
|
||||
} else {
|
||||
$css = '';
|
||||
}
|
||||
|
||||
$_SESSION['modname'] = $lastUsedMod['modname'];
|
||||
$_SESSION['path'] = $lastUsedMod['path'];
|
||||
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
|
||||
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||
define('TXT_PATH', $_SESSION['path']);
|
||||
|
||||
$sql = "SELECT theme FROM `D2Modder` WHERE `modname`='{$_SESSION['modname']}'";
|
||||
$res = PDO_FetchAll($sql);
|
||||
|
||||
if ($res[0]['theme'] == 1) {
|
||||
$css = 'dark.css';
|
||||
} else {
|
||||
$css = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
define('FILTER_PROPERTIES_FILE', 'filterProperties.txt');
|
||||
define('DB_FILE', $_SESSION['modname'] . ".db");
|
||||
define('TXT_PATH', $_SESSION['path']);
|
||||
|
||||
require_once "./src/D2Functions.php";
|
||||
require_once "./src/D2Database.php";
|
||||
require_once './src/D2Files.php';
|
||||
require_once './src/D2TxtParser.php';
|
||||
require_once './src/D2ItemDesc.php';
|
||||
require_once './src/D2Char.php';
|
||||
require_once "./src/D2Functions.php";
|
||||
require_once "./src/D2Database.php";
|
||||
require_once './src/D2Files.php';
|
||||
require_once './src/D2TxtParser.php';
|
||||
require_once './src/D2ItemDesc.php';
|
||||
require_once './src/D2Char.php';
|
||||
require_once './src/D2CharStructureData.php';
|
||||
|
||||
|
||||
$D2Files = new D2Files();
|
||||
$charFiles = $D2Files->getSaveFiles();
|
||||
|
||||
|
||||
foreach($charFiles as $charFile){
|
||||
|
||||
$D2Files = new D2Files();
|
||||
$charFiles = $D2Files->getSaveFiles();
|
||||
|
||||
foreach ($charFiles as $charFile) {
|
||||
$charData[] = new D2Char($charFile); // $charData goes into chars.php tab
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// dump($charData[0]->charData);
|
||||
// dump($charData[1]->charData);
|
||||
// die();
|
||||
|
||||
$idesc = new D2ItemDesc();
|
||||
$db = new D2Database();
|
||||
$parser = new D2TxtParser();
|
||||
|
||||
$idesc = new D2ItemDesc();
|
||||
$db = new D2Database();
|
||||
$parser = new D2TxtParser();
|
||||
|
||||
// $a = ["bighead1","fallen1","corruptrogue1","goatman1","fallenshaman1","fetish1","cr_archer1","cr_lancer1","vulture1","bloodraven","andariel","smith","vulture1","blunderbore1","duriel","fetishshaman1","councilmember1","mephisto","megademon1","regurgitator1","diablo","hephasto","vilemother1","vilechild1","overseer1","imp1","succubus1","succubuswitch1","putriddefiler1","painworm1","minion1","baalcrab"];
|
||||
//
|
||||
@ -120,10 +110,10 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
||||
|
||||
|
||||
|
||||
$armor = PDO_FetchAll('SELECT * FROM armor WHERE spawnable=1');
|
||||
$misc = PDO_FetchAll('SELECT * FROM misc WHERE spawnable=1
|
||||
AND type <> "stst"
|
||||
AND type <> "sum0"
|
||||
$armor = PDO_FetchAll('SELECT * FROM armor WHERE spawnable=1');
|
||||
$misc = PDO_FetchAll('SELECT * FROM misc WHERE spawnable=1
|
||||
AND type <> "stst"
|
||||
AND type <> "sum0"
|
||||
AND type <> "prtl"
|
||||
AND type <> "xfor"
|
||||
AND type <> "rext"
|
||||
@ -132,116 +122,113 @@ if (!isset($_SESSION['modname']) || (!file_exists(APP_DB)) || (!file_exists($_SE
|
||||
AND type <> "key"
|
||||
AND type <> "body"
|
||||
');
|
||||
$weapon = PDO_FetchAll('SELECT * FROM weapons WHERE spawnable=1');
|
||||
$uniqueitems = PDO_FetchAll("SELECT `index`,`code` FROM uniqueitems WHERE `enabled`='1' ORDER BY `index` ASC");
|
||||
$weapon = PDO_FetchAll('SELECT * FROM weapons WHERE spawnable=1');
|
||||
$uniqueitems = PDO_FetchAll("SELECT `index`,`code` FROM uniqueitems WHERE `enabled`='1' ORDER BY `index` ASC");
|
||||
|
||||
$prop = $parser->filterProps('Properties.txt');
|
||||
$prop = $parser->filterProps('Properties.txt');
|
||||
|
||||
// If there's data, process it and save
|
||||
if (!empty($_POST)) {
|
||||
// save db name from post into conf file... why?
|
||||
// If there's data, process it and save
|
||||
if (!empty($_POST)) {
|
||||
// save db name from post into conf file... why?
|
||||
|
||||
require_once './src/D2Char.php';
|
||||
$saver = new D2Char();
|
||||
require_once './src/D2Char.php';
|
||||
$saver = new D2Char();
|
||||
|
||||
// process post
|
||||
// combine armor/weapon codes
|
||||
foreach ($_POST as $k => $v) {
|
||||
$x = str_replace("_", " ", $k);
|
||||
$post[$x] = $v;
|
||||
}
|
||||
// process post
|
||||
// combine armor/weapon codes
|
||||
foreach ($_POST as $k => $v) {
|
||||
$x = str_replace("_", " ", $k);
|
||||
$post[$x] = $v;
|
||||
}
|
||||
|
||||
if (!empty($post['code'])) {
|
||||
array_filter($post['code']);
|
||||
if (!empty($post['code'])) {
|
||||
array_filter($post['code']);
|
||||
|
||||
if (!empty($post['code'][0])) {
|
||||
$post['code'] = $post['code'][0];
|
||||
} else {
|
||||
$post['code'] = $post['code'][1];
|
||||
}
|
||||
}
|
||||
if (!empty($post['code'][0])) {
|
||||
$post['code'] = $post['code'][0];
|
||||
} else {
|
||||
$post['code'] = $post['code'][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// last 3 items are not in d2 txt, rid of them
|
||||
// why did I set formtype? I can't rememer, need to comment code more
|
||||
// last 3 items are not in d2 txt, rid of them
|
||||
// why did I set formtype? I can't rememer, need to comment code more
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
|
||||
*
|
||||
*
|
||||
* Unique Items Form was posted here
|
||||
*
|
||||
*/
|
||||
*
|
||||
*
|
||||
* Unique Items Form was posted here
|
||||
*
|
||||
*/
|
||||
|
||||
if ($_POST['formtype'] == "uniqueitems") {
|
||||
if ($_POST['formtype'] == "uniqueitems") {
|
||||
|
||||
unset($post['formtype']);
|
||||
unset($post['submit']);
|
||||
unset($post['item']);
|
||||
unset($post['formtype']);
|
||||
unset($post['submit']);
|
||||
unset($post['item']);
|
||||
|
||||
// if ladder or carry1 is 0, set empty field.
|
||||
if (!$post['ladder']) {
|
||||
$post['ladder'] = '';
|
||||
}
|
||||
if (!$post['carry1']) {
|
||||
$post['carry1'] = '';
|
||||
}
|
||||
// if ladder or carry1 is 0, set empty field.
|
||||
if (!$post['ladder']) {
|
||||
$post['ladder'] = '';
|
||||
}
|
||||
if (!$post['carry1']) {
|
||||
$post['carry1'] = '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
ddump($post);
|
||||
|
||||
|
||||
$sql = "SELECT rowid,`index` from `uniqueitems` WHERE `index`=\"{$post['index']}\"";
|
||||
|
||||
$res = PDO_FetchRow($sql);
|
||||
|
||||
if ($res['index'] == $post['index']) {
|
||||
$sql = "UPDATE `uniqueitems` SET ";
|
||||
foreach ($post as $k => $v) {
|
||||
$sql .= "`$k`=\"$v\",";
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ' WHERE `index`="'.$post['index'].'"';
|
||||
|
||||
|
||||
|
||||
PDO_Execute($sql, [$post['index']]);
|
||||
//ddump($x);
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Set Items Form was posted here
|
||||
*
|
||||
*/ else {
|
||||
ddump($post);
|
||||
|
||||
$sql = "INSERT INTO `uniqueitems` (";
|
||||
foreach ($post as $k => $v) {
|
||||
$sql .= "`$k`,";
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ") VALUES (";
|
||||
foreach ($post as $k => $v) {
|
||||
$sql .= "'$v',";
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ")";
|
||||
ddump($sql);
|
||||
$sql = "SELECT rowid,`index` from `uniqueitems` WHERE `index`=\"{$post['index']}\"";
|
||||
|
||||
// $saver->save($u, $post);
|
||||
// $saver->saveTblEnries("UniqueItems.tbl.txt");
|
||||
}
|
||||
}
|
||||
if ($_POST['formtype'] == "setitems") {
|
||||
$saver->save($s, $post);
|
||||
$saver->saveTblEnries("SetItems.tbl.txt");
|
||||
}
|
||||
}
|
||||
$res = PDO_FetchRow($sql);
|
||||
|
||||
if ($res['index'] == $post['index']) {
|
||||
$sql = "UPDATE `uniqueitems` SET ";
|
||||
foreach ($post as $k => $v) {
|
||||
$sql .= "`$k`=\"$v\",";
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ' WHERE `index`="' . $post['index'] . '"';
|
||||
|
||||
PDO_Execute($sql, [$post['index']]);
|
||||
//ddump($x);
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Set Items Form was posted here
|
||||
*
|
||||
*/ else {
|
||||
|
||||
$sql = "INSERT INTO `uniqueitems` (";
|
||||
foreach ($post as $k => $v) {
|
||||
$sql .= "`$k`,";
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ") VALUES (";
|
||||
foreach ($post as $k => $v) {
|
||||
$sql .= "'$v',";
|
||||
}
|
||||
$sql = rtrim($sql, ",");
|
||||
$sql .= ")";
|
||||
ddump($sql);
|
||||
|
||||
// $saver->save($u, $post);
|
||||
// $saver->saveTblEnries("UniqueItems.tbl.txt");
|
||||
}
|
||||
}
|
||||
if ($_POST['formtype'] == "setitems") {
|
||||
$saver->save($s, $post);
|
||||
$saver->saveTblEnries("SetItems.tbl.txt");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// load app
|
||||
require_once './src/index.php';
|
||||
// load app
|
||||
require_once './src/index.php';
|
||||
}
|
||||
?>
|
@ -3,12 +3,14 @@
|
||||
require_once 'D2CharStructureData.php';
|
||||
require_once 'D2Files.php';
|
||||
require_once 'D2BitReader.php';
|
||||
require_once 'D2Strings.php';
|
||||
|
||||
class D2Char {
|
||||
|
||||
public $cData; // char data output
|
||||
public $items; // char item data
|
||||
private $sData; // char file structure data
|
||||
private $bData; // char binary data from d2s
|
||||
private $bData; // char binary data from d2s
|
||||
private $filePath; // .d2s file path
|
||||
private $fp; // file pointer
|
||||
|
||||
@ -23,10 +25,15 @@ class D2Char {
|
||||
fseek($this->fp, $k);
|
||||
$this->bData[$k] = fread($this->fp, $v);
|
||||
}
|
||||
|
||||
$this->strings = new D2Strings();
|
||||
return $this->parseChar();
|
||||
|
||||
}
|
||||
|
||||
public function parseItems(){
|
||||
|
||||
}
|
||||
|
||||
public function parseChar() {
|
||||
$cData = null;
|
||||
$cData['Identifier'] = bin2hex($this->bData[0]);
|
||||
@ -69,6 +76,8 @@ class D2Char {
|
||||
$cData['NPCIntroductions'] = $this->bData[714];
|
||||
$cData['filePath'] = $this->filePath;
|
||||
$this->cData = $cData;
|
||||
$this->parseItems();
|
||||
|
||||
return $this->cData;
|
||||
}
|
||||
|
||||
|
11
src/D2Strings.php
Normal file
11
src/D2Strings.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
class D2Strings {
|
||||
public array $strings;
|
||||
|
||||
public function __construct(){
|
||||
$sql = "SELECT * FROM strings";
|
||||
$this->strings = PDO_FetchAssoc($sql);
|
||||
return $this->strings;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user