mirror of https://github.com/OpenTTD/OpenTTD
(svn r25346) -Codechange: Glue between stations and flow stats
parent
c8f068d979
commit
db671ffb86
|
@ -97,6 +97,11 @@ Station::~Station()
|
||||||
delete lg;
|
delete lg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Station *st;
|
||||||
|
FOR_ALL_STATIONS(st) {
|
||||||
|
GoodsEntry *ge = &st->goods[c];
|
||||||
|
ge->flows.DeleteFlows(this->index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
|
|
|
@ -196,6 +196,7 @@ struct GoodsEntry {
|
||||||
|
|
||||||
LinkGraphID link_graph; ///< Link graph this station belongs to.
|
LinkGraphID link_graph; ///< Link graph this station belongs to.
|
||||||
NodeID node; ///< ID of node in link graph referring to this goods entry.
|
NodeID node; ///< ID of node in link graph referring to this goods entry.
|
||||||
|
FlowStatMap flows; ///< Planned flows through this station.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reports whether a vehicle has ever tried to load the cargo at this station.
|
* Reports whether a vehicle has ever tried to load the cargo at this station.
|
||||||
|
@ -212,6 +213,33 @@ struct GoodsEntry {
|
||||||
{
|
{
|
||||||
return HasBit(this->acceptance_pickup, GES_PICKUP);
|
return HasBit(this->acceptance_pickup, GES_PICKUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint GetSumFlowVia(StationID via) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the best next hop for a cargo packet from station source.
|
||||||
|
* @param source Source of the packet.
|
||||||
|
* @return The chosen next hop or INVALID_STATION if none was found.
|
||||||
|
*/
|
||||||
|
inline StationID GetVia(StationID source) const
|
||||||
|
{
|
||||||
|
FlowStatMap::const_iterator flow_it(this->flows.find(source));
|
||||||
|
return flow_it != this->flows.end() ? flow_it->second.GetVia() : INVALID_STATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the best next hop for a cargo packet from station source, optionally
|
||||||
|
* excluding one or two stations.
|
||||||
|
* @param source Source of the packet.
|
||||||
|
* @param excluded If this station would be chosen choose the second best one instead.
|
||||||
|
* @param excluded2 Second station to be excluded, if != INVALID_STATION.
|
||||||
|
* @return The chosen next hop or INVALID_STATION if none was found.
|
||||||
|
*/
|
||||||
|
inline StationID GetVia(StationID source, StationID excluded, StationID excluded2 = INVALID_STATION) const
|
||||||
|
{
|
||||||
|
FlowStatMap::const_iterator flow_it(this->flows.find(source));
|
||||||
|
return flow_it != this->flows.end() ? flow_it->second.GetVia(excluded, excluded2) : INVALID_STATION;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** All airport-related information. Only valid if tile != INVALID_TILE. */
|
/** All airport-related information. Only valid if tile != INVALID_TILE. */
|
||||||
|
|
|
@ -4161,6 +4161,20 @@ void FlowStatMap::DeleteFlows(StationID via)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sum of flows via a specific station from this GoodsEntry.
|
||||||
|
* @param via Remote station to look for.
|
||||||
|
* @return a FlowStat with all flows for 'via' added up.
|
||||||
|
*/
|
||||||
|
uint GoodsEntry::GetSumFlowVia(StationID via) const
|
||||||
|
{
|
||||||
|
uint ret = 0;
|
||||||
|
for (FlowStatMap::const_iterator i = this->flows.begin(); i != this->flows.end(); ++i) {
|
||||||
|
ret += i->second.GetShare(via);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
extern const TileTypeProcs _tile_type_station_procs = {
|
extern const TileTypeProcs _tile_type_station_procs = {
|
||||||
DrawTile_Station, // draw_tile_proc
|
DrawTile_Station, // draw_tile_proc
|
||||||
GetSlopePixelZ_Station, // get_slope_z_proc
|
GetSlopePixelZ_Station, // get_slope_z_proc
|
||||||
|
|
Loading…
Reference in New Issue