src/road.cpp
changeset 8732 b18f578f7c16
parent 8627 448ebf3a8291
child 8750 fdd6054e7bae
equal deleted inserted replaced
8731:a2cab8a23491 8732:b18f578f7c16
     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.h"
       
    11 #include "engine.h"
       
    12 #include "settings_type.h"
       
    13 #include "date_func.h"
     9 
    14 
    10 bool IsPossibleCrossing(const TileIndex tile, Axis ax)
    15 bool IsPossibleCrossing(const TileIndex tile, Axis ax)
    11 {
    16 {
    12 	return (IsTileType(tile, MP_RAILWAY) &&
    17 	return (IsTileType(tile, MP_RAILWAY) &&
    13 		!HasSignals(tile) &&
    18 		!HasSignals(tile) &&
    65 		}
    70 		}
    66 	}
    71 	}
    67 
    72 
    68 	return org_rb;
    73 	return org_rb;
    69 }
    74 }
       
    75 
       
    76 bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts)
       
    77 {
       
    78 	RoadTypes avail_roadtypes;
       
    79 
       
    80 	if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
       
    81 		avail_roadtypes = ROADTYPES_ROAD;
       
    82 	} else {
       
    83 		if (!IsValidPlayer(p)) return false;
       
    84 		avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
       
    85 	}
       
    86 	return (rts & ~avail_roadtypes) == 0;
       
    87 }
       
    88 
       
    89 bool ValParamRoadType(const RoadType rt)
       
    90 {
       
    91 	return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt));
       
    92 }
       
    93 
       
    94 RoadTypes GetPlayerRoadtypes(PlayerID p)
       
    95 {
       
    96 	RoadTypes rt = ROADTYPES_NONE;
       
    97 
       
    98 	for (EngineID i = 0; i != TOTAL_NUM_ENGINES; i++) {
       
    99 		const Engine* e = GetEngine(i);
       
   100 		const EngineInfo *ei = EngInfo(i);
       
   101 
       
   102 		if (e->type == VEH_ROAD && HasBit(ei->climates, _opt.landscape) &&
       
   103 				(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
       
   104 			SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
       
   105 		}
       
   106 	}
       
   107 
       
   108 	return rt;
       
   109 }