Skip to content

Commit

Permalink
Create CharacterSubJobFlagType
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Oct 26, 2024
1 parent 1734f82 commit 0021238
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MapleLib/WzLib/Util/WzBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private string DecodeUnicode(int length)
/// <param name="length"></param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe string DecodeAscii(int length)
private string DecodeAscii(int length)
{
Span<byte> bytes = length <= STACKALLOC_SIZE_LIMIT_L1 ? stackalloc byte[length] : new byte[length];
byte mask = 0xAA;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using MapleLib.ClientLib;
using MapleLib.WzLib.WzStructure.Data.ItemStructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MapleLib.WzLib.WzStructure.Data.CharacterStructure
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using MapleLib.WzLib.WzStructure.Data.QuestStructure;
using System;
namespace MapleLib.WzLib.WzStructure.Data.CharacterStructure
{
/// <summary>
/// Its the best guess so far, could not find it in KMST.
/// </summary>
public enum CharacterSubJobFlagType
{
Any = 0,
Adventurer = 1,
Adventurer_DualBlade = 2,
}

public static class CharacterSubJobFlagTypeExt
{
/// <summary>
/// Human readable string
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
public static string ToReadableString(this CharacterSubJobFlagType state)
{
return state.ToString().Replace("_", " ");
}

/// <summary>
/// Converts from the string name back to enum
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static CharacterSubJobFlagType ToEnum(this string name)
{
// Try to parse the string to enum
if (Enum.TryParse<CharacterSubJobFlagType>(name.Replace(" ", "_"), out CharacterSubJobFlagType result))
{
return (CharacterSubJobFlagType)result;
}
return CharacterSubJobFlagType.Any;
}

/// <summary>
/// Converts from the area code value to enum type
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static CharacterSubJobFlagType ToEnum(int value)
{
if (Enum.IsDefined(typeof(CharacterSubJobFlagType), value))
{
return (CharacterSubJobFlagType)value;
}
else
{
//Console.WriteLine($"Warning: Invalid CharacterSubJobFlagTypeExt value {value}. Defaulting to Any.");
return CharacterSubJobFlagType.Any;
}
}
}
}

0 comments on commit 0021238

Please sign in to comment.