@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @property array $dirs |
| 23 | 23 | */ |
| 24 | -final class AIDXReader extends PACKReaderAbstract{ |
|
| 24 | +final class AIDXReader extends PACKReaderAbstract { |
|
| 25 | 25 | |
| 26 | 26 | private const AIDX_ROOT = 'a4ArchiveType/LVersion/LBuildnumber/LIndex'; |
| 27 | 27 | private const AIDX_DATA = 'LNameOffset/LFlags/QFiletime/QSizeUncompressed/QSizeCompressed/a20Hash/x4'; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // get the root info block of the AIDX file (4+4+4+4 = 16 bytes) |
| 38 | 38 | $rootInfo = unpack($this::AIDX_ROOT, fread($this->fh, 16)); |
| 39 | 39 | |
| 40 | - if($rootInfo['ArchiveType'] !== "\x58\x44\x49\x41"){ // XDIA |
|
| 40 | + if ($rootInfo['ArchiveType'] !== "\x58\x44\x49\x41") { // XDIA |
|
| 41 | 41 | throw new WSDBException('invalid AIDX'); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | $files = array_fill(0, $n['files'], null); |
| 67 | 67 | |
| 68 | 68 | // create a directory object for each dir (4+4 = 8 bytes) |
| 69 | - foreach($dirs as $i => $_){ |
|
| 69 | + foreach ($dirs as $i => $_) { |
|
| 70 | 70 | $dirs[$i] = new Directory(unpack('LNameOffset/LBlockIndex', fread($this->fh, 8)), $parent); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // create a file object for each file (4+4+8+8+8+20+4 = 56 bytes) |
| 74 | - foreach($files as $i => $_){ |
|
| 74 | + foreach ($files as $i => $_) { |
|
| 75 | 75 | $files[$i] = new File(unpack($this::AIDX_DATA, fread($this->fh, 56)), $parent); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -83,17 +83,17 @@ discard block |
||
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | 85 | // apply the names to each object in the block |
| 86 | - foreach($dirs as $i => $e){ |
|
| 86 | + foreach ($dirs as $i => $e) { |
|
| 87 | 87 | $dirs[$i]->Name = $getname($e); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - foreach($files as $i => $e){ |
|
| 90 | + foreach ($files as $i => $e) { |
|
| 91 | 91 | $files[$i]->Name = $getname($e); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // loop through the directory stucture recursively and add the block data |
| 95 | - foreach($dirs as $i => $info){ |
|
| 96 | - if(isset($this->blocktable[$info->BlockIndex])){ |
|
| 95 | + foreach ($dirs as $i => $info) { |
|
| 96 | + if (isset($this->blocktable[$info->BlockIndex])) { |
|
| 97 | 97 | $dirs[$i]->Content = $this->getBlock($this->blocktable[$info->BlockIndex], $parent.$info->Name); |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace codemasher\WildstarDB\Archive; |
| 14 | 14 | |
| 15 | -final class Directory extends ItemAbstract{ |
|
| 15 | +final class Directory extends ItemAbstract { |
|
| 16 | 16 | |
| 17 | 17 | /** @var int */ |
| 18 | 18 | public $BlockIndex; |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | use function bin2hex; |
| 16 | 16 | |
| 17 | -final class File extends ItemAbstract{ |
|
| 17 | +final class File extends ItemAbstract { |
|
| 18 | 18 | |
| 19 | 19 | /** @var int */ |
| 20 | 20 | public $Flags; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param array $data |
| 36 | 36 | * @param string $parent |
| 37 | 37 | */ |
| 38 | - public function __construct(array $data, string $parent){ |
|
| 38 | + public function __construct(array $data, string $parent) { |
|
| 39 | 39 | parent::__construct($data, $parent); |
| 40 | 40 | |
| 41 | 41 | $this->Hash = bin2hex($this->Hash); |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @property array $blocktable |
| 22 | 22 | */ |
| 23 | -abstract class PACKReaderAbstract extends ReaderAbstract{ |
|
| 23 | +abstract class PACKReaderAbstract extends ReaderAbstract { |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * 4+4+512+8+8+8+4+4+4+8 = 564 bytes |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | $this->loadFile($filename); |
| 58 | 58 | $this->blocktable = []; |
| 59 | 59 | |
| 60 | - if($this->header['Signature'] !== "\x4b\x43\x41\x50"){ // KCAP |
|
| 60 | + if ($this->header['Signature'] !== "\x4b\x43\x41\x50") { // KCAP |
|
| 61 | 61 | throw new WSDBException('invalid PACK'); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // read the block info table |
| 65 | 65 | fseek($this->fh, $this->header['BlockTableOffset']); |
| 66 | 66 | |
| 67 | - for($i = 0; $i < $this->header['BlockCount']; $i++){ |
|
| 67 | + for ($i = 0; $i < $this->header['BlockCount']; $i++) { |
|
| 68 | 68 | $this->blocktable[$i] = unpack('QOffset/QSize', fread($this->fh, 16)); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | use function bin2hex, fread, fseek, unpack; |
| 18 | 18 | |
| 19 | -final class AARCReader extends PACKReaderAbstract{ |
|
| 19 | +final class AARCReader extends PACKReaderAbstract { |
|
| 20 | 20 | |
| 21 | 21 | private const AARC_ROOT = 'a4ArchiveType/LVersion/LBlockcount/LIndex'; |
| 22 | 22 | private const AARC_DATA = 'LIndex/a20Hash/QSizeCompressed'; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | // get the root info block of the AARC file (4+4+4+4 = 16 bytes) |
| 30 | 30 | $rootInfo = unpack($this::AARC_ROOT, fread($this->fh, 16)); |
| 31 | 31 | |
| 32 | - if($rootInfo['ArchiveType'] !== "\x43\x52\x41\x41"){ // CRAA |
|
| 32 | + if ($rootInfo['ArchiveType'] !== "\x43\x52\x41\x41") { // CRAA |
|
| 33 | 33 | throw new WSDBException('invalid AARC'); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | fseek($this->fh, $blockInfo['Offset']); |
| 40 | 40 | |
| 41 | 41 | // read the data block info (4+20+8 = 32 bytes) |
| 42 | - for($i = 0; $i < $rootInfo['Blockcount']; $i++){ |
|
| 42 | + for ($i = 0; $i < $rootInfo['Blockcount']; $i++) { |
|
| 43 | 43 | $data = unpack($this::AARC_DATA, fread($this->fh, 32)); |
| 44 | 44 | $hash = bin2hex($data['Hash']); |
| 45 | 45 | unset($data['Hash']); |
@@ -99,12 +99,12 @@ |
||
| 99 | 99 | $optimizer = (new OptimizerFactory($optimizer_settings, $logger))->get($tilerOptions->tile_format); |
| 100 | 100 | $map_tiler = new Imagetiler($tilerOptions, $optimizer, $logger); |
| 101 | 101 | |
| 102 | -foreach($maps as $map => $dir){ |
|
| 102 | +foreach ($maps as $map => $dir) { |
|
| 103 | 103 | |
| 104 | - try{ |
|
| 104 | + try { |
|
| 105 | 105 | $map_tiler->process(mapdir.'/'.$map.'.png', tiledir.'/'.$dir); |
| 106 | 106 | } |
| 107 | - catch(ImagetilerException $e){ |
|
| 107 | + catch (ImagetilerException $e) { |
|
| 108 | 108 | echo $e->getMessage(); |
| 109 | 109 | echo $e->getTraceAsString(); |
| 110 | 110 | } |
@@ -103,8 +103,7 @@ |
||
| 103 | 103 | |
| 104 | 104 | try{ |
| 105 | 105 | $map_tiler->process(mapdir.'/'.$map.'.png', tiledir.'/'.$dir); |
| 106 | - } |
|
| 107 | - catch(ImagetilerException $e){ |
|
| 106 | + } catch(ImagetilerException $e){ |
|
| 108 | 107 | echo $e->getMessage(); |
| 109 | 108 | echo $e->getTraceAsString(); |
| 110 | 109 | } |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $outpath = __DIR__.'/maps'; |
| 91 | 91 | |
| 92 | -foreach(new DirectoryIterator($wildstar_path.'/Patch/ClientData/Map') as $dir){ // 'C:\\Games\\Wildstar Studio\\out\\Map' |
|
| 92 | +foreach (new DirectoryIterator($wildstar_path.'/Patch/ClientData/Map') as $dir) { // 'C:\\Games\\Wildstar Studio\\out\\Map' |
|
| 93 | 93 | $map = $dir->getFilename(); |
| 94 | 94 | |
| 95 | - if(!$dir->isDir() || $dir->isDot() || (!empty($include_maps) && !in_array($map, $include_maps))){ |
|
| 95 | + if (!$dir->isDir() || $dir->isDot() || (!empty($include_maps) && !in_array($map, $include_maps))) { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | $xmax = 0; |
| 103 | 103 | $ymax = 0; |
| 104 | 104 | |
| 105 | - foreach(new DirectoryIterator($dir->getPathname()) as $file){ |
|
| 105 | + foreach (new DirectoryIterator($dir->getPathname()) as $file) { |
|
| 106 | 106 | |
| 107 | - if($file->getExtension() !== 'bmp'){ |
|
| 107 | + if ($file->getExtension() !== 'bmp') { |
|
| 108 | 108 | continue; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $y = hexdec($hex[0]); |
| 114 | 114 | |
| 115 | 115 | // exclude some empty tiles to not exaggerate map/image size |
| 116 | - if( |
|
| 116 | + if ( |
|
| 117 | 117 | ($map === 'Eastern' && $y < 3) |
| 118 | 118 | || ($map === 'AdventureMalgrave' && ($x > 80 || $y < 65)) |
| 119 | 119 | || ($map === 'NewCentral' && ($x > 80 || $y < 3)) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | || ($map === 'ProtostarWinterfest' && ($x < 63 || $x > 66 || $y < 63 || $y > 65)) |
| 127 | 127 | || ($map === 'PvPArena2' && ($x < 63 || $x > 66 || $y < 64 || $y > 65)) |
| 128 | 128 | || ($map === 'AdventureAstrovoidPrison' && ($x < 61 || $x > 65 || $y < 61 || $y > 66)) |
| 129 | - ){ |
|
| 129 | + ) { |
|
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $textures[$y][$x] = $file->getRealPath(); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if(empty($textures)){ |
|
| 141 | + if (empty($textures)) { |
|
| 142 | 142 | continue; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | $im->newImage(($xmax - $xmin + 1) * 512, ($ymax - $ymin + 1) * 512, '#757575'); |
| 149 | 149 | $im->setImageFormat('png'); |
| 150 | 150 | |
| 151 | - foreach($textures as $y => $col){ |
|
| 152 | - foreach($col as $x => $file){ |
|
| 151 | + foreach ($textures as $y => $col) { |
|
| 152 | + foreach ($col as $x => $file) { |
|
| 153 | 153 | $im->compositeImage(new Imagick($file), Imagick::COMPOSITE_OVER, ($x - $xmin) * 512, ($y - $ymin) * 512); |
| 154 | 154 | $logger->info($file); |
| 155 | 155 | } |