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

Method SearchNonStop

src/station_gui.cpp:1739–1765  ·  view source on GitHub ↗

* Determine if we need to show the special "non-stop" string. * @param cd Entry we are going to show. * @param station Station the entry refers to. * @param column The "column" the entry will be shown in. * @return either STR_STATION_VIEW_VIA or STR_STATION_VIEW_NONSTOP. */

Source from the content-addressed store, hash-verified

1737 * @return either STR_STATION_VIEW_VIA or STR_STATION_VIEW_NONSTOP.
1738 */
1739 StringID SearchNonStop(CargoDataEntry &cd, StationID station, int column)
1740 {
1741 assert(column < NUM_COLUMNS);
1742 CargoDataEntry *parent = cd.GetParent();
1743 for (int i = column - 1; i > 0; --i) {
1744 if (this->groupings[i] == GR_DESTINATION) {
1745 if (parent->GetStation() == station) {
1746 return STR_STATION_VIEW_NONSTOP;
1747 } else {
1748 return STR_STATION_VIEW_VIA;
1749 }
1750 }
1751 parent = parent->GetParent();
1752 }
1753
1754 if (column < NUM_COLUMNS - 1 && this->groupings[column + 1] == GR_DESTINATION) {
1755 CargoDataSet::iterator begin = cd.Begin();
1756 CargoDataSet::iterator end = cd.End();
1757 if (begin != end && ++(cd.Begin()) == end && (*(begin))->GetStation() == station) {
1758 return STR_STATION_VIEW_NONSTOP;
1759 } else {
1760 return STR_STATION_VIEW_VIA;
1761 }
1762 }
1763
1764 return STR_STATION_VIEW_VIA;
1765 }
1766
1767 /**
1768 * Draw icons of waiting cargo.

Callers 1

DrawEntriesMethod · 0.95

Calls 4

GetStationMethod · 0.80
GetParentMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected