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.334 by root, Mon Nov 19 01:37:28 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)) 82#include "salloc.h"
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 83
90#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
91 85
92/* this is used as fow flag as well, so has to have a different value */ 86/* this is used as fow flag as well, so has to have a different value */
93/* then anything that is computed by incoming darkness */ 87/* then anything that is computed by incoming darkness */
111fast_sv_grow (SV *sv, STRLEN need) 105fast_sv_grow (SV *sv, STRLEN need)
112{ 106{
113 STRLEN len = SvLEN (sv); 107 STRLEN len = SvLEN (sv);
114 STRLEN want = SvCUR (sv) + need; 108 STRLEN want = SvCUR (sv) + need;
115 109
116 if (expect_false (len < want)) 110 if (ecb_expect_false (len < want))
117 { 111 {
118 do 112 do
119 len *= 2; 113 len *= 2;
120 while (len < want); 114 while (len < want);
121 115
255 if (!rect.height) rect.height = 1; 249 if (!rect.height) rect.height = 1;
256 250
257 *w = rect.width; 251 *w = rect.width;
258 *h = rect.height; 252 *h = rect.height;
259} 253}
254
255/////////////////////////////////////////////////////////////////////////////
260 256
261typedef uint16_t tileid; 257typedef uint16_t tileid;
262typedef uint16_t faceid; 258typedef uint16_t faceid;
263 259
264struct maptex 260struct maptex
302static void 298static void
303prepend (T *&ptr, int sze, int inc) 299prepend (T *&ptr, int sze, int inc)
304{ 300{
305 T *p; 301 T *p;
306 302
307 New (0, p, sze + inc, T); 303 Newx (p, inc + sze, T);
308 Zero (p, inc, T); 304 Zero (p, inc, T);
309 Move (ptr, p + inc, sze, T); 305 Move (ptr, p + inc, sze, T);
310 Safefree (ptr); 306 Safefree (ptr);
311 307
312 ptr = p; 308 ptr = p;
459 { 455 {
460 return tile == o.tile && x == o.x && y == o.y && level == o.level; 456 return tile == o.tile && x == o.x && y == o.y && level == o.level;
461 } 457 }
462}; 458};
463 459
464typedef ska::flat_hash_map<smooth_key, IV> smooth_hash; 460typedef ska::flat_hash_map<smooth_key, IV, std::hash<smooth_key>, std::equal_to<smooth_key>, slice_allocator<smooth_key>> smooth_hash;
465 461
466namespace std { 462namespace std {
467 template <> 463 template <>
468 struct hash<smooth_key> 464 struct hash<smooth_key>
469 { 465 {
531 n |= n >> 4; 527 n |= n >> 4;
532 n |= n >> 8; 528 n |= n >> 8;
533 n |= n >> 16; 529 n |= n >> 16;
534 530
535 return n + 1; 531 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} 532}
548 533
549/* SDL should provide this, really. */ 534/* SDL should provide this, really. */
550#define SDLK_MODIFIER_MIN 300 535#define SDLK_MODIFIER_MIN 300
551#define SDLK_MODIFIER_MAX 314 536#define SDLK_MODIFIER_MAX 314
882 867
883NV ceil (NV x) 868NV ceil (NV x)
884 869
885IV minpot (UV n) 870IV minpot (UV n)
886 871
872UV ld32 (UV n)
873 CODE:
874 RETVAL = ecb_ld32 (n);
875 OUTPUT:
876 RETVAL
877
887IV popcount (UV n) 878IV popcount (UV n)
879 CODE:
880 RETVAL = ecb_popcount32 (n);
881 OUTPUT:
882 RETVAL
888 883
889NV distance (NV dx, NV dy) 884NV distance (NV dx, NV dy)
890 CODE: 885 CODE:
891 RETVAL = pow (dx * dx + dy * dy, 0.5); 886 RETVAL = pow (dx * dx + dy * dy, 0.5);
892 OUTPUT: 887 OUTPUT:
2307 } 2302 }
2308 2303
2309 px = (x + 1) * Th - tex.w; 2304 px = (x + 1) * Th - tex.w;
2310 py = (y + 1) * Tw - tex.h; 2305 py = (y + 1) * Tw - tex.h;
2311 2306
2312 if (expect_false (cell->player == player) && expect_false (z == 2)) 2307 if (ecb_expect_false (cell->player == player) && ecb_expect_false (z == 2))
2313 { 2308 {
2314 pl_x = px; 2309 pl_x = px;
2315 pl_y = py; 2310 pl_y = py;
2316 pl_tex = tex; 2311 pl_tex = tex;
2317 continue; 2312 continue;
2360 skey.x = x ; skey.y = y ; smooth_or_bits (smooth, skey, 0x0400); 2355 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); 2356 skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, skey, 0x0800);
2362 } 2357 }
2363 } 2358 }
2364 2359
2365 if (expect_false (z == 2) && expect_false (cell->flags)) 2360 if (ecb_expect_false (z == 2) && ecb_expect_false (cell->flags))
2366 { 2361 {
2367 // overlays such as the speech bubble, probably more to come 2362 // overlays such as the speech bubble, probably more to come
2368 if (cell->flags & 1) 2363 if (cell->flags & 1)
2369 { 2364 {
2370 rc_key_t key_ov = key; 2365 rc_key_t key_ov = key;
2489 mapcell *cell = row->col + (x + mx - row->c0); 2484 mapcell *cell = row->col + (x + mx - row->c0);
2490 2485
2491 int px = x * Tw; 2486 int px = x * Tw;
2492 int py = y * Th; 2487 int py = y * Th;
2493 2488
2494 if (expect_false (cell->player == player)) 2489 if (ecb_expect_false (cell->player == player))
2495 { 2490 {
2496 px += sdx; 2491 px += sdx;
2497 py += sdy; 2492 py += sdy;
2498 } 2493 }
2499 2494

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines