mirror of https://github.com/OpenTTD/OpenTTD.git
(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)
This commit is contained in:
parent
3edbb1a543
commit
a123484ee0
|
@ -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]
|
||||
|
|
|
@ -70,8 +70,10 @@ void SQAIVehicle_Register(Squirrel *engine) {
|
|||
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_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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 {
|
||||
return true;
|
||||
}
|
||||
|
||||
UpdateVehicleTimetable(v, true);
|
||||
v->cur_order_index++;
|
||||
}
|
||||
} else if (v->type != VEH_AIRCRAFT) {
|
||||
} 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:
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue