From 0c4edf625c371a809f6fd182469c278e6a2c355f Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 4 Jan 2026 15:30:23 +0100 Subject: [PATCH] Fix for servers with promotion column (mostly tfs 0.3+) --- admin/pages/players.php | 24 ++++++++++++++++++++++++ system/src/Server/XML/Vocations.php | 10 +++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/admin/pages/players.php b/admin/pages/players.php index bd3ab713..17e8f7d1 100644 --- a/admin/pages/players.php +++ b/admin/pages/players.php @@ -10,6 +10,7 @@ use MyAAC\Forum; use MyAAC\Models\Player; +use MyAAC\Server\XML\Vocations; defined('MYAAC') or die('Direct access not allowed!'); @@ -237,7 +238,30 @@ else if (isset($_REQUEST['search'])) { $player->setGroup($groups->getGroup($group)); $player->setLevel($level); $player->setExperience($experience); + + if ($db->hasColumn('players', 'promotion')) { + $promotion = 0; + + $vocationOriginal = Vocations::getOriginal($vocation); + if ($vocation != $vocationOriginal) { + $tmpId = $vocationOriginal; + while($promoted = Vocations::getPromoted($tmpId)) { + $promotion++; + + $tmpId = $promoted; + if ($promoted == $vocation) { + break; + } + } + + $vocation = $vocationOriginal; + } + + $player->setPromotion($promotion); + } + $player->setVocation($vocation); + $player->setHealth($health); $player->setHealthMax($health_max); $player->setMagLevel($magic_level); diff --git a/system/src/Server/XML/Vocations.php b/system/src/Server/XML/Vocations.php index 6bd8f357..ff90ece8 100644 --- a/system/src/Server/XML/Vocations.php +++ b/system/src/Server/XML/Vocations.php @@ -77,7 +77,15 @@ class Vocations } public static function getOriginal(int $id): ?int { - return self::$vocationsFrom[$id] ?? null; + while ($tmpId = self::$vocationsFrom[$id]) { + if ($tmpId == $id) { + break; + } + + $id = $tmpId; + } + + return $id; } public static function getBase($includingRook = true): array {