Files
@ r24256:f327b1e5e543
Branch filter:
Location: cpp/openttd-patchpack/source/src/sprite.cpp - annotation
r24256:f327b1e5e543
5.0 KiB
text/x-c
Fix: Restore compression of pdb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14277:5e0779a82f30 r14277:5e0779a82f30 r18462:a1ba75a7f741 r14275:c027409d8afb r21383:942c32fb8b0e r21383:942c32fb8b0e r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r19944:25a78576fb5e r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14284:8fe3cab84763 r14275:c027409d8afb r14309:f445232b17f6 r14275:c027409d8afb r14392:cedf8b528183 r14275:c027409d8afb r17728:6a6e98f25cac r14275:c027409d8afb r14275:c027409d8afb r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r14275:c027409d8afb r14284:8fe3cab84763 r17907:56fdc184ce8b r17907:56fdc184ce8b r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r14284:8fe3cab84763 r14281:b6400ec20242 r17728:6a6e98f25cac r14275:c027409d8afb r17728:6a6e98f25cac r14275:c027409d8afb r17350:ee624c6795a6 r14392:cedf8b528183 r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14284:8fe3cab84763 r14284:8fe3cab84763 r14392:cedf8b528183 r14392:cedf8b528183 r14392:cedf8b528183 r14392:cedf8b528183 r14392:cedf8b528183 r14392:cedf8b528183 r14392:cedf8b528183 r14392:cedf8b528183 r23607:36c15679007d r14392:cedf8b528183 r14275:c027409d8afb r14275:c027409d8afb r14275:c027409d8afb r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14284:8fe3cab84763 r14277:5e0779a82f30 r14309:f445232b17f6 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 r17728:6a6e98f25cac r14277:5e0779a82f30 r14277:5e0779a82f30 r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r14284:8fe3cab84763 r14284:8fe3cab84763 r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r17728:6a6e98f25cac r14284:8fe3cab84763 r14281:b6400ec20242 r17728:6a6e98f25cac r14277:5e0779a82f30 r17728:6a6e98f25cac r14277:5e0779a82f30 r17350:ee624c6795a6 r14277:5e0779a82f30 r21979:8f441a1deb2a r14277:5e0779a82f30 r14277:5e0779a82f30 r21979:8f441a1deb2a r21979:8f441a1deb2a r14277:5e0779a82f30 r14284:8fe3cab84763 r14284:8fe3cab84763 r21979:8f441a1deb2a r14277:5e0779a82f30 r14277:5e0779a82f30 r14277:5e0779a82f30 | /*
* 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 "viewport_func.h"
#include "landscape.h"
#include "spritecache.h"
#include "zoom_func.h"
#include "safeguards.h"
/**
* Draws a tile sprite sequence.
* @param ti The tile to draw on
* @param dts Sprite and subsprites to draw
* @param to The transparency 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)
* @param child_offset_is_unsigned Whether child sprite offsets are interpreted signed or unsigned
*/
void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
{
bool parent_sprite_encountered = false;
const DrawTileSeqStruct *dtss;
bool skip_childs = false;
foreach_draw_tile_seq(dtss, dts->seq) {
SpriteID image = dtss->image.sprite;
PaletteID pal = dtss->image.pal;
if (skip_childs) {
if (!dtss->IsParentSprite()) continue;
skip_childs = false;
}
/* TTD sprite 0 means no sprite */
if ((GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) ||
(IsInvisibilitySet(to) && !HasBit(image, SPRITE_MODIFIER_OPAQUE))) {
skip_childs = dtss->IsParentSprite();
continue;
}
image += (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? newgrf_offset : orig_offset);
if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += newgrf_offset;
pal = SpriteLayoutPaletteTransform(image, pal, default_palette);
if (dtss->IsParentSprite()) {
parent_sprite_encountered = true;
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 {
int offs_x = child_offset_is_unsigned ? (uint8)dtss->delta_x : dtss->delta_x;
int offs_y = child_offset_is_unsigned ? (uint8)dtss->delta_y : dtss->delta_y;
bool transparent = !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to);
if (parent_sprite_encountered) {
AddChildSpriteScreen(image, pal, offs_x, offs_y, transparent);
} else {
if (transparent) {
SetBit(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
}
DrawGroundSprite(image, pal, nullptr, offs_x, offs_y);
}
}
}
}
/**
* Draws a tile sprite sequence in the GUI
* @param x X position to draw to
* @param y Y position to draw to
* @param dts Sprite and subsprites to draw
* @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)
* @param child_offset_is_unsigned Whether child sprite offsets are interpreted signed or unsigned
*/
void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
{
const DrawTileSeqStruct *dtss;
Point child_offset = {0, 0};
bool skip_childs = false;
foreach_draw_tile_seq(dtss, dts->seq) {
SpriteID image = dtss->image.sprite;
PaletteID pal = dtss->image.pal;
if (skip_childs) {
if (!dtss->IsParentSprite()) continue;
skip_childs = false;
}
/* TTD sprite 0 means no sprite */
if (GB(image, 0, SPRITE_WIDTH) == 0 && !HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
skip_childs = dtss->IsParentSprite();
continue;
}
image += (HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? newgrf_offset : orig_offset);
if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += newgrf_offset;
pal = SpriteLayoutPaletteTransform(image, pal, default_palette);
if (dtss->IsParentSprite()) {
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
DrawSprite(image, pal, x + UnScaleGUI(pt.x), y + UnScaleGUI(pt.y));
const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL);
child_offset.x = UnScaleGUI(pt.x + spr->x_offs);
child_offset.y = UnScaleGUI(pt.y + spr->y_offs);
} else {
int offs_x = child_offset_is_unsigned ? (uint8)dtss->delta_x : dtss->delta_x;
int offs_y = child_offset_is_unsigned ? (uint8)dtss->delta_y : dtss->delta_y;
DrawSprite(image, pal, x + child_offset.x + ScaleGUITrad(offs_x), y + child_offset.y + ScaleGUITrad(offs_y));
}
}
}
|