Skip to content

BUG FIX: fix stray track reservations when route changes during operation#586

Open
kanyao1230 wants to merge 1 commit into
teamhimeh:OTRP-KUTAv6from
kanyao1230:feature/fix-route-cache-reservation
Open

BUG FIX: fix stray track reservations when route changes during operation#586
kanyao1230 wants to merge 1 commit into
teamhimeh:OTRP-KUTAv6from
kanyao1230:feature/fix-route-cache-reservation

Conversation

@kanyao1230

Copy link
Copy Markdown

概要

鉄道の運行中に経路が変わった際、もとの線路の予約が解除されずに残ってしまう問題を修正します。経路探索キャッシュのオン・オフにかかわらず発生しますが、キャッシュがオンの場合に特に顕在化しやすい状態でした。

原因

suche_neue_route() が呼ばれると(信号遮断・線路変更・その他の経路再計算要求時)、state = ROUTING_1 がセットされるだけで、既存の線路予約は解除されません。

その後 drive_to() が呼ばれ、cached_calc_route() によって route メンバが新しい経路で上書きされます。しかし、block_reserver によって確保された古い経路の前方予約済み線路(列車先頭より前方のタイル)は誰にも解除されず、そのまま残り続けます。

経路探索キャッシュがオンの場合、過去に使った経路がそのままキャッシュから返されるため、A* と比べて現在の経路との乖離が大きくなりやすく、症状が顕在化しやすい状態でした。

修正内容

drive_to() 内で cached_calc_route()route を置き換える直前に unreserve_route() を呼ぶよう変更しました。これにより、古い経路の前方予約がすべて解除されます。その後、列車が走行を再開すると block_reserver が新しい経路に対して正しく再予約します。

…y track reservations

When suche_neue_route() triggers a mid-journey reroute, drive_to() replaced
the route without first unreserving the old one. Tiles ahead of the front
vehicle on the old route remained reserved. This was especially visible with
route caching enabled. Fix: call unreserve_route() before cached_calc_route().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread simconvoi.cc
}

// unreserve old route before replacing to avoid stray reservations when rerouted
unreserve_route();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

すでにrail_vehicle_t::calc_route()では予約解除を行っています。この処理との整合性(呼ぶ順序等の確認)を行ってください

@simupoppo simupoppo Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

また、convoi_t::step()case NO_ROUTEにもunreserve_route()を追記しておくと良いかもしれません

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.

2 participants