Remove this. everywhere, add small note to override style

This commit is contained in:
Infi
2024-04-10 17:45:25 +02:00
parent 2dfd11f018
commit 948383b0c5
28 changed files with 316 additions and 304 deletions
+14 -14
View File
@@ -39,21 +39,21 @@ internal sealed unsafe class Context {
private Plugin Plugin { get; }
internal Context(Plugin plugin) {
this.Plugin = plugin;
Plugin = plugin;
Plugin.GameInteropProvider.InitializeFromAttributes(this);
}
internal void InviteToNoviceNetwork(string name, ushort world) {
if (this._inviteToNoviceNetwork == null) {
if (_inviteToNoviceNetwork == null) {
return;
}
// 6.3: 221EFD
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(0x14);
var a1 = Plugin.Functions.GetInfoProxyByIndex(0x14);
fixed (byte* namePtr = name.ToTerminatedBytes()) {
// can specify content id if we have it, but there's no need
this._inviteToNoviceNetwork(a1, 0, world, namePtr);
_inviteToNoviceNetwork(a1, 0, world, namePtr);
}
}
@@ -66,48 +66,48 @@ internal sealed unsafe class Context {
// 0x10006: search recipes using this material
internal void TryOn(uint itemId, byte stainId) {
if (this._tryOn == null) {
if (_tryOn == null) {
return;
}
this._tryOn(0xFF, itemId, stainId, 0, 0);
_tryOn(0xFF, itemId, stainId, 0, 0);
}
internal void LinkItem(uint itemId) {
if (this._linkItem == null) {
if (_linkItem == null) {
return;
}
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ChatLog);
this._linkItem(agent, itemId);
_linkItem(agent, itemId);
}
internal void OpenItemComparison(uint itemId) {
if (this._itemComparison == null) {
if (_itemComparison == null) {
return;
}
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ItemCompare);
this._itemComparison(agent, 0x4D, itemId, 0);
_itemComparison(agent, 0x4D, itemId, 0);
}
internal void SearchForRecipesUsingItem(uint itemId) {
if (this._searchForRecipesUsingItem == null || this._searchForRecipesUsingItemVfunc is not { } offset) {
if (_searchForRecipesUsingItem == null || _searchForRecipesUsingItemVfunc is not { } offset) {
return;
}
var uiModule = Framework.Instance()->GetUiModule();
var vf = (delegate* unmanaged<UIModule*, IntPtr>) uiModule->vfunc[offset / 8];
var a1 = vf(uiModule);
this._searchForRecipesUsingItem(a1, itemId);
_searchForRecipesUsingItem(a1, itemId);
}
internal void SearchForItem(uint itemId) {
if (this._searchForItem == null) {
if (_searchForItem == null) {
return;
}
var itemFinder = Framework.Instance()->GetUiModule()->GetItemFinderModule();
this._searchForItem(itemFinder, itemId, 1);
_searchForItem(itemFinder, itemId, 1);
}
}
+31 -31
View File
@@ -66,26 +66,26 @@ internal unsafe class GameFunctions : IDisposable {
internal Context Context { get; }
internal GameFunctions(Plugin plugin) {
this.Plugin = plugin;
this.Party = new Party(this.Plugin);
this.Chat = new Chat(this.Plugin);
this.Context = new Context(this.Plugin);
Plugin = plugin;
Party = new Party(Plugin);
Chat = new Chat(Plugin);
Context = new Context(Plugin);
Plugin.GameInteropProvider.InitializeFromAttributes(this);
this.ResolveTextCommandPlaceholderHook?.Enable();
ResolveTextCommandPlaceholderHook?.Enable();
}
public void Dispose() {
this.Chat.Dispose();
Chat.Dispose();
this.ResolveTextCommandPlaceholderHook?.Dispose();
ResolveTextCommandPlaceholderHook?.Dispose();
Marshal.FreeHGlobal(this._placeholderNamePtr);
Marshal.FreeHGlobal(_placeholderNamePtr);
}
private IntPtr GetInfoModule() {
if (this._infoModuleVfunc is not { } vfunc) {
if (_infoModuleVfunc is not { } vfunc) {
return IntPtr.Zero;
}
@@ -95,25 +95,25 @@ internal unsafe class GameFunctions : IDisposable {
}
internal IntPtr GetInfoProxyByIndex(uint idx) {
var infoModule = this.GetInfoModule();
return infoModule == IntPtr.Zero ? IntPtr.Zero : this._getInfoProxyByIndex(infoModule, idx);
var infoModule = GetInfoModule();
return infoModule == IntPtr.Zero ? IntPtr.Zero : _getInfoProxyByIndex(infoModule, idx);
}
internal uint? GetCurrentChatLogEntryIndex() {
if (this._currentChatEntryOffset == null) {
if (_currentChatEntryOffset == null) {
return null;
}
var log = (IntPtr) Framework.Instance()->GetUiModule()->GetRaptureLogModule();
return *(uint*) (log + this._currentChatEntryOffset.Value);
return *(uint*) (log + _currentChatEntryOffset.Value);
}
internal void SendFriendRequest(string name, ushort world) {
this.ListCommand(name, world, "friendlist");
ListCommand(name, world, "friendlist");
}
internal void AddToBlacklist(string name, ushort world) {
this.ListCommand(name, world, "blist");
ListCommand(name, world, "blist");
}
private void ListCommand(string name, ushort world, string commandName) {
@@ -123,8 +123,8 @@ internal unsafe class GameFunctions : IDisposable {
}
var worldName = row.Name.RawString;
this._replacementName = $"{name}@{worldName}";
this.Plugin.Common.Functions.Chat.SendMessage($"/{commandName} add {this._placeholder}");
_replacementName = $"{name}@{worldName}";
Plugin.Common.Functions.Chat.SendMessage($"/{commandName} add {_placeholder}");
}
internal static void SetAddonInteractable(string name, bool interactable) {
@@ -236,41 +236,41 @@ internal unsafe class GameFunctions : IDisposable {
}
internal bool IsMentor() {
if (this._isMentor == null || this._isMentorA1 == null || this._isMentorA1.Value == IntPtr.Zero) {
if (_isMentor == null || _isMentorA1 == null || _isMentorA1.Value == IntPtr.Zero) {
return false;
}
return this._isMentor(this._isMentorA1.Value) > 0;
return _isMentor(_isMentorA1.Value) > 0;
}
internal void OpenPartyFinder(uint id) {
if (this._openPartyFinder == null) {
if (_openPartyFinder == null) {
return;
}
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.LookingForGroup);
if (agent != null) {
this._openPartyFinder(agent, id);
_openPartyFinder(agent, id);
}
}
internal void OpenAchievement(uint id) {
if (this._openAchievement == null) {
if (_openAchievement == null) {
return;
}
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Achievement);
if (agent != null) {
this._openAchievement(agent, id);
_openAchievement(agent, id);
}
}
internal bool IsInInstance() {
if (this._inInstance == null) {
if (_inInstance == null) {
return false;
}
return this._inInstance() != 0;
return _inInstance() != 0;
}
internal bool TryOpenAdventurerPlate(ulong playerId)
@@ -304,21 +304,21 @@ internal unsafe class GameFunctions : IDisposable {
private string? _replacementName;
private IntPtr ResolveTextCommandPlaceholderDetour(IntPtr a1, byte* placeholderText, byte a3, byte a4) {
if (this._replacementName == null) {
if (_replacementName == null) {
goto Original;
}
var placeholder = MemoryHelper.ReadStringNullTerminated((IntPtr) placeholderText);
if (placeholder != this._placeholder) {
if (placeholder != _placeholder) {
goto Original;
}
MemoryHelper.WriteString(this._placeholderNamePtr, this._replacementName);
this._replacementName = null;
MemoryHelper.WriteString(_placeholderNamePtr, _replacementName);
_replacementName = null;
return this._placeholderNamePtr;
return _placeholderNamePtr;
Original:
return this.ResolveTextCommandPlaceholderHook!.Original(a1, placeholderText, a3, a4);
return ResolveTextCommandPlaceholderHook!.Original(a1, placeholderText, a3, a4);
}
}
+14 -14
View File
@@ -25,57 +25,57 @@ internal sealed unsafe class Party {
private Plugin Plugin { get; }
internal Party(Plugin plugin) {
this.Plugin = plugin;
Plugin = plugin;
Plugin.GameInteropProvider.InitializeFromAttributes(this);
}
internal void InviteSameWorld(string name, ushort world, ulong contentId) {
if (this._inviteToParty == null) {
if (_inviteToParty == null) {
return;
}
// 6.11: 214A55
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(2);
var a1 = Plugin.Functions.GetInfoProxyByIndex(2);
fixed (byte* namePtr = name.ToTerminatedBytes()) {
// this only works if target is on the same world
this._inviteToParty(a1, contentId, namePtr, world);
_inviteToParty(a1, contentId, namePtr, world);
}
}
internal void InviteOtherWorld(ulong contentId) {
if (this._inviteToPartyContentId == null) {
if (_inviteToPartyContentId == null) {
return;
}
// 6.11: 214A55
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(2);
var a1 = Plugin.Functions.GetInfoProxyByIndex(2);
if (contentId != 0) {
// third param is world, but it requires a specific world
// if they're not on that world, it will fail
// pass 0 and it will work on any world EXCEPT for the world the
// current player is on
this._inviteToPartyContentId(a1, contentId, 0);
_inviteToPartyContentId(a1, contentId, 0);
}
}
internal void InviteInInstance(ulong contentId) {
if (this._inviteToPartyInInstance == null) {
if (_inviteToPartyInInstance == null) {
return;
}
// 6.11: 214A55
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(2);
var a1 = Plugin.Functions.GetInfoProxyByIndex(2);
if (contentId != 0) {
// third param is world, but it requires a specific world
// if they're not on that world, it will fail
// pass 0 and it will work on any world EXCEPT for the world the
// current player is on
this._inviteToPartyInInstance(a1, contentId);
_inviteToPartyInInstance(a1, contentId);
}
}
internal void Kick(string name, ulong contentId) {
if (this._kick == null) {
if (_kick == null) {
return;
}
@@ -85,12 +85,12 @@ internal sealed unsafe class Party {
}
fixed (byte* namePtr = name.ToTerminatedBytes()) {
this._kick(agent, namePtr, 0, contentId);
_kick(agent, namePtr, 0, contentId);
}
}
internal void Promote(string name, ulong contentId) {
if (this._promote == null) {
if (_promote == null) {
return;
}
@@ -100,7 +100,7 @@ internal sealed unsafe class Party {
}
fixed (byte* namePtr = name.ToTerminatedBytes()) {
this._promote(agent, namePtr, 0, contentId);
_promote(agent, namePtr, 0, contentId);
}
}
}
@@ -9,9 +9,9 @@ internal class ChannelSwitchInfo {
internal string? Text { get; }
internal ChannelSwitchInfo(InputChannel? channel, bool permanent = false, RotateMode rotate = RotateMode.None, string? text = null) {
this.Channel = channel;
this.Permanent = permanent;
this.Rotate = rotate;
this.Text = text;
Channel = channel;
Permanent = permanent;
Rotate = rotate;
Text = text;
}
}
@@ -8,6 +8,6 @@ internal sealed class ChatActivatedArgs {
internal TellTarget? TellTarget { get; init; }
internal ChatActivatedArgs(ChannelSwitchInfo channelSwitchInfo) {
this.ChannelSwitchInfo = channelSwitchInfo;
ChannelSwitchInfo = channelSwitchInfo;
}
}
@@ -6,8 +6,8 @@ internal sealed class TellHistoryInfo {
internal ulong ContentId { get; }
internal TellHistoryInfo(string name, uint world, ulong contentId) {
this.Name = name;
this.World = world;
this.ContentId = contentId;
Name = name;
World = world;
ContentId = contentId;
}
}
+4 -4
View File
@@ -7,9 +7,9 @@ internal sealed class TellTarget {
internal TellReason Reason { get; }
internal TellTarget(string name, ushort world, ulong contentId, TellReason reason) {
this.Name = name;
this.World = world;
this.ContentId = contentId;
this.Reason = reason;
Name = name;
World = world;
ContentId = contentId;
Reason = reason;
}
}