mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18837) -Codechange: Rename DrawStationTileSeq() to DrawCommonTileSeq() and move it to separate file.
This commit is contained in:
parent
199091600a
commit
d27999e446
|
@ -683,6 +683,10 @@
|
||||||
RelativePath=".\..\src\sound.cpp"
|
RelativePath=".\..\src\sound.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\sprite.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\spritecache.cpp"
|
RelativePath=".\..\src\spritecache.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -680,6 +680,10 @@
|
||||||
RelativePath=".\..\src\sound.cpp"
|
RelativePath=".\..\src\sound.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\sprite.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\spritecache.cpp"
|
RelativePath=".\..\src\spritecache.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -58,6 +58,7 @@ settings.cpp
|
||||||
signal.cpp
|
signal.cpp
|
||||||
signs.cpp
|
signs.cpp
|
||||||
sound.cpp
|
sound.cpp
|
||||||
|
sprite.cpp
|
||||||
spritecache.cpp
|
spritecache.cpp
|
||||||
station.cpp
|
station.cpp
|
||||||
string.cpp
|
string.cpp
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
#include "transparency.h"
|
#include "transparency.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps an entity id stored on the map to a GRF file.
|
* Maps an entity id stored on the map to a GRF file.
|
||||||
* Entities are objects used ingame (houses, industries, industry tiles) for
|
* Entities are objects used ingame (houses, industries, industry tiles) for
|
||||||
|
@ -109,45 +107,6 @@ uint32 GetTerrainType(TileIndex tile);
|
||||||
TileIndex GetNearbyTile(byte parameter, TileIndex tile);
|
TileIndex GetNearbyTile(byte parameter, TileIndex tile);
|
||||||
uint32 GetNearbyTileInformation(TileIndex tile);
|
uint32 GetNearbyTileInformation(TileIndex tile);
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layout entry
|
|
||||||
* @Note for ground sprites use #GroundSpritePaletteTransform
|
|
||||||
* @Note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set
|
|
||||||
* when to use the default palette.
|
|
||||||
*
|
|
||||||
* @param image The sprite to draw
|
|
||||||
* @param pal The palette from the sprite layout
|
|
||||||
* @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
|
|
||||||
* @return The palette to use
|
|
||||||
*/
|
|
||||||
static inline SpriteID SpriteLayoutPaletteTransform(SpriteID image, SpriteID pal, SpriteID default_pal)
|
|
||||||
{
|
|
||||||
if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOUR)) {
|
|
||||||
return (pal != 0 ? pal : default_pal);
|
|
||||||
} else {
|
|
||||||
return PAL_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite
|
|
||||||
* @Note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set
|
|
||||||
* when to use the default palette.
|
|
||||||
*
|
|
||||||
* @param image The sprite to draw
|
|
||||||
* @param pal The palette from the sprite layout
|
|
||||||
* @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
|
|
||||||
* @return The palette to use
|
|
||||||
*/
|
|
||||||
static inline SpriteID GroundSpritePaletteTransform(SpriteID image, SpriteID pal, SpriteID default_pal)
|
|
||||||
{
|
|
||||||
if (HasBit(image, PALETTE_MODIFIER_COLOUR)) {
|
|
||||||
return (pal != 0 ? pal : default_pal);
|
|
||||||
} else {
|
|
||||||
return PAL_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, byte stage, SpriteID default_palette);
|
void DrawTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, byte stage, SpriteID default_palette);
|
||||||
|
|
||||||
#endif /* NEWGRF_COMMONS_H */
|
#endif /* NEWGRF_COMMONS_H */
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "pathfinder/yapf/yapf_cache.h"
|
#include "pathfinder/yapf/yapf_cache.h"
|
||||||
#include "newgrf_engine.h"
|
#include "newgrf_engine.h"
|
||||||
#include "landscape_type.h"
|
#include "landscape_type.h"
|
||||||
#include "newgrf_commons.h"
|
|
||||||
#include "train.h"
|
#include "train.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
#include "autoslope.h"
|
#include "autoslope.h"
|
||||||
|
@ -1982,7 +1981,7 @@ static void DrawTile_Track(TileInfo *ti)
|
||||||
if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
|
if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti);
|
||||||
|
|
||||||
/* No NewGRF depots, so no relocation */
|
/* No NewGRF depots, so no relocation */
|
||||||
DrawStationTileSeq(ti, dts, TO_BUILDINGS, rti->total_offset, 0, _drawtile_track_palette);
|
DrawCommonTileSeq(ti, dts, TO_BUILDINGS, rti->total_offset, 0, _drawtile_track_palette);
|
||||||
}
|
}
|
||||||
DrawBridgeMiddle(ti);
|
DrawBridgeMiddle(ti);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file sprite.cpp Handling of sprites */
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "sprite.h"
|
||||||
|
#include "tile_cmd.h"
|
||||||
|
#include "viewport_func.h"
|
||||||
|
|
||||||
|
#include "table/sprites.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a tile sprite sequence.
|
||||||
|
* @param ti The tile to draw on
|
||||||
|
* @param dts Sprite and subsprites to draw
|
||||||
|
* @param to The transparancy bit that toggles drawing of these sprites
|
||||||
|
* @param orig_offset Sprite-Offset for original sprites
|
||||||
|
* @param newgrf_offset Sprite-Offset for NewGRF defined sprites
|
||||||
|
* @param default_palette The default recolour sprite to use (typically company colour)
|
||||||
|
*/
|
||||||
|
void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, SpriteID default_palette)
|
||||||
|
{
|
||||||
|
const DrawTileSeqStruct *dtss;
|
||||||
|
foreach_draw_tile_seq(dtss, dts->seq) {
|
||||||
|
SpriteID image = dtss->image.sprite;
|
||||||
|
|
||||||
|
/* Stop drawing sprite sequence once we meet a sprite that doesn't have to be opaque */
|
||||||
|
if (IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE)) return;
|
||||||
|
|
||||||
|
if (newgrf_offset == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
|
||||||
|
image += orig_offset;
|
||||||
|
} else {
|
||||||
|
image += newgrf_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpriteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette);
|
||||||
|
|
||||||
|
if ((byte)dtss->delta_z != 0x80) {
|
||||||
|
AddSortableSpriteToDraw(
|
||||||
|
image, pal,
|
||||||
|
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
|
dtss->size_x, dtss->size_y,
|
||||||
|
dtss->size_z, ti->z + dtss->delta_z,
|
||||||
|
!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
/* For stations and original spritelayouts delta_x and delta_y are signed */
|
||||||
|
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
src/sprite.h
44
src/sprite.h
|
@ -13,6 +13,9 @@
|
||||||
#define SPRITE_H
|
#define SPRITE_H
|
||||||
|
|
||||||
#include "gfx_type.h"
|
#include "gfx_type.h"
|
||||||
|
#include "transparency.h"
|
||||||
|
|
||||||
|
#include "table/sprites.h"
|
||||||
|
|
||||||
#define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START)
|
#define GENERAL_SPRITE_COLOUR(colour) ((colour) + PALETTE_RECOLOUR_START)
|
||||||
#define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner]))
|
#define COMPANY_SPRITE_COLOUR(owner) (GENERAL_SPRITE_COLOUR(_company_colours[owner]))
|
||||||
|
@ -65,6 +68,47 @@ struct DrawBuildingsTileStruct {
|
||||||
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
|
/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
|
||||||
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
|
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
|
||||||
|
|
||||||
|
void DrawCommonTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, SpriteID default_palette);
|
||||||
|
|
||||||
bool SkipSpriteData(byte type, uint16 num);
|
bool SkipSpriteData(byte type, uint16 num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layout entry
|
||||||
|
* @Note for ground sprites use #GroundSpritePaletteTransform
|
||||||
|
* @Note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set
|
||||||
|
* when to use the default palette.
|
||||||
|
*
|
||||||
|
* @param image The sprite to draw
|
||||||
|
* @param pal The palette from the sprite layout
|
||||||
|
* @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
|
||||||
|
* @return The palette to use
|
||||||
|
*/
|
||||||
|
static inline SpriteID SpriteLayoutPaletteTransform(SpriteID image, SpriteID pal, SpriteID default_pal)
|
||||||
|
{
|
||||||
|
if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOUR)) {
|
||||||
|
return (pal != 0 ? pal : default_pal);
|
||||||
|
} else {
|
||||||
|
return PAL_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite
|
||||||
|
* @Note Not useable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set
|
||||||
|
* when to use the default palette.
|
||||||
|
*
|
||||||
|
* @param image The sprite to draw
|
||||||
|
* @param pal The palette from the sprite layout
|
||||||
|
* @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
|
||||||
|
* @return The palette to use
|
||||||
|
*/
|
||||||
|
static inline SpriteID GroundSpritePaletteTransform(SpriteID image, SpriteID pal, SpriteID default_pal)
|
||||||
|
{
|
||||||
|
if (HasBit(image, PALETTE_MODIFIER_COLOUR)) {
|
||||||
|
return (pal != 0 ? pal : default_pal);
|
||||||
|
} else {
|
||||||
|
return PAL_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SPRITE_H */
|
#endif /* SPRITE_H */
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "industry.h"
|
#include "industry.h"
|
||||||
#include "newgrf_cargo.h"
|
#include "newgrf_cargo.h"
|
||||||
#include "newgrf_station.h"
|
#include "newgrf_station.h"
|
||||||
#include "newgrf_commons.h"
|
|
||||||
#include "pathfinder/yapf/yapf_cache.h"
|
#include "pathfinder/yapf/yapf_cache.h"
|
||||||
#include "road_internal.h" /* For drawing catenary/checking road removal */
|
#include "road_internal.h" /* For drawing catenary/checking road removal */
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
@ -2456,48 +2455,7 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
total_offset = 0;
|
total_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawStationTileSeq(ti, t, TO_BUILDINGS, total_offset, relocation, palette);
|
DrawCommonTileSeq(ti, t, TO_BUILDINGS, total_offset, relocation, palette);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draws a station, waypoint or depot including all subsprites on a tile.
|
|
||||||
* @param ti The tile to draw on
|
|
||||||
* @param dts Sprite and subsprites to draw
|
|
||||||
* @param to The transparancy bit that toggles drawing of these sprites
|
|
||||||
* @param total_offset Sprite-Offset between the current railtype and normal rail
|
|
||||||
* @param relocation Sprite-Offset for NewGRF defined stations
|
|
||||||
* @param default_palette The default recolour sprite to use (typically company colour)
|
|
||||||
*/
|
|
||||||
void DrawStationTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 relocation, SpriteID default_palette)
|
|
||||||
{
|
|
||||||
const DrawTileSeqStruct *dtss;
|
|
||||||
foreach_draw_tile_seq(dtss, dts->seq) {
|
|
||||||
SpriteID image = dtss->image.sprite;
|
|
||||||
|
|
||||||
/* Stop drawing sprite sequence once we meet a sprite that doesn't have to be opaque */
|
|
||||||
if (IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE)) return;
|
|
||||||
|
|
||||||
if (relocation == 0 || HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) {
|
|
||||||
image += total_offset;
|
|
||||||
} else {
|
|
||||||
image += relocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
SpriteID pal = SpriteLayoutPaletteTransform(image, dtss->image.pal, default_palette);
|
|
||||||
|
|
||||||
if ((byte)dtss->delta_z != 0x80) {
|
|
||||||
AddSortableSpriteToDraw(
|
|
||||||
image, pal,
|
|
||||||
ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
|
||||||
dtss->size_x, dtss->size_y,
|
|
||||||
dtss->size_z, ti->z + dtss->delta_z,
|
|
||||||
!HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
/* For stations and original spritelayouts delta_x and delta_y are signed */
|
|
||||||
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
|
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include "rail_type.h"
|
#include "rail_type.h"
|
||||||
#include "road_type.h"
|
#include "road_type.h"
|
||||||
#include "cargo_type.h"
|
#include "cargo_type.h"
|
||||||
#include "transparency.h"
|
|
||||||
#include "company_type.h"
|
#include "company_type.h"
|
||||||
|
|
||||||
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
|
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius);
|
||||||
|
@ -35,8 +34,6 @@ void UpdateStationAcceptance(Station *st, bool show_msg);
|
||||||
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
|
const DrawTileSprites *GetStationTileLayout(StationType st, byte gfx);
|
||||||
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
|
void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image);
|
||||||
|
|
||||||
void DrawStationTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 relocation, SpriteID default_palette);
|
|
||||||
|
|
||||||
bool HasStationInUse(StationID station, CompanyID company);
|
bool HasStationInUse(StationID station, CompanyID company);
|
||||||
|
|
||||||
RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type);
|
RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type);
|
||||||
|
|
Loading…
Reference in New Issue