--- a/src/gfx.cpp Wed Jul 09 19:15:43 2008 +0000
+++ b/src/gfx.cpp Wed Jul 09 19:20:50 2008 +0000
@@ -669,7 +669,7 @@
}
}
-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;
Blitter::BlitterParams bp;
@@ -695,8 +695,8 @@
bp.height = UnScaleByZoom(sprite->height - clip_top - clip_bottom, dpi->zoom);
bp.top = 0;
bp.left = 0;
- bp.skip_left = UnScaleByZoom(clip_left, dpi->zoom);
- bp.skip_top = UnScaleByZoom(clip_top, dpi->zoom);
+ bp.skip_left = UnScaleByZoomLower(clip_left, dpi->zoom);
+ bp.skip_top = UnScaleByZoomLower(clip_top, dpi->zoom);
x += ScaleByZoom(bp.skip_left, dpi->zoom);
y += ScaleByZoom(bp.skip_top, dpi->zoom);
@@ -747,6 +747,9 @@
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);
}
--- a/src/town_cmd.cpp Wed Jul 09 19:15:43 2008 +0000
+++ b/src/town_cmd.cpp Wed Jul 09 19:20:50 2008 +0000
@@ -1614,7 +1614,7 @@
* @param random_bits required for newgrf houses
* @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)
CommandCost cc =
@@ -1624,7 +1624,8 @@
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 @@
* @param random_bits required for newgrf houses
* @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;
- ClearMakeHouseTile(t, tid, 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_X) ClearMakeHouseTile(t + TileDiffXY(1, 0), tid, counter, stage, ++type, random_bits);
- if (size & BUILDING_HAS_4_TILES) ClearMakeHouseTile(t + TileDiffXY(1, 1), 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), town, 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), town, counter, stage, ++type, random_bits);
}
@@ -1938,7 +1939,6 @@
/* build the house */
t->num_houses++;
- IncreaseBuildingCount(t, house);
/* Special houses that there can be only one of. */
t->flags12 |= oneof;
@@ -1959,7 +1959,7 @@
}
}
- MakeTownHouse(tile, t->index, construction_counter, construction_stage, house, Random());
+ MakeTownHouse(tile, t, construction_counter, construction_stage, house, Random());
return true;
}
@@ -1968,9 +1968,10 @@
}
-static void DoClearTownHouseHelper(TileIndex tile)
+static void DoClearTownHouseHelper(TileIndex tile, Town *t, HouseID house)
{
assert(IsTileType(tile, MP_HOUSE));
+ DecreaseBuildingCount(t, house);
DoClearSquare(tile);
DeleteAnimatedTile(tile);
}
@@ -2021,7 +2022,6 @@
}
t->num_houses--;
- DecreaseBuildingCount(t, house);
/* Clear flags for houses that only may exist once/town. */
if (hs->building_flags & BUILDING_IS_CHURCH) {
@@ -2032,10 +2032,10 @@
/* Do the actual clearing of tiles */
eflags = hs->building_flags;
- DoClearTownHouseHelper(tile);
- if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0));
- if (eflags & BUILDING_2_TILES_Y) DoClearTownHouseHelper(tile + TileDiffXY(0, 1));
- if (eflags & BUILDING_HAS_4_TILES) DoClearTownHouseHelper(tile + TileDiffXY(1, 1));
+ DoClearTownHouseHelper(tile, t, house);
+ if (eflags & BUILDING_2_TILES_Y) DoClearTownHouseHelper(tile + TileDiffXY(0, 1), t, ++house);
+ if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0), t, ++house);
+ if (eflags & BUILDING_HAS_4_TILES) DoClearTownHouseHelper(tile + TileDiffXY(1, 1), t, ++house);
}
static bool IsUniqueTownName(const char *name)