summaryrefslogtreecommitdiff
path: root/src/texteff.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-12-25 23:22:41 +0000
committersmatz <smatz@openttd.org>2009-12-25 23:22:41 +0000
commit9cefcdab827b5bc6a3931054b5d1758193ebe600 (patch)
treec257c5ccc20edb90a335c70a5471617f2a81f373 /src/texteff.cpp
parente6d6704f32ee5cd7179a75d4808a72e9c2ea9622 (diff)
downloadopenttd-9cefcdab827b5bc6a3931054b5d1758193ebe600.tar.xz
(svn r18636) -Codechange: make TextEffect::duration a value in ticks instead of ticks * 8
Diffstat (limited to 'src/texteff.cpp')
-rw-r--r--src/texteff.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/texteff.cpp b/src/texteff.cpp
index caee473cd..bc742924f 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -23,9 +23,9 @@
/** Container for all information about a text effect */
struct TextEffect : public ViewportSign{
- StringID string_id; ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
- uint16 duration; ///< How long the text effect should stay
uint64 params_1; ///< DParam parameter
+ StringID string_id; ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
+ uint8 duration; ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING)
TextEffectMode mode; ///< Type of text effect
/** Reset the text effect */
@@ -40,7 +40,7 @@ struct TextEffect : public ViewportSign{
static SmallVector<struct TextEffect, 32> _text_effects; ///< Text effects are stored there
/* Text Effects */
-TextEffectID AddTextEffect(StringID msg, int center, int y, uint16 duration, TextEffectMode mode)
+TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode)
{
if (_game_mode == GM_MENU) return INVALID_TE_ID;
@@ -80,25 +80,21 @@ void RemoveTextEffect(TextEffectID te_id)
_text_effects[te_id].Reset();
}
-static void MoveTextEffect(TextEffect *te)
-{
- /* Never expire for duration of 0xFFFF */
- if (te->duration == 0xFFFF) return;
- if (te->duration < 8) {
- te->Reset();
- } else {
- te->duration -= 8;
- te->MarkDirty();
- te->top--;
- te->MarkDirty();
- }
-}
-
void MoveAllTextEffects()
{
const TextEffect *end = _text_effects.End();
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
- if (te->string_id != INVALID_STRING_ID && te->mode == TE_RISING) MoveTextEffect(te);
+ if (te->string_id == INVALID_STRING_ID) continue;
+ if (te->mode != TE_RISING) continue;
+
+ if (te->duration-- == 0) {
+ te->Reset();
+ continue;
+ }
+
+ te->MarkDirty();
+ te->top--;
+ te->MarkDirty();
}
}