Mercurial > hg > openttd
changeset 8571:b611278e4fed draft
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
author | frosch <frosch@openttd.org> |
---|---|
date | Fri, 15 Feb 2008 18:40:42 +0000 |
parents | 2b1397dd930a |
children | 8a95003be848 |
files | src/newgrf.cpp src/newgrf_house.cpp src/newgrf_industrytiles.cpp src/newgrf_station.cpp src/rail_cmd.cpp src/road_cmd.cpp src/sprite.h src/station_cmd.cpp src/table/road_land.h src/table/station_land.h src/table/track_land.h src/table/unmovable_land.h src/unmovable_cmd.cpp |
diffstat | 13 files changed, 63 insertions(+), 64 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -929,24 +929,24 @@ uint seq_count = 0; dts->seq = NULL; - dts->ground_sprite = grf_load_word(&buf); - dts->ground_pal = grf_load_word(&buf); - if (dts->ground_sprite == 0) continue; - if (HasBit(dts->ground_pal, 15)) { - ClrBit(dts->ground_pal, 15); - SetBit(dts->ground_sprite, SPRITE_MODIFIER_USE_OFFSET); + dts->ground.sprite = grf_load_word(&buf); + dts->ground.pal = grf_load_word(&buf); + if (dts->ground.sprite == 0) continue; + if (HasBit(dts->ground.pal, 15)) { + ClrBit(dts->ground.pal, 15); + SetBit(dts->ground.sprite, SPRITE_MODIFIER_USE_OFFSET); } - if (HasBit(dts->ground_pal, 14)) { - ClrBit(dts->ground_pal, 14); - SetBit(dts->ground_sprite, SPRITE_MODIFIER_OPAQUE); + if (HasBit(dts->ground.pal, 14)) { + ClrBit(dts->ground.pal, 14); + SetBit(dts->ground.sprite, SPRITE_MODIFIER_OPAQUE); } - if (HasBit(dts->ground_sprite, 15)) { - ClrBit(dts->ground_sprite, 15); - SetBit(dts->ground_sprite, PALETTE_MODIFIER_COLOR); + if (HasBit(dts->ground.sprite, 15)) { + ClrBit(dts->ground.sprite, 15); + SetBit(dts->ground.sprite, PALETTE_MODIFIER_COLOR); } - if (HasBit(dts->ground_sprite, 14)) { - ClrBit(dts->ground_sprite, 14); - SetBit(dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT); + if (HasBit(dts->ground.sprite, 14)) { + ClrBit(dts->ground.sprite, 14); + SetBit(dts->ground.sprite, PALETTE_MODIFIER_TRANSPARENT); } while (buf < *bufp + len) { @@ -2652,27 +2652,27 @@ group->g.layout.dts = CallocT<DrawTileSprites>(1); /* Groundsprite */ - group->g.layout.dts->ground_sprite = grf_load_word(&buf); - group->g.layout.dts->ground_pal = grf_load_word(&buf); + group->g.layout.dts->ground.sprite = grf_load_word(&buf); + group->g.layout.dts->ground.pal = grf_load_word(&buf); /* Remap transparent/colour modifier bits */ - if (HasBit(group->g.layout.dts->ground_sprite, 14)) { - ClrBit(group->g.layout.dts->ground_sprite, 14); - SetBit(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_TRANSPARENT); + if (HasBit(group->g.layout.dts->ground.sprite, 14)) { + ClrBit(group->g.layout.dts->ground.sprite, 14); + SetBit(group->g.layout.dts->ground.sprite, PALETTE_MODIFIER_TRANSPARENT); } - if (HasBit(group->g.layout.dts->ground_sprite, 15)) { - ClrBit(group->g.layout.dts->ground_sprite, 15); - SetBit(group->g.layout.dts->ground_sprite, PALETTE_MODIFIER_COLOR); + if (HasBit(group->g.layout.dts->ground.sprite, 15)) { + ClrBit(group->g.layout.dts->ground.sprite, 15); + SetBit(group->g.layout.dts->ground.sprite, PALETTE_MODIFIER_COLOR); } - if (HasBit(group->g.layout.dts->ground_pal, 14)) { - ClrBit(group->g.layout.dts->ground_pal, 14); - SetBit(group->g.layout.dts->ground_sprite, SPRITE_MODIFIER_OPAQUE); + if (HasBit(group->g.layout.dts->ground.pal, 14)) { + ClrBit(group->g.layout.dts->ground.pal, 14); + SetBit(group->g.layout.dts->ground.sprite, SPRITE_MODIFIER_OPAQUE); } - if (HasBit(group->g.layout.dts->ground_pal, 15)) { + if (HasBit(group->g.layout.dts->ground.pal, 15)) { /* Bit 31 set means this is a custom sprite, so rewrite it to the * last spriteset defined. */ - SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground_sprite, 0, 14) * sprites; - SB(group->g.layout.dts->ground_sprite, 0, SPRITE_WIDTH, sprite); - ClrBit(group->g.layout.dts->ground_pal, 15); + SpriteID sprite = _cur_grffile->spriteset_start + GB(group->g.layout.dts->ground.sprite, 0, 14) * sprites; + SB(group->g.layout.dts->ground.sprite, 0, SPRITE_WIDTH, sprite); + ClrBit(group->g.layout.dts->ground.pal, 15); } group->g.layout.dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1);
--- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -289,8 +289,8 @@ const DrawTileSprites *dts = group->g.layout.dts; const DrawTileSeqStruct *dtss; - SpriteID image = dts->ground_sprite; - SpriteID pal = dts->ground_pal; + SpriteID image = dts->ground.sprite; + SpriteID pal = dts->ground.pal; if (IS_CUSTOM_SPRITE(image)) image += stage;
--- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -177,8 +177,8 @@ const DrawTileSprites *dts = group->g.layout.dts; const DrawTileSeqStruct *dtss; - SpriteID image = dts->ground_sprite; - SpriteID pal = dts->ground_pal; + SpriteID image = dts->ground.sprite; + SpriteID pal = dts->ground.pal; if (IS_CUSTOM_SPRITE(image)) image += stage;
--- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -772,7 +772,7 @@ sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis]; } - image = sprites->ground_sprite; + image = sprites->ground.sprite; if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); image += rti->custom_ground_offset;
--- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1760,7 +1760,7 @@ relocation = rti->total_offset; - image = dts->ground_sprite; + image = dts->ground.sprite; if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset; /* adjust ground tile for desert @@ -1796,7 +1796,7 @@ if (dts != NULL && dts->seq != NULL) { relocation = GetCustomStationRelocation(statspec, st, ti->tile); - image = dts->ground_sprite; + image = dts->ground.sprite; if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { image += GetCustomStationGroundRelocation(statspec, st, ti->tile); image += rti->custom_ground_offset; @@ -1811,7 +1811,7 @@ /* There is no custom layout, fall back to the default graphics */ dts = &_waypoint_gfx_table[GetWaypointAxis(ti->tile)]; relocation = 0; - image = dts->ground_sprite + rti->total_offset; + image = dts->ground.sprite + rti->total_offset; if (IsSnowRailGround(ti->tile)) image += rti->snow_offset; } } @@ -1872,7 +1872,7 @@ void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype) { const DrawTileSprites* dts = &_depot_gfx_table[dir]; - SpriteID image = dts->ground_sprite; + SpriteID image = dts->ground.sprite; uint32 offset = GetRailTypeInfo(railtype)->total_offset; if (image != SPR_FLAT_GRASS_TILE) image += offset; @@ -1884,7 +1884,7 @@ uint32 offset = GetRailTypeInfo(railtype)->total_offset; const DrawTileSprites* dts = &_waypoint_gfx_table[AXIS_X]; - DrawTileSequence(x, y, dts->ground_sprite + offset, dts->seq, 0); + DrawTileSequence(x, y, dts->ground.sprite + offset, dts->seq, 0); } static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y)
--- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1114,7 +1114,7 @@ dts = &_road_depot[GetRoadDepotDirection(ti->tile)]; } - DrawGroundSprite(dts->ground_sprite, PAL_NONE); + DrawGroundSprite(dts->ground.sprite, PAL_NONE); for (dtss = dts->seq; dtss->image.sprite != 0; dtss++) { SpriteID image = dtss->image.sprite; @@ -1149,7 +1149,7 @@ x += 33; y += 17; - DrawSprite(dts->ground_sprite, PAL_NONE, x, y); + DrawSprite(dts->ground.sprite, PAL_NONE, x, y); for (dtss = dts->seq; dtss->image.sprite != 0; dtss++) { Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
--- a/src/sprite.h +++ b/src/sprite.h @@ -34,8 +34,7 @@ }; struct DrawTileSprites { - SpriteID ground_sprite; - SpriteID ground_pal; + PalSpriteID ground; const DrawTileSeqStruct *seq; };
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2170,7 +2170,7 @@ } } } else { - SpriteID image = t->ground_sprite; + SpriteID image = t->ground.sprite; if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { image += GetCustomStationGroundRelocation(statspec, st, ti->tile); image += custom_ground_offset; @@ -2229,11 +2229,11 @@ total_offset = rti->total_offset; } - SpriteID img = t->ground_sprite; + SpriteID img = t->ground.sprite; DrawSprite(img + total_offset, HasBit(img, PALETTE_MODIFIER_COLOR) ? 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); + DrawSprite(SPR_TRAMWAY_TRAM + (t->ground.sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y); } const DrawTileSeqStruct *dtss;
--- a/src/table/road_land.h +++ b/src/table/road_land.h @@ -26,10 +26,10 @@ }; static const DrawTileSprites _road_depot[] = { - { 0xA4A, PAL_NONE, _road_depot_NE }, - { 0xA4A, PAL_NONE, _road_depot_SE }, - { 0xA4A, PAL_NONE, _road_depot_SW }, - { 0xA4A, PAL_NONE, _road_depot_NW } + { {0xA4A, PAL_NONE}, _road_depot_NE }, + { {0xA4A, PAL_NONE}, _road_depot_SE }, + { {0xA4A, PAL_NONE}, _road_depot_SW }, + { {0xA4A, PAL_NONE}, _road_depot_NW } }; static const DrawTileSeqStruct _tram_depot_NE[] = { @@ -55,10 +55,10 @@ }; static const DrawTileSprites _tram_depot[] = { - { 0xA4A, PAL_NONE, _tram_depot_NE }, - { 0xA4A, PAL_NONE, _tram_depot_SE }, - { 0xA4A, PAL_NONE, _tram_depot_SW }, - { 0xA4A, PAL_NONE, _tram_depot_NW } + { {0xA4A, PAL_NONE}, _tram_depot_NE }, + { {0xA4A, PAL_NONE}, _tram_depot_SE }, + { {0xA4A, PAL_NONE}, _tram_depot_SW }, + { {0xA4A, PAL_NONE}, _tram_depot_NW } }; #undef TILE_SEQ_LINE
--- a/src/table/station_land.h +++ b/src/table/station_land.h @@ -993,7 +993,7 @@ #undef TILE_SEQ_LINE #undef TILE_SEQ_LINE_PAL -#define TILE_SPRITE_LINE(img, dtss) { img, PAL_NONE, dtss }, +#define TILE_SPRITE_LINE(img, dtss) { {img, PAL_NONE}, dtss }, static const DrawTileSprites _station_display_datas_rail[] = { TILE_SPRITE_LINE(SPR_RAIL_TRACK_X, _station_display_datas_0)
--- a/src/table/track_land.h +++ b/src/table/track_land.h @@ -27,10 +27,10 @@ }; static const DrawTileSprites _depot_gfx_table[] = { - { SPR_FLAT_GRASS_TILE, PAL_NONE, _depot_gfx_NE }, - { SPR_RAIL_TRACK_Y, PAL_NONE, _depot_gfx_SE }, - { SPR_RAIL_TRACK_X, PAL_NONE, _depot_gfx_SW }, - { SPR_FLAT_GRASS_TILE, PAL_NONE, _depot_gfx_NW } + { {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NE }, + { {SPR_RAIL_TRACK_Y, PAL_NONE}, _depot_gfx_SE }, + { {SPR_RAIL_TRACK_X, PAL_NONE}, _depot_gfx_SW }, + { {SPR_FLAT_GRASS_TILE, PAL_NONE}, _depot_gfx_NW } }; @@ -47,8 +47,8 @@ }; static const DrawTileSprites _waypoint_gfx_table[] = { - { SPR_RAIL_TRACK_X, PAL_NONE, _waypoint_gfx_X }, - { SPR_RAIL_TRACK_Y, PAL_NONE, _waypoint_gfx_Y } + { {SPR_RAIL_TRACK_X, PAL_NONE}, _waypoint_gfx_X }, + { {SPR_RAIL_TRACK_Y, PAL_NONE}, _waypoint_gfx_Y } }; #undef TILE_SEQ_LINE
--- a/src/table/unmovable_land.h +++ b/src/table/unmovable_land.h @@ -70,7 +70,7 @@ #undef TILE_SEQ_LINE #undef TILE_SEQ_END -#define TILE_SPRITE_LINE(img, dtss) { img | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, dtss }, +#define TILE_SPRITE_LINE(img, dtss) { {img | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE}, dtss }, static const DrawTileSprites _unmovable_display_datas[] = { TILE_SPRITE_LINE(0xA2B, _unmovable_display_nothing)
--- a/src/unmovable_cmd.cpp +++ b/src/unmovable_cmd.cpp @@ -212,7 +212,7 @@ palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)]; - DrawGroundSprite(t->ground_sprite, palette); + DrawGroundSprite(t->ground.sprite, palette); foreach_draw_tile_seq(dtss, t->seq) { AddSortableSpriteToDraw(