Changeset - r8387:889be407f050
[Not reviewed]
master
0 2 0
peter1138 - 17 years ago 2008-01-23 09:43:53
peter1138@openttd.org
(svn r11957) -Codechange [FS#1678]: Minor simplification and optimisation when checking for available road/rail types (bilbo)
2 files changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/rail.cpp
Show inline comments
 
@@ -164,17 +164,18 @@ RailType GetBestRailtype(const PlayerID 
 
}
 

	
 
RailTypes GetPlayerRailtypes(PlayerID p)
 
{
 
	RailTypes rt = RAILTYPES_NONE;
 

	
 
	for (EngineID i = 0; i != TOTAL_NUM_ENGINES; i++) {
 
	EngineID i;
 
	FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_TRAIN) {
 
		const Engine* e = GetEngine(i);
 
		const EngineInfo *ei = EngInfo(i);
 

	
 
		if (e->type == VEH_TRAIN && HasBit(ei->climates, _opt.landscape) &&
 
		if (HasBit(ei->climates, _opt.landscape) &&
 
				(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
 
			const RailVehicleInfo *rvi = RailVehInfo(i);
 

	
 
			if (rvi->railveh_type != RAILVEH_WAGON) {
 
				assert(rvi->railtype < RAILTYPE_END);
 
				SetBit(rt, rvi->railtype);
src/road.cpp
Show inline comments
 
@@ -93,17 +93,18 @@ bool ValParamRoadType(const RoadType rt)
 
}
 

	
 
RoadTypes GetPlayerRoadtypes(PlayerID p)
 
{
 
	RoadTypes rt = ROADTYPES_NONE;
 

	
 
	for (EngineID i = 0; i != TOTAL_NUM_ENGINES; i++) {
 
	EngineID i;
 
	FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_ROAD) {
 
		const Engine* e = GetEngine(i);
 
		const EngineInfo *ei = EngInfo(i);
 

	
 
		if (e->type == VEH_ROAD && HasBit(ei->climates, _opt.landscape) &&
 
		if (HasBit(ei->climates, _opt.landscape) &&
 
				(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
 
			SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
 
		}
 
	}
 

	
 
	return rt;
0 comments (0 inline, 0 general)