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.279 by root, Thu Oct 2 15:59:40 2008 UTC vs.
Revision 1.284 by elmex, Thu Dec 11 00:17:47 2008 UTC

81#define expect_false(expr) expect ((expr) != 0, 0) 81#define expect_false(expr) expect ((expr) != 0, 0)
82#define expect_true(expr) expect ((expr) != 0, 1) 82#define expect_true(expr) expect ((expr) != 0, 1)
83 83
84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ 84#define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */
85 85
86#define FOW_DARKNESS 32 86#define FOW_DARKNESS 16
87 87
88#define MAP_EXTEND_X 32 88#define MAP_EXTEND_X 32
89#define MAP_EXTEND_Y 512 89#define MAP_EXTEND_Y 512
90 90
91#define MIN_FONT_HEIGHT 10 91#define MIN_FONT_HEIGHT 10
233 int w, h; 233 int w, h;
234 float s, t; 234 float s, t;
235 uint8_t r, g, b, a; 235 uint8_t r, g, b, a;
236 tileid smoothtile; 236 tileid smoothtile;
237 uint8_t smoothlevel; 237 uint8_t smoothlevel;
238 uint8_t unused; /* set to zero on use */
238} maptex; 239} maptex;
239 240
240typedef struct { 241typedef struct {
241 uint32_t player; 242 uint32_t player;
242 tileid tile[3]; 243 tileid tile[3];
1206#if DEBUG 1207#if DEBUG
1207 VALGRIND_DO_LEAK_CHECK; 1208 VALGRIND_DO_LEAK_CHECK;
1208#endif 1209#endif
1209} 1210}
1210 1211
1212int
1213SvREFCNT (SV *sv)
1214 CODE:
1215 RETVAL = SvREFCNT (sv);
1216 OUTPUT:
1217 RETVAL
1218
1211MODULE = Deliantra::Client PACKAGE = DC::Font 1219MODULE = Deliantra::Client PACKAGE = DC::Font
1212 1220
1213PROTOTYPES: DISABLE 1221PROTOTYPES: DISABLE
1214 1222
1215DC::Font 1223DC::Font
1759 //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 1767 //glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1760 // use uglier nearest interpolation because linear suffers 1768 // use uglier nearest interpolation because linear suffers
1761 // from transparent color bleeding and ugly wrapping effects. 1769 // from transparent color bleeding and ugly wrapping effects.
1762 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1770 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1763} 1771}
1772
1773void
1774expire_textures (DC::Map self, int texid, int count)
1775 PPCODE:
1776 for (; texid < self->texs && count; ++texid, --count)
1777 {
1778 maptex *tex = self->tex + texid;
1779
1780 if (tex->name)
1781 {
1782 if (tex->unused)
1783 {
1784 tex->name = 0;
1785 tex->unused = 0;
1786 XPUSHs (sv_2mortal (newSViv (texid)));
1787 }
1788 else
1789 tex->unused = 1;
1790 }
1791 }
1764 1792
1765int 1793int
1766ox (DC::Map self) 1794ox (DC::Map self)
1767 ALIAS: 1795 ALIAS:
1768 oy = 1 1796 oy = 1
1889 cell->tile [z] = self->face2tile [face]; 1917 cell->tile [z] = self->face2tile [face];
1890 1918
1891 if (cell->tile [z]) 1919 if (cell->tile [z])
1892 { 1920 {
1893 maptex *tex = self->tex + cell->tile [z]; 1921 maptex *tex = self->tex + cell->tile [z];
1922 tex->unused = 0;
1894 if (!tex->name) 1923 if (!tex->name)
1895 av_push (missing, newSViv (cell->tile [z])); 1924 av_push (missing, newSViv (cell->tile [z]));
1896 1925
1897 if (tex->smoothtile) 1926 if (tex->smoothtile)
1898 { 1927 {
1899 maptex *smooth = self->tex + tex->smoothtile; 1928 maptex *smooth = self->tex + tex->smoothtile;
1929 smooth->unused = 0;
1900 if (!smooth->name) 1930 if (!smooth->name)
1901 av_push (missing, newSViv (tex->smoothtile)); 1931 av_push (missing, newSViv (tex->smoothtile));
1902 } 1932 }
1903 } 1933 }
1904 } 1934 }
1995 key.g = 255; 2025 key.g = 255;
1996 key.b = 255; 2026 key.b = 255;
1997 key.a = 255; 2027 key.a = 255;
1998 key.mode = GL_QUADS; 2028 key.mode = GL_QUADS;
1999 key.format = GL_T2F_V3F; 2029 key.format = GL_T2F_V3F;
2000 key.texname = -1;
2001 2030
2002 mx += self->x; 2031 mx += self->x;
2003 my += self->y; 2032 my += self->y;
2004 2033
2005 // first pass: determine smooth_max 2034 // first pass: determine smooth_max
2029 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 2058 glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
2030 2059
2031 for (z = 0; z <= 2; z++) 2060 for (z = 0; z <= 2; z++)
2032 { 2061 {
2033 memset (smooth_level, 0, sizeof (smooth_level)); 2062 memset (smooth_level, 0, sizeof (smooth_level));
2063 key.texname = -1;
2034 2064
2035 for (y = 0; y < sh; y++) 2065 for (y = 0; y < sh; y++)
2036 if (0 <= y + my && y + my < self->rows) 2066 if (0 <= y + my && y + my < self->rows)
2037 { 2067 {
2038 maprow *row = self->row + (y + my); 2068 maprow *row = self->row + (y + my);
2049 int px = (x + 1) * T - tex.w; 2079 int px = (x + 1) * T - tex.w;
2050 int py = (y + 1) * T - tex.h; 2080 int py = (y + 1) * T - tex.h;
2051 2081
2052 if (key.texname != tex.name) 2082 if (key.texname != tex.name)
2053 { 2083 {
2084 self->tex [tile].unused = 0;
2085
2054 if (!tex.name) 2086 if (!tex.name)
2055 tex = self->tex [2]; /* missing, replace by noface */ 2087 tex = self->tex [2]; /* missing, replace by noface */
2056 2088
2057 key.texname = tex.name; 2089 key.texname = tex.name;
2058 arr = rc_array (rc, &key); 2090 arr = rc_array (rc, &key);
2071 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); 2103 rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0);
2072 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); 2104 rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0);
2073 2105
2074 if (expect_false (cell->flags) && expect_false (z == 2)) 2106 if (expect_false (cell->flags) && expect_false (z == 2))
2075 { 2107 {
2108 /* this is a workaround to make speech bubbles drawn
2109 * for example above walls, work. */
2110 rc_draw (rc);
2111 rc_clear (rc);
2112 key.texname = -1;
2113
2076 // overlays such as the speech bubble, probably more to come 2114 // overlays such as the speech bubble, probably more to come
2077 if (cell->flags & 1) 2115 if (cell->flags & 1)
2078 { 2116 {
2079 maptex tex = self->tex [1]; 2117 maptex tex = self->tex [1];
2080 int px = x * T + T * 2 / 32; 2118 int px = x * T + T * 2 / 32;
2180 { 2218 {
2181 // this time avoiding texture state changes 2219 // this time avoiding texture state changes
2182 // save gobs of state changes. 2220 // save gobs of state changes.
2183 if (key.texname != tex.name) 2221 if (key.texname != tex.name)
2184 { 2222 {
2223 self->tex [skey->tile].unused = 0;
2224
2185 glEnd (); 2225 glEnd ();
2186 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); 2226 glBindTexture (GL_TEXTURE_2D, key.texname = tex.name);
2187 glBegin (GL_QUADS); 2227 glBegin (GL_QUADS);
2188 } 2228 }
2189 2229

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines