Skip to content

Commit

Permalink
Engine: Add [MustDisposeResource]
Browse files Browse the repository at this point in the history
  • Loading branch information
Fayti1703 committed Jul 7, 2024
1 parent 3fa8741 commit 4edd50b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using System.Text;
using Fayti1703.CommonLib.Enumeration;
using JetBrains.Annotations;

namespace BinaryMatrix.Engine.BinlogRenderers;

Expand Down Expand Up @@ -198,6 +199,7 @@ public AppendInterpolation(int literalLength, int formattedCount, StringArrayBui
public string[] ToArray() => this.entries.ToArray();

public IEnumerator<string> GetEnumerator() => this.entries.GetEnumerator();
[MustDisposeResource]
IEnumerator IEnumerable.GetEnumerator() => ( (IEnumerable) this.entries ).GetEnumerator();
public int Count => this.entries.Count;

Expand Down
2 changes: 2 additions & 0 deletions BinaryMatrixEngine/GameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ private GameContext(IEnumerable<Player> players, RNG rng, GameHooks hooks, GameB
this.binlog = binlog;
}

[MustDisposeResource]
public GameContext(IEnumerable<Player> players, RNG rng, GameHooks hooks)
: this(players, rng, hooks, new GameBoard(), new List<TurnLog>()) { }

[MustDisposeResource]
public GameContext(GameState state, IReadOnlyDictionary<PlayerID, PlayerActor> actors, RNG rng, GameHooks hooks)
: this(state.CreatePlayers(actors), rng, hooks, state.board.Copy(), new List<TurnLog>(state.binlog)) {
this.TurnCounter = state.turnCounter;
Expand Down

0 comments on commit 4edd50b

Please sign in to comment.