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

Method SetDisplayedRow

src/station_gui.cpp:1676–1699  ·  view source on GitHub ↗

* Mark a specific row, characterized by its CargoDataEntry, as expanded. * @param entry The row to be marked as expanded. */

Source from the content-addressed store, hash-verified

1674 * @param entry The row to be marked as expanded.
1675 */
1676 void SetDisplayedRow(const CargoDataEntry &entry)
1677 {
1678 std::list<StationID> stations;
1679 const CargoDataEntry *parent = entry.GetParent();
1680 if (parent->GetParent() == nullptr) {
1681 this->displayed_rows.push_back(RowDisplay(&this->expanded_rows, entry.GetCargo()));
1682 return;
1683 }
1684
1685 StationID next = entry.GetStation();
1686 while (parent->GetParent()->GetParent() != nullptr) {
1687 stations.push_back(parent->GetStation());
1688 parent = parent->GetParent();
1689 }
1690
1691 CargoType cargo = parent->GetCargo();
1692 CargoDataEntry *filter = this->expanded_rows.Retrieve(cargo);
1693 while (!stations.empty()) {
1694 filter = filter->Retrieve(stations.back());
1695 stations.pop_back();
1696 }
1697
1698 this->displayed_rows.push_back(RowDisplay(filter, next));
1699 }
1700
1701 /**
1702 * Select the correct string for an entry referring to the specified station.

Callers 1

DrawEntriesMethod · 0.95

Calls 8

RowDisplayClass · 0.85
push_backMethod · 0.80
GetCargoMethod · 0.80
GetStationMethod · 0.80
pop_backMethod · 0.80
GetParentMethod · 0.45
RetrieveMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected