summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-12-08 18:13:29 +0000
committerrubidium <rubidium@openttd.org>2011-12-08 18:13:29 +0000
commit2ccbd2a6f5d0e3b9000122fe1845482241334f41 (patch)
treed8a346dc40e1f7f85376c413a0c12065e277ae49 /src/gfx.cpp
parent9e8b76650a084bb26b32113317933217b1d99e42 (diff)
downloadopenttd-2ccbd2a6f5d0e3b9000122fe1845482241334f41.tar.xz
(svn r23446) -Codechange: move _cur_palette and it's related first/count dirty variables into a single structure
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index b840fed3e..0cbead9af 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -44,10 +44,7 @@ bool _exit_game;
GameMode _game_mode;
SwitchMode _switch_mode; ///< The next mainloop command.
PauseModeByte _pause_mode;
-int _pal_first_dirty;
-int _pal_count_dirty;
-
-Colour _cur_palette[256];
+Palette _cur_palette;
static int _max_char_height; ///< Cache of the height of the largest font
static int _max_char_width; ///< Cache of the width of the largest font
@@ -1401,11 +1398,8 @@ void DoPaletteAnimations();
void GfxInitPalettes()
{
- memcpy(_cur_palette, _palette, sizeof(_cur_palette));
-
+ memcpy(&_cur_palette, &_palette, sizeof(_cur_palette));
DoPaletteAnimations();
- _pal_first_dirty = 0;
- _pal_count_dirty = 256;
}
#define EXTR(p, q) (((uint16)(palette_animation_counter * (p)) * (q)) >> 16)
@@ -1429,7 +1423,7 @@ void DoPaletteAnimations()
palette_animation_counter = 0;
}
- Colour *palette_pos = &_cur_palette[PALETTE_ANIM_START]; // Points to where animations are taking place on the palette
+ Colour *palette_pos = &_cur_palette.palette[PALETTE_ANIM_START]; // Points to where animations are taking place on the palette
/* Makes a copy of the current anmation palette in old_val,
* so the work on the current palette could be compared, see if there has been any changes */
memcpy(old_val, palette_pos, sizeof(old_val));
@@ -1513,10 +1507,10 @@ void DoPaletteAnimations()
if (blitter != NULL && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
palette_animation_counter = old_tc;
} else {
- if (memcmp(old_val, &_cur_palette[PALETTE_ANIM_START], sizeof(old_val)) != 0) {
+ if (memcmp(old_val, &_cur_palette.palette[PALETTE_ANIM_START], sizeof(old_val)) != 0 && _cur_palette.count_dirty == 0) {
/* Did we changed anything on the palette? Seems so. Mark it as dirty */
- _pal_first_dirty = PALETTE_ANIM_START;
- _pal_count_dirty = PALETTE_ANIM_SIZE;
+ _cur_palette.first_dirty = PALETTE_ANIM_START;
+ _cur_palette.count_dirty = PALETTE_ANIM_SIZE;
}
}
}