src/road.cpp
branchnoai
changeset 9724 b39bc69bb2f2
parent 9723 eee46cb39750
child 9837 c9ec4f82e0d0
equal deleted inserted replaced
9723:eee46cb39750 9724:b39bc69bb2f2
     4 #include "openttd.h"
     4 #include "openttd.h"
     5 #include "rail_map.h"
     5 #include "rail_map.h"
     6 #include "road_map.h"
     6 #include "road_map.h"
     7 #include "road_internal.h"
     7 #include "road_internal.h"
     8 #include "water_map.h"
     8 #include "water_map.h"
       
     9 #include "genworld.h"
       
    10 #include "player_func.h"
       
    11 #include "player_base.h"
       
    12 #include "engine.h"
       
    13 #include "settings_type.h"
       
    14 #include "date_func.h"
     9 
    15 
    10 bool IsPossibleCrossing(const TileIndex tile, Axis ax)
    16 bool IsPossibleCrossing(const TileIndex tile, Axis ax)
    11 {
    17 {
    12 	return (IsTileType(tile, MP_RAILWAY) &&
    18 	return (IsTileType(tile, MP_RAILWAY) &&
    13 		!HasSignals(tile) &&
    19 		!HasSignals(tile) &&
    65 		}
    71 		}
    66 	}
    72 	}
    67 
    73 
    68 	return org_rb;
    74 	return org_rb;
    69 }
    75 }
       
    76 
       
    77 bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts)
       
    78 {
       
    79 	RoadTypes avail_roadtypes;
       
    80 
       
    81 	if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
       
    82 		avail_roadtypes = ROADTYPES_ROAD;
       
    83 	} else {
       
    84 		if (!IsValidPlayer(p)) return false;
       
    85 		avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
       
    86 	}
       
    87 	return (rts & ~avail_roadtypes) == 0;
       
    88 }
       
    89 
       
    90 bool ValParamRoadType(const RoadType rt)
       
    91 {
       
    92 	return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt));
       
    93 }
       
    94 
       
    95 RoadTypes GetPlayerRoadtypes(PlayerID p)
       
    96 {
       
    97 	RoadTypes rt = ROADTYPES_NONE;
       
    98 
       
    99 	EngineID i;
       
   100 	FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_ROAD) {
       
   101 		const Engine* e = GetEngine(i);
       
   102 		const EngineInfo *ei = EngInfo(i);
       
   103 
       
   104 		if (HasBit(ei->climates, _opt.landscape) &&
       
   105 				(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
       
   106 			SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
       
   107 		}
       
   108 	}
       
   109 
       
   110 	return rt;
       
   111 }