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.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 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
882NV ceil (NV x) 867NV ceil (NV x)
883 868
884IV minpot (UV n) 869IV minpot (UV n)
885 870
886IV popcount (UV n) 871IV popcount (UV n)
872 CODE:
873 RETVAL = ecb_popcount32 (n);
874 OUTPUT:
875 RETVAL
887 876
888NV distance (NV dx, NV dy) 877NV distance (NV dx, NV dy)
889 CODE: 878 CODE:
890 RETVAL = pow (dx * dx + dy * dy, 0.5); 879 RETVAL = pow (dx * dx + dy * dy, 0.5);
891 OUTPUT: 880 OUTPUT:
2306 } 2295 }
2307 2296
2308 px = (x + 1) * Th - tex.w; 2297 px = (x + 1) * Th - tex.w;
2309 py = (y + 1) * Tw - tex.h; 2298 py = (y + 1) * Tw - tex.h;
2310 2299
2311 if (expect_false (cell->player == player) && expect_false (z == 2)) 2300 if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2))
2312 { 2301 {
2313 pl_x = px; 2302 pl_x = px;
2314 pl_y = py; 2303 pl_y = py;
2315 pl_tex = tex; 2304 pl_tex = tex;
2316 continue; 2305 continue;
2359 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);
2360 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);
2361 } 2350 }
2362 } 2351 }
2363 2352
2364 if (expect_false (z == 2) && expect_false (cell->flags)) 2353 if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags))
2365 { 2354 {
2366 // overlays such as the speech bubble, probably more to come 2355 // overlays such as the speech bubble, probably more to come
2367 if (cell->flags & 1) 2356 if (cell->flags & 1)
2368 { 2357 {
2369 rc_key_t key_ov = key; 2358 rc_key_t key_ov = key;
2488 mapcell *cell = row->col + (x + mx - row->c0); 2477 mapcell *cell = row->col + (x + mx - row->c0);
2489 2478
2490 int px = x * Tw; 2479 int px = x * Tw;
2491 int py = y * Th; 2480 int py = y * Th;
2492 2481
2493 if (expect_false (cell->player == player)) 2482 if (ecb_expect_false (cell->player == player))
2494 { 2483 {
2495 px += sdx; 2484 px += sdx;
2496 py += sdy; 2485 py += sdy;
2497 } 2486 }
2498 2487

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines