Skip to content

Commit 952972c

Browse files
committed
- Fix issue where multiple loads of Streets would throw an NRE
- Resolve duplicate door links being added to the "dummy" AICell - Bump version
1 parent e9e963c commit 952972c

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

Patches/AICellDataGetCellPatch.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ namespace DrakiaXYZ.Waypoints.Patches
77
{
88
internal class AICellDataGetCellPatch : ModulePatch
99
{
10-
private static AICell emptyCell;
11-
1210
protected override MethodBase GetTargetMethod()
1311
{
14-
emptyCell = new AICell();
15-
emptyCell.Links = new NavMeshDoorLink[0];
16-
1712
return AccessTools.Method(typeof(AICellData), "GetCell");
1813
}
1914

@@ -31,6 +26,8 @@ public static bool PatchPrefix(int i, int j, AICellData __instance, ref AICell _
3126
{
3227
Array.Resize(ref __instance.List, __instance.List.Length + 1);
3328

29+
AICell emptyCell = new AICell();
30+
emptyCell.Links = new NavMeshDoorLink[0];
3431
__instance.List[__instance.List.Length - 1] = emptyCell;
3532
}
3633

Patches/DoorLinkPatch.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using EFT.Interactive;
33
using HarmonyLib;
44
using System;
5+
using System.Linq;
56
using System.Reflection;
67
using UnityEngine;
78

@@ -17,6 +18,8 @@ protected override MethodBase GetTargetMethod()
1718
[PatchPrefix]
1819
public static void PatchPrefix(BotCellController __instance)
1920
{
21+
int i = 0;
22+
2023
// Prior to finding door links, add our own doorlinks for locked/breachable doors
2124
Door[] doors = UnityEngine.Object.FindObjectsOfType<Door>();
2225
foreach (Door door in doors)
@@ -34,7 +37,7 @@ public static void PatchPrefix(BotCellController __instance)
3437
Vector3 shutPos = door.transform.position + (door.GetDoorRotation(door.GetAngle(EDoorState.Shut)) * WorldInteractiveObject.GetRotationAxis(door.DoorForward, door.transform));
3538

3639
// Create the DoorLink object and setup its properties, create the carvers
37-
GameObject gameObject = new GameObject("DoorLink_Custom");
40+
GameObject gameObject = new GameObject($"DoorLink_Custom_{i}");
3841
NavMeshDoorLink navMeshDoorLink = gameObject.AddComponent<NavMeshDoorLink>();
3942
navMeshDoorLink.Close1 = hingePos;
4043
navMeshDoorLink.Open1 = hingePos;
@@ -53,6 +56,7 @@ public static void PatchPrefix(BotCellController __instance)
5356

5457
// Add to the AiCellData. NOTE: Will need to redo this for 3.8.0, yay
5558
AddToCells(__instance, door, navMeshDoorLink);
59+
i++;
5660
}
5761
}
5862

@@ -69,11 +73,11 @@ private static void AddToCells(BotCellController controller, Door door, NavMeshD
6973
{
7074
// Make sure our bounds are valid
7175
if (i < 0 || j < 0) continue;
72-
if (i > controller.Data.MaxIx || j > controller.Data.MaxIz) continue;
7376

7477
// Get the cell and validate it has a links list
7578
AICell cell = controller.Data.GetCell(i, j);
7679
if (cell.Links == null) cell.Links = new NavMeshDoorLink[0];
80+
if (cell.Links.Contains(navMeshDoorLink)) continue;
7781

7882
// Resizing an array is probably slow, but we're only doing this on match start, so should be fine
7983
Array.Resize(ref cell.Links, cell.Links.Length + 1);

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("1.3.3.0")]
37-
[assembly: AssemblyFileVersion("1.3.3.0")]
36+
[assembly: AssemblyVersion("1.3.4.0")]
37+
[assembly: AssemblyFileVersion("1.3.4.0")]
3838
[assembly: TarkovVersion(26535)]

ServerMod/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "DrakiaXYZ-Waypoints",
3-
"version": "1.3.3",
3+
"version": "1.3.4",
44
"main": "src/mod.js",
55
"license": "MIT",
66
"author": "DrakiaXYZ",

WaypointsPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace DrakiaXYZ.Waypoints
1111
{
12-
[BepInPlugin("xyz.drakia.waypoints", "DrakiaXYZ-Waypoints", "1.3.3")]
12+
[BepInPlugin("xyz.drakia.waypoints", "DrakiaXYZ-Waypoints", "1.3.4")]
1313
public class WaypointsPlugin : BaseUnityPlugin
1414
{
1515
public static string PluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

0 commit comments

Comments
 (0)