--- deliantra/Deliantra-Client/Client.xs 2006/08/04 16:49:58 1.134 +++ deliantra/Deliantra-Client/Client.xs 2006/08/18 02:23:39 1.143 @@ -146,12 +146,19 @@ static void layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) { - pango_layout_get_pixel_size (self->pl, w, h); + PangoRectangle rect; - if (!*w) *w = 1; - if (!*h) *h = 1; + // get_pixel_* wrongly rounds down + pango_layout_get_extents (self->pl, 0, &rect); - *w = (*w + 3) & ~3; + rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE; + rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; + + if (!rect.width) rect.width = 1; + if (!rect.height) rect.height = 1; + + *w = rect.width; + *h = rect.height; } typedef uint16_t mapface; @@ -164,8 +171,9 @@ } maptex; typedef struct { - int16_t darkness; + uint16_t darkness; mapface face[3]; + uint8_t stat_hp; } mapcell; typedef struct { @@ -303,7 +311,7 @@ if (x >= row->c1) break; - row->col[x - row->c0].darkness = -1; + row->col[x - row->c0].darkness = 0; } } } @@ -1027,12 +1035,13 @@ } void -render (CFPlus::Layout self, float x, float y) +render (CFPlus::Layout self, float x, float y, int flags = 0) PPCODE: pango_opengl_render_layout_subpixel ( self->pl, x * PANGO_SCALE, y * PANGO_SCALE, - self->r, self->g, self->b, self->a + self->r, self->g, self->b, self->a, + flags ); MODULE = CFPlus PACKAGE = CFPlus::Texture @@ -1254,7 +1263,7 @@ } void -map1a_update (CFPlus::Map self, SV *data_) +map1a_update (CFPlus::Map self, SV *data_, int extmap) CODE: { uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); @@ -1273,18 +1282,39 @@ if (flags & 15) { - if (cell->darkness < 0) + if (!cell->darkness) { - cell->darkness = 0; + cell->darkness = 256; cell->face [0] = 0; cell->face [1] = 0; cell->face [2] = 0; + cell->stat_hp = 0; } - cell->darkness = flags & 8 ? *data++ : 255; - //TODO: don't trust server data to be in-range(!) + if (flags & 8) + { + if (extmap) + { + uint8_t ext, cmd; + + do + { + ext = *data++; + cmd = ext & 0x7f; + + if (ext < 4) + cell->darkness = 255 - ext * 64 + 1; + else if (ext == 5) // health + cell->stat_hp = *data++; + } + while (cmd & 0x80); + } + else + cell->darkness = *data++ + 1; + } + if (flags & 4) { cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; @@ -1301,7 +1331,7 @@ } } else - cell->darkness = -1; + cell->darkness = 0; } } @@ -1438,6 +1468,33 @@ glDisable (GL_TEXTURE_2D); glDisable (GL_BLEND); + + for (y = 0; y < sh; y++) + if (0 <= y + vy && y + vy < self->rows) + { + maprow *row = self->row + (y + vy); + + for (x = 0; x < sw; x++) + if (row->c0 <= x + vx && x + vx < row->c1) + { + mapcell *cell = row->col + (x + vx - row->c0); + + int px = x * 32; + int py = y * 32; + + if (cell->stat_hp) + { + glColor3ub (0, 0, 0); + glRectf (px + 1, py + 1, px + 31, py + 4); + + glColor3ub (0, 255, 0); + glBegin (GL_LINES); + glVertex2f (px + 2, py + 2.5f); + glVertex2f (px + 29.f - cell->stat_hp * (28.f / 255.f), py + 2.5f); + glEnd (); + } + } + } } void @@ -1527,9 +1584,9 @@ { mapcell *cell = row->col + (x + vx - row->c0); - darkness[y * sw4 + x] = cell->darkness < 0 - ? 255 - FOW_DARKNESS - : 255 - cell->darkness; + darkness[y * sw4 + x] = cell->darkness + ? 255 - (cell->darkness - 1) + : 255 - FOW_DARKNESS; } } @@ -1654,9 +1711,9 @@ if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } - if (cell->darkness <= 0) + if (cell->darkness == 0) { - cell->darkness = -1; + cell->darkness = 0; for (z = 0; z <= 2; z++) { @@ -1804,6 +1861,7 @@ const_iv (GL_CONVOLUTION_BORDER_MODE), const_iv (GL_CONSTANT_BORDER), const_iv (GL_LINES), + const_iv (GL_LINE_STRIP), const_iv (GL_LINE_LOOP), const_iv (GL_QUADS), const_iv (GL_QUAD_STRIP), @@ -2010,4 +2068,3 @@ void glCallList (int list) -