summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-02-04 15:42:38 +0000
committerrubidium <rubidium@openttd.org>2010-02-04 15:42:38 +0000
commitfbb9b4760a7b85867817b4a089aeca0506bdb8be (patch)
tree57d0e9ca840e665c130f10074f15e778d0bec9b4
parent09730847eca596eae871deff4e539b345494e8a4 (diff)
downloadopenttd-fbb9b4760a7b85867817b4a089aeca0506bdb8be.tar.xz
(svn r19005) -Codechange: make animated cursors have a bit set instead of using negative numbers that are passed as uints, then cast again to be compared as ints before being inverted to be actually used. Also fixes a couple of 'integer conversion resulted in truncation' warnings ICC spewed.
-rw-r--r--src/table/sprites.h15
-rw-r--r--src/viewport.cpp4
2 files changed, 10 insertions, 9 deletions
diff --git a/src/table/sprites.h b/src/table/sprites.h
index 0a12742e3..29f0a7361 100644
--- a/src/table/sprites.h
+++ b/src/table/sprites.h
@@ -1396,13 +1396,14 @@ static const CursorID SPR_CURSOR_CLONE_SHIP = SPR_OPENTTD_BASE + 112;
static const CursorID SPR_CURSOR_CLONE_AIRPLANE = SPR_OPENTTD_BASE + 113;
/** Animation macro in table/animcursors.h (_animcursors[]) */
-enum AnimCursors {
- ANIMCURSOR_DEMOLISH = -1, ///< 704 - 707 - demolish dynamite
- ANIMCURSOR_LOWERLAND = -2, ///< 699 - 701 - lower land tool
- ANIMCURSOR_RAISELAND = -3, ///< 696 - 698 - raise land tool
- ANIMCURSOR_PICKSTATION = -4, ///< 716 - 718 - goto-order icon
- ANIMCURSOR_BUILDSIGNALS = -5, ///< 1292 - 1293 - build signal
-};
+
+/** Flag for saying a cursor sprite is an animated cursor. */
+static const CursorID ANIMCURSOR_FLAG = 1U << 31;
+static const CursorID ANIMCURSOR_DEMOLISH = ANIMCURSOR_FLAG | 0; ///< 704 - 707 - demolish dynamite
+static const CursorID ANIMCURSOR_LOWERLAND = ANIMCURSOR_FLAG | 1; ///< 699 - 701 - lower land tool
+static const CursorID ANIMCURSOR_RAISELAND = ANIMCURSOR_FLAG | 2; ///< 696 - 698 - raise land tool
+static const CursorID ANIMCURSOR_PICKSTATION = ANIMCURSOR_FLAG | 3; ///< 716 - 718 - goto-order icon
+static const CursorID ANIMCURSOR_BUILDSIGNALS = ANIMCURSOR_FLAG | 4; ///< 1292 - 1293 - build signal
/**
* Bitmask setup. For the graphics system, 32 bits are used to define
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 4fe1553bb..c9b674605 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2714,8 +2714,8 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC
if (mode == HT_SPECIAL) // special tools, like tunnels or docks start with presizing mode
VpStartPreSizing();
- if ((int)icon < 0) {
- SetAnimatedMouseCursor(_animcursors[~icon]);
+ if ((icon & ANIMCURSOR_FLAG) != 0) {
+ SetAnimatedMouseCursor(_animcursors[icon & ~ANIMCURSOR_FLAG]);
} else {
SetMouseCursor(icon, pal);
}