Skip to content

Commit

Permalink
Actually make code syntactically correct.
Browse files Browse the repository at this point in the history
  • Loading branch information
KazWolfe authored Feb 7, 2024
1 parent ea8f9b8 commit 343875d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/plugin-development/interaction/expanding-game-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class HealthWatcher : IDisposable {
if (player == null) return; // Player is not logged in, nothing we can do.
if (player.CurrentHp == this._lastHealth) return;

this._lastHealth = currentHealth;
PluginLog.Information("The player's health has updated to {health}.", currentHealth);
this._lastHealth = player.CurrentHp;
PluginLog.Information("The player's health has updated to {health}.", player.CurrentHp);
}
}
```
Expand All @@ -42,7 +42,7 @@ player's HP differs from the cached value, it will dispatch a message to the Plu
:::tip

It is always a good idea to unregister your events when you're done with them! The above snippet does this through the
`Dispose()` method, which is intended to be called by whatever created this method.
`Dispose()` method, which is intended to be called by whatever manages the lifecycle of this object.

Failing to unregister events when they're no longer necessary means that code will *still be called*, and may cause
unexpected behavior. As a rule of thumb, for every event you subscribe to with `+=`, you need to have a `-=` somewhere
Expand Down Expand Up @@ -77,8 +77,8 @@ Dalamud provides everything necessary for a plugin to create a hook, making the
plugin that wants to be informed when any macro changes might hook RaptureMacroModule's `SetSavePendingFlag`:

```csharp
public class MyHook : IDisposable {
private delegate void SetSavePendingDelegate(RaptureMacroModule* self, byte needsSave, uint set);
public unsafe class MyHook : IDisposable {
private delegate nint SetSavePendingDelegate(RaptureMacroModule* self, byte needsSave, uint set);

private readonly Hook<SetSavePendingDelegate>? _macroUpdateHook;

Expand Down Expand Up @@ -120,7 +120,7 @@ This can also be done with a direct signature via `IGameInteropProvider`, if the
Structs:

```csharp
public class MySiggedHook : IDisposable {
public unsafe class MySiggedHook : IDisposable {
private delegate nint SetSavePendingDelegate(RaptureMacroModule* self, byte needsSave, uint set);

[Signature("45 85 C0 75 04 88 51 3D", DetourName = nameof(DetourSetSavePending))]
Expand Down

0 comments on commit 343875d

Please sign in to comment.