Skip to content

Fix the findings from the review of #13 - #20

Merged
KoertLichtendonk merged 2 commits into
mainfrom
dev
Nov 23, 2026
Merged

KoertLichtendonk merged 2 commits into
mainfrom
dev

Conversation

@KoertLichtendonk

Copy link
Copy Markdown
Member

Fixes the confirmed findings from Claude's review of #13. Each finding was checked against the code first; overstated ones are only documented.

Changes

  • Fishing: PublishFishCaught returns Task; the net item is only taken once the net exists; net dialogs check again that the player is still playing their character and may use the net.
  • Vehicles: /park saves the virtual world and interior; the editor looks the live vehicle up again before saving and refuses if it's gone; deleting a vehicle uses a short-lived context.
  • New server event OnVehicleDeleted: published when a saved vehicle is deleted. Radios and Fishing clean up their own radio and net, so Vehicles no longer calls into them.
  • Maps: despawning skips objects that are already gone; a bulk replace of a map that wasn't loaded applies its removed buildings.
  • /government sets the binding to what the menu showed.
  • Banking: the fee cap prompt says 10000 instead of 10,000, because the parser refuses thousands separators on purpose.
  • Docs: the stuck heavy-fish limitation, CatchWeight and seed id notes for hosts, OnVehicleDeleted, /park, /deletevehicle <vehicle id>.

Not fixed in code, by decision: net-only fish (25 kg+) can't leave the net; a selling point at the docks will handle them later. Documented as a known limitation.

Database

Hosts need a migration:

No NuGet packages changed. Built with dotnet build; not tested in game yet.

- Fishing: PublishFishCaught returns Task, the net item is only taken once the net exists, net dialogs re-check the character and access
- Vehicles: /park keeps the world and interior, the editor saves the live vehicle, deleting a vehicle uses a short-lived context and publishes OnVehicleDeleted, which Fishing and Radios handle
- Maps: despawning skips objects that are gone, a bulk replace of an unloaded map applies its removed buildings
- /government sets binding to what the menu showed; the bank fee cap prompt no longer shows a thousands separator
- Docs: fishing limitation, CatchWeight and seed ids for hosts, OnVehicleDeleted, /deletevehicle notation

Database: Vehicles.VirtualWorld and Interior default to 0, Vehicles.ServerVehicle defaults to false, FishLoot.LootKind, SizeClass, RequiredFishingLevel and IsNetOnly get database defaults. Hosts need a migration.
_logger.LogError(ex, "Removing the keys of deleted vehicle {VehicleId} failed.", vehicleId);
}
RemoveVehicleFishingNet(vehicleId);
_ = _serverEventAggregator.PublishAsync(new OnVehicleDeletedEventArgs { VehicleId = vehicleId });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: this relies on every OnVehicleDeleted handler finishing before its first await, because DestroyLoadedVehicle runs right after. The two Framework handlers are synchronous, so this works today. But a host that writes an async Task handler will find the vehicle already destroyed after its first await, and nothing in the docs tells them.

Could you add that to the OnVehicleDeleted row in docs/server-events.md (for example "The loaded vehicle is destroyed right after; a handler that awaits can't use it after its first await"), so host authors know? The other option is to make the delete async and await the publish before destroying the vehicle, but that is a bigger change.

/// A map that was already in the game has them applied; applying them twice would count twice against the
/// player's limit.
/// </summary>
private void ApplyRemovedBuildings(Map map)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion: this loop is the same as the one at the end of MapEditorService.LoadMap (foreach (MapRemovedBuilding removal in map.GetRemovedBuildings()) _mapService.ApplyRemovedBuilding(removal);). A public IMapService.ApplyRemovedBuildings(Map map) (with a /// <summary>) would let both places call one method, so a later change to how removals apply (for example the player limit this comment mentions) only has to be made once.

/// Another admin can replace (a model change) or delete the vehicle while this editor is open, so the save looks
/// the live vehicle up again. False when the editor had a live vehicle and it's gone.
/// </summary>
private bool RefreshEditedVehicle()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming nit: Refresh… isn't in the verb list in AGENTS.md ("How code is written"), and this method both changes _component.EditedVehicle and answers a yes/no question. LoadEditedVehicle() (it looks the live vehicle up again and stores it) fits the vocabulary and still reads well as if (!LoadEditedVehicle()). See conventions.

@claude

claude Bot commented Nov 23, 2026

Copy link
Copy Markdown

Review

Verdict: Ready to merge
This pull request fixes the findings from the review of #13: PublishFishCaught now returns Task, the net item is taken only after the net exists, /park saves the virtual world and interior, and vehicle deletion uses a short-lived context. Vehicles no longer calls into Radios and Fishing: it publishes the new OnVehicleDeleted event instead. I found nothing blocking. The release build passes with no new warnings. The three inline comments below are small and can be fixed here or later.

Should fix

  • OnVehicleDeleted is published without being awaited, and the loaded vehicle is destroyed right after. Host handlers that await should know this. A line in docs/server-events.md would cover it.
  • The removed-buildings loop in MapBulkService.ApplyRemovedBuildings repeats the one in MapEditorService.LoadMap. It could be one IMapService method (suggestion).
  • RefreshEditedVehicle uses a name outside the verb vocabulary, for example LoadEditedVehicle (nit).

Docs: up to date (OnVehicleDeleted, /park, /deletevehicle, the fish seed and CatchWeight notes, and the new net-only fish limitation; links and #onvehicledeleted resolve)
Database: changes: database defaults on Vehicles.ServerVehicle (false), VirtualWorld and Interior (0), and on FishLoot.LootKind, SizeClass, RequiredFishingLevel and IsNetOnly (hosts need a migration; stated in the description)
Tested in game: not yet; the description says it was only built with dotnet build

- IMapService.ApplyRemovedBuildings(Map) applies a map's removed buildings; loading a map and a bulk replace both use it
- The vehicle editor's LoadEditedVehicle (was RefreshEditedVehicle) follows the verb vocabulary
- Docs: OnVehicleDeleted handlers must do their work before any await, because the vehicle is destroyed right after publishing
@claude

claude Bot commented Nov 23, 2026

Copy link
Copy Markdown

Review

Verdict: Ready to merge
This pull request fixes the findings from the review of #13. Vehicles now publishes the new OnVehicleDeleted event, and Radios and Fishing clean up after themselves. I reviewed the whole pull request again, including the new commit 5869780, and found nothing new to fix. The release build passes with 0 errors and no warnings.

All three points from my earlier review are now fixed:

  • The OnVehicleDeleted row in docs/server-events.md now says handlers must do their work before any await, because the vehicle is destroyed right after the event is published.
  • The duplicated removed-buildings loop is now one method, IMapService.ApplyRemovedBuildings(Map), with a /// <summary>. MapEditorService.LoadMap and MapBulkService both call it.
  • RefreshEditedVehicle is renamed to LoadEditedVehicle.

Docs: up to date (OnVehicleDeleted, /park, /deletevehicle <vehicle id>, the fish seed and CatchWeight notes, the net-only fish limitation; the #onvehicledeleted anchor works)
Database: changes: database defaults on Vehicles.ServerVehicle (false), VirtualWorld and Interior (0), and on FishLoot.LootKind, SizeClass, RequiredFishingLevel and IsNetOnly. Hosts need a migration; the description and the commit message both say so.
Tested in game: not yet; the description says it was only built with dotnet build

@KoertLichtendonk
KoertLichtendonk merged commit c3b4282 into main Nov 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant