diff -r 31fcaa5375a1 -r e72987579514 src/water_cmd.cpp --- a/src/water_cmd.cpp Fri Aug 03 19:16:36 2007 +0000 +++ b/src/water_cmd.cpp Fri Aug 03 22:09:42 2007 +0000 @@ -28,6 +28,7 @@ #include "water_map.h" #include "newgrf.h" #include "newgrf_canal.h" +#include "misc/autoptr.hpp" static const SpriteID _water_shore_sprites[] = { 0, @@ -62,7 +63,6 @@ TileIndex tile2; CommandCost cost, ret; - Depot *depot; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -83,17 +83,18 @@ ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (CmdFailed(ret)) return CMD_ERROR; - depot = AllocateDepot(); + Depot *depot = new Depot(tile); if (depot == NULL) return CMD_ERROR; + AutoPtrT d_auto_delete = depot; if (flags & DC_EXEC) { - depot->xy = tile; depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis); MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis); MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile2); + d_auto_delete.Detach(); } return cost.AddCost(_price.build_ship_depot); @@ -113,7 +114,7 @@ if (flags & DC_EXEC) { /* Kill the depot, which is registered at the northernmost tile. Use that one */ - DeleteDepot(GetDepotByTile(tile2 < tile ? tile2 : tile)); + delete GetDepotByTile(tile2 < tile ? tile2 : tile); MakeWater(tile); MakeWater(tile2); @@ -441,23 +442,11 @@ DrawGroundSprite(image, PAL_NONE); for (; wdts->delta_x != 0x80; wdts++) { - SpriteID image = wdts->image; - SpriteID pal; - - if (image < 24) image += locks_base; - image += base; - - if (HASBIT(_transparent_opt, TO_BUILDINGS)) { - SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); - pal = PALETTE_TO_TRANSPARENT; - } else { - pal = palette; - } - - AddSortableSpriteToDraw(image, pal, + AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette, ti->x + wdts->delta_x, ti->y + wdts->delta_y, wdts->width, wdts->height, - wdts->unk, ti->z + wdts->delta_z); + wdts->unk, ti->z + wdts->delta_z, + HASBIT(_transparent_opt, TO_BUILDINGS)); } } @@ -512,9 +501,9 @@ return z + GetPartialZ(x & 0xF, y & 0xF, tileh); } -static Slope GetSlopeTileh_Water(TileIndex tile, Slope tileh) +static Foundation GetFoundation_Water(TileIndex tile, Slope tileh) { - return tileh; + return FOUNDATION_NONE; } static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac) @@ -824,5 +813,5 @@ ChangeTileOwner_Water, /* change_tile_owner_clear */ NULL, /* get_produced_cargo_proc */ VehicleEnter_Water, /* vehicle_enter_tile_proc */ - GetSlopeTileh_Water, /* get_slope_tileh_proc */ + GetFoundation_Water, /* get_foundation_proc */ };