AutoVendor: find a vendor by the server's vendor bitfield #20

Open
AwfulWaffle wants to merge 1 commit from AwfulWaffle/RynthSuite:autovendor-vendor-bitfield into main
First-time contributor

Depends on: nothing (RynthSuite, based on upstream/main 7166d25).

What went wrong in play

/ub vendor open by name or by id found no vendor at all. The world cache never classifies anything as AcObjectClass.Vendor (WorldObjectCache has no Vendor arm; other code that needs to know re-derives it from the server's vendor bitfield), and AutoVendor's by-name search and its "is this a vendor" check both required that cache class. Seen on DreamWeave, where the summoned vault NPC could not be opened this way.

The fix

AutoVendorManager now recognises a vendor by the server's own vendor flag: PublicWeenieDesc._bitfield bit BF_VENDOR (0x200, ObjectDescriptionFlag.Vendor).

  • New IsVendorObject(wo): true for the cache class Vendor (should one ever be assigned), or when the engine's TryGetObjectBitfield reports bit 0x200. Guarded by HasGetObjectBitfield and a try/catch, so an engine without the API behaves exactly as before.
  • IsVendor(id) uses it, so opening by id works.
  • The by-name search is a single nearest-match loop over the landscape objects using IsVendorObject. The cheap name test runs before the bitfield read.

How it was tested

Build (from the worktree root):

dotnet build Plugins\RynthCore.Plugin.RynthAi\RynthCore.Plugin.RynthAi.csproj -c Release -r win-x86 -nodeReuse:false

Result: Build succeeded, 0 Error(s).

Host tests (from Tools\RynthCore.RynthAiHostTests):

dotnet run -c Release -- "Vendor"   ->  20 test(s), 140 check(s): 20 passed, 0 failed
dotnet run -c Release               ->  1499 test(s), 15376 check(s): 1498 passed, 1 failed

The one failure is map bake: 0x6346 from the real dats ..., which needs the game dats and also fails on pristine upstream/main (baseline 1494/1495). The new VendorFlagTests (4 tests: found by name, by id, by partial name; an unflagged object is not a vendor) are registered with one line in Program.cs.

Scope and risk

3 files: Vendor/AutoVendorManager.cs, Tests/VendorFlagTests.cs (new), and one registration line in Program.cs. Only vendor discovery changes. Risk: any object carrying the vendor bit and matching the name is now a candidate; the nearest wins. Needs the engine's TryGetObjectBitfield; without it, behaviour is unchanged.

🤖 Generated with Claude Code

Depends on: nothing (RynthSuite, based on upstream/main 7166d25). ## What went wrong in play `/ub vendor open` by name or by id found no vendor at all. The world cache never classifies anything as `AcObjectClass.Vendor` (`WorldObjectCache` has no Vendor arm; other code that needs to know re-derives it from the server's vendor bitfield), and AutoVendor's by-name search and its "is this a vendor" check both required that cache class. Seen on DreamWeave, where the summoned vault NPC could not be opened this way. ## The fix `AutoVendorManager` now recognises a vendor by the server's own vendor flag: `PublicWeenieDesc._bitfield` bit `BF_VENDOR` (0x200, `ObjectDescriptionFlag.Vendor`). - New `IsVendorObject(wo)`: true for the cache class `Vendor` (should one ever be assigned), or when the engine's `TryGetObjectBitfield` reports bit 0x200. Guarded by `HasGetObjectBitfield` and a try/catch, so an engine without the API behaves exactly as before. - `IsVendor(id)` uses it, so opening by id works. - The by-name search is a single nearest-match loop over the landscape objects using `IsVendorObject`. The cheap name test runs before the bitfield read. ## How it was tested Build (from the worktree root): dotnet build Plugins\RynthCore.Plugin.RynthAi\RynthCore.Plugin.RynthAi.csproj -c Release -r win-x86 -nodeReuse:false Result: Build succeeded, 0 Error(s). Host tests (from `Tools\RynthCore.RynthAiHostTests`): dotnet run -c Release -- "Vendor" -> 20 test(s), 140 check(s): 20 passed, 0 failed dotnet run -c Release -> 1499 test(s), 15376 check(s): 1498 passed, 1 failed The one failure is `map bake: 0x6346 from the real dats ...`, which needs the game dats and also fails on pristine upstream/main (baseline 1494/1495). The new `VendorFlagTests` (4 tests: found by name, by id, by partial name; an unflagged object is not a vendor) are registered with one line in `Program.cs`. ## Scope and risk 3 files: `Vendor/AutoVendorManager.cs`, `Tests/VendorFlagTests.cs` (new), and one registration line in `Program.cs`. Only vendor discovery changes. Risk: any object carrying the vendor bit and matching the name is now a candidate; the nearest wins. Needs the engine's `TryGetObjectBitfield`; without it, behaviour is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The world cache never assigns AcObjectClass.Vendor, so a vendor was never found by name or id. Recognise a vendor by the server's BF_VENDOR bit (PublicWeenieDesc bitfield 0x200), or the cache class if one is ever set, and open the nearest match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This pull request has changes conflicting with the target branch.
  • Plugins/RynthCore.Plugin.RynthAi/Vendor/AutoVendorManager.cs
  • Tools/RynthCore.RynthAiHostTests/Program.cs
  • Tools/RynthCore.RynthAiHostTests/Tests/VendorFlagTests.cs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u autovendor-vendor-bitfield:AwfulWaffle-autovendor-vendor-bitfield
git switch AwfulWaffle-autovendor-vendor-bitfield

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff AwfulWaffle-autovendor-vendor-bitfield
git switch AwfulWaffle-autovendor-vendor-bitfield
git rebase main
git switch main
git merge --ff-only AwfulWaffle-autovendor-vendor-bitfield
git switch AwfulWaffle-autovendor-vendor-bitfield
git rebase main
git switch main
git merge --no-ff AwfulWaffle-autovendor-vendor-bitfield
git switch main
git merge --squash AwfulWaffle-autovendor-vendor-bitfield
git switch main
git merge --ff-only AwfulWaffle-autovendor-vendor-bitfield
git switch main
git merge AwfulWaffle-autovendor-vendor-bitfield
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rynth/RynthSuite!20
No description provided.