Skip to content

Highlight matching contract fields on the course generator map#1289

Open
helgehelge123 wants to merge 1 commit into
Courseplay:mainfrom
helgehelge123:highlight-matching-contracts-on-ai-map
Open

Highlight matching contract fields on the course generator map#1289
helgehelge123 wants to merge 1 commit into
Courseplay:mainfrom
helgehelge123:highlight-matching-contracts-on-ai-map

Conversation

@helgehelge123

@helgehelge123 helgehelge123 commented Jul 6, 2026

Copy link
Copy Markdown

Problem

When creating a new job on the course generator map, all active contracts show up as identical red circles. With several contracts of different types, there is no way to see on the map which of those fields the currently selected vehicle can actually work on — you have to remember the field numbers or go back and forth with the contracts menu.

Change

The fields of the player's active field missions now get a pulsing green field border on the course generator map page when the currently selected vehicle has a matching implement. Non-matching contracts stay as they are (red circle only).

One file changed, additions only: CpCourseGeneratorFrame.lua.

How the matching works

No per-mission-type mapping is needed. Each field mission already declares the work area types it accepts (mission.workAreaTypes, e.g. WorkAreaType.PLOW for plow missions) — the same data the base game checks in AbstractFieldMission:getIsWorkAllowed() before letting a tool work on a mission field. The highlight simply tests those against the work area types of the vehicle and all of its attached implements (using the existing WorkWidthUtil.workAreaIterator / isValidWorkArea, which already excludes ridge markers and combine swath/chopper areas). So the highlight can never disagree with what the game would actually allow.

Missions are considered when they belong to the player's farm and are in RUNNING or PREPARING state.

Performance

  • The field polygon of a highlighted mission is fetched once (CpFieldUtil.getFieldPolygon), simplified to ~5 m resolution and cached; the cache is reset when the frame opens.
  • The implement work-area scan runs only when the vehicle changes, re-checked every 2 s so attaching/detaching implements with the menu open is picked up.
  • Drawing reuses a single FieldPlot instance, same drawing path as the existing custom field plots.

Testing

Tested in game (FS25 single player, patched zip of the current release): with a hoe attached, the hoeing contract fields pulse green on the map while other contract types keep only their red circle; highlight follows the selected vehicle and updates after attaching a different implement. Confirmed working by the reporter of the request in our group.

Not tested: multiplayer (the code only reads g_localPlayer.farmId and mission state client-side, no network traffic involved).

Note

The highlight is currently always on. If you would prefer it behind a global setting, happy to add one — just was not sure whether a new setting is wanted for a pure map visualization.

🤖 Generated with Claude Code

Screenshot

Vehicle with a matching implement selected: field 68 (matching active contract) gets the pulsing green border, the other contracts (60, 70, 79) keep just their red circle.

Contract highlight on the course generator map

… map

On the course generator map page, the fields of the player's active field
missions now get a pulsing green border when the currently selected vehicle
has an implement whose work area type the mission accepts. This makes it
easy to spot which of the contract fields (red circles on the map) the
vehicle can actually work on when creating a new job.

The matching is fully generic and needs no per-mission-type mapping: each
field mission already declares the work area types it accepts
(mission.workAreaTypes), which is exactly what the base game checks in
AbstractFieldMission:getIsWorkAllowed(). We test those against the work
area types of the vehicle and all its attached implements.

The field polygon of each highlighted mission is fetched once, simplified
and cached, and the implement scan is throttled to every 2 seconds, so the
per-frame cost of the highlight is negligible.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Tensuko Tensuko requested a review from pvaiko July 6, 2026 16:34
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