Debian Codegraph @

debian/patches/grtext_rename_functions.patch

raw symbols SCIP
1 Description: rename functions in grtext to fix C++20/23/26 builds
2 Author: Jon Daniel <[email protected]>
3 Forwarded: not-needed, already fixed in https://github.com/DescentDevelopers/Descent3/pull/686
4 --- a/grtext/grtext.cpp
5 +++ b/grtext/grtext.cpp
6 @@ -229,15 +229,12 @@ void grtext_Init() {
7 }
8 }
9
10 -// macro to get character width
11 -static inline int CHAR_WIDTH(int font, int ch) { return (int)(grfont_GetCharWidth(font, ch) * Grtext_scale); }
12 -
13 -static inline int CHAR_HEIGHT(int font) { return (int)(grfont_GetHeight(font) * Grtext_scale); }
14 -
15 -static inline int CHAR_SPACING(int font, int ch1, int ch2) { return (int)(grfont_GetKernedSpacing(font, ch1, ch2)); }
16 -
17 -// macro to get character width
18 -static inline int CHAR_WIDTH_TEMP(const tFontTemplate *ft, int ch) {
19 +// macros to get character dimensions
20 +static inline int GRCHAR_WIDTH(int font, int ch) { return (int)(grfont_GetCharWidth(font, ch) * Grtext_scale); }
21 +static inline int GRCHAR_HEIGHT(int font) { return (int)(grfont_GetHeight(font) * Grtext_scale); }
22 +static inline int GRCHAR_SPACING(int font, int ch1, int ch2) { return (int)(grfont_GetKernedSpacing(font, ch1, ch2)); }
23 +static inline int GRCHAR_HEIGHT_TEMP(const tFontTemplate *ft) { return (int)ft->ch_height; }
24 +static inline int GRCHAR_WIDTH_TEMP(const tFontTemplate *ft, int ch) {
25 if (ch > ft->max_ascii && ft->uppercase) {
26 ch = toupper(ch);
27 } else if (ch < ft->min_ascii || ch > ft->max_ascii) {
28 @@ -246,10 +243,7 @@ static inline int CHAR_WIDTH_TEMP(const tFontTemplate *ft, int ch) {
29
30 return (int)((ft->proportional) ? ft->ch_widths[ch - ft->min_ascii] : ft->ch_maxwidth);
31 }
32 -
33 -static inline int CHAR_HEIGHT_TEMP(const tFontTemplate *ft) { return (int)ft->ch_height; }
34 -
35 -static inline int CHAR_SPACING_TEMP(const tFontTemplate *ft, int ch1, int ch2) {
36 +static inline int GRCHAR_SPACING_TEMP(const tFontTemplate *ft, int ch1, int ch2) {
37 if (ch1 > ft->max_ascii && ft->uppercase) {
38 ch1 = toupper(ch1);
39 }
40 @@ -698,7 +692,7 @@ void grtext_RenderString(int x, int y, char *str) {
41 gx = cur_x; // Clip function needs global coords.
42
43 clipped = 0;
44 - if ((CLIP_TOP > (gy + CHAR_HEIGHT(Grtext_font))) || (CLIP_BOTTOM < gy))
45 + if ((CLIP_TOP > (gy + GRCHAR_HEIGHT(Grtext_font))) || (CLIP_BOTTOM < gy))
46 clipped = 2;
47 else if ((CLIP_LEFT > (gx + line_width)) || (CLIP_RIGHT < gx))
48 clipped = 2;
49 @@ -706,7 +700,7 @@ void grtext_RenderString(int x, int y, char *str) {
50 if (clipped != 2) {
51 if (CLIP_LEFT > gx || CLIP_RIGHT < (gx + line_width))
52 clipped = 1;
53 - if (CLIP_TOP > gy || CLIP_BOTTOM < (gy + CHAR_HEIGHT(Grtext_font)))
54 + if (CLIP_TOP > gy || CLIP_BOTTOM < (gy + GRCHAR_HEIGHT(Grtext_font)))
55 clipped = 1;
56
57 if (clipped == 0)
58 @@ -714,7 +708,7 @@ void grtext_RenderString(int x, int y, char *str) {
59 else if (clipped == 1)
60 grtext_DrawTextLineClip(gx, gy, line);
61 }
62 - cur_y += (Grtext_line_spacing + CHAR_HEIGHT(Grtext_font));
63 + cur_y += (Grtext_line_spacing + GRCHAR_HEIGHT(Grtext_font));
64 cur_x = CLIP_LEFT;
65
66 // replace the newline, if there was one
67 @@ -731,7 +725,7 @@ int grtext_GetTextHeightTemplate(tFontTemplate *ft, const char *str) {
68 const char *spos = str;
69
70 do {
71 - cur_h += (Grtext_line_spacing + CHAR_HEIGHT_TEMP(ft));
72 + cur_h += (Grtext_line_spacing + GRCHAR_HEIGHT_TEMP(ft));
73
74 spos = strchr(spos, '\n');
75 if (spos)
76 @@ -746,7 +740,7 @@ int grtext_GetTextHeight(const char *str) {
77 const char *spos = str;
78
79 do {
80 - cur_h += (Grtext_line_spacing + CHAR_HEIGHT(Grtext_font));
81 + cur_h += (Grtext_line_spacing + GRCHAR_HEIGHT(Grtext_font));
82
83 spos = strchr(spos, '\n');
84 if (spos)
85 @@ -774,7 +768,7 @@ int grtext_GetTextLineWidth(const char *str) {
86 if (!rgb_define_mode) {
87 if (ch == '\t') { // tab char
88 int space_width;
89 - space_width = (CHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing) * Grtext_tabspace;
90 + space_width = (GRCHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing) * Grtext_tabspace;
91 line_width = (line_width + space_width) / space_width * space_width;
92 } else if (ch == GRTEXT_FORMAT_CHAR) {
93 if ((i + 1) >= strsize)
94 @@ -787,8 +781,8 @@ int grtext_GetTextLineWidth(const char *str) {
95 }
96 line_width = 0;
97 } else {
98 - width = CHAR_WIDTH(Grtext_font, ch);
99 - line_width += (width + Grtext_spacing + CHAR_SPACING(Grtext_font, ch, ch2));
100 + width = GRCHAR_WIDTH(Grtext_font, ch);
101 + line_width += (width + Grtext_spacing + GRCHAR_SPACING(Grtext_font, ch, ch2));
102 }
103 } else
104 rgb_define_mode++;
105 @@ -818,7 +812,7 @@ int grtext_GetTextLineWidthTemplate(const tFontTemplate *ft, const char *str) {
106 if (!rgb_define_mode) {
107 if (ch == '\t') { // tab char
108 int space_width;
109 - space_width = (CHAR_WIDTH_TEMP(ft, ' ') + Grtext_spacing) * Grtext_tabspace;
110 + space_width = (GRCHAR_WIDTH_TEMP(ft, ' ') + Grtext_spacing) * Grtext_tabspace;
111 line_width = (line_width + space_width) / space_width * space_width;
112 } else if (ch == GRTEXT_FORMAT_CHAR) {
113 if ((i + 1) >= strsize)
114 @@ -831,8 +825,8 @@ int grtext_GetTextLineWidthTemplate(const tFontTemplate *ft, const char *str) {
115 }
116 line_width = 0;
117 } else {
118 - width = CHAR_WIDTH_TEMP(ft, ch);
119 - line_width += (width + Grtext_spacing + CHAR_SPACING_TEMP(ft, ch, ch2));
120 + width = GRCHAR_WIDTH_TEMP(ft, ch);
121 + line_width += (width + Grtext_spacing + GRCHAR_SPACING_TEMP(ft, ch, ch2));
122 }
123 } else
124 rgb_define_mode++;
125 @@ -858,7 +852,7 @@ void grtext_DrawTextLineClip(int x, int y, char *str) {
126 go through each character in the line and determine what is totally clipped,
127 partially clipped and by how much, and not clipped at all and draw accordingly
128 */
129 - h = CHAR_HEIGHT(Grtext_font);
130 + h = GRCHAR_HEIGHT(Grtext_font);
131 ch_y = 0;
132 ch_h = h;
133 draw_y = y;
134 @@ -867,7 +861,7 @@ void grtext_DrawTextLineClip(int x, int y, char *str) {
135 ch_y = CLIP_TOP - y;
136 draw_y = CLIP_TOP;
137 }
138 - if (CLIP_BOTTOM < (y + CHAR_HEIGHT(Grtext_font))) {
139 + if (CLIP_BOTTOM < (y + GRCHAR_HEIGHT(Grtext_font))) {
140 ch_h = CLIP_BOTTOM - y;
141 }
142 ch_h = ch_h - ch_y; // do this to clip both top and bottom
143 @@ -879,7 +873,7 @@ void grtext_DrawTextLineClip(int x, int y, char *str) {
144 ch = (uint8_t)str[i];
145 ch2 = (uint8_t)str[i + 1];
146
147 - w = CHAR_WIDTH(Grtext_font, ch);
148 + w = GRCHAR_WIDTH(Grtext_font, ch);
149
150 if (ch == GR_COLOR_CHAR) {
151 ddgr_color col;
152 @@ -891,7 +885,7 @@ void grtext_DrawTextLineClip(int x, int y, char *str) {
153 i += 3;
154 } else if (ch == '\t') { // tab char
155 int space_width;
156 - space_width = (CHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing) * Grtext_tabspace;
157 + space_width = (GRCHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing) * Grtext_tabspace;
158 cur_x = (cur_x + space_width) / space_width * space_width;
159 } else if (((cur_x + w) < CLIP_LEFT) || (cur_x > CLIP_RIGHT)) {
160 cur_x += (Grtext_spacing + w);
161 @@ -901,7 +895,7 @@ void grtext_DrawTextLineClip(int x, int y, char *str) {
162 cur_x = x + ((int)str[i + 1] * GRTEXT_FORMAT_SCALAR);
163 i++;
164 } else if (ch == ' ') {
165 - cur_x += (CHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing + CHAR_SPACING(Grtext_font, ch, ch2));
166 + cur_x += (GRCHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing + GRCHAR_SPACING(Grtext_font, ch, ch2));
167 } else {
168 ch_x = 0;
169 ch_w = w;
170 @@ -933,7 +927,7 @@ void grtext_DrawTextLineClip(int x, int y, char *str) {
171 cbi.sh = ch_h;
172 }
173 cur_x = grfont_BltChar(Grtext_font, &cbi);
174 - cur_x += (Grtext_spacing + CHAR_SPACING(Grtext_font, ch, ch2));
175 + cur_x += (Grtext_spacing + GRCHAR_SPACING(Grtext_font, ch, ch2));
176 }
177 }
178 }
179 @@ -956,7 +950,7 @@ void grtext_DrawTextLine(int x, int y, char *str) {
180 int w;
181 ch = (uint8_t)str[i];
182 ch2 = (uint8_t)str[i + 1];
183 - w = CHAR_WIDTH(Grtext_font, ch);
184 + w = GRCHAR_WIDTH(Grtext_font, ch);
185
186 if (ch == GR_COLOR_CHAR) {
187 ddgr_color col;
188 @@ -968,7 +962,7 @@ void grtext_DrawTextLine(int x, int y, char *str) {
189 i += 3;
190 } else if (ch == '\t') { // tab char
191 int space_width;
192 - space_width = (CHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing) * Grtext_tabspace;
193 + space_width = (GRCHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing) * Grtext_tabspace;
194 cur_x = (cur_x + space_width) / space_width * space_width;
195 } else if (ch == GRTEXT_FORMAT_CHAR) {
196 if ((i + 1) >= strsize)
197 @@ -976,7 +970,7 @@ void grtext_DrawTextLine(int x, int y, char *str) {
198 cur_x = x + ((int)str[i + 1] * GRTEXT_FORMAT_SCALAR);
199 i++;
200 } else if (ch == ' ') {
201 - cur_x += (CHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing);
202 + cur_x += (GRCHAR_WIDTH(Grtext_font, ' ') + Grtext_spacing);
203 } else {
204 cbi.ch = ch;
205 cbi.clipped = false; // if =1, use sx,sy,sw,sh
206 @@ -984,7 +978,7 @@ void grtext_DrawTextLine(int x, int y, char *str) {
207 cbi.y = y;
208 cbi.dsw = cbi.dsh = Grtext_scale;
209 cur_x = grfont_BltChar(Grtext_font, &cbi);
210 - cur_x += (Grtext_spacing + CHAR_SPACING(Grtext_font, ch, ch2));
211 + cur_x += (Grtext_spacing + GRCHAR_SPACING(Grtext_font, ch, ch2));
212 }
213 }
214 }