Files
@ r9470:75edf93b1c69
Branch filter:
Location: cpp/openttd-patchpack/source/src/road.cpp - annotation
r9470:75edf93b1c69
3.0 KiB
text/x-c
(svn r13390) -Codechange: introduce usererror() for fatal but not openttd related errors. Now all error() will 'crash' openttd after showing the message in win32 releases (MSVC), creating a crash.log and crash.dmp (like the '!' hack used before). On the other hand, usererror() will just close the game. So use error() only when it can be helpful to debugging, else use usererror().
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 | r8091:d63ba361d6b8 r8091:d63ba361d6b8 r9111:983de9c5a848 r9111:983de9c5a848 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r7641:2b26b5be3fd7 r8102:c3f2dd9e9116 r7641:2b26b5be3fd7 r8236:a2ecfe92ab23 r8254:b96be9ebfc6e r8254:b96be9ebfc6e r8786:f24a6d1fba34 r9070:e059c65164f3 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 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 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 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r8236:a2ecfe92ab23 r9070:e059c65164f3 r9070:e059c65164f3 r9070:e059c65164f3 r8236:a2ecfe92ab23 r9413:fcf267325763 r8236:a2ecfe92ab23 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 "road_internal.h"
#include "water_map.h"
#include "genworld.h"
#include "player_func.h"
#include "player_base.h"
#include "engine_func.h"
#include "engine_base.h"
#include "settings_type.h"
#include "date_func.h"
bool IsPossibleCrossing(const TileIndex tile, Axis ax)
{
return (IsTileType(tile, MP_RAILWAY) &&
!HasSignals(tile) &&
GetTrackBits(tile) == (ax == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) &&
GetTileSlope(tile, NULL) == SLOPE_FLAT);
}
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
{
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 PlayerID p, const RoadTypes rts)
{
RoadTypes avail_roadtypes;
if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) {
avail_roadtypes = ROADTYPES_ROAD;
} else {
if (!IsValidPlayer(p)) return false;
avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
}
return (rts & ~avail_roadtypes) == 0;
}
bool ValParamRoadType(const RoadType rt)
{
return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt));
}
RoadTypes GetPlayerRoadtypes(PlayerID p)
{
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->player_avail, p) || _date >= e->intro_date + 365)) {
SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
}
return rt;
}
|