Changeset - r23428:4a18cf6bbfe5
[Not reviewed]
master
0 6 0
peter1138 - 6 years ago 2019-02-24 18:52:15
peter1138@openttd.org
Codechange: Convert StationList from SmallVector to std::set.
6 files changed with 17 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -2432,7 +2432,7 @@ static int WhoCanServiceIndustry(Industr
 
	StationList stations;
 
	FindStationsAroundTiles(ind->location, &stations);
 

	
 
	if (stations.Length() == 0) return 0; // No stations found at all => nobody services
 
	if (stations.size() == 0) return 0; // No stations found at all => nobody services
 

	
 
	const Vehicle *v;
 
	int result = 0;
 
@@ -2468,7 +2468,7 @@ static int WhoCanServiceIndustry(Industr
 
				/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
 
				if ((o->GetUnloadType() & OUFB_UNLOAD) && !c_accepts) break;
 

	
 
				if (stations.Contains(st)) {
 
				if (stations.find(st) != stations.end()) {
 
					if (v->owner == _local_company) return 2; // Company services industry
 
					result = 1; // Competitor services industry
 
				}
src/newgrf_house.cpp
Show inline comments
 
@@ -350,8 +350,7 @@ static uint32 GetDistanceFromNearbyHouse
 

	
 
			/* Collect acceptance stats. */
 
			uint32 res = 0;
 
			for (Station * const * st_iter = sl->Begin(); st_iter != sl->End(); st_iter++) {
 
				const Station *st = *st_iter;
 
			for (Station *st : *sl) {
 
				if (HasBit(st->goods[cid].status, GoodsEntry::GES_EVER_ACCEPTED))    SetBit(res, 0);
 
				if (HasBit(st->goods[cid].status, GoodsEntry::GES_LAST_MONTH))       SetBit(res, 1);
 
				if (HasBit(st->goods[cid].status, GoodsEntry::GES_CURRENT_MONTH))    SetBit(res, 2);
src/script/api/script_industry.cpp
Show inline comments
 
@@ -134,7 +134,7 @@
 
	Industry *ind = ::Industry::Get(industry_id);
 
	StationList stations;
 
	::FindStationsAroundTiles(ind->location, &stations);
 
	return (int32)stations.Length();
 
	return (int32)stations.size();
 
}
 

	
 
/* static */ int32 ScriptIndustry::GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile)
src/station.cpp
Show inline comments
 
@@ -571,3 +571,8 @@ Money AirportMaintenanceCost(Owner owner
 
	/* 3 bits fraction for the maintenance cost factor. */
 
	return total_cost >> 3;
 
}
 

	
 
bool StationCompare::operator() (const Station *lhs, const Station *rhs) const
 
{
 
	return lhs->index < rhs->index;
 
}
src/station_cmd.cpp
Show inline comments
 
@@ -3839,7 +3839,7 @@ void FindStationsAroundTiles(const TileA
 
			/* Insert the station in the set. This will fail if it has
 
			 * already been added.
 
			 */
 
			stations->Include(st);
 
			stations->insert(st);
 
		}
 
	}
 
}
 
@@ -3867,9 +3867,7 @@ uint MoveGoodsToStation(CargoID type, ui
 
	uint best_rating1 = 0; // rating of st1
 
	uint best_rating2 = 0; // rating of st2
 

	
 
	for (Station * const *st_iter = all_stations->Begin(); st_iter != all_stations->End(); ++st_iter) {
 
		Station *st = *st_iter;
 

	
 
	for (Station *st : *all_stations) {
 
		/* Is the station reserved exclusively for somebody else? */
 
		if (st->owner != OWNER_NONE && st->town->exclusive_counter > 0 && st->town->exclusivity != st->owner) continue;
 

	
src/station_type.h
Show inline comments
 
@@ -12,9 +12,9 @@
 
#ifndef STATION_TYPE_H
 
#define STATION_TYPE_H
 

	
 
#include "core/smallvec_type.hpp"
 
#include "core/smallstack_type.hpp"
 
#include "tilearea_type.h"
 
#include <set>
 

	
 
typedef uint16 StationID;
 
typedef uint16 RoadStopID;
 
@@ -90,8 +90,12 @@ enum CatchmentArea {
 

	
 
static const uint MAX_LENGTH_STATION_NAME_CHARS = 32; ///< The maximum length of a station name in characters including '\0'
 

	
 
struct StationCompare {
 
	bool operator() (const Station *lhs, const Station *rhs) const;
 
};
 

	
 
/** List of stations */
 
typedef SmallVector<Station *, 2> StationList;
 
typedef std::set<Station *, StationCompare> StationList;
 

	
 
/**
 
 * Structure contains cached list of stations nearby. The list
0 comments (0 inline, 0 general)