diff options
author | rubidium <rubidium@openttd.org> | 2010-08-28 18:57:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-28 18:57:32 +0000 |
commit | d4403cb64937bbce065b1c84faa207194fd19262 (patch) | |
tree | 398c1d4ebaef6a91fcac0bfa24af8322e5883643 | |
parent | fba19a41d5ffddb8c33a4e45016d90a8ae3283be (diff) | |
download | openttd-d4403cb64937bbce065b1c84faa207194fd19262.tar.xz |
(svn r20666) -Codechange: enable drawing of (NewGRF) objects
-rw-r--r-- | src/object_cmd.cpp | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index 2cd8ddc82..aabf30c0c 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -259,42 +259,46 @@ static void DrawTile_Object(TileInfo *ti) if ((spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) == 0) DrawFoundation(ti, GetFoundation_Object(ti->tile, ti->tileh)); - const DrawTileSprites *dts = NULL; - Owner to = GetTileOwner(ti->tile); - PaletteID palette = to == OWNER_NONE ? PAL_NONE : COMPANY_SPRITE_COLOUR(to); - - if (type == OBJECT_HQ) { - TileIndex diff = ti->tile - Object::GetByTile(ti->tile)->location.tile; - dts = &_object_hq[GetCompanyHQSize(ti->tile) << 2 | TileY(diff) << 1 | TileX(diff)]; - } else { - dts = &_objects[type]; - } + if (type < NEW_OBJECT_OFFSET) { + const DrawTileSprites *dts = NULL; + Owner to = GetTileOwner(ti->tile); + PaletteID palette = to == OWNER_NONE ? PAL_NONE : COMPANY_SPRITE_COLOUR(to); + + if (type == OBJECT_HQ) { + TileIndex diff = ti->tile - Object::GetByTile(ti->tile)->location.tile; + dts = &_object_hq[GetCompanyHQSize(ti->tile) << 2 | TileY(diff) << 1 | TileX(diff)]; + } else { + dts = &_objects[type]; + } - if (spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) { - /* If an object has no foundation, but tries to draw a (flat) ground - * type... we have to be nice and convert that for them. */ - switch (dts->ground.sprite) { - case SPR_FLAT_BARE_LAND: DrawClearLandTile(ti, 0); break; - case SPR_FLAT_1_THIRD_GRASS_TILE: DrawClearLandTile(ti, 1); break; - case SPR_FLAT_2_THIRD_GRASS_TILE: DrawClearLandTile(ti, 2); break; - case SPR_FLAT_GRASS_TILE: DrawClearLandTile(ti, 3); break; - default: DrawGroundSprite(dts->ground.sprite, palette); break; + if (spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) { + /* If an object has no foundation, but tries to draw a (flat) ground + * type... we have to be nice and convert that for them. */ + switch (dts->ground.sprite) { + case SPR_FLAT_BARE_LAND: DrawClearLandTile(ti, 0); break; + case SPR_FLAT_1_THIRD_GRASS_TILE: DrawClearLandTile(ti, 1); break; + case SPR_FLAT_2_THIRD_GRASS_TILE: DrawClearLandTile(ti, 2); break; + case SPR_FLAT_GRASS_TILE: DrawClearLandTile(ti, 3); break; + default: DrawGroundSprite(dts->ground.sprite, palette); break; + } + } else { + DrawGroundSprite(dts->ground.sprite, palette); } - } else { - DrawGroundSprite(dts->ground.sprite, palette); - } - if (!IsInvisibilitySet(TO_STRUCTURES)) { - const DrawTileSeqStruct *dtss; - foreach_draw_tile_seq(dtss, dts->seq) { - AddSortableSpriteToDraw( - dtss->image.sprite, palette, - ti->x + dtss->delta_x, ti->y + dtss->delta_y, - dtss->size_x, dtss->size_y, - dtss->size_z, ti->z + dtss->delta_z, - IsTransparencySet(TO_STRUCTURES) - ); + if (!IsInvisibilitySet(TO_STRUCTURES)) { + const DrawTileSeqStruct *dtss; + foreach_draw_tile_seq(dtss, dts->seq) { + AddSortableSpriteToDraw( + dtss->image.sprite, palette, + ti->x + dtss->delta_x, ti->y + dtss->delta_y, + dtss->size_x, dtss->size_y, + dtss->size_z, ti->z + dtss->delta_z, + IsTransparencySet(TO_STRUCTURES) + ); + } } + } else { + DrawNewObjectTile(ti, spec); } if (spec->flags & OBJECT_FLAG_ALLOW_UNDER_BRIDGE) DrawBridgeMiddle(ti); |