Profiler/Fixup

* profiler expects teamId, not sideId
   (yes i know they are basically the same thing offset by 1!)
This commit is contained in:
Sarjuuk
2025-03-06 01:58:37 +01:00
parent c712d1234b
commit 3b0d288418
2 changed files with 30 additions and 1 deletions

View File

@@ -510,7 +510,7 @@ class AjaxProfile extends AjaxHandler
'level' => $pBase['level'],
'classs' => $pBase['class'],
'race' => $pBase['race'],
'faction' => ChrRace::tryFrom($pBase['race'])?->getSide() ?? SIDE_NONE,
'faction' => ChrRace::tryFrom($pBase['race'])?->getTeam() ?? TEAM_NEUTRAL,
'gender' => $pBase['gender'],
'skincolor' => $pBase['skincolor'],
'hairstyle' => $pBase['hairstyle'],

View File

@@ -487,6 +487,18 @@ enum ChrRace : int
return SIDE_NONE;
}
public function getTeam() : int
{
if ($this->isHorde() && $this->isAlliance())
return TEAM_NEUTRAL;
else if ($this->isHorde())
return TEAM_HORDE;
else if ($this->isAlliance())
return TEAM_ALLIANCE;
else
return TEAM_NEUTRAL;
}
public function json() : string
{
return match ($this)
@@ -530,6 +542,23 @@ enum ChrRace : int
return SIDE_BOTH;
}
public static function teamFromMask(int $raceMask) : int
{
// Any
if (!$raceMask || ($raceMask & self::MASK_ALL) == self::MASK_ALL)
return TEAM_NEUTRAL;
// Horde
if ($raceMask & self::MASK_HORDE && !($raceMask & self::MASK_ALLIANCE))
return TEAM_HORDE;
// Alliance
if ($raceMask & self::MASK_ALLIANCE && !($raceMask & self::MASK_HORDE))
return TEAM_ALLIANCE;
return TEAM_NEUTRAL;
}
}
// SpellFamilyNames