|
@@ -503,55 +503,49 @@ void GetProductionAroundTiles(AcceptedCa
|
|
|
*/
|
|
|
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile,
|
|
|
int w, int h, int rad)
|
|
|
{
|
|
|
memset(accepts, 0, sizeof(AcceptedCargo)); // sizeof(AcceptedCargo) != sizeof(accepts) (== sizeof(uint *))
|
|
|
|
|
|
int x = TileX(tile);
|
|
|
int y = TileY(tile);
|
|
|
|
|
|
/* expand the region by rad tiles on each side
|
|
|
* while making sure that we remain inside the board. */
|
|
|
int x2 = min(x + w + rad, MapSizeX());
|
|
|
int y2 = min(y + h + rad, MapSizeY());
|
|
|
int x1 = max(x - rad, 0);
|
|
|
int y1 = max(y - rad, 0);
|
|
|
|
|
|
assert(x1 < x2);
|
|
|
assert(y1 < y2);
|
|
|
assert(w > 0);
|
|
|
assert(h > 0);
|
|
|
|
|
|
for (int yc = y1; yc != y2; yc++) {
|
|
|
for (int xc = x1; xc != x2; xc++) {
|
|
|
TileIndex tile = TileXY(xc, yc);
|
|
|
|
|
|
if (!IsTileType(tile, MP_STATION)) {
|
|
|
AcceptedCargo ac;
|
|
|
|
|
|
GetAcceptedCargo(tile, ac);
|
|
|
for (uint i = 0; i < lengthof(ac); ++i) accepts[i] += ac[i];
|
|
|
}
|
|
|
AddAcceptedCargo(tile, accepts);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** Update the acceptance for a station.
|
|
|
* @param st Station to update
|
|
|
* @param show_msg controls whether to display a message that acceptance was changed.
|
|
|
*/
|
|
|
static void UpdateStationAcceptance(Station *st, bool show_msg)
|
|
|
{
|
|
|
/* Don't update acceptance for a buoy */
|
|
|
if (st->IsBuoy()) return;
|
|
|
|
|
|
/* old accepted goods types */
|
|
|
uint old_acc = GetAcceptanceMask(st);
|
|
|
|
|
|
/* And retrieve the acceptance. */
|
|
|
AcceptedCargo accepts;
|
|
|
if (!st->rect.IsEmpty()) {
|
|
|
GetAcceptanceAroundTiles(
|
|
|
accepts,
|
|
|
TileXY(st->rect.left, st->rect.top),
|
|
|
st->rect.right - st->rect.left + 1,
|
|
|
st->rect.bottom - st->rect.top + 1,
|
|
@@ -2327,53 +2321,48 @@ void StationPickerDrawSprite(int x, int
|
|
|
SpriteID img = t->ground.sprite;
|
|
|
DrawSprite(img + total_offset, HasBit(img, PALETTE_MODIFIER_COLOUR) ? pal : PAL_NONE, x, y);
|
|
|
|
|
|
if (roadtype == ROADTYPE_TRAM) {
|
|
|
DrawSprite(SPR_TRAMWAY_TRAM + (t->ground.sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y);
|
|
|
}
|
|
|
|
|
|
const DrawTileSeqStruct *dtss;
|
|
|
foreach_draw_tile_seq(dtss, t->seq) {
|
|
|
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
|
|
|
DrawSprite(dtss->image.sprite + total_offset, pal, x + pt.x, y + pt.y);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static uint GetSlopeZ_Station(TileIndex tile, uint x, uint y)
|
|
|
{
|
|
|
return GetTileMaxZ(tile);
|
|
|
}
|
|
|
|
|
|
static Foundation GetFoundation_Station(TileIndex tile, Slope tileh)
|
|
|
{
|
|
|
return FlatteningFoundation(tileh);
|
|
|
}
|
|
|
|
|
|
static void GetAcceptedCargo_Station(TileIndex tile, AcceptedCargo ac)
|
|
|
{
|
|
|
/* not used */
|
|
|
}
|
|
|
|
|
|
static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
|
|
|
{
|
|
|
td->owner[0] = GetTileOwner(tile);
|
|
|
if (IsDriveThroughStopTile(tile)) {
|
|
|
Owner road_owner = INVALID_OWNER;
|
|
|
Owner tram_owner = INVALID_OWNER;
|
|
|
RoadTypes rts = GetRoadTypes(tile);
|
|
|
if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
|
|
|
if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM);
|
|
|
|
|
|
/* Is there a mix of owners? */
|
|
|
if ((tram_owner != INVALID_OWNER && tram_owner != td->owner[0]) ||
|
|
|
(road_owner != INVALID_OWNER && road_owner != td->owner[0])) {
|
|
|
uint i = 1;
|
|
|
if (road_owner != INVALID_OWNER) {
|
|
|
td->owner_type[i] = STR_LAND_AREA_INFORMATION_ROAD_OWNER;
|
|
|
td->owner[i] = road_owner;
|
|
|
i++;
|
|
|
}
|
|
|
if (tram_owner != INVALID_OWNER) {
|
|
|
td->owner_type[i] = STR_LAND_AREA_INFORMATION_TRAM_OWNER;
|
|
|
td->owner[i] = tram_owner;
|
|
|
}
|
|
|
}
|
|
@@ -3142,36 +3131,36 @@ static CommandCost TerraformTile_Station
|
|
|
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
|
|
|
|
|
|
case STATION_TRUCK:
|
|
|
case STATION_BUS: {
|
|
|
DiagDirection direction = GetRoadStopDir(tile);
|
|
|
if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break;
|
|
|
if (IsDriveThroughStopTile(tile)) {
|
|
|
if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
|
|
|
}
|
|
|
return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
|
|
|
}
|
|
|
|
|
|
default: break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
}
|
|
|
|
|
|
|
|
|
extern const TileTypeProcs _tile_type_station_procs = {
|
|
|
DrawTile_Station, // draw_tile_proc
|
|
|
GetSlopeZ_Station, // get_slope_z_proc
|
|
|
ClearTile_Station, // clear_tile_proc
|
|
|
GetAcceptedCargo_Station, // get_accepted_cargo_proc
|
|
|
NULL, // get_accepted_cargo_proc
|
|
|
GetTileDesc_Station, // get_tile_desc_proc
|
|
|
GetTileTrackStatus_Station, // get_tile_track_status_proc
|
|
|
ClickTile_Station, // click_tile_proc
|
|
|
AnimateTile_Station, // animate_tile_proc
|
|
|
TileLoop_Station, // tile_loop_clear
|
|
|
ChangeTileOwner_Station, // change_tile_owner_clear
|
|
|
NULL, // get_produced_cargo_proc
|
|
|
VehicleEnter_Station, // vehicle_enter_tile_proc
|
|
|
GetFoundation_Station, // get_foundation_proc
|
|
|
TerraformTile_Station, // terraform_tile_proc
|
|
|
};
|