1
0
Fork 0

(svn r24425) [1.2] -Backport from trunk:

- Fix: [Windows] Unbreak NewGRF MD5 sum calculation. Macros and side effects do not mix, especially if there is some obscure '#define min' in a windows header that nobody thinks of [FS#5231] (r24416)
- Fix: Disallow removing roadtypes from bridges when not dragging in bridge direction [FS#5221] (r24414)
- Fix: Draw wires under low bridges if the bridge is transparent, not if the wire is transparent (r24403)
- Fix: Station properties 11 and 14 were combined incorrectly [FS#5243] (r24402)
- Fix: [Windows] Changing resolution did not resize the window (r24394)
release/1.2
rubidium 2012-07-20 19:49:02 +00:00
parent d726d793ed
commit bb02a4ec73
10 changed files with 55 additions and 33 deletions

View File

@ -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;

View File

@ -116,7 +116,6 @@ DECLARE_ENUM_AS_BIT_SET(TarScanner::Mode)
/* Implementation of opendir/readdir/closedir for Windows */
#if defined(WIN32)
#include <windows.h>
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);

View File

@ -21,6 +21,7 @@
#endif
#ifdef WIN32
# include <windows.h>
# include <shellapi.h>
# include "core/mem_func.hpp"
#endif

View File

@ -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. */

View File

@ -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&#2398903 */
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

View File

@ -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 */

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -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;