… | |
… | |
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 | |
240 | typedef struct { |
241 | typedef struct { |
241 | uint32_t player; |
242 | uint32_t player; |
242 | tileid tile[3]; |
243 | tileid tile[3]; |
… | |
… | |
528 | if (!svp || !SvTRUE (*svp)) |
529 | if (!svp || !SvTRUE (*svp)) |
529 | return 0; |
530 | return 0; |
530 | |
531 | |
531 | return 1; |
532 | return 1; |
532 | } |
533 | } |
|
|
534 | |
|
|
535 | /******************************************************************************/ |
533 | |
536 | |
534 | /* process keyboard modifiers */ |
537 | /* process keyboard modifiers */ |
535 | static int |
538 | static int |
536 | mod_munge (int mod) |
539 | mod_munge (int mod) |
537 | { |
540 | { |
… | |
… | |
1204 | #if DEBUG |
1207 | #if DEBUG |
1205 | VALGRIND_DO_LEAK_CHECK; |
1208 | VALGRIND_DO_LEAK_CHECK; |
1206 | #endif |
1209 | #endif |
1207 | } |
1210 | } |
1208 | |
1211 | |
|
|
1212 | int |
|
|
1213 | SvREFCNT (SV *sv) |
|
|
1214 | CODE: |
|
|
1215 | RETVAL = SvREFCNT (sv); |
|
|
1216 | OUTPUT: |
|
|
1217 | RETVAL |
|
|
1218 | |
1209 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1219 | MODULE = Deliantra::Client PACKAGE = DC::Font |
1210 | |
1220 | |
1211 | PROTOTYPES: DISABLE |
1221 | PROTOTYPES: DISABLE |
1212 | |
1222 | |
1213 | DC::Font |
1223 | DC::Font |
… | |
… | |
1757 | //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); |
1758 | // use uglier nearest interpolation because linear suffers |
1768 | // use uglier nearest interpolation because linear suffers |
1759 | // from transparent color bleeding and ugly wrapping effects. |
1769 | // from transparent color bleeding and ugly wrapping effects. |
1760 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1770 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
1761 | } |
1771 | } |
|
|
1772 | |
|
|
1773 | void |
|
|
1774 | expire_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 | } |
1762 | |
1792 | |
1763 | int |
1793 | int |
1764 | ox (DC::Map self) |
1794 | ox (DC::Map self) |
1765 | ALIAS: |
1795 | ALIAS: |
1766 | oy = 1 |
1796 | oy = 1 |
… | |
… | |
1887 | cell->tile [z] = self->face2tile [face]; |
1917 | cell->tile [z] = self->face2tile [face]; |
1888 | |
1918 | |
1889 | if (cell->tile [z]) |
1919 | if (cell->tile [z]) |
1890 | { |
1920 | { |
1891 | maptex *tex = self->tex + cell->tile [z]; |
1921 | maptex *tex = self->tex + cell->tile [z]; |
|
|
1922 | tex->unused = 0; |
1892 | if (!tex->name) |
1923 | if (!tex->name) |
1893 | av_push (missing, newSViv (cell->tile [z])); |
1924 | av_push (missing, newSViv (cell->tile [z])); |
1894 | |
1925 | |
1895 | if (tex->smoothtile) |
1926 | if (tex->smoothtile) |
1896 | { |
1927 | { |
1897 | maptex *smooth = self->tex + tex->smoothtile; |
1928 | maptex *smooth = self->tex + tex->smoothtile; |
|
|
1929 | smooth->unused = 0; |
1898 | if (!smooth->name) |
1930 | if (!smooth->name) |
1899 | av_push (missing, newSViv (tex->smoothtile)); |
1931 | av_push (missing, newSViv (tex->smoothtile)); |
1900 | } |
1932 | } |
1901 | } |
1933 | } |
1902 | } |
1934 | } |
… | |
… | |
1993 | key.g = 255; |
2025 | key.g = 255; |
1994 | key.b = 255; |
2026 | key.b = 255; |
1995 | key.a = 255; |
2027 | key.a = 255; |
1996 | key.mode = GL_QUADS; |
2028 | key.mode = GL_QUADS; |
1997 | key.format = GL_T2F_V3F; |
2029 | key.format = GL_T2F_V3F; |
1998 | key.texname = -1; |
|
|
1999 | |
2030 | |
2000 | mx += self->x; |
2031 | mx += self->x; |
2001 | my += self->y; |
2032 | my += self->y; |
2002 | |
2033 | |
2003 | // first pass: determine smooth_max |
2034 | // first pass: determine smooth_max |
… | |
… | |
2027 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2058 | glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
2028 | |
2059 | |
2029 | for (z = 0; z <= 2; z++) |
2060 | for (z = 0; z <= 2; z++) |
2030 | { |
2061 | { |
2031 | memset (smooth_level, 0, sizeof (smooth_level)); |
2062 | memset (smooth_level, 0, sizeof (smooth_level)); |
|
|
2063 | key.texname = -1; |
2032 | |
2064 | |
2033 | for (y = 0; y < sh; y++) |
2065 | for (y = 0; y < sh; y++) |
2034 | if (0 <= y + my && y + my < self->rows) |
2066 | if (0 <= y + my && y + my < self->rows) |
2035 | { |
2067 | { |
2036 | maprow *row = self->row + (y + my); |
2068 | maprow *row = self->row + (y + my); |
… | |
… | |
2047 | int px = (x + 1) * T - tex.w; |
2079 | int px = (x + 1) * T - tex.w; |
2048 | int py = (y + 1) * T - tex.h; |
2080 | int py = (y + 1) * T - tex.h; |
2049 | |
2081 | |
2050 | if (key.texname != tex.name) |
2082 | if (key.texname != tex.name) |
2051 | { |
2083 | { |
|
|
2084 | self->tex [tile].unused = 0; |
|
|
2085 | |
2052 | if (!tex.name) |
2086 | if (!tex.name) |
2053 | tex = self->tex [2]; /* missing, replace by noface */ |
2087 | tex = self->tex [2]; /* missing, replace by noface */ |
2054 | |
2088 | |
2055 | key.texname = tex.name; |
2089 | key.texname = tex.name; |
2056 | arr = rc_array (rc, &key); |
2090 | arr = rc_array (rc, &key); |
… | |
… | |
2069 | 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); |
2070 | 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); |
2071 | |
2105 | |
2072 | if (expect_false (cell->flags) && expect_false (z == 2)) |
2106 | if (expect_false (cell->flags) && expect_false (z == 2)) |
2073 | { |
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 | |
2074 | // overlays such as the speech bubble, probably more to come |
2114 | // overlays such as the speech bubble, probably more to come |
2075 | if (cell->flags & 1) |
2115 | if (cell->flags & 1) |
2076 | { |
2116 | { |
2077 | maptex tex = self->tex [1]; |
2117 | maptex tex = self->tex [1]; |
2078 | int px = x * T + T * 2 / 32; |
2118 | int px = x * T + T * 2 / 32; |
… | |
… | |
2178 | { |
2218 | { |
2179 | // this time avoiding texture state changes |
2219 | // this time avoiding texture state changes |
2180 | // save gobs of state changes. |
2220 | // save gobs of state changes. |
2181 | if (key.texname != tex.name) |
2221 | if (key.texname != tex.name) |
2182 | { |
2222 | { |
|
|
2223 | self->tex [skey->tile].unused = 0; |
|
|
2224 | |
2183 | glEnd (); |
2225 | glEnd (); |
2184 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2226 | glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); |
2185 | glBegin (GL_QUADS); |
2227 | glBegin (GL_QUADS); |
2186 | } |
2228 | } |
2187 | |
2229 | |
… | |
… | |
2249 | { |
2291 | { |
2250 | mapcell *cell = row->col + (x + mx - row->c0); |
2292 | mapcell *cell = row->col + (x + mx - row->c0); |
2251 | |
2293 | |
2252 | int px = x * T; |
2294 | int px = x * T; |
2253 | int py = y * T; |
2295 | int py = y * T; |
|
|
2296 | |
|
|
2297 | if (expect_false (cell->player == player)) |
|
|
2298 | { |
|
|
2299 | px += sdx; |
|
|
2300 | py += sdy; |
|
|
2301 | } |
2254 | |
2302 | |
2255 | if (cell->stat_hp) |
2303 | if (cell->stat_hp) |
2256 | { |
2304 | { |
2257 | int width = cell->stat_width * T; |
2305 | int width = cell->stat_width * T; |
2258 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
2306 | int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width; |
… | |
… | |
2999 | void glRotate (float angle, float x, float y, float z) |
3047 | void glRotate (float angle, float x, float y, float z) |
3000 | CODE: |
3048 | CODE: |
3001 | glRotatef (angle, x, y, z); |
3049 | glRotatef (angle, x, y, z); |
3002 | |
3050 | |
3003 | void glColor (float r, float g, float b, float a = 1.0) |
3051 | void glColor (float r, float g, float b, float a = 1.0) |
|
|
3052 | PROTOTYPE: @ |
3004 | ALIAS: |
3053 | ALIAS: |
3005 | glColor_premultiply = 1 |
3054 | glColor_premultiply = 1 |
3006 | CODE: |
3055 | CODE: |
3007 | if (ix) |
3056 | if (ix) |
3008 | { |
3057 | { |