Merge pull request #145 from Poliwrath/things2

Small things (again)
This commit is contained in:
goaaats 2020-07-27 09:02:25 +02:00 committed by GitHub
commit 8b749be730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 55 deletions

View file

@ -169,12 +169,9 @@ namespace Dalamud.Injector {
var ffxivDir = Path.GetDirectoryName(process.MainModule.FileName);
var startInfo = new DalamudStartInfo {
WorkingDirectory = null,
ConfigurationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
@"\XIVLauncher\dalamudConfig.json",
PluginDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
@"\XIVLauncher\installedPlugins",
DefaultPluginDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
@"\XIVLauncher\devPlugins",
ConfigurationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json"),
PluginDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "installedPlugins"),
DefaultPluginDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "devPlugins"),
GameVersion = File.ReadAllText(Path.Combine(ffxivDir, "ffxivgame.ver")),
Language = ClientLanguage.English

View file

@ -5,6 +5,7 @@ using Dalamud.Configuration;
using Dalamud.DiscordBot;
using Dalamud.Game.Chat;
using Newtonsoft.Json;
using Serilog;
namespace Dalamud
{
@ -43,7 +44,17 @@ namespace Dalamud
public string ConfigPath;
public static DalamudConfiguration Load(string path) {
var deserialized = JsonConvert.DeserializeObject<DalamudConfiguration>(File.ReadAllText(path));
DalamudConfiguration deserialized;
try
{
deserialized = JsonConvert.DeserializeObject<DalamudConfiguration>(File.ReadAllText(path));
}
catch (Exception ex)
{
Log.Warning(ex, "Failed to load DalamudConfiguration at {0}", path);
deserialized = new DalamudConfiguration();
}
deserialized.ConfigPath = path;
return deserialized;

View file

@ -424,12 +424,12 @@ namespace Dalamud {
CommandManager.AddHandler("/xldreloadplugins", new CommandInfo(OnPluginReloadCommand) {
HelpMessage = Loc.Localize("DalamudPluginReloadHelp", "Reloads all plugins."),
ShowInHelp = false
ShowInHelp = false
});
CommandManager.AddHandler("/xldsay", new CommandInfo(OnCommandDebugSay) {
HelpMessage = Loc.Localize("DalamudPrintChatHelp", "Print to chat."),
ShowInHelp = false
ShowInHelp = false
});
CommandManager.AddHandler("/xlhelp", new CommandInfo(OnHelpCommand) {
@ -456,57 +456,48 @@ namespace Dalamud {
HelpMessage = Loc.Localize("DalamudBotJoinHelp", "Add the XIVLauncher discord bot you set up to your server.")
});
CommandManager.AddHandler("/xlbgmset", new CommandInfo(OnBgmSetCommand)
{
CommandManager.AddHandler("/xlbgmset", new CommandInfo(OnBgmSetCommand) {
HelpMessage = Loc.Localize("DalamudBgmSetHelp", "Set the Game background music. Usage: /xlbgmset <BGM ID>")
});
#if DEBUG
CommandManager.AddHandler("/xldzpi", new CommandInfo(OnDebugZoneDownInjectCommand)
{
CommandManager.AddHandler("/xldzpi", new CommandInfo(OnDebugZoneDownInjectCommand) {
HelpMessage = "Inject zone down channel",
ShowInHelp = false
});
#endif
CommandManager.AddHandler("/xlbonus", new CommandInfo(OnRouletteBonusNotifyCommand)
{
CommandManager.AddHandler("/xlbonus", new CommandInfo(OnRouletteBonusNotifyCommand) {
HelpMessage = Loc.Localize("DalamudBonusHelp", "Notify when a roulette has a bonus you specified. Run without parameters for more info. Usage: /xlbonus <roulette name> <role name>")
});
CommandManager.AddHandler("/xldev", new CommandInfo(OnDebugDrawDevMenu) {
HelpMessage = Loc.Localize("DalamudDevMenuHelp", "Draw dev menu DEBUG"),
ShowInHelp = false
ShowInHelp = false
});
CommandManager.AddHandler("/xlplugins", new CommandInfo(OnOpenInstallerCommand)
{
CommandManager.AddHandler("/xlplugins", new CommandInfo(OnOpenInstallerCommand) {
HelpMessage = Loc.Localize("DalamudInstallerHelp", "Open the plugin installer")
});
this.CommandManager.AddHandler("/xlcredits", new CommandInfo(OnOpenCreditsCommand) {
CommandManager.AddHandler("/xlcredits", new CommandInfo(OnOpenCreditsCommand) {
HelpMessage = Loc.Localize("DalamudCreditsHelp", "Opens the credits for dalamud.")
});
this.CommandManager.AddHandler("/xllanguage", new CommandInfo(OnSetLanguageCommand)
{
CommandManager.AddHandler("/xllanguage", new CommandInfo(OnSetLanguageCommand) {
HelpMessage = Loc.Localize("DalamudLanguageHelp", "Set the language for the in-game addon and plugins that support it. Available languages: ") + Localization.ApplicableLangCodes.Aggregate("en", (current, code) => current + ", " + code)
});
this.CommandManager.AddHandler("/xlsettings", new CommandInfo(OnOpenSettingsCommand)
{
CommandManager.AddHandler("/xlsettings", new CommandInfo(OnOpenSettingsCommand) {
HelpMessage = Loc.Localize("DalamudSettingsHelp", "Change various In-Game-Addon settings like chat channels and the discord bot setup.")
});
this.CommandManager.AddHandler("/xlbugreport", new CommandInfo(OnBugReportCommand)
{
CommandManager.AddHandler("/xlbugreport", new CommandInfo(OnBugReportCommand) {
HelpMessage = Loc.Localize("DalamudBugReport", "Upload a log to be analyzed by our professional development team."),
ShowInHelp = false
});
this.CommandManager.AddHandler("/imdebug", new CommandInfo(OnDebugImInfoCommand)
{
CommandManager.AddHandler("/imdebug", new CommandInfo(OnDebugImInfoCommand) {
HelpMessage = "ImGui DEBUG",
ShowInHelp = false
});
@ -671,7 +662,7 @@ namespace Dalamud {
}
private void OnDebugDrawDevMenu(string command, string arguments) {
this.isImguiDrawDevMenu = true;
this.isImguiDrawDevMenu = !this.isImguiDrawDevMenu;
}
private void OnDebugImInfoCommand(string command, string arguments) {

View file

@ -8,48 +8,78 @@ using Dalamud.Game.ClientState.Actors;
namespace Dalamud.Game.ClientState.Structs
{
public class ActorOffsets
{
public const int Name = 0x30;
public const int ActorId = 116;
public const int DataId = 128;
public const int OwnerId = 132;
public const int ObjectKind = 140;
public const int SubKind = 141;
public const int IsFriendly = 142;
public const int YalmDistanceFromPlayerX = 144;
public const int PlayerTargetStatus = 145;
public const int YalmDistanceFromPlayerY = 146;
public const int Position = 160;
public const int Rotation = 176;
public const int Customize = 0x17B8;
public const int PlayerCharacterTargetActorId = 0x1F0;
public const int BattleNpcTargetActorId = 0x17F8;
public const int CompanyTag = 0x17D0;
public const int NameId = 0x1868;
public const int CurrentWorld = 0x1884;
public const int HomeWorld = 0x1886;
public const int CurrentHp = 0x1898;
public const int MaxHp = 0x189C;
public const int CurrentMp = 0x18A0;
public const int MaxMp = 0x18AA;
public const int ClassJob = 6358;
public const int Level = 6360;
public const int UIStatusEffects = 0x1958;
}
/// <summary>
/// Native memory representation of a FFXIV actor.
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct Actor {
[FieldOffset(0x30)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
[FieldOffset(ActorOffsets.Name)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string Name;
[FieldOffset(116)] public int ActorId;
[FieldOffset(128)] public int DataId;
[FieldOffset(132)] public int OwnerId;
[FieldOffset(140)] public ObjectKind ObjectKind;
[FieldOffset(141)] public byte SubKind;
[FieldOffset(142)] public bool IsFriendly;
[FieldOffset(144)] public byte YalmDistanceFromPlayerX; // Demo says one of these is x distance
[FieldOffset(145)] public byte PlayerTargetStatus; // This is some kind of enum
[FieldOffset(146)] public byte YalmDistanceFromPlayerY; // and the other is z distance
[FieldOffset(160)] public Position3 Position;
[FieldOffset(176)] public float Rotation; // Rotation around the vertical axis (yaw), from -pi to pi radians
[FieldOffset(ActorOffsets.ActorId)] public int ActorId;
[FieldOffset(ActorOffsets.DataId)] public int DataId;
[FieldOffset(ActorOffsets.OwnerId)] public int OwnerId;
[FieldOffset(ActorOffsets.ObjectKind)] public ObjectKind ObjectKind;
[FieldOffset(ActorOffsets.SubKind)] public byte SubKind;
[FieldOffset(ActorOffsets.IsFriendly)] public bool IsFriendly;
[FieldOffset(ActorOffsets.YalmDistanceFromPlayerX)] public byte YalmDistanceFromPlayerX; // Demo says one of these is x distance
[FieldOffset(ActorOffsets.PlayerTargetStatus)] public byte PlayerTargetStatus; // This is some kind of enum
[FieldOffset(ActorOffsets.YalmDistanceFromPlayerY)] public byte YalmDistanceFromPlayerY; // and the other is z distance
[FieldOffset(ActorOffsets.Position)] public Position3 Position;
[FieldOffset(ActorOffsets.Rotation)] public float Rotation; // Rotation around the vertical axis (yaw), from -pi to pi radians
[FieldOffset(0x17B8)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] public byte[] Customize;
[FieldOffset(ActorOffsets.Customize)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] public byte[] Customize;
[FieldOffset(0x1F0)] public int PlayerCharacterTargetActorId;
[FieldOffset(0x17F8)] public int BattleNpcTargetActorId;
[FieldOffset(ActorOffsets.PlayerCharacterTargetActorId)] public int PlayerCharacterTargetActorId;
[FieldOffset(ActorOffsets.BattleNpcTargetActorId)] public int BattleNpcTargetActorId;
// This field can't be correctly aligned, so we have to cut it manually.
[FieldOffset(0x17d0)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
[FieldOffset(ActorOffsets.CompanyTag)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
public byte[] CompanyTag;
[FieldOffset(0x1868)] public int NameId;
[FieldOffset(0x1884)] public byte CurrentWorld;
[FieldOffset(0x1886)] public byte HomeWorld;
[FieldOffset(0x1898)] public int CurrentHp;
[FieldOffset(0x189C)] public int MaxHp;
[FieldOffset(0x18A0)] public int CurrentMp;
[FieldOffset(ActorOffsets.NameId)] public int NameId;
[FieldOffset(ActorOffsets.CurrentWorld)] public byte CurrentWorld;
[FieldOffset(ActorOffsets.HomeWorld)] public byte HomeWorld;
[FieldOffset(ActorOffsets.CurrentHp)] public int CurrentHp;
[FieldOffset(ActorOffsets.MaxHp)] public int MaxHp;
[FieldOffset(ActorOffsets.CurrentMp)] public int CurrentMp;
// This value is weird. It seems to change semi-randomly between 0 and 10k, definitely
// in response to mp-using events, but it doesn't often have a value and the changing seems
// somewhat arbitrary.
[FieldOffset(0x18AA)] public int MaxMp;
[FieldOffset(6358)] public byte ClassJob;
[FieldOffset(6360)] public byte Level;
[FieldOffset(0x1958)][MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public StatusEffect[] UIStatusEffects;
[FieldOffset(ActorOffsets.MaxMp)] public int MaxMp;
[FieldOffset(ActorOffsets.ClassJob)] public byte ClassJob;
[FieldOffset(ActorOffsets.Level)] public byte Level;
[FieldOffset(ActorOffsets.UIStatusEffects)][MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] public StatusEffect[] UIStatusEffects;
}
}