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.218 by root, Mon Aug 6 02:11:45 2007 UTC vs.
Revision 1.219 by root, Mon Aug 6 05:06:32 2007 UTC

1350 HV *hv = (HV *)SvRV (self); 1350 HV *hv = (HV *)SvRV (self);
1351 float s = SvNV (*hv_fetch (hv, "s", 1, 1)); 1351 float s = SvNV (*hv_fetch (hv, "s", 1, 1));
1352 float t = SvNV (*hv_fetch (hv, "t", 1, 1)); 1352 float t = SvNV (*hv_fetch (hv, "t", 1, 1));
1353 int name = SvIV (*hv_fetch (hv, "name", 4, 1)); 1353 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
1354 1354
1355 if (name <= 0)
1356 XSRETURN_EMPTY;
1357
1355 if (items < 5) 1358 if (items < 5)
1356 { 1359 {
1357 w = SvNV (*hv_fetch (hv, "w", 1, 1)); 1360 w = SvNV (*hv_fetch (hv, "w", 1, 1));
1358 h = SvNV (*hv_fetch (hv, "h", 1, 1)); 1361 h = SvNV (*hv_fetch (hv, "h", 1, 1));
1359 } 1362 }
1696 RETVAL = map_sv; 1699 RETVAL = map_sv;
1697} 1700}
1698 OUTPUT: 1701 OUTPUT:
1699 RETVAL 1702 RETVAL
1700 1703
1701void 1704SV *
1702draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T) 1705draw (CFPlus::Map self, int mx, int my, int sw, int sh, int T)
1703 CODE: 1706 CODE:
1704{ 1707{
1705 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ()); 1708 HV *smooth = (HV *)sv_2mortal ((SV *)newHV ());
1706 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level 1709 uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level
1707 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k) 1710 static uint8_t smooth_max[256][256]; // egad, fats and wasteful on memory (64k)
1708 smooth_key skey; 1711 smooth_key skey;
1709 int x, y, z; 1712 int x, y, z;
1710 int last_name; 1713 int last_name;
1714 AV *missing = newAV ();
1715 RETVAL = newRV_noinc ((SV *)missing);
1711 1716
1712 // thats current max. sorry. 1717 // thats current max. sorry.
1713 if (sw > 255) sw = 255; 1718 if (sw > 255) sw = 255;
1714 if (sh > 255) sh = 255; 1719 if (sh > 255) sh = 255;
1715 1720
1723 glEnable (GL_TEXTURE_2D); 1728 glEnable (GL_TEXTURE_2D);
1724 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 1729 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1725 1730
1726 glBegin (GL_QUADS); 1731 glBegin (GL_QUADS);
1727 1732
1728 last_name = 0; 1733 last_name = -1;
1729 1734
1730 mx += self->x; 1735 mx += self->x;
1731 my += self->y; 1736 my += self->y;
1732 1737
1733 // first pass: determine smooth_max 1738 // first pass: determine smooth_max
1768 tileid tile = cell->tile [z]; 1773 tileid tile = cell->tile [z];
1769 1774
1770 if (tile) 1775 if (tile)
1771 { 1776 {
1772 maptex tex = self->tex [tile]; 1777 maptex tex = self->tex [tile];
1773 int px = (x + 1) * T - tex.w; 1778 int px, py;
1774 int py = (y + 1) * T - tex.h;
1775 1779
1776 // suppressing texture state switches here 1780 // suppressing texture state switches here
1777 // is only moderately effective, but worth the extra effort 1781 // is only moderately effective, but worth the extra effort
1778 if (last_name != tex.name) 1782 if (last_name != tex.name)
1779 { 1783 {
1780 if (!tex.name) 1784 if (!tex.name)
1785 {
1786 av_push (missing, newSViv (tile));
1781 tex = self->tex [2]; /* missing, replace by noface */ 1787 tex = self->tex [2]; /* missing, replace by noface */
1788 }
1782 1789
1783 glEnd (); 1790 glEnd ();
1784 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1791 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1785 glBegin (GL_QUADS); 1792 glBegin (GL_QUADS);
1786 } 1793 }
1794
1795 px = (x + 1) * T - tex.w;
1796 py = (y + 1) * T - tex.h;
1787 1797
1788 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1798 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1789 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); 1799 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1790 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); 1800 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1791 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); 1801 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1887 // this time naively avoiding texture state changes 1897 // this time naively avoiding texture state changes
1888 // save gobs of state changes. 1898 // save gobs of state changes.
1889 if (last_name != tex.name) 1899 if (last_name != tex.name)
1890 { 1900 {
1891 if (!tex.name) 1901 if (!tex.name)
1902 {
1903 av_push (missing, newSViv (skey->tile));
1892 continue; // smoothing not yet available 1904 continue; // smoothing not yet available
1905 }
1893 1906
1894 glEnd (); 1907 glEnd ();
1895 glBindTexture (GL_TEXTURE_2D, last_name = tex.name); 1908 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1896 glBegin (GL_QUADS); 1909 glBegin (GL_QUADS);
1897 } 1910 }
1958 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1); 1971 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1959 } 1972 }
1960 } 1973 }
1961 } 1974 }
1962} 1975}
1976 OUTPUT:
1977 RETVAL
1963 1978
1964void 1979void
1965draw_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)
1966 CODE: 1981 CODE:
1967{ 1982{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines