File diff r20870:322ed90de367 → r20871:d965d79314c1
src/station_cmd.cpp
Show inline comments
 
@@ -4151,32 +4151,30 @@ StationID FlowStat::GetVia(StationID exc
 
}
 

	
 
/**
 
 * Reduce all flows to minimum capacity so that they don't get in the way of
 
 * link usage statistics too much. Keep them around, though, to continue
 
 * routing any remaining cargo.
 
 */
 
void FlowStat::Invalidate()
 
{
 
	assert(!this->shares.empty());
 
	SharesMap new_shares;
 
	uint i = 0;
 
	uint orig = 0;
 
	for (SharesMap::iterator it(this->shares.begin()); it != this->shares.end(); ++it) {
 
		new_shares[++i] = it->second;
 
		orig += it->first;
 
		if (orig == this->unrestricted) this->unrestricted = orig;
 
		if (it->first == this->unrestricted) this->unrestricted = i;
 
	}
 
	this->shares.swap(new_shares);
 
	assert(!this->shares.empty());
 
	assert(!this->shares.empty() && this->unrestricted <= (--this->shares.end())->first);
 
}
 

	
 
/**
 
 * Change share for specified station. By specifing INT_MIN as parameter you
 
 * can erase a share. Newly added flows will be unrestricted.
 
 * @param st Next Hop to be removed.
 
 * @param flow Share to be added or removed.
 
 */
 
void FlowStat::ChangeShare(StationID st, int flow)
 
{
 
	/* We assert only before changing as afterwards the shares can actually
 
	 * be empty. In that case the whole flow stat must be deleted then. */