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.220 by root, Thu Aug 9 11:02:08 2007 UTC vs.
Revision 1.222 by root, Sat Aug 11 06:34:26 2007 UTC

17#include "perl.h" 17#include "perl.h"
18#include "XSUB.h" 18#include "XSUB.h"
19 19
20#ifdef _WIN32 20#ifdef _WIN32
21# undef pipe 21# undef pipe
22// microsoft vs. C
23# define sqrtf(x) sqrt(x)
24# define roundf(x) (int)(x)
25# define atan2f(x,y) atan2(x,y)
26# define M_PI 3.14159265f
22#endif 27#endif
23 28
24#include <assert.h> 29#include <assert.h>
25#include <math.h> 30#include <math.h>
26#include <string.h> 31#include <string.h>
1550 self->rows += MAP_EXTEND_Y; 1555 self->rows += MAP_EXTEND_Y;
1551 self->y += MAP_EXTEND_Y; 1556 self->y += MAP_EXTEND_Y;
1552 } 1557 }
1553} 1558}
1554 1559
1555void 1560SV *
1556map1a_update (CFPlus::Map self, SV *data_, int extmap) 1561map1a_update (CFPlus::Map self, SV *data_, int extmap)
1557 CODE: 1562 CODE:
1558{ 1563{
1559 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1564 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1560 uint8_t *data_end = (uint8_t *)SvEND (data_); 1565 uint8_t *data_end = (uint8_t *)SvEND (data_);
1561 mapcell *cell; 1566 mapcell *cell;
1562 int x, y, flags; 1567 int x, y, z, flags;
1568 AV *missing = newAV ();
1569 RETVAL = newRV_noinc ((SV *)missing);
1563 1570
1564 while (data < data_end - 1) 1571 while (data < data_end - 1)
1565 { 1572 {
1566 flags = (data [0] << 8) + data [1]; data += 2; 1573 flags = (data [0] << 8) + data [1]; data += 2;
1567 1574
1618 } 1625 }
1619 else 1626 else
1620 cell->darkness = *data++ + 1; 1627 cell->darkness = *data++ + 1;
1621 } 1628 }
1622 1629
1630 for (z = 0; z <= 2; ++z)
1623 if (flags & 4) 1631 if (flags & (4 >> z))
1624 { 1632 {
1625 faceid face = (data [0] << 8) + data [1]; data += 2; 1633 faceid face = (data [0] << 8) + data [1]; data += 2;
1626 need_facenum (self, face); 1634 need_facenum (self, face);
1627 cell->tile [0] = self->face2tile [face]; 1635 cell->tile [z] = self->face2tile [face];
1636
1637 if (cell->tile [z])
1638 {
1639 maptex *tex = self->tex + cell->tile [z];
1640 if (!tex->name)
1641 av_push (missing, newSViv (cell->tile [z]));
1642
1643 if (tex->smoothtile)
1644 {
1645 maptex *smooth = self->tex + tex->smoothtile;
1646 if (!smooth->name)
1647 av_push (missing, newSViv (tex->smoothtile));
1648 }
1649 }
1628 } 1650 }
1629
1630 if (flags & 2)
1631 {
1632 faceid face = (data [0] << 8) + data [1]; data += 2;
1633 need_facenum (self, face);
1634 cell->tile [1] = self->face2tile [face];
1635 }
1636
1637 if (flags & 1)
1638 {
1639 faceid face = (data [0] << 8) + data [1]; data += 2;
1640 need_facenum (self, face);
1641 cell->tile [2] = self->face2tile [face];
1642 }
1643 } 1651 }
1644 else 1652 else
1645 cell->darkness = 0; 1653 cell->darkness = 0;
1646 } 1654 }
1647} 1655}
1656 OUTPUT:
1657 RETVAL
1648 1658
1649SV * 1659SV *
1650mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1660mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1651 CODE: 1661 CODE:
1652{ 1662{
1699 RETVAL = map_sv; 1709 RETVAL = map_sv;
1700} 1710}
1701 OUTPUT: 1711 OUTPUT:
1702 RETVAL 1712 RETVAL
1703 1713
1704SV * 1714void
1705draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) 1715draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T)
1706 CODE: 1716 CODE:
1707{ 1717{
1708 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1718 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1709 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 1719 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
1710 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) 1720 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k)
1711 smooth_key skey; 1721 smooth_key skey;
1712 int x, y, z; 1722 int x, y, z;
1713 int last_name; 1723 int last_name;
1714 AV *missing = newAV ();
1715 RETVAL = newRV_noinc ((SV *)missing);
1716 1724
1717 // thats current max. sorry. 1725 // thats current max. sorry.
1718 if (sw > 255) sw = 255; 1726 if (sw > 255) sw = 255;
1719 if (sh > 255) sh = 255; 1727 if (sh > 255) sh = 255;
1720 1728
1780 // suppressing texture state switches here 1788 // suppressing texture state switches here
1781 // is only moderately effective, but worth the extra effort 1789 // is only moderately effective, but worth the extra effort
1782 if (last_name != tex.name) 1790 if (last_name != tex.name)
1783 { 1791 {
1784 if (!tex.name) 1792 if (!tex.name)
1785 {
1786 av_push (missing, newSViv (tile));
1787 tex = self->tex [2]; /* missing, replace by noface */ 1793 tex = self->tex [2]; /* missing, replace by noface */
1788 }
1789 1794
1790 glEnd (); 1795 glEnd ();
1791 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1796 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1792 glBegin (GL_QUADS); 1797 glBegin (GL_QUADS);
1793 } 1798 }
1897 // this time naively avoiding texture state changes 1902 // this time naively avoiding texture state changes
1898 // save gobs of state changes. 1903 // save gobs of state changes.
1899 if (last_name != tex.name) 1904 if (last_name != tex.name)
1900 { 1905 {
1901 if (!tex.name) 1906 if (!tex.name)
1902 {
1903 av_push (missing, newSViv (skey->tile));
1904 continue; // smoothing not yet available 1907 continue; // smoothing not yet available
1905 }
1906 1908
1907 glEnd (); 1909 glEnd ();
1908 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1910 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1909 glBegin (GL_QUADS); 1911 glBegin (GL_QUADS);
1910 } 1912 }
1971 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); 1973 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1972 } 1974 }
1973 } 1975 }
1974 } 1976 }
1975} 1977}
1976 OUTPUT:
1977 RETVAL
1978 1978
1979void 1979void
1980draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 1980draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1981 CODE: 1981 CODE:
1982{ 1982{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines