fix: Fixes invalid professions. (#1882)

This commit is contained in:
Kamron Batman 2024-07-22 20:15:24 -07:00 • committed by GitHub
parent e41d35d3d7
commit 0a07109cc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 133 additions and 131 deletions

View file

@ -1,12 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
namespace Server;
public class ProfessionInfo
{
public static ProfessionInfo[] Professions { get; }
private static readonly ProfessionInfo[] _professions;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool VerifyProfession(int profIndex) =>
profIndex >= 0 && profIndex < _professions.Length;
public static bool GetProfession(int profIndex, out ProfessionInfo profession)
{
if (!VerifyProfession(profIndex))
{
profession = null;
return false;
}
return (profession = _professions[profIndex - 1]) != null;
}
private static bool TryGetSkillName(string name, out SkillName skillName)
{
@ -177,11 +193,11 @@ public class ProfessionInfo
}
}
Professions = new ProfessionInfo[1 + maxProf];
_professions = new ProfessionInfo[maxProf];
foreach (var p in profs)
{
Professions[p.ID] = p;
_professions[p.ID - 1] = p;
}
profs.Clear();