tron@2186: /* $Id$ */ tron@2186: glx@9574: /** @file texteff.cpp */ glx@9574: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" rubidium@9723: #include "tile_cmd.h" rubidium@9599: #include "landscape.h" rubidium@9723: #include "gfx_func.h" truelight@0: #include "saveload.h" truelight@543: #include "console.h" tron@2153: #include "variables.h" rubidium@9628: #include "blitter/factory.hpp" glx@9629: #include "texteff.hpp" rubidium@9631: #include "video/video_driver.hpp" rubidium@9722: #include "transparency.h" rubidium@9723: #include "strings_func.h" rubidium@9723: #include "core/alloc_func.hpp" rubidium@9723: #include "date_func.h" rubidium@9723: #include "functions.h" rubidium@9723: #include "viewport_func.h" rubidium@9724: #include "settings_type.h" rubidium@9724: rubidium@9724: #include "table/sprites.h" rubidium@9724: rubidium@9724: #include /* va_list */ truelight@0: rubidium@5679: enum { Darkvater@6541: MAX_TEXTMESSAGE_LENGTH = 200, glx@9629: INIT_NUM_TEXT_MESSAGES = 20, rubidium@5679: MAX_CHAT_MESSAGES = 10, rubidium@5679: }; rubidium@5679: rubidium@6574: struct TextEffect { truelight@0: StringID string_id; tron@849: int32 x; tron@849: int32 y; tron@849: int32 right; tron@849: int32 bottom; truelight@0: uint16 duration; glx@9629: uint64 params_1; glx@9629: uint64 params_2; glx@9629: TextEffectMode mode; rubidium@6574: }; truelight@0: truelight@543: rubidium@9701: struct ChatMessage { truelight@543: char message[MAX_TEXTMESSAGE_LENGTH]; truelight@543: uint16 color; truelight@4363: Date end_date; rubidium@6574: }; truelight@543: rubidium@9701: /* used for text effects */ glx@9629: static TextEffect *_text_effect_list = NULL; rubidium@9701: static uint16 _num_text_effects = INIT_NUM_TEXT_MESSAGES; truelight@0: rubidium@9701: /* used for chat window */ rubidium@9701: static ChatMessage _chatmsg_list[MAX_CHAT_MESSAGES]; rubidium@9701: static bool _chatmessage_dirty = false; rubidium@9701: static bool _chatmessage_visible = false; truelight@543: Darkvater@4956: /* The chatbox grows from the bottom so the coordinates are pixels from Darkvater@4956: * the left and pixels from the bottom. The height is the maximum height */ rubidium@9723: static const PointDimension _chatmsg_box = {10, 30, 500, 150}; rubidium@9701: static uint8 _chatmessage_backup[150 * 500 * 6]; // (height * width) truelight@543: rubidium@9701: static inline uint GetChatMessageCount() Darkvater@4957: { Darkvater@4959: uint i; Darkvater@4957: Darkvater@4959: for (i = 0; i < MAX_CHAT_MESSAGES; i++) { rubidium@9701: if (_chatmsg_list[i].message[0] == '\0') break; Darkvater@4957: } Darkvater@4957: Darkvater@4957: return i; Darkvater@4957: } Darkvater@4957: Darkvater@4957: /* Add a text message to the 'chat window' to be shown Darkvater@4957: * @param color The colour this message is to be shown in Darkvater@4957: * @param duration The duration of the chat message in game-days Darkvater@4957: * @param message message itself in printf() style */ rubidium@9701: void CDECL AddChatMessage(uint16 color, uint8 duration, const char *message, ...) truelight@543: { tron@2455: char buf[MAX_TEXTMESSAGE_LENGTH]; Darkvater@4957: const char *bufp; truelight@543: va_list va; Darkvater@4957: uint msg_count; Darkvater@4957: uint16 lines; truelight@543: truelight@543: va_start(va, message); tron@2373: vsnprintf(buf, lengthof(buf), message, va); truelight@543: va_end(va); truelight@543: Darkvater@6541: Darkvater@6541: Utf8TrimString(buf, MAX_TEXTMESSAGE_LENGTH); Darkvater@6541: Darkvater@4957: /* Force linebreaks for strings that are too long */ rubidium@9701: lines = GB(FormatStringLinebreaks(buf, _chatmsg_box.width - 8), 0, 16) + 1; Darkvater@4957: if (lines >= MAX_CHAT_MESSAGES) return; truelight@543: rubidium@9701: msg_count = GetChatMessageCount(); Darkvater@4957: /* We want to add more chat messages than there is free space for, remove 'old' */ Darkvater@4957: if (lines > MAX_CHAT_MESSAGES - msg_count) { Darkvater@4957: int i = lines - (MAX_CHAT_MESSAGES - msg_count); rubidium@9701: memmove(&_chatmsg_list[0], &_chatmsg_list[i], sizeof(_chatmsg_list[0]) * (msg_count - i)); Darkvater@4957: msg_count = MAX_CHAT_MESSAGES - lines; truelight@543: } truelight@543: Darkvater@4957: for (bufp = buf; lines != 0; lines--) { rubidium@9701: ChatMessage *cmsg = &_chatmsg_list[msg_count++]; rubidium@9701: ttd_strlcpy(cmsg->message, bufp, sizeof(cmsg->message)); Darkvater@4957: Darkvater@4957: /* The default colour for a message is player colour. Replace this with Darkvater@4957: * white for any additional lines */ rubidium@9701: cmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR; rubidium@9701: cmsg->end_date = _date + duration; Darkvater@4957: Darkvater@4957: bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string Darkvater@4957: } truelight@543: rubidium@9701: _chatmessage_dirty = true; truelight@543: } truelight@543: rubidium@9701: void InitChatMessage() truelight@543: { tron@2639: uint i; tron@2639: tron@2639: for (i = 0; i < MAX_CHAT_MESSAGES; i++) { rubidium@9701: _chatmsg_list[i].message[0] = '\0'; tron@2639: } truelight@543: } truelight@543: rubidium@9701: /** Hide the chatbox */ rubidium@9701: void UndrawChatMessage() truelight@543: { rubidium@9701: if (_chatmessage_visible) { rubidium@9628: Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); rubidium@5679: /* Sometimes we also need to hide the cursor rubidium@5679: * This is because both textmessage and the cursor take a shot of the rubidium@5679: * screen before drawing. rubidium@5679: * Now the textmessage takes his shot and paints his data before the cursor rubidium@5679: * does, so in the shot of the cursor is the screen-data of the textmessage rubidium@5679: * included when the cursor hangs somewhere over the textmessage. To rubidium@5679: * avoid wrong repaints, we undraw the cursor in that case, and everything rubidium@5679: * looks nicely ;) rubidium@5679: * (and now hope this story above makes sense to you ;)) rubidium@5679: */ truelight@543: truelight@543: if (_cursor.visible) { rubidium@9701: if (_cursor.draw_pos.x + _cursor.draw_size.x >= _chatmsg_box.x && rubidium@9701: _cursor.draw_pos.x <= _chatmsg_box.x + _chatmsg_box.width && rubidium@9701: _cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _chatmsg_box.y - _chatmsg_box.height && rubidium@9701: _cursor.draw_pos.y <= _screen.height - _chatmsg_box.y) { truelight@543: UndrawMouseCursor(); truelight@543: } truelight@543: } truelight@543: rubidium@9701: int x = _chatmsg_box.x; rubidium@9701: int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height; rubidium@9701: int width = _chatmsg_box.width; rubidium@9701: int height = _chatmsg_box.height; truelight@9517: if (y < 0) { rubidium@9701: height = max(height + y, min(_chatmsg_box.height, _screen.height)); truelight@9517: y = 0; truelight@9517: } truelight@9517: if (x + width >= _screen.width) { truelight@9517: width = _screen.width - x; truelight@9517: } truelight@9545: if (width <= 0 || height <= 0) return; truelight@9517: rubidium@9701: _chatmessage_visible = false; rubidium@5679: /* Put our 'shot' back to the screen */ rubidium@9701: blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); rubidium@5679: /* And make sure it is updated next time */ rubidium@9631: _video_driver->MakeDirty(x, y, width, height); truelight@543: rubidium@9701: _chatmessage_dirty = true; truelight@543: } truelight@543: } truelight@543: glx@9574: /** Check if a message is expired every day */ rubidium@9701: void ChatMessageDailyLoop() truelight@543: { tron@2639: uint i; tron@2639: truelight@1595: for (i = 0; i < MAX_CHAT_MESSAGES; i++) { rubidium@9701: ChatMessage *cmsg = &_chatmsg_list[i]; rubidium@9701: if (cmsg->message[0] == '\0') continue; truelight@1595: Darkvater@4957: /* Message has expired, remove from the list */ rubidium@9701: if (cmsg->end_date < _date) { truelight@1595: /* Move the remaining messages over the current message */ rubidium@9701: if (i != MAX_CHAT_MESSAGES - 1) memmove(cmsg, cmsg + 1, sizeof(*cmsg) * (MAX_CHAT_MESSAGES - i - 1)); truelight@1595: truelight@1595: /* Mark the last item as empty */ rubidium@9701: _chatmsg_list[MAX_CHAT_MESSAGES - 1].message[0] = '\0'; rubidium@9701: _chatmessage_dirty = true; truelight@1595: truelight@1595: /* Go one item back, because we moved the array 1 to the left */ truelight@543: i--; truelight@543: } truelight@543: } truelight@543: } truelight@543: rubidium@9701: /** Draw the chat message-box */ rubidium@9701: void DrawChatMessage() truelight@543: { rubidium@9628: Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); rubidium@9701: if (!_chatmessage_dirty) return; truelight@543: rubidium@5679: /* First undraw if needed */ rubidium@9701: UndrawChatMessage(); truelight@543: Darkvater@4959: if (_iconsole_mode == ICONSOLE_FULL) return; truelight@543: truelight@1595: /* Check if we have anything to draw at all */ rubidium@9701: uint count = GetChatMessageCount(); Darkvater@4960: if (count == 0) return; truelight@543: rubidium@9701: int x = _chatmsg_box.x; rubidium@9701: int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height; rubidium@9701: int width = _chatmsg_box.width; rubidium@9701: int height = _chatmsg_box.height; truelight@9517: if (y < 0) { rubidium@9701: height = max(height + y, min(_chatmsg_box.height, _screen.height)); truelight@9517: y = 0; truelight@9517: } truelight@9517: if (x + width >= _screen.width) { truelight@9517: width = _screen.width - x; truelight@9517: } truelight@9545: if (width <= 0 || height <= 0) return; truelight@9545: rubidium@9701: assert(blitter->BufferSize(width, height) < (int)sizeof(_chatmessage_backup)); glx@9629: rubidium@5679: /* Make a copy of the screen as it is before painting (for undraw) */ rubidium@9701: blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); truelight@543: Darkvater@4960: _cur_dpi = &_screen; // switch to _screen painting truelight@543: rubidium@9701: /* Paint a half-transparent box behind the chat messages */ Darkvater@4960: GfxFillRect( rubidium@9701: _chatmsg_box.x, rubidium@9701: _screen.height - _chatmsg_box.y - count * 13 - 2, rubidium@9701: _chatmsg_box.x + _chatmsg_box.width - 1, rubidium@9701: _screen.height - _chatmsg_box.y - 2, peter1138@5919: PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE) // black, but with some alpha for background Darkvater@4960: ); truelight@1595: rubidium@9701: /* Paint the chat messages starting with the lowest at the bottom */ truelight@9517: for (uint y = 13; count-- != 0; y += 13) { rubidium@9701: DoDrawString(_chatmsg_list[count].message, _chatmsg_box.x + 3, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].color); rubidium@9601: } truelight@543: rubidium@5679: /* Make sure the data is updated next flush */ rubidium@9631: _video_driver->MakeDirty(x, y, width, height); truelight@543: rubidium@9701: _chatmessage_visible = true; rubidium@9701: _chatmessage_dirty = false; truelight@543: } truelight@543: rubidium@9703: /* Text Effects */ rubidium@9703: /** rubidium@9703: * Mark the area of the text effect as dirty. rubidium@9703: * rubidium@9703: * This function marks the area of a text effect as dirty for repaint. rubidium@9703: * rubidium@9703: * @param te The TextEffect to mark the area dirty rubidium@9703: * @ingroup dirty rubidium@9703: */ truelight@0: static void MarkTextEffectAreaDirty(TextEffect *te) truelight@0: { rubidium@9703: /* Width and height of the text effect are doubled, so they are correct in both zoom out levels 1x and 2x. */ truelight@0: MarkAllViewportsDirty( truelight@0: te->x, truelight@0: te->y - 1, truelight@0: (te->right - te->x)*2 + te->x + 1, truelight@0: (te->bottom - (te->y - 1)) * 2 + (te->y - 1) + 1 truelight@0: ); truelight@0: } truelight@0: glx@9629: TextEffectID AddTextEffect(StringID msg, int x, int y, uint16 duration, TextEffectMode mode) truelight@0: { truelight@0: TextEffect *te; truelight@0: int w; truelight@0: char buffer[100]; glx@9629: TextEffectID i; truelight@0: glx@9629: if (_game_mode == GM_MENU) return INVALID_TE_ID; truelight@193: glx@9629: /* Look for a free spot in the text effect array */ glx@9629: for (i = 0; i < _num_text_effects; i++) { glx@9629: if (_text_effect_list[i].string_id == INVALID_STRING_ID) break; truelight@0: } truelight@0: glx@9629: /* If there is none found, we grow the array */ glx@9629: if (i == _num_text_effects) { glx@9629: _num_text_effects += 25; rubidium@9723: _text_effect_list = ReallocT(_text_effect_list, _num_text_effects); glx@9629: for (; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID; glx@9629: i = _num_text_effects - 1; glx@9629: } glx@9629: glx@9629: te = &_text_effect_list[i]; glx@9629: glx@9629: /* Start defining this object */ truelight@0: te->string_id = msg; truelight@0: te->duration = duration; truelight@0: te->y = y - 5; truelight@0: te->bottom = y + 5; tron@534: te->params_1 = GetDParam(0); tron@534: te->params_2 = GetDParam(4); glx@9629: te->mode = mode; truelight@0: Darkvater@4912: GetString(buffer, msg, lastof(buffer)); Darkvater@4609: w = GetStringBoundingBox(buffer).width; truelight@0: truelight@0: te->x = x - (w >> 1); truelight@0: te->right = x + (w >> 1) - 1; truelight@0: MarkTextEffectAreaDirty(te); glx@9629: glx@9629: return i; glx@9629: } glx@9629: glx@9629: void UpdateTextEffect(TextEffectID te_id, StringID msg) glx@9629: { glx@9629: assert(te_id < _num_text_effects); glx@9629: TextEffect *te; glx@9629: glx@9629: /* Update details */ glx@9629: te = &_text_effect_list[te_id]; glx@9629: te->string_id = msg; glx@9629: te->params_1 = GetDParam(0); glx@9629: te->params_2 = GetDParam(4); glx@9629: rubidium@9703: /* Update width of text effect */ rubidium@9703: char buffer[100]; rubidium@9703: GetString(buffer, msg, lastof(buffer)); rubidium@9703: int w = GetStringBoundingBox(buffer).width; rubidium@9703: rubidium@9703: /* Only allow to make it broader, so it completely covers the old text. That avoids remnants of the old text. */ rubidium@9703: int right_new = te->x + w; rubidium@9703: if (te->right < right_new) te->right = right_new; rubidium@9703: glx@9629: MarkTextEffectAreaDirty(te); glx@9629: } glx@9629: glx@9629: void RemoveTextEffect(TextEffectID te_id) glx@9629: { glx@9629: assert(te_id < _num_text_effects); glx@9629: TextEffect *te; glx@9629: glx@9629: te = &_text_effect_list[te_id]; glx@9629: MarkTextEffectAreaDirty(te); glx@9629: te->string_id = INVALID_STRING_ID; truelight@0: } truelight@0: truelight@0: static void MoveTextEffect(TextEffect *te) truelight@0: { glx@9629: /* Never expire for duration of 0xFFFF */ glx@9629: if (te->duration == 0xFFFF) return; truelight@0: if (te->duration < 8) { tron@2470: te->string_id = INVALID_STRING_ID; truelight@0: } else { tron@2549: te->duration -= 8; truelight@0: te->y--; truelight@0: te->bottom--; truelight@0: } truelight@0: MarkTextEffectAreaDirty(te); truelight@0: } truelight@0: rubidium@6573: void MoveAllTextEffects() truelight@0: { glx@9629: for (TextEffectID i = 0; i < _num_text_effects; i++) { glx@9629: TextEffect *te = &_text_effect_list[i]; glx@9629: if (te->string_id != INVALID_STRING_ID && te->mode == TE_RISING) MoveTextEffect(te); truelight@0: } truelight@0: } truelight@0: rubidium@6573: void InitTextEffects() truelight@0: { glx@9629: if (_text_effect_list == NULL) _text_effect_list = MallocT(_num_text_effects); truelight@0: glx@9629: for (TextEffectID i = 0; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID; truelight@0: } truelight@0: truelight@0: void DrawTextEffects(DrawPixelInfo *dpi) truelight@0: { tron@4469: switch (dpi->zoom) { glx@9624: case ZOOM_LVL_NORMAL: glx@9629: for (TextEffectID i = 0; i < _num_text_effects; i++) { glx@9629: TextEffect *te = &_text_effect_list[i]; tron@4469: if (te->string_id != INVALID_STRING_ID && tron@4469: dpi->left <= te->right && tron@4469: dpi->top <= te->bottom && tron@4469: dpi->left + dpi->width > te->x && tron@4469: dpi->top + dpi->height > te->y) { rubidium@9722: if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) { glx@9629: AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2); glx@9629: } tron@4469: } tron@4469: } tron@4469: break; truelight@0: glx@9624: case ZOOM_LVL_OUT_2X: glx@9629: for (TextEffectID i = 0; i < _num_text_effects; i++) { glx@9629: TextEffect *te = &_text_effect_list[i]; tron@4469: if (te->string_id != INVALID_STRING_ID && tron@4469: dpi->left <= te->right * 2 - te->x && tron@4469: dpi->top <= te->bottom * 2 - te->y && tron@4469: dpi->left + dpi->width > te->x && tron@4469: dpi->top + dpi->height > te->y) { rubidium@9722: if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) { glx@9629: AddStringToDraw(te->x, te->y, (StringID)(te->string_id - 1), te->params_1, te->params_2); glx@9629: } tron@4469: } tron@4469: } tron@4469: break; glx@9624: glx@9624: case ZOOM_LVL_OUT_4X: glx@9624: case ZOOM_LVL_OUT_8X: glx@9624: break; glx@9624: glx@9624: default: NOT_REACHED(); truelight@0: } truelight@0: } truelight@0: truelight@9718: /** The table/list with animated tiles. */ truelight@9718: TileIndex *_animated_tile_list = NULL; truelight@9718: /** The number of animated tiles in the current state. */ truelight@9718: uint _animated_tile_count = 0; truelight@9718: /** The number of slots for animated tiles allocated currently. */ truelight@9718: static uint _animated_tile_allocated = 0; truelight@9718: truelight@9718: /** truelight@9718: * Removes the given tile from the animated tile table. truelight@9718: * @param tile the tile to remove truelight@9718: */ tron@1977: void DeleteAnimatedTile(TileIndex tile) truelight@0: { truelight@9718: for (TileIndex *ti = _animated_tile_list; ti < _animated_tile_list + _animated_tile_count; ti++) { tron@1977: if (tile == *ti) { truelight@9718: /* Remove the hole truelight@9718: * The order of the remaining elements must stay the same, otherwise the animation loop truelight@9718: * may miss a tile; that's why we must use memmove instead of just moving the last element. truelight@9718: */ truelight@9718: memmove(ti, ti + 1, (_animated_tile_list + _animated_tile_count - (ti + 1)) * sizeof(*ti)); truelight@9718: _animated_tile_count--; truelight@0: MarkTileDirtyByTile(tile); truelight@0: return; truelight@193: } truelight@0: } truelight@0: } truelight@0: truelight@9718: /** truelight@9718: * Add the given tile to the animated tile table (if it does not exist truelight@9718: * on that table yet). Also increases the size of the table if necessary. truelight@9718: * @param tile the tile to make animated truelight@9718: */ truelight@9718: void AddAnimatedTile(TileIndex tile) truelight@0: { truelight@9718: MarkTileDirtyByTile(tile); truelight@0: truelight@9718: for (const TileIndex *ti = _animated_tile_list; ti < _animated_tile_list + _animated_tile_count; ti++) { truelight@9718: if (tile == *ti) return; truelight@193: } truelight@0: truelight@9718: /* Table not large enough, so make it larger */ truelight@9718: if (_animated_tile_count == _animated_tile_allocated) { truelight@9718: _animated_tile_allocated *= 2; truelight@9718: _animated_tile_list = ReallocT(_animated_tile_list, _animated_tile_allocated); truelight@9718: } truelight@9718: truelight@9718: _animated_tile_list[_animated_tile_count] = tile; truelight@9718: _animated_tile_count++; truelight@0: } truelight@0: truelight@9718: /** truelight@9718: * Animate all tiles in the animated tile list, i.e.\ call AnimateTile on them. truelight@9718: */ rubidium@6573: void AnimateAnimatedTiles() truelight@0: { truelight@9718: const TileIndex *ti = _animated_tile_list; truelight@9718: while (ti < _animated_tile_list + _animated_tile_count) { truelight@9718: const TileIndex curr = *ti; truelight@9718: AnimateTile(curr); truelight@9718: /* During the AnimateTile call, DeleteAnimatedTile could have been called, truelight@9718: * deleting an element we've already processed and pushing the rest one truelight@9718: * slot to the left. We can detect this by checking whether the index truelight@9718: * in the current slot has changed - if it has, an element has been deleted, truelight@9718: * and we should process the current slot again instead of going forward. truelight@9718: * NOTE: this will still break if more than one animated tile is being truelight@9718: * deleted during the same AnimateTile call, but no code seems to truelight@9718: * be doing this anyway. truelight@9718: */ truelight@9718: if (*ti == curr) ++ti; truelight@0: } truelight@0: } truelight@0: truelight@9718: /** truelight@9718: * Initialize all animated tile variables to some known begin point truelight@9718: */ rubidium@6573: void InitializeAnimatedTiles() truelight@0: { truelight@9718: _animated_tile_list = ReallocT(_animated_tile_list, 256); truelight@9718: _animated_tile_count = 0; truelight@9718: _animated_tile_allocated = 256; truelight@0: } truelight@0: truelight@9718: /** truelight@9718: * Save the ANIT chunk. truelight@9718: */ truelight@9718: static void Save_ANIT() truelight@0: { truelight@9718: SlSetLength(_animated_tile_count * sizeof(*_animated_tile_list)); truelight@9718: SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32); truelight@0: } truelight@0: truelight@9718: /** truelight@9718: * Load the ANIT chunk; the chunk containing the animated tiles. truelight@9718: */ truelight@9718: static void Load_ANIT() truelight@9718: { truelight@9718: /* Before version 80 we did NOT have a variable length animated tile table */ truelight@9718: if (CheckSavegameVersion(80)) { truelight@9718: /* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */ truelight@9718: SlArray(_animated_tile_list, 256, CheckSavegameVersion(6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32); truelight@0: truelight@9718: for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) { truelight@9718: if (_animated_tile_list[_animated_tile_count] == 0) break; truelight@9718: } truelight@9718: return; truelight@9718: } truelight@9718: truelight@9718: _animated_tile_count = SlGetFieldLength() / sizeof(*_animated_tile_list); truelight@9718: truelight@9718: /* Determine a nice rounded size for the amount of allocated tiles */ truelight@9718: _animated_tile_allocated = 256; truelight@9718: while (_animated_tile_allocated < _animated_tile_count) _animated_tile_allocated *= 2; truelight@9718: truelight@9718: _animated_tile_list = ReallocT(_animated_tile_list, _animated_tile_allocated); truelight@9718: SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32); truelight@9718: } truelight@9718: truelight@9718: /** truelight@9718: * "Definition" imported by the saveload code to be able to load and save truelight@9718: * the animated tile table. truelight@9718: */ rubidium@5838: extern const ChunkHandler _animated_tile_chunk_handlers[] = { truelight@9718: { 'ANIT', Save_ANIT, Load_ANIT, CH_RIFF | CH_LAST}, truelight@0: };