mirror of https://github.com/OpenTTD/OpenTTD
(svn r13688) [0.6] -Backport from trunk:
- Fix: If the first bridge can not be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long [FS#2100] (r13611) - Fix: [OSX] 10.5 failed to switch to fullscreen (r13584) - Fix: Properly count number of non-north housetiles [FS#2083] (r13518) - Fix: Drawing of zoomed out partial sprites could cause deadlocks or crashes (r13502)release/0.6
parent
a68eee5f31
commit
b95eb99c55
|
@ -65,6 +65,13 @@ public:
|
||||||
{
|
{
|
||||||
const char *default_blitter = "8bpp-optimized";
|
const char *default_blitter = "8bpp-optimized";
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
/* MacOS X 10.5 removed 8bpp fullscreen support.
|
||||||
|
* Because of this we will pick 32bpp by default */
|
||||||
|
if (MacOSVersionIsAtLeast(10, 5, 0)) {
|
||||||
|
default_blitter = "32bpp-anim";
|
||||||
|
}
|
||||||
|
#endif /* defined(__APPLE__) */
|
||||||
if (GetBlitters().size() == 0) return NULL;
|
if (GetBlitters().size() == 0) return NULL;
|
||||||
const char *bname = (StrEmpty(name)) ? default_blitter : name;
|
const char *bname = (StrEmpty(name)) ? default_blitter : name;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
|
||||||
|
|
||||||
void DrawBridgeMiddle(const TileInfo *ti);
|
void DrawBridgeMiddle(const TileInfo *ti);
|
||||||
|
|
||||||
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len);
|
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags = 0);
|
||||||
int CalcBridgeLenCostFactor(int x);
|
int CalcBridgeLenCostFactor(int x);
|
||||||
|
|
||||||
void ResetBridges();
|
void ResetBridges();
|
||||||
|
|
|
@ -669,7 +669,7 @@ void DrawSprite(SpriteID img, SpriteID pal, int x, int y, const SubSprite *sub)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
|
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub)
|
||||||
{
|
{
|
||||||
const DrawPixelInfo *dpi = _cur_dpi;
|
const DrawPixelInfo *dpi = _cur_dpi;
|
||||||
Blitter::BlitterParams bp;
|
Blitter::BlitterParams bp;
|
||||||
|
@ -695,8 +695,8 @@ static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMod
|
||||||
bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom);
|
bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom);
|
||||||
bp.top = 0;
|
bp.top = 0;
|
||||||
bp.left = 0;
|
bp.left = 0;
|
||||||
bp.skip_left = UnScaleByZoom(clip_left, dpi->zoom);
|
bp.skip_left = UnScaleByZoomLower(clip_left, dpi->zoom);
|
||||||
bp.skip_top = UnScaleByZoom(clip_top, dpi->zoom);
|
bp.skip_top = UnScaleByZoomLower(clip_top, dpi->zoom);
|
||||||
|
|
||||||
x += ScaleByZoom(bp.skip_left, dpi->zoom);
|
x += ScaleByZoom(bp.skip_left, dpi->zoom);
|
||||||
y += ScaleByZoom(bp.skip_top, dpi->zoom);
|
y += ScaleByZoom(bp.skip_top, dpi->zoom);
|
||||||
|
@ -747,6 +747,9 @@ static inline void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMod
|
||||||
if (bp.width <= 0) return;
|
if (bp.width <= 0) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(bp.skip_left + bp.width <= UnScaleByZoom(sprite->width, dpi->zoom));
|
||||||
|
assert(bp.skip_top + bp.height <= UnScaleByZoom(sprite->height, dpi->zoom));
|
||||||
|
|
||||||
BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom);
|
BlitterFactoryBase::GetCurrentBlitter()->Draw(&bp, mode, dpi->zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1614,7 +1614,7 @@ HouseZonesBits GetTownRadiusGroup(const Town* t, TileIndex tile)
|
||||||
* @param random_bits required for newgrf houses
|
* @param random_bits required for newgrf houses
|
||||||
* @pre house can be built here
|
* @pre house can be built here
|
||||||
*/
|
*/
|
||||||
static inline void ClearMakeHouseTile(TileIndex tile, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
|
static inline void ClearMakeHouseTile(TileIndex tile, Town *t, byte counter, byte stage, HouseID type, byte random_bits)
|
||||||
{
|
{
|
||||||
#if !defined(NDEBUG) || defined(WITH_ASSERT)
|
#if !defined(NDEBUG) || defined(WITH_ASSERT)
|
||||||
CommandCost cc =
|
CommandCost cc =
|
||||||
|
@ -1624,7 +1624,8 @@ static inline void ClearMakeHouseTile(TileIndex tile, TownID tid, byte counter,
|
||||||
|
|
||||||
assert(CmdSucceeded(cc));
|
assert(CmdSucceeded(cc));
|
||||||
|
|
||||||
MakeHouseTile(tile, tid, counter, stage, type, random_bits);
|
IncreaseBuildingCount(t, type);
|
||||||
|
MakeHouseTile(tile, t->index, counter, stage, type, random_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1638,14 +1639,14 @@ static inline void ClearMakeHouseTile(TileIndex tile, TownID tid, byte counter,
|
||||||
* @param random_bits required for newgrf houses
|
* @param random_bits required for newgrf houses
|
||||||
* @pre house can be built here
|
* @pre house can be built here
|
||||||
*/
|
*/
|
||||||
static void MakeTownHouse(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
|
static void MakeTownHouse(TileIndex t, Town *town, byte counter, byte stage, HouseID type, byte random_bits)
|
||||||
{
|
{
|
||||||
BuildingFlags size = GetHouseSpecs(type)->building_flags;
|
BuildingFlags size = GetHouseSpecs(type)->building_flags;
|
||||||
|
|
||||||
ClearMakeHouseTile(t, tid, counter, stage, type, random_bits);
|
ClearMakeHouseTile(t, town, counter, stage, type, random_bits);
|
||||||
if (size & BUILDING_2_TILES_Y) ClearMakeHouseTile(t + TileDiffXY(0, 1), tid, counter, stage, ++type, random_bits);
|
if (size & BUILDING_2_TILES_Y) ClearMakeHouseTile(t + TileDiffXY(0, 1), town, counter, stage, ++type, random_bits);
|
||||||
if (size & BUILDING_2_TILES_X) ClearMakeHouseTile(t + TileDiffXY(1, 0), tid, counter, stage, ++type, random_bits);
|
if (size & BUILDING_2_TILES_X) ClearMakeHouseTile(t + TileDiffXY(1, 0), town, counter, stage, ++type, random_bits);
|
||||||
if (size & BUILDING_HAS_4_TILES) ClearMakeHouseTile(t + TileDiffXY(1, 1), tid, counter, stage, ++type, random_bits);
|
if (size & BUILDING_HAS_4_TILES) ClearMakeHouseTile(t + TileDiffXY(1, 1), town, counter, stage, ++type, random_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1938,7 +1939,6 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||||
|
|
||||||
/* build the house */
|
/* build the house */
|
||||||
t->num_houses++;
|
t->num_houses++;
|
||||||
IncreaseBuildingCount(t, house);
|
|
||||||
|
|
||||||
/* Special houses that there can be only one of. */
|
/* Special houses that there can be only one of. */
|
||||||
t->flags12 |= oneof;
|
t->flags12 |= oneof;
|
||||||
|
@ -1959,7 +1959,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeTownHouse(tile, t->index, construction_counter, construction_stage, house, Random());
|
MakeTownHouse(tile, t, construction_counter, construction_stage, house, Random());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1968,9 +1968,10 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void DoClearTownHouseHelper(TileIndex tile)
|
static void DoClearTownHouseHelper(TileIndex tile, Town *t, HouseID house)
|
||||||
{
|
{
|
||||||
assert(IsTileType(tile, MP_HOUSE));
|
assert(IsTileType(tile, MP_HOUSE));
|
||||||
|
DecreaseBuildingCount(t, house);
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
DeleteAnimatedTile(tile);
|
DeleteAnimatedTile(tile);
|
||||||
}
|
}
|
||||||
|
@ -2021,7 +2022,6 @@ void ClearTownHouse(Town *t, TileIndex tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
t->num_houses--;
|
t->num_houses--;
|
||||||
DecreaseBuildingCount(t, house);
|
|
||||||
|
|
||||||
/* Clear flags for houses that only may exist once/town. */
|
/* Clear flags for houses that only may exist once/town. */
|
||||||
if (hs->building_flags & BUILDING_IS_CHURCH) {
|
if (hs->building_flags & BUILDING_IS_CHURCH) {
|
||||||
|
@ -2032,10 +2032,10 @@ void ClearTownHouse(Town *t, TileIndex tile)
|
||||||
|
|
||||||
/* Do the actual clearing of tiles */
|
/* Do the actual clearing of tiles */
|
||||||
eflags = hs->building_flags;
|
eflags = hs->building_flags;
|
||||||
DoClearTownHouseHelper(tile);
|
DoClearTownHouseHelper(tile, t, house);
|
||||||
if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0));
|
if (eflags & BUILDING_2_TILES_Y) DoClearTownHouseHelper(tile + TileDiffXY(0, 1), t, ++house);
|
||||||
if (eflags & BUILDING_2_TILES_Y) DoClearTownHouseHelper(tile + TileDiffXY(0, 1));
|
if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0), t, ++house);
|
||||||
if (eflags & BUILDING_HAS_4_TILES) DoClearTownHouseHelper(tile + TileDiffXY(1, 1));
|
if (eflags & BUILDING_HAS_4_TILES) DoClearTownHouseHelper(tile + TileDiffXY(1, 1), t, ++house);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsUniqueTownName(const char *name)
|
static bool IsUniqueTownName(const char *name)
|
||||||
|
|
|
@ -152,15 +152,18 @@ static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z)
|
||||||
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
|
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len)
|
bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags)
|
||||||
{
|
{
|
||||||
const BridgeSpec *b = GetBridgeSpec(bridge_type);
|
if (flags & DC_QUERY_COST) {
|
||||||
uint max; // max possible length of a bridge (with patch 100)
|
return bridge_len <= (_patches.longbridges ? 100 : 16);
|
||||||
|
}
|
||||||
|
|
||||||
if (bridge_type >= MAX_BRIDGES) return false;
|
if (bridge_type >= MAX_BRIDGES) return false;
|
||||||
|
|
||||||
|
const BridgeSpec *b = GetBridgeSpec(bridge_type);
|
||||||
if (b->avail_year > _cur_year) return false;
|
if (b->avail_year > _cur_year) return false;
|
||||||
|
|
||||||
max = b->max_length;
|
uint max = b->max_length;
|
||||||
if (max >= 16 && _patches.longbridges) max = 100;
|
if (max >= 16 && _patches.longbridges) max = 100;
|
||||||
|
|
||||||
return b->min_length <= bridge_len && bridge_len <= max;
|
return b->min_length <= bridge_len && bridge_len <= max;
|
||||||
|
@ -244,7 +247,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
|
||||||
|
|
||||||
/* set and test bridge length, availability */
|
/* set and test bridge length, availability */
|
||||||
bridge_len = sx + sy - x - y - 1;
|
bridge_len = sx + sy - x - y - 1;
|
||||||
if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
|
if (!CheckBridge_Stuff(bridge_type, bridge_len, flags)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
|
||||||
|
|
||||||
/* retrieve landscape height and ensure it's on land */
|
/* retrieve landscape height and ensure it's on land */
|
||||||
tile_start = TileXY(x, y);
|
tile_start = TileXY(x, y);
|
||||||
|
|
Loading…
Reference in New Issue