mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-23 12:14:11 +01:00
Codechange: Use span instead of raw pointer for animated cursors. (#14575)
This allows the terminator entry to be removed.
This commit is contained in:
16
src/gfx.cpp
16
src/gfx.cpp
@@ -1659,15 +1659,15 @@ static void SetCursorSprite(CursorID cursor, PaletteID pal)
|
||||
|
||||
static void SwitchAnimatedCursor()
|
||||
{
|
||||
const AnimCursor *cur = _cursor.animate_cur;
|
||||
|
||||
if (cur == nullptr || cur->sprite == AnimCursor::LAST) cur = _cursor.animate_list;
|
||||
if (_cursor.animate_cur == std::end(_cursor.animate_list)) {
|
||||
_cursor.animate_cur = std::begin(_cursor.animate_list);
|
||||
}
|
||||
|
||||
assert(!_cursor.sprites.empty());
|
||||
SetCursorSprite(cur->sprite, _cursor.sprites[0].image.pal);
|
||||
SetCursorSprite(_cursor.animate_cur->sprite, _cursor.sprites[0].image.pal);
|
||||
|
||||
_cursor.animate_timeout = cur->display_time;
|
||||
_cursor.animate_cur = cur + 1;
|
||||
_cursor.animate_timeout = _cursor.animate_cur->display_time;
|
||||
++_cursor.animate_cur;
|
||||
}
|
||||
|
||||
void CursorTick()
|
||||
@@ -1710,11 +1710,11 @@ void SetMouseCursor(CursorID sprite, PaletteID pal)
|
||||
* @param table Array of animation states.
|
||||
* @see SetMouseCursor
|
||||
*/
|
||||
void SetAnimatedMouseCursor(const AnimCursor *table)
|
||||
void SetAnimatedMouseCursor(std::span<const AnimCursor> table)
|
||||
{
|
||||
assert(!_cursor.sprites.empty());
|
||||
_cursor.animate_list = table;
|
||||
_cursor.animate_cur = nullptr;
|
||||
_cursor.animate_cur = std::end(table);
|
||||
_cursor.sprites[0].image.pal = PAL_NONE;
|
||||
SwitchAnimatedCursor();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user