--- deliantra/Deliantra-Client/Client.xs 2006/06/14 18:59:30 1.115 +++ deliantra/Deliantra-Client/Client.xs 2006/06/15 08:29:16 1.116 @@ -438,6 +438,10 @@ newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); } +NV floor (NV x) + +NV ceil (NV x) + void pango_init () CODE: @@ -675,7 +679,7 @@ SDL_LockSurface (surface2); PUSHs (sv_2mortal (newSVpvn (surface2->pixels, surface2->h * surface2->pitch))); SDL_UnlockSurface (surface2); - PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA8 : GL_RGB8))); + PUSHs (sv_2mortal (newSViv (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA) ? GL_RGBA : GL_RGB))); PUSHs (sv_2mortal (newSViv (GL_RGBA))); PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); @@ -969,7 +973,7 @@ PUSHs (sv_2mortal (newSViv (w))); PUSHs (sv_2mortal (newSViv (h))); PUSHs (sv_2mortal (retval)); - PUSHs (sv_2mortal (newSViv (GL_RGBA8))); + PUSHs (sv_2mortal (newSViv (GL_RGBA))); PUSHs (sv_2mortal (newSViv (GL_RGBA))); } else @@ -1332,22 +1336,15 @@ void draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) - PPCODE: + CODE: { int vx, vy; int x, y, z; int last_name; mapface face; - int sw4 = (sw + 3) & ~3; - SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); - uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); - memset (darkness, 255, sw4 * sh); - SvPOK_only (darkness_sv); - SvCUR_set (darkness_sv, sw4 * sh); - - vx = self->x + (self->w - sw) / 2 - shift_x; - vy = self->y + (self->h - sh) / 2 - shift_y; + vx = self->x + (self->w - sw + 1) / 2 - shift_x; + vy = self->y + (self->h - sh + 1) / 2 - shift_y; /* int vx = self->vx = self->w >= sw @@ -1381,10 +1378,6 @@ { mapcell *cell = row->col + (x + vx - row->c0); - darkness[y * sw4 + x] = cell->darkness < 0 - ? 255 - FOW_DARKNESS - : 255 - cell->darkness; - face = cell->face [z]; if (face) @@ -1414,6 +1407,40 @@ glDisable (GL_TEXTURE_2D); glDisable (GL_BLEND); +} + +void +fow_texture (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) + PPCODE: +{ + int vx, vy; + int x, y; + int sw4 = (sw + 3) & ~3; + SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); + uint8_t *darkness = (uint8_t *)SvPVX (darkness_sv); + + memset (darkness, 255, sw4 * sh); + SvPOK_only (darkness_sv); + SvCUR_set (darkness_sv, sw4 * sh); + + vx = self->x + (self->w - sw + 1) / 2 - shift_x; + vy = self->y + (self->h - sh + 1) / 2 - shift_y; + + 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); + + darkness[y * sw4 + x] = cell->darkness < 0 + ? 255 - FOW_DARKNESS + : 255 - cell->darkness; + } + } EXTEND (SP, 3); PUSHs (sv_2mortal (newSViv (sw4)));