Commit 1d352e1
committed
Fix arrival vs. termination handling to avoid wrong stats and double counting
The new station-aware routing introduced a bug where train arrivals were being
double-counted and termination conditions were incorrectly classified as arrivals.
Problems fixed:
- targetReached() was called twice for successful arrivals: once in getNextTile()
when destination was reached, and again in tick() when no tile was returned
- Trains removed due to hop limit were counted as successful arrivals
- Trains stuck with no routing options were counted as successful arrivals
Solution implemented:
- Introduced MoveResult union type with explicit cases: "move", "arrived",
"hopLimit", "stuck" to clearly distinguish termination conditions
- Renamed getNextTile() to getNextStep() and changed return type to MoveResult
- Removed targetReached() call from navigation logic to prevent double counting
- Updated tick() method to use switch statement on MoveResult for proper handling
- Ensured recordTrainArrival() only called for actual destination arrivals
- Ensured recordTrainRemovedDueToHopLimit() only called for hop limit terminations
- Stuck trains are deleted without recording any arrival statistics
This ensures accurate train statistics tracking with the new routing system.1 parent d6c1dc4 commit 1d352e1
1 file changed
+38
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
136 | 142 | | |
137 | 143 | | |
138 | 144 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
145 | 163 | | |
146 | 164 | | |
147 | 165 | | |
| |||
262 | 280 | | |
263 | 281 | | |
264 | 282 | | |
265 | | - | |
| 283 | + | |
266 | 284 | | |
267 | 285 | | |
268 | 286 | | |
| |||
273 | 291 | | |
274 | 292 | | |
275 | 293 | | |
276 | | - | |
277 | | - | |
| 294 | + | |
278 | 295 | | |
279 | 296 | | |
280 | 297 | | |
281 | 298 | | |
282 | 299 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | 300 | | |
287 | | - | |
| 301 | + | |
288 | 302 | | |
289 | 303 | | |
290 | 304 | | |
| |||
295 | 309 | | |
296 | 310 | | |
297 | 311 | | |
298 | | - | |
299 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
300 | 315 | | |
301 | 316 | | |
302 | 317 | | |
303 | 318 | | |
304 | 319 | | |
305 | | - | |
| 320 | + | |
| 321 | + | |
306 | 322 | | |
307 | 323 | | |
308 | 324 | | |
| |||
339 | 355 | | |
340 | 356 | | |
341 | 357 | | |
342 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
343 | 362 | | |
344 | 363 | | |
345 | | - | |
| 364 | + | |
| 365 | + | |
346 | 366 | | |
347 | 367 | | |
348 | 368 | | |
| |||
0 commit comments