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.176 by root, Tue Apr 10 09:39:48 2007 UTC vs.
Revision 1.181 by root, Mon Apr 16 21:06:36 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);
701Mix_AllocateChannels (int numchans = -1) 701Mix_AllocateChannels (int numchans = -1)
702 702
703void 703void
704lowdelay (int fd, int val = 1) 704lowdelay (int fd, int val = 1)
705 CODE: 705 CODE:
706#ifndef _WIN32
707 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); 706 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (void *)&val, sizeof (val));
708#endif
709 707
710void 708void
711win32_proxy_info () 709win32_proxy_info ()
712 PPCODE: 710 PPCODE:
713{ 711{
1567draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) 1565draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T)
1568 CODE: 1566 CODE:
1569{ 1567{
1570 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1568 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1571 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 1569 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
1572 uint8_t smooth_max[256][256]; 1570 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k)
1573 smooth_key skey; 1571 smooth_key skey;
1574 int x, y, z; 1572 int x, y, z;
1575 int last_name; 1573 int last_name;
1576 1574
1577 // thats current max. sorry. 1575 // thats current max. sorry.
1608 for (x = 0; x < sw; x++) 1606 for (x = 0; x < sw; x++)
1609 if (row->c0 <= x + mx && x + mx < row->c1) 1607 if (row->c0 <= x + mx && x + mx < row->c1)
1610 { 1608 {
1611 mapcell *cell = row->col + (x + mx - row->c0); 1609 mapcell *cell = row->col + (x + mx - row->c0);
1612 1610
1613 for (z = 0; z <= 2; z++)
1614 {
1615 uint8_t level = self->tex [cell->tile [z]].smoothlevel;
1616 if (level > smooth_max [x + 1][y + 1])
1617 smooth_max [x + 1][y + 1] = level; 1611 smooth_max[x + 1][y + 1] =
1618 } 1612 MAX (self->tex [cell->tile [0]].smoothlevel,
1613 MAX (self->tex [cell->tile [1]].smoothlevel,
1614 self->tex [cell->tile [2]].smoothlevel));
1619 } 1615 }
1620 } 1616 }
1621 1617
1622 for (z = 0; z <= 2; z++) 1618 for (z = 0; z <= 2; z++)
1623 { 1619 {
1685 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); 1681 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31);
1686 1682
1687 // add bits to current tile and all neighbours. skey.x|y is 1683 // add bits to current tile and all neighbours. skey.x|y is
1688 // shifted +1|+1 so we always stay positive. 1684 // shifted +1|+1 so we always stay positive.
1689 1685
1686 // bits is ___n cccc CCCC bbbb
1687 // n do not draw borders&corners
1688 // c draw these corners, but...
1689 // C ... not these
1690 // b draw these borders
1691
1692 // borders: 1 ┃· 2 ━━ 4 ·┃ 8 ··
1693 // ┃· ·· ·┃ ━━
1694
1695 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ··
1696 // ·· ·· ·┏ ┓·
1697
1690 // full tile 1698 // full tile
1691 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); 1699 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000);
1692 1700
1693 // borders 1701 // borders
1694 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0031); 1702 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091);
1695 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0092); 1703 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032);
1696 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); 1704 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064);
1697 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); 1705 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8);
1698 1706
1699 // corners 1707 // corners
1700 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); 1708 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100);
1704 } 1712 }
1705 } 1713 }
1706 } 1714 }
1707 } 1715 }
1708 1716
1709 // go through all smoothlevels, lowest to highest, then draw 1717 // go through all smoothlevels, lowest to highest, then draw.
1710 // this is basically counting sort 1718 // this is basically counting sort
1711 { 1719 {
1712 int w, b; 1720 int w, b;
1713 1721
1714 for (w = 0; w < 256 / 32; ++w) 1722 for (w = 0; w < 256 / 32; ++w)
1724 hv_iterinit (smooth); 1732 hv_iterinit (smooth);
1725 while ((he = hv_iternext (smooth))) 1733 while ((he = hv_iternext (smooth)))
1726 { 1734 {
1727 smooth_key *skey = (smooth_key *)HeKEY (he); 1735 smooth_key *skey = (smooth_key *)HeKEY (he);
1728 IV bits = SvIVX (HeVAL (he)); 1736 IV bits = SvIVX (HeVAL (he));
1729
1730 // bits is ___n cccc CCCC bbbb
1731 // n do not draw borders&corners
1732 // c draw these corners, but...
1733 // C ... not these
1734 // b draw these borders
1735 1737
1736 if (!(bits & 0x1000) 1738 if (!(bits & 0x1000)
1737 && skey->level == level 1739 && skey->level == level
1738 && level >= smooth_max [skey->x][skey->y]) 1740 && level >= smooth_max [skey->x][skey->y])
1739 { 1741 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines