Skip to content

Commit 0021238

Browse files
committed
Create CharacterSubJobFlagType
1 parent 1734f82 commit 0021238

File tree

3 files changed

+61
-6
lines changed

3 files changed

+61
-6
lines changed

MapleLib/WzLib/Util/WzBinaryReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private string DecodeUnicode(int length)
154154
/// <param name="length"></param>
155155
/// <returns></returns>
156156
[MethodImpl(MethodImplOptions.AggressiveInlining)]
157-
private unsafe string DecodeAscii(int length)
157+
private string DecodeAscii(int length)
158158
{
159159
Span<byte> bytes = length <= STACKALLOC_SIZE_LIMIT_L1 ? stackalloc byte[length] : new byte[length];
160160
byte mask = 0xAA;

MapleLib/WzLib/WzStructure/Data/CharacterStructure/CharacterClassTypeInfo.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using MapleLib.ClientLib;
22
using MapleLib.WzLib.WzStructure.Data.ItemStructure;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
83

94
namespace MapleLib.WzLib.WzStructure.Data.CharacterStructure
105
{
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using MapleLib.WzLib.WzStructure.Data.QuestStructure;
2+
using System;
3+
namespace MapleLib.WzLib.WzStructure.Data.CharacterStructure
4+
{
5+
/// <summary>
6+
/// Its the best guess so far, could not find it in KMST.
7+
/// </summary>
8+
public enum CharacterSubJobFlagType
9+
{
10+
Any = 0,
11+
Adventurer = 1,
12+
Adventurer_DualBlade = 2,
13+
}
14+
15+
public static class CharacterSubJobFlagTypeExt
16+
{
17+
/// <summary>
18+
/// Human readable string
19+
/// </summary>
20+
/// <param name="state"></param>
21+
/// <returns></returns>
22+
public static string ToReadableString(this CharacterSubJobFlagType state)
23+
{
24+
return state.ToString().Replace("_", " ");
25+
}
26+
27+
/// <summary>
28+
/// Converts from the string name back to enum
29+
/// </summary>
30+
/// <param name="name"></param>
31+
/// <returns></returns>
32+
public static CharacterSubJobFlagType ToEnum(this string name)
33+
{
34+
// Try to parse the string to enum
35+
if (Enum.TryParse<CharacterSubJobFlagType>(name.Replace(" ", "_"), out CharacterSubJobFlagType result))
36+
{
37+
return (CharacterSubJobFlagType)result;
38+
}
39+
return CharacterSubJobFlagType.Any;
40+
}
41+
42+
/// <summary>
43+
/// Converts from the area code value to enum type
44+
/// </summary>
45+
/// <param name="value"></param>
46+
/// <returns></returns>
47+
public static CharacterSubJobFlagType ToEnum(int value)
48+
{
49+
if (Enum.IsDefined(typeof(CharacterSubJobFlagType), value))
50+
{
51+
return (CharacterSubJobFlagType)value;
52+
}
53+
else
54+
{
55+
//Console.WriteLine($"Warning: Invalid CharacterSubJobFlagTypeExt value {value}. Defaulting to Any.");
56+
return CharacterSubJobFlagType.Any;
57+
}
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)