Skip to content

Commit bc90a52

Browse files
committed
fix: correct null ref on MapOptions
1 parent a0dc6bf commit bc90a52

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Framework/Intersect.Framework.Core/Config/MapOptions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Intersect.Config;
88
/// </summary>
99
public partial class MapOptions
1010
{
11+
public const int DefaultMapWidth = 32;
12+
public const int DefaultMapHeight = 26;
13+
1114
private bool _enableDiagonalMovement = true;
1215

1316
/// <summary>
@@ -57,7 +60,7 @@ public bool EnableDiagonalMovement
5760
/// <summary>
5861
/// The height of the map in tiles.
5962
/// </summary>
60-
public int MapHeight { get; set; } = 26;
63+
public int MapHeight { get; set; } = DefaultMapHeight;
6164

6265
/// <summary>
6366
/// The width of map items.
@@ -72,7 +75,7 @@ public bool EnableDiagonalMovement
7275
/// <summary>
7376
/// The width of the map in tiles.
7477
/// </summary>
75-
public int MapWidth { get; set; } = 32;
78+
public int MapWidth { get; set; } = DefaultMapWidth;
7679

7780
/// <summary>
7881
/// The number of movement directions available in the game for entities within the map.

Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.ComponentModel.DataAnnotations.Schema;
22
using Intersect.Collections;
33
using Intersect.Compression;
4+
using Intersect.Config;
45
using Intersect.Enums;
56
using Intersect.Framework.Core.Serialization;
67
using Intersect.GameObjects.Events;
@@ -39,7 +40,10 @@ public partial class MapBase : DatabaseObject<MapBase>
3940
public Dictionary<string, Tile[,]> Layers = new();
4041

4142
//Map Attributes
42-
private MapAttribute[,] mAttributes = new MapAttribute[Options.Instance.Map.MapWidth, Options.Instance.Map.MapHeight];
43+
private MapAttribute[,] mAttributes = new MapAttribute[
44+
Options.Instance?.Map.MapWidth ?? MapOptions.DefaultMapWidth,
45+
Options.Instance?.Map.MapHeight ?? MapOptions.DefaultMapHeight
46+
];
4347

4448
//Cached Att Data
4549
private byte[] mCachedAttributeData = null;

0 commit comments

Comments
 (0)