diff --git a/src/elrail.cpp b/src/elrail.cpp index 9aedfc6e5d..5d4a4a6a95 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -111,7 +111,6 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override) case MP_STATION: if (!HasStationRail(t)) return TRACK_BIT_NONE; if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE; - if (!IsStationTileElectrifiable(t)) return TRACK_BIT_NONE; return TrackToTrackBits(GetRailStationTrack(t)); default: @@ -409,7 +408,8 @@ static void DrawCatenaryRailway(const TileInfo *ti) } } - if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i)) { + if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i) && + (!IsRailStationTile(ti->tile) || CanStationTileHavePylons(ti->tile))) { for (Direction k = DIR_BEGIN; k < DIR_END; k++) { byte temp = PPPorder[i][GetTLG(ti->tile)][k]; @@ -437,12 +437,15 @@ static void DrawCatenaryRailway(const TileInfo *ti) if (IsTunnelTile(ti->tile)) return; /* Don't draw a wire under a low bridge */ - if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) { + if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_BRIDGES)) { int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); if (height <= GetTileMaxZ(ti->tile) + 1) return; } + /* Don't draw a wire if the station tile does not want any */ + if (IsRailStationTile(ti->tile) && !CanStationTileHaveWires(ti->tile)) return; + SpriteID wire_normal = GetWireBase(ti->tile); SpriteID wire_halftile = (halftile_corner != CORNER_INVALID) ? GetWireBase(ti->tile, TCX_UPPER_HALFTILE) : wire_normal; Track halftile_track; diff --git a/src/fileio_func.h b/src/fileio_func.h index 6dea50e9ca..25d961bc0c 100644 --- a/src/fileio_func.h +++ b/src/fileio_func.h @@ -116,7 +116,6 @@ DECLARE_ENUM_AS_BIT_SET(TarScanner::Mode) /* Implementation of opendir/readdir/closedir for Windows */ #if defined(WIN32) -#include struct DIR; struct dirent { // XXX - only d_name implemented @@ -127,19 +126,6 @@ struct dirent { // XXX - only d_name implemented DIR *dir; }; -struct DIR { - HANDLE hFind; - /* the dirent returned by readdir. - * note: having only one global instance is not possible because - * multiple independent opendir/readdir sequences must be supported. */ - dirent ent; - WIN32_FIND_DATA fd; - /* since opendir calls FindFirstFile, we need a means of telling the - * first call to readdir that we already have a file. - * that's the case iff this is true */ - bool at_first_entry; -}; - DIR *opendir(const TCHAR *path); struct dirent *readdir(DIR *d); int closedir(DIR *d); diff --git a/src/ini.cpp b/src/ini.cpp index fe49f5fe7e..e82daaceb0 100644 --- a/src/ini.cpp +++ b/src/ini.cpp @@ -21,6 +21,7 @@ #endif #ifdef WIN32 +# include # include # include "core/mem_func.hpp" #endif diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 047566ee4e..4b0a14881b 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -894,18 +894,29 @@ bool IsStationTileBlocked(TileIndex tile) } /** - * Check if a rail station tile can be electrified. + * Check if a rail station tile shall have pylons when electrified. * @param tile %Tile to test. - * @return Tile can be electrified. + * @return Tile shall have pylons. * @note This could be cached (during build) in the map array to save on all the dereferencing. */ -bool IsStationTileElectrifiable(TileIndex tile) +bool CanStationTileHavePylons(TileIndex tile) { const StationSpec *statspec = GetStationSpec(tile); + uint gfx = GetStationGfx(tile); + /* Default stations do not draw pylons under roofs (gfx >= 4) */ + return statspec != NULL ? HasBit(statspec->pylons, gfx) : gfx < 4; +} - return statspec == NULL || - HasBit(statspec->pylons, GetStationGfx(tile)) || - !HasBit(statspec->wires, GetStationGfx(tile)); +/** + * Check if a rail station tile shall have wires when electrified. + * @param tile %Tile to test. + * @return Tile shall have wires. + * @note This could be cached (during build) in the map array to save on all the dereferencing. + */ +bool CanStationTileHaveWires(TileIndex tile) +{ + const StationSpec *statspec = GetStationSpec(tile); + return statspec == NULL || !HasBit(statspec->wires, GetStationGfx(tile)); } /** Wrapper for animation control, see #GetStationCallback. */ diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 07227222a6..dc38a69b35 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -89,6 +89,19 @@ void OSOpenBrowser(const char *url) * modified from Jan Wassenberg's GPL implementation posted over at * http://www.gamedev.net/community/forums/topic.asp?topic_id=364584&whichpage=1� */ +struct DIR { + HANDLE hFind; + /* the dirent returned by readdir. + * note: having only one global instance is not possible because + * multiple independent opendir/readdir sequences must be supported. */ + dirent ent; + WIN32_FIND_DATA fd; + /* since opendir calls FindFirstFile, we need a means of telling the + * first call to readdir that we already have a file. + * that's the case iff this is true */ + bool at_first_entry; +}; + /* suballocator - satisfies most requests with a reusable static instance. * this avoids hundreds of alloc/free which would fragment the heap. * To guarantee concurrency, we fall back to malloc if the instance is diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 0930d2ace7..6f91e20be4 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -216,6 +216,9 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec CommandCost cost(EXPENSES_CONSTRUCTION); if (IsTileType(tile, MP_TUNNELBRIDGE)) { + /* Removing any roadbit in the bridge axis removes the roadtype (that's the behaviour remove-long-roads needs) */ + if ((AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) & pieces) == ROAD_NONE) return_cmd_error(rt == ROADTYPE_TRAM ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD); + TileIndex other_end = GetOtherTunnelBridgeEnd(tile); /* Pay for *every* tile of the bridge or tunnel */ uint len = GetTunnelBridgeLength(other_end, tile) + 2; @@ -651,6 +654,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 case MP_TUNNELBRIDGE: { if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) goto do_clear; + /* Only allow building the outern roadbit, so building long roads stops at existing bridges */ if (MirrorRoadBits(DiagDirToRoadBits(GetTunnelBridgeDirection(tile))) != pieces) goto do_clear; if (HasTileRoadType(tile, rt)) return_cmd_error(STR_ERROR_ALREADY_BUILT); /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */ diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index d4acee4fe9..8f662120d1 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2803,7 +2803,7 @@ draw_default_foundation: } } - if (HasStationRail(ti->tile) && HasCatenaryDrawn(GetRailType(ti->tile)) && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti); + if (HasStationRail(ti->tile) && HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti); if (HasBit(roadtypes, ROADTYPE_TRAM)) { Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y; diff --git a/src/station_func.h b/src/station_func.h index 3b33002b9a..233ffee30a 100644 --- a/src/station_func.h +++ b/src/station_func.h @@ -39,8 +39,8 @@ void DeleteOilRig(TileIndex t); /* Check if a rail station tile is traversable. */ bool IsStationTileBlocked(TileIndex tile); -/* Check if a rail station tile is electrifiable. */ -bool IsStationTileElectrifiable(TileIndex tile); +bool CanStationTileHavePylons(TileIndex tile); +bool CanStationTileHaveWires(TileIndex tile); void UpdateAirportsNoise(); diff --git a/src/stdafx.h b/src/stdafx.h index 68f7b5d88a..1c804220e8 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -163,6 +163,7 @@ #define WINVER 0x0400 // Windows NT 4.0 / Windows 95 #endif #define _WIN32_IE_ 0x0401 // 4.01 (win98 and NT4SP5+) + #define NOMINMAX // Disable min/max macros in windows.h. #pragma warning(disable: 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data #pragma warning(disable: 4761) // integral size mismatch in argument : conversion supplied diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index df7510084d..beeef29fe9 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -305,7 +305,7 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen) { RECT r; DWORD style, showstyle; - int x, y, w, h; + int w, h; showstyle = SW_SHOWNORMAL; _wnd.fullscreen = full_screen; @@ -322,14 +322,15 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen) #if !defined(WINCE) AdjustWindowRect(&r, style, FALSE); #endif + w = r.right - r.left; + h = r.bottom - r.top; - if (_wnd.main_wnd == NULL) { - w = r.right - r.left; - h = r.bottom - r.top; - x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; - y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; - + if (_wnd.main_wnd != NULL) { + if (!_window_maximize) SetWindowPos(_wnd.main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE); + } else { TCHAR Windowtitle[50]; + int x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; + int y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; _sntprintf(Windowtitle, lengthof(Windowtitle), _T("OpenTTD %s"), MB_TO_WIDE(_openttd_revision)); @@ -1055,6 +1056,8 @@ void VideoDriver_Win32::MainLoop() bool VideoDriver_Win32::ChangeResolution(int w, int h) { + if (_window_maximize) ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL); + _wnd.width = _wnd.width_org = w; _wnd.height = _wnd.height_org = h;