mirror of
https://github.com/Rogiel/php-mpq
synced 2025-12-06 08:23:05 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4549549eec |
@@ -42,19 +42,18 @@ abstract class BaseHashing implements Hashing {
|
|||||||
|
|
||||||
public function hash($string) {
|
public function hash($string) {
|
||||||
$seed1 = 0x7FED7FED;
|
$seed1 = 0x7FED7FED;
|
||||||
$seed2 = ((0xEEEE << 16) | 0xEEEE);
|
$seed2 = 0xEEEEEEEE;
|
||||||
$strLen = strlen($string);
|
$strLen = strlen($string);
|
||||||
|
|
||||||
for ($i = 0;$i < $strLen;$i++) {
|
for ($i = 0;$i < $strLen;$i++) {
|
||||||
$next = ord(strtoupper(substr($string, $i, 1)));
|
$next = ord(strtoupper(substr($string, $i, 1)));
|
||||||
|
|
||||||
$seed1 = CryptoUtils::$cryptTable[($this->hashType << 8) + $next] ^ (CryptoUtils::uPlus($seed1,$seed2));
|
$seed1 = CryptoUtils::$cryptTable[($this->hashType << 8) + $next] ^ (CryptoUtils::uPlus($seed1,$seed2)) & 0xFFFFFFFF;
|
||||||
$seed2 = CryptoUtils::uPlus(CryptoUtils::uPlus(CryptoUtils::uPlus(CryptoUtils::uPlus($next,$seed1),$seed2),$seed2 << 5),3);
|
$seed2 = CryptoUtils::uPlus(CryptoUtils::uPlus(CryptoUtils::uPlus(CryptoUtils::uPlus($next,$seed1),$seed2),$seed2 << 5),3) & 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
return $seed1;
|
return $seed1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// function that adds up two integers without allowing them to overflow to floats
|
// function that adds up two integers without allowing them to overflow to floats
|
||||||
private function uPlus($o1, $o2) {
|
private function uPlus($o1, $o2) {
|
||||||
$o1h = ($o1 >> 16) & 0xFFFF;
|
$o1h = ($o1 >> 16) & 0xFFFF;
|
||||||
|
|||||||
@@ -130,12 +130,12 @@ class MPQFile {
|
|||||||
$parser->seek($this->getUserDataOffset() + $this->getHeader()->getBlockTablePos());
|
$parser->seek($this->getUserDataOffset() + $this->getHeader()->getBlockTablePos());
|
||||||
$blocks = array();
|
$blocks = array();
|
||||||
|
|
||||||
$offsetFix = 0;
|
// $offsetFix = 0;
|
||||||
for($i = 0; $i<$this->getHeader()->getBlockTableSize(); $i++) {
|
for($i = 0; $i<$this->getHeader()->getBlockTableSize(); $i++) {
|
||||||
$block = $blocks[$i - $offsetFix] = Block::parse($parser);
|
$block = $blocks[$i] = Block::parse($parser);
|
||||||
if($block->getSize() == 0) {
|
// if($block->getSize() == 0) {
|
||||||
$offsetFix++;
|
// $offsetFix++;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
return new BlockTable($blocks);
|
return new BlockTable($blocks);
|
||||||
}
|
}
|
||||||
@@ -184,6 +184,7 @@ class MPQFile {
|
|||||||
if($hash == NULL) {
|
if($hash == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getBlockTable()->getBlock($hash->getBlockIndex());
|
return $this->getBlockTable()->getBlock($hash->getBlockIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,22 +203,11 @@ class MPQFile {
|
|||||||
$blockSize = $block->getCompressedSize();
|
$blockSize = $block->getCompressedSize();
|
||||||
$fileSize = $block->getSize();
|
$fileSize = $block->getSize();
|
||||||
|
|
||||||
print_r($this->getBlockTable()->getBlocks());
|
|
||||||
|
|
||||||
// print_r($block);
|
|
||||||
// echo $block->isExisting() ? "true" : "false";
|
|
||||||
// echo "\n";
|
|
||||||
//
|
|
||||||
// echo $fileSize."\n";
|
|
||||||
// echo $this->getHeader()->getBlockSize()."\n";
|
|
||||||
|
|
||||||
for ($i = $fileSize; $i > 0; $i -= $blockSize) {
|
for ($i = $fileSize; $i > 0; $i -= $blockSize) {
|
||||||
echo $i;
|
|
||||||
$sectors[] = $parser->readUInt32();
|
$sectors[] = $parser->readUInt32();
|
||||||
$blockSize -= 4;
|
$blockSize -= 4;
|
||||||
}
|
}
|
||||||
print_r($sectors);
|
$sectors[] = $parser->readUInt32();
|
||||||
// $sectors[] = $parser->readUInt32();
|
|
||||||
} else {
|
} else {
|
||||||
$sectors = array(
|
$sectors = array(
|
||||||
0,
|
0,
|
||||||
|
|||||||
Reference in New Issue
Block a user