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.330 by root, Sun Nov 18 15:24:24 2018 UTC vs.
Revision 1.332 by root, Mon Nov 19 00:56:08 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 Newxz (p, sze + inc, T); 302 Newx (p, inc + sze, T);
303 Zero (p, inc, T);
308 Move (ptr, p + inc, sze, T); 304 Move (ptr, p + inc, sze, T);
309 Safefree (ptr); 305 Safefree (ptr);
310 306
311 ptr = p; 307 ptr = p;
312} 308}
530 n |= n >> 4; 526 n |= n >> 4;
531 n |= n >> 8; 527 n |= n >> 8;
532 n |= n >> 16; 528 n |= n >> 16;
533 529
534 return n + 1; 530 return n + 1;
535}
536
537static unsigned int
538popcount (unsigned int n)
539{
540 n -= (n >> 1) & 0x55555555U;
541 n = ((n >> 2) & 0x33333333U) + (n & 0x33333333U);
542 n = ((n >> 4) + n) & 0x0f0f0f0fU;
543 n *= 0x01010101U;
544
545 return n >> 24;
546} 531}
547 532
548/* SDL should provide this, really. */ 533/* SDL should provide this, really. */
549#define SDLK_MODIFIER_MIN 300 534#define SDLK_MODIFIER_MIN 300
550#define SDLK_MODIFIER_MAX 314 535#define SDLK_MODIFIER_MAX 314
881 866
882NV ceil (NV x) 867NV ceil (NV x)
883 868
884IV minpot (UV n) 869IV minpot (UV n)
885 870
871UV ld32 (UV n)
872 CODE:
873 RETVAL = ecb_ld32 (n);
874 OUTPUT:
875 RETVAL
876
886IV popcount (UV n) 877IV popcount (UV n)
878 CODE:
879 RETVAL = ecb_popcount32 (n);
880 OUTPUT:
881 RETVAL
887 882
888NV distance (NV dx, NV dy) 883NV distance (NV dx, NV dy)
889 CODE: 884 CODE:
890 RETVAL = pow (dx * dx + dy * dy, 0.5); 885 RETVAL = pow (dx * dx + dy * dy, 0.5);
891 OUTPUT: 886 OUTPUT:
2306 } 2301 }
2307 2302
2308 px = (x + 1) * Th - tex.w; 2303 px = (x + 1) * Th - tex.w;
2309 py = (y + 1) * Tw - tex.h; 2304 py = (y + 1) * Tw - tex.h;
2310 2305
2311 if (expect_false (cell->player == player) && expect_false (z == 2)) 2306 if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2))
2312 { 2307 {
2313 pl_x = px; 2308 pl_x = px;
2314 pl_y = py; 2309 pl_y = py;
2315 pl_tex = tex; 2310 pl_tex = tex;
2316 continue; 2311 continue;
2359 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); 2354 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400);
2360 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800); 2355 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800);
2361 } 2356 }
2362 } 2357 }
2363 2358
2364 if (expect_false (z == 2) && expect_false (cell->flags)) 2359 if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags))
2365 { 2360 {
2366 // overlays such as the speech bubble, probably more to come 2361 // overlays such as the speech bubble, probably more to come
2367 if (cell->flags & 1) 2362 if (cell->flags & 1)
2368 { 2363 {
2369 rc_key_t key_ov = key; 2364 rc_key_t key_ov = key;
2488 mapcell *cell = row->col + (x + mx - row->c0); 2483 mapcell *cell = row->col + (x + mx - row->c0);
2489 2484
2490 int px = x * Tw; 2485 int px = x * Tw;
2491 int py = y * Th; 2486 int py = y * Th;
2492 2487
2493 if (expect_false (cell->player == player)) 2488 if (ecb_expect_false (cell->player == player))
2494 { 2489 {
2495 px += sdx; 2490 px += sdx;
2496 py += sdy; 2491 py += sdy;
2497 } 2492 }
2498 2493

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines