--- deliantra/Deliantra-Client/Client.xs 2006/04/16 07:25:29 1.42 +++ deliantra/Deliantra-Client/Client.xs 2006/04/18 01:36:12 1.49 @@ -1,3 +1,7 @@ +#ifdef _WIN32 +# include +#endif + #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -15,12 +19,20 @@ #include #include -#include -#include -#include -#include - -#include +#ifndef _WIN32 +# include +# include +# include +# include +# include +#else + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; +#endif #define FOW_DARKNESS 32 @@ -49,7 +61,14 @@ * reasonably well with bitstream vera */ PangoFontDescription *font = pango_context_get_font_description (context); - pango_font_description_set_absolute_size (font, self->base_height * (PANGO_SCALE * 8 / 10)); + + int height = self->base_height * (PANGO_SCALE * 8 / 10); + + if (pango_font_description_get_size (font) != height) + { + pango_font_description_set_absolute_size (font, height); + pango_layout_context_changed (self->pl); + } } static void @@ -92,7 +111,7 @@ int texs; maptex *tex; - uint32_t rows; + int32_t rows; maprow *row; } *CFClient__Map; @@ -197,6 +216,7 @@ map_blank (CFClient__Map self, int x0, int y0, int w, int h) { int x, y; + maprow *row; for (y = y0; y < y0 + h; y++) if (y >= 0) @@ -204,7 +224,7 @@ if (y >= self->rows) break; - maprow *row = self->row + y; + row = self->row + y; for (x = x0; x < x0 + w; x++) if (x >= row->c0) @@ -231,7 +251,9 @@ void lowdelay (int fd, int val = 1) CODE: +#ifndef _WIN32 setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); +#endif char * gl_version () @@ -287,10 +309,17 @@ fmt.palette = NULL; fmt.BitsPerPixel = 32; fmt.BytesPerPixel = 4; +#if SDL_BYTEORDER == SDL_LIL_ENDIAN fmt.Rmask = 0x000000ff; fmt.Gmask = 0x0000ff00; fmt.Bmask = 0x00ff0000; fmt.Amask = 0xff000000; +#else + fmt.Rmask = 0xff000000; + fmt.Gmask = 0x00ff0000; + fmt.Bmask = 0x0000ff00; + fmt.Amask = 0x000000ff; +#endif fmt.Rloss = 0; fmt.Gloss = 0; fmt.Bloss = 0; @@ -314,7 +343,7 @@ SDL_UnlockSurface (surface2); 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_INT_8_8_8_8_REV))); + PUSHs (sv_2mortal (newSViv (GL_UNSIGNED_BYTE))); SDL_FreeSurface (surface); SDL_FreeSurface (surface2); @@ -393,6 +422,14 @@ pango_layout_set_markup (self->pl, text, textlen); } +SV * +get_text (CFClient::Layout self) + CODE: + RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); + SvUTF8_on (RETVAL); + OUTPUT: + RETVAL + void set_height (CFClient::Layout self, int base_height) CODE: @@ -567,19 +604,34 @@ self->texs *= 2; } - maptex *tex = self->tex + texid; + { + maptex *tex = self->tex + texid; - tex->name = name; - tex->w = w; - tex->h = h; - tex->s = s; - tex->t = t; - tex->r = r; - tex->g = g; - tex->b = b; - tex->a = a; + tex->name = name; + tex->w = w; + tex->h = h; + tex->s = s; + tex->t = t; + tex->r = r; + tex->g = g; + tex->b = b; + tex->a = a; + } } +int +ox (CFClient::Map self) + ALIAS: + oy = 1 + CODE: + switch (ix) + { + case 0: RETVAL = self->ox; break; + case 1: RETVAL = self->oy; break; + } + OUTPUT: + RETVAL + void scroll (CFClient::Map self, int dx, int dy) CODE: @@ -594,8 +646,8 @@ else if (dy < 0) map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); - self->x += dx; self->ox += dx; - self->y += dy; self->oy += dy; + self->ox += dx; self->x += dx; + self->oy += dy; self->y += dy; while (self->y < 0) { @@ -606,45 +658,34 @@ } } -int -ox (CFClient::Map self) - ALIAS: - oy = 1 - CODE: - switch (ix) - { - case 0: RETVAL = self->ox; break; - case 1: RETVAL = self->oy; break; - } - OUTPUT: - RETVAL - void map1a_update (CFClient::Map self, SV *data_) CODE: { uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); uint8_t *data_end = (uint8_t *)SvEND (data_); - + mapcell *cell; + int x, y, flags; + while (data < data_end) { - int flags = (data [0] << 8) + data [1]; data += 2; + flags = (data [0] << 8) + data [1]; data += 2; - int x = ((flags >> 10) & 63) + self->x; - int y = ((flags >> 4) & 63) + self->y; + x = ((flags >> 10) & 63) + self->x; + y = ((flags >> 4) & 63) + self->y; - mapcell *cell = map_get_cell (self, x, y); + cell = map_get_cell (self, x, y); if (flags & 15) { - if (cell->darkness < 0) // && x < self->w && y < self->h) + if (cell->darkness < 0) { cell->darkness = 0; cell->face [0] = 0; cell->face [1] = 0; cell->face [2] = 0; } - + cell->darkness = flags & 8 ? *data++ : 255; //TODO: don't trust server data to be in-range(!) @@ -733,15 +774,20 @@ draw (CFClient::Map self, int shift_x, int shift_y, int x0, int y0, int sw, int sh) PPCODE: { + 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); - int vx = self->x + (self->w - sw) / 2 - shift_x; - int vy = self->y + (self->h - sh) / 2 - shift_y; + vx = self->x + (self->w - sw) / 2 - shift_x; + vy = self->y + (self->h - sh) / 2 - shift_y; /* int vx = self->vx = self->w >= sw @@ -760,12 +806,10 @@ glEnable (GL_TEXTURE_2D); glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - int x, y, z; - - int last_name = 0; - glBegin (GL_QUADS); + last_name = 0; + for (z = 0; z < 3; z++) for (y = 0; y < sh; y++) if (0 <= y + vy && y + vy < self->rows) @@ -781,7 +825,7 @@ ? 255 - FOW_DARKNESS : 255 - cell->darkness; - mapface face = cell->face [z]; + face = cell->face [z]; if (face) { @@ -851,7 +895,6 @@ if (row && row->c0 <= x && x < row->c1) { mapcell *cell = row->col + (x - row->c0); - uint8_t flags = 0; if (cell->face [0]) flags |= 1; @@ -895,13 +938,14 @@ PPCODE: { int x, y, z; + int w, h; int x1, y1; if (*data++ != 0) return; /* version mismatch */ - int w = *data++ << 8; w |= *data++; - int h = *data++ << 8; h |= *data++; + w = *data++ << 8; w |= *data++; + h = *data++ << 8; h |= *data++; // we need to do this 'cause we don't keep an absolute coord system for rows // TODO: treat rows as we treat