Skip to content

Commit d99cfb2

Browse files
committed
Merge branch 'development'
2 parents 971f6db + 2e6c4b8 commit d99cfb2

33 files changed

+308
-111
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
"version": "8.0"
1515
},
1616
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
17-
"packages": "curl,unzip,procps,git"
17+
"packages": "curl,unzip,procps,git,lldb"
1818
}
1919
},
2020
"appPort": ["5121:5121/udp"],
2121
"containerEnv": {
2222
"NWNX_DOTNET_ASSEMBLY": "/workspaces/NWN.Anvil/NWN.Anvil/bin/Debug/net8.0/NWN.Anvil",
2323
"ANVIL_ADD_PLUGIN_PATHS": "/workspaces/NWN.Anvil/NWN.Anvil.TestRunner/bin/Debug:/workspaces/NWN.Anvil/NWN.Anvil.Tests/bin/Debug"
24-
}
24+
},
25+
"runArgs": ["--privileged"],
26+
"onCreateCommand": ["sh", "-c", "dotnet tool install --global dotnet-sos && /root/.dotnet/tools/dotnet-sos install"]
2527
}

CHANGELOG.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,43 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6-
## 8193.37.2
6+
## Unreleased
7+
8+
### Pending Changes
9+
https://github.com/nwn-dotnet/Anvil/compare/v8193.37.3...HEAD
10+
11+
## 8193.37.3 (NWN 8193.37-17)
12+
https://github.com/nwn-dotnet/Anvil/compare/v8193.37.2...v8193.37.3
13+
14+
### Added
15+
- Events: Added `Spell` property to `OnCreatureDamage` event.
16+
17+
### Package Updates
18+
- NWNX: 292a2c0 -> 73cf6ab
19+
- NWN.Core: 8193.37.3 -> 8193.37.4
20+
- NWN.Native: 8193.37.3 -> 8193.37.4
21+
- Docker: Ubuntu 20.04 -> Debian 13 (Trixie)
22+
- Docker: Pinned OpenSSL 1.1.1t
23+
24+
### Changed
25+
- Improved invalid object detection in some edge cases.
26+
- Events: Placeable `OnDamaged` event now supports damage sources from non-creatures.
27+
- NwCreature: `GetFeatRemainingUses`, `GetFeatTotalUses` now matches the behaviour of the NWScript function.
28+
- If the feat has unlimited uses, returns int.MaxValue instead of 100.
29+
- NwSpell: `GetSpellLevelByClass` now matches the behaviour of the NWScript function.
30+
- Returns the spell level for the specified class. Returns null if no spell level is defined for the specified class.
31+
- `includeMasterSpell` parameter - If true, will use the master spell class level if this spell has no class level configured
32+
33+
### Fixed
34+
- Fixed an OpenSSL crash when running Anvil/NWNX_DotNET on newer operating systems (Debian 12+, Ubuntu 22.04+)
35+
36+
## 8193.37.2 (NWN 8193.37-15)
737
https://github.com/nwn-dotnet/Anvil/compare/v8193.37.1...v8193.37.2
838

939
### Changed
1040
- Improved invalid object detection in some edge cases.
1141

12-
## 8193.37.1
42+
## 8193.37.1 (NWN 8193.37-15)
1343
https://github.com/nwn-dotnet/Anvil/compare/v8193.37.0...v8193.37.1
1444

1545
### Added

NWN.Anvil.TestRunner/NWN.Anvil.TestRunner.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
</ItemGroup>
6464

6565
<ItemGroup>
66-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
67-
<PackageReference Include="NWN.Native" Version="8193.37.3" PrivateAssets="compile" />
66+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
67+
<PackageReference Include="NWN.Native" Version="8193.37.4" PrivateAssets="compile" />
6868
</ItemGroup>
6969

7070
<ItemGroup>

NWN.Anvil.Tests/NWN.Anvil.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545

4646
<ItemGroup>
4747
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
48-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
49-
<PackageReference Include="NWN.Native" Version="8193.37.3" PrivateAssets="compile" />
48+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
49+
<PackageReference Include="NWN.Native" Version="8193.37.4" PrivateAssets="compile" />
5050
</ItemGroup>
5151

5252
</Project>

NWN.Anvil/NWN.Anvil.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
6868
<PackageReference Include="NLog" Version="5.4.0" />
6969
<PackageReference Include="Paket.Core" Version="8.0.3" PrivateAssets="all" />
70-
<PackageReference Include="NWN.Core" Version="8193.37.3" PrivateAssets="compile" />
71-
<PackageReference Include="NWN.Native" Version="8193.37.3" PrivateAssets="compile" />
70+
<PackageReference Include="NWN.Core" Version="8193.37.4" PrivateAssets="compile" />
71+
<PackageReference Include="NWN.Native" Version="8193.37.4" PrivateAssets="compile" />
7272
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
7373
</ItemGroup>
7474

NWN.Anvil/src/main/API/Events/Game/PlaceableEvents/PlaceableEvents.OnDamaged.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public OnDamaged()
4545
uint objSelf = NWScript.OBJECT_SELF;
4646
DamagedObject = objSelf.ToNwObject<NwPlaceable>()!;
4747
TotalDamageDealt = NWScript.GetTotalDamageDealt();
48-
Damager = NWScript.GetLastDamager(objSelf).ToNwObject<NwCreature>()!;
48+
Damager = NWScript.GetLastDamager(objSelf).ToNwObject<NwGameObject>();
4949
}
5050
}
5151
}

NWN.Anvil/src/main/API/Events/Native/DamageEvents/OnCreatureDamage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public sealed class OnCreatureDamage : IEvent
1212
public DamageData<int> DamageData { get; private init; } = null!;
1313
public NwObject DamagedBy { get; private init; } = null!;
1414
public NwGameObject Target { get; private init; } = null!;
15+
public NwSpell? Spell { get; private init; }
1516

1617
NwObject IEvent.Context => DamagedBy;
1718

@@ -49,6 +50,7 @@ private static int OnApplyDamage(void* pEffectListHandler, void* pObject, void*
4950
DamagedBy = effect.m_oidCreator.ToNwObject<NwObject>()!,
5051
Target = gameObject.ToNwObject<NwGameObject>()!,
5152
DamageData = new DamageData<int>(effect.m_nParamInteger),
53+
Spell = NwSpell.FromSpellId((int)effect.m_nSpellId),
5254
});
5355
}
5456

NWN.Anvil/src/main/API/Events/Native/ItemEvents/ItemEventHandlerEventFactory.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ private static void OnEventHandler(void* pItem, uint nEventId, uint nCallerObjec
2222
{
2323
CNWSItem item = CNWSItem.FromPointer(pItem);
2424

25-
ItemHandlerEvent eventData = nEventId switch
25+
ItemHandlerEvent? eventData = nEventId switch
2626
{
2727
11 => HandleEvent<OnItemDestroy>(item),
2828
16 => HandleEvent<OnItemDecrementStackSize>(item),
29-
_ => throw new ArgumentOutOfRangeException(nameof(nEventId), nEventId, null),
29+
_ => null,
3030
};
3131

32+
if (eventData == null)
33+
{
34+
Hook.CallOriginal(pItem, nEventId, nCallerObjectId, pScript, nCalendarDay, nTimeOfDay);
35+
return;
36+
}
37+
3238
if (!eventData.Skip)
3339
{
3440
Hook.CallOriginal(pItem, nEventId, nCallerObjectId, pScript, nCalendarDay, nTimeOfDay);

NWN.Anvil/src/main/API/Extensions/IntegerExtensions.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,27 @@ public static int ToInt(this bool value)
155155

156156
if (playerSearch.HasFlag(PlayerSearch.Controlled))
157157
{
158-
CNWSPlayer? player = LowLevel.ServerExoApp.GetClientObjectByObjectId(objectId);
158+
NwPlayer? player = NwPlayer.CreateInternal(LowLevel.ServerExoApp.GetClientObjectByObjectId(objectId));
159159
if (player != null)
160160
{
161-
return new NwPlayer(player);
161+
return player;
162162
}
163163
}
164164

165165
if (playerSearch.HasFlag(PlayerSearch.Login))
166166
{
167167
CExoArrayListCNWSPlayerPtr? players = LowLevel.ServerExoApp.m_pcExoAppInternal.m_lstPlayerList;
168-
foreach (CNWSPlayer player in players)
168+
foreach (CNWSPlayer nwPlayer in players)
169169
{
170-
if (player.m_oidPCObject == objectId)
170+
if (nwPlayer == null || nwPlayer.Pointer == IntPtr.Zero || nwPlayer.m_oidPCObject != objectId)
171171
{
172-
return new NwPlayer(player);
172+
continue;
173+
}
174+
175+
NwPlayer? player = NwPlayer.CreateInternal(nwPlayer);
176+
if (player != null)
177+
{
178+
return player;
173179
}
174180
}
175181
}

NWN.Anvil/src/main/API/Objects/NwArea.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ internal CNWSArea Area
2626
}
2727
}
2828

29-
internal NwArea(CNWSArea area) : base(area)
29+
private NwArea(CNWSArea area) : base(area)
3030
{
3131
this.area = area;
3232
}
3333

34+
internal static NwArea? CreateInternal(CNWSArea? area)
35+
{
36+
return area != null && area.Pointer != IntPtr.Zero ? new NwArea(area) : null;
37+
}
38+
3439
public override bool IsValid => NWNXUtils.AsNWSArea(NWNXUtils.GetGameObject(ObjectId)) == area.Pointer;
3540

3641
/// <summary>

0 commit comments

Comments
 (0)