BUG FIX: fix stray track reservations when route changes during operation#586
Open
kanyao1230 wants to merge 1 commit into
Open
BUG FIX: fix stray track reservations when route changes during operation#586kanyao1230 wants to merge 1 commit into
kanyao1230 wants to merge 1 commit into
Conversation
…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>
simupoppo
reviewed
Jun 12, 2026
| } | ||
|
|
||
| // unreserve old route before replacing to avoid stray reservations when rerouted | ||
| unreserve_route(); |
Collaborator
There was a problem hiding this comment.
すでにrail_vehicle_t::calc_route()では予約解除を行っています。この処理との整合性(呼ぶ順序等の確認)を行ってください
Collaborator
There was a problem hiding this comment.
また、convoi_t::step()のcase NO_ROUTEにもunreserve_route()を追記しておくと良いかもしれません
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
鉄道の運行中に経路が変わった際、もとの線路の予約が解除されずに残ってしまう問題を修正します。経路探索キャッシュのオン・オフにかかわらず発生しますが、キャッシュがオンの場合に特に顕在化しやすい状態でした。
原因
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が新しい経路に対して正しく再予約します。