MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Rebuild

Method Rebuild

src/roadstop.cpp:321–351  ·  view source on GitHub ↗

* 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 */

Source from the content-addressed store, hash-verified

319 * @param side the side of the road stop to look at
320 */
321void 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/**

Callers 2

ClearDriveThroughMethod · 0.45
CheckIntegrityMethod · 0.45

Calls 8

GetDriveThroughStopAxisFunction · 0.85
GetEntryDirectionFunction · 0.85
TileOffsByAxisFunction · 0.85
VehiclesOnTileClass · 0.85
DirToDiagDirFunction · 0.85
includeFunction · 0.85
TestMethod · 0.80
IsPrimaryVehicleMethod · 0.45

Tested by

no test coverage detected