Skip to content

Commit d0362cc

Browse files
committed
Merge branch 'main' into cn
2 parents 39a6233 + 9d47332 commit d0362cc

93 files changed

Lines changed: 43651 additions & 12250 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CExporter/Exporter.cs

Lines changed: 142 additions & 50 deletions
Large diffs are not rendered by default.

CExporter/ExporterStatics.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ public static Type[] GetHavokTypes() {
4848

4949
return definedTypes.Where(t => t.FullName!.StartsWith(HavokNamespacePrefix) && !t.FullName.EndsWith("VirtualTable") && t.GetCustomAttribute<CExporterIgnoreAttribute>() == null).ToArray();
5050
}
51+
52+
public static Type GetBestMatchFromSize(int size) => size switch {
53+
< 9 => typeof(byte),
54+
< 17 => typeof(ushort),
55+
< 33 => typeof(uint),
56+
_ => typeof(ulong)
57+
};
5158
}
5259

5360
internal class CExporterUnionCompare : IEqualityComparer<CExporterUnionAttribute> {

CExporter/Extensions.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ public static bool IsFieldInType(this Type type, FieldInfo field) {
7373
return type.GetFields(ExporterStatics.BindingFlags).Any(f => f.Name == name && f.FieldType == field.FieldType) || type.GetFields(ExporterStatics.BindingFlags).Any(f => f.Name == field.Name && f.FieldType == field.FieldType);
7474
}
7575

76-
public static bool IsDirectBase(this FieldInfo field) {
77-
var bases = field.DeclaringType?.GetInheritsTypes() ?? [];
78-
return bases.Any(b => field.FieldType == b && field.Name == (b.Name == field.DeclaringType?.Name ? b.Name + "Base" : b.Name)) || field.GetCustomAttribute<CExporterBaseTypeAttribute>() != null;
79-
}
80-
8176
public static string FixTypeName(this Type type, bool shouldLower = true) {
8277
using var builderPooled = StringBuilderPool.Get(500);
8378
var builder = builderPooled.Builder;
@@ -211,8 +206,6 @@ public static string SanitizeName(this Type type) {
211206
return builder.ToString();
212207
}
213208

214-
public static string FullSanitizeName(this Type type) => type.FixTypeName();
215-
216209
public static int PackSize(this Type type) {
217210
if (type.GetCustomAttribute<FixedSizeArrayAttribute>() != null) return 1; // FixedSizeArrayAttribute is always packed to 1 as the generated struct gets generated with Pack = 1
218211
if (!type.IsStruct()) return type.SizeOf();
@@ -223,7 +216,7 @@ public static int PackSize(this Type type) {
223216
}
224217

225218
public static bool IsInStructList(this Type type, List<ProcessedStruct> structs) {
226-
var name = type.FullSanitizeName();
219+
var name = type.FixTypeName();
227220
foreach (var str in structs) {
228221
if (str.StructTypeName == name) return true;
229222
}
@@ -256,6 +249,15 @@ public static int GetFieldOffsetSequential(this FieldInfo info) {
256249
}
257250
throw new Exception("Field not found");
258251
}
252+
253+
public static bool IsDirectBase(this FieldInfo field) {
254+
var bases = field.DeclaringType?.GetInheritsTypes() ?? [];
255+
return bases.Any(b => field.FieldType == b && field.Name == (b.Name == field.DeclaringType?.Name ? b.Name + "Base" : b.Name)) || field.GetCustomAttribute<CExporterBaseTypeAttribute>() != null;
256+
}
257+
258+
public static bool IsBitArray(this FieldInfo type) {
259+
return type.GetCustomAttributes().Any(t => t.GetType().Name.Contains("BitFieldAttribute`1"));
260+
}
259261
}
260262
public static class Extensions {
261263
public static void WriteFile(this FileInfo file, string content) {

FFXIVClientStructs/FFXIV/Application/Network/WorkDefinitions/ClientSelectData.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public partial struct ClientSelectData {
4444
[Flags]
4545
public enum ClientSelectDataConfigFlags : ushort {
4646
None = 0,
47-
HideHead = 0x01,
48-
HideWeapon = 0x02,
49-
HideLegacyMark = 0x04,
50-
// ? = 0x08,
51-
StoreNewItemsInArmouryChest = 0x10,
52-
StoreCraftedItemsInInventory = 0x20,
53-
CloseVisor = 0x40,
54-
HideVieraEars = 0x80
47+
HideHead = 1 << 0,
48+
HideWeapon = 1 << 1,
49+
HideLegacyMark = 1 << 2,
50+
// ? = 1 << 3,
51+
StoreNewItemsInArmouryChest = 1 << 4,
52+
StoreCraftedItemsInInventory = 1 << 5,
53+
CloseVisor = 1 << 6,
54+
HideVieraEars = 1 << 7,
5555
}

FFXIVClientStructs/FFXIV/Application/Network/WorkDefinitions/DailyQuestWork.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
77
[StructLayout(LayoutKind.Explicit, Size = 0x10)]
88
public partial struct DailyQuestWork {
99
[FieldOffset(0x08)] public ushort QuestId;
10+
[BitField<bool>(nameof(IsCompleted), 0)]
1011
[FieldOffset(0x0A)] public byte Flags;
11-
12-
public bool IsCompleted => (Flags & 1) != 0;
1312
}

FFXIVClientStructs/FFXIV/Application/Network/WorkDefinitions/LeveWork.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ namespace FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
88
public partial struct LeveWork {
99
[FieldOffset(0x08)] public ushort LeveId;
1010
[FieldOffset(0x0A)] public byte Sequence;
11+
[BitField<bool>(nameof(IsHidden), 14)]
12+
[BitField<bool>(nameof(IsPriority), 15)]
1113
[FieldOffset(0x0C)] public ushort Flags;
1214
[FieldOffset(0x0E)] public ushort LeveSeed;
1315
[FieldOffset(0x10)] public byte ClearClass;
14-
15-
public bool IsHidden => (Flags & 0x4000) != 0;
16-
public bool IsPriority => (Flags & 0x8000) != 0;
1716
}

FFXIVClientStructs/FFXIV/Application/Network/WorkDefinitions/QuestWork.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ namespace FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
88
public unsafe partial struct QuestWork {
99
[FieldOffset(0x08)] public ushort QuestId;
1010
[FieldOffset(0x0A)] public byte Sequence;
11+
[BitField<bool>(nameof(IsPriority), 0)]
12+
[BitField<int>(nameof(RewardItemArrayIndex), 1, 2)]
13+
[BitField<bool>(nameof(IsHidden), 3)]
1114
[FieldOffset(0x0B)] public byte Flags;
1215
[FieldOffset(0x0C), FixedSizeArray] internal FixedSizeArray6<byte> _variables;
1316
[FieldOffset(0x12)] public byte AcceptClassJob;
14-
15-
public int RewardItemArrayIndex => Flags >> 1 & 3;
16-
public bool IsHidden => (Flags & 8) != 0;
17-
public bool IsPriority => (Flags & 1) != 0;
1817
}

FFXIVClientStructs/FFXIV/Client/Game/Character/ActionEffectHandler.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ public partial struct TargetEffects {
4949
/// <summary>
5050
/// Global result of a single action. Used in combination with target data: a list of GameObjectId's and sets of Effect's.
5151
/// </summary>
52+
[GenerateInterop]
5253
[StructLayout(LayoutKind.Explicit, Size = 0x28)]
53-
public struct Header {
54+
public partial struct Header {
5455
[FieldOffset(0x00)] public GameObjectId AnimationTargetId; // 'primary' target of the action; animation is played on this object
5556
[FieldOffset(0x08)] public uint ActionId;
5657
[FieldOffset(0x0C)] public uint GlobalSequence; // unique id of the action, monotonously increasing as the server is running
@@ -61,11 +62,16 @@ public struct Header {
6162
[FieldOffset(0x1C)] public ushort SpellId;
6263
[FieldOffset(0x1E)] public byte AnimationVariation;
6364
[FieldOffset(0x1F)] public byte ActionType;
65+
[BitField<bool>(nameof(ShowInLog), 0)]
66+
[BitField<bool>(nameof(ForceAnimationLock), 1)]
6467
[FieldOffset(0x20)] public byte Flags;
6568
[FieldOffset(0x21)] public byte NumTargets;
6669

67-
public bool ShowInLog => (Flags & 1) != 0; // if this flag is set, the message will be printed to the action log when processing the action
68-
public bool ForceAnimationLock => (Flags & 2) != 0; // if this flag is set, the animation lock is applied to caster even though SourceSequence == 0
70+
/// <remarks> If this flag is set, the message will be printed to the action log when processing the action. </remarks>
71+
public partial bool ShowInLog { get; set; }
72+
73+
/// <remarks> If this flag is set, the animation lock is applied to caster even though <c>SourceSequence == 0</c>. </remarks>
74+
public partial bool ForceAnimationLock { get; set; }
6975
}
7076

7177
/// <summary>

FFXIVClientStructs/FFXIV/Client/Game/Character/Character.cs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ namespace FFXIVClientStructs.FFXIV.Client.Game.Character;
1212
[VirtualTable("48 8D 05 ?? ?? ?? ?? 48 89 07 48 8D 8F ?? ?? ?? ?? 48 8D 05 ?? ?? ?? ?? 48 89 87 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8D 8F ?? ?? ?? ?? 33 ED 48 8D 05 ?? ?? ?? ??", 3)]
1313
public unsafe partial struct Character {
1414
[FieldOffset(0x600)] public MovementStateOptions MovementState;
15-
/// <summary>
16-
/// <code>
17-
/// 0b0010_0000 [0x20] = <see cref="IsSwimming"/>
18-
/// </code>
19-
/// </summary>
15+
[BitField<bool>(nameof(IsSwimming), 5)] // found in Client::Game::Event::EventSceneModuleUsualImpl.IsSwimming
2016
[FieldOffset(0x628)] public byte Flags628;
2117

2218
[FieldOffset(0x630)] public EmoteController EmoteController;
@@ -28,7 +24,7 @@ public unsafe partial struct Character {
2824
[FieldOffset(0xA30)] public TimelineContainer Timeline;
2925
[FieldOffset(0xD80)] public LookAtContainer LookAt;
3026

31-
// 0x01 = OffhandDrawn
27+
[BitField<bool>(nameof(IsOffhandDrawn), 0)]
3228
[FieldOffset(0x1980)] public byte WeaponFlags;
3329
[FieldOffset(0x1988)] public VfxContainer Vfx;
3430

@@ -38,15 +34,16 @@ public unsafe partial struct Character {
3834
// 0x1AA8: start of some substructure
3935
[FieldOffset(0x1B28)] public ModelContainer ModelContainer;
4036

41-
// 0x01 = PartyMember
42-
// 0x02 = AllianceMember
43-
// 0x04 = Friend
37+
[BitField<bool>(nameof(IsPartyMember), 0)]
38+
[BitField<bool>(nameof(IsAllianceMember), 1)]
39+
[BitField<bool>(nameof(IsFriend), 2)]
4440
[FieldOffset(0x1CE2)] public byte RelationFlags;
4541

4642
// 0x40 = All attacks will be cancelled, character is doing the the 'winded' emote, used in e.g. 'Strange Bedfellows' and 'Combat Evolved' when quest expects an item to be used on the character
4743
[FieldOffset(0x1CE8)] public byte ActorControlFlags;
4844

4945
[FieldOffset(0x21E0)] public Balloon Balloon;
46+
[FieldOffset(0x2260)] public NpcYellBalloon YellBalloon;
5047

5148
[FieldOffset(0x22E8)] public float Alpha;
5249

@@ -85,15 +82,13 @@ public unsafe partial struct Character {
8582
[FieldOffset(0x2365)] public byte ModeParam; // Different purpose depending on mode. See CharacterModes for more info.
8683
[FieldOffset(0x2366)] public byte GMRank;
8784

88-
public bool IsSwimming => (Flags628 & 0x20) != 0; // found in Client::Game::Event::EventSceneModuleUsualImpl.IsSwimming
89-
public bool IsWeaponDrawn => (Timeline.Flags3 & 0x40) != 0;
90-
public bool IsOffhandDrawn => (WeaponFlags & 0x1) != 0;
91-
public bool InCombat => (CharacterData.Flags & 0x2) != 0;
92-
public bool IsHostile => (CharacterData.Flags & 0x1) != 0;
93-
public bool IsCasting => GetCastInfo() != null && GetCastInfo()->IsCasting;
94-
public bool IsPartyMember => (RelationFlags & 0x1) != 0;
95-
public bool IsAllianceMember => (RelationFlags & 0x2) != 0;
96-
public bool IsFriend => (RelationFlags & 0x4) != 0;
85+
/// <remarks> See <see cref="Sound.SoundVolumeCategory"/>. </remarks>
86+
[FieldOffset(0x2369)] public byte SoundVolumeCategory;
87+
[FieldOffset(0x236A)] public byte SoundVolumeCategoryOverride;
88+
[FieldOffset(0x236B)] private byte SoundFlags; // 0x40 = SoundVolumeCategory determined
89+
90+
public bool IsWeaponDrawn => Timeline.IsWeaponDrawn;
91+
public bool IsCasting => VirtualTable != null && GetCastInfo() is var info && info != null && info->IsCasting;
9792

9893
/// <summary>
9994
/// Gets the (hard) target ID for this character. If this character is the LocalPlayer, this will instead read the

FFXIVClientStructs/FFXIV/Client/Game/Character/CharacterData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public unsafe partial struct CharacterData {
2828
[FieldOffset(0x30)] public byte OnlineStatus;
2929
[FieldOffset(0x31)] public byte Battalion; // used for determining friend/enemy state
3030

31-
// 0x01 = IsHostile
32-
// 0x02 = InCombat
31+
[BitField<bool>(nameof(IsHostile), 0)]
32+
[BitField<bool>(nameof(InCombat), 1)]
3333
[FieldOffset(0x34)] public byte Flags;
3434

3535
/// <summary>

0 commit comments

Comments
 (0)