Improve lobby handling so it doesn't spam errors anymore
This commit is contained in:
@@ -3,11 +3,13 @@ using Dalamud.Game.ClientState.Objects;
|
|||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using OtterGui.Log;
|
using OtterGui.Log;
|
||||||
using Penumbra.GameData.Actors;
|
using Penumbra.GameData.Actors;
|
||||||
using Penumbra.GameData.Enums;
|
using Penumbra.GameData.Enums;
|
||||||
using Penumbra.GameData.Interop;
|
using Penumbra.GameData.Interop;
|
||||||
|
using Penumbra.GameData.Structs;
|
||||||
using Penumbra.String;
|
using Penumbra.String;
|
||||||
|
|
||||||
namespace CustomizePlus.GameData.Services;
|
namespace CustomizePlus.GameData.Services;
|
||||||
@@ -84,7 +86,7 @@ public class ObjectManager(
|
|||||||
IsInGPose = gPose.Utf8Name.Length > 0;
|
IsInGPose = gPose.Utf8Name.Length > 0;
|
||||||
|
|
||||||
//C+ custom
|
//C+ custom
|
||||||
IsInLobby = AddLobbyCharacter();
|
IsInLobby = AddLobbyCharacters();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -136,10 +138,6 @@ public class ObjectManager(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//c+ custom
|
|
||||||
public Actor LobbyActor
|
|
||||||
=> IsInLobby ? this[200] : nint.Zero;
|
|
||||||
|
|
||||||
public Actor GPosePlayer
|
public Actor GPosePlayer
|
||||||
=> this[(int)ScreenActor.GPosePlayer];
|
=> this[(int)ScreenActor.GPosePlayer];
|
||||||
|
|
||||||
@@ -218,22 +216,32 @@ public class ObjectManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//c+ custom
|
//c+ custom
|
||||||
private unsafe bool AddLobbyCharacter()
|
private unsafe bool AddLobbyCharacters()
|
||||||
{
|
{
|
||||||
var agent = AgentLobby.Instance();
|
var agent = AgentLobby.Instance();
|
||||||
if (agent == null || agent->LobbyData.CharaSelectEntries.LongCount() == 0)
|
if (agent == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var chara = agent->LobbyData.CharaSelectEntries[(long)agent->SelectedCharacterContentId].Value;
|
var span = agent->LobbyData.CharaSelectEntries.AsSpan();
|
||||||
if (chara == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var actor = CutsceneCharacters.FirstOrDefault();
|
// The lobby uses the first 8 cutscene actors.
|
||||||
|
int cnt = 0;
|
||||||
|
foreach (var actor in CutsceneCharacters.Take(8))
|
||||||
|
{
|
||||||
|
if (!actor.Valid) //shouldn't happen so should be safe to break?
|
||||||
|
break;
|
||||||
|
|
||||||
if (!actor.Valid)
|
if (cnt >= span.Length)
|
||||||
return false;
|
break;
|
||||||
|
|
||||||
HandleIdentifier(actors.CreatePlayer(new ByteString(chara->Name), chara->HomeWorldId), actor);
|
if (span[cnt].Value == null) //should mean the end of valid actors so should be safe to break?
|
||||||
|
break;
|
||||||
|
|
||||||
|
var chara = span[cnt].Value;
|
||||||
|
HandleIdentifier(actors.CreatePlayer(new ByteString(chara->Name), chara->HomeWorldId), actor);
|
||||||
|
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -487,10 +487,7 @@ public class ProfileManager : IDisposable
|
|||||||
//performance: using textual override for ProfileAppliesTo here to not call
|
//performance: using textual override for ProfileAppliesTo here to not call
|
||||||
//GetGameObjectName every time we are trying to check object against profiles
|
//GetGameObjectName every time we are trying to check object against profiles
|
||||||
|
|
||||||
if (_objectManager.LobbyActor.Valid &&
|
if (_objectManager.IsInLobby && !_configuration.ProfileApplicationSettings.ApplyInLobby)
|
||||||
_objectManager.TryGetValue(actorIdentifier, out var actorData) &&
|
|
||||||
actorData.Objects.Count == 1 &&
|
|
||||||
_objectManager.LobbyActor == actorData.Objects[0] && !_configuration.ProfileApplicationSettings.ApplyInLobby)
|
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
(actorIdentifier, _) = _gameObjectService.GetTrueActorForSpecialTypeActor(actorIdentifier);
|
(actorIdentifier, _) = _gameObjectService.GetTrueActorForSpecialTypeActor(actorIdentifier);
|
||||||
|
|||||||
Reference in New Issue
Block a user