* Rebuild, from scratch, the vehicles and other metadata on this stop. * @param rs the roadstop this entry is part of * @param side the side of the road stop to look at */
| 319 | * @param side the side of the road stop to look at |
| 320 | */ |
| 321 | void RoadStop::Entry::Rebuild(const RoadStop *rs, int side) |
| 322 | { |
| 323 | assert(rs->status.Test(RoadStopStatusFlag::BaseEntry)); |
| 324 | |
| 325 | Axis axis = GetDriveThroughStopAxis(rs->xy); |
| 326 | if (side == -1) side = (&rs->entries->east == this); |
| 327 | |
| 328 | auto entry_dir = GetEntryDirection(side, axis); |
| 329 | std::vector<const RoadVehicle *> vehicles; |
| 330 | |
| 331 | this->length = 0; |
| 332 | TileIndexDiff offset = TileOffsByAxis(axis); |
| 333 | for (TileIndex tile = rs->xy; IsDriveThroughRoadStopContinuation(rs->xy, tile); tile += offset) { |
| 334 | this->length += TILE_SIZE; |
| 335 | for (const Vehicle *v : VehiclesOnTile(tile)) { |
| 336 | /* Not a RV or not in the right direction or crashed :( */ |
| 337 | if (v->type != VEH_ROAD || DirToDiagDir(v->direction) != entry_dir || !v->IsPrimaryVehicle() || v->vehstatus.Test(VehState::Crashed)) continue; |
| 338 | |
| 339 | const RoadVehicle *rv = RoadVehicle::From(v); |
| 340 | /* Don't add ones not in a road stop */ |
| 341 | if (rv->state < RVSB_IN_ROAD_STOP) continue; |
| 342 | |
| 343 | include(vehicles, rv); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | this->occupied = 0; |
| 348 | for (const auto &it : vehicles) { |
| 349 | this->occupied += it->gcache.cached_total_length; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | |
| 354 | /** |
no test coverage detected