Files
@ r12162:c4894f5339c3
Branch filter:
Location: cpp/openttd-patchpack/source/src/road.cpp - annotation
r12162:c4894f5339c3
3.1 KiB
text/x-c
(svn r16583) -Update: the order of the language files so it's in sync with english.txt. Normally WT2 would do this, but only with activity for those languages. Now we'd like to the order to match so we can more easily spot import bugs while developing WT3.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | r8091:d63ba361d6b8 r8091:d63ba361d6b8 r9111:983de9c5a848 r9111:983de9c5a848 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r8236:a2ecfe92ab23 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r9070:e059c65164f3 r10960:e97ebf9cf99b r8236:a2ecfe92ab23 r11108:1df88c46bf05 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r11904:2acd21e9a0b6 r11108:1df88c46bf05 r11108:1df88c46bf05 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r10956:5bfc69fc5e37 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7832:a9b062f087f1 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r11944:3b8f9f948e8d r11944:3b8f9f948e8d r11944:3b8f9f948e8d r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r10207:a1fc2f2a33db r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r9070:e059c65164f3 r9070:e059c65164f3 r9070:e059c65164f3 r8236:a2ecfe92ab23 r9413:fcf267325763 r10744:a93a9430d707 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 | /* $Id$ */
/** @file road.cpp Generic road related functions. */
#include "stdafx.h"
#include "openttd.h"
#include "rail_map.h"
#include "road_map.h"
#include "water_map.h"
#include "genworld.h"
#include "company_func.h"
#include "company_base.h"
#include "engine_base.h"
#include "date_func.h"
#include "settings_type.h"
#include "landscape.h"
bool IsPossibleCrossing(const TileIndex tile, Axis ax)
{
return (IsTileType(tile, MP_RAILWAY) &&
GetRailTileType(tile) == RAIL_TILE_NORMAL &&
GetTrackBits(tile) == (ax == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) &&
GetFoundationSlope(tile, NULL) == SLOPE_FLAT);
}
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
{
if (!IsValidTile(tile)) return ROAD_NONE;
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
const TileIndex neighbor_tile = TileAddByDiagDir(tile, dir);
/* Get the Roadbit pointing to the neighbor_tile */
const RoadBits target_rb = DiagDirToRoadBits(dir);
/* If the roadbit is in the current plan */
if (org_rb & target_rb) {
bool connective = false;
const RoadBits mirrored_rb = MirrorRoadBits(target_rb);
switch (GetTileType(neighbor_tile)) {
/* Allways connective ones */
case MP_CLEAR: case MP_TREES:
connective = true;
break;
/* The conditionaly connective ones */
case MP_TUNNELBRIDGE:
case MP_STATION:
case MP_ROAD: {
const RoadBits neighbor_rb = GetAnyRoadBits(neighbor_tile, ROADTYPE_ROAD) | GetAnyRoadBits(neighbor_tile, ROADTYPE_TRAM);
/* Accept only connective tiles */
connective = (neighbor_rb & mirrored_rb) || // Neighbor has got the fitting RoadBit
CountBits(neighbor_rb) == 1; // Neighbor has got only one Roadbit
} break;
case MP_RAILWAY:
connective = IsPossibleCrossing(neighbor_tile, DiagDirToAxis(dir));
break;
case MP_WATER:
/* Check for real water tile */
connective = !IsWater(neighbor_tile);
break;
/* The defentetly not connective ones */
default: break;
}
/* If the neighbor tile is inconnective remove the planed road connection to it */
if (!connective) org_rb ^= target_rb;
}
}
return org_rb;
}
bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts)
{
RoadTypes avail_roadtypes;
if (company == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
avail_roadtypes = ROADTYPES_ROAD;
} else {
Company *c = Company::GetIfValid(company);
if (c == NULL) return false;
avail_roadtypes = (RoadTypes)c->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
}
return (rts & ~avail_roadtypes) == 0;
}
bool ValParamRoadType(const RoadType rt)
{
return HasRoadTypesAvail(_current_company, RoadTypeToRoadTypes(rt));
}
RoadTypes GetCompanyRoadtypes(CompanyID company)
{
RoadTypes rt = ROADTYPES_NONE;
Engine *e;
FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
const EngineInfo *ei = &e->info;
if (HasBit(ei->climates, _settings_game.game_creation.landscape) &&
(HasBit(e->company_avail, company) || _date >= e->intro_date + DAYS_IN_YEAR)) {
SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
}
return rt;
}
|