fix: Fixes invalid professions. (#1882)
This commit is contained in:
parent
e41d35d3d7
commit
0a07109cc1
4 changed files with 133 additions and 131 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue