wok-next view assaultcube/stuff/patches/assaultcube-gcc6.patch @ rev 21677

updated geos (3.6.3 -> 3.8.1)
author Hans-G?nter Theisgen
date Mon Jun 29 11:11:43 2020 +0100 (2020-06-29)
parents
children
line source
1 From 752950989b4e286459ca9aee3d61a868d7b20fa4 Mon Sep 17 00:00:00 2001
2 From: ac-stef <ac_stef@users.sf.net>
3 Date: Sat, 27 Feb 2016 21:28:23 +0100
4 Subject: [PATCH] fix some errors and warnings for GCC 6
6 * do not use std::abs() because math.h includes one, that converts ints
7 to double. Use own iabs(), which directly uses labs() instead.
8 * don't use the word "gamma" as name for variables
9 * don't use a homebrew round() function
10 ---
11 source/src/bot/bot_waypoint.cpp | 12 ++++++------
12 source/src/command.cpp | 2 +-
13 source/src/command.h | 1 +
14 source/src/crypto.cpp | 2 +-
15 source/src/editing.cpp | 6 +++---
16 source/src/entity.h | 2 +-
17 source/src/main.cpp | 8 ++++----
18 source/src/platform.h | 9 +--------
19 source/src/protos.h | 3 ++-
20 source/src/rendercubes.cpp | 8 ++++----
21 source/src/rendertext.cpp | 4 ++--
22 source/src/tools.h | 3 +--
23 source/src/world.cpp | 6 +++---
24 source/src/worldocull.cpp | 2 +-
25 source/src/worldrender.cpp | 4 ++--
26 15 files changed, 33 insertions(+), 39 deletions(-)
28 diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp
29 index 520c686..7b265ef 100644
30 --- a/source/src/bot/bot_waypoint.cpp
31 +++ b/source/src/bot/bot_waypoint.cpp
32 @@ -1221,7 +1221,7 @@ void CWaypointClass::CalcCost(node_s *pNode)
33 flCost += (1.0f-flFraction)*0.5f;
34 }
36 - if ((abs(a) > 4) || (abs(b) > 4)) continue;
37 + if ((iabs(a) > 4) || (iabs(b) > 4)) continue;
39 vec from = to;
40 to.z -= (JUMP_HEIGHT - 1.0f);
41 @@ -1249,7 +1249,7 @@ void CWaypointClass::CalcCost(node_s *pNode)
42 flCost += (1.0f-flFraction)*0.5f;
43 }
45 - if ((abs(a) > 4) || (abs(b) > 4)) continue;
46 + if ((iabs(a) > 4) || (iabs(b) > 4)) continue;
48 vec from = to;
49 to.z -= (JUMP_HEIGHT - 1.0f);
50 @@ -1671,12 +1671,12 @@ node_s *CWaypointClass::GetNearestTriggerFloodWP(vec v_origin, float flRange)
51 void CWaypointClass::GetNodeIndexes(const vec &v_origin, short *i, short *j)
52 {
53 // Function code by cheesy and PMB
54 - //*i = abs((int)((int)(v_origin.x + (2*ssize)) / SECTOR_SIZE));
55 - //*j = abs((int)((int)(v_origin.y + (2*ssize)) / SECTOR_SIZE));
56 + //*i = iabs((int)((int)(v_origin.x + (2*ssize)) / SECTOR_SIZE));
57 + //*j = iabs((int)((int)(v_origin.y + (2*ssize)) / SECTOR_SIZE));
58 //*i = (int)((v_origin.x) / ssize * MAX_MAP_GRIDS);
59 //*j = (int)((v_origin.y) / ssize * MAX_MAP_GRIDS);
60 - *i = abs((int)((v_origin.x) / MAX_MAP_GRIDS));
61 - *j = abs((int)((v_origin.y) / MAX_MAP_GRIDS));
62 + *i = iabs((int)((v_origin.x) / MAX_MAP_GRIDS));
63 + *j = iabs((int)((v_origin.y) / MAX_MAP_GRIDS));
65 if (*i > MAX_MAP_GRIDS - 1)
66 *i = MAX_MAP_GRIDS - 1;
67 diff --git a/source/src/command.cpp b/source/src/command.cpp
68 index 668f3bf..2a5c90d 100644
69 --- a/source/src/command.cpp
70 +++ b/source/src/command.cpp
71 @@ -499,7 +499,7 @@ char *executeret(const char *p) // all evaluation hap
72 if(lc<=seer_t1.length())
73 {
74 int dt = seer_t1[seer_index] - seer_t1[lc];
75 - if(abs(dt)<2)
76 + if(iabs(dt)<2)
77 {
78 conoutf("SCRIPT EXECUTION warning [%d:%s]", &p, p);
79 seer_t2.add(seer_t1[seer_index]);
80 diff --git a/source/src/command.h b/source/src/command.h
81 index a3ca68a..2a3de0c 100644
82 --- a/source/src/command.h
83 +++ b/source/src/command.h
84 @@ -86,6 +86,7 @@ enum { IEXC_CORE = 0, IEXC_CFG, IEXC_PROMPT, IEXC_MAPCFG, IEXC_MDLCFG, IEXC_NUM
85 #define VARNP(name, global, min, cur, max) int global = variable(#name, min, cur, max, &global, NULL, true)
86 #define VARF(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, false)
87 #define VARFP(name, min, cur, max, body) extern int name; void var_##name() { body; } int name = variable(#name, min, cur, max, &name, var_##name, true)
88 +#define VARNFP(name, global, min, cur, max, body) extern int global; void var_##name() { body; } int global = variable(#name, min, cur, max, &global, var_##name, true)
90 #define FVARP(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, true)
91 #define FVAR(name, min, cur, max) float name = fvariable(#name, min, cur, max, &name, NULL, false)
92 diff --git a/source/src/crypto.cpp b/source/src/crypto.cpp
93 index 44041be..0684750 100644
94 --- a/source/src/crypto.cpp
95 +++ b/source/src/crypto.cpp
96 @@ -778,7 +778,7 @@ static const char *hashchunktoa(tiger::chunk h) // portable solution instead o
97 const char *genpwdhash(const char *name, const char *pwd, int salt)
98 {
99 static string temp;
100 - formatstring(temp)("%s %d %s %s %d", pwd, salt, name, pwd, abs(PROTOCOL_VERSION));
101 + formatstring(temp)("%s %d %s %s %d", pwd, salt, name, pwd, iabs(PROTOCOL_VERSION));
102 tiger::hashval hash;
103 tiger::hash((uchar *)temp, (int)strlen(temp), hash);
104 formatstring(temp)("%s %s %s", hashchunktoa(hash.chunks[0]), hashchunktoa(hash.chunks[1]), hashchunktoa(hash.chunks[2]));
105 diff --git a/source/src/editing.cpp b/source/src/editing.cpp
106 index 8d5e1ff..745aa98 100644
107 --- a/source/src/editing.cpp
108 +++ b/source/src/editing.cpp
109 @@ -137,11 +137,11 @@ void checkselections()
110 void makesel(bool isnew)
111 {
112 block &cursel = sels.last(); //RR 10/12/12 - FIXEME, error checking should happen with "isnew", not here checking if it really is new.
113 - if(isnew || sels.length() == 0) addselection(min(lastx, cx), min(lasty, cy), abs(lastx-cx)+1, abs(lasty-cy)+1, max(lasth, ch));
114 + if(isnew || sels.length() == 0) addselection(min(lastx, cx), min(lasty, cy), iabs(lastx-cx)+1, iabs(lasty-cy)+1, max(lasth, ch));
115 else
116 {
117 cursel.x = min(lastx, cx); cursel.y = min(lasty, cy);
118 - cursel.xs = abs(lastx-cx)+1; cursel.ys = abs(lasty-cy)+1;
119 + cursel.xs = iabs(lastx-cx)+1; cursel.ys = iabs(lasty-cy)+1;
120 cursel.h = max(lasth, ch);
121 correctsel(cursel);
122 }
123 @@ -849,7 +849,7 @@ void movemap(int xo, int yo, int zo) // move whole map
124 }
125 if(xo || yo)
126 {
127 - block b = { max(-xo, 0), max(-yo, 0), ssize - abs(xo), ssize - abs(yo) }, *cp = blockcopy(b);
128 + block b = { max(-xo, 0), max(-yo, 0), ssize - iabs(xo), ssize - iabs(yo) }, *cp = blockcopy(b);
129 cp->x = max(xo, 0);
130 cp->y = max(yo, 0);
131 blockpaste(*cp);
132 diff --git a/source/src/entity.h b/source/src/entity.h
133 index e2ad32d..84ac385 100644
134 --- a/source/src/entity.h
135 +++ b/source/src/entity.h
136 @@ -538,7 +538,7 @@ class playerent : public dynent, public playerstate
137 {
138 const int maxskin[2] = { 4, 6 };
139 t = team_base(t < 0 ? team : t);
140 - nextskin[t] = abs(s) % maxskin[t];
141 + nextskin[t] = iabs(s) % maxskin[t];
142 }
143 };
145 diff --git a/source/src/main.cpp b/source/src/main.cpp
146 index 0d57c0c..c51cd74 100644
147 --- a/source/src/main.cpp
148 +++ b/source/src/main.cpp
149 @@ -519,11 +519,11 @@ void setresdata(char *s, enet_uint32 c)
150 COMMANDF(screenres, "ii", (int *w, int *h) { screenres(*w, *h); });
152 static int curgamma = 100;
153 -VARFP(gamma, 30, 100, 300,
154 +VARNFP(gamma, vgamma, 30, 100, 300,
155 {
156 - if(gamma == curgamma) return;
157 - curgamma = gamma;
158 - float f = gamma/100.0f;
159 + if(vgamma == curgamma) return;
160 + curgamma = vgamma;
161 + float f = vgamma/100.0f;
162 if(SDL_SetGamma(f,f,f)==-1) conoutf("Could not set gamma: %s", SDL_GetError());
163 });
165 diff --git a/source/src/platform.h b/source/src/platform.h
166 index aece7e2..fd2eef1 100644
167 --- a/source/src/platform.h
168 +++ b/source/src/platform.h
169 @@ -2,14 +2,6 @@
170 #ifdef _FORTIFY_SOURCE
171 #undef _FORTIFY_SOURCE
172 #endif
173 -
174 - #define gamma __gamma
175 -#endif
176 -
177 -#include <math.h>
178 -
179 -#ifdef __GNUC__
180 - #undef gamma
181 #endif
183 #include <string.h>
184 @@ -19,6 +11,7 @@
185 #include <ctype.h>
186 #include <time.h>
187 #include <limits.h>
188 +#include <math.h>
189 #ifdef __GNUC__
190 #include <new>
191 #include <signal.h>
192 diff --git a/source/src/protos.h b/source/src/protos.h
193 index 1c07fad..97b0ee0 100644
194 --- a/source/src/protos.h
195 +++ b/source/src/protos.h
196 @@ -1053,7 +1053,8 @@ struct servercommandline
197 {
198 demo_interm = true;
199 }
200 - else if(ai > 0) maxdemos = ai; break;
201 + else if(ai > 0) maxdemos = ai;
202 + break;
203 }
204 case 'W': demopath = a; break;
205 case 'r': maprot = a; break;
206 diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp
207 index 1940da8..2be7fb0 100644
208 --- a/source/src/rendercubes.cpp
209 +++ b/source/src/rendercubes.cpp
210 @@ -216,9 +216,9 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l4, sqr
211 else // continue strip
212 {
213 int lighterr = lighterror*2;
214 - if((abs(ol1r-l3->r)<lighterr && abs(ol2r-l4->r)<lighterr // skip vertices if light values are close enough
215 - && abs(ol1g-l3->g)<lighterr && abs(ol2g-l4->g)<lighterr
216 - && abs(ol1b-l3->b)<lighterr && abs(ol2b-l4->b)<lighterr) || !wtex)
217 + if((iabs(ol1r-l3->r)<lighterr && iabs(ol2r-l4->r)<lighterr // skip vertices if light values are close enough
218 + && iabs(ol1g-l3->g)<lighterr && iabs(ol2g-l4->g)<lighterr
219 + && iabs(ol1b-l3->b)<lighterr && iabs(ol2b-l4->b)<lighterr) || !wtex)
220 {
221 verts.setsize(verts.length()-2);
222 nquads--;
223 @@ -375,7 +375,7 @@ void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil
224 {
225 int lighterr = lighterror*2;
226 if((!hf && !ohf)
227 - && ((abs(ol1r-l2->r)<lighterr && abs(ol1g-l2->g)<lighterr && abs(ol1b-l2->b)<lighterr) || !wtex)) // skip vertices if light values are close enough
228 + && ((iabs(ol1r-l2->r)<lighterr && iabs(ol1g-l2->g)<lighterr && iabs(ol1b-l2->b)<lighterr) || !wtex)) // skip vertices if light values are close enough
229 {
230 verts.setsize(verts.length()-2);
231 nquads--;
232 diff --git a/source/src/rendertext.cpp b/source/src/rendertext.cpp
233 index 0ed23af..b55da4f 100644
234 --- a/source/src/rendertext.cpp
235 +++ b/source/src/rendertext.cpp
236 @@ -330,7 +330,7 @@ static void text_color(char c, char *stack, int size, int &sp, bvec color, int a
237 if(c=='r') c = stack[(sp > 0) ? --sp : sp]; // restore color
238 else if(c == 'b') { if(allowblinkingtext && !ignoreblinkingbit) stack[sp] *= -1; } // blinking text - only if allowed
239 else stack[sp] = c;
240 - switch(abs(stack[sp]))
241 + switch(iabs(stack[sp]))
242 {
243 case '0': color = bvec( 2, 255, 128 ); break; // green: player talk
244 case '1': color = bvec( 96, 160, 255 ); break; // blue: team chat
245 @@ -380,7 +380,7 @@ static void text_color(char c, char *stack, int size, int &sp, bvec color, int a
246 //default: color = bvec( 255, 255, 255 ); break;
247 }
248 int b = (int) (sinf(lastmillis / 200.0f) * 115.0f);
249 - b = stack[sp] > 0 ? 100 : min(abs(b), 100);
250 + b = stack[sp] > 0 ? 100 : min(iabs(b), 100);
251 glColor4ub(color.x, color.y, color.z, (a * b) / 100);
252 }
253 }
254 diff --git a/source/src/tools.h b/source/src/tools.h
255 index 0aeacff..9eb5a38 100644
256 --- a/source/src/tools.h
257 +++ b/source/src/tools.h
258 @@ -54,8 +54,7 @@ static inline T min(T a, T b)
259 {
260 return a < b ? a : b;
261 }
262 -
263 -static inline float round(float x) { return floor(x + 0.5f); }
264 +inline int iabs(int n) { return labs(n); }
266 #define clamp(a,b,c) (max(b, min(a, c)))
267 #define rnd(x) ((int)(randomMT()&0xFFFFFF)%(x))
268 diff --git a/source/src/world.cpp b/source/src/world.cpp
269 index 6a1c7bb..99a70eb 100644
270 --- a/source/src/world.cpp
271 +++ b/source/src/world.cpp
272 @@ -79,9 +79,9 @@ void remip(const block &b, int level)
273 || o[i]->ceil!=o[3]->ceil
274 || o[i]->ftex!=o[3]->ftex
275 || o[i]->ctex!=o[3]->ctex
276 - || abs(o[i+1]->r-o[0]->r)>lighterr // perfect mip even if light is not exactly equal
277 - || abs(o[i+1]->g-o[0]->g)>lighterr
278 - || abs(o[i+1]->b-o[0]->b)>lighterr
279 + || iabs(o[i+1]->r-o[0]->r)>lighterr // perfect mip even if light is not exactly equal
280 + || iabs(o[i+1]->g-o[0]->g)>lighterr
281 + || iabs(o[i+1]->b-o[0]->b)>lighterr
282 || o[i]->utex!=o[3]->utex
283 || o[i]->wtex!=o[3]->wtex) goto c;
284 }
285 diff --git a/source/src/worldrender.cpp b/source/src/worldrender.cpp
286 index 8fd3104..45aa606 100644
287 --- a/source/src/worldrender.cpp
288 +++ b/source/src/worldrender.cpp
289 @@ -297,10 +297,10 @@ void distlod(int &low, int &high, int angle, float widef)
290 void render_world(float vx, float vy, float vh, float changelod, int yaw, int pitch, float fov, float fovy, int w, int h)
291 {
292 loopi(LARGEST_FACTOR) stats[i] = 0;
293 - min_lod = minimap || (player1->isspectating() && player1->spectatemode == SM_OVERVIEW) ? MAX_LOD : MIN_LOD+abs(pitch)/12;
294 + min_lod = minimap || (player1->isspectating() && player1->spectatemode == SM_OVERVIEW) ? MAX_LOD : MIN_LOD+iabs(pitch)/12;
295 yaw = 360-yaw;
296 float widef = fov/75.0f;
297 - int cdist = abs(yaw%90-45);
298 + int cdist = iabs(yaw%90-45);
299 if(cdist<7) // hack to avoid popup at high fovs at 45 yaw
300 {
301 min_lod = max(min_lod, (int)(MIN_LOD+(10-cdist)/1.0f*widef)); // less if lod worked better