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.177 by root, Tue Apr 10 10:13:10 2007 UTC vs.
Revision 1.186 by root, Sat Apr 21 09:25:31 2007 UTC

345} smooth_key; 345} smooth_key;
346 346
347static void 347static void
348smooth_or_bits (HV *hv, smooth_key *key, IV bits) 348smooth_or_bits (HV *hv, smooth_key *key, IV bits)
349{ 349{
350 SV **sv = hv_fetch (hv, (char *)key, sizeof (key), 1); 350 SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1);
351 351
352 if (SvIOK (*sv)) 352 if (SvIOK (*sv))
353 SvIV_set (*sv, SvIVX (*sv) | bits); 353 SvIV_set (*sv, SvIVX (*sv) | bits);
354 else 354 else
355 sv_setiv (*sv, bits); 355 sv_setiv (*sv, bits);
400 400
401/* SDL should provide this, really. */ 401/* SDL should provide this, really. */
402#define SDLK_MODIFIER_MIN 300 402#define SDLK_MODIFIER_MIN 300
403#define SDLK_MODIFIER_MAX 314 403#define SDLK_MODIFIER_MAX 314
404 404
405static AV *texture_av;
406
405MODULE = CFPlus PACKAGE = CFPlus 407MODULE = CFPlus PACKAGE = CFPlus
406 408
407PROTOTYPES: ENABLE 409PROTOTYPES: ENABLE
408 410
409BOOT: 411BOOT:
410{ 412{
413 texture_av = newAV ();
414 AvREAL_off (texture_av);
415
411 HV *stash = gv_stashpv ("CFPlus", 1); 416 HV *stash = gv_stashpv ("CFPlus", 1);
412 static const struct { 417 static const struct {
413 const char *name; 418 const char *name;
414 IV iv; 419 IV iv;
415 } *civ, const_iv[] = { 420 } *civ, const_iv[] = {
701Mix_AllocateChannels (int numchans = -1) 706Mix_AllocateChannels (int numchans = -1)
702 707
703void 708void
704lowdelay (int fd, int val = 1) 709lowdelay (int fd, int val = 1)
705 CODE: 710 CODE:
706#ifndef _WIN32
707 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); 711 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (void *)&val, sizeof (val));
708#endif
709 712
710void 713void
711win32_proxy_info () 714win32_proxy_info ()
712 PPCODE: 715 PPCODE:
713{ 716{
1462 } 1465 }
1463 else if (cmd == 6) // monster width 1466 else if (cmd == 6) // monster width
1464 cell->stat_width = *data++ + 1; 1467 cell->stat_width = *data++ + 1;
1465 else if (cmd == 0x47) 1468 else if (cmd == 0x47)
1466 { 1469 {
1467 if (*data == 8) 1470 if (*data == 4)
1468 ; // decode player uuid 1471 ; // decode player count
1469 1472
1470 data += *data + 1; 1473 data += *data + 1;
1471 } 1474 }
1472 else if (cmd == 8) // cell flags 1475 else if (cmd == 8) // cell flags
1473 cell->flags = *data++; 1476 cell->flags = *data++;
1567draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) 1570draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T)
1568 CODE: 1571 CODE:
1569{ 1572{
1570 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1573 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1571 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 1574 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
1572 uint8_t smooth_max[256][256]; 1575 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k)
1573 smooth_key skey; 1576 smooth_key skey;
1574 int x, y, z; 1577 int x, y, z;
1575 int last_name; 1578 int last_name;
1576 1579
1577 // thats current max. sorry. 1580 // thats current max. sorry.
1683 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); 1686 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31);
1684 1687
1685 // add bits to current tile and all neighbours. skey.x|y is 1688 // add bits to current tile and all neighbours. skey.x|y is
1686 // shifted +1|+1 so we always stay positive. 1689 // shifted +1|+1 so we always stay positive.
1687 1690
1691 // bits is ___n cccc CCCC bbbb
1692 // n do not draw borders&corners
1693 // c draw these corners, but...
1694 // C ... not these
1695 // b draw these borders
1696
1697 // borders: 1 ┃· 2 ━━ 4 ·┃ 8 ··
1698 // ┃· ·· ·┃ ━━
1699
1700 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ··
1701 // ·· ·· ·┏ ┓·
1702
1688 // full tile 1703 // full tile
1689 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); 1704 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000);
1690 1705
1691 // borders 1706 // borders
1692 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0031); 1707 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091);
1693 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0092); 1708 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032);
1694 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); 1709 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064);
1695 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); 1710 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8);
1696 1711
1697 // corners 1712 // corners
1698 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); 1713 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100);
1702 } 1717 }
1703 } 1718 }
1704 } 1719 }
1705 } 1720 }
1706 1721
1707 // go through all smoothlevels, lowest to highest, then draw 1722 // go through all smoothlevels, lowest to highest, then draw.
1708 // this is basically counting sort 1723 // this is basically counting sort
1709 { 1724 {
1710 int w, b; 1725 int w, b;
1711 1726
1712 for (w = 0; w < 256 / 32; ++w) 1727 for (w = 0; w < 256 / 32; ++w)
1722 hv_iterinit (smooth); 1737 hv_iterinit (smooth);
1723 while ((he = hv_iternext (smooth))) 1738 while ((he = hv_iternext (smooth)))
1724 { 1739 {
1725 smooth_key *skey = (smooth_key *)HeKEY (he); 1740 smooth_key *skey = (smooth_key *)HeKEY (he);
1726 IV bits = SvIVX (HeVAL (he)); 1741 IV bits = SvIVX (HeVAL (he));
1727
1728 // bits is ___n cccc CCCC bbbb
1729 // n do not draw borders&corners
1730 // c draw these corners, but...
1731 // C ... not these
1732 // b draw these borders
1733 1742
1734 if (!(bits & 0x1000) 1743 if (!(bits & 0x1000)
1735 && skey->level == level 1744 && skey->level == level
1736 && level >= smooth_max [skey->x][skey->y]) 1745 && level >= smooth_max [skey->x][skey->y])
1737 { 1746 {
2366 2375
2367int glGenTexture () 2376int glGenTexture ()
2368 CODE: 2377 CODE:
2369{ 2378{
2370 GLuint name; 2379 GLuint name;
2380 if (AvFILL (texture_av) >= 0)
2381 name = (GLuint)av_pop (texture_av);
2382 else
2371 glGenTextures (1, &name); 2383 glGenTextures (1, &name);
2372 RETVAL = name; 2384 RETVAL = name;
2373} 2385}
2374 OUTPUT: 2386 OUTPUT:
2375 RETVAL 2387 RETVAL
2376 2388
2377void glDeleteTexture (int name) 2389void glDeleteTexture (int name)
2378 CODE: 2390 CODE:
2379{ 2391{
2380 GLuint name_ = name; 2392 /* make a half-assed attempt at returning the memory used by the texture */
2393 /* textures are frequently being reused by cfplus anyway */
2394 glBindTexture (GL_TEXTURE_2D, name);
2395 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, 0, 0, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0);
2396 av_push (texture_av, (SV *)name);
2381 glDeleteTextures (1, &name_); 2397 /*glDeleteTextures (1, &name_);*/
2382} 2398}
2383 2399
2384int glGenList () 2400int glGenList ()
2385 CODE: 2401 CODE:
2386 RETVAL = glGenLists (1); 2402 RETVAL = glGenLists (1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines