diff --git a/includes/components/profiler.class.php b/includes/components/profiler.class.php index d7b1a621..a12726e9 100644 --- a/includes/components/profiler.class.php +++ b/includes/components/profiler.class.php @@ -743,14 +743,7 @@ class Profiler DB::Aowow()->query('DELETE FROM ?_profiler_completion_titles WHERE `id` = ?d', $profileId); - $tBlocks = explode(' ', $char['knownTitles']); - $indizes = []; - for ($i = 0; $i < 6; $i++) - for ($j = 0; $j < 32; $j++) - if ($tBlocks[$i] & (1 << $j)) - $indizes[] = $j + ($i * 32); - - if ($indizes) + if ($indizes = Util::indexBitBlob($char['knownTitles'])) DB::Aowow()->query('INSERT INTO ?_profiler_completion_titles SELECT ?d, `id` FROM ?_titles WHERE `bitIdx` IN (?a)', $profileId, $indizes); CLI::write(' ..titles'); diff --git a/includes/dbtypes/skill.class.php b/includes/dbtypes/skill.class.php index ab361031..2f18cd69 100644 --- a/includes/dbtypes/skill.class.php +++ b/includes/dbtypes/skill.class.php @@ -29,11 +29,7 @@ class SkillList extends DBTypeList if (!$_) $_ = [0, 0, 0, 0, 0]; else - { - $_ = explode(' ', $_); - while (count($_) < 5) - $_[] = 0; - } + $_ = array_pad(explode(' ', $_), 5, 0); if (!$_curTpl['iconId']) $_curTpl['iconString'] = DEFAULT_ICON; diff --git a/includes/utilities.php b/includes/utilities.php index 181e9fb8..9022610f 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -1051,6 +1051,18 @@ abstract class Util return $bits; } + public static function indexBitBlob(string $bitBlob, int $blobSize = 32) : array + { + $indizes = []; + $blocks = explode(' ', $bitBlob); + for ($i = 0; $i < count($blocks); $i++) + for ($j = 0; $j < $blobSize; $j++) + if ($blocks[$i] & (1 << $j)) + $indizes[] = $j + ($i * $blobSize); + + return $indizes; + } + public static function toString(mixed $var) : string { if (is_array($var))