diff --git a/config.lib b/config.lib index fda308f811..53f3752b34 100644 --- a/config.lib +++ b/config.lib @@ -815,6 +815,7 @@ check_params() { fi if [ "$os" = "OSX" ]; then + check_osx_sdk # Test on G5 if [ "$enable_osx_g5" != "0" ]; then @@ -1617,6 +1618,30 @@ set_universal_binary_flags() { fi } +check_osx_sdk() { +cat > tmp.osx.cpp << EOF +#include +#if !defined(MAC_OS_X_VERSION_10_5) +# error "Need newer SDK" +#endif +int main() { + return 0; +} +EOF + execute="$cxx_host $CFLAGS -E tmp.osx.cpp -o - 2>&1" + eval $execute > /dev/null + ret=$? + log 2 "executing $execute" + log 2 " exit code $ret" + rm -f tmp.osx.cpp + if [ "$ret" != "0" ]; then + log 1 "I couldn't detect any XCode >= 2.5 on your system" + log 1 "please install/upgrade your XCode" + + exit 1 + fi +} + check_direct_music() { echo " #include @@ -2601,31 +2626,31 @@ make_sed() { if [ "$icon_theme_dir" != "" ]; then SRC_REPLACE="$SRC_REPLACE - s#!!ICON_THEME_DIR!!#$prefix_dir/$icon_theme_dir#g; + s~!!ICON_THEME_DIR!!~$prefix_dir/$icon_theme_dir~g; " else SRC_REPLACE="$SRC_REPLACE - s#!!ICON_THEME_DIR!!##g; + s~!!ICON_THEME_DIR!!~~g; " fi if [ "$man_dir" != "" ]; then SRC_REPLACE="$SRC_REPLACE - s#!!MAN_DIR!!#$prefix_dir/$man_dir#g; + s~!!MAN_DIR!!~$prefix_dir/$man_dir~g; " else SRC_REPLACE="$SRC_REPLACE - s#!!MAN_DIR!!##g; + s~!!MAN_DIR!!~~g; " fi if [ "$menu_dir" != "" ]; then SRC_REPLACE="$SRC_REPLACE - s#!!MENU_DIR!!#$prefix_dir/$menu_dir#g; + s~!!MENU_DIR!!~$prefix_dir/$menu_dir~g; " else SRC_REPLACE="$SRC_REPLACE - s#!!MENU_DIR!!##g; + s~!!MENU_DIR!!~~g; " fi } diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index 27168e8213..f32aee67ce 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -318,7 +318,7 @@ static FORCEINLINE T ROR(const T x, const uint8 n) */ static FORCEINLINE uint32 BSWAP32(uint32 x) { -#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3)) +#if !defined(__ICC) && defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3)) /* GCC >= 4.3 provides a builtin, resulting in faster code */ return (uint32)__builtin_bswap32((int32)x); #else diff --git a/src/openttd.cpp b/src/openttd.cpp index 2dc2e48dd5..5aada53089 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -300,9 +300,6 @@ static void InitializeDynamicVariables() */ static void ShutdownGame() { - /* stop the AI */ - AI::Uninitialize(false); - IConsoleFree(); if (_network_available) NetworkShutDown(); // Shut down the network and close any open connections @@ -311,6 +308,9 @@ static void ShutdownGame() UnInitWindowSystem(); + /* stop the AI */ + AI::Uninitialize(false); + /* Uninitialize airport state machines */ UnInitializeAirports(); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 6a48081af1..64358c48ca 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1820,7 +1820,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (distant_join && (!_settings_game.station.distant_join_stations || !IsValidStationID(station_to_join))) return CMD_ERROR; /* Check if a valid, buildable airport was chosen for construction */ - if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR; + if (p1 >= lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR; if (!CheckIfAuthorityAllowsNewStation(tile, flags)) { return CMD_ERROR; diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 4074aa1e4f..c98c4abef5 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -60,11 +60,9 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) _generating_world = true; BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { - if (GetTileType(tile) != MP_WATER) { - SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); - DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR); - MarkTileDirtyByTile(tile); - } + SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); + DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + MarkTileDirtyByTile(tile); } END_TILE_LOOP(tile, size_x, size_y, 0); _generating_world = false; } diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index d44b86a07c..484614dfb9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2429,7 +2429,7 @@ uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t) */ CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) { - if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR; + if (!IsValidTownID(p1) || p2 >= lengthof(_town_action_proc)) return CMD_ERROR; Town *t = GetTown(p1); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 00545ec751..a36b00ea1e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1219,13 +1219,12 @@ Trackdir GetVehicleTrackdir(const Vehicle *v) if (IsStandardRoadStopTile(v->tile)) // We'll assume the road vehicle is facing outwards return DiagDirToDiagTrackdir(GetRoadStopDir(v->tile)); // Road vehicle in a station - if (IsDriveThroughStopTile(v->tile)) return DiagDirToDiagTrackdir(DirToDiagDir(v->direction)); + /* Drive through road stops / wormholes (tunnels) */ + if (v->u.road.state > RVSB_TRACKDIR_MASK) return DiagDirToDiagTrackdir(DirToDiagDir(v->direction)); - /* If vehicle's state is a valid track direction (vehicle is not turning around) return it */ - if (!IsReversingRoadTrackdir((Trackdir)v->u.road.state)) return (Trackdir)v->u.road.state; - - /* Vehicle is turning around, get the direction from vehicle's direction */ - return DiagDirToDiagTrackdir(DirToDiagDir(v->direction)); + /* If vehicle's state is a valid track direction (vehicle is not turning around) return it, + * otherwise transform it into a valid track direction */ + return (Trackdir)((IsReversingRoadTrackdir((Trackdir)v->u.road.state)) ? (v->u.road.state - 6) : v->u.road.state); /* case VEH_AIRCRAFT: case VEH_EFFECT: case VEH_DISASTER: */ default: return INVALID_TRACKDIR;