Setup/WIN

* fix paths for WIN ... and try to not use slashes in the future...
 * fixes #430
This commit is contained in:
Sarjuuk
2024-07-05 18:09:24 +02:00
parent a4bcb33ba4
commit 8d885a5a67
4 changed files with 42 additions and 41 deletions

View File

@@ -343,8 +343,9 @@ abstract class CLI
$path .= ($path ? DIRECTORY_SEPARATOR : '').trim($fileOrPath); $path .= ($path ? DIRECTORY_SEPARATOR : '').trim($fileOrPath);
// remove quotes (from erronous user input) // remove double quotes (from erronous user input), single quotes are
$path = str_replace(['"', "'"], ['', ''], $path); // valid chars for filenames and removing those mutilates several wow icons
$path = str_replace('"', '', $path);
if (!$path) // empty strings given. (faulty dbc data?) if (!$path) // empty strings given. (faulty dbc data?)
return ''; return '';

View File

@@ -204,7 +204,7 @@ class CLISetup
// alternative data source (no quotes, use forward slash) // alternative data source (no quotes, use forward slash)
if (isset(self::$opts['datasrc'])) if (isset(self::$opts['datasrc']))
self::$srcDir = CLI::nicePath(self::$opts['datasrc']); self::$srcDir = CLI::nicePath('', self::$opts['datasrc']);
if (!self::setLocales()) if (!self::setLocales())
CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR); CLI::write('No valid locale specified. Check your config or --locales parameter, if used', CLI::LOG_ERROR);
@@ -475,15 +475,12 @@ class CLISetup
$setupDirs = glob('setup/*'); $setupDirs = glob('setup/*');
foreach ($setupDirs as $sd) foreach ($setupDirs as $sd)
{ {
if (mb_substr(self::$srcDir, -1) == '/') if (mb_substr($sd, -1) == DIRECTORY_SEPARATOR)
self::$srcDir = mb_substr(self::$srcDir, 0, -1);
if (mb_substr($sd, -1) == '/')
$sd = mb_substr($sd, 0, -1); $sd = mb_substr($sd, 0, -1);
if (Util::lower($sd) == Util::lower(self::$srcDir)) if (Util::lower($sd) == Util::lower(self::$srcDir))
{ {
self::$srcDir = $sd.'/'; self::$srcDir = $sd.DIRECTORY_SEPARATOR;
break; break;
} }
} }
@@ -495,7 +492,7 @@ class CLISetup
foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST) as $path) foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST) as $path)
{ {
$_ = str_replace('\\', '/', $path->getPathname()); $_ = CLI::nicePath($path->getPathname());
self::$mpqFiles[strtolower($_)] = $_; self::$mpqFiles[strtolower($_)] = $_;
} }
@@ -521,7 +518,7 @@ class CLISetup
$_ = strtolower(CLI::nicePath($file)); $_ = strtolower(CLI::nicePath($file));
// remove trailing slash // remove trailing slash
if (mb_substr($_, -1, 1) == '/') if (mb_substr($_, -1, 1) == DIRECTORY_SEPARATOR)
$_ = mb_substr($_, 0, -1); $_ = mb_substr($_, 0, -1);
if (isset(self::$mpqFiles[$_])) if (isset(self::$mpqFiles[$_]))
@@ -569,7 +566,7 @@ class CLISetup
continue; continue;
if ($xp) // if in subDir add trailing slash if ($xp) // if in subDir add trailing slash
$xp .= '/'; $xp .= DIRECTORY_SEPARATOR;
$path = sprintf($pathPattern, $xp); $path = sprintf($pathPattern, $xp);
if (self::fileExists($path)) if (self::fileExists($path))
@@ -599,7 +596,7 @@ class CLISetup
continue; continue;
if ($xp) if ($xp)
$xp .= '/'; $xp .= DIRECTORY_SEPARATOR;
$gsFile = sprintf(self::GLOBALSTRINGS_LUA, self::$srcDir, $xp); $gsFile = sprintf(self::GLOBALSTRINGS_LUA, self::$srcDir, $xp);
if (self::fileExists($gsFile)) if (self::fileExists($gsFile))

View File

@@ -34,20 +34,20 @@ CLISetup::registerSetup("build", new class extends SetupScript
); );
private $genSteps = array( private $genSteps = array(
// srcPath, realPath, localized, [pattern, isIcon, tileSize, localized], [[dest, ext, srcSize, destSize, borderOffset]] // srcPath, realPath, localized, [pattern, isIcon, tileSize], [[dest, ext, srcSize, destSize, borderOffset]]
0 => ['Icons/', null, false, ['/.*\.(blp|png)$', true, 0], self::ICON_DIRS, ], 0 => ['Icons/', null, false, ['.*\.(blp|png)$', true, 0], self::ICON_DIRS, ],
1 => ['Spellbook/', null, false, ['/UI-Glyph-Rune-?\d+.(blp|png)$', false, 0], [['static/images/wow/Interface/Spellbook/', 'png', 0, 0, 0]]], 1 => ['Spellbook/', null, false, ['UI-Glyph-Rune-?\d+.(blp|png)$', false, 0], [['static/images/wow/Interface/Spellbook/', 'png', 0, 0, 0]]],
2 => ['PaperDoll/', null, false, ['/UI-(Backpack|PaperDoll)-.*\.(blp|png)$', true, 0], self::ICON_DIRS, ], 2 => ['PaperDoll/', null, false, ['UI-(Backpack|PaperDoll)-.*\.(blp|png)$', true, 0], self::ICON_DIRS, ],
3 => ['GLUES/CHARACTERCREATE/', null, false, ['/UI-CharacterCreate-Races.(blp|png)', true, 64], self::ICON_DIRS, ], 3 => ['GLUES/CHARACTERCREATE/', null, false, ['UI-CharacterCreate-Races\.(blp|png)', true, 64], self::ICON_DIRS, ],
4 => ['GLUES/CHARACTERCREATE/', null, false, ['/UI-CharacterCreate-CLASSES.(blp|png)', true, 64], self::ICON_DIRS, ], 4 => ['GLUES/CHARACTERCREATE/', null, false, ['UI-CharacterCreate-CLASSES\.(blp|png)', true, 64], self::ICON_DIRS, ],
5 => ['GLUES/CHARACTERCREATE/', null, false, ['/UI-CharacterCreate-Factions.(blp|png)', true, 64], self::ICON_DIRS, ], 5 => ['GLUES/CHARACTERCREATE/', null, false, ['UI-CharacterCreate-Factions\.(blp|png)', true, 64], self::ICON_DIRS, ],
// 6 => ['Minimap/' , null, false, ['/OBJECTICONS.(BLP|png)', true, 32], [['static/images/wow/icons/tiny/', 'gif', 0, 16, 2]]], // 6 => ['Minimap/' , null, false, ['OBJECTICONS.(BLP|png)', true, 32], [['static/images/wow/icons/tiny/', 'gif', 0, 16, 2]]],
7 => ['FlavorImages/', null, false, ['/.*\.(blp|png)$', false, 0], [['static/images/wow/Interface/FlavorImages/', 'png', 0, 0, 0]]], 7 => ['FlavorImages/', null, false, ['.*\.(blp|png)$', false, 0], [['static/images/wow/Interface/FlavorImages/', 'png', 0, 0, 0]]],
8 => ['Pictures/', null, false, ['/.*\.(blp|png)$', false, 0], [['static/images/wow/Interface/Pictures/', 'png', 0, 0, 0]]], 8 => ['Pictures/', null, false, ['.*\.(blp|png)$', false, 0], [['static/images/wow/Interface/Pictures/', 'png', 0, 0, 0]]],
9 => ['PvPRankBadges/', null, false, ['/.*\.(blp|png)$', false, 0], [['static/images/wow/Interface/PvPRankBadges/', 'png', 0, 0, 0]]], 9 => ['PvPRankBadges/', null, false, ['.*\.(blp|png)$', false, 0], [['static/images/wow/Interface/PvPRankBadges/', 'png', 0, 0, 0]]],
10 => ['Calendar/Holidays/', null, false, ['/.*(start|[ayhs])\.(blp|png)$', true, 0], self::ICON_DIRS, ], 10 => ['Calendar/Holidays/', null, false, ['.*(start|[ayhs])\.(blp|png)$', true, 0], self::ICON_DIRS, ],
11 => ['GLUES/LOADINGSCREENS/', null, false, ['/lo.*\.(blp|png)$', false, 0], [['cache/loadingscreens/', 'png', 0, 0, 0]]], 11 => ['GLUES/LOADINGSCREENS/', null, false, ['lo.*\.(blp|png)$', false, 0], [['cache/loadingscreens/', 'png', 0, 0, 0]]],
12 => ['PVPFrame/', null, false, ['/PVP-(ArenaPoints|Currency).*\.(blp|png)$', true, 0], self::ICON_DIRS, ] 12 => ['PVPFrame/', null, false, ['PVP-(ArenaPoints|Currency).*\.(blp|png)$', true, 0], self::ICON_DIRS, ]
); );
// textures are composed of 64x64 icons // textures are composed of 64x64 icons
@@ -148,10 +148,14 @@ CLISetup::registerSetup("build", new class extends SetupScript
if (!$groups) // by default do not generate loadingscreens if (!$groups) // by default do not generate loadingscreens
$groups = [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 12]; $groups = [0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 12];
// removed unused generators // removed unused generators and reset realPaths (in case of retry from failed attempt)
foreach ($this->genSteps as $idx => $_) foreach ($this->genSteps as $idx => $_)
{
if (!in_array($idx, $groups)) if (!in_array($idx, $groups))
unset($this->genSteps[$idx]); unset($this->genSteps[$idx]);
else
$this->genSteps[$idx][self::$GEN_IDX_SRC_REAL] = null;
}
if (!$this->checkSourceDirs()) if (!$this->checkSourceDirs())
{ {
@@ -164,9 +168,9 @@ CLISetup::registerSetup("build", new class extends SetupScript
$allPaths = []; $allPaths = [];
foreach ($this->genSteps as $i => [, $path, , [$pattern, $isIcon, $tileSize], $outInfo]) foreach ($this->genSteps as $i => [, $path, , [$pattern, $isIcon, $tileSize], $outInfo])
{ {
$search = $path.$pattern; $search = CLI::nicePath('', $path);
if ($pattern) if ($pattern)
$search = '/'.str_replace('/', '\\/', $search).'/i'; $search = '/'.strtr($search, ['\\' => '\\\\', '/' => '\\/']).$pattern.'/i';
$files = CLISetup::filesInPath($search, !!$pattern); $files = CLISetup::filesInPath($search, !!$pattern);
$allPaths = array_merge($allPaths, array_map(function ($x) { return substr($x, 0, -4); }, $files)); $allPaths = array_merge($allPaths, array_map(function ($x) { return substr($x, 0, -4); }, $files));
@@ -186,7 +190,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
ini_set('max_execution_time', $this->maxExecTime); ini_set('max_execution_time', $this->maxExecTime);
$src = null; $src = null;
$na = explode('/', $f); $na = explode(DIRECTORY_SEPARATOR, $f);
$img = explode('.', array_pop($na)); $img = explode('.', array_pop($na));
array_pop($img); // there are a hand full of images with multiple file endings or random dots in the name array_pop($img); // there are a hand full of images with multiple file endings or random dots in the name
$img = implode('.', $img); $img = implode('.', $img);
@@ -214,7 +218,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
foreach ($row as $x => $name) foreach ($row as $x => $name)
{ {
$j++; $j++;
$outFile = $dest.($isIcon ? strtolower($name) : $name).'.'.$ext; $outFile = CLI::nicePath(($isIcon ? strtolower($name) : $name).'.'.$ext, $dest);
$this->status = ' - '.str_pad($j.'/'.$nFiles, 12).str_pad('('.number_format($j * 100 / $nFiles, 2).'%)', 9); $this->status = ' - '.str_pad($j.'/'.$nFiles, 12).str_pad('('.number_format($j * 100 / $nFiles, 2).'%)', 9);
@@ -287,7 +291,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
{ {
$j++; $j++;
$this->status = ' - '.str_pad($j.'/'.$nFiles, 12).str_pad('('.number_format($j * 100 / $nFiles, 2).'%)', 9); $this->status = ' - '.str_pad($j.'/'.$nFiles, 12).str_pad('('.number_format($j * 100 / $nFiles, 2).'%)', 9);
$outFile = $dest.($isIcon ? strtolower($img) : $img).'.'.$ext; $outFile = CLI::nicePath(($isIcon ? strtolower($img) : $img).'.'.$ext, $dest);
if (!CLISetup::getOpt('force') && file_exists($outFile)) if (!CLISetup::getOpt('force') && file_exists($outFile))
{ {
@@ -341,7 +345,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
if ($itemIcons = DB::Aowow()->selectCol('SELECT `inventoryIcon1` FROM dbc_itemdisplayinfo WHERE `inventoryIcon1` <> ""')) if ($itemIcons = DB::Aowow()->selectCol('SELECT `inventoryIcon1` FROM dbc_itemdisplayinfo WHERE `inventoryIcon1` <> ""'))
foreach ($itemIcons as $icon) foreach ($itemIcons as $icon)
$dbcEntries[] = strtolower($this->genSteps[0][self::$GEN_IDX_SRC_REAL].'/'.$icon); $dbcEntries[] = strtolower($this->genSteps[0][self::$GEN_IDX_SRC_REAL].DIRECTORY_SEPARATOR.$icon);
} }
if (in_array(1, $gens)) // generates glyphs if (in_array(1, $gens)) // generates glyphs
@@ -353,7 +357,7 @@ CLISetup::registerSetup("build", new class extends SetupScript
if (in_array(10, $gens)) // generates holiday icons if (in_array(10, $gens)) // generates holiday icons
if ($eventIcons = DB::Aowow()->selectCol('SELECT `textureString` FROM dbc_holidays WHERE `textureString` <> ""')) if ($eventIcons = DB::Aowow()->selectCol('SELECT `textureString` FROM dbc_holidays WHERE `textureString` <> ""'))
foreach ($eventIcons as $icon) foreach ($eventIcons as $icon)
$dbcEntries[] = strtolower($this->genSteps[10][self::$GEN_IDX_SRC_REAL].'/'.$icon.'start'); $dbcEntries[] = strtolower($this->genSteps[10][self::$GEN_IDX_SRC_REAL].DIRECTORY_SEPARATOR.$icon.'start');
// case-insensitive array_unique *vomits silently into a corner* // case-insensitive array_unique *vomits silently into a corner*
$dbcEntries = array_intersect_key($dbcEntries, array_unique($dbcEntries)); $dbcEntries = array_intersect_key($dbcEntries, array_unique($dbcEntries));

View File

@@ -171,7 +171,7 @@ trait TrImageProcessor
if ($p = CLISetup::filesInPathLocalized($path, $this->success, $localized)) if ($p = CLISetup::filesInPathLocalized($path, $this->success, $localized))
{ {
$foundCache[$subDir] = $p; $foundCache[$subDir] = $p;
$this->genSteps[$i][self::$GEN_IDX_SRC_REAL] = $p; // pvp v7.3+ - make $realPaths areferene $this->genSteps[$i][self::$GEN_IDX_SRC_REAL] = $p; // php v8.2+ - make GEN_IDX_SRC_REAL a const
} }
else else
$this->success = false; $this->success = false;
@@ -192,10 +192,9 @@ trait TrImageProcessor
continue; continue;
$foundCache[$subDir] = true; $foundCache[$subDir] = true;
if (!$realPaths) if (!$realPaths)
{ {
CLI::write(CLI::red('MISSING').' - '.str_pad($subDir, 14).' @ '.sprintf($this->imgPath, '['.implode('/,', $locList).'/]').$subDir); CLI::write(CLI::red('MISSING').' - '.str_pad($subDir, $outTblLen).' @ '.sprintf($this->imgPath, '['.implode('/,', $locList).'/]').$subDir);
$this->success = false; $this->success = false;
} }
else if ($localized) else if ($localized)
@@ -203,13 +202,13 @@ trait TrImageProcessor
$foundLoc = []; $foundLoc = [];
foreach (CLISetup::$expectedPaths as $xp => $lId) foreach (CLISetup::$expectedPaths as $xp => $lId)
if (in_array($lId, array_keys(CLISetup::$locales))) if (in_array($lId, array_keys(CLISetup::$locales)))
if (isset($realPaths[$lId]) && ($n = stripos($realPaths[$lId], '/'.$xp.'/'))) if (isset($realPaths[$lId]) && ($n = stripos($realPaths[$lId], DIRECTORY_SEPARATOR.$xp.DIRECTORY_SEPARATOR)))
$foundLoc[$lId] = substr($realPaths[$lId], $n + 1, 4); $foundLoc[$lId] = substr($realPaths[$lId], $n + 1, 4);
if ($diff = array_diff_key(CLISetup::$locales, $foundLoc)) if ($diff = array_diff_key(CLISetup::$locales, $foundLoc))
{ {
$buff = []; $buff = [];
foreach ($diff as $d) foreach ($diff as $d => $_)
$buff[] = CLI::red(Util::$localeStrings[$d]); $buff[] = CLI::red(Util::$localeStrings[$d]);
foreach ($foundLoc as $str) foreach ($foundLoc as $str)
$buff[] = CLI::green($str); $buff[] = CLI::green($str);
@@ -227,7 +226,7 @@ trait TrImageProcessor
// if not localized directly return result // if not localized directly return result
foreach ($this->genSteps as $i => [$subDir, $realPaths, $localized, , ]) foreach ($this->genSteps as $i => [$subDir, $realPaths, $localized, , ])
if (!$localized) if (!$localized && $realPaths)
$this->genSteps[$i][self::$GEN_IDX_SRC_REAL] = reset($realPaths); $this->genSteps[$i][self::$GEN_IDX_SRC_REAL] = reset($realPaths);
return $this->success; return $this->success;
@@ -466,7 +465,7 @@ abstract class SetupScript
$dirs[] = $dir; $dirs[] = $dir;
else else
foreach (CLISetup::$locales as $str) foreach (CLISetup::$locales as $str)
$dirs[] = $dir . $str . '/'; $dirs[] = $dir . $str . DIRECTORY_SEPARATOR;
foreach ($dirs as $d) foreach ($dirs as $d)
{ {