author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5668 | 36b39f4a9032 |
child 6215 | bbd141b026b5 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
4 |
#include "openttd.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2153
diff
changeset
|
5 |
#include "functions.h" |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
6 |
#include "macros.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1174
diff
changeset
|
7 |
#include "strings.h" |
0 | 8 |
#include "gfx.h" |
9 |
#include "viewport.h" |
|
10 |
#include "saveload.h" |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
11 |
#include "hal.h" |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
12 |
#include "console.h" |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
13 |
#include "string.h" |
2153
ecfc674410b4
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents:
2062
diff
changeset
|
14 |
#include "variables.h" |
2218
2132596a35c0
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
15 |
#include "table/sprites.h" |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
16 |
#include <stdarg.h> /* va_list */ |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
2685
diff
changeset
|
17 |
#include "date.h" |
0 | 18 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
19 |
enum { |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
20 |
MAX_TEXTMESSAGE_LENGTH = 150, |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
21 |
MAX_TEXT_MESSAGES = 30, |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
22 |
MAX_CHAT_MESSAGES = 10, |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
23 |
MAX_ANIMATED_TILES = 256, |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
24 |
}; |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
25 |
|
0 | 26 |
typedef struct TextEffect { |
27 |
StringID string_id; |
|
849
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
28 |
int32 x; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
29 |
int32 y; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
30 |
int32 right; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
31 |
int32 bottom; |
0 | 32 |
uint16 duration; |
33 |
uint32 params_1; |
|
34 |
uint32 params_2; |
|
35 |
} TextEffect; |
|
36 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
37 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
38 |
typedef struct TextMessage { |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
39 |
char message[MAX_TEXTMESSAGE_LENGTH]; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
40 |
uint16 color; |
4363
8a38cd70dab9
(svn r6078) -Fix: forgot one uint16 -> Date conversion. Tnx to #openttdcoop team for detecting and Rubidium for finding the cause.
truelight
parents:
4261
diff
changeset
|
41 |
Date end_date; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
42 |
} TextMessage; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
43 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
44 |
static TextEffect _text_effect_list[MAX_TEXT_MESSAGES]; |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
45 |
static TextMessage _textmsg_list[MAX_CHAT_MESSAGES]; |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
46 |
TileIndex _animated_tile_list[MAX_ANIMATED_TILES]; |
0 | 47 |
|
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
48 |
static bool _textmessage_dirty = false; |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2470
diff
changeset
|
49 |
static bool _textmessage_visible = false; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
50 |
|
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
51 |
/* The chatbox grows from the bottom so the coordinates are pixels from |
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
52 |
* the left and pixels from the bottom. The height is the maximum height */ |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
53 |
static const Oblong _textmsg_box = {10, 30, 500, 150}; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
54 |
static Pixel _textmessage_backup[150 * 500]; // (height * width) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
55 |
|
4958 | 56 |
extern void memcpy_pitch(void *dst, void *src, int w, int h, int srcpitch, int dstpitch); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
57 |
|
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
58 |
static inline uint GetTextMessageCount(void) |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
59 |
{ |
4959
9a25901ce3e6
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
60 |
uint i; |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
61 |
|
4959
9a25901ce3e6
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
62 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
63 |
if (_textmsg_list[i].message[0] == '\0') break; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
64 |
} |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
65 |
|
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
66 |
return i; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
67 |
} |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
68 |
|
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
69 |
/* Add a text message to the 'chat window' to be shown |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
70 |
* @param color The colour this message is to be shown in |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
71 |
* @param duration The duration of the chat message in game-days |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
72 |
* @param message message itself in printf() style */ |
1022
d5ec3467d2a4
(svn r1523) -Fix: somehow mousewheel was disabled on windows using SDL; reenabled again
darkvater
parents:
849
diff
changeset
|
73 |
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
74 |
{ |
2455 | 75 |
char buf[MAX_TEXTMESSAGE_LENGTH]; |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
76 |
const char *bufp; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
77 |
va_list va; |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
78 |
uint msg_count; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
79 |
uint16 lines; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
80 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
81 |
va_start(va, message); |
2373
e073ec69bf56
(svn r2899) -Fix: Several format string vulnerabilities and buffer overflows in the network code
tron
parents:
2295
diff
changeset
|
82 |
vsnprintf(buf, lengthof(buf), message, va); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
83 |
va_end(va); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
84 |
|
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
85 |
/* Force linebreaks for strings that are too long */ |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
86 |
lines = GB(FormatStringLinebreaks(buf, _textmsg_box.width - 8), 0, 16) + 1; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
87 |
if (lines >= MAX_CHAT_MESSAGES) return; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
88 |
|
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
89 |
msg_count = GetTextMessageCount(); |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
90 |
/* We want to add more chat messages than there is free space for, remove 'old' */ |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
91 |
if (lines > MAX_CHAT_MESSAGES - msg_count) { |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
92 |
int i = lines - (MAX_CHAT_MESSAGES - msg_count); |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
93 |
memmove(&_textmsg_list[0], &_textmsg_list[i], sizeof(_textmsg_list[0]) * (msg_count - i)); |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
94 |
msg_count = MAX_CHAT_MESSAGES - lines; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
95 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
96 |
|
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
97 |
for (bufp = buf; lines != 0; lines--) { |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
98 |
TextMessage *tmsg = &_textmsg_list[msg_count++]; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
99 |
ttd_strlcpy(tmsg->message, bufp, sizeof(tmsg->message)); |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
100 |
|
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
101 |
/* The default colour for a message is player colour. Replace this with |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
102 |
* white for any additional lines */ |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
103 |
tmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
104 |
tmsg->end_date = _date + duration; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
105 |
|
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
106 |
bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
107 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
108 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
109 |
_textmessage_dirty = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
110 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
111 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
112 |
void InitTextMessage(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
113 |
{ |
2639 | 114 |
uint i; |
115 |
||
116 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
|
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
117 |
_textmsg_list[i].message[0] = '\0'; |
2639 | 118 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
119 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
120 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
121 |
/* Hide the textbox */ |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
122 |
void UndrawTextMessage(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
123 |
{ |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
124 |
if (_textmessage_visible) { |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
125 |
/* Sometimes we also need to hide the cursor |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
126 |
* This is because both textmessage and the cursor take a shot of the |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
127 |
* screen before drawing. |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
128 |
* Now the textmessage takes his shot and paints his data before the cursor |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
129 |
* does, so in the shot of the cursor is the screen-data of the textmessage |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
130 |
* included when the cursor hangs somewhere over the textmessage. To |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
131 |
* avoid wrong repaints, we undraw the cursor in that case, and everything |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
132 |
* looks nicely ;) |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
133 |
* (and now hope this story above makes sense to you ;)) |
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
134 |
*/ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
135 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
136 |
if (_cursor.visible) { |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
137 |
if (_cursor.draw_pos.x + _cursor.draw_size.x >= _textmsg_box.x && |
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
138 |
_cursor.draw_pos.x <= _textmsg_box.x + _textmsg_box.width && |
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
139 |
_cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _textmsg_box.y - _textmsg_box.height && |
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
140 |
_cursor.draw_pos.y <= _screen.height - _textmsg_box.y) { |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
141 |
UndrawMouseCursor(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
142 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
143 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
144 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
145 |
_textmessage_visible = false; |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
146 |
/* Put our 'shot' back to the screen */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
147 |
memcpy_pitch( |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
148 |
_screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch, |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
149 |
_textmessage_backup, |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
150 |
_textmsg_box.width, _textmsg_box.height, _textmsg_box.width, _screen.pitch); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
151 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
152 |
/* And make sure it is updated next time */ |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
153 |
_video_driver->make_dirty(_textmsg_box.x, _screen.height - _textmsg_box.y - _textmsg_box.height, _textmsg_box.width, _textmsg_box.height); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
154 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
155 |
_textmessage_dirty = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
156 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
157 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
158 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
159 |
/* Check if a message is expired every day */ |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
160 |
void TextMessageDailyLoop(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
161 |
{ |
2639 | 162 |
uint i; |
163 |
||
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
164 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
165 |
TextMessage *tmsg = &_textmsg_list[i]; |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
166 |
if (tmsg->message[0] == '\0') continue; |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
167 |
|
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
168 |
/* Message has expired, remove from the list */ |
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
169 |
if (tmsg->end_date < _date) { |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
170 |
/* Move the remaining messages over the current message */ |
4957
44b747809879
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
171 |
if (i != MAX_CHAT_MESSAGES - 1) memmove(tmsg, tmsg + 1, sizeof(*tmsg) * (MAX_CHAT_MESSAGES - i - 1)); |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
172 |
|
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
173 |
/* Mark the last item as empty */ |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
174 |
_textmsg_list[MAX_CHAT_MESSAGES - 1].message[0] = '\0'; |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
175 |
_textmessage_dirty = true; |
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
176 |
|
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
177 |
/* Go one item back, because we moved the array 1 to the left */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
178 |
i--; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
179 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
180 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
181 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
182 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
183 |
/* Draw the textmessage-box */ |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
184 |
void DrawTextMessage(void) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
185 |
{ |
4960
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
186 |
uint y, count; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
187 |
|
2639 | 188 |
if (!_textmessage_dirty) return; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
189 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
190 |
/* First undraw if needed */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
191 |
UndrawTextMessage(); |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
192 |
|
4959
9a25901ce3e6
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
193 |
if (_iconsole_mode == ICONSOLE_FULL) return; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
194 |
|
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
195 |
/* Check if we have anything to draw at all */ |
4960
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
196 |
count = GetTextMessageCount(); |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
197 |
if (count == 0) return; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
198 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
199 |
/* Make a copy of the screen as it is before painting (for undraw) */ |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
200 |
memcpy_pitch( |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
201 |
_textmessage_backup, |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
202 |
_screen.dst_ptr + _textmsg_box.x + (_screen.height - _textmsg_box.y - _textmsg_box.height) * _screen.pitch, |
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
203 |
_textmsg_box.width, _textmsg_box.height, _screen.pitch, _textmsg_box.width); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
204 |
|
4960
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
205 |
_cur_dpi = &_screen; // switch to _screen painting |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
206 |
|
4960
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
207 |
/* Paint a half-transparent box behind the text messages */ |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
208 |
GfxFillRect( |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
209 |
_textmsg_box.x, |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
210 |
_screen.height - _textmsg_box.y - count * 13 - 2, |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
211 |
_textmsg_box.x + _textmsg_box.width - 1, |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
212 |
_screen.height - _textmsg_box.y - 2, |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
213 |
PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE) // black, but with some alpha for background |
4960
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
214 |
); |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
215 |
|
4960
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
216 |
/* Paint the messages starting with the lowest at the bottom */ |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
217 |
for (y = 13; count-- != 0; y += 13) { |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
218 |
DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color); |
92987006dcca
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
219 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
220 |
|
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
221 |
/* Make sure the data is updated next flush */ |
4956
49ecd2a36222
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
222 |
_video_driver->make_dirty(_textmsg_box.x, _screen.height - _textmsg_box.y - _textmsg_box.height, _textmsg_box.width, _textmsg_box.height); |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
223 |
|
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
224 |
_textmessage_visible = true; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
225 |
_textmessage_dirty = false; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
226 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
227 |
|
0 | 228 |
static void MarkTextEffectAreaDirty(TextEffect *te) |
229 |
{ |
|
230 |
MarkAllViewportsDirty( |
|
231 |
te->x, |
|
232 |
te->y - 1, |
|
233 |
(te->right - te->x)*2 + te->x + 1, |
|
234 |
(te->bottom - (te->y - 1)) * 2 + (te->y - 1) + 1 |
|
235 |
); |
|
236 |
} |
|
237 |
||
238 |
void AddTextEffect(StringID msg, int x, int y, uint16 duration) |
|
239 |
{ |
|
240 |
TextEffect *te; |
|
241 |
int w; |
|
242 |
char buffer[100]; |
|
243 |
||
4958 | 244 |
if (_game_mode == GM_MENU) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
245 |
|
2470 | 246 |
for (te = _text_effect_list; te->string_id != INVALID_STRING_ID; ) { |
2639 | 247 |
if (++te == endof(_text_effect_list)) return; |
0 | 248 |
} |
249 |
||
250 |
te->string_id = msg; |
|
251 |
te->duration = duration; |
|
252 |
te->y = y - 5; |
|
253 |
te->bottom = y + 5; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
425
diff
changeset
|
254 |
te->params_1 = GetDParam(0); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
425
diff
changeset
|
255 |
te->params_2 = GetDParam(4); |
0 | 256 |
|
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4609
diff
changeset
|
257 |
GetString(buffer, msg, lastof(buffer)); |
4609
954fe701062f
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4469
diff
changeset
|
258 |
w = GetStringBoundingBox(buffer).width; |
0 | 259 |
|
260 |
te->x = x - (w >> 1); |
|
261 |
te->right = x + (w >> 1) - 1; |
|
262 |
MarkTextEffectAreaDirty(te); |
|
263 |
} |
|
264 |
||
265 |
static void MoveTextEffect(TextEffect *te) |
|
266 |
{ |
|
267 |
if (te->duration < 8) { |
|
2470 | 268 |
te->string_id = INVALID_STRING_ID; |
0 | 269 |
} else { |
2549 | 270 |
te->duration -= 8; |
0 | 271 |
te->y--; |
272 |
te->bottom--; |
|
273 |
} |
|
274 |
MarkTextEffectAreaDirty(te); |
|
275 |
} |
|
276 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
277 |
void MoveAllTextEffects(void) |
0 | 278 |
{ |
279 |
TextEffect *te; |
|
280 |
||
2549 | 281 |
for (te = _text_effect_list; te != endof(_text_effect_list); te++) { |
282 |
if (te->string_id != INVALID_STRING_ID) MoveTextEffect(te); |
|
0 | 283 |
} |
284 |
} |
|
285 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
286 |
void InitTextEffects(void) |
0 | 287 |
{ |
288 |
TextEffect *te; |
|
289 |
||
2549 | 290 |
for (te = _text_effect_list; te != endof(_text_effect_list); te++) { |
2470 | 291 |
te->string_id = INVALID_STRING_ID; |
0 | 292 |
} |
293 |
} |
|
294 |
||
295 |
void DrawTextEffects(DrawPixelInfo *dpi) |
|
296 |
{ |
|
4469 | 297 |
const TextEffect* te; |
0 | 298 |
|
4469 | 299 |
switch (dpi->zoom) { |
300 |
case 0: |
|
301 |
for (te = _text_effect_list; te != endof(_text_effect_list); te++) { |
|
302 |
if (te->string_id != INVALID_STRING_ID && |
|
303 |
dpi->left <= te->right && |
|
304 |
dpi->top <= te->bottom && |
|
305 |
dpi->left + dpi->width > te->x && |
|
306 |
dpi->top + dpi->height > te->y) { |
|
5026
d589561bc43d
(svn r7067) Remove the unused parameter params_3 from AddStringToDraw()
tron
parents:
4960
diff
changeset
|
307 |
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2); |
4469 | 308 |
} |
309 |
} |
|
310 |
break; |
|
0 | 311 |
|
4469 | 312 |
case 1: |
313 |
for (te = _text_effect_list; te != endof(_text_effect_list); te++) { |
|
314 |
if (te->string_id != INVALID_STRING_ID && |
|
315 |
dpi->left <= te->right * 2 - te->x && |
|
316 |
dpi->top <= te->bottom * 2 - te->y && |
|
317 |
dpi->left + dpi->width > te->x && |
|
318 |
dpi->top + dpi->height > te->y) { |
|
5026
d589561bc43d
(svn r7067) Remove the unused parameter params_3 from AddStringToDraw()
tron
parents:
4960
diff
changeset
|
319 |
AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2); |
4469 | 320 |
} |
321 |
} |
|
322 |
break; |
|
0 | 323 |
} |
324 |
} |
|
325 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
326 |
void DeleteAnimatedTile(TileIndex tile) |
0 | 327 |
{ |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
328 |
TileIndex *ti; |
0 | 329 |
|
2549 | 330 |
for (ti = _animated_tile_list; ti != endof(_animated_tile_list); ti++) { |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
331 |
if (tile == *ti) { |
0 | 332 |
/* remove the hole */ |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
333 |
memmove(ti, ti + 1, (lastof(_animated_tile_list) - ti) * sizeof(*ti)); |
0 | 334 |
/* and clear last item */ |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
335 |
*lastof(_animated_tile_list) = 0; |
0 | 336 |
MarkTileDirtyByTile(tile); |
337 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
338 |
} |
0 | 339 |
} |
340 |
} |
|
341 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
342 |
bool AddAnimatedTile(TileIndex tile) |
0 | 343 |
{ |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
344 |
TileIndex *ti; |
0 | 345 |
|
2549 | 346 |
for (ti = _animated_tile_list; ti != endof(_animated_tile_list); ti++) { |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
347 |
if (tile == *ti || *ti == 0) { |
0 | 348 |
*ti = tile; |
349 |
MarkTileDirtyByTile(tile); |
|
350 |
return true; |
|
351 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
352 |
} |
0 | 353 |
|
354 |
return false; |
|
355 |
} |
|
356 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
357 |
void AnimateAnimatedTiles(void) |
0 | 358 |
{ |
2549 | 359 |
const TileIndex* ti; |
0 | 360 |
|
2549 | 361 |
for (ti = _animated_tile_list; ti != endof(_animated_tile_list) && *ti != 0; ti++) { |
362 |
AnimateTile(*ti); |
|
0 | 363 |
} |
364 |
} |
|
365 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
366 |
void InitializeAnimatedTiles(void) |
0 | 367 |
{ |
368 |
memset(_animated_tile_list, 0, sizeof(_animated_tile_list)); |
|
369 |
} |
|
370 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1022
diff
changeset
|
371 |
static void SaveLoad_ANIT(void) |
0 | 372 |
{ |
5428
00fab4aeff78
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5427
diff
changeset
|
373 |
/* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */ |
2685
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2639
diff
changeset
|
374 |
if (CheckSavegameVersion(6)) { |
1881
435d39bd6ee0
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1595
diff
changeset
|
375 |
SlArray(_animated_tile_list, lengthof(_animated_tile_list), SLE_FILE_U16 | SLE_VAR_U32); |
2549 | 376 |
} else { |
1174
6a5e747f3ba6
(svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
tron
parents:
1093
diff
changeset
|
377 |
SlArray(_animated_tile_list, lengthof(_animated_tile_list), SLE_UINT32); |
2549 | 378 |
} |
0 | 379 |
} |
380 |
||
381 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
382 |
extern const ChunkHandler _animated_tile_chunk_handlers[] = { |
0 | 383 |
{ 'ANIT', SaveLoad_ANIT, SaveLoad_ANIT, CH_RIFF | CH_LAST}, |
384 |
}; |