Fix companion identification, extract offsets and vtable indices to separate file.

This commit is contained in:
Ottermandias 2023-01-16 13:02:22 +01:00
parent 79eee0e2c7
commit 4059e0630a
9 changed files with 60 additions and 22 deletions

View file

@ -204,7 +204,7 @@ public sealed partial class ActorManager : IDisposable
if (agent == null || agent->Data == null)
return ActorIdentifier.Invalid;
var worldId = *(ushort*)((byte*)agent->Data + 0xC0);
var worldId = *(ushort*)((byte*)agent->Data + Offsets.AgentCharaCardDataWorldId);
return CreatePlayer(new ByteString(agent->Data->Name.StringPtr), worldId);
}

View file

@ -306,7 +306,7 @@ public partial class ActorManager
{
var dataId = actor->DataID;
// Special case for squadron that is also in the game functions, cf. E8 ?? ?? ?? ?? 89 87 ?? ?? ?? ?? 4C 89 BF
if (dataId == 0xf845d)
if (dataId == 0xF845D)
dataId = actor->GetNpcID();
if (MannequinIds.Contains(dataId))
{
@ -338,7 +338,7 @@ public partial class ActorManager
if (owner == null)
return ActorIdentifier.Invalid;
var dataId = GetCompanionId(actor, owner);
var dataId = GetCompanionId(actor, (Character*) owner);
var name = new ByteString(owner->Name);
var homeWorld = ((Character*)owner)->HomeWorld;
return check
@ -365,13 +365,13 @@ public partial class ActorManager
/// Obtain the current companion ID for an object by its actor and owner.
/// </summary>
private unsafe uint GetCompanionId(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* actor,
FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject* owner) // TODO: CS Update
Character* owner) // TODO: CS Update
{
return (ObjectKind)actor->ObjectKind switch
{
ObjectKind.MountType => *(ushort*)((byte*)owner + 0x650 + 0x18),
(ObjectKind)15 => *(ushort*)((byte*)owner + 0x860 + 0x18),
ObjectKind.Companion => *(ushort*)((byte*)actor + 0x1AAC),
ObjectKind.MountType => owner->Mount.MountId,
(ObjectKind)15 => owner->Ornament.OrnamentId,
ObjectKind.Companion => actor->DataID,
_ => actor->DataID,
};
}

View file

@ -400,17 +400,17 @@ internal sealed class ObjectIdentification : DataSharer, IObjectIdentifier
public static unsafe ulong KeyFromCharacterBase(CharacterBase* drawObject)
{
var type = (*(delegate* unmanaged<CharacterBase*, uint>**)drawObject)[50](drawObject);
var unk = (ulong)*((byte*)drawObject + 0x8E8) << 8;
var type = (*(delegate* unmanaged<CharacterBase*, uint>**)drawObject)[Offsets.DrawObjectGetModelTypeVfunc](drawObject);
var unk = (ulong)*((byte*)drawObject + Offsets.DrawObjectModelUnk1) << 8;
return type switch
{
1 => type | unk,
2 => type | unk | ((ulong)*(ushort*)((byte*)drawObject + 0x908) << 16),
2 => type | unk | ((ulong)*(ushort*)((byte*)drawObject + Offsets.DrawObjectModelUnk3) << 16),
3 => type
| unk
| ((ulong)*(ushort*)((byte*)drawObject + 0x8F0) << 16)
| ((ulong)**(ushort**)((byte*)drawObject + 0x910) << 32)
| ((ulong)**(ushort**)((byte*)drawObject + 0x910) << 40),
| ((ulong)*(ushort*)((byte*)drawObject + Offsets.DrawObjectModelUnk2) << 16)
| ((ulong)**(ushort**)((byte*)drawObject + Offsets.DrawObjectModelUnk4) << 32)
| ((ulong)**(ushort**)((byte*)drawObject + Offsets.DrawObjectModelUnk3) << 40),
_ => 0u,
};
}

View file

@ -0,0 +1,35 @@
namespace Penumbra.GameData;
public static class Offsets
{
// ActorManager.Data
public const int AgentCharaCardDataWorldId = 0xC0;
// ObjectIdentification
public const int DrawObjectGetModelTypeVfunc = 50;
private const int DrawObjectModelBase = 0x8E8;
public const int DrawObjectModelUnk1 = DrawObjectModelBase;
public const int DrawObjectModelUnk2 = DrawObjectModelBase + 0x08;
public const int DrawObjectModelUnk3 = DrawObjectModelBase + 0x20;
public const int DrawObjectModelUnk4 = DrawObjectModelBase + 0x28;
// PathResolver.AnimationState
public const int GetGameObjectIdxVfunc = 28;
public const int TimeLinePtr = 0x50;
// PathResolver.Meta
public const int UpdateModelSkip = 0x90c;
public const int GetEqpIndirectSkip1 = 0xA30;
public const int GetEqpIndirectSkip2 = 0xA28;
// FontReloader
public const int ReloadFontsVfunc = 43;
// ObjectReloader
public const int EnableDrawVfunc = 16;
public const int DisableDrawVfunc = 17;
// ResourceHandle
public const int ResourceHandleGetDataVfunc = 23;
public const int ResourceHandleGetLengthVfunc = 17;
}