--- deliantra/Deliantra-Client/Client.xs 2008/09/01 06:18:09 1.277 +++ deliantra/Deliantra-Client/Client.xs 2008/12/11 00:17:47 1.284 @@ -83,7 +83,7 @@ #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ -#define FOW_DARKNESS 32 +#define FOW_DARKNESS 16 #define MAP_EXTEND_X 32 #define MAP_EXTEND_Y 512 @@ -235,6 +235,7 @@ uint8_t r, g, b, a; tileid smoothtile; uint8_t smoothlevel; + uint8_t unused; /* set to zero on use */ } maptex; typedef struct { @@ -1208,6 +1209,13 @@ #endif } +int +SvREFCNT (SV *sv) + CODE: + RETVAL = SvREFCNT (sv); + OUTPUT: + RETVAL + MODULE = Deliantra::Client PACKAGE = DC::Font PROTOTYPES: DISABLE @@ -1762,6 +1770,26 @@ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } +void +expire_textures (DC::Map self, int texid, int count) + PPCODE: + for (; texid < self->texs && count; ++texid, --count) + { + maptex *tex = self->tex + texid; + + if (tex->name) + { + if (tex->unused) + { + tex->name = 0; + tex->unused = 0; + XPUSHs (sv_2mortal (newSViv (texid))); + } + else + tex->unused = 1; + } + } + int ox (DC::Map self) ALIAS: @@ -1891,12 +1919,14 @@ if (cell->tile [z]) { maptex *tex = self->tex + cell->tile [z]; + tex->unused = 0; if (!tex->name) av_push (missing, newSViv (cell->tile [z])); if (tex->smoothtile) { maptex *smooth = self->tex + tex->smoothtile; + smooth->unused = 0; if (!smooth->name) av_push (missing, newSViv (tex->smoothtile)); } @@ -1997,7 +2027,6 @@ key.a = 255; key.mode = GL_QUADS; key.format = GL_T2F_V3F; - key.texname = -1; mx += self->x; my += self->y; @@ -2031,6 +2060,7 @@ for (z = 0; z <= 2; z++) { memset (smooth_level, 0, sizeof (smooth_level)); + key.texname = -1; for (y = 0; y < sh; y++) if (0 <= y + my && y + my < self->rows) @@ -2051,6 +2081,8 @@ if (key.texname != tex.name) { + self->tex [tile].unused = 0; + if (!tex.name) tex = self->tex [2]; /* missing, replace by noface */ @@ -2073,6 +2105,12 @@ if (expect_false (cell->flags) && expect_false (z == 2)) { + /* this is a workaround to make speech bubbles drawn + * for example above walls, work. */ + rc_draw (rc); + rc_clear (rc); + key.texname = -1; + // overlays such as the speech bubble, probably more to come if (cell->flags & 1) { @@ -2182,6 +2220,8 @@ // save gobs of state changes. if (key.texname != tex.name) { + self->tex [skey->tile].unused = 0; + glEnd (); glBindTexture (GL_TEXTURE_2D, key.texname = tex.name); glBegin (GL_QUADS); @@ -2254,6 +2294,12 @@ int px = x * T; int py = y * T; + if (expect_false (cell->player == player)) + { + px += sdx; + py += sdy; + } + if (cell->stat_hp) { int width = cell->stat_width * T; @@ -3003,6 +3049,7 @@ glRotatef (angle, x, y, z); void glColor (float r, float g, float b, float a = 1.0) + PROTOTYPE: @ ALIAS: glColor_premultiply = 1 CODE: