From a123484ee0bb58324655d9c6d0e780b8c5dd0746 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 13 Jul 2009 10:16:50 +0000 Subject: [PATCH] (svn r16804) [0.7] -Backport from trunk: - Fix: Service orders did not behave like conditional orders; if a train does not need service it did not completely skip the order, but still go in the direction of the depot [FS#3031] (r16802) - Fix: Houses would not get build on the map edge [FS#3025] (r16795) - Fix: Audio playback rate was fixed at 11025Hz regardless of the rate specified to the audio driver, resulting in incorrect playback speed. It is still preferable to use 11025Hz output rate if possible as OpenTTD's sample rate converter is very low quality (r16784) - Fix: Do not use the same error message for turning around road vehicles and flipping parts of trains in the depot [FS#3019] (r16772) --- src/ai/api/ai_vehicle.hpp | 2 +- src/ai/api/ai_vehicle.hpp.sq | 66 +++++++++++++++++++----------------- src/depot_gui.cpp | 2 +- src/lang/english.txt | 7 ++-- src/mixer.cpp | 2 +- src/openttd.cpp | 2 -- src/order_cmd.cpp | 46 +++++++++++++------------ src/road_map.cpp | 11 ------ src/road_map.h | 10 ------ src/sound/allegro_s.cpp | 1 + src/sound/cocoa_s.cpp | 1 + src/sound/sdl_s.cpp | 1 + src/sound/win32_s.cpp | 2 ++ src/town_cmd.cpp | 31 +++++++++-------- src/train_cmd.cpp | 2 +- src/vehicle_gui.cpp | 4 +-- 16 files changed, 90 insertions(+), 100 deletions(-) diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp index 901258e3f2..a4b9a66d2c 100644 --- a/src/ai/api/ai_vehicle.hpp +++ b/src/ai/api/ai_vehicle.hpp @@ -43,7 +43,7 @@ public: ERR_VEHICLE_CANNOT_START_STOP, // [STR_883B_CAN_T_STOP_START_TRAIN, STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, STR_9818_CAN_T_STOP_START_SHIP, STR_A016_CAN_T_STOP_START_AIRCRAFT] /** Vehicle can't turn */ - ERR_VEHICLE_CANNOT_TURN, // [STR_8869_CAN_T_REVERSE_DIRECTION, STR_9033_CAN_T_MAKE_VEHICLE_TURN] + ERR_VEHICLE_CANNOT_TURN, // [STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN, STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS] /** Vehicle can't be refit */ ERR_VEHICLE_CANNOT_REFIT, // [STR_RAIL_CAN_T_REFIT_VEHICLE, STR_REFIT_ROAD_VEHICLE_CAN_T, STR_9841_CAN_T_REFIT_SHIP, STR_A042_CAN_T_REFIT_AIRCRAFT] diff --git a/src/ai/api/ai_vehicle.hpp.sq b/src/ai/api/ai_vehicle.hpp.sq index ee16f7f8d4..458c59178b 100644 --- a/src/ai/api/ai_vehicle.hpp.sq +++ b/src/ai/api/ai_vehicle.hpp.sq @@ -52,38 +52,40 @@ void SQAIVehicle_Register(Squirrel *engine) { SQAIVehicle.DefSQConst(engine, AIVehicle::VS_CRASHED, "VS_CRASHED"); SQAIVehicle.DefSQConst(engine, AIVehicle::VS_INVALID, "VS_INVALID"); - AIError::RegisterErrorMap(STR_00E1_TOO_MANY_VEHICLES_IN_GAME, AIVehicle::ERR_VEHICLE_TOO_MANY); - AIError::RegisterErrorMap(STR_AIRCRAFT_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); - AIError::RegisterErrorMap(STR_ROAD_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); - AIError::RegisterErrorMap(STR_SHIP_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); - AIError::RegisterErrorMap(STR_RAIL_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); - AIError::RegisterErrorMap(STR_A008_CAN_T_BUILD_AIRCRAFT, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); - AIError::RegisterErrorMap(STR_980D_CAN_T_BUILD_SHIP, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); - AIError::RegisterErrorMap(STR_9009_CAN_T_BUILD_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); - AIError::RegisterErrorMap(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); - AIError::RegisterErrorMap(STR_DEPOT_WRONG_DEPOT_TYPE, AIVehicle::ERR_VEHICLE_WRONG_DEPOT); - AIError::RegisterErrorMap(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); - AIError::RegisterErrorMap(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); - AIError::RegisterErrorMap(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); - AIError::RegisterErrorMap(STR_A012_CAN_T_SEND_AIRCRAFT_TO, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); - AIError::RegisterErrorMap(STR_883B_CAN_T_STOP_START_TRAIN, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); - AIError::RegisterErrorMap(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); - AIError::RegisterErrorMap(STR_9818_CAN_T_STOP_START_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); - AIError::RegisterErrorMap(STR_A016_CAN_T_STOP_START_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); - AIError::RegisterErrorMap(STR_8869_CAN_T_REVERSE_DIRECTION, AIVehicle::ERR_VEHICLE_CANNOT_TURN); - AIError::RegisterErrorMap(STR_9033_CAN_T_MAKE_VEHICLE_TURN, AIVehicle::ERR_VEHICLE_CANNOT_TURN); - AIError::RegisterErrorMap(STR_RAIL_CAN_T_REFIT_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); - AIError::RegisterErrorMap(STR_REFIT_ROAD_VEHICLE_CAN_T, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); - AIError::RegisterErrorMap(STR_9841_CAN_T_REFIT_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); - AIError::RegisterErrorMap(STR_A042_CAN_T_REFIT_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); - AIError::RegisterErrorMap(STR_CAN_T_REFIT_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED); - AIError::RegisterErrorMap(STR_CAN_T_SELL_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED); - AIError::RegisterErrorMap(STR_A01B_AIRCRAFT_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); - AIError::RegisterErrorMap(STR_9013_MUST_BE_STOPPED_INSIDE, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); - AIError::RegisterErrorMap(STR_TRAIN_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); - AIError::RegisterErrorMap(STR_980B_SHIP_MUST_BE_STOPPED_IN, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); - AIError::RegisterErrorMap(STR_A017_AIRCRAFT_IS_IN_FLIGHT, AIVehicle::ERR_VEHICLE_IN_FLIGHT); - AIError::RegisterErrorMap(STR_TRAIN_START_NO_CATENARY, AIVehicle::ERR_VEHCILE_NO_POWER); + AIError::RegisterErrorMap(STR_00E1_TOO_MANY_VEHICLES_IN_GAME, AIVehicle::ERR_VEHICLE_TOO_MANY); + AIError::RegisterErrorMap(STR_AIRCRAFT_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); + AIError::RegisterErrorMap(STR_ROAD_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); + AIError::RegisterErrorMap(STR_SHIP_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); + AIError::RegisterErrorMap(STR_RAIL_VEHICLE_NOT_AVAILABLE, AIVehicle::ERR_VEHICLE_NOT_AVAILABLE); + AIError::RegisterErrorMap(STR_A008_CAN_T_BUILD_AIRCRAFT, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); + AIError::RegisterErrorMap(STR_980D_CAN_T_BUILD_SHIP, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); + AIError::RegisterErrorMap(STR_9009_CAN_T_BUILD_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); + AIError::RegisterErrorMap(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE, AIVehicle::ERR_VEHICLE_BUILD_DISABLED); + AIError::RegisterErrorMap(STR_DEPOT_WRONG_DEPOT_TYPE, AIVehicle::ERR_VEHICLE_WRONG_DEPOT); + AIError::RegisterErrorMap(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); + AIError::RegisterErrorMap(STR_9018_CAN_T_SEND_VEHICLE_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); + AIError::RegisterErrorMap(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); + AIError::RegisterErrorMap(STR_A012_CAN_T_SEND_AIRCRAFT_TO, AIVehicle::ERR_VEHICLE_CANNOT_SEND_TO_DEPOT); + AIError::RegisterErrorMap(STR_883B_CAN_T_STOP_START_TRAIN, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); + AIError::RegisterErrorMap(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); + AIError::RegisterErrorMap(STR_9818_CAN_T_STOP_START_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); + AIError::RegisterErrorMap(STR_A016_CAN_T_STOP_START_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_START_STOP); + AIError::RegisterErrorMap(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN, AIVehicle::ERR_VEHICLE_CANNOT_TURN); + AIError::RegisterErrorMap(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN, AIVehicle::ERR_VEHICLE_CANNOT_TURN); + AIError::RegisterErrorMap(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_TURN); + AIError::RegisterErrorMap(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS, AIVehicle::ERR_VEHICLE_CANNOT_TURN); + AIError::RegisterErrorMap(STR_RAIL_CAN_T_REFIT_VEHICLE, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); + AIError::RegisterErrorMap(STR_REFIT_ROAD_VEHICLE_CAN_T, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); + AIError::RegisterErrorMap(STR_9841_CAN_T_REFIT_SHIP, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); + AIError::RegisterErrorMap(STR_A042_CAN_T_REFIT_AIRCRAFT, AIVehicle::ERR_VEHICLE_CANNOT_REFIT); + AIError::RegisterErrorMap(STR_CAN_T_REFIT_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED); + AIError::RegisterErrorMap(STR_CAN_T_SELL_DESTROYED_VEHICLE, AIVehicle::ERR_VEHICLE_IS_DESTROYED); + AIError::RegisterErrorMap(STR_A01B_AIRCRAFT_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); + AIError::RegisterErrorMap(STR_9013_MUST_BE_STOPPED_INSIDE, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); + AIError::RegisterErrorMap(STR_TRAIN_MUST_BE_STOPPED, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); + AIError::RegisterErrorMap(STR_980B_SHIP_MUST_BE_STOPPED_IN, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT); + AIError::RegisterErrorMap(STR_A017_AIRCRAFT_IS_IN_FLIGHT, AIVehicle::ERR_VEHICLE_IN_FLIGHT); + AIError::RegisterErrorMap(STR_TRAIN_START_NO_CATENARY, AIVehicle::ERR_VEHCILE_NO_POWER); AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_TOO_MANY, "ERR_VEHICLE_TOO_MANY"); AIError::RegisterErrorMapString(AIVehicle::ERR_VEHICLE_NOT_AVAILABLE, "ERR_VEHICLE_NOT_AVAILABLE"); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index fafa0a9355..a8d0d83d54 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -948,7 +948,7 @@ struct DepotWindow : Window { if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) { if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) { - DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); + DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE)); } else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); } else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) { diff --git a/src/lang/english.txt b/src/lang/english.txt index 3b64ab85fd..0b683b8123 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2814,7 +2814,9 @@ STR_8865_NAME_TRAIN :{WHITE}Name tra STR_8866_CAN_T_NAME_TRAIN :{WHITE}Can't name train... STR_8867_NAME_TRAIN :{BLACK}Name train STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL :{BLACK}{BIGFONT}Train Crash!{}{COMMA} die in fireball after collision -STR_8869_CAN_T_REVERSE_DIRECTION :{WHITE}Can't reverse direction of train... +STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN :{WHITE}Can't reverse direction of train... +STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE :{WHITE}Can't reverse direction of vehicle... +STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS :{WHITE}Can't reverse direction of vehicles consisting of multiple units... STR_886A_RENAME_TRAIN_VEHICLE_TYPE :{WHITE}Rename train vehicle type STR_886B_CAN_T_RENAME_TRAIN_VEHICLE :{WHITE}Can't rename train vehicle type... STR_CLEAR_TIME :{BLACK}Clear Time @@ -2902,8 +2904,7 @@ STR_CITIZENS_CELEBRATE_FIRST_PASSENGER_TRAM :{BLACK}{BIGFONT STR_CITIZENS_CELEBRATE_FIRST_CARGO_TRAM :{BLACK}{BIGFONT}Citizens celebrate . . .{}First freight tram arrives at {STATION}! STR_9031_ROAD_VEHICLE_CRASH_DRIVER :{BLACK}{BIGFONT}Road Vehicle Crash!{}Driver dies in fireball after collision with train STR_9032_ROAD_VEHICLE_CRASH_DIE :{BLACK}{BIGFONT}Road Vehicle Crash!{}{COMMA} die in fireball after collision with train -STR_9033_CAN_T_MAKE_VEHICLE_TURN :{WHITE}Can't make vehicle turn around... -STR_ONLY_TURN_SINGLE_UNIT :{WHITE}Can't turn vehicles consisting of multiple units +STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN :{WHITE}Can't make road vehicle turn around... STR_9034_RENAME :{BLACK}Rename STR_9035_RENAME_ROAD_VEHICLE_TYPE :{BLACK}Rename road vehicle type STR_9036_RENAME_ROAD_VEHICLE_TYPE :{WHITE}Rename road vehicle type diff --git a/src/mixer.cpp b/src/mixer.cpp index 3a55b7fadb..c6c5776dad 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -26,7 +26,7 @@ struct MixerChannel { }; static MixerChannel _channels[8]; -static uint32 _play_rate; +static uint32 _play_rate = 11025; /** * The theoretical maximum volume for a single sound sample. Multiple sound diff --git a/src/openttd.cpp b/src/openttd.cpp index 8d105648c6..72d8f0f1a6 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -18,7 +18,6 @@ #include "fontcache.h" #include "gfxinit.h" #include "gui.h" -#include "mixer.h" #include "sound_func.h" #include "window_func.h" @@ -567,7 +566,6 @@ int ttd_main(int argc, char *argv[]) /* Sample catalogue */ DEBUG(misc, 1, "Loading sound effects..."); - MxInitialize(11025); SoundInitialize("sample.cat"); /* Initialize FreeType */ diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index cb415c6014..81874af7d5 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1627,10 +1627,12 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v) */ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth) { + if (conditional_depth > v->GetNumOrders()) return false; + switch (order->GetType()) { case OT_GOTO_STATION: v->dest_tile = v->GetOrderStationLocation(order->GetDestination()); - break; + return true; case OT_GOTO_DEPOT: if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) { @@ -1651,22 +1653,27 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth) extern void AircraftNextAirportPos_and_Order(Vehicle *v); AircraftNextAirportPos_and_Order(v); } - } else { - UpdateVehicleTimetable(v, true); - v->cur_order_index++; + return true; } - } else if (v->type != VEH_AIRCRAFT) { - v->dest_tile = GetDepot(order->GetDestination())->xy; + + UpdateVehicleTimetable(v, true); + v->cur_order_index++; + } else if ((order->GetDepotOrderType() & ODTFB_SERVICE) && !v->NeedsServicing()) { + UpdateVehicleTimetable(v, true); + v->cur_order_index++; + } else { + if (v->type != VEH_AIRCRAFT) { + v->dest_tile = GetDepot(order->GetDestination())->xy; + } + return true; } break; case OT_GOTO_WAYPOINT: v->dest_tile = GetWaypoint(order->GetDestination())->xy; - break; + return true; case OT_CONDITIONAL: { - if (conditional_depth > v->GetNumOrders()) return false; - VehicleOrderID next_order = ProcessConditionalOrder(order, v); if (next_order != INVALID_VEH_ORDER_ID) { UpdateVehicleTimetable(v, false); @@ -1676,20 +1683,20 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth) UpdateVehicleTimetable(v, true); v->cur_order_index++; } - - /* Get the current order */ - if (v->cur_order_index >= v->GetNumOrders()) v->cur_order_index = 0; - - const Order *order = GetVehicleOrder(v, v->cur_order_index); - v->current_order = *order; - return UpdateOrderDest(v, order, conditional_depth + 1); + break; } default: v->dest_tile = 0; return false; } - return true; + + /* Get the current order */ + if (v->cur_order_index >= v->GetNumOrders()) v->cur_order_index = 0; + + order = GetVehicleOrder(v, v->cur_order_index); + v->current_order = *order; + return UpdateOrderDest(v, order, conditional_depth + 1); } /** @@ -1705,11 +1712,6 @@ bool ProcessOrders(Vehicle *v) case OT_GOTO_DEPOT: /* Let a depot order in the orderlist interrupt. */ if (!(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return false; - - if ((v->current_order.GetDepotOrderType() & ODTFB_SERVICE) && !v->NeedsServicing()) { - UpdateVehicleTimetable(v, true); - v->cur_order_index++; - } break; case OT_LOADING: diff --git a/src/road_map.cpp b/src/road_map.cpp index 83a247c48e..34028e4672 100644 --- a/src/road_map.cpp +++ b/src/road_map.cpp @@ -34,14 +34,3 @@ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge default: return ROAD_NONE; } } - - -TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt) -{ - /* Don't allow local authorities to build roads through road depots or road stops. */ - if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) { - return TRACK_BIT_NONE; - } - - return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt))); -} diff --git a/src/road_map.h b/src/road_map.h index adc644f038..0bd6d54a45 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -361,16 +361,6 @@ static inline DiagDirection GetRoadDepotDirection(TileIndex t) */ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance = false); -/** - * Get the accessible track bits for the given tile. - * Special behaviour: - * - road depots: no track bits - * - non-drive-through stations: no track bits - * @param tile the tile to get the track bits for - * @return the track bits for the given tile - */ -TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt); - /** * Return if the tile is a valid tile for a crossing. * diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp index 069e473e5f..a94f6d2386 100644 --- a/src/sound/allegro_s.cpp +++ b/src/sound/allegro_s.cpp @@ -58,6 +58,7 @@ const char *SoundDriver_Allegro::Start(const char * const *parm) } _stream = play_audio_stream(BUFFER_SIZE, 16, true, 11025, 255, 128); + MxInitialize(11025); return NULL; } diff --git a/src/sound/cocoa_s.cpp b/src/sound/cocoa_s.cpp index 7e315fb75c..851136efab 100644 --- a/src/sound/cocoa_s.cpp +++ b/src/sound/cocoa_s.cpp @@ -69,6 +69,7 @@ const char *SoundDriver_Cocoa::Start(const char * const *parm) requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8; requestedDesc.mBytesPerPacket = requestedDesc.mBytesPerFrame * requestedDesc.mFramesPerPacket; + MxInitialize(requestedDesc.mSampleRate); /* Locate the default output audio unit */ desc.componentType = kAudioUnitType_Output; diff --git a/src/sound/sdl_s.cpp b/src/sound/sdl_s.cpp index d111ac8ed0..7c89331f7a 100644 --- a/src/sound/sdl_s.cpp +++ b/src/sound/sdl_s.cpp @@ -30,6 +30,7 @@ const char *SoundDriver_SDL::Start(const char * const *parm) spec.channels = 2; spec.samples = 512; spec.callback = fill_sound_buffer; + MxInitialize(spec.freq); SDL_CALL SDL_OpenAudio(&spec, &spec); SDL_CALL SDL_PauseAudio(0); return NULL; diff --git a/src/sound/win32_s.cpp b/src/sound/win32_s.cpp index 3a5419495a..776158adf0 100644 --- a/src/sound/win32_s.cpp +++ b/src/sound/win32_s.cpp @@ -65,6 +65,8 @@ const char *SoundDriver_Win32::Start(const char * const *parm) if (waveOutOpen(&_waveout, WAVE_MAPPER, &wfex, (DWORD_PTR)&waveOutProc, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) return "waveOutOpen failed"; + MxInitialize(wfex.nSamplesPerSec); + PrepareHeader(&_wave_hdr[0]); PrepareHeader(&_wave_hdr[1]); FillHeaders(); diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 05b240f33f..f2a91a8b04 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -37,6 +37,7 @@ #include "oldpool_func.h" #include "economy_func.h" #include "station_func.h" +#include "station_map.h" #include "cheat_type.h" #include "functions.h" #include "animated_tile_func.h" @@ -692,17 +693,9 @@ void OnTick_Town() */ static RoadBits GetTownRoadBits(TileIndex tile) { - TrackBits b = GetAnyRoadTrackBits(tile, ROADTYPE_ROAD); - RoadBits r = ROAD_NONE; + if (IsRoadDepotTile(tile) || IsStandardRoadStopTile(tile)) return ROAD_NONE; - if (b == TRACK_BIT_NONE) return r; - if (b & TRACK_BIT_X) r |= ROAD_X; - if (b & TRACK_BIT_Y) r |= ROAD_Y; - if (b & TRACK_BIT_UPPER) r |= ROAD_NE | ROAD_NW; - if (b & TRACK_BIT_LOWER) r |= ROAD_SE | ROAD_SW; - if (b & TRACK_BIT_LEFT) r |= ROAD_NW | ROAD_SW; - if (b & TRACK_BIT_RIGHT) r |= ROAD_NE | ROAD_SE; - return r; + return GetAnyRoadBits(tile, ROADTYPE_ROAD, true); } /** @@ -751,7 +744,7 @@ static bool IsNeighborRoadTile(TileIndex tile, const DiagDirection dir, uint dis */ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir) { - if (TileX(tile) < 2 || TileX(tile) >= MapMaxX() || TileY(tile) < 2 || TileY(tile) >= MapMaxY()) return false; + if (DistanceFromEdge(tile) == 0) return false; Slope cur_slope, desired_slope; @@ -899,14 +892,24 @@ static RoadBits GetTownRoadGridElement(Town *t, TileIndex tile, DiagDirection di static bool GrowTownWithExtraHouse(Town *t, TileIndex tile) { /* We can't look further than that. */ - if (TileX(tile) < 2 || TileY(tile) < 2 || MapMaxX() <= TileX(tile) || MapMaxY() <= TileY(tile)) return false; + if (DistanceFromEdge(tile) == 0) return false; uint counter = 0; // counts the house neighbor tiles /* Check the tiles E,N,W and S of the current tile for houses */ for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { + /* Count both void and house tiles for checking whether there + * are enough houses in the area. This to make it likely that + * houses get build up to the edge of the map. */ + switch (GetTileType(TileAddByDiagDir(tile, dir))) { + case MP_HOUSE: + case MP_VOID: + counter++; + break; - if (IsTileType(TileAddByDiagDir(tile, dir), MP_HOUSE)) counter++; + default: + break; + } /* If there are enough neighbors stop here */ if (counter >= 3) { @@ -1109,7 +1112,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t /* Don't walk into water. */ if (IsWaterTile(house_tile)) return; - if (!IsValidTile(house_tile) || !IsValidTile(house_tile + TileOffsByDiagDir(target_dir))) return; + if (!IsValidTile(house_tile)) return; if (_settings_game.economy.allow_town_roads || _generating_world) { switch (t1->layout) { diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index c26b27724b..d4b7b1b6ef 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1917,7 +1917,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 /* turn a single unit around */ if (IsMultiheaded(v) || HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) { - return_cmd_error(STR_ONLY_TURN_SINGLE_UNIT); + return_cmd_error(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS); } Vehicle *front = v->First(); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 4d4a7cbf4c..1462d9317a 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1658,8 +1658,8 @@ static const uint32 _vehicle_command_translation_table[][4] = { CMD_CLONE_VEHICLE | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT) }, { // VCT_CMD_TURN_AROUND - CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION), - CMD_TURN_ROADVEH | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN), + CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN), + CMD_TURN_ROADVEH | CMD_MSG(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN), 0xffffffff, // invalid for ships 0xffffffff // invalid for aircrafts },