ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.329 by root, Sun Nov 18 13:07:51 2018 UTC vs.
Revision 1.331 by root, Mon Nov 19 00:10:34 2018 UTC

76# include <netinet/in.h> 76# include <netinet/in.h>
77# include <netinet/tcp.h> 77# include <netinet/tcp.h>
78# include <inttypes.h> 78# include <inttypes.h>
79#endif 79#endif
80 80
81#if __GNUC__ >= 4 81#include "ecb.h"
82# define expect(expr,value) __builtin_expect ((expr),(value))
83#else
84# define expect(expr,value) (expr)
85#endif
86
87#define expect_false(expr) expect ((expr) != 0, 0)
88#define expect_true(expr) expect ((expr) != 0, 1)
89 82
90#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 83#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
91 84
92/* this is used as fow flag as well, so has to have a different value */ 85/* this is used as fow flag as well, so has to have a different value */
93/* then anything that is computed by incoming darkness */ 86/* then anything that is computed by incoming darkness */
111fast_sv_grow (SV *sv, STRLEN need) 104fast_sv_grow (SV *sv, STRLEN need)
112{ 105{
113 STRLEN len = SvLEN (sv); 106 STRLEN len = SvLEN (sv);
114 STRLEN want = SvCUR (sv) + need; 107 STRLEN want = SvCUR (sv) + need;
115 108
116 if (expect_false (len < want)) 109 if (ecb_expect_false (len < want))
117 { 110 {
118 do 111 do
119 len *= 2; 112 len *= 2;
120 while (len < want); 113 while (len < want);
121 114
255 if (!rect.height) rect.height = 1; 248 if (!rect.height) rect.height = 1;
256 249
257 *w = rect.width; 250 *w = rect.width;
258 *h = rect.height; 251 *h = rect.height;
259} 252}
253
254/////////////////////////////////////////////////////////////////////////////
260 255
261typedef uint16_t tileid; 256typedef uint16_t tileid;
262typedef uint16_t faceid; 257typedef uint16_t faceid;
263 258
264struct maptex 259struct maptex
302static void 297static void
303prepend (T *&ptr, int sze, int inc) 298prepend (T *&ptr, int sze, int inc)
304{ 299{
305 T *p; 300 T *p;
306 301
307 New (0, p, sze + inc, T); 302 Newx (p, inc + sze, T);
308 Zero (p, inc, T); 303 Zero (p, inc, T);
309 Move (ptr, p + inc, sze, T); 304 Move (ptr, p + inc, sze, T);
310 Safefree (ptr); 305 Safefree (ptr);
311 306
312 ptr = p; 307 ptr = p;
531 n |= n >> 4; 526 n |= n >> 4;
532 n |= n >> 8; 527 n |= n >> 8;
533 n |= n >> 16; 528 n |= n >> 16;
534 529
535 return n + 1; 530 return n + 1;
536}
537
538static unsigned int
539popcount (unsigned int n)
540{
541 n -= (n >> 1) & 0x55555555U;
542 n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U);
543 n = ((n >> 4) + n) & 0x0f0f0f0fU;
544 n *= 0x01010101U;
545
546 return n >> 24;
547} 531}
548 532
549/* SDL should provide this, really. */ 533/* SDL should provide this, really. */
550#define SDLK_MODIFIER_MIN 300 534#define SDLK_MODIFIER_MIN 300
551#define SDLK_MODIFIER_MAX 314 535#define SDLK_MODIFIER_MAX 314
883NV ceil (NV x) 867NV ceil (NV x)
884 868
885IV minpot (UV n) 869IV minpot (UV n)
886 870
887IV popcount (UV n) 871IV popcount (UV n)
872 CODE:
873 RETVAL = ecb_popcount32 (n);
874 OUTPUT:
875 RETVAL
888 876
889NV distance (NV dx, NV dy) 877NV distance (NV dx, NV dy)
890 CODE: 878 CODE:
891 RETVAL = pow (dx * dx + dy * dy, 0.5); 879 RETVAL = pow (dx * dx + dy * dy, 0.5);
892 OUTPUT: 880 OUTPUT:
2307 } 2295 }
2308 2296
2309 px = (x + 1) * Th - tex.w; 2297 px = (x + 1) * Th - tex.w;
2310 py = (y + 1) * Tw - tex.h; 2298 py = (y + 1) * Tw - tex.h;
2311 2299
2312 if (expect_false (cell->player == player) && expect_false (z == 2)) 2300 if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2))
2313 { 2301 {
2314 pl_x = px; 2302 pl_x = px;
2315 pl_y = py; 2303 pl_y = py;
2316 pl_tex = tex; 2304 pl_tex = tex;
2317 continue; 2305 continue;
2360 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); 2348 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400);
2361 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); 2349 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800);
2362 } 2350 }
2363 } 2351 }
2364 2352
2365 if (expect_false (z == 2) && expect_false (cell->flags)) 2353 if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags))
2366 { 2354 {
2367 // overlays such as the speech bubble, probably more to come 2355 // overlays such as the speech bubble, probably more to come
2368 if (cell->flags & 1) 2356 if (cell->flags & 1)
2369 { 2357 {
2370 rc_key_t key_ov = key; 2358 rc_key_t key_ov = key;
2489 mapcell *cell = row->col + (x + mx - row->c0); 2477 mapcell *cell = row->col + (x + mx - row->c0);
2490 2478
2491 int px = x * Tw; 2479 int px = x * Tw;
2492 int py = y * Th; 2480 int py = y * Th;
2493 2481
2494 if (expect_false (cell->player == player)) 2482 if (ecb_expect_false (cell->player == player))
2495 { 2483 {
2496 px += sdx; 2484 px += sdx;
2497 py += sdy; 2485 py += sdy;
2498 } 2486 }
2499 2487

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines